diff --git a/configure.ac b/configure.ac index 4c1ec5ba..47872d7b 100644 --- a/configure.ac +++ b/configure.ac @@ -612,11 +612,11 @@ case "$with_spidermonkey" in ;; esac -for package in mozjs-38; do +for package in mozjs-45; do if test -n "$CONFIG_SPIDERMONKEY"; then break else - AC_MSG_CHECKING([for SpiderMonkey (mozjs-38) in pkg-config $package]) + AC_MSG_CHECKING([for SpiderMonkey (mozjs-45) in pkg-config $package]) if $PKG_CONFIG --cflags --libs $package > /dev/null 2>&AS_MESSAGE_LOG_FD; then SPIDERMONKEY_LIBS="$($PKG_CONFIG --libs $package)" SPIDERMONKEY_CFLAGS="$($PKG_CONFIG --cflags $package)" diff --git a/meson.build b/meson.build index b9d54c2b..777e5808 100644 --- a/meson.build +++ b/meson.build @@ -271,7 +271,7 @@ if conf_data.get('CONFIG_BZIP2') endif if conf_data.get('CONFIG_ECMASCRIPT') - mozjsdeps = dependency('mozjs-38') + mozjsdeps = dependency('mozjs-45') deps += mozjsdeps endif diff --git a/src/ecmascript/spidermonkey-shared.c b/src/ecmascript/spidermonkey-shared.c index 7f057fbd..8af6d565 100644 --- a/src/ecmascript/spidermonkey-shared.c +++ b/src/ecmascript/spidermonkey-shared.c @@ -8,6 +8,7 @@ #include "elinks.h" #include "ecmascript/spidermonkey-shared.h" +#include /** A shared runtime used for both user scripts (scripting/smjs/) and * scripts on web pages (ecmascript/spidermonkey/). diff --git a/src/ecmascript/spidermonkey-shared.h b/src/ecmascript/spidermonkey-shared.h index 782867fa..ee3fbae9 100644 --- a/src/ecmascript/spidermonkey-shared.h +++ b/src/ecmascript/spidermonkey-shared.h @@ -53,20 +53,20 @@ JSObject *spidermonkey_InitClass(JSContext *cx, JSObject *obj, JSPropertySpec *static_ps, const spidermonkeyFunctionSpec *static_fs); -static void undef_to_jsval(JSContext *ctx, jsval *vp); -static unsigned char *jsval_to_string(JSContext *ctx, jsval *vp); +static void undef_to_jsval(JSContext *ctx, JS::Value *vp); +static unsigned char *jsval_to_string(JSContext *ctx, JS::Value *vp); static unsigned char *jsid_to_string(JSContext *ctx, jsid *id); /* Inline functions */ static inline void -undef_to_jsval(JSContext *ctx, jsval *vp) +undef_to_jsval(JSContext *ctx, JS::Value *vp) { - *vp = JSVAL_NULL; + *vp = JS::NullValue(); } static inline unsigned char * -jsval_to_string(JSContext *ctx, jsval *vp) +jsval_to_string(JSContext *ctx, JS::Value *vp) { JS::RootedValue r_vp(ctx, *vp); JSString *str = r_vp.toString(); @@ -85,6 +85,6 @@ jsid_to_string(JSContext *ctx, jsid *id) } #define ELINKS_CAST_PROP_PARAMS JSObject *obj = (hobj.get()); \ - jsval *vp = (hvp.address()); + JS::Value *vp = (hvp.address()); #endif diff --git a/src/ecmascript/spidermonkey.c b/src/ecmascript/spidermonkey.c index 300124e6..a626eebb 100644 --- a/src/ecmascript/spidermonkey.c +++ b/src/ecmascript/spidermonkey.c @@ -11,6 +11,7 @@ #include "elinks.h" #include "ecmascript/spidermonkey/util.h" +#include #include "bfu/dialog.h" #include "cache/cache.h" @@ -66,6 +67,8 @@ error_reporter(JSContext *ctx, const char *message, JSErrorReport *report) unsigned char *strict, *exception, *warning, *error; struct string msg; + char *prefix = nullptr; + assert(interpreter && interpreter->vs && interpreter->vs->doc_view && ses && ses->tab); if_assert_failed goto reported; @@ -92,6 +95,20 @@ error_reporter(JSContext *ctx, const char *message, JSErrorReport *report) add_to_string(&msg, ":\n\n"); add_to_string(&msg, message); + if (report->filename) { + prefix = JS_smprintf("%s:", report->filename); + } + + if (report->lineno) { + char* tmp = prefix; + prefix = JS_smprintf("%s%u:%u ", tmp ? tmp : "", report->lineno, report->column); + JS_free(ctx, tmp); + } + + if (prefix) { + add_to_string(&msg, prefix); + } +#if 0 if (report->linebuf && report->tokenptr) { int pos = report->tokenptr - report->linebuf; @@ -100,6 +117,7 @@ error_reporter(JSContext *ctx, const char *message, JSErrorReport *report) pos - 2, " ", strlen(report->linebuf) - pos - 1, " "); } +#endif info_box(term, MSGBOX_FREE_TEXT, N_("JavaScript Error"), ALIGN_CENTER, msg.source); @@ -182,6 +200,7 @@ spidermonkey_get_interpreter(struct ecmascript_interpreter *interpreter) if (!forms_obj) { goto release_and_fail; } +// JS_SetPrivate(forms_obj, interpreter->vs); history_obj = spidermonkey_InitClass(ctx, window_obj, NULL, &history_class, NULL, 0, @@ -191,6 +210,8 @@ spidermonkey_get_interpreter(struct ecmascript_interpreter *interpreter) if (!history_obj) { goto release_and_fail; } +// JS_SetPrivate(history_obj, interpreter->vs); + location_obj = spidermonkey_InitClass(ctx, window_obj, NULL, &location_class, NULL, 0, @@ -200,8 +221,10 @@ spidermonkey_get_interpreter(struct ecmascript_interpreter *interpreter) if (!location_obj) { goto release_and_fail; } +// JS_SetPrivate(location_obj, interpreter->vs); - menubar_obj = JS_InitClass(ctx, window_obj, JS::NullPtr(), + + menubar_obj = JS_InitClass(ctx, window_obj, nullptr, &menubar_class, NULL, 0, unibar_props, NULL, NULL, NULL); @@ -210,7 +233,7 @@ spidermonkey_get_interpreter(struct ecmascript_interpreter *interpreter) } JS_SetPrivate(menubar_obj, "t"); /* to @menubar_class */ - statusbar_obj = JS_InitClass(ctx, window_obj, JS::NullPtr(), + statusbar_obj = JS_InitClass(ctx, window_obj, nullptr, &statusbar_class, NULL, 0, unibar_props, NULL, NULL, NULL); @@ -219,13 +242,14 @@ spidermonkey_get_interpreter(struct ecmascript_interpreter *interpreter) } JS_SetPrivate(statusbar_obj, "s"); /* to @statusbar_class */ - navigator_obj = JS_InitClass(ctx, window_obj, JS::NullPtr(), + navigator_obj = JS_InitClass(ctx, window_obj, nullptr, &navigator_class, NULL, 0, navigator_props, NULL, NULL, NULL); if (!navigator_obj) { goto release_and_fail; } +// JS_SetPrivate(navigator_obj, interpreter->vs); return ctx; @@ -252,7 +276,7 @@ spidermonkey_eval(struct ecmascript_interpreter *interpreter, struct string *code, struct string *ret) { JSContext *ctx; - jsval rval; + JS::Value rval; assert(interpreter); if (!js_module_init_ok) { @@ -267,7 +291,7 @@ spidermonkey_eval(struct ecmascript_interpreter *interpreter, JS::RootedValue r_val(ctx, rval); JS::CompileOptions options(ctx); - JS::Evaluate(ctx, cg, options, code->source, code->length, &r_val); + JS::Evaluate(ctx, options, code->source, code->length, &r_val); done_heartbeat(interpreter->heartbeat); } @@ -278,7 +302,7 @@ spidermonkey_eval_stringback(struct ecmascript_interpreter *interpreter, { bool ret; JSContext *ctx; - jsval rval; + JS::Value rval; assert(interpreter); if (!js_module_init_ok) return NULL; @@ -295,7 +319,7 @@ spidermonkey_eval_stringback(struct ecmascript_interpreter *interpreter, // .setCompileAndGo(true) // .setNoScriptRval(true); - ret = JS::Evaluate(ctx, cg, options, code->source, code->length, &r_rval); + ret = JS::Evaluate(ctx, options, code->source, code->length, &r_rval); done_heartbeat(interpreter->heartbeat); if (ret == false) { @@ -315,8 +339,7 @@ spidermonkey_eval_boolback(struct ecmascript_interpreter *interpreter, struct string *code) { JSContext *ctx; - JS::RootedFunction fun(ctx); - jsval rval; + JS::Value rval; int ret; assert(interpreter); @@ -324,9 +347,11 @@ spidermonkey_eval_boolback(struct ecmascript_interpreter *interpreter, ctx = interpreter->backend_data; interpreter->ret = NULL; + JS::RootedFunction fun(ctx); + JS::CompileOptions options(ctx); JS::AutoObjectVector ag(ctx); - if (!JS::CompileFunction(ctx, ag, options, "", 0, nullptr, code->source, + if (!JS::CompileFunction(ctx, ag, options, "aaa", 0, nullptr, code->source, code->length, &fun)) { return -1; }; diff --git a/src/ecmascript/spidermonkey/document.c b/src/ecmascript/spidermonkey/document.c index de5ec176..aca00e64 100644 --- a/src/ecmascript/spidermonkey/document.c +++ b/src/ecmascript/spidermonkey/document.c @@ -11,6 +11,7 @@ #include "elinks.h" #include "ecmascript/spidermonkey/util.h" +#include #include "bfu/dialog.h" #include "cache/cache.h" @@ -60,11 +61,11 @@ JSClass document_class = { #ifdef CONFIG_COOKIES static bool -document_get_property_cookie(JSContext *ctx, unsigned int argc, jsval *vp) +document_get_property_cookie(JSContext *ctx, unsigned int argc, JS::Value *vp) { JS::CallArgs args = CallArgsFromVp(argc, vp); JS::RootedObject hobj(ctx, &args.thisv().toObject()); - JS::RootedObject parent_win(ctx, JS_GetParent(hobj)); + JS::RootedObject parent_win(ctx, js::GetGlobalForObjectCrossCompartment(hobj)); struct view_state *vs; struct string *cookies; @@ -92,15 +93,14 @@ document_get_property_cookie(JSContext *ctx, unsigned int argc, jsval *vp) } static bool -document_set_property_cookie(JSContext *ctx, unsigned int argc, jsval *vp) +document_set_property_cookie(JSContext *ctx, unsigned int argc, JS::Value *vp) { JS::CallArgs args = CallArgsFromVp(argc, vp); JS::RootedObject hobj(ctx, &args.thisv().toObject()); - JS::RootedObject parent_win(ctx, JS_GetParent(hobj)); + JS::RootedObject parent_win(ctx, js::GetGlobalForObjectCrossCompartment(hobj)); struct view_state *vs; struct string *cookies; - parent_win = JS_GetParent(hobj); assert(JS_InstanceOf(ctx, parent_win, &window_class, NULL)); if_assert_failed return false; @@ -117,11 +117,11 @@ document_set_property_cookie(JSContext *ctx, unsigned int argc, jsval *vp) #endif static bool -document_get_property_location(JSContext *ctx, unsigned int argc, jsval *vp) +document_get_property_location(JSContext *ctx, unsigned int argc, JS::Value *vp) { JS::CallArgs args = CallArgsFromVp(argc, vp); JS::RootedObject hobj(ctx, &args.thisv().toObject()); - JS::RootedObject parent_win(ctx, JS_GetParent(hobj)); + JS::RootedObject parent_win(ctx, js::GetGlobalForObjectCrossCompartment(hobj)); assert(JS_InstanceOf(ctx, parent_win, &window_class, NULL)); if_assert_failed return false; @@ -132,11 +132,11 @@ document_get_property_location(JSContext *ctx, unsigned int argc, jsval *vp) } static bool -document_set_property_location(JSContext *ctx, unsigned int argc, jsval *vp) +document_set_property_location(JSContext *ctx, unsigned int argc, JS::Value *vp) { JS::CallArgs args = CallArgsFromVp(argc, vp); JS::RootedObject hobj(ctx, &args.thisv().toObject()); - JS::RootedObject parent_win(ctx, JS_GetParent(hobj)); + JS::RootedObject parent_win(ctx, js::GetGlobalForObjectCrossCompartment(hobj)); struct view_state *vs; struct document_view *doc_view; @@ -156,11 +156,11 @@ document_set_property_location(JSContext *ctx, unsigned int argc, jsval *vp) static bool -document_get_property_referrer(JSContext *ctx, unsigned int argc, jsval *vp) +document_get_property_referrer(JSContext *ctx, unsigned int argc, JS::Value *vp) { JS::CallArgs args = CallArgsFromVp(argc, vp); JS::RootedObject hobj(ctx, &args.thisv().toObject()); - JS::RootedObject parent_win(ctx, JS_GetParent(hobj)); + JS::RootedObject parent_win(ctx, js::GetGlobalForObjectCrossCompartment(hobj)); struct view_state *vs; struct document_view *doc_view; struct document *document; @@ -220,11 +220,11 @@ document_get_property_referrer(JSContext *ctx, unsigned int argc, jsval *vp) static bool -document_get_property_title(JSContext *ctx, unsigned int argc, jsval *vp) +document_get_property_title(JSContext *ctx, unsigned int argc, JS::Value *vp) { JS::CallArgs args = CallArgsFromVp(argc, vp); JS::RootedObject hobj(ctx, &args.thisv().toObject()); - JS::RootedObject parent_win(ctx, JS_GetParent(hobj)); + JS::RootedObject parent_win(ctx, js::GetGlobalForObjectCrossCompartment(hobj)); struct view_state *vs; struct document_view *doc_view; struct document *document; @@ -245,11 +245,11 @@ document_get_property_title(JSContext *ctx, unsigned int argc, jsval *vp) } static bool -document_set_property_title(JSContext *ctx, int argc, jsval *vp) +document_set_property_title(JSContext *ctx, int argc, JS::Value *vp) { JS::CallArgs args = CallArgsFromVp(argc, vp); JS::RootedObject hobj(ctx, &args.thisv().toObject()); - JS::RootedObject parent_win(ctx, JS_GetParent(hobj)); + JS::RootedObject parent_win(ctx, js::GetGlobalForObjectCrossCompartment(hobj)); struct view_state *vs; struct document_view *doc_view; struct document *document; @@ -271,11 +271,11 @@ document_set_property_title(JSContext *ctx, int argc, jsval *vp) } static bool -document_get_property_url(JSContext *ctx, unsigned int argc, jsval *vp) +document_get_property_url(JSContext *ctx, unsigned int argc, JS::Value *vp) { JS::CallArgs args = CallArgsFromVp(argc, vp); JS::RootedObject hobj(ctx, &args.thisv().toObject()); - JS::RootedObject parent_win(ctx, JS_GetParent(hobj)); + JS::RootedObject parent_win(ctx, js::GetGlobalForObjectCrossCompartment(hobj)); struct view_state *vs; struct document_view *doc_view; struct document *document; @@ -303,11 +303,11 @@ document_get_property_url(JSContext *ctx, unsigned int argc, jsval *vp) } static bool -document_set_property_url(JSContext *ctx, int argc, jsval *vp) +document_set_property_url(JSContext *ctx, int argc, JS::Value *vp) { JS::CallArgs args = CallArgsFromVp(argc, vp); JS::RootedObject hobj(ctx, &args.thisv().toObject()); - JS::RootedObject parent_win(ctx, JS_GetParent(hobj)); + JS::RootedObject parent_win(ctx, js::GetGlobalForObjectCrossCompartment(hobj)); struct view_state *vs; struct document_view *doc_view; struct document *document; @@ -360,7 +360,7 @@ document_get_property(JSContext *ctx, JS::HandleObject hobj, JS::HandleId hid, J if (classPtr != &document_class) return false; - parent_win = JS_GetParent(obj); + parent_win = js::GetGlobalForObjectCrossCompartment(hobj); assert(JS_InstanceOf(ctx, parent_win, &window_class, NULL)); if_assert_failed return false; @@ -381,8 +381,8 @@ document_get_property(JSContext *ctx, JS::HandleObject hobj, JS::HandleId hid, J return true; } -static bool document_write(JSContext *ctx, unsigned int argc, jsval *rval); -static bool document_writeln(JSContext *ctx, unsigned int argc, jsval *rval); +static bool document_write(JSContext *ctx, unsigned int argc, JS::Value *rval); +static bool document_writeln(JSContext *ctx, unsigned int argc, JS::Value *rval); const spidermonkeyFunctionSpec document_funcs[] = { { "write", document_write, 1 }, @@ -391,9 +391,9 @@ const spidermonkeyFunctionSpec document_funcs[] = { }; static bool -document_write_do(JSContext *ctx, unsigned int argc, jsval *rval, int newline) +document_write_do(JSContext *ctx, unsigned int argc, JS::Value *rval, int newline) { - jsval val; + JS::Value val; struct ecmascript_interpreter *interpreter = JS_GetContextPrivate(ctx); struct string *ret = interpreter->ret; JS::CallArgs args = JS::CallArgsFromVp(argc, rval); @@ -428,7 +428,7 @@ document_write_do(JSContext *ctx, unsigned int argc, jsval *rval, int newline) /* @document_funcs{"write"} */ static bool -document_write(JSContext *ctx, unsigned int argc, jsval *rval) +document_write(JSContext *ctx, unsigned int argc, JS::Value *rval) { return document_write_do(ctx, argc, rval, 0); @@ -436,7 +436,7 @@ document_write(JSContext *ctx, unsigned int argc, jsval *rval) /* @document_funcs{"writeln"} */ static bool -document_writeln(JSContext *ctx, unsigned int argc, jsval *rval) +document_writeln(JSContext *ctx, unsigned int argc, JS::Value *rval) { return document_write_do(ctx, argc, rval, 1); } diff --git a/src/ecmascript/spidermonkey/form.c b/src/ecmascript/spidermonkey/form.c index 0c20ac2e..4ba033f8 100644 --- a/src/ecmascript/spidermonkey/form.c +++ b/src/ecmascript/spidermonkey/form.c @@ -11,6 +11,7 @@ #include "elinks.h" #include "ecmascript/spidermonkey/util.h" +#include #include "bfu/dialog.h" #include "cache/cache.h" @@ -50,18 +51,18 @@ //static JSClass form_class; /* defined below */ static bool form_get_property(JSContext *ctx, JS::HandleObject hobj, JS::HandleId hid, JS::MutableHandleValue hvp); -static bool form_get_property_action(JSContext *ctx, unsigned int argc, jsval *vp); -static bool form_set_property_action(JSContext *ctx, unsigned int argc, jsval *vp); -static bool form_get_property_elements(JSContext *ctx, unsigned int argc, jsval *vp); -static bool form_get_property_encoding(JSContext *ctx, unsigned int argc, jsval *vp); -static bool form_set_property_encoding(JSContext *ctx, unsigned int argc, jsval *vp); -static bool form_get_property_length(JSContext *ctx, unsigned int argc, jsval *vp); -static bool form_get_property_method(JSContext *ctx, unsigned int argc, jsval *vp); -static bool form_set_property_method(JSContext *ctx, unsigned int argc, jsval *vp); -static bool form_get_property_name(JSContext *ctx, unsigned int argc, jsval *vp); -static bool form_set_property_name(JSContext *ctx, unsigned int argc, jsval *vp); -static bool form_get_property_target(JSContext *ctx, unsigned int argc, jsval *vp); -static bool form_set_property_target(JSContext *ctx, unsigned int argc, jsval *vp); +static bool form_get_property_action(JSContext *ctx, unsigned int argc, JS::Value *vp); +static bool form_set_property_action(JSContext *ctx, unsigned int argc, JS::Value *vp); +static bool form_get_property_elements(JSContext *ctx, unsigned int argc, JS::Value *vp); +static bool form_get_property_encoding(JSContext *ctx, unsigned int argc, JS::Value *vp); +static bool form_set_property_encoding(JSContext *ctx, unsigned int argc, JS::Value *vp); +static bool form_get_property_length(JSContext *ctx, unsigned int argc, JS::Value *vp); +static bool form_get_property_method(JSContext *ctx, unsigned int argc, JS::Value *vp); +static bool form_set_property_method(JSContext *ctx, unsigned int argc, JS::Value *vp); +static bool form_get_property_name(JSContext *ctx, unsigned int argc, JS::Value *vp); +static bool form_set_property_name(JSContext *ctx, unsigned int argc, JS::Value *vp); +static bool form_get_property_target(JSContext *ctx, unsigned int argc, JS::Value *vp); +static bool form_set_property_target(JSContext *ctx, unsigned int argc, JS::Value *vp); static void form_finalize(JSFreeOp *op, JSObject *obj); @@ -82,7 +83,7 @@ static JSClass form_class = { * JS code, but I hope it doesn't matter anywhere. --pasky */ static bool input_get_property(JSContext *ctx, JS::HandleObject hobj, JS::HandleId hid, JS::MutableHandleValue hvp); -static bool input_set_property(JSContext *ctx, JS::HandleObject hobj, JS::HandleId hid, bool strict, JS::MutableHandleValue hvp); +static bool input_set_property(JSContext *ctx, JS::HandleObject hobj, JS::HandleId hid, JS::MutableHandleValue hvp); static void input_finalize(JSFreeOp *op, JSObject *obj); /* Each @input_class object must have a @form_class parent. */ @@ -123,7 +124,7 @@ static struct form_state *input_get_form_state(JSContext *ctx, JSObject *jsinput static bool -input_get_property_accessKey(JSContext *ctx, unsigned int argc, jsval *vp) +input_get_property_accessKey(JSContext *ctx, unsigned int argc, JS::Value *vp) { JS::CallArgs args = CallArgsFromVp(argc, vp); JS::RootedObject hobj(ctx, &args.thisv().toObject()); @@ -137,20 +138,23 @@ input_get_property_accessKey(JSContext *ctx, unsigned int argc, jsval *vp) struct link *link = NULL; JSString *keystr; - JS::RootedObject parent_form(ctx, JS_GetParent(hobj)); - assert(JS_InstanceOf(ctx, parent_form, &form_class, NULL)); - if_assert_failed return false; +// JS::RootedObject parent_form(ctx, js::GetGlobalForObjectCrossCompartment(hobj)); +// assert(JS_InstanceOf(ctx, parent_form, &form_class, NULL)); +// if_assert_failed return false; - JS::RootedObject parent_doc(ctx, JS_GetParent(parent_form)); - assert(JS_InstanceOf(ctx, parent_doc, &document_class, NULL)); - if_assert_failed return false; +// JS::RootedObject parent_doc(ctx, js::GetGlobalForObjectCrossCompartment(parent_form)); +// assert(JS_InstanceOf(ctx, parent_doc, &document_class, NULL)); +// if_assert_failed return false; - JS::RootedObject parent_win(ctx, JS_GetParent(parent_doc)); - assert(JS_InstanceOf(ctx, parent_win, &window_class, NULL)); - if_assert_failed return false; +// JS::RootedObject parent_win(ctx, js::GetGlobalForObjectCrossCompartment(parent_doc)); +// assert(JS_InstanceOf(ctx, parent_win, &window_class, NULL)); +// if_assert_failed return false; + + JS::RootedObject parent_win(ctx, js::GetGlobalForObjectCrossCompartment(hobj)); vs = JS_GetInstancePrivate(ctx, parent_win, &window_class, NULL); + if (!vs) { return false; } @@ -186,7 +190,7 @@ input_get_property_accessKey(JSContext *ctx, unsigned int argc, jsval *vp) } static bool -input_set_property_accessKey(JSContext *ctx, unsigned int argc, jsval *vp) +input_set_property_accessKey(JSContext *ctx, unsigned int argc, JS::Value *vp) { JS::CallArgs args = CallArgsFromVp(argc, vp); JS::RootedObject hobj(ctx, &args.thisv().toObject()); @@ -200,15 +204,17 @@ input_set_property_accessKey(JSContext *ctx, unsigned int argc, jsval *vp) struct link *link = NULL; unicode_val_T accesskey; - JS::RootedObject parent_form(ctx, JS_GetParent(hobj)); - assert(JS_InstanceOf(ctx, parent_form, &form_class, NULL)); - if_assert_failed return false; - JS::RootedObject parent_doc(ctx, JS_GetParent(parent_form)); - assert(JS_InstanceOf(ctx, parent_doc, &document_class, NULL)); - if_assert_failed return false; - JS::RootedObject parent_win(ctx, JS_GetParent(parent_doc)); - assert(JS_InstanceOf(ctx, parent_win, &window_class, NULL)); - if_assert_failed return false; +// JS::RootedObject parent_form(ctx, js::GetGlobalForObjectCrossCompartment(hobj)); +// assert(JS_InstanceOf(ctx, parent_form, &form_class, NULL)); +// if_assert_failed return false; +// JS::RootedObject parent_doc(ctx, js::GetGlobalForObjectCrossCompartment(parent_form)); +// assert(JS_InstanceOf(ctx, parent_doc, &document_class, NULL)); +// if_assert_failed return false; +// JS::RootedObject parent_win(ctx, js::GetGlobalForObjectCrossCompartment(parent_doc)); +// assert(JS_InstanceOf(ctx, parent_win, &window_class, NULL)); +// if_assert_failed return false; + + JS::RootedObject parent_win(ctx, js::GetGlobalForObjectCrossCompartment(hobj)); vs = JS_GetInstancePrivate(ctx, parent_win, &window_class, NULL); @@ -270,7 +276,7 @@ input_set_property_accessKey(JSContext *ctx, unsigned int argc, jsval *vp) } static bool -input_get_property_alt(JSContext *ctx, unsigned int argc, jsval *vp) +input_get_property_alt(JSContext *ctx, unsigned int argc, JS::Value *vp) { JS::CallArgs args = CallArgsFromVp(argc, vp); JS::RootedObject hobj(ctx, &args.thisv().toObject()); @@ -281,17 +287,18 @@ input_get_property_alt(JSContext *ctx, unsigned int argc, jsval *vp) struct form_state *fs; struct el_form_control *fc; - JS::RootedObject parent_form(ctx, JS_GetParent(hobj)); - assert(JS_InstanceOf(ctx, parent_form, &form_class, NULL)); - if_assert_failed return false; +// JS::RootedObject parent_form(ctx, js::GetGlobalForObjectCrossCompartment(hobj)); +// assert(JS_InstanceOf(ctx, parent_form, &form_class, NULL)); +// if_assert_failed return false; - JS::RootedObject parent_doc(ctx, JS_GetParent(parent_form)); - assert(JS_InstanceOf(ctx, parent_doc, &document_class, NULL)); - if_assert_failed return false; +// JS::RootedObject parent_doc(ctx, js::GetGlobalForObjectCrossCompartment(parent_form)); +// assert(JS_InstanceOf(ctx, parent_doc, &document_class, NULL)); +// if_assert_failed return false; - JS::RootedObject parent_win(ctx, JS_GetParent(parent_doc)); - assert(JS_InstanceOf(ctx, parent_win, &window_class, NULL)); - if_assert_failed return false; +// JS::RootedObject parent_win(ctx, js::GetGlobalForObjectCrossCompartment(parent_doc)); +// assert(JS_InstanceOf(ctx, parent_win, &window_class, NULL)); +// if_assert_failed return false; + JS::RootedObject parent_win(ctx, js::GetGlobalForObjectCrossCompartment(hobj)); vs = JS_GetInstancePrivate(ctx, parent_win, &window_class, NULL); @@ -313,7 +320,7 @@ input_get_property_alt(JSContext *ctx, unsigned int argc, jsval *vp) } static bool -input_set_property_alt(JSContext *ctx, unsigned int argc, jsval *vp) +input_set_property_alt(JSContext *ctx, unsigned int argc, JS::Value *vp) { JS::CallArgs args = CallArgsFromVp(argc, vp); JS::RootedObject hobj(ctx, &args.thisv().toObject()); @@ -323,15 +330,16 @@ input_set_property_alt(JSContext *ctx, unsigned int argc, jsval *vp) struct form_state *fs; struct el_form_control *fc; - JS::RootedObject parent_form(ctx, JS_GetParent(hobj)); - assert(JS_InstanceOf(ctx, parent_form, &form_class, NULL)); - if_assert_failed return false; - JS::RootedObject parent_doc(ctx, JS_GetParent(parent_form)); - assert(JS_InstanceOf(ctx, parent_doc, &document_class, NULL)); - if_assert_failed return false; - JS::RootedObject parent_win(ctx, JS_GetParent(parent_doc)); - assert(JS_InstanceOf(ctx, parent_win, &window_class, NULL)); - if_assert_failed return false; +// JS::RootedObject parent_form(ctx, js::GetGlobalForObjectCrossCompartment(hobj)); +// assert(JS_InstanceOf(ctx, parent_form, &form_class, NULL)); +// if_assert_failed return false; +// JS::RootedObject parent_doc(ctx, js::GetGlobalForObjectCrossCompartment(parent_form)); +// assert(JS_InstanceOf(ctx, parent_doc, &document_class, NULL)); +// if_assert_failed return false; +// JS::RootedObject parent_win(ctx, js::GetGlobalForObjectCrossCompartment(parent_doc)); +// assert(JS_InstanceOf(ctx, parent_win, &window_class, NULL)); +// if_assert_failed return false; + JS::RootedObject parent_win(ctx, js::GetGlobalForObjectCrossCompartment(hobj)); vs = JS_GetInstancePrivate(ctx, parent_win, &window_class, NULL); @@ -353,7 +361,7 @@ input_set_property_alt(JSContext *ctx, unsigned int argc, jsval *vp) } static bool -input_get_property_checked(JSContext *ctx, unsigned int argc, jsval *vp) +input_get_property_checked(JSContext *ctx, unsigned int argc, JS::Value *vp) { JS::CallArgs args = CallArgsFromVp(argc, vp); JS::RootedObject hobj(ctx, &args.thisv().toObject()); @@ -369,7 +377,7 @@ input_get_property_checked(JSContext *ctx, unsigned int argc, jsval *vp) } static bool -input_set_property_checked(JSContext *ctx, unsigned int argc, jsval *vp) +input_set_property_checked(JSContext *ctx, unsigned int argc, JS::Value *vp) { JS::CallArgs args = CallArgsFromVp(argc, vp); JS::RootedObject hobj(ctx, &args.thisv().toObject()); @@ -380,15 +388,16 @@ input_set_property_checked(JSContext *ctx, unsigned int argc, jsval *vp) struct form_state *fs; struct el_form_control *fc; - JS::RootedObject parent_form(ctx, JS_GetParent(hobj)); - assert(JS_InstanceOf(ctx, parent_form, &form_class, NULL)); - if_assert_failed return false; - JS::RootedObject parent_doc(ctx, JS_GetParent(parent_form)); - assert(JS_InstanceOf(ctx, parent_doc, &document_class, NULL)); - if_assert_failed return false; - JS::RootedObject parent_win(ctx, JS_GetParent(parent_doc)); - assert(JS_InstanceOf(ctx, parent_win, &window_class, NULL)); - if_assert_failed return false; +// JS::RootedObject parent_form(ctx, js::GetGlobalForObjectCrossCompartment(hobj)); +// assert(JS_InstanceOf(ctx, parent_form, &form_class, NULL)); +// if_assert_failed return false; +// JS::RootedObject parent_doc(ctx, js::GetGlobalForObjectCrossCompartment(parent_form)); +// assert(JS_InstanceOf(ctx, parent_doc, &document_class, NULL)); +// if_assert_failed return false; +// JS::RootedObject parent_win(ctx, js::GetGlobalForObjectCrossCompartment(parent_doc)); +// assert(JS_InstanceOf(ctx, parent_win, &window_class, NULL)); +// if_assert_failed return false; + JS::RootedObject parent_win(ctx, js::GetGlobalForObjectCrossCompartment(hobj)); vs = JS_GetInstancePrivate(ctx, parent_win, &window_class, NULL); @@ -412,7 +421,7 @@ input_set_property_checked(JSContext *ctx, unsigned int argc, jsval *vp) } static bool -input_get_property_defaultChecked(JSContext *ctx, unsigned int argc, jsval *vp) +input_get_property_defaultChecked(JSContext *ctx, unsigned int argc, JS::Value *vp) { JS::CallArgs args = CallArgsFromVp(argc, vp); JS::RootedObject hobj(ctx, &args.thisv().toObject()); @@ -423,17 +432,18 @@ input_get_property_defaultChecked(JSContext *ctx, unsigned int argc, jsval *vp) struct form_state *fs; struct el_form_control *fc; - JS::RootedObject parent_form(ctx, JS_GetParent(hobj)); - assert(JS_InstanceOf(ctx, parent_form, &form_class, NULL)); - if_assert_failed return false; +// JS::RootedObject parent_form(ctx, js::GetGlobalForObjectCrossCompartment(hobj)); +// assert(JS_InstanceOf(ctx, parent_form, &form_class, NULL)); +// if_assert_failed return false; - JS::RootedObject parent_doc(ctx, JS_GetParent(parent_form)); - assert(JS_InstanceOf(ctx, parent_doc, &document_class, NULL)); - if_assert_failed return false; +// JS::RootedObject parent_doc(ctx, js::GetGlobalForObjectCrossCompartment(parent_form)); +// assert(JS_InstanceOf(ctx, parent_doc, &document_class, NULL)); +// if_assert_failed return false; - JS::RootedObject parent_win(ctx, JS_GetParent(parent_doc)); - assert(JS_InstanceOf(ctx, parent_win, &window_class, NULL)); - if_assert_failed return false; +// JS::RootedObject parent_win(ctx, js::GetGlobalForObjectCrossCompartment(parent_doc)); +// assert(JS_InstanceOf(ctx, parent_win, &window_class, NULL)); +// if_assert_failed return false; + JS::RootedObject parent_win(ctx, js::GetGlobalForObjectCrossCompartment(hobj)); vs = JS_GetInstancePrivate(ctx, parent_win, &window_class, NULL); @@ -455,7 +465,7 @@ input_get_property_defaultChecked(JSContext *ctx, unsigned int argc, jsval *vp) } static bool -input_get_property_defaultValue(JSContext *ctx, unsigned int argc, jsval *vp) +input_get_property_defaultValue(JSContext *ctx, unsigned int argc, JS::Value *vp) { JS::CallArgs args = CallArgsFromVp(argc, vp); JS::RootedObject hobj(ctx, &args.thisv().toObject()); @@ -466,17 +476,18 @@ input_get_property_defaultValue(JSContext *ctx, unsigned int argc, jsval *vp) struct form_state *fs; struct el_form_control *fc; - JS::RootedObject parent_form(ctx, JS_GetParent(hobj)); - assert(JS_InstanceOf(ctx, parent_form, &form_class, NULL)); - if_assert_failed return false; +// JS::RootedObject parent_form(ctx, js::GetGlobalForObjectCrossCompartment(hobj)); +// assert(JS_InstanceOf(ctx, parent_form, &form_class, NULL)); +// if_assert_failed return false; - JS::RootedObject parent_doc(ctx, JS_GetParent(parent_form)); - assert(JS_InstanceOf(ctx, parent_doc, &document_class, NULL)); - if_assert_failed return false; +// JS::RootedObject parent_doc(ctx, js::GetGlobalForObjectCrossCompartment(parent_form)); +// assert(JS_InstanceOf(ctx, parent_doc, &document_class, NULL)); +// if_assert_failed return false; - JS::RootedObject parent_win(ctx, JS_GetParent(parent_doc)); - assert(JS_InstanceOf(ctx, parent_win, &window_class, NULL)); - if_assert_failed return false; +// JS::RootedObject parent_win(ctx, js::GetGlobalForObjectCrossCompartment(parent_doc)); +// assert(JS_InstanceOf(ctx, parent_win, &window_class, NULL)); +// if_assert_failed return false; + JS::RootedObject parent_win(ctx, js::GetGlobalForObjectCrossCompartment(hobj)); vs = JS_GetInstancePrivate(ctx, parent_win, &window_class, NULL); @@ -499,7 +510,7 @@ input_get_property_defaultValue(JSContext *ctx, unsigned int argc, jsval *vp) } static bool -input_get_property_disabled(JSContext *ctx, unsigned int argc, jsval *vp) +input_get_property_disabled(JSContext *ctx, unsigned int argc, JS::Value *vp) { JS::CallArgs args = CallArgsFromVp(argc, vp); JS::RootedObject hobj(ctx, &args.thisv().toObject()); @@ -510,17 +521,18 @@ input_get_property_disabled(JSContext *ctx, unsigned int argc, jsval *vp) struct form_state *fs; struct el_form_control *fc; - JS::RootedObject parent_form(ctx, JS_GetParent(hobj)); - assert(JS_InstanceOf(ctx, parent_form, &form_class, NULL)); - if_assert_failed return false; +// JS::RootedObject parent_form(ctx, js::GetGlobalForObjectCrossCompartment(hobj)); +// assert(JS_InstanceOf(ctx, parent_form, &form_class, NULL)); +// if_assert_failed return false; - JS::RootedObject parent_doc(ctx, JS_GetParent(parent_form)); - assert(JS_InstanceOf(ctx, parent_doc, &document_class, NULL)); - if_assert_failed return false; +// JS::RootedObject parent_doc(ctx, js::GetGlobalForObjectCrossCompartment(parent_form)); +// assert(JS_InstanceOf(ctx, parent_doc, &document_class, NULL)); +// if_assert_failed return false; - JS::RootedObject parent_win(ctx, JS_GetParent(parent_doc)); - assert(JS_InstanceOf(ctx, parent_win, &window_class, NULL)); - if_assert_failed return false; +// JS::RootedObject parent_win(ctx, js::GetGlobalForObjectCrossCompartment(parent_doc)); +// assert(JS_InstanceOf(ctx, parent_win, &window_class, NULL)); +// if_assert_failed return false; + JS::RootedObject parent_win(ctx, js::GetGlobalForObjectCrossCompartment(hobj)); vs = JS_GetInstancePrivate(ctx, parent_win, &window_class, NULL); @@ -543,7 +555,7 @@ input_get_property_disabled(JSContext *ctx, unsigned int argc, jsval *vp) } static bool -input_set_property_disabled(JSContext *ctx, unsigned int argc, jsval *vp) +input_set_property_disabled(JSContext *ctx, unsigned int argc, JS::Value *vp) { JS::CallArgs args = CallArgsFromVp(argc, vp); JS::RootedObject hobj(ctx, &args.thisv().toObject()); @@ -554,15 +566,16 @@ input_set_property_disabled(JSContext *ctx, unsigned int argc, jsval *vp) struct form_state *fs; struct el_form_control *fc; - JS::RootedObject parent_form(ctx, JS_GetParent(hobj)); - assert(JS_InstanceOf(ctx, parent_form, &form_class, NULL)); - if_assert_failed return false; - JS::RootedObject parent_doc(ctx, JS_GetParent(parent_form)); - assert(JS_InstanceOf(ctx, parent_doc, &document_class, NULL)); - if_assert_failed return false; - JS::RootedObject parent_win(ctx, JS_GetParent(parent_doc)); - assert(JS_InstanceOf(ctx, parent_win, &window_class, NULL)); - if_assert_failed return false; +// JS::RootedObject parent_form(ctx, js::GetGlobalForObjectCrossCompartment(hobj)); +// assert(JS_InstanceOf(ctx, parent_form, &form_class, NULL)); +// if_assert_failed return false; +// JS::RootedObject parent_doc(ctx, js::GetGlobalForObjectCrossCompartment(parent_form)); +// assert(JS_InstanceOf(ctx, parent_doc, &document_class, NULL)); +// if_assert_failed return false; +// JS::RootedObject parent_win(ctx, js::GetGlobalForObjectCrossCompartment(parent_doc)); +// assert(JS_InstanceOf(ctx, parent_win, &window_class, NULL)); +// if_assert_failed return false; + JS::RootedObject parent_win(ctx, js::GetGlobalForObjectCrossCompartment(hobj)); vs = JS_GetInstancePrivate(ctx, parent_win, &window_class, NULL); @@ -587,12 +600,12 @@ input_set_property_disabled(JSContext *ctx, unsigned int argc, jsval *vp) } static bool -input_get_property_form(JSContext *ctx, unsigned int argc, jsval *vp) +input_get_property_form(JSContext *ctx, unsigned int argc, JS::Value *vp) { JS::CallArgs args = CallArgsFromVp(argc, vp); JS::RootedObject hobj(ctx, &args.thisv().toObject()); - JS::RootedObject parent_form(ctx, JS_GetParent(hobj)); + JS::RootedObject parent_form(ctx, js::GetGlobalForObjectCrossCompartment(hobj)); assert(JS_InstanceOf(ctx, parent_form, &form_class, NULL)); if_assert_failed return false; @@ -602,7 +615,7 @@ input_get_property_form(JSContext *ctx, unsigned int argc, jsval *vp) } static bool -input_get_property_maxLength(JSContext *ctx, unsigned int argc, jsval *vp) +input_get_property_maxLength(JSContext *ctx, unsigned int argc, JS::Value *vp) { JS::CallArgs args = CallArgsFromVp(argc, vp); JS::RootedObject hobj(ctx, &args.thisv().toObject()); @@ -613,17 +626,18 @@ input_get_property_maxLength(JSContext *ctx, unsigned int argc, jsval *vp) struct form_state *fs; struct el_form_control *fc; - JS::RootedObject parent_form(ctx, JS_GetParent(hobj)); - assert(JS_InstanceOf(ctx, parent_form, &form_class, NULL)); - if_assert_failed return false; +// JS::RootedObject parent_form(ctx, js::GetGlobalForObjectCrossCompartment(hobj)); +// assert(JS_InstanceOf(ctx, parent_form, &form_class, NULL)); +// if_assert_failed return false; - JS::RootedObject parent_doc(ctx, JS_GetParent(parent_form)); - assert(JS_InstanceOf(ctx, parent_doc, &document_class, NULL)); - if_assert_failed return false; +// JS::RootedObject parent_doc(ctx, js::GetGlobalForObjectCrossCompartment(parent_form)); +// assert(JS_InstanceOf(ctx, parent_doc, &document_class, NULL)); +// if_assert_failed return false; - JS::RootedObject parent_win(ctx, JS_GetParent(parent_doc)); - assert(JS_InstanceOf(ctx, parent_win, &window_class, NULL)); - if_assert_failed return false; +// JS::RootedObject parent_win(ctx, js::GetGlobalForObjectCrossCompartment(parent_doc)); +// assert(JS_InstanceOf(ctx, parent_win, &window_class, NULL)); +// if_assert_failed return false; + JS::RootedObject parent_win(ctx, js::GetGlobalForObjectCrossCompartment(hobj)); vs = JS_GetInstancePrivate(ctx, parent_win, &window_class, NULL); @@ -645,7 +659,7 @@ input_get_property_maxLength(JSContext *ctx, unsigned int argc, jsval *vp) } static bool -input_set_property_maxLength(JSContext *ctx, unsigned int argc, jsval *vp) +input_set_property_maxLength(JSContext *ctx, unsigned int argc, JS::Value *vp) { JS::CallArgs args = CallArgsFromVp(argc, vp); JS::RootedObject hobj(ctx, &args.thisv().toObject()); @@ -656,15 +670,16 @@ input_set_property_maxLength(JSContext *ctx, unsigned int argc, jsval *vp) struct form_state *fs; struct el_form_control *fc; - JS::RootedObject parent_form(ctx, JS_GetParent(hobj)); - assert(JS_InstanceOf(ctx, parent_form, &form_class, NULL)); - if_assert_failed return false; - JS::RootedObject parent_doc(ctx, JS_GetParent(parent_form)); - assert(JS_InstanceOf(ctx, parent_doc, &document_class, NULL)); - if_assert_failed return false; - JS::RootedObject parent_win(ctx, JS_GetParent(parent_doc)); - assert(JS_InstanceOf(ctx, parent_win, &window_class, NULL)); - if_assert_failed return false; +// JS::RootedObject parent_form(ctx, js::GetGlobalForObjectCrossCompartment(hobj)); +// assert(JS_InstanceOf(ctx, parent_form, &form_class, NULL)); +// if_assert_failed return false; +// JS::RootedObject parent_doc(ctx, js::GetGlobalForObjectCrossCompartment(parent_form)); +// assert(JS_InstanceOf(ctx, parent_doc, &document_class, NULL)); +// if_assert_failed return false; +// JS::RootedObject parent_win(ctx, js::GetGlobalForObjectCrossCompartment(parent_doc)); +// assert(JS_InstanceOf(ctx, parent_win, &window_class, NULL)); +// if_assert_failed return false; + JS::RootedObject parent_win(ctx, js::GetGlobalForObjectCrossCompartment(hobj)); vs = JS_GetInstancePrivate(ctx, parent_win, &window_class, NULL); @@ -686,7 +701,7 @@ input_set_property_maxLength(JSContext *ctx, unsigned int argc, jsval *vp) } static bool -input_get_property_name(JSContext *ctx, unsigned int argc, jsval *vp) +input_get_property_name(JSContext *ctx, unsigned int argc, JS::Value *vp) { JS::CallArgs args = CallArgsFromVp(argc, vp); JS::RootedObject hobj(ctx, &args.thisv().toObject()); @@ -697,17 +712,18 @@ input_get_property_name(JSContext *ctx, unsigned int argc, jsval *vp) struct form_state *fs; struct el_form_control *fc; - JS::RootedObject parent_form(ctx, JS_GetParent(hobj)); - assert(JS_InstanceOf(ctx, parent_form, &form_class, NULL)); - if_assert_failed return false; +// JS::RootedObject parent_form(ctx, js::GetGlobalForObjectCrossCompartment(hobj)); +// assert(JS_InstanceOf(ctx, parent_form, &form_class, NULL)); +// if_assert_failed return false; - JS::RootedObject parent_doc(ctx, JS_GetParent(parent_form)); - assert(JS_InstanceOf(ctx, parent_doc, &document_class, NULL)); - if_assert_failed return false; +// JS::RootedObject parent_doc(ctx, js::GetGlobalForObjectCrossCompartment(parent_form)); +// assert(JS_InstanceOf(ctx, parent_doc, &document_class, NULL)); +// if_assert_failed return false; - JS::RootedObject parent_win(ctx, JS_GetParent(parent_doc)); - assert(JS_InstanceOf(ctx, parent_win, &window_class, NULL)); - if_assert_failed return false; +// JS::RootedObject parent_win(ctx, js::GetGlobalForObjectCrossCompartment(parent_doc)); +// assert(JS_InstanceOf(ctx, parent_win, &window_class, NULL)); +// if_assert_failed return false; + JS::RootedObject parent_win(ctx, js::GetGlobalForObjectCrossCompartment(hobj)); vs = JS_GetInstancePrivate(ctx, parent_win, &window_class, NULL); @@ -730,7 +746,7 @@ input_get_property_name(JSContext *ctx, unsigned int argc, jsval *vp) /* @input_class.setProperty */ static bool -input_set_property_name(JSContext *ctx, unsigned int argc, jsval *vp) +input_set_property_name(JSContext *ctx, unsigned int argc, JS::Value *vp) { JS::CallArgs args = CallArgsFromVp(argc, vp); JS::RootedObject hobj(ctx, &args.thisv().toObject()); @@ -747,15 +763,16 @@ input_set_property_name(JSContext *ctx, unsigned int argc, jsval *vp) if (!JS_InstanceOf(ctx, hobj, &input_class, NULL)) return false; - JS::RootedObject parent_form(ctx, JS_GetParent(hobj)); - assert(JS_InstanceOf(ctx, parent_form, &form_class, NULL)); - if_assert_failed return false; - JS::RootedObject parent_doc(ctx, JS_GetParent(parent_form)); - assert(JS_InstanceOf(ctx, parent_doc, &document_class, NULL)); - if_assert_failed return false; - JS::RootedObject parent_win(ctx, JS_GetParent(parent_doc)); - assert(JS_InstanceOf(ctx, parent_win, &window_class, NULL)); - if_assert_failed return false; +// JS::RootedObject parent_form(ctx, js::GetGlobalForObjectCrossCompartment(hobj)); +// assert(JS_InstanceOf(ctx, parent_form, &form_class, NULL)); +// if_assert_failed return false; +// JS::RootedObject parent_doc(ctx, js::GetGlobalForObjectCrossCompartment(parent_form)); +// assert(JS_InstanceOf(ctx, parent_doc, &document_class, NULL)); +// if_assert_failed return false; +// JS::RootedObject parent_win(ctx, js::GetGlobalForObjectCrossCompartment(parent_doc)); +// assert(JS_InstanceOf(ctx, parent_win, &window_class, NULL)); +// if_assert_failed return false; + JS::RootedObject parent_win(ctx, js::GetGlobalForObjectCrossCompartment(hobj)); vs = JS_GetInstancePrivate(ctx, parent_win, &window_class, NULL); @@ -777,7 +794,7 @@ input_set_property_name(JSContext *ctx, unsigned int argc, jsval *vp) } static bool -input_get_property_readonly(JSContext *ctx, unsigned int argc, jsval *vp) +input_get_property_readonly(JSContext *ctx, unsigned int argc, JS::Value *vp) { JS::CallArgs args = CallArgsFromVp(argc, vp); JS::RootedObject hobj(ctx, &args.thisv().toObject()); @@ -794,17 +811,18 @@ input_get_property_readonly(JSContext *ctx, unsigned int argc, jsval *vp) if (!JS_InstanceOf(ctx, hobj, &input_class, NULL)) return false; - JS::RootedObject parent_form(ctx, JS_GetParent(hobj)); - assert(JS_InstanceOf(ctx, parent_form, &form_class, NULL)); - if_assert_failed return false; +// JS::RootedObject parent_form(ctx, js::GetGlobalForObjectCrossCompartment(hobj)); +// assert(JS_InstanceOf(ctx, parent_form, &form_class, NULL)); +// if_assert_failed return false; - JS::RootedObject parent_doc(ctx, JS_GetParent(parent_form)); - assert(JS_InstanceOf(ctx, parent_doc, &document_class, NULL)); - if_assert_failed return false; +// JS::RootedObject parent_doc(ctx, js::GetGlobalForObjectCrossCompartment(parent_form)); +// assert(JS_InstanceOf(ctx, parent_doc, &document_class, NULL)); +// if_assert_failed return false; - JS::RootedObject parent_win(ctx, JS_GetParent(parent_doc)); - assert(JS_InstanceOf(ctx, parent_win, &window_class, NULL)); - if_assert_failed return false; +// JS::RootedObject parent_win(ctx, js::GetGlobalForObjectCrossCompartment(parent_doc)); +// assert(JS_InstanceOf(ctx, parent_win, &window_class, NULL)); +// if_assert_failed return false; + JS::RootedObject parent_win(ctx, js::GetGlobalForObjectCrossCompartment(hobj)); vs = JS_GetInstancePrivate(ctx, parent_win, &window_class, NULL); @@ -828,7 +846,7 @@ input_get_property_readonly(JSContext *ctx, unsigned int argc, jsval *vp) /* @input_class.setProperty */ static bool -input_set_property_readonly(JSContext *ctx, unsigned int argc, jsval *vp) +input_set_property_readonly(JSContext *ctx, unsigned int argc, JS::Value *vp) { JS::CallArgs args = CallArgsFromVp(argc, vp); JS::RootedObject hobj(ctx, &args.thisv().toObject()); @@ -844,15 +862,16 @@ input_set_property_readonly(JSContext *ctx, unsigned int argc, jsval *vp) * such calls. */ if (!JS_InstanceOf(ctx, hobj, &input_class, NULL)) return false; - JS::RootedObject parent_form(ctx, JS_GetParent(hobj)); - assert(JS_InstanceOf(ctx, parent_form, &form_class, NULL)); - if_assert_failed return false; - JS::RootedObject parent_doc(ctx, JS_GetParent(parent_form)); - assert(JS_InstanceOf(ctx, parent_doc, &document_class, NULL)); - if_assert_failed return false; - JS::RootedObject parent_win(ctx, JS_GetParent(parent_doc)); - assert(JS_InstanceOf(ctx, parent_win, &window_class, NULL)); - if_assert_failed return false; +// JS::RootedObject parent_form(ctx, js::GetGlobalForObjectCrossCompartment(hobj)); +// assert(JS_InstanceOf(ctx, parent_form, &form_class, NULL)); +// if_assert_failed return false; +// JS::RootedObject parent_doc(ctx, js::GetGlobalForObjectCrossCompartment(parent_form)); +// assert(JS_InstanceOf(ctx, parent_doc, &document_class, NULL)); +// if_assert_failed return false; +// JS::RootedObject parent_win(ctx, js::GetGlobalForObjectCrossCompartment(parent_doc)); +// assert(JS_InstanceOf(ctx, parent_win, &window_class, NULL)); +// if_assert_failed return false; + JS::RootedObject parent_win(ctx, js::GetGlobalForObjectCrossCompartment(hobj)); vs = JS_GetInstancePrivate(ctx, parent_win, &window_class, NULL); @@ -877,7 +896,7 @@ input_set_property_readonly(JSContext *ctx, unsigned int argc, jsval *vp) } static bool -input_get_property_selectedIndex(JSContext *ctx, unsigned int argc, jsval *vp) +input_get_property_selectedIndex(JSContext *ctx, unsigned int argc, JS::Value *vp) { JS::CallArgs args = CallArgsFromVp(argc, vp); JS::RootedObject hobj(ctx, &args.thisv().toObject()); @@ -894,17 +913,18 @@ input_get_property_selectedIndex(JSContext *ctx, unsigned int argc, jsval *vp) if (!JS_InstanceOf(ctx, hobj, &input_class, NULL)) return false; - JS::RootedObject parent_form(ctx, JS_GetParent(hobj)); - assert(JS_InstanceOf(ctx, parent_form, &form_class, NULL)); - if_assert_failed return false; +// JS::RootedObject parent_form(ctx, js::GetGlobalForObjectCrossCompartment(hobj)); +// assert(JS_InstanceOf(ctx, parent_form, &form_class, NULL)); +// if_assert_failed return false; - JS::RootedObject parent_doc(ctx, JS_GetParent(parent_form)); - assert(JS_InstanceOf(ctx, parent_doc, &document_class, NULL)); - if_assert_failed return false; +// JS::RootedObject parent_doc(ctx, js::GetGlobalForObjectCrossCompartment(parent_form)); +// assert(JS_InstanceOf(ctx, parent_doc, &document_class, NULL)); +// if_assert_failed return false; - JS::RootedObject parent_win(ctx, JS_GetParent(parent_doc)); - assert(JS_InstanceOf(ctx, parent_win, &window_class, NULL)); - if_assert_failed return false; +// JS::RootedObject parent_win(ctx, js::GetGlobalForObjectCrossCompartment(parent_doc)); +// assert(JS_InstanceOf(ctx, parent_win, &window_class, NULL)); +// if_assert_failed return false; + JS::RootedObject parent_win(ctx, js::GetGlobalForObjectCrossCompartment(hobj)); vs = JS_GetInstancePrivate(ctx, parent_win, &window_class, NULL); @@ -932,7 +952,7 @@ input_get_property_selectedIndex(JSContext *ctx, unsigned int argc, jsval *vp) /* @input_class.setProperty */ static bool -input_set_property_selectedIndex(JSContext *ctx, unsigned int argc, jsval *vp) +input_set_property_selectedIndex(JSContext *ctx, unsigned int argc, JS::Value *vp) { JS::CallArgs args = CallArgsFromVp(argc, vp); JS::RootedObject hobj(ctx, &args.thisv().toObject()); @@ -948,15 +968,16 @@ input_set_property_selectedIndex(JSContext *ctx, unsigned int argc, jsval *vp) * such calls. */ if (!JS_InstanceOf(ctx, hobj, &input_class, NULL)) return false; - JS::RootedObject parent_form(ctx, JS_GetParent(hobj)); - assert(JS_InstanceOf(ctx, parent_form, &form_class, NULL)); - if_assert_failed return false; - JS::RootedObject parent_doc(ctx, JS_GetParent(parent_form)); - assert(JS_InstanceOf(ctx, parent_doc, &document_class, NULL)); - if_assert_failed return false; - JS::RootedObject parent_win(ctx, JS_GetParent(parent_doc)); - assert(JS_InstanceOf(ctx, parent_win, &window_class, NULL)); - if_assert_failed return false; +// JS::RootedObject parent_form(ctx, js::GetGlobalForObjectCrossCompartment(hobj)); +// assert(JS_InstanceOf(ctx, parent_form, &form_class, NULL)); +// if_assert_failed return false; +// JS::RootedObject parent_doc(ctx, js::GetGlobalForObjectCrossCompartment(parent_form)); +// assert(JS_InstanceOf(ctx, parent_doc, &document_class, NULL)); +// if_assert_failed return false; +// JS::RootedObject parent_win(ctx, js::GetGlobalForObjectCrossCompartment(parent_doc)); +// assert(JS_InstanceOf(ctx, parent_win, &window_class, NULL)); +// if_assert_failed return false; + JS::RootedObject parent_win(ctx, js::GetGlobalForObjectCrossCompartment(hobj)); vs = JS_GetInstancePrivate(ctx, parent_win, &window_class, NULL); @@ -985,7 +1006,7 @@ input_set_property_selectedIndex(JSContext *ctx, unsigned int argc, jsval *vp) } static bool -input_get_property_size(JSContext *ctx, unsigned int argc, jsval *vp) +input_get_property_size(JSContext *ctx, unsigned int argc, JS::Value *vp) { JS::CallArgs args = CallArgsFromVp(argc, vp); JS::RootedObject hobj(ctx, &args.thisv().toObject()); @@ -1002,17 +1023,18 @@ input_get_property_size(JSContext *ctx, unsigned int argc, jsval *vp) if (!JS_InstanceOf(ctx, hobj, &input_class, NULL)) return false; - JS::RootedObject parent_form(ctx, JS_GetParent(hobj)); - assert(JS_InstanceOf(ctx, parent_form, &form_class, NULL)); - if_assert_failed return false; +// JS::RootedObject parent_form(ctx, js::GetGlobalForObjectCrossCompartment(hobj)); +// assert(JS_InstanceOf(ctx, parent_form, &form_class, NULL)); +// if_assert_failed return false; - JS::RootedObject parent_doc(ctx, JS_GetParent(parent_form)); - assert(JS_InstanceOf(ctx, parent_doc, &document_class, NULL)); - if_assert_failed return false; +// JS::RootedObject parent_doc(ctx, js::GetGlobalForObjectCrossCompartment(parent_form)); +// assert(JS_InstanceOf(ctx, parent_doc, &document_class, NULL)); +// if_assert_failed return false; - JS::RootedObject parent_win(ctx, JS_GetParent(parent_doc)); - assert(JS_InstanceOf(ctx, parent_win, &window_class, NULL)); - if_assert_failed return false; +// JS::RootedObject parent_win(ctx, js::GetGlobalForObjectCrossCompartment(parent_doc)); +// assert(JS_InstanceOf(ctx, parent_win, &window_class, NULL)); +// if_assert_failed return false; + JS::RootedObject parent_win(ctx, js::GetGlobalForObjectCrossCompartment(hobj)); vs = JS_GetInstancePrivate(ctx, parent_win, &window_class, NULL); @@ -1034,7 +1056,7 @@ input_get_property_size(JSContext *ctx, unsigned int argc, jsval *vp) } static bool -input_get_property_src(JSContext *ctx, unsigned int argc, jsval *vp) +input_get_property_src(JSContext *ctx, unsigned int argc, JS::Value *vp) { JS::CallArgs args = CallArgsFromVp(argc, vp); JS::RootedObject hobj(ctx, &args.thisv().toObject()); @@ -1053,17 +1075,18 @@ input_get_property_src(JSContext *ctx, unsigned int argc, jsval *vp) if (!JS_InstanceOf(ctx, hobj, &input_class, NULL)) return false; - JS::RootedObject parent_form(ctx, JS_GetParent(hobj)); - assert(JS_InstanceOf(ctx, parent_form, &form_class, NULL)); - if_assert_failed return false; +// JS::RootedObject parent_form(ctx, js::GetGlobalForObjectCrossCompartment(hobj)); +// assert(JS_InstanceOf(ctx, parent_form, &form_class, NULL)); +// if_assert_failed return false; - JS::RootedObject parent_doc(ctx, JS_GetParent(parent_form)); - assert(JS_InstanceOf(ctx, parent_doc, &document_class, NULL)); - if_assert_failed return false; +// JS::RootedObject parent_doc(ctx, js::GetGlobalForObjectCrossCompartment(parent_form)); +// assert(JS_InstanceOf(ctx, parent_doc, &document_class, NULL)); +// if_assert_failed return false; - JS::RootedObject parent_win(ctx, JS_GetParent(parent_doc)); - assert(JS_InstanceOf(ctx, parent_win, &window_class, NULL)); - if_assert_failed return false; +// JS::RootedObject parent_win(ctx, js::GetGlobalForObjectCrossCompartment(parent_doc)); +// assert(JS_InstanceOf(ctx, parent_win, &window_class, NULL)); +// if_assert_failed return false; + JS::RootedObject parent_win(ctx, js::GetGlobalForObjectCrossCompartment(hobj)); vs = JS_GetInstancePrivate(ctx, parent_win, &window_class, NULL); @@ -1092,7 +1115,7 @@ input_get_property_src(JSContext *ctx, unsigned int argc, jsval *vp) } static bool -input_set_property_src(JSContext *ctx, unsigned int argc, jsval *vp) +input_set_property_src(JSContext *ctx, unsigned int argc, JS::Value *vp) { JS::CallArgs args = CallArgsFromVp(argc, vp); JS::RootedObject hobj(ctx, &args.thisv().toObject()); @@ -1111,17 +1134,18 @@ input_set_property_src(JSContext *ctx, unsigned int argc, jsval *vp) if (!JS_InstanceOf(ctx, hobj, &input_class, NULL)) return false; - JS::RootedObject parent_form(ctx, JS_GetParent(hobj)); - assert(JS_InstanceOf(ctx, parent_form, &form_class, NULL)); - if_assert_failed return false; +// JS::RootedObject parent_form(ctx, js::GetGlobalForObjectCrossCompartment(hobj)); +// assert(JS_InstanceOf(ctx, parent_form, &form_class, NULL)); +// if_assert_failed return false; - JS::RootedObject parent_doc(ctx, JS_GetParent(parent_form)); - assert(JS_InstanceOf(ctx, parent_doc, &document_class, NULL)); - if_assert_failed return false; +// JS::RootedObject parent_doc(ctx, js::GetGlobalForObjectCrossCompartment(parent_form)); +// assert(JS_InstanceOf(ctx, parent_doc, &document_class, NULL)); +// if_assert_failed return false; - JS::RootedObject parent_win(ctx, JS_GetParent(parent_doc)); - assert(JS_InstanceOf(ctx, parent_win, &window_class, NULL)); - if_assert_failed return false; +// JS::RootedObject parent_win(ctx, js::GetGlobalForObjectCrossCompartment(parent_doc)); +// assert(JS_InstanceOf(ctx, parent_win, &window_class, NULL)); +// if_assert_failed return false; + JS::RootedObject parent_win(ctx, js::GetGlobalForObjectCrossCompartment(hobj)); vs = JS_GetInstancePrivate(ctx, parent_win, &window_class, NULL); @@ -1149,7 +1173,7 @@ input_set_property_src(JSContext *ctx, unsigned int argc, jsval *vp) } static bool -input_get_property_tabIndex(JSContext *ctx, unsigned int argc, jsval *vp) +input_get_property_tabIndex(JSContext *ctx, unsigned int argc, JS::Value *vp) { JS::CallArgs args = CallArgsFromVp(argc, vp); JS::RootedObject hobj(ctx, &args.thisv().toObject()); @@ -1168,17 +1192,18 @@ input_get_property_tabIndex(JSContext *ctx, unsigned int argc, jsval *vp) if (!JS_InstanceOf(ctx, hobj, &input_class, NULL)) return false; - JS::RootedObject parent_form(ctx, JS_GetParent(hobj)); - assert(JS_InstanceOf(ctx, parent_form, &form_class, NULL)); - if_assert_failed return false; +// JS::RootedObject parent_form(ctx, js::GetGlobalForObjectCrossCompartment(hobj)); +// assert(JS_InstanceOf(ctx, parent_form, &form_class, NULL)); +// if_assert_failed return false; - JS::RootedObject parent_doc(ctx, JS_GetParent(parent_form)); - assert(JS_InstanceOf(ctx, parent_doc, &document_class, NULL)); - if_assert_failed return false; +// JS::RootedObject parent_doc(ctx, js::GetGlobalForObjectCrossCompartment(parent_form)); +// assert(JS_InstanceOf(ctx, parent_doc, &document_class, NULL)); +// if_assert_failed return false; - JS::RootedObject parent_win(ctx, JS_GetParent(parent_doc)); - assert(JS_InstanceOf(ctx, parent_win, &window_class, NULL)); - if_assert_failed return false; +// JS::RootedObject parent_win(ctx, js::GetGlobalForObjectCrossCompartment(parent_doc)); +// assert(JS_InstanceOf(ctx, parent_win, &window_class, NULL)); +// if_assert_failed return false; + JS::RootedObject parent_win(ctx, js::GetGlobalForObjectCrossCompartment(hobj)); vs = JS_GetInstancePrivate(ctx, parent_win, &window_class, NULL); @@ -1209,7 +1234,7 @@ input_get_property_tabIndex(JSContext *ctx, unsigned int argc, jsval *vp) } static bool -input_get_property_type(JSContext *ctx, unsigned int argc, jsval *vp) +input_get_property_type(JSContext *ctx, unsigned int argc, JS::Value *vp) { JS::CallArgs args = CallArgsFromVp(argc, vp); JS::RootedObject hobj(ctx, &args.thisv().toObject()); @@ -1227,17 +1252,18 @@ input_get_property_type(JSContext *ctx, unsigned int argc, jsval *vp) if (!JS_InstanceOf(ctx, hobj, &input_class, NULL)) return false; - JS::RootedObject parent_form(ctx, JS_GetParent(hobj)); - assert(JS_InstanceOf(ctx, parent_form, &form_class, NULL)); - if_assert_failed return false; +// JS::RootedObject parent_form(ctx, js::GetGlobalForObjectCrossCompartment(hobj)); +// assert(JS_InstanceOf(ctx, parent_form, &form_class, NULL)); +// if_assert_failed return false; - JS::RootedObject parent_doc(ctx, JS_GetParent(parent_form)); - assert(JS_InstanceOf(ctx, parent_doc, &document_class, NULL)); - if_assert_failed return false; +// JS::RootedObject parent_doc(ctx, js::GetGlobalForObjectCrossCompartment(parent_form)); +// assert(JS_InstanceOf(ctx, parent_doc, &document_class, NULL)); +// if_assert_failed return false; - JS::RootedObject parent_win(ctx, JS_GetParent(parent_doc)); - assert(JS_InstanceOf(ctx, parent_win, &window_class, NULL)); - if_assert_failed return false; +// JS::RootedObject parent_win(ctx, js::GetGlobalForObjectCrossCompartment(parent_doc)); +// assert(JS_InstanceOf(ctx, parent_win, &window_class, NULL)); +// if_assert_failed return false; + JS::RootedObject parent_win(ctx, js::GetGlobalForObjectCrossCompartment(hobj)); vs = JS_GetInstancePrivate(ctx, parent_win, &window_class, NULL); @@ -1273,7 +1299,7 @@ input_get_property_type(JSContext *ctx, unsigned int argc, jsval *vp) } static bool -input_get_property_value(JSContext *ctx, unsigned int argc, jsval *vp) +input_get_property_value(JSContext *ctx, unsigned int argc, JS::Value *vp) { JS::CallArgs args = CallArgsFromVp(argc, vp); JS::RootedObject hobj(ctx, &args.thisv().toObject()); @@ -1294,7 +1320,7 @@ input_get_property_value(JSContext *ctx, unsigned int argc, jsval *vp) } static bool -input_set_property_value(JSContext *ctx, unsigned int argc, jsval *vp) +input_set_property_value(JSContext *ctx, unsigned int argc, JS::Value *vp) { JS::CallArgs args = CallArgsFromVp(argc, vp); JS::RootedObject hobj(ctx, &args.thisv().toObject()); @@ -1311,17 +1337,18 @@ input_set_property_value(JSContext *ctx, unsigned int argc, jsval *vp) if (!JS_InstanceOf(ctx, hobj, &input_class, NULL)) return false; - JS::RootedObject parent_form(ctx, JS_GetParent(hobj)); - assert(JS_InstanceOf(ctx, parent_form, &form_class, NULL)); - if_assert_failed return false; +// JS::RootedObject parent_form(ctx, js::GetGlobalForObjectCrossCompartment(hobj)); +// assert(JS_InstanceOf(ctx, parent_form, &form_class, NULL)); +// if_assert_failed return false; - JS::RootedObject parent_doc(ctx, JS_GetParent(parent_form)); - assert(JS_InstanceOf(ctx, parent_doc, &document_class, NULL)); - if_assert_failed return false; +// JS::RootedObject parent_doc(ctx, js::GetGlobalForObjectCrossCompartment(parent_form)); +// assert(JS_InstanceOf(ctx, parent_doc, &document_class, NULL)); +// if_assert_failed return false; - JS::RootedObject parent_win(ctx, JS_GetParent(parent_doc)); - assert(JS_InstanceOf(ctx, parent_win, &window_class, NULL)); - if_assert_failed return false; +// JS::RootedObject parent_win(ctx, js::GetGlobalForObjectCrossCompartment(parent_doc)); +// assert(JS_InstanceOf(ctx, parent_win, &window_class, NULL)); +// if_assert_failed return false; + JS::RootedObject parent_win(ctx, js::GetGlobalForObjectCrossCompartment(hobj)); vs = JS_GetInstancePrivate(ctx, parent_win, &window_class, NULL); @@ -1371,10 +1398,10 @@ static JSPropertySpec input_props[] = { { NULL } }; -static bool input_blur(JSContext *ctx, unsigned int argc, jsval *rval); -static bool input_click(JSContext *ctx, unsigned int argc, jsval *rval); -static bool input_focus(JSContext *ctx, unsigned int argc, jsval *rval); -static bool input_select(JSContext *ctx, unsigned int argc, jsval *rval); +static bool input_blur(JSContext *ctx, unsigned int argc, JS::Value *rval); +static bool input_click(JSContext *ctx, unsigned int argc, JS::Value *rval); +static bool input_focus(JSContext *ctx, unsigned int argc, JS::Value *rval); +static bool input_select(JSContext *ctx, unsigned int argc, JS::Value *rval); static const spidermonkeyFunctionSpec input_funcs[] = { { "blur", input_blur, 0 }, @@ -1409,7 +1436,6 @@ input_get_property(JSContext *ctx, JS::HandleObject hobj, JS::HandleId hid, JS:: JS::RootedObject parent_form(ctx); /* instance of @form_class */ JS::RootedObject parent_doc(ctx); /* instance of @document_class */ - JS::RootedObject parent_win(ctx); /* instance of @window_class */ struct view_state *vs; struct document_view *doc_view; struct document *document; @@ -1424,17 +1450,18 @@ input_get_property(JSContext *ctx, JS::HandleObject hobj, JS::HandleId hid, JS:: if (!JS_InstanceOf(ctx, hobj, &input_class, NULL)) return false; - parent_form = JS_GetParent(obj); - assert(JS_InstanceOf(ctx, parent_form, &form_class, NULL)); - if_assert_failed return false; +// parent_form = js::GetGlobalForObjectCrossCompartment(obj); +// assert(JS_InstanceOf(ctx, parent_form, &form_class, NULL)); +// if_assert_failed return false; - parent_doc = JS_GetParent(parent_form); - assert(JS_InstanceOf(ctx, parent_doc, &document_class, NULL)); - if_assert_failed return false; +// parent_doc = js::GetGlobalForObjectCrossCompartment(parent_form); +// assert(JS_InstanceOf(ctx, parent_doc, &document_class, NULL)); +// if_assert_failed return false; - parent_win = JS_GetParent(parent_doc); - assert(JS_InstanceOf(ctx, parent_win, &window_class, NULL)); - if_assert_failed return false; +// parent_win = js::GetGlobalForObjectCrossCompartment(parent_doc); +// assert(JS_InstanceOf(ctx, parent_win, &window_class, NULL)); +// if_assert_failed return false; + JS::RootedObject parent_win(ctx, js::GetGlobalForObjectCrossCompartment(hobj)); vs = JS_GetInstancePrivate(ctx, parent_win, &window_class, NULL); @@ -1468,7 +1495,7 @@ input_get_property(JSContext *ctx, JS::HandleObject hobj, JS::HandleId hid, JS:: } else { keystr = unicode_to_jsstring(ctx, link->accesskey); if (keystr) - *vp = STRING_TO_JSVAL(keystr); + *vp = JS::StringValue(keystr); else return false; } @@ -1559,14 +1586,13 @@ input_get_property(JSContext *ctx, JS::HandleObject hobj, JS::HandleId hid, JS:: /* @input_class.setProperty */ static bool -input_set_property(JSContext *ctx, JS::HandleObject hobj, JS::HandleId hid, bool strict, JS::MutableHandleValue hvp) +input_set_property(JSContext *ctx, JS::HandleObject hobj, JS::HandleId hid, JS::MutableHandleValue hvp) { ELINKS_CAST_PROP_PARAMS jsid id = hid.get(); JS::RootedObject parent_form(ctx); /* instance of @form_class */ JS::RootedObject parent_doc(ctx); /* instance of @document_class */ - JS::RootedObject parent_win(ctx); /* instance of @window_class */ struct view_state *vs; struct document_view *doc_view; struct document *document; @@ -1581,15 +1607,16 @@ input_set_property(JSContext *ctx, JS::HandleObject hobj, JS::HandleId hid, bool * such calls. */ if (!JS_InstanceOf(ctx, hobj, &input_class, NULL)) return false; - parent_form = JS_GetParent(obj); - assert(JS_InstanceOf(ctx, parent_form, &form_class, NULL)); - if_assert_failed return false; - parent_doc = JS_GetParent(parent_form); - assert(JS_InstanceOf(ctx, parent_doc, &document_class, NULL)); - if_assert_failed return false; - parent_win = JS_GetParent(parent_doc); - assert(JS_InstanceOf(ctx, parent_win, &window_class, NULL)); - if_assert_failed return false; +// parent_form = js::GetGlobalForObjectCrossCompartment(obj); +// assert(JS_InstanceOf(ctx, parent_form, &form_class, NULL)); +// if_assert_failed return false; +// parent_doc = js::GetGlobalForObjectCrossCompartment(parent_form); +// assert(JS_InstanceOf(ctx, parent_doc, &document_class, NULL)); +// if_assert_failed return false; +// parent_win = js::GetGlobalForObjectCrossCompartment(parent_doc); +// assert(JS_InstanceOf(ctx, parent_win, &window_class, NULL)); +// if_assert_failed return false; + JS::RootedObject parent_win(ctx, js::GetGlobalForObjectCrossCompartment(hobj)); vs = JS_GetInstancePrivate(ctx, parent_win, &window_class, NULL); @@ -1679,7 +1706,7 @@ input_set_property(JSContext *ctx, JS::HandleObject hobj, JS::HandleId hid, bool /* @input_funcs{"blur"} */ static bool -input_blur(JSContext *ctx, unsigned int argc, jsval *rval) +input_blur(JSContext *ctx, unsigned int argc, JS::Value *rval) { /* We are a text-mode browser and there *always* has to be something * selected. So we do nothing for now. (That was easy.) */ @@ -1688,12 +1715,11 @@ input_blur(JSContext *ctx, unsigned int argc, jsval *rval) /* @input_funcs{"click"} */ static bool -input_click(JSContext *ctx, unsigned int argc, jsval *rval) +input_click(JSContext *ctx, unsigned int argc, JS::Value *rval) { - jsval val; + JS::Value val; JS::RootedObject parent_form(ctx); /* instance of @form_class */ JS::RootedObject parent_doc(ctx); /* instance of @document_class */ - JS::RootedObject parent_win(ctx); /* instance of @window_class */ JS::RootedObject hobj(ctx, JS_THIS_OBJECT(ctx, rval)); JS::CallArgs args = JS::CallArgsFromVp(argc, rval); struct view_state *vs; @@ -1705,15 +1731,16 @@ input_click(JSContext *ctx, unsigned int argc, jsval *rval) int linknum; if (!JS_InstanceOf(ctx, hobj, &input_class, &args)) return false; - parent_form = JS_GetParent(hobj); - assert(JS_InstanceOf(ctx, parent_form, &form_class, NULL)); - if_assert_failed return false; - parent_doc = JS_GetParent(parent_form); - assert(JS_InstanceOf(ctx, parent_doc, &document_class, NULL)); - if_assert_failed return false; - parent_win = JS_GetParent(parent_doc); - assert(JS_InstanceOf(ctx, parent_win, &window_class, NULL)); - if_assert_failed return false; +// parent_form = js::GetGlobalForObjectCrossCompartment(hobj); +// assert(JS_InstanceOf(ctx, parent_form, &form_class, NULL)); +// if_assert_failed return false; +// parent_doc = js::GetGlobalForObjectCrossCompartment(parent_form); +// assert(JS_InstanceOf(ctx, parent_doc, &document_class, NULL)); +// if_assert_failed return false; +// parent_win = js::GetGlobalForObjectCrossCompartment(parent_doc); +// assert(JS_InstanceOf(ctx, parent_win, &window_class, NULL)); +// if_assert_failed return false; + JS::RootedObject parent_win(ctx, js::GetGlobalForObjectCrossCompartment(hobj)); vs = JS_GetInstancePrivate(ctx, parent_win, &window_class, NULL); @@ -1746,13 +1773,12 @@ input_click(JSContext *ctx, unsigned int argc, jsval *rval) /* @input_funcs{"focus"} */ static bool -input_focus(JSContext *ctx, unsigned int argc, jsval *rval) +input_focus(JSContext *ctx, unsigned int argc, JS::Value *rval) { - jsval val; + JS::Value val; JS::RootedObject parent_form(ctx); /* instance of @form_class */ JS::RootedObject parent_doc(ctx); /* instance of @document_class */ - JS::RootedObject parent_win(ctx); /* instance of @window_class */ - JS::RootedObject obj(ctx, JS_THIS_OBJECT(ctx, rval)); + JS::RootedObject hobj(ctx, JS_THIS_OBJECT(ctx, rval)); JS::CallArgs args = JS::CallArgsFromVp(argc, rval); struct view_state *vs; struct document_view *doc_view; @@ -1762,23 +1788,24 @@ input_focus(JSContext *ctx, unsigned int argc, jsval *rval) struct el_form_control *fc; int linknum; - if (!JS_InstanceOf(ctx, obj, &input_class, &args)) return false; - parent_form = JS_GetParent(obj); - assert(JS_InstanceOf(ctx, parent_form, &form_class, NULL)); - if_assert_failed return false; - parent_doc = JS_GetParent(parent_form); - assert(JS_InstanceOf(ctx, parent_doc, &document_class, NULL)); - if_assert_failed return false; - parent_win = JS_GetParent(parent_doc); - assert(JS_InstanceOf(ctx, parent_win, &window_class, NULL)); - if_assert_failed return false; + if (!JS_InstanceOf(ctx, hobj, &input_class, &args)) return false; +// parent_form = js::GetGlobalForObjectCrossCompartment(obj); +// assert(JS_InstanceOf(ctx, parent_form, &form_class, NULL)); +// if_assert_failed return false; +// parent_doc = js::GetGlobalForObjectCrossCompartment(parent_form); +// assert(JS_InstanceOf(ctx, parent_doc, &document_class, NULL)); +// if_assert_failed return false; +// parent_win = js::GetGlobalForObjectCrossCompartment(parent_doc); +// assert(JS_InstanceOf(ctx, parent_win, &window_class, NULL)); +// if_assert_failed return false; + JS::RootedObject parent_win(ctx, js::GetGlobalForObjectCrossCompartment(hobj)); vs = JS_GetInstancePrivate(ctx, parent_win, &window_class, NULL); doc_view = vs->doc_view; document = doc_view->document; ses = doc_view->session; - fs = input_get_form_state(ctx, obj); + fs = input_get_form_state(ctx, hobj); if (!fs) return false; /* detached */ assert(fs); @@ -1798,7 +1825,7 @@ input_focus(JSContext *ctx, unsigned int argc, jsval *rval) /* @input_funcs{"select"} */ static bool -input_select(JSContext *ctx, unsigned int argc, jsval *rval) +input_select(JSContext *ctx, unsigned int argc, JS::Value *rval) { /* We support no text selecting yet. So we do nothing for now. * (That was easy, too.) */ @@ -1806,7 +1833,7 @@ input_select(JSContext *ctx, unsigned int argc, jsval *rval) } static JSObject * -get_input_object(JSContext *ctx, JSObject *jsform, struct form_state *fs) +get_input_object(JSContext *ctx, struct form_state *fs) { JSObject *jsinput = fs->ecmascript_obj; @@ -1821,11 +1848,10 @@ get_input_object(JSContext *ctx, JSObject *jsform, struct form_state *fs) return jsinput; } - JS::RootedObject r_jsform(ctx, jsform); /* jsform ('form') is input's parent */ /* FIXME: That is NOT correct since the real containing element * should be its parent, but gimme DOM first. --pasky */ - jsinput = JS_NewObject(ctx, &input_class, r_jsform); + jsinput = JS_NewObject(ctx, &input_class); if (!jsinput) return NULL; @@ -1900,7 +1926,7 @@ spidermonkey_moved_form_state(struct form_state *fs) static JSObject * -get_form_control_object(JSContext *ctx, JSObject *jsform, +get_form_control_object(JSContext *ctx, enum form_type type, struct form_state *fs) { switch (type) { @@ -1915,7 +1941,7 @@ get_form_control_object(JSContext *ctx, JSObject *jsform, case FC_BUTTON: case FC_HIDDEN: case FC_SELECT: - return get_input_object(ctx, jsform, fs); + return get_input_object(ctx, fs); case FC_TEXTAREA: /* TODO */ @@ -1928,7 +1954,7 @@ get_form_control_object(JSContext *ctx, JSObject *jsform, } -static struct form_view *form_get_form_view(JSContext *ctx, JSObject *jsform, jsval *argv); +static struct form_view *form_get_form_view(JSContext *ctx, JSObject *jsform, JS::Value *argv); static bool form_elements_get_property(JSContext *ctx, JS::HandleObject hobj, JS::HandleId hid, JS::MutableHandleValue hvp); /* Each @form_elements_class object must have a @form_class parent. */ @@ -1942,8 +1968,8 @@ static JSClass form_elements_class = { static bool form_elements_item2(JSContext *ctx, JS::HandleObject hobj, int index, JS::MutableHandleValue hvp); static bool form_elements_namedItem2(JSContext *ctx, JS::HandleObject hobj, unsigned char *string, JS::MutableHandleValue hvp); -static bool form_elements_item(JSContext *ctx, unsigned int argc, jsval *rval); -static bool form_elements_namedItem(JSContext *ctx, unsigned int argc, jsval *rval); +static bool form_elements_item(JSContext *ctx, unsigned int argc, JS::Value *rval); +static bool form_elements_namedItem(JSContext *ctx, unsigned int argc, JS::Value *rval); static const spidermonkeyFunctionSpec form_elements_funcs[] = { @@ -1952,7 +1978,7 @@ static const spidermonkeyFunctionSpec form_elements_funcs[] = { { NULL } }; -static bool form_elements_get_property_length(JSContext *ctx, unsigned int argc, jsval *vp); +static bool form_elements_get_property_length(JSContext *ctx, unsigned int argc, JS::Value *vp); /* Tinyids of properties. Use negative values to distinguish these * from array indexes (elements[INT] for INT>=0 is equivalent to @@ -1971,10 +1997,9 @@ form_elements_get_property(JSContext *ctx, JS::HandleObject hobj, JS::HandleId h { jsid id = hid.get(); - jsval idval; - JS::RootedObject parent_form(ctx); /* instance of @form_class */ - JS::RootedObject parent_doc(ctx); /* instance of @document_class */ - JS::RootedObject parent_win(ctx); /* instance of @window_class */ + JS::Value idval; +// JS::RootedObject parent_form(ctx); /* instance of @form_class */ +// JS::RootedObject parent_doc(ctx); /* instance of @document_class */ struct view_state *vs; struct document_view *doc_view; struct document *document; @@ -1988,21 +2013,15 @@ form_elements_get_property(JSContext *ctx, JS::HandleObject hobj, JS::HandleId h if (!JS_InstanceOf(ctx, hobj, &form_elements_class, NULL)) { return false; } - parent_form = JS_GetParent(hobj); - assert(JS_InstanceOf(ctx, parent_form, &form_class, NULL)); - if_assert_failed return false; - parent_doc = JS_GetParent(parent_form); - assert(JS_InstanceOf(ctx, parent_doc, &document_class, NULL)); - if_assert_failed return false; - parent_win = JS_GetParent(parent_doc); - assert(JS_InstanceOf(ctx, parent_win, &window_class, NULL)); - if_assert_failed return false; + JS::RootedObject parent_win(ctx, js::GetGlobalForObjectCrossCompartment(hobj)); vs = JS_GetInstancePrivate(ctx, parent_win, &window_class, NULL); doc_view = vs->doc_view; document = doc_view->document; - form_view = form_get_form_view(ctx, parent_form, NULL); + + form_view = JS_GetInstancePrivate(ctx, hobj, &form_elements_class, nullptr); +// form_view = form_get_form_view(ctx, nullptr, /*parent_form*/ NULL); if (!form_view) return false; /* detached */ form = find_form_by_form_view(document, form_view); @@ -2010,6 +2029,7 @@ form_elements_get_property(JSContext *ctx, JS::HandleObject hobj, JS::HandleId h JS::RootedValue r_idval(ctx, idval); JS_IdToValue(ctx, id, &r_idval); unsigned char *string = JS_EncodeString(ctx, r_idval.toString()); + form_elements_namedItem2(ctx, hobj, string, hvp); return true; } @@ -2038,7 +2058,7 @@ form_elements_get_property(JSContext *ctx, JS::HandleObject hobj, JS::HandleId h } static bool -form_elements_get_property_length(JSContext *ctx, unsigned int argc, jsval *vp) +form_elements_get_property_length(JSContext *ctx, unsigned int argc, JS::Value *vp) { JS::CallArgs args = CallArgsFromVp(argc, vp); JS::RootedObject hobj(ctx, &args.thisv().toObject()); @@ -2049,18 +2069,7 @@ form_elements_get_property_length(JSContext *ctx, unsigned int argc, jsval *vp) struct form_view *form_view; struct form *form; - JS::RootedObject parent_form(ctx, JS_GetParent(hobj)); - - assert(JS_InstanceOf(ctx, parent_form, &form_class, NULL)); - if_assert_failed return false; - - JS::RootedObject parent_doc(ctx, JS_GetParent(parent_form)); - assert(JS_InstanceOf(ctx, parent_doc, &document_class, NULL)); - if_assert_failed return false; - - JS::RootedObject parent_win(ctx, JS_GetParent(parent_doc)); - assert(JS_InstanceOf(ctx, parent_win, &window_class, NULL)); - if_assert_failed return false; + JS::RootedObject parent_win(ctx, js::GetGlobalForObjectCrossCompartment(hobj)); vs = JS_GetInstancePrivate(ctx, parent_win, &window_class, NULL); @@ -2068,9 +2077,11 @@ form_elements_get_property_length(JSContext *ctx, unsigned int argc, jsval *vp) if (!vs) { return false; } + doc_view = vs->doc_view; document = doc_view->document; - form_view = form_get_form_view(ctx, parent_form, NULL); + form_view = JS_GetInstancePrivate(ctx, hobj, &form_elements_class, nullptr); +// form_view = form_get_form_view(ctx, nullptr, /*parent_form*/ NULL); if (!form_view) return false; /* detached */ form = find_form_by_form_view(document, form_view); @@ -2082,9 +2093,9 @@ form_elements_get_property_length(JSContext *ctx, unsigned int argc, jsval *vp) /* @form_elements_funcs{"item"} */ static bool -form_elements_item(JSContext *ctx, unsigned int argc, jsval *vp) +form_elements_item(JSContext *ctx, unsigned int argc, JS::Value *vp) { - jsval val = JSVAL_VOID; + JS::Value val; JS::CallArgs args = JS::CallArgsFromVp(argc, vp); JS::RootedObject hobj(ctx, &args.thisv().toObject()); JS::RootedValue rval(ctx, val); @@ -2092,7 +2103,7 @@ form_elements_item(JSContext *ctx, unsigned int argc, jsval *vp) int index = args[0].toInt32(); bool ret = form_elements_item2(ctx, hobj, index, &rval); - args.rval().set(rval.get()); + args.rval().set(rval); return ret; } @@ -2102,7 +2113,6 @@ form_elements_item2(JSContext *ctx, JS::HandleObject hobj, int index, JS::Mutabl { JS::RootedObject parent_form(ctx); /* instance of @form_class */ JS::RootedObject parent_doc(ctx); /* instance of @document_class */ - JS::RootedObject parent_win(ctx); /* instance of @window_class */ struct view_state *vs; struct document_view *doc_view; struct document *document; @@ -2112,21 +2122,17 @@ form_elements_item2(JSContext *ctx, JS::HandleObject hobj, int index, JS::Mutabl int counter = -1; if (!JS_InstanceOf(ctx, hobj, &form_elements_class, NULL)) return false; - parent_form = JS_GetParent(hobj); - assert(JS_InstanceOf(ctx, parent_form, &form_class, NULL)); - if_assert_failed return false; - parent_doc = JS_GetParent(parent_form); - assert(JS_InstanceOf(ctx, parent_doc, &document_class, NULL)); - if_assert_failed return false; - parent_win = JS_GetParent(parent_doc); - assert(JS_InstanceOf(ctx, parent_win, &window_class, NULL)); - if_assert_failed return false; + JS::RootedObject parent_win(ctx, js::GetGlobalForObjectCrossCompartment(hobj)); vs = JS_GetInstancePrivate(ctx, parent_win, &window_class, NULL); doc_view = vs->doc_view; document = doc_view->document; - form_view = form_get_form_view(ctx, parent_form, NULL); + + form_view = JS_GetInstancePrivate(ctx, hobj, &form_elements_class, nullptr); + +// form_view = form_get_form_view(ctx, nullptr/*parent_form*/, NULL); + if (!form_view) return false; /* detached */ form = find_form_by_form_view(document, form_view); @@ -2138,7 +2144,7 @@ form_elements_item2(JSContext *ctx, JS::HandleObject hobj, int index, JS::Mutabl struct form_state *fs = find_form_state(doc_view, fc); if (fs) { - JSObject *fcobj = get_form_control_object(ctx, parent_form, fc->type, fs); + JSObject *fcobj = get_form_control_object(ctx, fc->type, fs); if (fcobj) { hvp.setObject(*fcobj); @@ -2153,15 +2159,15 @@ form_elements_item2(JSContext *ctx, JS::HandleObject hobj, int index, JS::Mutabl /* @form_elements_funcs{"namedItem"} */ static bool -form_elements_namedItem(JSContext *ctx, unsigned int argc, jsval *vp) +form_elements_namedItem(JSContext *ctx, unsigned int argc, JS::Value *vp) { - jsval val = JSVAL_VOID; + JS::Value val; JS::CallArgs args = JS::CallArgsFromVp(argc, vp); JS::RootedObject hobj(ctx, &args.thisv().toObject()); JS::RootedValue rval(ctx, val); -// jsval *argv = JS_ARGV(ctx, rval); +// JS::Value *argv = JS_ARGV(ctx, rval); unsigned char *string = JS_EncodeString(ctx, args[0].toString()); bool ret = form_elements_namedItem2(ctx, hobj, string, &rval); args.rval().set(rval); @@ -2174,7 +2180,6 @@ form_elements_namedItem2(JSContext *ctx, JS::HandleObject hobj, unsigned char *s { JS::RootedObject parent_form(ctx); /* instance of @form_class */ JS::RootedObject parent_doc(ctx); /* instance of @document_class */ - JS::RootedObject parent_win(ctx); /* instance of @window_class */ struct view_state *vs; struct document_view *doc_view; struct document *document; @@ -2187,21 +2192,24 @@ form_elements_namedItem2(JSContext *ctx, JS::HandleObject hobj, unsigned char *s } if (!JS_InstanceOf(ctx, hobj, &form_elements_class, NULL)) return false; - parent_form = JS_GetParent(hobj); - assert(JS_InstanceOf(ctx, parent_form, &form_class, NULL)); - if_assert_failed return false; - parent_doc = JS_GetParent(parent_form); - assert(JS_InstanceOf(ctx, parent_doc, &document_class, NULL)); - if_assert_failed return false; - parent_win = JS_GetParent(parent_doc); - assert(JS_InstanceOf(ctx, parent_win, &window_class, NULL)); - if_assert_failed return false; +// parent_form = js::GetGlobalForObjectCrossCompartment(hobj); +// assert(JS_InstanceOf(ctx, parent_form, &form_class, NULL)); +// if_assert_failed return false; +// parent_doc = js::GetGlobalForObjectCrossCompartment(parent_form); +// assert(JS_InstanceOf(ctx, parent_doc, &document_class, NULL)); +// if_assert_failed return false; +// parent_win = js::GetGlobalForObjectCrossCompartment(parent_doc); +// assert(JS_InstanceOf(ctx, parent_win, &window_class, NULL)); +// if_assert_failed return false; + JS::RootedObject parent_win(ctx, js::GetGlobalForObjectCrossCompartment(hobj)); vs = JS_GetInstancePrivate(ctx, parent_win, &window_class, NULL); doc_view = vs->doc_view; document = doc_view->document; - form_view = form_get_form_view(ctx, parent_form, NULL); + + form_view = JS_GetInstancePrivate(ctx, hobj, &form_elements_class, nullptr); +// form_view = form_get_form_view(ctx, nullptr, /*parent_form*/ NULL); if (!form_view) return false; /* detached */ form = find_form_by_form_view(document, form_view); @@ -2213,7 +2221,7 @@ form_elements_namedItem2(JSContext *ctx, JS::HandleObject hobj, unsigned char *s struct form_state *fs = find_form_state(doc_view, fc); if (fs) { - JSObject *fcobj = get_form_control_object(ctx, parent_form, fc->type, fs); + JSObject *fcobj = get_form_control_object(ctx, fc->type, fs); if (fcobj) { hvp.setObject(*fcobj); @@ -2253,8 +2261,8 @@ static JSPropertySpec form_props[] = { { NULL } }; -static bool form_reset(JSContext *ctx, unsigned int argc, jsval *rval); -static bool form_submit(JSContext *ctx, unsigned int argc, jsval *rval); +static bool form_reset(JSContext *ctx, unsigned int argc, JS::Value *rval); +static bool form_submit(JSContext *ctx, unsigned int argc, JS::Value *rval); static const spidermonkeyFunctionSpec form_funcs[] = { { "reset", form_reset, 0 }, @@ -2263,13 +2271,12 @@ static const spidermonkeyFunctionSpec form_funcs[] = { }; static struct form_view * -form_get_form_view(JSContext *ctx, JSObject *jsform, jsval *argv) +form_get_form_view(JSContext *ctx, JSObject *jsform, JS::Value *argv) { JS::RootedObject r_jsform(ctx, jsform); - JS::CallArgs args = JS::CallArgsFromVp(1, argv); struct form_view *fv = JS_GetInstancePrivate(ctx, r_jsform, &form_class, - &args); + NULL); if (!fv) return NULL; /* detached */ @@ -2287,7 +2294,6 @@ form_get_property(JSContext *ctx, JS::HandleObject hobj, JS::HandleId hid, JS::M jsid id = hid.get(); /* DBG("doc %p %s\n", parent_doc, JS_GetStringBytes(JS_ValueToString(ctx, OBJECT_TO_JSVAL(parent_doc)))); */ JS::RootedObject parent_doc(ctx); /* instance of @document_class */ - JS::RootedObject parent_win(ctx); /* instance of @window_class */ struct view_state *vs; struct document_view *doc_view; struct form_view *fv; @@ -2298,17 +2304,18 @@ form_get_property(JSContext *ctx, JS::HandleObject hobj, JS::HandleId hid, JS::M * such calls. */ if (!JS_InstanceOf(ctx, hobj, &form_class, NULL)) return false; - parent_doc = JS_GetParent(obj); - assert(JS_InstanceOf(ctx, parent_doc, &document_class, NULL)); - if_assert_failed return false; - parent_win = JS_GetParent(parent_doc); - assert(JS_InstanceOf(ctx, parent_win, &window_class, NULL)); - if_assert_failed return false; +// parent_doc = js::GetGlobalForObjectCrossCompartment(obj); +// assert(JS_InstanceOf(ctx, parent_doc, &document_class, NULL)); +// if_assert_failed return false; +// parent_win = js::GetGlobalForObjectCrossCompartment(parent_doc); +// assert(JS_InstanceOf(ctx, parent_win, &window_class, NULL)); +// if_assert_failed return false; + JS::RootedObject parent_win(ctx, js::GetGlobalForObjectCrossCompartment(hobj)); vs = JS_GetInstancePrivate(ctx, parent_win, &window_class, NULL); doc_view = vs->doc_view; - fv = form_get_form_view(ctx, obj, NULL); + fv = form_get_form_view(ctx, hobj, NULL); if (!fv) return false; /* detached */ form = find_form_by_form_view(doc_view->document, fv); @@ -2329,7 +2336,7 @@ form_get_property(JSContext *ctx, JS::HandleObject hobj, JS::HandleId hid, JS::M undef_to_jsval(ctx, vp); fs = find_form_state(doc_view, fc); if (fs) { - fcobj = get_form_control_object(ctx, obj, fc->type, fs); + fcobj = get_form_control_object(ctx, fc->type, fs); if (fcobj) object_to_jsval(ctx, vp, fcobj); } @@ -2351,7 +2358,7 @@ form_get_property(JSContext *ctx, JS::HandleObject hobj, JS::HandleId hid, JS::M case JSP_FORM_ELEMENTS: { /* jsform ('form') is form_elements' parent; who knows is that's correct */ - JSObject *jsform_elems = JS_NewObject(ctx, &form_elements_class, hobj); + JSObject *jsform_elems = JS_NewObjectWithGivenProto(ctx, &form_elements_class, hobj); JS::RootedObject r_jsform_elems(ctx, jsform_elems); @@ -2420,7 +2427,7 @@ form_get_property(JSContext *ctx, JS::HandleObject hobj, JS::HandleId hid, JS::M static bool -form_get_property_action(JSContext *ctx, unsigned int argc, jsval *vp) +form_get_property_action(JSContext *ctx, unsigned int argc, JS::Value *vp) { JS::CallArgs args = CallArgsFromVp(argc, vp); JS::RootedObject hobj(ctx, &args.thisv().toObject()); @@ -2436,13 +2443,14 @@ form_get_property_action(JSContext *ctx, unsigned int argc, jsval *vp) if (!JS_InstanceOf(ctx, hobj, &form_class, NULL)) return false; - JS::RootedObject parent_doc(ctx, JS_GetParent(hobj)); - assert(JS_InstanceOf(ctx, parent_doc, &document_class, NULL)); - if_assert_failed return false; - - JS::RootedObject parent_win(ctx, JS_GetParent(parent_doc)); - assert(JS_InstanceOf(ctx, parent_win, &window_class, NULL)); - if_assert_failed return false; +// JS::RootedObject parent_doc(ctx, js::GetGlobalForObjectCrossCompartment(hobj)); +// assert(JS_InstanceOf(ctx, parent_doc, &document_class, NULL)); +// if_assert_failed return false; +// +// JS::RootedObject parent_win(ctx, js::GetGlobalForObjectCrossCompartment(parent_doc)); +// assert(JS_InstanceOf(ctx, parent_win, &window_class, NULL)); +// if_assert_failed return false; + JS::RootedObject parent_win(ctx, js::GetGlobalForObjectCrossCompartment(hobj)); vs = JS_GetInstancePrivate(ctx, parent_win, &window_class, NULL); @@ -2461,7 +2469,7 @@ form_get_property_action(JSContext *ctx, unsigned int argc, jsval *vp) } static bool -form_set_property_action(JSContext *ctx, unsigned int argc, jsval *vp) +form_set_property_action(JSContext *ctx, unsigned int argc, JS::Value *vp) { JS::CallArgs args = CallArgsFromVp(argc, vp); JS::RootedObject hobj(ctx, &args.thisv().toObject()); @@ -2478,13 +2486,14 @@ form_set_property_action(JSContext *ctx, unsigned int argc, jsval *vp) if (!JS_InstanceOf(ctx, hobj, &form_class, NULL)) return false; - JS::RootedObject parent_doc(ctx, JS_GetParent(hobj)); - assert(JS_InstanceOf(ctx, parent_doc, &document_class, NULL)); - if_assert_failed return false; +// JS::RootedObject parent_doc(ctx, js::GetGlobalForObjectCrossCompartment(hobj)); +// assert(JS_InstanceOf(ctx, parent_doc, &document_class, NULL)); +// if_assert_failed return false; - JS::RootedObject parent_win(ctx, JS_GetParent(parent_doc)); - assert(JS_InstanceOf(ctx, parent_win, &window_class, NULL)); - if_assert_failed return false; +// JS::RootedObject parent_win(ctx, js::GetGlobalForObjectCrossCompartment(parent_doc)); +// assert(JS_InstanceOf(ctx, parent_win, &window_class, NULL)); +// if_assert_failed return false; + JS::RootedObject parent_win(ctx, js::GetGlobalForObjectCrossCompartment(hobj)); vs = JS_GetInstancePrivate(ctx, parent_win, &window_class, NULL); @@ -2509,7 +2518,7 @@ form_set_property_action(JSContext *ctx, unsigned int argc, jsval *vp) } static bool -form_get_property_elements(JSContext *ctx, unsigned int argc, jsval *vp) +form_get_property_elements(JSContext *ctx, unsigned int argc, JS::Value *vp) { JS::CallArgs args = CallArgsFromVp(argc, vp); JS::RootedObject hobj(ctx, &args.thisv().toObject()); @@ -2526,19 +2535,21 @@ form_get_property_elements(JSContext *ctx, unsigned int argc, jsval *vp) if (!fv) return false; /* detached */ /* jsform ('form') is form_elements' parent; who knows is that's correct */ - JSObject *jsform_elems = JS_NewObject(ctx, &form_elements_class, hobj); + JSObject *jsform_elems = JS_NewObjectWithGivenProto(ctx, &form_elements_class, hobj); JS::RootedObject r_jsform_elems(ctx, jsform_elems); JS_DefineProperties(ctx, r_jsform_elems, (JSPropertySpec *) form_elements_props); spidermonkey_DefineFunctions(ctx, jsform_elems, form_elements_funcs); + JS_SetPrivate(jsform_elems, fv); + args.rval().setObject(*jsform_elems); return true; } static bool -form_get_property_encoding(JSContext *ctx, unsigned int argc, jsval *vp) +form_get_property_encoding(JSContext *ctx, unsigned int argc, JS::Value *vp) { JS::CallArgs args = CallArgsFromVp(argc, vp); JS::RootedObject hobj(ctx, &args.thisv().toObject()); @@ -2554,13 +2565,14 @@ form_get_property_encoding(JSContext *ctx, unsigned int argc, jsval *vp) if (!JS_InstanceOf(ctx, hobj, &form_class, NULL)) return false; - JS::RootedObject parent_doc(ctx, JS_GetParent(hobj)); - assert(JS_InstanceOf(ctx, parent_doc, &document_class, NULL)); - if_assert_failed return false; +// JS::RootedObject parent_doc(ctx, js::GetGlobalForObjectCrossCompartment(hobj)); +// assert(JS_InstanceOf(ctx, parent_doc, &document_class, NULL)); +// if_assert_failed return false; - JS::RootedObject parent_win(ctx, JS_GetParent(parent_doc)); - assert(JS_InstanceOf(ctx, parent_win, &window_class, NULL)); - if_assert_failed return false; +// JS::RootedObject parent_win(ctx, js::GetGlobalForObjectCrossCompartment(parent_doc)); +// assert(JS_InstanceOf(ctx, parent_win, &window_class, NULL)); +// if_assert_failed return false; + JS::RootedObject parent_win(ctx, js::GetGlobalForObjectCrossCompartment(hobj)); vs = JS_GetInstancePrivate(ctx, parent_win, &window_class, NULL); @@ -2592,7 +2604,7 @@ form_get_property_encoding(JSContext *ctx, unsigned int argc, jsval *vp) /* @form_class.setProperty */ static bool -form_set_property_encoding(JSContext *ctx, unsigned int argc, jsval *vp) +form_set_property_encoding(JSContext *ctx, unsigned int argc, JS::Value *vp) { JS::CallArgs args = CallArgsFromVp(argc, vp); JS::RootedObject hobj(ctx, &args.thisv().toObject()); @@ -2609,13 +2621,14 @@ form_set_property_encoding(JSContext *ctx, unsigned int argc, jsval *vp) if (!JS_InstanceOf(ctx, hobj, &form_class, NULL)) return false; - JS::RootedObject parent_doc(ctx, JS_GetParent(hobj)); - assert(JS_InstanceOf(ctx, parent_doc, &document_class, NULL)); - if_assert_failed return false; +// JS::RootedObject parent_doc(ctx, js::GetGlobalForObjectCrossCompartment(hobj)); +// assert(JS_InstanceOf(ctx, parent_doc, &document_class, NULL)); +// if_assert_failed return false; - JS::RootedObject parent_win(ctx, JS_GetParent(parent_doc)); - assert(JS_InstanceOf(ctx, parent_win, &window_class, NULL)); - if_assert_failed return false; +// JS::RootedObject parent_win(ctx, js::GetGlobalForObjectCrossCompartment(parent_doc)); +// assert(JS_InstanceOf(ctx, parent_win, &window_class, NULL)); +// if_assert_failed return false; + JS::RootedObject parent_win(ctx, js::GetGlobalForObjectCrossCompartment(hobj)); vs = JS_GetInstancePrivate(ctx, parent_win, &window_class, NULL); @@ -2643,7 +2656,7 @@ form_set_property_encoding(JSContext *ctx, unsigned int argc, jsval *vp) } static bool -form_get_property_length(JSContext *ctx, unsigned int argc, jsval *vp) +form_get_property_length(JSContext *ctx, unsigned int argc, JS::Value *vp) { JS::CallArgs args = CallArgsFromVp(argc, vp); JS::RootedObject hobj(ctx, &args.thisv().toObject()); @@ -2659,13 +2672,14 @@ form_get_property_length(JSContext *ctx, unsigned int argc, jsval *vp) if (!JS_InstanceOf(ctx, hobj, &form_class, NULL)) return false; - JS::RootedObject parent_doc(ctx, JS_GetParent(hobj)); - assert(JS_InstanceOf(ctx, parent_doc, &document_class, NULL)); - if_assert_failed return false; - - JS::RootedObject parent_win(ctx, JS_GetParent(parent_doc)); - assert(JS_InstanceOf(ctx, parent_win, &window_class, NULL)); - if_assert_failed return false; +// JS::RootedObject parent_doc(ctx, js::GetGlobalForObjectCrossCompartment(hobj)); +// assert(JS_InstanceOf(ctx, parent_doc, &document_class, NULL)); +// if_assert_failed return false; +// +// JS::RootedObject parent_win(ctx, js::GetGlobalForObjectCrossCompartment(parent_doc)); +// assert(JS_InstanceOf(ctx, parent_win, &window_class, NULL)); +// if_assert_failed return false; + JS::RootedObject parent_win(ctx, js::GetGlobalForObjectCrossCompartment(hobj)); vs = JS_GetInstancePrivate(ctx, parent_win, &window_class, NULL); @@ -2685,7 +2699,7 @@ form_get_property_length(JSContext *ctx, unsigned int argc, jsval *vp) } static bool -form_get_property_method(JSContext *ctx, unsigned int argc, jsval *vp) +form_get_property_method(JSContext *ctx, unsigned int argc, JS::Value *vp) { JS::CallArgs args = CallArgsFromVp(argc, vp); JS::RootedObject hobj(ctx, &args.thisv().toObject()); @@ -2701,13 +2715,14 @@ form_get_property_method(JSContext *ctx, unsigned int argc, jsval *vp) if (!JS_InstanceOf(ctx, hobj, &form_class, NULL)) return false; - JS::RootedObject parent_doc(ctx, JS_GetParent(hobj)); - assert(JS_InstanceOf(ctx, parent_doc, &document_class, NULL)); - if_assert_failed return false; - - JS::RootedObject parent_win(ctx, JS_GetParent(parent_doc)); - assert(JS_InstanceOf(ctx, parent_win, &window_class, NULL)); - if_assert_failed return false; +// JS::RootedObject parent_doc(ctx, js::GetGlobalForObjectCrossCompartment(hobj)); +// assert(JS_InstanceOf(ctx, parent_doc, &document_class, NULL)); +// if_assert_failed return false; +// +// JS::RootedObject parent_win(ctx, js::GetGlobalForObjectCrossCompartment(parent_doc)); +// assert(JS_InstanceOf(ctx, parent_win, &window_class, NULL)); +// if_assert_failed return false; + JS::RootedObject parent_win(ctx, js::GetGlobalForObjectCrossCompartment(hobj)); vs = JS_GetInstancePrivate(ctx, parent_win, &window_class, NULL); @@ -2738,7 +2753,7 @@ form_get_property_method(JSContext *ctx, unsigned int argc, jsval *vp) /* @form_class.setProperty */ static bool -form_set_property_method(JSContext *ctx, unsigned int argc, jsval *vp) +form_set_property_method(JSContext *ctx, unsigned int argc, JS::Value *vp) { JS::CallArgs args = CallArgsFromVp(argc, vp); JS::RootedObject hobj(ctx, &args.thisv().toObject()); @@ -2755,13 +2770,14 @@ form_set_property_method(JSContext *ctx, unsigned int argc, jsval *vp) if (!JS_InstanceOf(ctx, hobj, &form_class, NULL)) return false; - JS::RootedObject parent_doc(ctx, JS_GetParent(hobj)); - assert(JS_InstanceOf(ctx, parent_doc, &document_class, NULL)); - if_assert_failed return false; +// JS::RootedObject parent_doc(ctx, js::GetGlobalForObjectCrossCompartment(hobj)); +// assert(JS_InstanceOf(ctx, parent_doc, &document_class, NULL)); +// if_assert_failed return false; - JS::RootedObject parent_win(ctx, JS_GetParent(parent_doc)); - assert(JS_InstanceOf(ctx, parent_win, &window_class, NULL)); - if_assert_failed return false; +// JS::RootedObject parent_win(ctx, js::GetGlobalForObjectCrossCompartment(parent_doc)); +// assert(JS_InstanceOf(ctx, parent_win, &window_class, NULL)); +// if_assert_failed return false; + JS::RootedObject parent_win(ctx, js::GetGlobalForObjectCrossCompartment(hobj)); vs = JS_GetInstancePrivate(ctx, parent_win, &window_class, NULL); @@ -2786,7 +2802,7 @@ form_set_property_method(JSContext *ctx, unsigned int argc, jsval *vp) } static bool -form_get_property_name(JSContext *ctx, unsigned int argc, jsval *vp) +form_get_property_name(JSContext *ctx, unsigned int argc, JS::Value *vp) { JS::CallArgs args = CallArgsFromVp(argc, vp); JS::RootedObject hobj(ctx, &args.thisv().toObject()); @@ -2802,13 +2818,14 @@ form_get_property_name(JSContext *ctx, unsigned int argc, jsval *vp) if (!JS_InstanceOf(ctx, hobj, &form_class, NULL)) return false; - JS::RootedObject parent_doc(ctx, JS_GetParent(hobj)); - assert(JS_InstanceOf(ctx, parent_doc, &document_class, NULL)); - if_assert_failed return false; +// JS::RootedObject parent_doc(ctx, js::GetGlobalForObjectCrossCompartment(hobj)); +// assert(JS_InstanceOf(ctx, parent_doc, &document_class, NULL)); +// if_assert_failed return false; - JS::RootedObject parent_win(ctx, JS_GetParent(parent_doc)); - assert(JS_InstanceOf(ctx, parent_win, &window_class, NULL)); - if_assert_failed return false; +// JS::RootedObject parent_win(ctx, js::GetGlobalForObjectCrossCompartment(parent_doc)); +// assert(JS_InstanceOf(ctx, parent_win, &window_class, NULL)); +// if_assert_failed return false; + JS::RootedObject parent_win(ctx, js::GetGlobalForObjectCrossCompartment(hobj)); vs = JS_GetInstancePrivate(ctx, parent_win, &window_class, NULL); @@ -2829,7 +2846,7 @@ form_get_property_name(JSContext *ctx, unsigned int argc, jsval *vp) /* @form_class.setProperty */ static bool -form_set_property_name(JSContext *ctx, unsigned int argc, jsval *vp) +form_set_property_name(JSContext *ctx, unsigned int argc, JS::Value *vp) { JS::CallArgs args = CallArgsFromVp(argc, vp); JS::RootedObject hobj(ctx, &args.thisv().toObject()); @@ -2845,13 +2862,14 @@ form_set_property_name(JSContext *ctx, unsigned int argc, jsval *vp) if (!JS_InstanceOf(ctx, hobj, &form_class, NULL)) return false; - JS::RootedObject parent_doc(ctx, JS_GetParent(hobj)); - assert(JS_InstanceOf(ctx, parent_doc, &document_class, NULL)); - if_assert_failed return false; +// JS::RootedObject parent_doc(ctx, js::GetGlobalForObjectCrossCompartment(hobj)); +// assert(JS_InstanceOf(ctx, parent_doc, &document_class, NULL)); +// if_assert_failed return false; - JS::RootedObject parent_win(ctx, JS_GetParent(parent_doc)); - assert(JS_InstanceOf(ctx, parent_win, &window_class, NULL)); - if_assert_failed return false; +// JS::RootedObject parent_win(ctx, js::GetGlobalForObjectCrossCompartment(parent_doc)); +// assert(JS_InstanceOf(ctx, parent_win, &window_class, NULL)); +// if_assert_failed return false; + JS::RootedObject parent_win(ctx, js::GetGlobalForObjectCrossCompartment(hobj)); vs = JS_GetInstancePrivate(ctx, parent_win, &window_class, NULL); @@ -2870,7 +2888,7 @@ form_set_property_name(JSContext *ctx, unsigned int argc, jsval *vp) } static bool -form_get_property_target(JSContext *ctx, unsigned int argc, jsval *vp) +form_get_property_target(JSContext *ctx, unsigned int argc, JS::Value *vp) { JS::CallArgs args = CallArgsFromVp(argc, vp); JS::RootedObject hobj(ctx, &args.thisv().toObject()); @@ -2886,13 +2904,14 @@ form_get_property_target(JSContext *ctx, unsigned int argc, jsval *vp) if (!JS_InstanceOf(ctx, hobj, &form_class, NULL)) return false; - JS::RootedObject parent_doc(ctx, JS_GetParent(hobj)); - assert(JS_InstanceOf(ctx, parent_doc, &document_class, NULL)); - if_assert_failed return false; +// JS::RootedObject parent_doc(ctx, js::GetGlobalForObjectCrossCompartment(hobj)); +// assert(JS_InstanceOf(ctx, parent_doc, &document_class, NULL)); +// if_assert_failed return false; - JS::RootedObject parent_win(ctx, JS_GetParent(parent_doc)); - assert(JS_InstanceOf(ctx, parent_win, &window_class, NULL)); - if_assert_failed return false; +// JS::RootedObject parent_win(ctx, js::GetGlobalForObjectCrossCompartment(parent_doc)); +// assert(JS_InstanceOf(ctx, parent_win, &window_class, NULL)); +// if_assert_failed return false; + JS::RootedObject parent_win(ctx, js::GetGlobalForObjectCrossCompartment(hobj)); vs = JS_GetInstancePrivate(ctx, parent_win, &window_class, NULL); @@ -2911,7 +2930,7 @@ form_get_property_target(JSContext *ctx, unsigned int argc, jsval *vp) } static bool -form_set_property_target(JSContext *ctx, unsigned int argc, jsval *vp) +form_set_property_target(JSContext *ctx, unsigned int argc, JS::Value *vp) { JS::CallArgs args = CallArgsFromVp(argc, vp); JS::RootedObject hobj(ctx, &args.thisv().toObject()); @@ -2927,13 +2946,14 @@ form_set_property_target(JSContext *ctx, unsigned int argc, jsval *vp) if (!JS_InstanceOf(ctx, hobj, &form_class, NULL)) return false; - JS::RootedObject parent_doc(ctx, JS_GetParent(hobj)); - assert(JS_InstanceOf(ctx, parent_doc, &document_class, NULL)); - if_assert_failed return false; +// JS::RootedObject parent_doc(ctx, js::GetGlobalForObjectCrossCompartment(hobj)); +// assert(JS_InstanceOf(ctx, parent_doc, &document_class, NULL)); +// if_assert_failed return false; - JS::RootedObject parent_win(ctx, JS_GetParent(parent_doc)); - assert(JS_InstanceOf(ctx, parent_win, &window_class, NULL)); - if_assert_failed return false; +// JS::RootedObject parent_win(ctx, js::GetGlobalForObjectCrossCompartment(parent_doc)); +// assert(JS_InstanceOf(ctx, parent_win, &window_class, NULL)); +// if_assert_failed return false; + JS::RootedObject parent_win(ctx, js::GetGlobalForObjectCrossCompartment(hobj)); vs = JS_GetInstancePrivate(ctx, parent_win, &window_class, NULL); @@ -2954,27 +2974,27 @@ form_set_property_target(JSContext *ctx, unsigned int argc, jsval *vp) /* @form_funcs{"reset"} */ static bool -form_reset(JSContext *ctx, unsigned int argc, jsval *rval) +form_reset(JSContext *ctx, unsigned int argc, JS::Value *rval) { - jsval val; + JS::Value val; JS::RootedObject parent_doc(ctx); /* instance of @document_class */ - JS::RootedObject parent_win(ctx); /* instance of @window_class */ JSObject *obj = JS_THIS_OBJECT(ctx, rval); JS::RootedObject hobj(ctx, obj); JS::CallArgs args = JS::CallArgsFromVp(argc, rval); -// jsval *argv = JS_ARGV(ctx, rval); +// JS::Value *argv = JS_ARGV(ctx, rval); struct view_state *vs; struct document_view *doc_view; struct form_view *fv; struct form *form; if (!JS_InstanceOf(ctx, hobj, &form_class, &args)) return false; - parent_doc = JS_GetParent(obj); - assert(JS_InstanceOf(ctx, parent_doc, &document_class, NULL)); - if_assert_failed return false; - parent_win = JS_GetParent(parent_doc); - assert(JS_InstanceOf(ctx, parent_win, &window_class, NULL)); - if_assert_failed return false; +// parent_doc = js::GetGlobalForObjectCrossCompartment(obj); +// assert(JS_InstanceOf(ctx, parent_doc, &document_class, NULL)); +// if_assert_failed return false; +// parent_win = js::GetGlobalForObjectCrossCompartment(parent_doc); +// assert(JS_InstanceOf(ctx, parent_win, &window_class, NULL)); +// if_assert_failed return false; + JS::RootedObject parent_win(ctx, js::GetGlobalForObjectCrossCompartment(hobj)); vs = JS_GetInstancePrivate(ctx, parent_win, &window_class, NULL); @@ -2996,15 +3016,14 @@ form_reset(JSContext *ctx, unsigned int argc, jsval *rval) /* @form_funcs{"submit"} */ static bool -form_submit(JSContext *ctx, unsigned int argc, jsval *rval) +form_submit(JSContext *ctx, unsigned int argc, JS::Value *rval) { - jsval val; + JS::Value val; JS::RootedObject parent_doc(ctx); /* instance of @document_class */ - JS::RootedObject parent_win(ctx); /* instance of @window_class */ JSObject *obj = JS_THIS_OBJECT(ctx, rval); JS::RootedObject hobj(ctx, obj); JS::CallArgs args = JS::CallArgsFromVp(argc, rval); -// jsval *argv = JS_ARGV(ctx, rval); +// JS::Value *argv = JS_ARGV(ctx, rval); struct view_state *vs; struct document_view *doc_view; struct session *ses; @@ -3012,12 +3031,13 @@ form_submit(JSContext *ctx, unsigned int argc, jsval *rval) struct form *form; if (!JS_InstanceOf(ctx, hobj, &form_class, &args)) return false; - parent_doc = JS_GetParent(obj); - assert(JS_InstanceOf(ctx, parent_doc, &document_class, NULL)); - if_assert_failed return false; - parent_win = JS_GetParent(parent_doc); - assert(JS_InstanceOf(ctx, parent_win, &window_class, NULL)); - if_assert_failed return false; +// parent_doc = js::GetGlobalForObjectCrossCompartment(obj); +// assert(JS_InstanceOf(ctx, parent_doc, &document_class, NULL)); +// if_assert_failed return false; +// parent_win = js::GetGlobalForObjectCrossCompartment(parent_doc); +// assert(JS_InstanceOf(ctx, parent_win, &window_class, NULL)); +// if_assert_failed return false; + JS::RootedObject parent_win(ctx, js::GetGlobalForObjectCrossCompartment(hobj)); vs = JS_GetInstancePrivate(ctx, parent_win, &window_class, NULL); @@ -3052,11 +3072,10 @@ get_form_object(JSContext *ctx, JSObject *jsdoc, struct form_view *fv) return jsform; } - JS::RootedObject r_jsdoc(ctx, jsdoc); /* jsdoc ('document') is fv's parent */ /* FIXME: That is NOT correct since the real containing element * should be its parent, but gimme DOM first. --pasky */ - jsform = JS_NewObject(ctx, &form_class, r_jsdoc); + jsform = JS_NewObject(ctx, &form_class); if (jsform == NULL) return NULL; JS::RootedObject r_jsform(ctx, jsform); @@ -3115,7 +3134,7 @@ spidermonkey_detach_form_view(struct form_view *fv) static bool forms_get_property(JSContext *ctx, JS::HandleObject hobj, JS::HandleId hid, JS::MutableHandleValue hvp); -static bool forms_get_property_length(JSContext *ctx, unsigned int argc, jsval *vp); +static bool forms_get_property_length(JSContext *ctx, unsigned int argc, JS::Value *vp); /* Each @forms_class object must have a @document_class parent. */ JSClass forms_class = { @@ -3126,9 +3145,9 @@ JSClass forms_class = { nullptr, nullptr, nullptr, nullptr }; -static bool forms_item(JSContext *ctx, unsigned int argc, jsval *rval); +static bool forms_item(JSContext *ctx, unsigned int argc, JS::Value *rval); static bool forms_item2(JSContext *ctx, JS::HandleObject hobj, int index, JS::MutableHandleValue hvp); -static bool forms_namedItem(JSContext *ctx, unsigned int argc, jsval *rval); +static bool forms_namedItem(JSContext *ctx, unsigned int argc, JS::Value *rval); const spidermonkeyFunctionSpec forms_funcs[] = { { "item", forms_item, 1 }, @@ -3152,7 +3171,7 @@ JSPropertySpec forms_props[] = { * string (but might not be). If found, set *rval = the DOM * object. If not found, leave *rval unchanged. */ static void -find_form_by_name(JSContext *ctx, JS::HandleObject jsdoc, +find_form_by_name(JSContext *ctx, struct document_view *doc_view, unsigned char *string, JS::MutableHandleValue hvp) { @@ -3163,7 +3182,7 @@ find_form_by_name(JSContext *ctx, JS::HandleObject jsdoc, foreach (form, doc_view->document->forms) { if (form->name && !c_strcasecmp(string, form->name)) { - hvp.setObject(*get_form_object(ctx, jsdoc, + hvp.setObject(*get_form_object(ctx, nullptr, find_form_view(doc_view, form))); break; } @@ -3176,9 +3195,8 @@ forms_get_property(JSContext *ctx, JS::HandleObject hobj, JS::HandleId hid, JS:: { jsid id = hid.get(); - jsval idval; - JS::RootedObject parent_doc(ctx); /* instance of @document_class */ - JS::RootedObject parent_win(ctx); /* instance of @window_class */ + JS::Value idval; +// JS::RootedObject parent_doc(ctx); /* instance of @document_class */ struct view_state *vs; struct document_view *doc_view; @@ -3188,13 +3206,7 @@ forms_get_property(JSContext *ctx, JS::HandleObject hobj, JS::HandleId hid, JS:: if (!JS_InstanceOf(ctx, hobj, &forms_class, NULL)) return false; - parent_doc = JS_GetParent(hobj); - assert(JS_InstanceOf(ctx, parent_doc, &document_class, NULL)); - if_assert_failed return false; - - parent_win = JS_GetParent(parent_doc); - assert(JS_InstanceOf(ctx, parent_win, &window_class, NULL)); - if_assert_failed return false; + JS::RootedObject parent_win(ctx, js::GetGlobalForObjectCrossCompartment(hobj)); vs = JS_GetInstancePrivate(ctx, parent_win, &window_class, NULL); @@ -3216,7 +3228,7 @@ forms_get_property(JSContext *ctx, JS::HandleObject hobj, JS::HandleId hid, JS:: * "TypeError: forms.namedItem is not a function". */ JS_IdToValue(ctx, id, &r_idval); unsigned char *string = JS_EncodeString(ctx, r_idval.toString()); - find_form_by_name(ctx, parent_doc, doc_view, string, hvp); + find_form_by_name(ctx, doc_view, string, hvp); return true; } @@ -3231,7 +3243,7 @@ forms_get_property(JSContext *ctx, JS::HandleObject hobj, JS::HandleId hid, JS:: } static bool -forms_get_property_length(JSContext *ctx, unsigned int argc, jsval *vp) +forms_get_property_length(JSContext *ctx, unsigned int argc, JS::Value *vp) { JS::CallArgs args = CallArgsFromVp(argc, vp); JS::RootedObject hobj(ctx, &args.thisv().toObject()); @@ -3246,13 +3258,14 @@ forms_get_property_length(JSContext *ctx, unsigned int argc, jsval *vp) if (!JS_InstanceOf(ctx, hobj, &forms_class, NULL)) return false; - JS::RootedObject parent_doc(ctx, JS_GetParent(hobj)); - assert(JS_InstanceOf(ctx, parent_doc, &document_class, NULL)); - if_assert_failed return false; +// JS::RootedObject parent_doc(ctx, js::GetGlobalForObjectCrossCompartment(hobj)); +// assert(JS_InstanceOf(ctx, parent_doc, &document_class, NULL)); +// if_assert_failed return false; - JS::RootedObject parent_win(ctx, JS_GetParent(parent_doc)); - assert(JS_InstanceOf(ctx, parent_win, &window_class, NULL)); - if_assert_failed return false; +// JS::RootedObject parent_win(ctx, js::GetGlobalForObjectCrossCompartment(parent_doc)); +// assert(JS_InstanceOf(ctx, parent_win, &window_class, NULL)); +// if_assert_failed return false; + JS::RootedObject parent_win(ctx, js::GetGlobalForObjectCrossCompartment(hobj)); vs = JS_GetInstancePrivate(ctx, parent_win, &window_class, NULL); @@ -3268,15 +3281,15 @@ forms_get_property_length(JSContext *ctx, unsigned int argc, jsval *vp) /* @forms_funcs{"item"} */ static bool -forms_item(JSContext *ctx, unsigned int argc, jsval *vp) +forms_item(JSContext *ctx, unsigned int argc, JS::Value *vp) { - jsval val = JSVAL_VOID; + JS::Value val; JS::CallArgs args = JS::CallArgsFromVp(argc, vp); JS::RootedObject hobj(ctx, &args.thisv().toObject()); JS::RootedValue rval(ctx, val); -// jsval *argv = JS_ARGV(ctx, rval); +// JS::Value *argv = JS_ARGV(ctx, rval); int index = args[0].toInt32(); bool ret = forms_item2(ctx, hobj, index, &rval); @@ -3288,8 +3301,7 @@ forms_item(JSContext *ctx, unsigned int argc, jsval *vp) static bool forms_item2(JSContext *ctx, JS::HandleObject hobj, int index, JS::MutableHandleValue hvp) { - JS::RootedObject parent_doc(ctx); /* instance of @document_class */ - JS::RootedObject parent_win(ctx); /* instance of @window_class */ +// JS::RootedObject parent_doc(ctx); /* instance of @document_class */ struct view_state *vs; struct form_view *fv; int counter = -1; @@ -3297,13 +3309,7 @@ forms_item2(JSContext *ctx, JS::HandleObject hobj, int index, JS::MutableHandleV if (!JS_InstanceOf(ctx, hobj, &forms_class, NULL)) return false; - parent_doc = JS_GetParent(hobj); - assert(JS_InstanceOf(ctx, parent_doc, &document_class, NULL)); - if_assert_failed return false; - - parent_win = JS_GetParent(parent_doc); - assert(JS_InstanceOf(ctx, parent_win, &window_class, NULL)); - if_assert_failed return false; + JS::RootedObject parent_win(ctx, js::GetGlobalForObjectCrossCompartment(hobj)); vs = JS_GetInstancePrivate(ctx, parent_win, &window_class, NULL); @@ -3313,7 +3319,7 @@ forms_item2(JSContext *ctx, JS::HandleObject hobj, int index, JS::MutableHandleV foreach (fv, vs->forms) { counter++; if (counter == index) { - hvp.setObject(*get_form_object(ctx, parent_doc, fv)); + hvp.setObject(*get_form_object(ctx, nullptr, fv)); break; } } @@ -3323,25 +3329,20 @@ forms_item2(JSContext *ctx, JS::HandleObject hobj, int index, JS::MutableHandleV /* @forms_funcs{"namedItem"} */ static bool -forms_namedItem(JSContext *ctx, unsigned int argc, jsval *vp) +forms_namedItem(JSContext *ctx, unsigned int argc, JS::Value *vp) { - jsval val; - JS::RootedObject parent_doc(ctx); /* instance of @document_class */ - JS::RootedObject parent_win(ctx); /* instance of @window_class */ + JS::Value val; +// JS::RootedObject parent_doc(ctx); /* instance of @document_class */ JS::CallArgs args = JS::CallArgsFromVp(argc, vp); JS::RootedObject hobj(ctx, &args.thisv().toObject()); -// jsval *argv = JS_ARGV(ctx, rval); +// JS::Value *argv = JS_ARGV(ctx, rval); struct view_state *vs; struct document_view *doc_view; if (!JS_InstanceOf(ctx, hobj, &forms_class, &args)) return false; - parent_doc = JS_GetParent(hobj); - assert(JS_InstanceOf(ctx, parent_doc, &document_class, NULL)); - if_assert_failed return false; - parent_win = JS_GetParent(parent_doc); - assert(JS_InstanceOf(ctx, parent_win, &window_class, NULL)); - if_assert_failed return false; + + JS::RootedObject parent_win(ctx, js::GetGlobalForObjectCrossCompartment(hobj)); vs = JS_GetInstancePrivate(ctx, parent_win, &window_class, NULL); @@ -3355,7 +3356,7 @@ forms_namedItem(JSContext *ctx, unsigned int argc, jsval *vp) JS::RootedValue rval(ctx, val); - find_form_by_name(ctx, parent_doc, doc_view, string, &rval); + find_form_by_name(ctx, doc_view, string, &rval); args.rval().set(rval.get()); return true; diff --git a/src/ecmascript/spidermonkey/location.c b/src/ecmascript/spidermonkey/location.c index c4399f83..2059f4b6 100644 --- a/src/ecmascript/spidermonkey/location.c +++ b/src/ecmascript/spidermonkey/location.c @@ -11,6 +11,7 @@ #include "elinks.h" #include "ecmascript/spidermonkey/util.h" +#include #include "bfu/dialog.h" #include "cache/cache.h" @@ -45,9 +46,9 @@ #include "viewer/text/vs.h" -static bool history_back(JSContext *ctx, unsigned int argc, jsval *rval); -static bool history_forward(JSContext *ctx, unsigned int argc, jsval *rval); -static bool history_go(JSContext *ctx, unsigned int argc, jsval *rval); +static bool history_back(JSContext *ctx, unsigned int argc, JS::Value *rval); +static bool history_forward(JSContext *ctx, unsigned int argc, JS::Value *rval); +static bool history_go(JSContext *ctx, unsigned int argc, JS::Value *rval); JSClass history_class = { "history", @@ -66,7 +67,7 @@ const spidermonkeyFunctionSpec history_funcs[] = { /* @history_funcs{"back"} */ static bool -history_back(JSContext *ctx, unsigned int argc, jsval *rval) +history_back(JSContext *ctx, unsigned int argc, JS::Value *rval) { struct ecmascript_interpreter *interpreter = JS_GetContextPrivate(ctx); struct document_view *doc_view = interpreter->vs->doc_view; @@ -85,7 +86,7 @@ history_back(JSContext *ctx, unsigned int argc, jsval *rval) /* @history_funcs{"forward"} */ static bool -history_forward(JSContext *ctx, unsigned int argc, jsval *rval) +history_forward(JSContext *ctx, unsigned int argc, JS::Value *rval) { struct ecmascript_interpreter *interpreter = JS_GetContextPrivate(ctx); struct document_view *doc_view = interpreter->vs->doc_view; @@ -100,7 +101,7 @@ history_forward(JSContext *ctx, unsigned int argc, jsval *rval) /* @history_funcs{"go"} */ static bool -history_go(JSContext *ctx, unsigned int argc, jsval *rval) +history_go(JSContext *ctx, unsigned int argc, JS::Value *rval) { struct ecmascript_interpreter *interpreter = JS_GetContextPrivate(ctx); struct document_view *doc_view = interpreter->vs->doc_view; @@ -130,8 +131,8 @@ history_go(JSContext *ctx, unsigned int argc, jsval *rval) } -static bool location_get_property_href(JSContext *ctx, unsigned int argc, jsval *vp); -static bool location_set_property_href(JSContext *ctx, unsigned int argc, jsval *vp); +static bool location_get_property_href(JSContext *ctx, unsigned int argc, JS::Value *vp); +static bool location_set_property_href(JSContext *ctx, unsigned int argc, JS::Value *vp); /* Each @location_class object must have a @window_class parent. */ JSClass location_class = { @@ -156,7 +157,7 @@ JSPropertySpec location_props[] = { static bool -location_get_property_href(JSContext *ctx, unsigned int argc, jsval *vp) +location_get_property_href(JSContext *ctx, unsigned int argc, JS::Value *vp) { JS::CallArgs args = CallArgsFromVp(argc, vp); JS::RootedObject hobj(ctx, &args.thisv().toObject()); @@ -169,7 +170,7 @@ location_get_property_href(JSContext *ctx, unsigned int argc, jsval *vp) if (!JS_InstanceOf(ctx, hobj, &location_class, NULL)) return false; - JS::RootedObject parent_win(ctx, JS_GetParent(hobj)); + JS::RootedObject parent_win(ctx, GetGlobalForObjectCrossCompartment(hobj)); assert(JS_InstanceOf(ctx, parent_win, &window_class, NULL)); if_assert_failed return false; @@ -192,7 +193,7 @@ location_get_property_href(JSContext *ctx, unsigned int argc, jsval *vp) } static bool -location_set_property_href(JSContext *ctx, unsigned int argc, jsval *vp) +location_set_property_href(JSContext *ctx, unsigned int argc, JS::Value *vp) { JS::CallArgs args = CallArgsFromVp(argc, vp); JS::RootedObject hobj(ctx, &args.thisv().toObject()); @@ -206,7 +207,7 @@ location_set_property_href(JSContext *ctx, unsigned int argc, jsval *vp) if (!JS_InstanceOf(ctx, hobj, &location_class, NULL)) return false; - JS::RootedObject parent_win(ctx, JS_GetParent(hobj)); + JS::RootedObject parent_win(ctx, GetGlobalForObjectCrossCompartment(hobj)); assert(JS_InstanceOf(ctx, parent_win, &window_class, NULL)); if_assert_failed return false; @@ -222,7 +223,7 @@ location_set_property_href(JSContext *ctx, unsigned int argc, jsval *vp) } -static bool location_toString(JSContext *ctx, unsigned int argc, jsval *rval); +static bool location_toString(JSContext *ctx, unsigned int argc, JS::Value *rval); const spidermonkeyFunctionSpec location_funcs[] = { { "toString", location_toString, 0 }, @@ -232,9 +233,9 @@ const spidermonkeyFunctionSpec location_funcs[] = { /* @location_funcs{"toString"}, @location_funcs{"toLocaleString"} */ static bool -location_toString(JSContext *ctx, unsigned int argc, jsval *rval) +location_toString(JSContext *ctx, unsigned int argc, JS::Value *rval) { - jsval val; + JS::Value val; JSObject *obj = JS_THIS_OBJECT(ctx, rval); JS::CallArgs args = JS::CallArgsFromVp(argc, rval); JS::RootedObject hobj(ctx, obj); diff --git a/src/ecmascript/spidermonkey/navigator.c b/src/ecmascript/spidermonkey/navigator.c index 4b3589aa..3bbfdf79 100644 --- a/src/ecmascript/spidermonkey/navigator.c +++ b/src/ecmascript/spidermonkey/navigator.c @@ -44,12 +44,12 @@ #include "viewer/text/vs.h" -static bool navigator_get_property_appCodeName(JSContext *ctx, unsigned int argc, jsval *vp); -static bool navigator_get_property_appName(JSContext *ctx, unsigned int argc, jsval *vp); -static bool navigator_get_property_appVersion(JSContext *ctx, unsigned int argc, jsval *vp); -static bool navigator_get_property_language(JSContext *ctx, unsigned int argc, jsval *vp); -static bool navigator_get_property_platform(JSContext *ctx, unsigned int argc, jsval *vp); -static bool navigator_get_property_userAgent(JSContext *ctx, unsigned int argc, jsval *vp); +static bool navigator_get_property_appCodeName(JSContext *ctx, unsigned int argc, JS::Value *vp); +static bool navigator_get_property_appName(JSContext *ctx, unsigned int argc, JS::Value *vp); +static bool navigator_get_property_appVersion(JSContext *ctx, unsigned int argc, JS::Value *vp); +static bool navigator_get_property_language(JSContext *ctx, unsigned int argc, JS::Value *vp); +static bool navigator_get_property_platform(JSContext *ctx, unsigned int argc, JS::Value *vp); +static bool navigator_get_property_userAgent(JSContext *ctx, unsigned int argc, JS::Value *vp); JSClass navigator_class = { "navigator", @@ -87,7 +87,7 @@ JSPropertySpec navigator_props[] = { /* @navigator_class.getProperty */ static bool -navigator_get_property_appCodeName(JSContext *ctx, unsigned int argc, jsval *vp) +navigator_get_property_appCodeName(JSContext *ctx, unsigned int argc, JS::Value *vp) { JS::CallArgs args = CallArgsFromVp(argc, vp); args.rval().setString(JS_NewStringCopyZ(ctx, "Mozilla")); /* More like a constant nowadays. */ @@ -96,7 +96,7 @@ navigator_get_property_appCodeName(JSContext *ctx, unsigned int argc, jsval *vp) } static bool -navigator_get_property_appName(JSContext *ctx, unsigned int argc, jsval *vp) +navigator_get_property_appName(JSContext *ctx, unsigned int argc, JS::Value *vp) { JS::CallArgs args = CallArgsFromVp(argc, vp); args.rval().setString(JS_NewStringCopyZ(ctx, @@ -106,7 +106,7 @@ navigator_get_property_appName(JSContext *ctx, unsigned int argc, jsval *vp) } static bool -navigator_get_property_appVersion(JSContext *ctx, unsigned int argc, jsval *vp) +navigator_get_property_appVersion(JSContext *ctx, unsigned int argc, JS::Value *vp) { JS::CallArgs args = CallArgsFromVp(argc, vp); args.rval().setString(JS_NewStringCopyZ(ctx, VERSION)); @@ -115,7 +115,7 @@ navigator_get_property_appVersion(JSContext *ctx, unsigned int argc, jsval *vp) } static bool -navigator_get_property_language(JSContext *ctx, unsigned int argc, jsval *vp) +navigator_get_property_language(JSContext *ctx, unsigned int argc, JS::Value *vp) { JS::CallArgs args = CallArgsFromVp(argc, vp); @@ -131,7 +131,7 @@ navigator_get_property_language(JSContext *ctx, unsigned int argc, jsval *vp) } static bool -navigator_get_property_platform(JSContext *ctx, unsigned int argc, jsval *vp) +navigator_get_property_platform(JSContext *ctx, unsigned int argc, JS::Value *vp) { JS::CallArgs args = CallArgsFromVp(argc, vp); args.rval().setString(JS_NewStringCopyZ(ctx, system_name)); @@ -140,7 +140,7 @@ navigator_get_property_platform(JSContext *ctx, unsigned int argc, jsval *vp) } static bool -navigator_get_property_userAgent(JSContext *ctx, unsigned int argc, jsval *vp) +navigator_get_property_userAgent(JSContext *ctx, unsigned int argc, JS::Value *vp) { JS::CallArgs args = CallArgsFromVp(argc, vp); unsigned char *optstr; diff --git a/src/ecmascript/spidermonkey/unibar.c b/src/ecmascript/spidermonkey/unibar.c index 1d3bdcfb..4a20598c 100644 --- a/src/ecmascript/spidermonkey/unibar.c +++ b/src/ecmascript/spidermonkey/unibar.c @@ -11,6 +11,7 @@ #include "elinks.h" #include "ecmascript/spidermonkey/util.h" +#include #include "bfu/dialog.h" #include "cache/cache.h" @@ -44,8 +45,8 @@ #include "viewer/text/link.h" #include "viewer/text/vs.h" -static bool unibar_get_property_visible(JSContext *ctx, unsigned int argc, jsval *vp); -static bool unibar_set_property_visible(JSContext *ctx, unsigned int argc, jsval *vp); +static bool unibar_get_property_visible(JSContext *ctx, unsigned int argc, JS::Value *vp); +static bool unibar_set_property_visible(JSContext *ctx, unsigned int argc, JS::Value *vp); /* Each @menubar_class object must have a @window_class parent. */ JSClass menubar_class = { @@ -79,7 +80,7 @@ JSPropertySpec unibar_props[] = { static bool -unibar_get_property_visible(JSContext *ctx, unsigned int argc, jsval *vp) +unibar_get_property_visible(JSContext *ctx, unsigned int argc, JS::Value *vp) { JS::CallArgs args = CallArgsFromVp(argc, vp); JS::RootedObject hobj(ctx, &args.thisv().toObject()); @@ -96,7 +97,7 @@ unibar_get_property_visible(JSContext *ctx, unsigned int argc, jsval *vp) && !JS_InstanceOf(ctx, hobj, &statusbar_class, NULL)) return false; - JS::RootedObject parent_win(ctx, JS_GetParent(hobj)); + JS::RootedObject parent_win(ctx, js::GetGlobalForObjectCrossCompartment(hobj)); assert(JS_InstanceOf(ctx, parent_win, &window_class, NULL)); if_assert_failed return false; @@ -130,7 +131,7 @@ unibar_get_property_visible(JSContext *ctx, unsigned int argc, jsval *vp) } static bool -unibar_set_property_visible(JSContext *ctx, unsigned int argc, jsval *vp) +unibar_set_property_visible(JSContext *ctx, unsigned int argc, JS::Value *vp) { JS::CallArgs args = CallArgsFromVp(argc, vp); JS::RootedObject hobj(ctx, &args.thisv().toObject()); @@ -147,7 +148,7 @@ unibar_set_property_visible(JSContext *ctx, unsigned int argc, jsval *vp) && !JS_InstanceOf(ctx, hobj, &statusbar_class, NULL)) return false; - JS::RootedObject parent_win(ctx, JS_GetParent(hobj)); + JS::RootedObject parent_win(ctx, js::GetGlobalForObjectCrossCompartment(hobj)); assert(JS_InstanceOf(ctx, parent_win, &window_class, NULL)); if_assert_failed return false; diff --git a/src/ecmascript/spidermonkey/util.h b/src/ecmascript/spidermonkey/util.h index a99cdea4..8911b979 100644 --- a/src/ecmascript/spidermonkey/util.h +++ b/src/ecmascript/spidermonkey/util.h @@ -5,56 +5,56 @@ #include "ecmascript/spidermonkey-shared.h" #include "util/memory.h" -static void string_to_jsval(JSContext *ctx, jsval *vp, unsigned char *string); -static void astring_to_jsval(JSContext *ctx, jsval *vp, unsigned char *string); -static void int_to_jsval(JSContext *ctx, jsval *vp, int number); -static void object_to_jsval(JSContext *ctx, jsval *vp, JSObject *object); -static void boolean_to_jsval(JSContext *ctx, jsval *vp, int boolean); +static void string_to_jsval(JSContext *ctx, JS::Value *vp, unsigned char *string); +static void astring_to_jsval(JSContext *ctx, JS::Value *vp, unsigned char *string); +static void int_to_jsval(JSContext *ctx, JS::Value *vp, int number); +static void object_to_jsval(JSContext *ctx, JS::Value *vp, JSObject *object); +static void boolean_to_jsval(JSContext *ctx, JS::Value *vp, int boolean); -static int jsval_to_boolean(JSContext *ctx, jsval *vp); +static int jsval_to_boolean(JSContext *ctx, JS::Value *vp); /** Inline functions */ static inline void -string_to_jsval(JSContext *ctx, jsval *vp, unsigned char *string) +string_to_jsval(JSContext *ctx, JS::Value *vp, unsigned char *string) { if (!string) { - *vp = JSVAL_NULL; + *vp = JS::NullValue(); } else { - *vp = STRING_TO_JSVAL(JS_NewStringCopyZ(ctx, string)); + *vp = JS::StringValue(JS_NewStringCopyZ(ctx, string)); } } static inline void -astring_to_jsval(JSContext *ctx, jsval *vp, unsigned char *string) +astring_to_jsval(JSContext *ctx, JS::Value *vp, unsigned char *string) { string_to_jsval(ctx, vp, string); mem_free_if(string); } static inline void -int_to_jsval(JSContext *ctx, jsval *vp, int number) +int_to_jsval(JSContext *ctx, JS::Value *vp, int number) { - *vp = INT_TO_JSVAL(number); + *vp = JS::Int32Value(number); } static inline void -object_to_jsval(JSContext *ctx, jsval *vp, JSObject *object) +object_to_jsval(JSContext *ctx, JS::Value *vp, JSObject *object) { - *vp = OBJECT_TO_JSVAL(object); + *vp = JS::ObjectValue(*object); } static inline void -boolean_to_jsval(JSContext *ctx, jsval *vp, int boolean) +boolean_to_jsval(JSContext *ctx, JS::Value *vp, int boolean) { - *vp = BOOLEAN_TO_JSVAL(boolean); + *vp = JS::BooleanValue(boolean); } static inline int -jsval_to_boolean(JSContext *ctx, jsval *vp) +jsval_to_boolean(JSContext *ctx, JS::Value *vp) { JS::RootedValue r_vp(ctx, *vp); return (int)r_vp.toBoolean(); diff --git a/src/ecmascript/spidermonkey/window.c b/src/ecmascript/spidermonkey/window.c index 6e5e9e3c..bd4f9d63 100644 --- a/src/ecmascript/spidermonkey/window.c +++ b/src/ecmascript/spidermonkey/window.c @@ -11,6 +11,7 @@ #include "elinks.h" #include "ecmascript/spidermonkey/util.h" +#include #include "bfu/dialog.h" #include "cache/cache.h" @@ -45,12 +46,12 @@ static bool window_get_property(JSContext *ctx, JS::HandleObject hobj, JS::HandleId hid, JS::MutableHandleValue hvp); -static bool window_get_property_closed(JSContext *cx, unsigned int argc, jsval *vp); -static bool window_get_property_parent(JSContext *ctx, unsigned int argc, jsval *vp); -static bool window_get_property_self(JSContext *ctx, unsigned int argc, jsval *vp); -static bool window_get_property_status(JSContext *ctx, unsigned int argc, jsval *vp); -static bool window_set_property_status(JSContext *ctx, unsigned int argc, jsval *vp); -static bool window_get_property_top(JSContext *ctx, unsigned int argc, jsval *vp); +static bool window_get_property_closed(JSContext *cx, unsigned int argc, JS::Value *vp); +static bool window_get_property_parent(JSContext *ctx, unsigned int argc, JS::Value *vp); +static bool window_get_property_self(JSContext *ctx, unsigned int argc, JS::Value *vp); +static bool window_get_property_status(JSContext *ctx, unsigned int argc, JS::Value *vp); +static bool window_set_property_status(JSContext *ctx, unsigned int argc, JS::Value *vp); +static bool window_get_property_top(JSContext *ctx, unsigned int argc, JS::Value *vp); JSClass window_class = { "window", @@ -129,7 +130,6 @@ find_child_frame(struct document_view *doc_view, struct frame_desc *tframe) static bool window_get_property(JSContext *ctx, JS::HandleObject hobj, JS::HandleId hid, JS::MutableHandleValue hvp) { - ELINKS_CAST_PROP_PARAMS jsid id = hid.get(); struct view_state *vs; @@ -152,7 +152,7 @@ window_get_property(JSContext *ctx, JS::HandleObject hobj, JS::HandleId hid, JS: /* TODO: Try other lookups (mainly element lookup) until * something yields data. */ if (obj) { - object_to_jsval(ctx, vp, obj); + hvp.setObject(*obj); } return true; } @@ -160,17 +160,17 @@ window_get_property(JSContext *ctx, JS::HandleObject hobj, JS::HandleId hid, JS: if (!JSID_IS_INT(id)) return true; - undef_to_jsval(ctx, vp); + hvp.setUndefined(); switch (JSID_TO_INT(id)) { case JSP_WIN_CLOSED: /* TODO: It will be a major PITA to implement this properly. * Well, perhaps not so much if we introduce reference tracking * for (struct session)? Still... --pasky */ - boolean_to_jsval(ctx, vp, 0); + hvp.setBoolean(false); break; case JSP_WIN_SELF: - object_to_jsval(ctx, vp, obj); + hvp.setObject(*hobj.get()); break; case JSP_WIN_PARENT: /* XXX: It would be nice if the following worked, yes. @@ -235,8 +235,9 @@ found_parent: * is alien but some other child window is not, we should still * let the script walk thru. That'd mean moving the check to * other individual properties in this switch. */ - if (compare_uri(vs->uri, top_view->vs->uri, URI_HOST)) - object_to_jsval(ctx, vp, newjsframe); + if (compare_uri(vs->uri, top_view->vs->uri, URI_HOST)) { + hvp.setObject(*newjsframe); + } /* else */ /****X*X*X*** SECURITY VIOLATION! RED ALERT, SHIELDS UP! ***X*X*X****\ |* (Pasky was apparently looking at the Links2 JS code . ___ ^.^ *| @@ -258,9 +259,9 @@ found_parent: void location_goto(struct document_view *doc_view, unsigned char *url); -static bool window_alert(JSContext *ctx, unsigned int argc, jsval *rval); -static bool window_open(JSContext *ctx, unsigned int argc, jsval *rval); -static bool window_setTimeout(JSContext *ctx, unsigned int argc, jsval *rval); +static bool window_alert(JSContext *ctx, unsigned int argc, JS::Value *rval); +static bool window_open(JSContext *ctx, unsigned int argc, JS::Value *rval); +static bool window_setTimeout(JSContext *ctx, unsigned int argc, JS::Value *rval); const spidermonkeyFunctionSpec window_funcs[] = { { "alert", window_alert, 1 }, @@ -271,24 +272,30 @@ const spidermonkeyFunctionSpec window_funcs[] = { /* @window_funcs{"alert"} */ static bool -window_alert(JSContext *ctx, unsigned int argc, jsval *rval) +window_alert(JSContext *ctx, unsigned int argc, JS::Value *rval) { - jsval val; + JS::Value val; JSObject *obj = JS_THIS_OBJECT(ctx, rval); JS::RootedObject hobj(ctx, obj); JS::CallArgs args = JS::CallArgsFromVp(argc, rval); -// jsval *argv = JS_ARGV(ctx, rval); + +// JS::Value *argv = JS_ARGV(ctx, rval); struct view_state *vs; unsigned char *string; - if (!JS_InstanceOf(ctx, hobj, &window_class, &args)) return false; + if (!JS_InstanceOf(ctx, hobj, &window_class, nullptr)) { + return false; + } - vs = JS_GetInstancePrivate(ctx, hobj, &window_class, &args); + vs = JS_GetInstancePrivate(ctx, hobj, &window_class, nullptr); if (argc != 1) return true; - string = jsval_to_string(ctx, args[0].address()); + JSString *str = JS::ToString(ctx, args[0]); + + string = JS_EncodeString(ctx, str); + if (!*string) return true; @@ -301,13 +308,13 @@ window_alert(JSContext *ctx, unsigned int argc, jsval *rval) /* @window_funcs{"open"} */ static bool -window_open(JSContext *ctx, unsigned int argc, jsval *rval) +window_open(JSContext *ctx, unsigned int argc, JS::Value *rval) { - jsval val; + JS::Value val; JSObject *obj = JS_THIS_OBJECT(ctx, rval); JS::RootedObject hobj(ctx, obj); JS::CallArgs args = JS::CallArgsFromVp(argc, rval); -// jsval *argv = JS_ARGV(ctx, rval); +// JS::Value *argv = JS_ARGV(ctx, rval); struct view_state *vs; struct document_view *doc_view; struct session *ses; @@ -414,10 +421,10 @@ end: /* @window_funcs{"setTimeout"} */ static bool -window_setTimeout(JSContext *ctx, unsigned int argc, jsval *rval) +window_setTimeout(JSContext *ctx, unsigned int argc, JS::Value *rval) { JS::CallArgs args = JS::CallArgsFromVp(argc, rval); -// jsval *argv = JS_ARGV(ctx, rval); +// JS::Value *argv = JS_ARGV(ctx, rval); struct ecmascript_interpreter *interpreter = JS_GetContextPrivate(ctx); unsigned char *code; int timeout; @@ -460,7 +467,7 @@ window_get_property_closed(JSContext *ctx, JS::HandleObject hobj, JS::HandleId h #endif static bool -window_get_property_closed(JSContext *ctx, unsigned int argc, jsval *vp) +window_get_property_closed(JSContext *ctx, unsigned int argc, JS::Value *vp) { JS::CallArgs args = CallArgsFromVp(argc, vp); args.rval().setBoolean(false); @@ -469,7 +476,7 @@ window_get_property_closed(JSContext *ctx, unsigned int argc, jsval *vp) } static bool -window_get_property_parent(JSContext *ctx, unsigned int argc, jsval *vp) +window_get_property_parent(JSContext *ctx, unsigned int argc, JS::Value *vp) { JS::CallArgs args = CallArgsFromVp(argc, vp); @@ -489,7 +496,7 @@ window_get_property_parent(JSContext *ctx, unsigned int argc, jsval *vp) } static bool -window_get_property_self(JSContext *ctx, unsigned int argc, jsval *vp) +window_get_property_self(JSContext *ctx, unsigned int argc, JS::Value *vp) { JS::CallArgs args = CallArgsFromVp(argc, vp); args.rval().setObject(args.thisv().toObject()); @@ -498,7 +505,7 @@ window_get_property_self(JSContext *ctx, unsigned int argc, jsval *vp) } static bool -window_get_property_status(JSContext *ctx, unsigned int argc, jsval *vp) +window_get_property_status(JSContext *ctx, unsigned int argc, JS::Value *vp) { JS::CallArgs args = CallArgsFromVp(argc, vp); args.rval().setUndefined(); @@ -507,7 +514,7 @@ window_get_property_status(JSContext *ctx, unsigned int argc, jsval *vp) } static bool -window_set_property_status(JSContext *ctx, unsigned int argc, jsval *vp) +window_set_property_status(JSContext *ctx, unsigned int argc, JS::Value *vp) { JS::CallArgs args = CallArgsFromVp(argc, vp); if (args.length() != 1) { @@ -529,7 +536,7 @@ window_set_property_status(JSContext *ctx, unsigned int argc, jsval *vp) } static bool -window_get_property_top(JSContext *ctx, unsigned int argc, jsval *vp) +window_get_property_top(JSContext *ctx, unsigned int argc, JS::Value *vp) { JS::CallArgs args = CallArgsFromVp(argc, vp); diff --git a/src/scripting/smjs/action_object.c b/src/scripting/smjs/action_object.c index 78d973c3..18c6aeb7 100644 --- a/src/scripting/smjs/action_object.c +++ b/src/scripting/smjs/action_object.c @@ -24,7 +24,7 @@ struct smjs_action_fn_callback_hop { }; static void smjs_action_fn_finalize(JSFreeOp *op, JSObject *obj); -static bool smjs_action_fn_callback(JSContext *ctx, unsigned int argc, jsval *rval); +static bool smjs_action_fn_callback(JSContext *ctx, unsigned int argc, JS::Value *rval); static const JSClass action_fn_class = { "action_fn", @@ -58,9 +58,9 @@ smjs_action_fn_finalize(JSFreeOp *op, JSObject *obj) /* @action_fn_class.call */ static bool -smjs_action_fn_callback(JSContext *ctx, unsigned int argc, jsval *rval) +smjs_action_fn_callback(JSContext *ctx, unsigned int argc, JS::Value *rval) { - jsval value; + JS::Value value; JS::CallArgs args = CallArgsFromVp(argc, rval); struct smjs_action_fn_callback_hop *hop; @@ -164,7 +164,7 @@ action_get_property(JSContext *ctx, JS::HandleObject hobj, JS::HandleId hid, JS: { jsid id = hid.get(); - jsval val; + JS::Value val; JS::RootedValue rval(ctx, val); JSObject *action_fn; unsigned char *action_str; @@ -206,7 +206,7 @@ smjs_get_action_object(void) void smjs_init_action_interface(void) { - jsval val; + JS::Value val; struct JSObject *action_object; if (!smjs_ctx || !smjs_elinks_object) diff --git a/src/scripting/smjs/bookmarks.c b/src/scripting/smjs/bookmarks.c index 82cd0d2d..fcedbaba 100644 --- a/src/scripting/smjs/bookmarks.c +++ b/src/scripting/smjs/bookmarks.c @@ -84,11 +84,11 @@ enum bookmark_prop { BOOKMARK_CHILDREN = -3, }; -static bool bookmark_get_property_title(JSContext *ctx, unsigned int argc, jsval *vp); -static bool bookmark_set_property_title(JSContext *ctx, unsigned int argc, jsval *vp); -static bool bookmark_get_property_url(JSContext *ctx, unsigned int argc, jsval *vp); -static bool bookmark_set_property_url(JSContext *ctx, unsigned int argc, jsval *vp); -static bool bookmark_get_property_children(JSContext *ctx, unsigned int argc, jsval *vp); +static bool bookmark_get_property_title(JSContext *ctx, unsigned int argc, JS::Value *vp); +static bool bookmark_set_property_title(JSContext *ctx, unsigned int argc, JS::Value *vp); +static bool bookmark_get_property_url(JSContext *ctx, unsigned int argc, JS::Value *vp); +static bool bookmark_set_property_url(JSContext *ctx, unsigned int argc, JS::Value *vp); +static bool bookmark_get_property_children(JSContext *ctx, unsigned int argc, JS::Value *vp); static const JSPropertySpec bookmark_props[] = { JS_PSGS("title", bookmark_get_property_title, bookmark_set_property_title, JSPROP_ENUMERATE), @@ -104,22 +104,22 @@ static JSObject *smjs_get_bookmark_folder_object(struct bookmark *bookmark); * @return true if successful. On error, report the error and * return false. */ static bool -bookmark_string_to_jsval(JSContext *ctx, const unsigned char *str, jsval *vp) +bookmark_string_to_jsval(JSContext *ctx, const unsigned char *str, JS::Value *vp) { JSString *jsstr = utf8_to_jsstring(ctx, str, -1); if (jsstr == NULL) return false; - *vp = STRING_TO_JSVAL(jsstr); + *vp = JS::StringValue(jsstr); return true; } -/** Convert a jsval to a string and store it in struct bookmark. +/** Convert a JS::Value to a string and store it in struct bookmark. * * @param ctx * Context for memory allocations and error reports. * @param val - * The @c jsval that should be converted. + * The @c JS::Value that should be converted. * @param[in,out] result * A string allocated with mem_alloc(). * On success, this function frees the original string, if any. @@ -149,7 +149,7 @@ jsval_to_bookmark_string(JSContext *ctx, JS::HandleValue val, unsigned char **re } static bool -bookmark_get_property_title(JSContext *ctx, unsigned int argc, jsval *vp) +bookmark_get_property_title(JSContext *ctx, unsigned int argc, JS::Value *vp) { JS::CallArgs args = CallArgsFromVp(argc, vp); JS::RootedObject hobj(ctx, &args.thisv().toObject()); @@ -177,7 +177,7 @@ bookmark_get_property_title(JSContext *ctx, unsigned int argc, jsval *vp) } static bool -bookmark_set_property_title(JSContext *ctx, unsigned int argc, jsval *vp) +bookmark_set_property_title(JSContext *ctx, unsigned int argc, JS::Value *vp) { JS::CallArgs args = CallArgsFromVp(argc, vp); JS::RootedObject hobj(ctx, &args.thisv().toObject()); @@ -208,7 +208,7 @@ bookmark_set_property_title(JSContext *ctx, unsigned int argc, jsval *vp) } static bool -bookmark_get_property_url(JSContext *ctx, unsigned int argc, jsval *vp) +bookmark_get_property_url(JSContext *ctx, unsigned int argc, JS::Value *vp) { JS::CallArgs args = CallArgsFromVp(argc, vp); JS::RootedObject hobj(ctx, &args.thisv().toObject()); @@ -236,7 +236,7 @@ bookmark_get_property_url(JSContext *ctx, unsigned int argc, jsval *vp) } static bool -bookmark_set_property_url(JSContext *ctx, unsigned int argc, jsval *vp) +bookmark_set_property_url(JSContext *ctx, unsigned int argc, JS::Value *vp) { JS::CallArgs args = CallArgsFromVp(argc, vp); JS::RootedObject hobj(ctx, &args.thisv().toObject()); @@ -267,7 +267,7 @@ bookmark_set_property_url(JSContext *ctx, unsigned int argc, jsval *vp) } static bool -bookmark_get_property_children(JSContext *ctx, unsigned int argc, jsval *vp) +bookmark_get_property_children(JSContext *ctx, unsigned int argc, JS::Value *vp) { JS::CallArgs args = CallArgsFromVp(argc, vp); JS::RootedObject hobj(ctx, &args.thisv().toObject()); @@ -319,7 +319,7 @@ bookmark_folder_get_property(JSContext *ctx, JS::HandleObject hobj, JS::HandleId struct bookmark *bookmark; struct bookmark *folder; - jsval val; + JS::Value val; JS::RootedValue title_jsval(ctx, val); unsigned char *title = NULL; @@ -360,7 +360,7 @@ smjs_get_bookmark_folder_object(struct bookmark *bookmark) void smjs_init_bookmarks_interface(void) { - jsval val; + JS::Value val; struct JSObject *bookmarks_object; if (!smjs_ctx || !smjs_elinks_object) diff --git a/src/scripting/smjs/cache_object.c b/src/scripting/smjs/cache_object.c index e9c35033..bd6204d2 100644 --- a/src/scripting/smjs/cache_object.c +++ b/src/scripting/smjs/cache_object.c @@ -37,14 +37,14 @@ enum cache_entry_prop { CACHE_ENTRY_URI = -5, }; -static bool cache_entry_get_property_content(JSContext *ctx, unsigned int argc, jsval *vp); -static bool cache_entry_set_property_content(JSContext *ctx, unsigned int argc, jsval *vp); -static bool cache_entry_get_property_type(JSContext *ctx, unsigned int argc, jsval *vp); -static bool cache_entry_set_property_type(JSContext *ctx, unsigned int argc, jsval *vp); -static bool cache_entry_get_property_length(JSContext *ctx, unsigned int argc, jsval *vp); -static bool cache_entry_get_property_head(JSContext *ctx, unsigned int argc, jsval *vp); -static bool cache_entry_set_property_head(JSContext *ctx, unsigned int argc, jsval *vp); -static bool cache_entry_get_property_uri(JSContext *ctx, unsigned int argc, jsval *vp); +static bool cache_entry_get_property_content(JSContext *ctx, unsigned int argc, JS::Value *vp); +static bool cache_entry_set_property_content(JSContext *ctx, unsigned int argc, JS::Value *vp); +static bool cache_entry_get_property_type(JSContext *ctx, unsigned int argc, JS::Value *vp); +static bool cache_entry_set_property_type(JSContext *ctx, unsigned int argc, JS::Value *vp); +static bool cache_entry_get_property_length(JSContext *ctx, unsigned int argc, JS::Value *vp); +static bool cache_entry_get_property_head(JSContext *ctx, unsigned int argc, JS::Value *vp); +static bool cache_entry_set_property_head(JSContext *ctx, unsigned int argc, JS::Value *vp); +static bool cache_entry_get_property_uri(JSContext *ctx, unsigned int argc, JS::Value *vp); static const JSPropertySpec cache_entry_props[] = { JS_PSGS("content", cache_entry_get_property_content, cache_entry_set_property_content, JSPROP_ENUMERATE), @@ -56,7 +56,7 @@ static const JSPropertySpec cache_entry_props[] = { }; static bool -cache_entry_get_property_content(JSContext *ctx, unsigned int argc, jsval *vp) +cache_entry_get_property_content(JSContext *ctx, unsigned int argc, JS::Value *vp) { JS::CallArgs args = CallArgsFromVp(argc, vp); JS::RootedObject hobj(ctx, &args.thisv().toObject()); @@ -100,7 +100,7 @@ cache_entry_get_property_content(JSContext *ctx, unsigned int argc, jsval *vp) } static bool -cache_entry_set_property_content(JSContext *ctx, unsigned int argc, jsval *vp) +cache_entry_set_property_content(JSContext *ctx, unsigned int argc, JS::Value *vp) { JS::CallArgs args = CallArgsFromVp(argc, vp); JS::RootedObject hobj(ctx, &args.thisv().toObject()); @@ -140,7 +140,7 @@ cache_entry_set_property_content(JSContext *ctx, unsigned int argc, jsval *vp) } static bool -cache_entry_get_property_type(JSContext *ctx, unsigned int argc, jsval *vp) +cache_entry_get_property_type(JSContext *ctx, unsigned int argc, JS::Value *vp) { JS::CallArgs args = CallArgsFromVp(argc, vp); JS::RootedObject hobj(ctx, &args.thisv().toObject()); @@ -172,7 +172,7 @@ cache_entry_get_property_type(JSContext *ctx, unsigned int argc, jsval *vp) } static bool -cache_entry_set_property_type(JSContext *ctx, unsigned int argc, jsval *vp) +cache_entry_set_property_type(JSContext *ctx, unsigned int argc, JS::Value *vp) { JS::CallArgs args = CallArgsFromVp(argc, vp); JS::RootedObject hobj(ctx, &args.thisv().toObject()); @@ -297,7 +297,7 @@ smjs_detach_cache_entry_object(struct cache_entry *cached) } static bool -cache_entry_get_property_length(JSContext *ctx, unsigned int argc, jsval *vp) +cache_entry_get_property_length(JSContext *ctx, unsigned int argc, JS::Value *vp) { JS::CallArgs args = CallArgsFromVp(argc, vp); JS::RootedObject hobj(ctx, &args.thisv().toObject()); @@ -329,7 +329,7 @@ cache_entry_get_property_length(JSContext *ctx, unsigned int argc, jsval *vp) } static bool -cache_entry_get_property_head(JSContext *ctx, unsigned int argc, jsval *vp) +cache_entry_get_property_head(JSContext *ctx, unsigned int argc, JS::Value *vp) { JS::CallArgs args = CallArgsFromVp(argc, vp); JS::RootedObject hobj(ctx, &args.thisv().toObject()); @@ -361,7 +361,7 @@ cache_entry_get_property_head(JSContext *ctx, unsigned int argc, jsval *vp) } static bool -cache_entry_set_property_head(JSContext *ctx, unsigned int argc, jsval *vp) +cache_entry_set_property_head(JSContext *ctx, unsigned int argc, JS::Value *vp) { JS::CallArgs args = CallArgsFromVp(argc, vp); JS::RootedObject hobj(ctx, &args.thisv().toObject()); @@ -399,7 +399,7 @@ cache_entry_set_property_head(JSContext *ctx, unsigned int argc, jsval *vp) } static bool -cache_entry_get_property_uri(JSContext *ctx, unsigned int argc, jsval *vp) +cache_entry_get_property_uri(JSContext *ctx, unsigned int argc, JS::Value *vp) { JS::CallArgs args = CallArgsFromVp(argc, vp); JS::RootedObject hobj(ctx, &args.thisv().toObject()); diff --git a/src/scripting/smjs/core.c b/src/scripting/smjs/core.c index 4d2ba394..94285c32 100644 --- a/src/scripting/smjs/core.c +++ b/src/scripting/smjs/core.c @@ -10,6 +10,7 @@ #include "config/home.h" #include "ecmascript/spidermonkey-shared.h" +#include #include "intl/charsets.h" #include "main/module.h" #include "osdep/osdep.h" @@ -41,6 +42,7 @@ error_reporter(JSContext *ctx, const char *message, JSErrorReport *report) { unsigned char *strict, *exception, *warning, *error; struct string msg; + char *prefix = nullptr; if (!init_string(&msg)) goto reported; @@ -55,14 +57,32 @@ error_reporter(JSContext *ctx, const char *message, JSErrorReport *report) add_to_string(&msg, ":\n\n"); add_to_string(&msg, message); - if (report->linebuf && report->tokenptr) { - int pos = report->tokenptr - report->linebuf; + add_format_to_string(&msg, "\n\n%d:%d ", report->lineno, report->column); + + if (report->filename) { + prefix = JS_smprintf("%s:", report->filename); + } + + if (report->lineno) { + char* tmp = prefix; + prefix = JS_smprintf("%s%u:%u ", tmp ? tmp : "", report->lineno, report->column); + JS_free(ctx, tmp); + } + + if (prefix) { + add_to_string(&msg, prefix); + } + +#if 0 + if (report->linebuf) { + int pos = report->offset; add_format_to_string(&msg, "\n\n%s\n.%*s^%*s.", report->linebuf, pos - 2, " ", strlen(report->linebuf) - pos - 1, " "); } +#endif alert_smjs_error(msg.source); done_string(&msg); @@ -79,14 +99,12 @@ smjs_do_file(unsigned char *path) if (!init_string(&script)) return 0; - jsval val; - JS::RootedValue rval(smjs_ctx, val); - JS::RootedObject cg(smjs_ctx, JS::CurrentGlobalOrNull(smjs_ctx)); - - JS::CompileOptions options(smjs_ctx); + JS::CompileOptions opts(smjs_ctx); + opts.setNoScriptRval(true); + JS::RootedValue rval(smjs_ctx); if (!add_file_to_string(&script, path) - || false == JS::Evaluate(smjs_ctx, cg, options, + || false == JS::Evaluate(smjs_ctx, opts, script.source, script.length, &rval)) { alert_smjs_error("error loading script file"); ret = 0; @@ -98,7 +116,7 @@ smjs_do_file(unsigned char *path) } static bool -smjs_do_file_wrapper(JSContext *ctx, unsigned int argc, jsval *rval) +smjs_do_file_wrapper(JSContext *ctx, unsigned int argc, JS::Value *rval) { JS::CallArgs args = CallArgsFromVp(argc, rval); diff --git a/src/scripting/smjs/elinks_object.c b/src/scripting/smjs/elinks_object.c index 7231b941..9a84ca18 100644 --- a/src/scripting/smjs/elinks_object.c +++ b/src/scripting/smjs/elinks_object.c @@ -33,7 +33,7 @@ /* @elinks_funcs{"alert"} */ static bool -elinks_alert(JSContext *ctx, unsigned int argc, jsval *rval) +elinks_alert(JSContext *ctx, unsigned int argc, JS::Value *rval) { JS::CallArgs args = CallArgsFromVp(argc, rval); @@ -69,7 +69,7 @@ elinks_alert(JSContext *ctx, unsigned int argc, jsval *rval) /* @elinks_funcs{"execute"} */ static bool -elinks_execute(JSContext *ctx, unsigned int argc, jsval *rval) +elinks_execute(JSContext *ctx, unsigned int argc, JS::Value *rval) { JS::CallArgs args = CallArgsFromVp(argc, rval); @@ -94,10 +94,10 @@ enum elinks_prop { ELINKS_SESSION, }; -static bool elinks_get_property_home(JSContext *ctx, unsigned int argc, jsval *vp); -static bool elinks_get_property_location(JSContext *ctx, unsigned int argc, jsval *vp); -static bool elinks_set_property_location(JSContext *ctx, unsigned int argc, jsval *vp); -static bool elinks_get_property_session(JSContext *ctx, unsigned int argc, jsval *vp); +static bool elinks_get_property_home(JSContext *ctx, unsigned int argc, JS::Value *vp); +static bool elinks_get_property_location(JSContext *ctx, unsigned int argc, JS::Value *vp); +static bool elinks_set_property_location(JSContext *ctx, unsigned int argc, JS::Value *vp); +static bool elinks_get_property_session(JSContext *ctx, unsigned int argc, JS::Value *vp); static const JSPropertySpec elinks_props[] = { JS_PSG("home", elinks_get_property_home, JSPROP_ENUMERATE), JS_PSGS("location", elinks_get_property_location, elinks_set_property_location, JSPROP_ENUMERATE), @@ -106,7 +106,7 @@ static const JSPropertySpec elinks_props[] = { }; static bool elinks_get_property(JSContext *ctx, JS::HandleObject hobj, JS::HandleId hid, JS::MutableHandleValue hvp); -static bool elinks_set_property(JSContext *ctx, JS::HandleObject hobj, JS::HandleId hid, bool strict, JS::MutableHandleValue hvp); +static bool elinks_set_property(JSContext *ctx, JS::HandleObject hobj, JS::HandleId hid, JS::MutableHandleValue hvp); static const JSClass elinks_class = { "elinks", @@ -176,7 +176,7 @@ elinks_get_property(JSContext *ctx, JS::HandleObject hobj, JS::HandleId hid, JS: } static bool -elinks_set_property(JSContext *ctx, JS::HandleObject hobj, JS::HandleId hid, bool strict, JS::MutableHandleValue hvp) +elinks_set_property(JSContext *ctx, JS::HandleObject hobj, JS::HandleId hid, JS::MutableHandleValue hvp) { jsid id = hid.get(); @@ -254,7 +254,7 @@ smjs_init_elinks_object(void) /* If elinks. is defined, call it with the given arguments, * store the return value in rval, and return true. Else return false. */ bool -smjs_invoke_elinks_object_method(unsigned char *method, int argc, jsval *argv, JS::MutableHandleValue rval) +smjs_invoke_elinks_object_method(unsigned char *method, int argc, JS::Value *argv, JS::MutableHandleValue rval) { JS::CallArgs args = CallArgsFromVp(argc, argv); @@ -263,7 +263,7 @@ smjs_invoke_elinks_object_method(unsigned char *method, int argc, jsval *argv, J assert(argv); JS::RootedObject r_smjs_elinks_object(smjs_ctx, smjs_elinks_object); - jsval val; + JS::Value val; JS::RootedValue fun(smjs_ctx, val); if (false == JS_GetProperty(smjs_ctx, r_smjs_elinks_object, @@ -277,7 +277,7 @@ smjs_invoke_elinks_object_method(unsigned char *method, int argc, jsval *argv, J } static bool -elinks_get_property_home(JSContext *ctx, unsigned int argc, jsval *vp) +elinks_get_property_home(JSContext *ctx, unsigned int argc, JS::Value *vp) { JS::CallArgs args = CallArgsFromVp(argc, vp); JS::RootedObject hobj(ctx, &args.thisv().toObject()); @@ -294,7 +294,7 @@ elinks_get_property_home(JSContext *ctx, unsigned int argc, jsval *vp) } static bool -elinks_get_property_location(JSContext *ctx, unsigned int argc, jsval *vp) +elinks_get_property_location(JSContext *ctx, unsigned int argc, JS::Value *vp) { JS::CallArgs args = CallArgsFromVp(argc, vp); JS::RootedObject hobj(ctx, &args.thisv().toObject()); @@ -316,7 +316,7 @@ elinks_get_property_location(JSContext *ctx, unsigned int argc, jsval *vp) } static bool -elinks_set_property_location(JSContext *ctx, unsigned int argc, jsval *vp) +elinks_set_property_location(JSContext *ctx, unsigned int argc, JS::Value *vp) { JS::CallArgs args = CallArgsFromVp(argc, vp); JS::RootedObject hobj(ctx, &args.thisv().toObject()); @@ -344,7 +344,7 @@ elinks_set_property_location(JSContext *ctx, unsigned int argc, jsval *vp) } static bool -elinks_get_property_session(JSContext *ctx, unsigned int argc, jsval *vp) +elinks_get_property_session(JSContext *ctx, unsigned int argc, JS::Value *vp) { JS::CallArgs args = CallArgsFromVp(argc, vp); JS::RootedObject hobj(ctx, &args.thisv().toObject()); diff --git a/src/scripting/smjs/elinks_object.h b/src/scripting/smjs/elinks_object.h index 5b519151..da9a6c54 100644 --- a/src/scripting/smjs/elinks_object.h +++ b/src/scripting/smjs/elinks_object.h @@ -12,6 +12,6 @@ void smjs_init_elinks_object(void); /* Invoke elinks. with the given arguments and put the return value * into *rval. */ -bool smjs_invoke_elinks_object_method(unsigned char *method, int argc, jsval *argv, JS::MutableHandleValue rval); +bool smjs_invoke_elinks_object_method(unsigned char *method, int argc, JS::Value *argv, JS::MutableHandleValue rval); #endif diff --git a/src/scripting/smjs/globhist.c b/src/scripting/smjs/globhist.c index 343985dd..52f618ac 100644 --- a/src/scripting/smjs/globhist.c +++ b/src/scripting/smjs/globhist.c @@ -13,7 +13,7 @@ #include "util/memory.h" static bool smjs_globhist_item_get_property(JSContext *ctx, JS::HandleObject hobj, JS::HandleId hid, JS::MutableHandleValue hvp); -static bool smjs_globhist_item_set_property(JSContext *ctx, JS::HandleObject hobj, JS::HandleId hid, bool strict, JS::MutableHandleValue hvp); +static bool smjs_globhist_item_set_property(JSContext *ctx, JS::HandleObject hobj, JS::HandleId hid, JS::MutableHandleValue hvp); static void smjs_globhist_item_finalize(JSFreeOp *op, JSObject *obj); @@ -51,12 +51,12 @@ enum smjs_globhist_item_prop { GLOBHIST_LAST_VISIT = -3, }; -static bool smjs_globhist_item_get_property_title(JSContext *ctx, unsigned int argc, jsval *vp); -static bool smjs_globhist_item_set_property_title(JSContext *ctx, unsigned int argc, jsval *vp); -static bool smjs_globhist_item_get_property_url(JSContext *ctx, unsigned int argc, jsval *vp); -static bool smjs_globhist_item_set_property_url(JSContext *ctx, unsigned int argc, jsval *vp); -static bool smjs_globhist_item_get_property_last_visit(JSContext *ctx, unsigned int argc, jsval *vp); -static bool smjs_globhist_item_set_property_last_visit(JSContext *ctx, unsigned int argc, jsval *vp); +static bool smjs_globhist_item_get_property_title(JSContext *ctx, unsigned int argc, JS::Value *vp); +static bool smjs_globhist_item_set_property_title(JSContext *ctx, unsigned int argc, JS::Value *vp); +static bool smjs_globhist_item_get_property_url(JSContext *ctx, unsigned int argc, JS::Value *vp); +static bool smjs_globhist_item_set_property_url(JSContext *ctx, unsigned int argc, JS::Value *vp); +static bool smjs_globhist_item_get_property_last_visit(JSContext *ctx, unsigned int argc, JS::Value *vp); +static bool smjs_globhist_item_set_property_last_visit(JSContext *ctx, unsigned int argc, JS::Value *vp); static const JSPropertySpec smjs_globhist_item_props[] = { JS_PSGS("title", smjs_globhist_item_get_property_title, smjs_globhist_item_set_property_title, JSPROP_ENUMERATE), @@ -133,7 +133,7 @@ smjs_globhist_item_get_property(JSContext *ctx, JS::HandleObject hobj, JS::Handl /* @smjs_globhist_item_class.setProperty */ static bool -smjs_globhist_item_set_property(JSContext *ctx, JS::HandleObject hobj, JS::HandleId hid, bool strict, JS::MutableHandleValue hvp) +smjs_globhist_item_set_property(JSContext *ctx, JS::HandleObject hobj, JS::HandleId hid, JS::MutableHandleValue hvp) { jsid id = hid.get(); @@ -217,7 +217,7 @@ smjs_globhist_get_property(JSContext *ctx, JS::HandleObject hobj, JS::HandleId h JSObject *jsobj; unsigned char *uri_string; struct global_history_item *history_item; - jsval tmp; + JS::Value tmp; JS::RootedValue r_tmp(ctx, tmp); @@ -264,7 +264,7 @@ smjs_get_globhist_object(void) void smjs_init_globhist_interface(void) { - jsval val; + JS::Value val; struct JSObject *globhist; if (!smjs_ctx || !smjs_elinks_object) @@ -281,7 +281,7 @@ smjs_init_globhist_interface(void) } static bool -smjs_globhist_item_get_property_title(JSContext *ctx, unsigned int argc, jsval *vp) +smjs_globhist_item_get_property_title(JSContext *ctx, unsigned int argc, JS::Value *vp) { JS::CallArgs args = CallArgsFromVp(argc, vp); JS::RootedObject hobj(ctx, &args.thisv().toObject()); @@ -306,7 +306,7 @@ smjs_globhist_item_get_property_title(JSContext *ctx, unsigned int argc, jsval * } static bool -smjs_globhist_item_set_property_title(JSContext *ctx, unsigned int argc, jsval *vp) +smjs_globhist_item_set_property_title(JSContext *ctx, unsigned int argc, JS::Value *vp) { JS::CallArgs args = CallArgsFromVp(argc, vp); JS::RootedObject hobj(ctx, &args.thisv().toObject()); @@ -335,7 +335,7 @@ smjs_globhist_item_set_property_title(JSContext *ctx, unsigned int argc, jsval * } static bool -smjs_globhist_item_get_property_url(JSContext *ctx, unsigned int argc, jsval *vp) +smjs_globhist_item_get_property_url(JSContext *ctx, unsigned int argc, JS::Value *vp) { JS::CallArgs args = CallArgsFromVp(argc, vp); JS::RootedObject hobj(ctx, &args.thisv().toObject()); @@ -360,7 +360,7 @@ smjs_globhist_item_get_property_url(JSContext *ctx, unsigned int argc, jsval *vp } static bool -smjs_globhist_item_set_property_url(JSContext *ctx, unsigned int argc, jsval *vp) +smjs_globhist_item_set_property_url(JSContext *ctx, unsigned int argc, JS::Value *vp) { JS::CallArgs args = CallArgsFromVp(argc, vp); JS::RootedObject hobj(ctx, &args.thisv().toObject()); @@ -389,7 +389,7 @@ smjs_globhist_item_set_property_url(JSContext *ctx, unsigned int argc, jsval *vp } static bool -smjs_globhist_item_get_property_last_visit(JSContext *ctx, unsigned int argc, jsval *vp) +smjs_globhist_item_get_property_last_visit(JSContext *ctx, unsigned int argc, JS::Value *vp) { JS::CallArgs args = CallArgsFromVp(argc, vp); JS::RootedObject hobj(ctx, &args.thisv().toObject()); @@ -431,7 +431,7 @@ smjs_globhist_item_get_property_last_visit(JSContext *ctx, unsigned int argc, js /* @smjs_globhist_item_class.setProperty */ static bool -smjs_globhist_item_set_property_last_visit(JSContext *ctx, unsigned int argc, jsval *vp) +smjs_globhist_item_set_property_last_visit(JSContext *ctx, unsigned int argc, JS::Value *vp) { JS::CallArgs args = CallArgsFromVp(argc, vp); JS::RootedObject hobj(ctx, &args.thisv().toObject()); diff --git a/src/scripting/smjs/hooks.c b/src/scripting/smjs/hooks.c index 9edb3be4..0359927a 100644 --- a/src/scripting/smjs/hooks.c +++ b/src/scripting/smjs/hooks.c @@ -27,7 +27,7 @@ script_hook_url(va_list ap, void *data) unsigned char **url = va_arg(ap, unsigned char **); struct session *ses = va_arg(ap, struct session *); enum evhook_status ret = EVENT_HOOK_STATUS_NEXT; - jsval args[3], rval; + JS::Value args[3], rval; JS::RootedValue r_rval(smjs_ctx, rval); if (*url == NULL) return EVENT_HOOK_STATUS_NEXT; @@ -59,7 +59,7 @@ script_hook_pre_format_html(va_list ap, void *data) struct cache_entry *cached = va_arg(ap, struct cache_entry *); enum evhook_status ret = EVENT_HOOK_STATUS_NEXT; JSObject *cache_entry_object, *view_state_object = NULL; - jsval args[4], rval; + JS::Value args[4], rval; JS::RootedValue r_rval(smjs_ctx, rval); evhook_use_params(ses && cached); diff --git a/src/scripting/smjs/keybinding.c b/src/scripting/smjs/keybinding.c index dc0aa03f..460d72b3 100644 --- a/src/scripting/smjs/keybinding.c +++ b/src/scripting/smjs/keybinding.c @@ -14,7 +14,7 @@ #include "util/memory.h" static bool keymap_get_property(JSContext *ctx, JS::HandleObject hobj, JS::HandleId hid, JS::MutableHandleValue hvp); -static bool keymap_set_property(JSContext *ctx, JS::HandleObject hobj, JS::HandleId hid, bool strict, JS::MutableHandleValue hvp); +static bool keymap_set_property(JSContext *ctx, JS::HandleObject hobj, JS::HandleId hid, JS::MutableHandleValue hvp); static void keymap_finalize(JSFreeOp *op, JSObject *obj); static const JSClass keymap_class = { @@ -34,7 +34,7 @@ keymap_get_property(JSContext *ctx, JS::HandleObject hobj, JS::HandleId hid, JS: unsigned char *action_str; const unsigned char *keystroke_str; int *data; - jsval tmp; + JS::Value tmp; JS::RootedValue r_tmp(ctx, tmp); /* This can be called if @obj if not itself an instance of the @@ -46,6 +46,8 @@ keymap_get_property(JSContext *ctx, JS::HandleObject hobj, JS::HandleId hid, JS: data = JS_GetInstancePrivate(ctx, hobj, (JSClass *) &keymap_class, NULL); + + if (!JS_IdToValue(ctx, id, &r_tmp)) goto ret_null; @@ -71,7 +73,7 @@ smjs_keybinding_action_callback(va_list ap, void *data) { JS::CallArgs args; - jsval rval; + JS::Value rval; JS::RootedValue r_rval(smjs_ctx, rval); struct session *ses = va_arg(ap, struct session *); JSObject *jsobj = data; @@ -80,11 +82,11 @@ smjs_keybinding_action_callback(va_list ap, void *data) smjs_ses = ses; - jsval r2; + JS::Value r2; JS::RootedValue r_jsobject(smjs_ctx, r2); r_jsobject.setObject(*jsobj); - JS_CallFunctionValue(smjs_ctx, JS::NullPtr(), r_jsobject, + JS_CallFunctionValue(smjs_ctx, nullptr, r_jsobject, args, &r_rval); smjs_ses = NULL; @@ -94,20 +96,20 @@ smjs_keybinding_action_callback(va_list ap, void *data) /* @keymap_class.setProperty */ static bool -keymap_set_property(JSContext *ctx, JS::HandleObject hobj, JS::HandleId hid, bool strict, JS::MutableHandleValue hvp) +keymap_set_property(JSContext *ctx, JS::HandleObject hobj, JS::HandleId hid, JS::MutableHandleValue hvp) { jsid id = hid.get(); int *data; unsigned char *keymap_str; - jsval val; const unsigned char *keystroke_str; /* This can be called if @obj if not itself an instance of the * appropriate class but has one in its prototype chain. Fail * such calls. */ - if (!JS_InstanceOf(ctx, hobj, (JSClass *) &keymap_class, NULL)) + if (!JS_InstanceOf(ctx, hobj, (JSClass *) &keymap_class, NULL)) { return false; + } data = JS_GetInstancePrivate(ctx, hobj, (JSClass *) &keymap_class, NULL); @@ -115,11 +117,13 @@ keymap_set_property(JSContext *ctx, JS::HandleObject hobj, JS::HandleId hid, boo /* Ugly fact: we need to get the string from the id to give to bind_do, * which will of course then convert the string back to an id... */ keymap_str = get_keymap_name((enum keymap_id) *data); + if (!keymap_str) return false; - JS::RootedValue rval(ctx, val); + JS::RootedValue rval(ctx); JS_IdToValue(ctx, id, &rval); keystroke_str = JS_EncodeString(ctx, rval.toString()); + if (!keystroke_str) return false; if (hvp.isString()) { @@ -134,6 +138,7 @@ keymap_set_property(JSContext *ctx, JS::HandleObject hobj, JS::HandleId hid, boo return true; } else if (hvp.isNull()) { /* before JSVAL_IS_OBJECT */ + if (bind_do(keymap_str, keystroke_str, "none", 0)) return false; @@ -226,7 +231,6 @@ static const JSClass keymaps_hash_class = { static JSObject * smjs_get_keymap_hash_object(void) { - jsval val; int keymap_id; JSObject *keymaps_hash; @@ -234,7 +238,7 @@ smjs_get_keymap_hash_object(void) if (!keymaps_hash) return NULL; JS::RootedObject r_keymaps_hash(smjs_ctx, keymaps_hash); - JS::RootedValue r_val(smjs_ctx, val); + JS::RootedValue r_val(smjs_ctx); for (keymap_id = 0; keymap_id < KEYMAP_MAX; ++keymap_id) { unsigned char *keymap_str = get_keymap_name(keymap_id); @@ -245,7 +249,6 @@ smjs_get_keymap_hash_object(void) if (!map) return NULL; r_val.setObject(*map); - JS_SetProperty(smjs_ctx, r_keymaps_hash, keymap_str, r_val); } @@ -255,7 +258,6 @@ smjs_get_keymap_hash_object(void) void smjs_init_keybinding_interface(void) { - jsval val; struct JSObject *keymaps_hash; if (!smjs_ctx || !smjs_elinks_object) @@ -264,7 +266,7 @@ smjs_init_keybinding_interface(void) keymaps_hash = smjs_get_keymap_hash_object(); if (!keymaps_hash) return; - JS::RootedValue r_val(smjs_ctx, val); + JS::RootedValue r_val(smjs_ctx); r_val.setObject(*keymaps_hash); JS::RootedObject r_smjs_elinks_object(smjs_ctx, smjs_elinks_object); diff --git a/src/scripting/smjs/load_uri.c b/src/scripting/smjs/load_uri.c index fd23efcf..646d6348 100644 --- a/src/scripting/smjs/load_uri.c +++ b/src/scripting/smjs/load_uri.c @@ -21,7 +21,7 @@ struct smjs_load_uri_hop { /* SpiderMonkey versions earlier than 1.8 cannot properly call * a closure if given just a JSFunction pointer. They need a - * jsval that points to the corresponding JSObject. Besides, + * JS::Value that points to the corresponding JSObject. Besides, * JS_AddNamedRoot is not documented to support JSFunction * pointers. */ JS::MutableHandleValue callback; @@ -33,7 +33,7 @@ smjs_loading_callback(struct download *download, void *data) struct session *saved_smjs_ses = smjs_ses; struct smjs_load_uri_hop *hop = data; - jsval args[1], rval; + JS::Value args[1], rval; JSObject *cache_entry_object; if (is_in_progress_state(download->state)) return; @@ -55,10 +55,10 @@ smjs_loading_callback(struct download *download, void *data) cache_entry_object = smjs_get_cache_entry_object(download->cached); if (!cache_entry_object) goto end; - args[0] = OBJECT_TO_JSVAL(cache_entry_object); + args[0] = JS::ObjectValue(*cache_entry_object); argv = CallArgsFromVp(1, args); - JS_CallFunctionValue(smjs_ctx, JS::NullPtr(), hop->callback, argv, &r_rval); + JS_CallFunctionValue(smjs_ctx, nullptr, hop->callback, argv, &r_rval); end: if (download->cached) @@ -70,7 +70,7 @@ end: } static bool -smjs_load_uri(JSContext *ctx, unsigned int argc, jsval *rval) +smjs_load_uri(JSContext *ctx, unsigned int argc, JS::Value *rval) { JS::CallArgs args = CallArgsFromVp(argc, rval); diff --git a/src/scripting/smjs/session_object.c b/src/scripting/smjs/session_object.c index 65f2eaea..8366e317 100644 --- a/src/scripting/smjs/session_object.c +++ b/src/scripting/smjs/session_object.c @@ -31,13 +31,13 @@ static JSObject *smjs_session_object; static bool session_get_property(JSContext *ctx, JS::HandleObject hobj, JS::HandleId hid, JS::MutableHandleValue hvp); -static bool session_set_property(JSContext *ctx, JS::HandleObject hobj, JS::HandleId hid, bool strict, JS::MutableHandleValue hvp); +static bool session_set_property(JSContext *ctx, JS::HandleObject hobj, JS::HandleId hid, JS::MutableHandleValue hvp); static void session_finalize(JSFreeOp *op, JSObject *obj); -static bool session_construct(JSContext *ctx, unsigned int argc, jsval *rval); +static bool session_construct(JSContext *ctx, unsigned int argc, JS::Value *rval); static const JSClass session_class = { "session", - JSCLASS_HAS_PRIVATE | JSCLASS_IMPLEMENTS_BARRIERS, /* struct session *; a weak reference */ + JSCLASS_HAS_PRIVATE, /* struct session *; a weak reference */ JS_PropertyStub, nullptr, session_get_property, session_set_property, nullptr, nullptr, nullptr, session_finalize, @@ -164,30 +164,30 @@ smjs_get_session_location_array_object(struct session *ses) * smjs_detach_session_object detaches both session.jsobject and * session.history.js_object. */ -static bool session_get_property_visited(JSContext *ctx, unsigned int argc, jsval *vp); -static bool session_set_property_visited(JSContext *ctx, unsigned int argc, jsval *vp); -static bool session_get_property_history(JSContext *ctx, unsigned int argc, jsval *vp); -static bool session_get_property_loading_uri(JSContext *ctx, unsigned int argc, jsval *vp); -static bool session_get_property_reloadlevel(JSContext *ctx, unsigned int argc, jsval *vp); -static bool session_set_property_reloadlevel(JSContext *ctx, unsigned int argc, jsval *vp); -static bool session_get_property_redirect_cnt(JSContext *ctx, unsigned int argc, jsval *vp); -static bool session_set_property_redirect_cnt(JSContext *ctx, unsigned int argc, jsval *vp); -static bool session_get_property_search_direction(JSContext *ctx, unsigned int argc, jsval *vp); -static bool session_set_property_search_direction(JSContext *ctx, unsigned int argc, jsval *vp); -static bool session_get_property_kbdprefix(JSContext *ctx, unsigned int argc, jsval *vp); -static bool session_set_property_kbdprefix(JSContext *ctx, unsigned int argc, jsval *vp); +static bool session_get_property_visited(JSContext *ctx, unsigned int argc, JS::Value *vp); +static bool session_set_property_visited(JSContext *ctx, unsigned int argc, JS::Value *vp); +static bool session_get_property_history(JSContext *ctx, unsigned int argc, JS::Value *vp); +static bool session_get_property_loading_uri(JSContext *ctx, unsigned int argc, JS::Value *vp); +static bool session_get_property_reloadlevel(JSContext *ctx, unsigned int argc, JS::Value *vp); +static bool session_set_property_reloadlevel(JSContext *ctx, unsigned int argc, JS::Value *vp); +static bool session_get_property_redirect_cnt(JSContext *ctx, unsigned int argc, JS::Value *vp); +static bool session_set_property_redirect_cnt(JSContext *ctx, unsigned int argc, JS::Value *vp); +static bool session_get_property_search_direction(JSContext *ctx, unsigned int argc, JS::Value *vp); +static bool session_set_property_search_direction(JSContext *ctx, unsigned int argc, JS::Value *vp); +static bool session_get_property_kbdprefix(JSContext *ctx, unsigned int argc, JS::Value *vp); +static bool session_set_property_kbdprefix(JSContext *ctx, unsigned int argc, JS::Value *vp); -static bool session_get_property_mark(JSContext *ctx, unsigned int argc, jsval *vp); -static bool session_set_property_mark(JSContext *ctx, unsigned int argc, jsval *vp); -static bool session_get_property_exit_query(JSContext *ctx, unsigned int argc, jsval *vp); -static bool session_get_property_insert_mode(JSContext *ctx, unsigned int argc, jsval *vp); -static bool session_set_property_insert_mode(JSContext *ctx, unsigned int argc, jsval *vp); -static bool session_get_property_navigate_mode(JSContext *ctx, unsigned int argc, jsval *vp); -static bool session_set_property_navigate_mode(JSContext *ctx, unsigned int argc, jsval *vp); -static bool session_get_property_search_word(JSContext *ctx, unsigned int argc, jsval *vp); -static bool session_set_property_search_word(JSContext *ctx, unsigned int argc, jsval *vp); -static bool session_get_property_last_search_word(JSContext *ctx, unsigned int argc, jsval *vp); -static bool session_set_property_last_search_word(JSContext *ctx, unsigned int argc, jsval *vp); +static bool session_get_property_mark(JSContext *ctx, unsigned int argc, JS::Value *vp); +static bool session_set_property_mark(JSContext *ctx, unsigned int argc, JS::Value *vp); +static bool session_get_property_exit_query(JSContext *ctx, unsigned int argc, JS::Value *vp); +static bool session_get_property_insert_mode(JSContext *ctx, unsigned int argc, JS::Value *vp); +static bool session_set_property_insert_mode(JSContext *ctx, unsigned int argc, JS::Value *vp); +static bool session_get_property_navigate_mode(JSContext *ctx, unsigned int argc, JS::Value *vp); +static bool session_set_property_navigate_mode(JSContext *ctx, unsigned int argc, JS::Value *vp); +static bool session_get_property_search_word(JSContext *ctx, unsigned int argc, JS::Value *vp); +static bool session_set_property_search_word(JSContext *ctx, unsigned int argc, JS::Value *vp); +static bool session_get_property_last_search_word(JSContext *ctx, unsigned int argc, JS::Value *vp); +static bool session_set_property_last_search_word(JSContext *ctx, unsigned int argc, JS::Value *vp); enum session_prop { SESSION_VISITED, @@ -229,7 +229,7 @@ static const JSPropertySpec session_props[] = { }; static bool -session_get_property_visited(JSContext *ctx, unsigned int argc, jsval *vp) +session_get_property_visited(JSContext *ctx, unsigned int argc, JS::Value *vp) { JS::CallArgs args = CallArgsFromVp(argc, vp); JS::RootedObject hobj(ctx, &args.thisv().toObject()); @@ -252,7 +252,7 @@ session_get_property_visited(JSContext *ctx, unsigned int argc, jsval *vp) } static bool -session_get_property_history(JSContext *ctx, unsigned int argc, jsval *vp) +session_get_property_history(JSContext *ctx, unsigned int argc, JS::Value *vp) { JS::CallArgs args = CallArgsFromVp(argc, vp); JS::RootedObject hobj(ctx, &args.thisv().toObject()); @@ -281,7 +281,7 @@ session_get_property_history(JSContext *ctx, unsigned int argc, jsval *vp) } static bool -session_get_property_loading_uri(JSContext *ctx, unsigned int argc, jsval *vp) +session_get_property_loading_uri(JSContext *ctx, unsigned int argc, JS::Value *vp) { JS::CallArgs args = CallArgsFromVp(argc, vp); JS::RootedObject hobj(ctx, &args.thisv().toObject()); @@ -311,7 +311,7 @@ session_get_property_loading_uri(JSContext *ctx, unsigned int argc, jsval *vp) } static bool -session_get_property_reloadlevel(JSContext *ctx, unsigned int argc, jsval *vp) +session_get_property_reloadlevel(JSContext *ctx, unsigned int argc, JS::Value *vp) { JS::CallArgs args = CallArgsFromVp(argc, vp); JS::RootedObject hobj(ctx, &args.thisv().toObject()); @@ -334,7 +334,7 @@ session_get_property_reloadlevel(JSContext *ctx, unsigned int argc, jsval *vp) } static bool -session_get_property_redirect_cnt(JSContext *ctx, unsigned int argc, jsval *vp) +session_get_property_redirect_cnt(JSContext *ctx, unsigned int argc, JS::Value *vp) { JS::CallArgs args = CallArgsFromVp(argc, vp); JS::RootedObject hobj(ctx, &args.thisv().toObject()); @@ -357,7 +357,7 @@ session_get_property_redirect_cnt(JSContext *ctx, unsigned int argc, jsval *vp) } static bool -session_get_property_search_direction(JSContext *ctx, unsigned int argc, jsval *vp) +session_get_property_search_direction(JSContext *ctx, unsigned int argc, JS::Value *vp) { JS::CallArgs args = CallArgsFromVp(argc, vp); JS::RootedObject hobj(ctx, &args.thisv().toObject()); @@ -380,7 +380,7 @@ session_get_property_search_direction(JSContext *ctx, unsigned int argc, jsval * } static bool -session_get_property_kbdprefix(JSContext *ctx, unsigned int argc, jsval *vp) +session_get_property_kbdprefix(JSContext *ctx, unsigned int argc, JS::Value *vp) { JS::CallArgs args = CallArgsFromVp(argc, vp); JS::RootedObject hobj(ctx, &args.thisv().toObject()); @@ -403,7 +403,7 @@ session_get_property_kbdprefix(JSContext *ctx, unsigned int argc, jsval *vp) } static bool -session_get_property_mark(JSContext *ctx, unsigned int argc, jsval *vp) +session_get_property_mark(JSContext *ctx, unsigned int argc, JS::Value *vp) { JS::CallArgs args = CallArgsFromVp(argc, vp); JS::RootedObject hobj(ctx, &args.thisv().toObject()); @@ -430,7 +430,7 @@ session_get_property_mark(JSContext *ctx, unsigned int argc, jsval *vp) } static bool -session_get_property_exit_query(JSContext *ctx, unsigned int argc, jsval *vp) +session_get_property_exit_query(JSContext *ctx, unsigned int argc, JS::Value *vp) { JS::CallArgs args = CallArgsFromVp(argc, vp); JS::RootedObject hobj(ctx, &args.thisv().toObject()); @@ -453,7 +453,7 @@ session_get_property_exit_query(JSContext *ctx, unsigned int argc, jsval *vp) } static bool -session_get_property_insert_mode(JSContext *ctx, unsigned int argc, jsval *vp) +session_get_property_insert_mode(JSContext *ctx, unsigned int argc, JS::Value *vp) { JS::CallArgs args = CallArgsFromVp(argc, vp); JS::RootedObject hobj(ctx, &args.thisv().toObject()); @@ -481,7 +481,7 @@ session_get_property_insert_mode(JSContext *ctx, unsigned int argc, jsval *vp) } static bool -session_get_property_navigate_mode(JSContext *ctx, unsigned int argc, jsval *vp) +session_get_property_navigate_mode(JSContext *ctx, unsigned int argc, JS::Value *vp) { JS::CallArgs args = CallArgsFromVp(argc, vp); JS::RootedObject hobj(ctx, &args.thisv().toObject()); @@ -507,7 +507,7 @@ session_get_property_navigate_mode(JSContext *ctx, unsigned int argc, jsval *vp) } static bool -session_get_property_search_word(JSContext *ctx, unsigned int argc, jsval *vp) +session_get_property_search_word(JSContext *ctx, unsigned int argc, JS::Value *vp) { JS::CallArgs args = CallArgsFromVp(argc, vp); JS::RootedObject hobj(ctx, &args.thisv().toObject()); @@ -530,7 +530,7 @@ session_get_property_search_word(JSContext *ctx, unsigned int argc, jsval *vp) } static bool -session_get_property_last_search_word(JSContext *ctx, unsigned int argc, jsval *vp) +session_get_property_last_search_word(JSContext *ctx, unsigned int argc, JS::Value *vp) { JS::CallArgs args = CallArgsFromVp(argc, vp); JS::RootedObject hobj(ctx, &args.thisv().toObject()); @@ -580,7 +580,7 @@ session_get_property(JSContext *ctx, JS::HandleObject hobj, JS::HandleId hid, JS } static bool -session_set_property_visited(JSContext *ctx, unsigned int argc, jsval *vp) +session_set_property_visited(JSContext *ctx, unsigned int argc, JS::Value *vp) { JS::CallArgs args = CallArgsFromVp(argc, vp); JS::RootedObject hobj(ctx, &args.thisv().toObject()); @@ -604,7 +604,7 @@ session_set_property_visited(JSContext *ctx, unsigned int argc, jsval *vp) } static bool -session_set_property_reloadlevel(JSContext *ctx, unsigned int argc, jsval *vp) +session_set_property_reloadlevel(JSContext *ctx, unsigned int argc, JS::Value *vp) { JS::CallArgs args = CallArgsFromVp(argc, vp); JS::RootedObject hobj(ctx, &args.thisv().toObject()); @@ -627,7 +627,7 @@ session_set_property_reloadlevel(JSContext *ctx, unsigned int argc, jsval *vp) } static bool -session_set_property_redirect_cnt(JSContext *ctx, unsigned int argc, jsval *vp) +session_set_property_redirect_cnt(JSContext *ctx, unsigned int argc, JS::Value *vp) { JS::CallArgs args = CallArgsFromVp(argc, vp); JS::RootedObject hobj(ctx, &args.thisv().toObject()); @@ -650,7 +650,7 @@ session_set_property_redirect_cnt(JSContext *ctx, unsigned int argc, jsval *vp) } static bool -session_set_property_search_direction(JSContext *ctx, unsigned int argc, jsval *vp) +session_set_property_search_direction(JSContext *ctx, unsigned int argc, JS::Value *vp) { JS::CallArgs args = CallArgsFromVp(argc, vp); JS::RootedObject hobj(ctx, &args.thisv().toObject()); @@ -687,7 +687,7 @@ session_set_property_search_direction(JSContext *ctx, unsigned int argc, jsval * } static bool -session_set_property_kbdprefix(JSContext *ctx, unsigned int argc, jsval *vp) +session_set_property_kbdprefix(JSContext *ctx, unsigned int argc, JS::Value *vp) { JS::CallArgs args = CallArgsFromVp(argc, vp); JS::RootedObject hobj(ctx, &args.thisv().toObject()); @@ -710,7 +710,7 @@ session_set_property_kbdprefix(JSContext *ctx, unsigned int argc, jsval *vp) } static bool -session_set_property_mark(JSContext *ctx, unsigned int argc, jsval *vp) +session_set_property_mark(JSContext *ctx, unsigned int argc, JS::Value *vp) { JS::CallArgs args = CallArgsFromVp(argc, vp); JS::RootedObject hobj(ctx, &args.thisv().toObject()); @@ -749,7 +749,7 @@ session_set_property_mark(JSContext *ctx, unsigned int argc, jsval *vp) } static bool -session_set_property_insert_mode(JSContext *ctx, unsigned int argc, jsval *vp) +session_set_property_insert_mode(JSContext *ctx, unsigned int argc, JS::Value *vp) { JS::CallArgs args = CallArgsFromVp(argc, vp); JS::RootedObject hobj(ctx, &args.thisv().toObject()); @@ -788,7 +788,7 @@ session_set_property_insert_mode(JSContext *ctx, unsigned int argc, jsval *vp) } static bool -session_set_property_navigate_mode(JSContext *ctx, unsigned int argc, jsval *vp) +session_set_property_navigate_mode(JSContext *ctx, unsigned int argc, JS::Value *vp) { JS::CallArgs args = CallArgsFromVp(argc, vp); JS::RootedObject hobj(ctx, &args.thisv().toObject()); @@ -825,7 +825,7 @@ session_set_property_navigate_mode(JSContext *ctx, unsigned int argc, jsval *vp) } static bool -session_set_property_search_word(JSContext *ctx, unsigned int argc, jsval *vp) +session_set_property_search_word(JSContext *ctx, unsigned int argc, JS::Value *vp) { JS::CallArgs args = CallArgsFromVp(argc, vp); JS::RootedObject hobj(ctx, &args.thisv().toObject()); @@ -857,7 +857,7 @@ session_set_property_search_word(JSContext *ctx, unsigned int argc, jsval *vp) } static bool -session_set_property_last_search_word(JSContext *ctx, unsigned int argc, jsval *vp) +session_set_property_last_search_word(JSContext *ctx, unsigned int argc, JS::Value *vp) { JS::CallArgs args = CallArgsFromVp(argc, vp); JS::RootedObject hobj(ctx, &args.thisv().toObject()); @@ -891,7 +891,7 @@ session_set_property_last_search_word(JSContext *ctx, unsigned int argc, jsval * static bool -session_set_property(JSContext *ctx, JS::HandleObject hobj, JS::HandleId hid, bool strict, JS::MutableHandleValue hvp) +session_set_property(JSContext *ctx, JS::HandleObject hobj, JS::HandleId hid, JS::MutableHandleValue hvp) { jsid id = hid.get(); @@ -916,12 +916,12 @@ session_set_property(JSContext *ctx, JS::HandleObject hobj, JS::HandleId hid, bo /** Pointed to by session_class.construct. Create a new session (tab) * and return the JSObject wrapper. */ static bool -session_construct(JSContext *ctx, unsigned int argc, jsval *rval) +session_construct(JSContext *ctx, unsigned int argc, JS::Value *rval) { JS::CallArgs args = CallArgsFromVp(argc, rval); //JS::RootedObject hobj(ctx, &args.thisv().toObject()); - jsval val; + JS::Value val; int bg = 0; /* open new tab in background */ struct session *ses; JSObject *jsobj; @@ -1124,7 +1124,7 @@ smjs_detach_session_array_object(struct terminal *term) } static bool -smjs_session_goto_url(JSContext *ctx, unsigned int argc, jsval *rval) +smjs_session_goto_url(JSContext *ctx, unsigned int argc, JS::Value *rval) { JS::CallArgs args = CallArgsFromVp(argc, rval); JS::RootedObject this_o(ctx, &args.thisv().toObject()); diff --git a/src/scripting/smjs/terminal_object.c b/src/scripting/smjs/terminal_object.c index bbc2633f..49506f65 100644 --- a/src/scripting/smjs/terminal_object.c +++ b/src/scripting/smjs/terminal_object.c @@ -209,7 +209,7 @@ smjs_get_terminal_array_object(void) void smjs_init_terminal_interface(void) { - jsval val; + JS::Value val; struct JSObject *obj; if (!smjs_ctx || !smjs_elinks_object) diff --git a/src/scripting/smjs/view_state_object.c b/src/scripting/smjs/view_state_object.c index 041616fa..be3ffca9 100644 --- a/src/scripting/smjs/view_state_object.c +++ b/src/scripting/smjs/view_state_object.c @@ -21,7 +21,7 @@ #include "viewer/text/vs.h" static bool view_state_get_property(JSContext *ctx, JS::HandleObject hobj, JS::HandleId hid, JS::MutableHandleValue hvp); -static bool view_state_set_property(JSContext *ctx, JS::HandleObject hobj, JS::HandleId hid, bool strict, JS::MutableHandleValue hvp); +static bool view_state_set_property(JSContext *ctx, JS::HandleObject hobj, JS::HandleId hid, JS::MutableHandleValue hvp); static void view_state_finalize(JSFreeOp *op, JSObject *obj); static const JSClass view_state_class = { @@ -42,7 +42,7 @@ enum view_state_prop { }; static bool -view_state_get_property_plain(JSContext *ctx, unsigned int argc, jsval *vp) +view_state_get_property_plain(JSContext *ctx, unsigned int argc, JS::Value *vp) { JS::CallArgs args = CallArgsFromVp(argc, vp); JS::RootedObject hobj(ctx, &args.thisv().toObject()); @@ -65,7 +65,7 @@ view_state_get_property_plain(JSContext *ctx, unsigned int argc, jsval *vp) } static bool -view_state_set_property_plain(JSContext *ctx, unsigned int argc, jsval *vp) +view_state_set_property_plain(JSContext *ctx, unsigned int argc, JS::Value *vp) { JS::CallArgs args = CallArgsFromVp(argc, vp); JS::RootedObject hobj(ctx, &args.thisv().toObject()); @@ -91,7 +91,7 @@ view_state_set_property_plain(JSContext *ctx, unsigned int argc, jsval *vp) } static bool -view_state_get_property_uri(JSContext *ctx, unsigned int argc, jsval *vp) +view_state_get_property_uri(JSContext *ctx, unsigned int argc, JS::Value *vp) { JS::CallArgs args = CallArgsFromVp(argc, vp); JS::RootedObject hobj(ctx, &args.thisv().toObject()); @@ -162,7 +162,7 @@ view_state_get_property(JSContext *ctx, JS::HandleObject hobj, JS::HandleId hid, /* @view_state_class.setProperty */ static bool -view_state_set_property(JSContext *ctx, JS::HandleObject hobj, JS::HandleId hid, bool strict, JS::MutableHandleValue hvp) +view_state_set_property(JSContext *ctx, JS::HandleObject hobj, JS::HandleId hid, JS::MutableHandleValue hvp) { jsid id = hid.get(); diff --git a/test/ecmascript/infinite.html b/test/ecmascript/infinite.html index f9f36eb4..ad229a87 100644 --- a/test/ecmascript/infinite.html +++ b/test/ecmascript/infinite.html @@ -1,3 +1,7 @@