mirror of
https://github.com/rkd77/elinks.git
synced 2025-01-03 14:57:44 -05:00
[spidermonkey] Some code related to compartments. Progress.
This commit is contained in:
parent
b0ced9308b
commit
873797935c
@ -54,6 +54,7 @@ struct ecmascript_interpreter {
|
|||||||
* to redraw. */
|
* to redraw. */
|
||||||
unsigned int onload_snippets_cache_id;
|
unsigned int onload_snippets_cache_id;
|
||||||
void *ac;
|
void *ac;
|
||||||
|
void *ac2;
|
||||||
void *ar;
|
void *ar;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -261,7 +261,8 @@ spidermonkey_get_interpreter(struct ecmascript_interpreter *interpreter)
|
|||||||
JS::RootedObject window_obj(ctx, JS_NewGlobalObject(ctx, &window_class, NULL, JS::FireOnNewGlobalHook, options));
|
JS::RootedObject window_obj(ctx, JS_NewGlobalObject(ctx, &window_class, NULL, JS::FireOnNewGlobalHook, options));
|
||||||
|
|
||||||
if (window_obj) {
|
if (window_obj) {
|
||||||
interpreter->ac = new JSAutoCompartment(ctx, window_obj);
|
interpreter->ac = window_obj;
|
||||||
|
interpreter->ac2 = new JSAutoCompartment(ctx, window_obj);
|
||||||
} else {
|
} else {
|
||||||
goto release_and_fail;
|
goto release_and_fail;
|
||||||
}
|
}
|
||||||
@ -277,7 +278,7 @@ spidermonkey_get_interpreter(struct ecmascript_interpreter *interpreter)
|
|||||||
if (!spidermonkey_DefineFunctions(ctx, window_obj, window_funcs)) {
|
if (!spidermonkey_DefineFunctions(ctx, window_obj, window_funcs)) {
|
||||||
goto release_and_fail;
|
goto release_and_fail;
|
||||||
}
|
}
|
||||||
JS_SetPrivate(window_obj, interpreter->vs); /* to @window_class */
|
//JS_SetPrivate(window_obj, interpreter); /* to @window_class */
|
||||||
|
|
||||||
document_obj = spidermonkey_InitClass(ctx, window_obj, NULL,
|
document_obj = spidermonkey_InitClass(ctx, window_obj, NULL,
|
||||||
&document_class, NULL, 0,
|
&document_class, NULL, 0,
|
||||||
@ -287,7 +288,6 @@ spidermonkey_get_interpreter(struct ecmascript_interpreter *interpreter)
|
|||||||
if (!document_obj) {
|
if (!document_obj) {
|
||||||
goto release_and_fail;
|
goto release_and_fail;
|
||||||
}
|
}
|
||||||
JS_SetPrivate(document_obj, interpreter->vs);
|
|
||||||
|
|
||||||
forms_obj = spidermonkey_InitClass(ctx, document_obj, NULL,
|
forms_obj = spidermonkey_InitClass(ctx, document_obj, NULL,
|
||||||
&forms_class, NULL, 0,
|
&forms_class, NULL, 0,
|
||||||
@ -297,7 +297,6 @@ spidermonkey_get_interpreter(struct ecmascript_interpreter *interpreter)
|
|||||||
if (!forms_obj) {
|
if (!forms_obj) {
|
||||||
goto release_and_fail;
|
goto release_and_fail;
|
||||||
}
|
}
|
||||||
// JS_SetPrivate(forms_obj, interpreter->vs);
|
|
||||||
|
|
||||||
history_obj = spidermonkey_InitClass(ctx, window_obj, NULL,
|
history_obj = spidermonkey_InitClass(ctx, window_obj, NULL,
|
||||||
&history_class, NULL, 0,
|
&history_class, NULL, 0,
|
||||||
@ -307,8 +306,6 @@ spidermonkey_get_interpreter(struct ecmascript_interpreter *interpreter)
|
|||||||
if (!history_obj) {
|
if (!history_obj) {
|
||||||
goto release_and_fail;
|
goto release_and_fail;
|
||||||
}
|
}
|
||||||
// JS_SetPrivate(history_obj, interpreter->vs);
|
|
||||||
|
|
||||||
|
|
||||||
location_obj = spidermonkey_InitClass(ctx, window_obj, NULL,
|
location_obj = spidermonkey_InitClass(ctx, window_obj, NULL,
|
||||||
&location_class, NULL, 0,
|
&location_class, NULL, 0,
|
||||||
@ -318,8 +315,6 @@ spidermonkey_get_interpreter(struct ecmascript_interpreter *interpreter)
|
|||||||
if (!location_obj) {
|
if (!location_obj) {
|
||||||
goto release_and_fail;
|
goto release_and_fail;
|
||||||
}
|
}
|
||||||
// JS_SetPrivate(location_obj, interpreter->vs);
|
|
||||||
|
|
||||||
|
|
||||||
menubar_obj = JS_InitClass(ctx, window_obj, nullptr,
|
menubar_obj = JS_InitClass(ctx, window_obj, nullptr,
|
||||||
&menubar_class, NULL, 0,
|
&menubar_class, NULL, 0,
|
||||||
@ -346,8 +341,6 @@ spidermonkey_get_interpreter(struct ecmascript_interpreter *interpreter)
|
|||||||
if (!navigator_obj) {
|
if (!navigator_obj) {
|
||||||
goto release_and_fail;
|
goto release_and_fail;
|
||||||
}
|
}
|
||||||
// JS_SetPrivate(navigator_obj, interpreter->vs);
|
|
||||||
|
|
||||||
JS_SetCompartmentPrivate(js::GetContextCompartment(ctx), interpreter);
|
JS_SetCompartmentPrivate(js::GetContextCompartment(ctx), interpreter);
|
||||||
|
|
||||||
return ctx;
|
return ctx;
|
||||||
@ -367,7 +360,7 @@ spidermonkey_put_interpreter(struct ecmascript_interpreter *interpreter)
|
|||||||
|
|
||||||
ctx = interpreter->backend_data;
|
ctx = interpreter->backend_data;
|
||||||
if (interpreter->ac) {
|
if (interpreter->ac) {
|
||||||
delete (JSAutoCompartment *)interpreter->ac;
|
//delete (JSAutoCompartment *)interpreter->ac;
|
||||||
}
|
}
|
||||||
if (interpreter->ar) {
|
if (interpreter->ar) {
|
||||||
delete (JSAutoRequest *)interpreter->ar;
|
delete (JSAutoRequest *)interpreter->ar;
|
||||||
@ -391,6 +384,8 @@ spidermonkey_eval(struct ecmascript_interpreter *interpreter,
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
ctx = interpreter->backend_data;
|
ctx = interpreter->backend_data;
|
||||||
|
JS_BeginRequest(ctx);
|
||||||
|
JSCompartment *comp = JS_EnterCompartment(ctx, interpreter->ac);
|
||||||
|
|
||||||
interpreter->heartbeat = add_heartbeat(interpreter);
|
interpreter->heartbeat = add_heartbeat(interpreter);
|
||||||
interpreter->ret = ret;
|
interpreter->ret = ret;
|
||||||
@ -401,6 +396,8 @@ spidermonkey_eval(struct ecmascript_interpreter *interpreter,
|
|||||||
|
|
||||||
JS::Evaluate(ctx, options, code->source, code->length, &r_val);
|
JS::Evaluate(ctx, options, code->source, code->length, &r_val);
|
||||||
done_heartbeat(interpreter->heartbeat);
|
done_heartbeat(interpreter->heartbeat);
|
||||||
|
JS_LeaveCompartment(ctx, comp);
|
||||||
|
JS_EndRequest(ctx);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -411,6 +408,7 @@ spidermonkey_eval_stringback(struct ecmascript_interpreter *interpreter,
|
|||||||
bool ret;
|
bool ret;
|
||||||
JSContext *ctx;
|
JSContext *ctx;
|
||||||
JS::Value rval;
|
JS::Value rval;
|
||||||
|
unsigned char *result = NULL;
|
||||||
|
|
||||||
assert(interpreter);
|
assert(interpreter);
|
||||||
if (!js_module_init_ok) return NULL;
|
if (!js_module_init_ok) return NULL;
|
||||||
@ -418,6 +416,9 @@ spidermonkey_eval_stringback(struct ecmascript_interpreter *interpreter,
|
|||||||
interpreter->ret = NULL;
|
interpreter->ret = NULL;
|
||||||
interpreter->heartbeat = add_heartbeat(interpreter);
|
interpreter->heartbeat = add_heartbeat(interpreter);
|
||||||
|
|
||||||
|
JS_BeginRequest(ctx);
|
||||||
|
JSCompartment *comp = JS_EnterCompartment(ctx, interpreter->ac);
|
||||||
|
|
||||||
JS::RootedObject cg(ctx, JS::CurrentGlobalOrNull(ctx));
|
JS::RootedObject cg(ctx, JS::CurrentGlobalOrNull(ctx));
|
||||||
JS::RootedValue r_rval(ctx, rval);
|
JS::RootedValue r_rval(ctx, rval);
|
||||||
JS::CompileOptions options(ctx);
|
JS::CompileOptions options(ctx);
|
||||||
@ -431,14 +432,17 @@ spidermonkey_eval_stringback(struct ecmascript_interpreter *interpreter,
|
|||||||
done_heartbeat(interpreter->heartbeat);
|
done_heartbeat(interpreter->heartbeat);
|
||||||
|
|
||||||
if (ret == false) {
|
if (ret == false) {
|
||||||
return NULL;
|
result = NULL;
|
||||||
}
|
}
|
||||||
if (r_rval.isNullOrUndefined()) {
|
else if (r_rval.isNullOrUndefined()) {
|
||||||
/* Undefined value. */
|
/* Undefined value. */
|
||||||
return NULL;
|
result = NULL;
|
||||||
|
} else {
|
||||||
|
result = stracpy(JS_EncodeString(ctx, r_rval.toString()));
|
||||||
}
|
}
|
||||||
|
JS_LeaveCompartment(ctx, comp);
|
||||||
return stracpy(JS_EncodeString(ctx, r_rval.toString()));
|
JS_EndRequest(ctx);
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -449,12 +453,16 @@ spidermonkey_eval_boolback(struct ecmascript_interpreter *interpreter,
|
|||||||
JSContext *ctx;
|
JSContext *ctx;
|
||||||
JS::Value rval;
|
JS::Value rval;
|
||||||
int ret;
|
int ret;
|
||||||
|
int result = 0;
|
||||||
|
|
||||||
assert(interpreter);
|
assert(interpreter);
|
||||||
if (!js_module_init_ok) return 0;
|
if (!js_module_init_ok) return 0;
|
||||||
ctx = interpreter->backend_data;
|
ctx = interpreter->backend_data;
|
||||||
interpreter->ret = NULL;
|
interpreter->ret = NULL;
|
||||||
|
|
||||||
|
JSCompartment *comp = JS_EnterCompartment(ctx, interpreter->ac);
|
||||||
|
JS_BeginRequest(ctx);
|
||||||
|
|
||||||
JS::RootedFunction fun(ctx);
|
JS::RootedFunction fun(ctx);
|
||||||
|
|
||||||
JS::CompileOptions options(ctx);
|
JS::CompileOptions options(ctx);
|
||||||
@ -471,17 +479,22 @@ spidermonkey_eval_boolback(struct ecmascript_interpreter *interpreter,
|
|||||||
done_heartbeat(interpreter->heartbeat);
|
done_heartbeat(interpreter->heartbeat);
|
||||||
|
|
||||||
if (ret == 2) { /* onClick="history.back()" */
|
if (ret == 2) { /* onClick="history.back()" */
|
||||||
return 0;
|
result = 0;
|
||||||
}
|
}
|
||||||
if (ret == false) {
|
else if (ret == false) {
|
||||||
return -1;
|
result = -1;
|
||||||
}
|
}
|
||||||
if (r_val.isUndefined()) {
|
else if (r_val.isUndefined()) {
|
||||||
/* Undefined value. */
|
/* Undefined value. */
|
||||||
return -1;
|
result = -1;
|
||||||
|
} else {
|
||||||
|
result = r_val.toBoolean();
|
||||||
}
|
}
|
||||||
|
|
||||||
return r_val.toBoolean();
|
JS_LeaveCompartment(ctx, comp);
|
||||||
|
JS_EndRequest(ctx);
|
||||||
|
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
struct module spidermonkey_module = struct_module(
|
struct module spidermonkey_module = struct_module(
|
||||||
|
@ -10,6 +10,7 @@
|
|||||||
|
|
||||||
#include "elinks.h"
|
#include "elinks.h"
|
||||||
|
|
||||||
|
#include "ecmascript/ecmascript.h"
|
||||||
#include "ecmascript/spidermonkey/util.h"
|
#include "ecmascript/spidermonkey/util.h"
|
||||||
#include <jsfriendapi.h>
|
#include <jsfriendapi.h>
|
||||||
|
|
||||||
@ -70,15 +71,20 @@ document_get_property_cookie(JSContext *ctx, unsigned int argc, JS::Value *vp)
|
|||||||
{
|
{
|
||||||
JS::CallArgs args = CallArgsFromVp(argc, vp);
|
JS::CallArgs args = CallArgsFromVp(argc, vp);
|
||||||
JS::RootedObject hobj(ctx, &args.thisv().toObject());
|
JS::RootedObject hobj(ctx, &args.thisv().toObject());
|
||||||
JS::RootedObject parent_win(ctx, js::GetGlobalForObjectCrossCompartment(hobj));
|
|
||||||
|
JSCompartment *comp = js::GetContextCompartment(ctx);
|
||||||
|
|
||||||
|
if (!comp) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
struct ecmascript_interpreter *interpreter = JS_GetCompartmentPrivate(comp);
|
||||||
|
|
||||||
struct view_state *vs;
|
struct view_state *vs;
|
||||||
struct string *cookies;
|
struct string *cookies;
|
||||||
|
|
||||||
assert(JS_InstanceOf(ctx, parent_win, &window_class, NULL));
|
vs = interpreter->vs;
|
||||||
if_assert_failed return false;
|
|
||||||
|
|
||||||
vs = JS_GetInstancePrivate(ctx, parent_win,
|
|
||||||
&window_class, NULL);
|
|
||||||
if (!vs) {
|
if (!vs) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -102,15 +108,19 @@ document_set_property_cookie(JSContext *ctx, unsigned int argc, JS::Value *vp)
|
|||||||
{
|
{
|
||||||
JS::CallArgs args = CallArgsFromVp(argc, vp);
|
JS::CallArgs args = CallArgsFromVp(argc, vp);
|
||||||
JS::RootedObject hobj(ctx, &args.thisv().toObject());
|
JS::RootedObject hobj(ctx, &args.thisv().toObject());
|
||||||
JS::RootedObject parent_win(ctx, js::GetGlobalForObjectCrossCompartment(hobj));
|
|
||||||
|
JSCompartment *comp = js::GetContextCompartment(ctx);
|
||||||
|
|
||||||
|
if (!comp) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
struct ecmascript_interpreter *interpreter = JS_GetCompartmentPrivate(comp);
|
||||||
|
|
||||||
struct view_state *vs;
|
struct view_state *vs;
|
||||||
struct string *cookies;
|
struct string *cookies;
|
||||||
|
|
||||||
assert(JS_InstanceOf(ctx, parent_win, &window_class, NULL));
|
vs = interpreter->vs;
|
||||||
if_assert_failed return false;
|
|
||||||
|
|
||||||
vs = JS_GetInstancePrivate(ctx, parent_win,
|
|
||||||
&window_class, NULL);
|
|
||||||
if (!vs) {
|
if (!vs) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -141,15 +151,20 @@ document_set_property_location(JSContext *ctx, unsigned int argc, JS::Value *vp)
|
|||||||
{
|
{
|
||||||
JS::CallArgs args = CallArgsFromVp(argc, vp);
|
JS::CallArgs args = CallArgsFromVp(argc, vp);
|
||||||
JS::RootedObject hobj(ctx, &args.thisv().toObject());
|
JS::RootedObject hobj(ctx, &args.thisv().toObject());
|
||||||
JS::RootedObject parent_win(ctx, js::GetGlobalForObjectCrossCompartment(hobj));
|
|
||||||
|
JSCompartment *comp = js::GetContextCompartment(ctx);
|
||||||
|
|
||||||
|
if (!comp) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
struct ecmascript_interpreter *interpreter = JS_GetCompartmentPrivate(comp);
|
||||||
|
|
||||||
struct view_state *vs;
|
struct view_state *vs;
|
||||||
struct document_view *doc_view;
|
struct document_view *doc_view;
|
||||||
|
|
||||||
assert(JS_InstanceOf(ctx, parent_win, &window_class, NULL));
|
vs = interpreter->vs;
|
||||||
if_assert_failed return false;
|
|
||||||
|
|
||||||
vs = JS_GetInstancePrivate(ctx, parent_win,
|
|
||||||
&window_class, NULL);
|
|
||||||
if (!vs) {
|
if (!vs) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -165,17 +180,21 @@ document_get_property_referrer(JSContext *ctx, unsigned int argc, JS::Value *vp)
|
|||||||
{
|
{
|
||||||
JS::CallArgs args = CallArgsFromVp(argc, vp);
|
JS::CallArgs args = CallArgsFromVp(argc, vp);
|
||||||
JS::RootedObject hobj(ctx, &args.thisv().toObject());
|
JS::RootedObject hobj(ctx, &args.thisv().toObject());
|
||||||
JS::RootedObject parent_win(ctx, js::GetGlobalForObjectCrossCompartment(hobj));
|
|
||||||
|
JSCompartment *comp = js::GetContextCompartment(ctx);
|
||||||
|
|
||||||
|
if (!comp) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
struct ecmascript_interpreter *interpreter = JS_GetCompartmentPrivate(comp);
|
||||||
|
|
||||||
struct view_state *vs;
|
struct view_state *vs;
|
||||||
struct document_view *doc_view;
|
struct document_view *doc_view;
|
||||||
struct document *document;
|
struct document *document;
|
||||||
struct session *ses;
|
struct session *ses;
|
||||||
|
|
||||||
assert(JS_InstanceOf(ctx, parent_win, &window_class, NULL));
|
vs = interpreter->vs;
|
||||||
if_assert_failed return false;
|
|
||||||
|
|
||||||
vs = JS_GetInstancePrivate(ctx, parent_win,
|
|
||||||
&window_class, NULL);
|
|
||||||
|
|
||||||
if (!vs) {
|
if (!vs) {
|
||||||
return false;
|
return false;
|
||||||
@ -229,16 +248,20 @@ document_get_property_title(JSContext *ctx, unsigned int argc, JS::Value *vp)
|
|||||||
{
|
{
|
||||||
JS::CallArgs args = CallArgsFromVp(argc, vp);
|
JS::CallArgs args = CallArgsFromVp(argc, vp);
|
||||||
JS::RootedObject hobj(ctx, &args.thisv().toObject());
|
JS::RootedObject hobj(ctx, &args.thisv().toObject());
|
||||||
JS::RootedObject parent_win(ctx, js::GetGlobalForObjectCrossCompartment(hobj));
|
|
||||||
|
JSCompartment *comp = js::GetContextCompartment(ctx);
|
||||||
|
|
||||||
|
if (!comp) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
struct ecmascript_interpreter *interpreter = JS_GetCompartmentPrivate(comp);
|
||||||
struct view_state *vs;
|
struct view_state *vs;
|
||||||
struct document_view *doc_view;
|
struct document_view *doc_view;
|
||||||
struct document *document;
|
struct document *document;
|
||||||
|
|
||||||
assert(JS_InstanceOf(ctx, parent_win, &window_class, NULL));
|
vs = interpreter->vs;
|
||||||
if_assert_failed return false;
|
|
||||||
|
|
||||||
vs = JS_GetInstancePrivate(ctx, parent_win,
|
|
||||||
&window_class, NULL);
|
|
||||||
if (!vs) {
|
if (!vs) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -254,19 +277,23 @@ document_set_property_title(JSContext *ctx, int argc, JS::Value *vp)
|
|||||||
{
|
{
|
||||||
JS::CallArgs args = CallArgsFromVp(argc, vp);
|
JS::CallArgs args = CallArgsFromVp(argc, vp);
|
||||||
JS::RootedObject hobj(ctx, &args.thisv().toObject());
|
JS::RootedObject hobj(ctx, &args.thisv().toObject());
|
||||||
// JS::RootedObject parent_win(ctx, js::GetGlobalForObjectCrossCompartment(hobj));
|
|
||||||
|
JSCompartment *comp = js::GetContextCompartment(ctx);
|
||||||
|
|
||||||
|
if (!comp) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
struct ecmascript_interpreter *interpreter = JS_GetCompartmentPrivate(comp);
|
||||||
|
|
||||||
|
|
||||||
|
JS::RootedObject parent_win(ctx, js::GetGlobalForObjectCrossCompartment(hobj));
|
||||||
struct view_state *vs;
|
struct view_state *vs;
|
||||||
struct document_view *doc_view;
|
struct document_view *doc_view;
|
||||||
struct document *document;
|
struct document *document;
|
||||||
|
|
||||||
assert(JS_InstanceOf(ctx, hobj, &document_class, NULL));
|
vs = interpreter->vs;
|
||||||
if_assert_failed return false;
|
|
||||||
|
|
||||||
// assert(JS_InstanceOf(ctx, parent_win, &window_class, NULL));
|
|
||||||
// if_assert_failed return false;
|
|
||||||
|
|
||||||
vs = JS_GetInstancePrivate(ctx, hobj,
|
|
||||||
&document_class, NULL);
|
|
||||||
if (!vs || !vs->doc_view) {
|
if (!vs || !vs->doc_view) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -283,16 +310,20 @@ document_get_property_url(JSContext *ctx, unsigned int argc, JS::Value *vp)
|
|||||||
{
|
{
|
||||||
JS::CallArgs args = CallArgsFromVp(argc, vp);
|
JS::CallArgs args = CallArgsFromVp(argc, vp);
|
||||||
JS::RootedObject hobj(ctx, &args.thisv().toObject());
|
JS::RootedObject hobj(ctx, &args.thisv().toObject());
|
||||||
JS::RootedObject parent_win(ctx, js::GetGlobalForObjectCrossCompartment(hobj));
|
JSCompartment *comp = js::GetContextCompartment(ctx);
|
||||||
|
|
||||||
|
if (!comp) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
struct ecmascript_interpreter *interpreter = JS_GetCompartmentPrivate(comp);
|
||||||
|
|
||||||
struct view_state *vs;
|
struct view_state *vs;
|
||||||
struct document_view *doc_view;
|
struct document_view *doc_view;
|
||||||
struct document *document;
|
struct document *document;
|
||||||
|
|
||||||
assert(JS_InstanceOf(ctx, parent_win, &window_class, NULL));
|
vs = interpreter->vs;
|
||||||
if_assert_failed return false;
|
|
||||||
|
|
||||||
vs = JS_GetInstancePrivate(ctx, parent_win,
|
|
||||||
&window_class, NULL);
|
|
||||||
if (!vs) {
|
if (!vs) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -315,16 +346,19 @@ document_set_property_url(JSContext *ctx, int argc, JS::Value *vp)
|
|||||||
{
|
{
|
||||||
JS::CallArgs args = CallArgsFromVp(argc, vp);
|
JS::CallArgs args = CallArgsFromVp(argc, vp);
|
||||||
JS::RootedObject hobj(ctx, &args.thisv().toObject());
|
JS::RootedObject hobj(ctx, &args.thisv().toObject());
|
||||||
JS::RootedObject parent_win(ctx, js::GetGlobalForObjectCrossCompartment(hobj));
|
|
||||||
|
JSCompartment *comp = js::GetContextCompartment(ctx);
|
||||||
|
|
||||||
|
if (!comp) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
struct ecmascript_interpreter *interpreter = JS_GetCompartmentPrivate(comp);
|
||||||
struct view_state *vs;
|
struct view_state *vs;
|
||||||
struct document_view *doc_view;
|
struct document_view *doc_view;
|
||||||
struct document *document;
|
struct document *document;
|
||||||
|
|
||||||
assert(JS_InstanceOf(ctx, parent_win, &window_class, NULL));
|
vs = interpreter->vs;
|
||||||
if_assert_failed return false;
|
|
||||||
|
|
||||||
vs = JS_GetInstancePrivate(ctx, parent_win,
|
|
||||||
&window_class, NULL);
|
|
||||||
if (!vs) {
|
if (!vs) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -359,18 +393,21 @@ document_get_property(JSContext *ctx, JS::HandleObject hobj, JS::HandleId hid, J
|
|||||||
struct document *document;
|
struct document *document;
|
||||||
struct form *form;
|
struct form *form;
|
||||||
unsigned char *string;
|
unsigned char *string;
|
||||||
|
JSCompartment *comp = js::GetContextCompartment(ctx);
|
||||||
|
|
||||||
|
if (!comp) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
struct ecmascript_interpreter *interpreter = JS_GetCompartmentPrivate(comp);
|
||||||
|
|
||||||
|
|
||||||
JSClass* classPtr = JS_GetClass(hobj);
|
JSClass* classPtr = JS_GetClass(hobj);
|
||||||
|
|
||||||
if (classPtr != &document_class)
|
if (classPtr != &document_class)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
parent_win = js::GetGlobalForObjectCrossCompartment(hobj);
|
vs = interpreter->vs;
|
||||||
assert(JS_InstanceOf(ctx, parent_win, &window_class, NULL));
|
|
||||||
if_assert_failed return false;
|
|
||||||
|
|
||||||
vs = JS_GetInstancePrivate(ctx, parent_win,
|
|
||||||
&window_class, NULL);
|
|
||||||
doc_view = vs->doc_view;
|
doc_view = vs->doc_view;
|
||||||
document = doc_view->document;
|
document = doc_view->document;
|
||||||
|
|
||||||
@ -410,7 +447,6 @@ document_write_do(JSContext *ctx, unsigned int argc, JS::Value *rval, int newlin
|
|||||||
|
|
||||||
struct ecmascript_interpreter *interpreter = JS_GetCompartmentPrivate(comp);
|
struct ecmascript_interpreter *interpreter = JS_GetCompartmentPrivate(comp);
|
||||||
JS::Value val;
|
JS::Value val;
|
||||||
// struct ecmascript_interpreter *interpreter = JS_GetContextPrivate(ctx);
|
|
||||||
struct string *ret = interpreter->ret;
|
struct string *ret = interpreter->ret;
|
||||||
JS::CallArgs args = JS::CallArgsFromVp(argc, rval);
|
JS::CallArgs args = JS::CallArgsFromVp(argc, rval);
|
||||||
|
|
||||||
|
File diff suppressed because it is too large
Load Diff
@ -190,6 +190,13 @@ location_get_property_href(JSContext *ctx, unsigned int argc, JS::Value *vp)
|
|||||||
JS::RootedObject hobj(ctx, &args.thisv().toObject());
|
JS::RootedObject hobj(ctx, &args.thisv().toObject());
|
||||||
|
|
||||||
struct view_state *vs;
|
struct view_state *vs;
|
||||||
|
JSCompartment *comp = js::GetContextCompartment(ctx);
|
||||||
|
|
||||||
|
if (!comp) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
struct ecmascript_interpreter *interpreter = JS_GetCompartmentPrivate(comp);
|
||||||
|
|
||||||
/* This can be called if @obj if not itself an instance of the
|
/* This can be called if @obj if not itself an instance of the
|
||||||
* appropriate class but has one in its prototype chain. Fail
|
* appropriate class but has one in its prototype chain. Fail
|
||||||
@ -197,12 +204,7 @@ location_get_property_href(JSContext *ctx, unsigned int argc, JS::Value *vp)
|
|||||||
if (!JS_InstanceOf(ctx, hobj, &location_class, NULL))
|
if (!JS_InstanceOf(ctx, hobj, &location_class, NULL))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
JS::RootedObject parent_win(ctx, GetGlobalForObjectCrossCompartment(hobj));
|
vs = interpreter->vs;
|
||||||
assert(JS_InstanceOf(ctx, parent_win, &window_class, NULL));
|
|
||||||
if_assert_failed return false;
|
|
||||||
|
|
||||||
vs = JS_GetInstancePrivate(ctx, parent_win,
|
|
||||||
&window_class, NULL);
|
|
||||||
if (!vs) {
|
if (!vs) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -227,6 +229,13 @@ location_set_property_href(JSContext *ctx, unsigned int argc, JS::Value *vp)
|
|||||||
|
|
||||||
struct view_state *vs;
|
struct view_state *vs;
|
||||||
struct document_view *doc_view;
|
struct document_view *doc_view;
|
||||||
|
JSCompartment *comp = js::GetContextCompartment(ctx);
|
||||||
|
|
||||||
|
if (!comp) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
struct ecmascript_interpreter *interpreter = JS_GetCompartmentPrivate(comp);
|
||||||
|
|
||||||
/* This can be called if @obj if not itself an instance of the
|
/* This can be called if @obj if not itself an instance of the
|
||||||
* appropriate class but has one in its prototype chain. Fail
|
* appropriate class but has one in its prototype chain. Fail
|
||||||
@ -234,12 +243,7 @@ location_set_property_href(JSContext *ctx, unsigned int argc, JS::Value *vp)
|
|||||||
if (!JS_InstanceOf(ctx, hobj, &location_class, NULL))
|
if (!JS_InstanceOf(ctx, hobj, &location_class, NULL))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
JS::RootedObject parent_win(ctx, GetGlobalForObjectCrossCompartment(hobj));
|
vs = interpreter->vs;
|
||||||
assert(JS_InstanceOf(ctx, parent_win, &window_class, NULL));
|
|
||||||
if_assert_failed return false;
|
|
||||||
|
|
||||||
vs = JS_GetInstancePrivate(ctx, parent_win,
|
|
||||||
&window_class, NULL);
|
|
||||||
if (!vs) {
|
if (!vs) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -97,6 +97,13 @@ unibar_get_property_visible(JSContext *ctx, unsigned int argc, JS::Value *vp)
|
|||||||
struct document_view *doc_view;
|
struct document_view *doc_view;
|
||||||
struct session_status *status;
|
struct session_status *status;
|
||||||
unsigned char *bar;
|
unsigned char *bar;
|
||||||
|
JSCompartment *comp = js::GetContextCompartment(ctx);
|
||||||
|
|
||||||
|
if (!comp) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
struct ecmascript_interpreter *interpreter = JS_GetCompartmentPrivate(comp);
|
||||||
|
|
||||||
/* This can be called if @obj if not itself an instance of either
|
/* This can be called if @obj if not itself an instance of either
|
||||||
* appropriate class but has one in its prototype chain. Fail
|
* appropriate class but has one in its prototype chain. Fail
|
||||||
@ -105,12 +112,7 @@ unibar_get_property_visible(JSContext *ctx, unsigned int argc, JS::Value *vp)
|
|||||||
&& !JS_InstanceOf(ctx, hobj, &statusbar_class, NULL))
|
&& !JS_InstanceOf(ctx, hobj, &statusbar_class, NULL))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
JS::RootedObject parent_win(ctx, js::GetGlobalForObjectCrossCompartment(hobj));
|
vs = interpreter->vs;
|
||||||
assert(JS_InstanceOf(ctx, parent_win, &window_class, NULL));
|
|
||||||
if_assert_failed return false;
|
|
||||||
|
|
||||||
vs = JS_GetInstancePrivate(ctx, parent_win,
|
|
||||||
&window_class, NULL);
|
|
||||||
if (!vs) {
|
if (!vs) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -148,6 +150,13 @@ unibar_set_property_visible(JSContext *ctx, unsigned int argc, JS::Value *vp)
|
|||||||
struct document_view *doc_view;
|
struct document_view *doc_view;
|
||||||
struct session_status *status;
|
struct session_status *status;
|
||||||
unsigned char *bar;
|
unsigned char *bar;
|
||||||
|
JSCompartment *comp = js::GetContextCompartment(ctx);
|
||||||
|
|
||||||
|
if (!comp) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
struct ecmascript_interpreter *interpreter = JS_GetCompartmentPrivate(comp);
|
||||||
|
|
||||||
/* This can be called if @obj if not itself an instance of either
|
/* This can be called if @obj if not itself an instance of either
|
||||||
* appropriate class but has one in its prototype chain. Fail
|
* appropriate class but has one in its prototype chain. Fail
|
||||||
@ -156,12 +165,7 @@ unibar_set_property_visible(JSContext *ctx, unsigned int argc, JS::Value *vp)
|
|||||||
&& !JS_InstanceOf(ctx, hobj, &statusbar_class, NULL))
|
&& !JS_InstanceOf(ctx, hobj, &statusbar_class, NULL))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
JS::RootedObject parent_win(ctx, js::GetGlobalForObjectCrossCompartment(hobj));
|
vs = interpreter->vs;
|
||||||
assert(JS_InstanceOf(ctx, parent_win, &window_class, NULL));
|
|
||||||
if_assert_failed return false;
|
|
||||||
|
|
||||||
vs = JS_GetInstancePrivate(ctx, parent_win,
|
|
||||||
&window_class, NULL);
|
|
||||||
if (!vs) {
|
if (!vs) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -135,14 +135,20 @@ static bool
|
|||||||
window_get_property(JSContext *ctx, JS::HandleObject hobj, JS::HandleId hid, JS::MutableHandleValue hvp)
|
window_get_property(JSContext *ctx, JS::HandleObject hobj, JS::HandleId hid, JS::MutableHandleValue hvp)
|
||||||
{
|
{
|
||||||
struct view_state *vs;
|
struct view_state *vs;
|
||||||
|
JSCompartment *comp = js::GetContextCompartment(ctx);
|
||||||
|
|
||||||
|
if (!comp) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
struct ecmascript_interpreter *interpreter = JS_GetCompartmentPrivate(comp);
|
||||||
/* This can be called if @obj if not itself an instance of the
|
/* This can be called if @obj if not itself an instance of the
|
||||||
* appropriate class but has one in its prototype chain. Fail
|
* appropriate class but has one in its prototype chain. Fail
|
||||||
* such calls. */
|
* such calls. */
|
||||||
if (!JS_InstanceOf(ctx, hobj, &window_class, NULL))
|
if (!JS_InstanceOf(ctx, hobj, &window_class, NULL))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
vs = JS_GetInstancePrivate(ctx, hobj, &window_class, NULL);
|
vs = interpreter->vs;
|
||||||
|
|
||||||
/* No need for special window.location measurements - when
|
/* No need for special window.location measurements - when
|
||||||
* location is then evaluated in string context, toString()
|
* location is then evaluated in string context, toString()
|
||||||
@ -188,6 +194,13 @@ window_alert(JSContext *ctx, unsigned int argc, JS::Value *rval)
|
|||||||
JSObject *obj = JS_THIS_OBJECT(ctx, rval);
|
JSObject *obj = JS_THIS_OBJECT(ctx, rval);
|
||||||
JS::RootedObject hobj(ctx, obj);
|
JS::RootedObject hobj(ctx, obj);
|
||||||
JS::CallArgs args = JS::CallArgsFromVp(argc, rval);
|
JS::CallArgs args = JS::CallArgsFromVp(argc, rval);
|
||||||
|
JSCompartment *comp = js::GetContextCompartment(ctx);
|
||||||
|
|
||||||
|
if (!comp) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
struct ecmascript_interpreter *interpreter = JS_GetCompartmentPrivate(comp);
|
||||||
|
|
||||||
// JS::Value *argv = JS_ARGV(ctx, rval);
|
// JS::Value *argv = JS_ARGV(ctx, rval);
|
||||||
struct view_state *vs;
|
struct view_state *vs;
|
||||||
@ -197,7 +210,7 @@ window_alert(JSContext *ctx, unsigned int argc, JS::Value *rval)
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
vs = JS_GetInstancePrivate(ctx, hobj, &window_class, nullptr);
|
vs = interpreter->vs;
|
||||||
|
|
||||||
if (argc != 1)
|
if (argc != 1)
|
||||||
return true;
|
return true;
|
||||||
@ -232,10 +245,17 @@ window_open(JSContext *ctx, unsigned int argc, JS::Value *rval)
|
|||||||
struct uri *uri;
|
struct uri *uri;
|
||||||
static time_t ratelimit_start;
|
static time_t ratelimit_start;
|
||||||
static int ratelimit_count;
|
static int ratelimit_count;
|
||||||
|
JSCompartment *comp = js::GetContextCompartment(ctx);
|
||||||
|
|
||||||
|
if (!comp) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
struct ecmascript_interpreter *interpreter = JS_GetCompartmentPrivate(comp);
|
||||||
|
|
||||||
if (!JS_InstanceOf(ctx, hobj, &window_class, &args)) return false;
|
if (!JS_InstanceOf(ctx, hobj, &window_class, &args)) return false;
|
||||||
|
|
||||||
vs = JS_GetInstancePrivate(ctx, hobj, &window_class, &args);
|
vs = interpreter->vs;
|
||||||
doc_view = vs->doc_view;
|
doc_view = vs->doc_view;
|
||||||
ses = doc_view->session;
|
ses = doc_view->session;
|
||||||
|
|
||||||
@ -438,8 +458,14 @@ window_set_property_status(JSContext *ctx, unsigned int argc, JS::Value *vp)
|
|||||||
}
|
}
|
||||||
|
|
||||||
JS::RootedObject hobj(ctx, &args.thisv().toObject());
|
JS::RootedObject hobj(ctx, &args.thisv().toObject());
|
||||||
|
JSCompartment *comp = js::GetContextCompartment(ctx);
|
||||||
|
|
||||||
struct view_state *vs = JS_GetInstancePrivate(ctx, hobj, &window_class, NULL);
|
if (!comp) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
struct ecmascript_interpreter *interpreter = JS_GetCompartmentPrivate(comp);
|
||||||
|
struct view_state *vs = interpreter->vs;
|
||||||
|
|
||||||
if (!vs) {
|
if (!vs) {
|
||||||
return true;
|
return true;
|
||||||
@ -460,10 +486,17 @@ window_get_property_top(JSContext *ctx, unsigned int argc, JS::Value *vp)
|
|||||||
struct document_view *doc_view;
|
struct document_view *doc_view;
|
||||||
struct document_view *top_view;
|
struct document_view *top_view;
|
||||||
JSObject *newjsframe;
|
JSObject *newjsframe;
|
||||||
|
JSCompartment *comp = js::GetContextCompartment(ctx);
|
||||||
|
|
||||||
|
if (!comp) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
struct ecmascript_interpreter *interpreter = JS_GetCompartmentPrivate(comp);
|
||||||
|
|
||||||
JS::RootedObject hobj(ctx, &args.thisv().toObject());
|
JS::RootedObject hobj(ctx, &args.thisv().toObject());
|
||||||
|
|
||||||
vs = JS_GetInstancePrivate(ctx, hobj, &window_class, NULL);
|
vs = interpreter->vs;
|
||||||
|
|
||||||
if (!vs) {
|
if (!vs) {
|
||||||
return false;
|
return false;
|
||||||
|
Loading…
Reference in New Issue
Block a user