mirror of
https://github.com/rkd77/elinks.git
synced 2024-10-11 05:29:28 -04:00
Bug 846: Add plenty of JS_InstanceOf assertions and checks.
(Adapted from 47dce0922b
in ELinks 0.12.GIT.)
This commit is contained in:
parent
9a829b3277
commit
0744d96213
@ -25,6 +25,7 @@
|
|||||||
#include "ecmascript/spidermonkey/form.h"
|
#include "ecmascript/spidermonkey/form.h"
|
||||||
#include "ecmascript/spidermonkey/location.h"
|
#include "ecmascript/spidermonkey/location.h"
|
||||||
#include "ecmascript/spidermonkey/document.h"
|
#include "ecmascript/spidermonkey/document.h"
|
||||||
|
#include "ecmascript/spidermonkey/window.h"
|
||||||
#include "intl/gettext/libintl.h"
|
#include "intl/gettext/libintl.h"
|
||||||
#include "main/select.h"
|
#include "main/select.h"
|
||||||
#include "osdep/newwin.h"
|
#include "osdep/newwin.h"
|
||||||
@ -79,7 +80,12 @@ document_get_property(JSContext *ctx, JSObject *obj, jsval id, jsval *vp)
|
|||||||
struct document *document;
|
struct document *document;
|
||||||
struct session *ses;
|
struct session *ses;
|
||||||
|
|
||||||
|
assert(JS_InstanceOf(ctx, obj, (JSClass *) &document_class, NULL));
|
||||||
|
if_assert_failed return JS_FALSE;
|
||||||
parent_win = JS_GetParent(ctx, obj);
|
parent_win = JS_GetParent(ctx, obj);
|
||||||
|
assert(JS_InstanceOf(ctx, parent_win, (JSClass *) &window_class, NULL));
|
||||||
|
if_assert_failed return JS_FALSE;
|
||||||
|
|
||||||
vs = JS_GetPrivate(ctx, parent_win); /* from @window_class */
|
vs = JS_GetPrivate(ctx, parent_win); /* from @window_class */
|
||||||
doc_view = vs->doc_view;
|
doc_view = vs->doc_view;
|
||||||
document = doc_view->document;
|
document = doc_view->document;
|
||||||
@ -168,7 +174,12 @@ document_set_property(JSContext *ctx, JSObject *obj, jsval id, jsval *vp)
|
|||||||
struct document_view *doc_view;
|
struct document_view *doc_view;
|
||||||
struct document *document;
|
struct document *document;
|
||||||
|
|
||||||
|
assert(JS_InstanceOf(ctx, obj, (JSClass *) &document_class, NULL));
|
||||||
|
if_assert_failed return JS_FALSE;
|
||||||
parent_win = JS_GetParent(ctx, obj);
|
parent_win = JS_GetParent(ctx, obj);
|
||||||
|
assert(JS_InstanceOf(ctx, parent_win, (JSClass *) &window_class, NULL));
|
||||||
|
if_assert_failed return JS_FALSE;
|
||||||
|
|
||||||
vs = JS_GetPrivate(ctx, parent_win); /* from @window_class */
|
vs = JS_GetPrivate(ctx, parent_win); /* from @window_class */
|
||||||
doc_view = vs->doc_view;
|
doc_view = vs->doc_view;
|
||||||
document = doc_view->document;
|
document = doc_view->document;
|
||||||
|
@ -22,7 +22,9 @@
|
|||||||
#include "document/forms.h"
|
#include "document/forms.h"
|
||||||
#include "document/view.h"
|
#include "document/view.h"
|
||||||
#include "ecmascript/ecmascript.h"
|
#include "ecmascript/ecmascript.h"
|
||||||
|
#include "ecmascript/spidermonkey/document.h"
|
||||||
#include "ecmascript/spidermonkey/form.h"
|
#include "ecmascript/spidermonkey/form.h"
|
||||||
|
#include "ecmascript/spidermonkey/window.h"
|
||||||
#include "intl/gettext/libintl.h"
|
#include "intl/gettext/libintl.h"
|
||||||
#include "main/select.h"
|
#include "main/select.h"
|
||||||
#include "osdep/newwin.h"
|
#include "osdep/newwin.h"
|
||||||
@ -44,6 +46,9 @@
|
|||||||
#include "viewer/text/vs.h"
|
#include "viewer/text/vs.h"
|
||||||
|
|
||||||
|
|
||||||
|
static const JSClass form_class; /* defined below */
|
||||||
|
|
||||||
|
|
||||||
/* Accordingly to the JS specs, each input type should own object. That'd be a
|
/* Accordingly to the JS specs, each input type should own object. That'd be a
|
||||||
* huge PITA though, however DOM comes to the rescue and defines just a single
|
* huge PITA though, however DOM comes to the rescue and defines just a single
|
||||||
* HTMLInputElement. The difference could be spotted only by some clever tricky
|
* HTMLInputElement. The difference could be spotted only by some clever tricky
|
||||||
@ -131,9 +136,18 @@ input_get_property(JSContext *ctx, JSObject *obj, jsval id, jsval *vp)
|
|||||||
int linknum;
|
int linknum;
|
||||||
struct link *link = NULL;
|
struct link *link = NULL;
|
||||||
|
|
||||||
|
assert(JS_InstanceOf(ctx, obj, (JSClass *) &input_class, NULL));
|
||||||
|
if_assert_failed return JS_FALSE;
|
||||||
parent_form = JS_GetParent(ctx, obj);
|
parent_form = JS_GetParent(ctx, obj);
|
||||||
|
assert(JS_InstanceOf(ctx, parent_form, (JSClass *) &form_class, NULL));
|
||||||
|
if_assert_failed return JS_FALSE;
|
||||||
parent_doc = JS_GetParent(ctx, parent_form);
|
parent_doc = JS_GetParent(ctx, parent_form);
|
||||||
|
assert(JS_InstanceOf(ctx, parent_doc, (JSClass *) &document_class, NULL));
|
||||||
|
if_assert_failed return JS_FALSE;
|
||||||
parent_win = JS_GetParent(ctx, parent_doc);
|
parent_win = JS_GetParent(ctx, parent_doc);
|
||||||
|
assert(JS_InstanceOf(ctx, parent_win, (JSClass *) &window_class, NULL));
|
||||||
|
if_assert_failed return JS_FALSE;
|
||||||
|
|
||||||
vs = JS_GetPrivate(ctx, parent_win); /* from @window_class */
|
vs = JS_GetPrivate(ctx, parent_win); /* from @window_class */
|
||||||
doc_view = vs->doc_view;
|
doc_view = vs->doc_view;
|
||||||
document = doc_view->document;
|
document = doc_view->document;
|
||||||
@ -253,9 +267,18 @@ input_set_property(JSContext *ctx, JSObject *obj, jsval id, jsval *vp)
|
|||||||
int linknum;
|
int linknum;
|
||||||
struct link *link = NULL;
|
struct link *link = NULL;
|
||||||
|
|
||||||
|
assert(JS_InstanceOf(ctx, obj, (JSClass *) &input_class, NULL));
|
||||||
|
if_assert_failed return JS_FALSE;
|
||||||
parent_form = JS_GetParent(ctx, obj);
|
parent_form = JS_GetParent(ctx, obj);
|
||||||
|
assert(JS_InstanceOf(ctx, parent_form, (JSClass *) &form_class, NULL));
|
||||||
|
if_assert_failed return JS_FALSE;
|
||||||
parent_doc = JS_GetParent(ctx, parent_form);
|
parent_doc = JS_GetParent(ctx, parent_form);
|
||||||
|
assert(JS_InstanceOf(ctx, parent_doc, (JSClass *) &document_class, NULL));
|
||||||
|
if_assert_failed return JS_FALSE;
|
||||||
parent_win = JS_GetParent(ctx, parent_doc);
|
parent_win = JS_GetParent(ctx, parent_doc);
|
||||||
|
assert(JS_InstanceOf(ctx, parent_win, (JSClass *) &window_class, NULL));
|
||||||
|
if_assert_failed return JS_FALSE;
|
||||||
|
|
||||||
vs = JS_GetPrivate(ctx, parent_win); /* from @window_class */
|
vs = JS_GetPrivate(ctx, parent_win); /* from @window_class */
|
||||||
doc_view = vs->doc_view;
|
doc_view = vs->doc_view;
|
||||||
document = doc_view->document;
|
document = doc_view->document;
|
||||||
@ -348,9 +371,17 @@ input_click(JSContext *ctx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
|
|||||||
struct form_control *fc;
|
struct form_control *fc;
|
||||||
int linknum;
|
int linknum;
|
||||||
|
|
||||||
|
if (!JS_InstanceOf(ctx, obj, (JSClass *) &input_class, argv)) return JS_FALSE;
|
||||||
parent_form = JS_GetParent(ctx, obj);
|
parent_form = JS_GetParent(ctx, obj);
|
||||||
|
assert(JS_InstanceOf(ctx, parent_form, (JSClass *) &form_class, NULL));
|
||||||
|
if_assert_failed return JS_FALSE;
|
||||||
parent_doc = JS_GetParent(ctx, parent_form);
|
parent_doc = JS_GetParent(ctx, parent_form);
|
||||||
|
assert(JS_InstanceOf(ctx, parent_doc, (JSClass *) &document_class, NULL));
|
||||||
|
if_assert_failed return JS_FALSE;
|
||||||
parent_win = JS_GetParent(ctx, parent_doc);
|
parent_win = JS_GetParent(ctx, parent_doc);
|
||||||
|
assert(JS_InstanceOf(ctx, parent_win, (JSClass *) &window_class, NULL));
|
||||||
|
if_assert_failed return JS_FALSE;
|
||||||
|
|
||||||
vs = JS_GetPrivate(ctx, parent_win); /* from @window_class */
|
vs = JS_GetPrivate(ctx, parent_win); /* from @window_class */
|
||||||
doc_view = vs->doc_view;
|
doc_view = vs->doc_view;
|
||||||
document = doc_view->document;
|
document = doc_view->document;
|
||||||
@ -392,9 +423,17 @@ input_focus(JSContext *ctx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
|
|||||||
struct form_control *fc;
|
struct form_control *fc;
|
||||||
int linknum;
|
int linknum;
|
||||||
|
|
||||||
|
if (!JS_InstanceOf(ctx, obj, (JSClass *) &input_class, argv)) return JS_FALSE;
|
||||||
parent_form = JS_GetParent(ctx, obj);
|
parent_form = JS_GetParent(ctx, obj);
|
||||||
|
assert(JS_InstanceOf(ctx, parent_form, (JSClass *) &form_class, NULL));
|
||||||
|
if_assert_failed return JS_FALSE;
|
||||||
parent_doc = JS_GetParent(ctx, parent_form);
|
parent_doc = JS_GetParent(ctx, parent_form);
|
||||||
|
assert(JS_InstanceOf(ctx, parent_doc, (JSClass *) &document_class, NULL));
|
||||||
|
if_assert_failed return JS_FALSE;
|
||||||
parent_win = JS_GetParent(ctx, parent_doc);
|
parent_win = JS_GetParent(ctx, parent_doc);
|
||||||
|
assert(JS_InstanceOf(ctx, parent_win, (JSClass *) &window_class, NULL));
|
||||||
|
if_assert_failed return JS_FALSE;
|
||||||
|
|
||||||
vs = JS_GetPrivate(ctx, parent_win); /* from @window_class */
|
vs = JS_GetPrivate(ctx, parent_win); /* from @window_class */
|
||||||
doc_view = vs->doc_view;
|
doc_view = vs->doc_view;
|
||||||
document = doc_view->document;
|
document = doc_view->document;
|
||||||
@ -512,9 +551,18 @@ form_elements_get_property(JSContext *ctx, JSObject *obj, jsval id, jsval *vp)
|
|||||||
struct form_view *form_view;
|
struct form_view *form_view;
|
||||||
struct form *form;
|
struct form *form;
|
||||||
|
|
||||||
|
assert(JS_InstanceOf(ctx, obj, (JSClass *) &form_elements_class, NULL));
|
||||||
|
if_assert_failed return JS_FALSE;
|
||||||
parent_form = JS_GetParent(ctx, obj);
|
parent_form = JS_GetParent(ctx, obj);
|
||||||
|
assert(JS_InstanceOf(ctx, parent_form, (JSClass *) &form_class, NULL));
|
||||||
|
if_assert_failed return JS_FALSE;
|
||||||
parent_doc = JS_GetParent(ctx, parent_form);
|
parent_doc = JS_GetParent(ctx, parent_form);
|
||||||
|
assert(JS_InstanceOf(ctx, parent_doc, (JSClass *) &document_class, NULL));
|
||||||
|
if_assert_failed return JS_FALSE;
|
||||||
parent_win = JS_GetParent(ctx, parent_doc);
|
parent_win = JS_GetParent(ctx, parent_doc);
|
||||||
|
assert(JS_InstanceOf(ctx, parent_win, (JSClass *) &window_class, NULL));
|
||||||
|
if_assert_failed return JS_FALSE;
|
||||||
|
|
||||||
vs = JS_GetPrivate(ctx, parent_win); /* from @window_class */
|
vs = JS_GetPrivate(ctx, parent_win); /* from @window_class */
|
||||||
doc_view = vs->doc_view;
|
doc_view = vs->doc_view;
|
||||||
document = doc_view->document;
|
document = doc_view->document;
|
||||||
@ -560,9 +608,17 @@ form_elements_item(JSContext *ctx, JSObject *obj, uintN argc, jsval *argv, jsval
|
|||||||
int counter = -1;
|
int counter = -1;
|
||||||
int index;
|
int index;
|
||||||
|
|
||||||
|
if (!JS_InstanceOf(ctx, obj, (JSClass *) &form_elements_class, argv)) return JS_FALSE;
|
||||||
parent_form = JS_GetParent(ctx, obj);
|
parent_form = JS_GetParent(ctx, obj);
|
||||||
|
assert(JS_InstanceOf(ctx, parent_form, (JSClass *) &form_class, NULL));
|
||||||
|
if_assert_failed return JS_FALSE;
|
||||||
parent_doc = JS_GetParent(ctx, parent_form);
|
parent_doc = JS_GetParent(ctx, parent_form);
|
||||||
|
assert(JS_InstanceOf(ctx, parent_doc, (JSClass *) &document_class, NULL));
|
||||||
|
if_assert_failed return JS_FALSE;
|
||||||
parent_win = JS_GetParent(ctx, parent_doc);
|
parent_win = JS_GetParent(ctx, parent_doc);
|
||||||
|
assert(JS_InstanceOf(ctx, parent_win, (JSClass *) &window_class, NULL));
|
||||||
|
if_assert_failed return JS_FALSE;
|
||||||
|
|
||||||
vs = JS_GetPrivate(ctx, parent_win); /* from @window_class */
|
vs = JS_GetPrivate(ctx, parent_win); /* from @window_class */
|
||||||
doc_view = vs->doc_view;
|
doc_view = vs->doc_view;
|
||||||
document = doc_view->document;
|
document = doc_view->document;
|
||||||
@ -606,9 +662,17 @@ form_elements_namedItem(JSContext *ctx, JSObject *obj, uintN argc, jsval *argv,
|
|||||||
struct form_control *fc;
|
struct form_control *fc;
|
||||||
unsigned char *string;
|
unsigned char *string;
|
||||||
|
|
||||||
|
if (!JS_InstanceOf(ctx, obj, (JSClass *) &form_elements_class, argv)) return JS_FALSE;
|
||||||
parent_form = JS_GetParent(ctx, obj);
|
parent_form = JS_GetParent(ctx, obj);
|
||||||
|
assert(JS_InstanceOf(ctx, parent_form, (JSClass *) &form_class, NULL));
|
||||||
|
if_assert_failed return JS_FALSE;
|
||||||
parent_doc = JS_GetParent(ctx, parent_form);
|
parent_doc = JS_GetParent(ctx, parent_form);
|
||||||
|
assert(JS_InstanceOf(ctx, parent_doc, (JSClass *) &document_class, NULL));
|
||||||
|
if_assert_failed return JS_FALSE;
|
||||||
parent_win = JS_GetParent(ctx, parent_doc);
|
parent_win = JS_GetParent(ctx, parent_doc);
|
||||||
|
assert(JS_InstanceOf(ctx, parent_win, (JSClass *) &window_class, NULL));
|
||||||
|
if_assert_failed return JS_FALSE;
|
||||||
|
|
||||||
vs = JS_GetPrivate(ctx, parent_win); /* from @window_class */
|
vs = JS_GetPrivate(ctx, parent_win); /* from @window_class */
|
||||||
doc_view = vs->doc_view;
|
doc_view = vs->doc_view;
|
||||||
document = doc_view->document;
|
document = doc_view->document;
|
||||||
@ -694,8 +758,15 @@ form_get_property(JSContext *ctx, JSObject *obj, jsval id, jsval *vp)
|
|||||||
struct form_view *fv;
|
struct form_view *fv;
|
||||||
struct form *form;
|
struct form *form;
|
||||||
|
|
||||||
|
assert(JS_InstanceOf(ctx, obj, (JSClass *) &form_class, NULL));
|
||||||
|
if_assert_failed return JS_FALSE;
|
||||||
parent_doc = JS_GetParent(ctx, obj);
|
parent_doc = JS_GetParent(ctx, obj);
|
||||||
|
assert(JS_InstanceOf(ctx, parent_doc, (JSClass *) &document_class, NULL));
|
||||||
|
if_assert_failed return JS_FALSE;
|
||||||
parent_win = JS_GetParent(ctx, parent_doc);
|
parent_win = JS_GetParent(ctx, parent_doc);
|
||||||
|
assert(JS_InstanceOf(ctx, parent_win, (JSClass *) &window_class, NULL));
|
||||||
|
if_assert_failed return JS_FALSE;
|
||||||
|
|
||||||
vs = JS_GetPrivate(ctx, parent_win); /* from @window_class */
|
vs = JS_GetPrivate(ctx, parent_win); /* from @window_class */
|
||||||
doc_view = vs->doc_view;
|
doc_view = vs->doc_view;
|
||||||
fv = JS_GetPrivate(ctx, obj); /* from @form_class */
|
fv = JS_GetPrivate(ctx, obj); /* from @form_class */
|
||||||
@ -809,8 +880,15 @@ form_set_property(JSContext *ctx, JSObject *obj, jsval id, jsval *vp)
|
|||||||
struct form *form;
|
struct form *form;
|
||||||
unsigned char *string;
|
unsigned char *string;
|
||||||
|
|
||||||
|
assert(JS_InstanceOf(ctx, obj, (JSClass *) &form_class, NULL));
|
||||||
|
if_assert_failed return JS_FALSE;
|
||||||
parent_doc = JS_GetParent(ctx, obj);
|
parent_doc = JS_GetParent(ctx, obj);
|
||||||
|
assert(JS_InstanceOf(ctx, parent_doc, (JSClass *) &document_class, NULL));
|
||||||
|
if_assert_failed return JS_FALSE;
|
||||||
parent_win = JS_GetParent(ctx, parent_doc);
|
parent_win = JS_GetParent(ctx, parent_doc);
|
||||||
|
assert(JS_InstanceOf(ctx, parent_win, (JSClass *) &window_class, NULL));
|
||||||
|
if_assert_failed return JS_FALSE;
|
||||||
|
|
||||||
vs = JS_GetPrivate(ctx, parent_win); /* from @window_class */
|
vs = JS_GetPrivate(ctx, parent_win); /* from @window_class */
|
||||||
doc_view = vs->doc_view;
|
doc_view = vs->doc_view;
|
||||||
fv = JS_GetPrivate(ctx, obj); /* from @form_class */
|
fv = JS_GetPrivate(ctx, obj); /* from @form_class */
|
||||||
@ -874,8 +952,14 @@ form_reset(JSContext *ctx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
|
|||||||
struct form_view *fv;
|
struct form_view *fv;
|
||||||
struct form *form;
|
struct form *form;
|
||||||
|
|
||||||
|
if (!JS_InstanceOf(ctx, obj, (JSClass *) &form_class, argv)) return JS_FALSE;
|
||||||
parent_doc = JS_GetParent(ctx, obj);
|
parent_doc = JS_GetParent(ctx, obj);
|
||||||
|
assert(JS_InstanceOf(ctx, parent_doc, (JSClass *) &document_class, NULL));
|
||||||
|
if_assert_failed return JS_FALSE;
|
||||||
parent_win = JS_GetParent(ctx, parent_doc);
|
parent_win = JS_GetParent(ctx, parent_doc);
|
||||||
|
assert(JS_InstanceOf(ctx, parent_win, (JSClass *) &window_class, NULL));
|
||||||
|
if_assert_failed return JS_FALSE;
|
||||||
|
|
||||||
vs = JS_GetPrivate(ctx, parent_win); /* from @window_class */
|
vs = JS_GetPrivate(ctx, parent_win); /* from @window_class */
|
||||||
doc_view = vs->doc_view;
|
doc_view = vs->doc_view;
|
||||||
fv = JS_GetPrivate(ctx, obj); /* from @form_class */
|
fv = JS_GetPrivate(ctx, obj); /* from @form_class */
|
||||||
@ -903,8 +987,14 @@ form_submit(JSContext *ctx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
|
|||||||
struct form_view *fv;
|
struct form_view *fv;
|
||||||
struct form *form;
|
struct form *form;
|
||||||
|
|
||||||
|
if (!JS_InstanceOf(ctx, obj, (JSClass *) &form_class, argv)) return JS_FALSE;
|
||||||
parent_doc = JS_GetParent(ctx, obj);
|
parent_doc = JS_GetParent(ctx, obj);
|
||||||
|
assert(JS_InstanceOf(ctx, parent_doc, (JSClass *) &document_class, NULL));
|
||||||
|
if_assert_failed return JS_FALSE;
|
||||||
parent_win = JS_GetParent(ctx, parent_doc);
|
parent_win = JS_GetParent(ctx, parent_doc);
|
||||||
|
assert(JS_InstanceOf(ctx, parent_win, (JSClass *) &window_class, NULL));
|
||||||
|
if_assert_failed return JS_FALSE;
|
||||||
|
|
||||||
vs = JS_GetPrivate(ctx, parent_win); /* from @window_class */
|
vs = JS_GetPrivate(ctx, parent_win); /* from @window_class */
|
||||||
doc_view = vs->doc_view;
|
doc_view = vs->doc_view;
|
||||||
ses = doc_view->session;
|
ses = doc_view->session;
|
||||||
@ -935,8 +1025,6 @@ get_form_object(JSContext *ctx, JSObject *jsdoc, struct form_view *fv)
|
|||||||
}
|
}
|
||||||
return fv->ecmascript_obj;
|
return fv->ecmascript_obj;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static JSBool forms_get_property(JSContext *ctx, JSObject *obj, jsval id, jsval *vp);
|
static JSBool forms_get_property(JSContext *ctx, JSObject *obj, jsval id, jsval *vp);
|
||||||
|
|
||||||
/* Each @forms_class object must have a @document_class parent. */
|
/* Each @forms_class object must have a @document_class parent. */
|
||||||
@ -975,8 +1063,15 @@ forms_get_property(JSContext *ctx, JSObject *obj, jsval id, jsval *vp)
|
|||||||
struct document_view *doc_view;
|
struct document_view *doc_view;
|
||||||
struct document *document;
|
struct document *document;
|
||||||
|
|
||||||
|
assert(JS_InstanceOf(ctx, obj, (JSClass *) &forms_class, NULL));
|
||||||
|
if_assert_failed return JS_FALSE;
|
||||||
parent_doc = JS_GetParent(ctx, obj);
|
parent_doc = JS_GetParent(ctx, obj);
|
||||||
|
assert(JS_InstanceOf(ctx, parent_doc, (JSClass *) &document_class, NULL));
|
||||||
|
if_assert_failed return JS_FALSE;
|
||||||
parent_win = JS_GetParent(ctx, parent_doc);
|
parent_win = JS_GetParent(ctx, parent_doc);
|
||||||
|
assert(JS_InstanceOf(ctx, parent_win, (JSClass *) &window_class, NULL));
|
||||||
|
if_assert_failed return JS_FALSE;
|
||||||
|
|
||||||
vs = JS_GetPrivate(ctx, parent_win); /* from @window_class */
|
vs = JS_GetPrivate(ctx, parent_win); /* from @window_class */
|
||||||
doc_view = vs->doc_view;
|
doc_view = vs->doc_view;
|
||||||
document = doc_view->document;
|
document = doc_view->document;
|
||||||
@ -1013,8 +1108,14 @@ forms_item(JSContext *ctx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
|
|||||||
int counter = -1;
|
int counter = -1;
|
||||||
int index;
|
int index;
|
||||||
|
|
||||||
|
if (!JS_InstanceOf(ctx, obj, (JSClass *) &forms_class, argv)) return JS_FALSE;
|
||||||
parent_doc = JS_GetParent(ctx, obj);
|
parent_doc = JS_GetParent(ctx, obj);
|
||||||
|
assert(JS_InstanceOf(ctx, parent_doc, (JSClass *) &document_class, NULL));
|
||||||
|
if_assert_failed return JS_FALSE;
|
||||||
parent_win = JS_GetParent(ctx, parent_doc);
|
parent_win = JS_GetParent(ctx, parent_doc);
|
||||||
|
assert(JS_InstanceOf(ctx, parent_win, (JSClass *) &window_class, NULL));
|
||||||
|
if_assert_failed return JS_FALSE;
|
||||||
|
|
||||||
vs = JS_GetPrivate(ctx, parent_win); /* from @window_class */
|
vs = JS_GetPrivate(ctx, parent_win); /* from @window_class */
|
||||||
|
|
||||||
if (argc != 1)
|
if (argc != 1)
|
||||||
@ -1047,8 +1148,14 @@ forms_namedItem(JSContext *ctx, JSObject *obj, uintN argc, jsval *argv, jsval *r
|
|||||||
struct form *form;
|
struct form *form;
|
||||||
unsigned char *string;
|
unsigned char *string;
|
||||||
|
|
||||||
|
if (!JS_InstanceOf(ctx, obj, (JSClass *) &forms_class, argv)) return JS_FALSE;
|
||||||
parent_doc = JS_GetParent(ctx, obj);
|
parent_doc = JS_GetParent(ctx, obj);
|
||||||
|
assert(JS_InstanceOf(ctx, parent_doc, (JSClass *) &document_class, NULL));
|
||||||
|
if_assert_failed return JS_FALSE;
|
||||||
parent_win = JS_GetParent(ctx, parent_doc);
|
parent_win = JS_GetParent(ctx, parent_doc);
|
||||||
|
assert(JS_InstanceOf(ctx, parent_win, (JSClass *) &window_class, NULL));
|
||||||
|
if_assert_failed return JS_FALSE;
|
||||||
|
|
||||||
vs = JS_GetPrivate(ctx, parent_win); /* from @window_class */
|
vs = JS_GetPrivate(ctx, parent_win); /* from @window_class */
|
||||||
doc_view = vs->doc_view;
|
doc_view = vs->doc_view;
|
||||||
document = doc_view->document;
|
document = doc_view->document;
|
||||||
|
@ -23,6 +23,7 @@
|
|||||||
#include "document/view.h"
|
#include "document/view.h"
|
||||||
#include "ecmascript/ecmascript.h"
|
#include "ecmascript/ecmascript.h"
|
||||||
#include "ecmascript/spidermonkey/location.h"
|
#include "ecmascript/spidermonkey/location.h"
|
||||||
|
#include "ecmascript/spidermonkey/window.h"
|
||||||
#include "intl/gettext/libintl.h"
|
#include "intl/gettext/libintl.h"
|
||||||
#include "main/select.h"
|
#include "main/select.h"
|
||||||
#include "osdep/newwin.h"
|
#include "osdep/newwin.h"
|
||||||
@ -148,7 +149,12 @@ location_get_property(JSContext *ctx, JSObject *obj, jsval id, jsval *vp)
|
|||||||
JSObject *parent_win; /* instance of @window_class */
|
JSObject *parent_win; /* instance of @window_class */
|
||||||
struct view_state *vs;
|
struct view_state *vs;
|
||||||
|
|
||||||
|
assert(JS_InstanceOf(ctx, obj, (JSClass *) &location_class, NULL));
|
||||||
|
if_assert_failed return JS_FALSE;
|
||||||
parent_win = JS_GetParent(ctx, obj);
|
parent_win = JS_GetParent(ctx, obj);
|
||||||
|
assert(JS_InstanceOf(ctx, parent_win, (JSClass *) &window_class, NULL));
|
||||||
|
if_assert_failed return JS_FALSE;
|
||||||
|
|
||||||
vs = JS_GetPrivate(ctx, parent_win); /* from @window_class */
|
vs = JS_GetPrivate(ctx, parent_win); /* from @window_class */
|
||||||
|
|
||||||
if (!JSVAL_IS_INT(id))
|
if (!JSVAL_IS_INT(id))
|
||||||
@ -176,7 +182,12 @@ location_set_property(JSContext *ctx, JSObject *obj, jsval id, jsval *vp)
|
|||||||
struct view_state *vs;
|
struct view_state *vs;
|
||||||
struct document_view *doc_view;
|
struct document_view *doc_view;
|
||||||
|
|
||||||
|
assert(JS_InstanceOf(ctx, obj, (JSClass *) &location_class, NULL));
|
||||||
|
if_assert_failed return JS_FALSE;
|
||||||
parent_win = JS_GetParent(ctx, obj);
|
parent_win = JS_GetParent(ctx, obj);
|
||||||
|
assert(JS_InstanceOf(ctx, parent_win, (JSClass *) &window_class, NULL));
|
||||||
|
if_assert_failed return JS_FALSE;
|
||||||
|
|
||||||
vs = JS_GetPrivate(ctx, parent_win); /* from @window_class */
|
vs = JS_GetPrivate(ctx, parent_win); /* from @window_class */
|
||||||
doc_view = vs->doc_view;
|
doc_view = vs->doc_view;
|
||||||
|
|
||||||
|
@ -23,6 +23,7 @@
|
|||||||
#include "document/view.h"
|
#include "document/view.h"
|
||||||
#include "ecmascript/ecmascript.h"
|
#include "ecmascript/ecmascript.h"
|
||||||
#include "ecmascript/spidermonkey/unibar.h"
|
#include "ecmascript/spidermonkey/unibar.h"
|
||||||
|
#include "ecmascript/spidermonkey/window.h"
|
||||||
#include "intl/gettext/libintl.h"
|
#include "intl/gettext/libintl.h"
|
||||||
#include "main/select.h"
|
#include "main/select.h"
|
||||||
#include "osdep/newwin.h"
|
#include "osdep/newwin.h"
|
||||||
@ -81,7 +82,13 @@ unibar_get_property(JSContext *ctx, JSObject *obj, jsval id, jsval *vp)
|
|||||||
struct session_status *status;
|
struct session_status *status;
|
||||||
unsigned char *bar;
|
unsigned char *bar;
|
||||||
|
|
||||||
|
assert(JS_InstanceOf(ctx, obj, (JSClass *) &menubar_class, NULL)
|
||||||
|
|| JS_InstanceOf(ctx, obj, (JSClass *) &statusbar_class, NULL));
|
||||||
|
if_assert_failed return JS_FALSE;
|
||||||
parent_win = JS_GetParent(ctx, obj);
|
parent_win = JS_GetParent(ctx, obj);
|
||||||
|
assert(JS_InstanceOf(ctx, parent_win, (JSClass *) &window_class, NULL));
|
||||||
|
if_assert_failed return JS_FALSE;
|
||||||
|
|
||||||
vs = JS_GetPrivate(ctx, parent_win); /* from @window_class */
|
vs = JS_GetPrivate(ctx, parent_win); /* from @window_class */
|
||||||
doc_view = vs->doc_view;
|
doc_view = vs->doc_view;
|
||||||
status = &doc_view->session->status;
|
status = &doc_view->session->status;
|
||||||
@ -127,7 +134,13 @@ unibar_set_property(JSContext *ctx, JSObject *obj, jsval id, jsval *vp)
|
|||||||
struct session_status *status;
|
struct session_status *status;
|
||||||
unsigned char *bar;
|
unsigned char *bar;
|
||||||
|
|
||||||
|
assert(JS_InstanceOf(ctx, obj, (JSClass *) &menubar_class, NULL)
|
||||||
|
|| JS_InstanceOf(ctx, obj, (JSClass *) &statusbar_class, NULL));
|
||||||
|
if_assert_failed return JS_FALSE;
|
||||||
parent_win = JS_GetParent(ctx, obj);
|
parent_win = JS_GetParent(ctx, obj);
|
||||||
|
assert(JS_InstanceOf(ctx, parent_win, (JSClass *) &window_class, NULL));
|
||||||
|
if_assert_failed return JS_FALSE;
|
||||||
|
|
||||||
vs = JS_GetPrivate(ctx, parent_win); /* from @window_class */
|
vs = JS_GetPrivate(ctx, parent_win); /* from @window_class */
|
||||||
doc_view = vs->doc_view;
|
doc_view = vs->doc_view;
|
||||||
status = &doc_view->session->status;
|
status = &doc_view->session->status;
|
||||||
|
@ -120,6 +120,9 @@ window_get_property(JSContext *ctx, JSObject *obj, jsval id, jsval *vp)
|
|||||||
{
|
{
|
||||||
struct view_state *vs;
|
struct view_state *vs;
|
||||||
|
|
||||||
|
assert(JS_InstanceOf(ctx, obj, (JSClass *) &window_class, NULL));
|
||||||
|
if_assert_failed return JS_FALSE;
|
||||||
|
|
||||||
vs = JS_GetPrivate(ctx, obj); /* from @window_class */
|
vs = JS_GetPrivate(ctx, obj); /* from @window_class */
|
||||||
|
|
||||||
/* No need for special window.location measurements - when
|
/* No need for special window.location measurements - when
|
||||||
@ -239,6 +242,9 @@ window_set_property(JSContext *ctx, JSObject *obj, jsval id, jsval *vp)
|
|||||||
{
|
{
|
||||||
struct view_state *vs;
|
struct view_state *vs;
|
||||||
|
|
||||||
|
assert(JS_InstanceOf(ctx, obj, (JSClass *) &window_class, NULL));
|
||||||
|
if_assert_failed return JS_FALSE;
|
||||||
|
|
||||||
vs = JS_GetPrivate(ctx, obj); /* from @window_class */
|
vs = JS_GetPrivate(ctx, obj); /* from @window_class */
|
||||||
|
|
||||||
if (JSVAL_IS_STRING(id)) {
|
if (JSVAL_IS_STRING(id)) {
|
||||||
@ -282,6 +288,8 @@ window_alert(JSContext *ctx, JSObject *obj, uintN argc, jsval *argv, jsval *rval
|
|||||||
struct view_state *vs;
|
struct view_state *vs;
|
||||||
unsigned char *string;
|
unsigned char *string;
|
||||||
|
|
||||||
|
if (!JS_InstanceOf(ctx, obj, (JSClass *) &window_class, argv)) return JS_FALSE;
|
||||||
|
|
||||||
vs = JS_GetPrivate(ctx, obj); /* from @window_class */
|
vs = JS_GetPrivate(ctx, obj); /* from @window_class */
|
||||||
|
|
||||||
if (argc != 1)
|
if (argc != 1)
|
||||||
@ -339,6 +347,8 @@ window_open(JSContext *ctx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
|
|||||||
static time_t ratelimit_start;
|
static time_t ratelimit_start;
|
||||||
static int ratelimit_count;
|
static int ratelimit_count;
|
||||||
|
|
||||||
|
if (!JS_InstanceOf(ctx, obj, (JSClass *) &window_class, argv)) return JS_FALSE;
|
||||||
|
|
||||||
vs = JS_GetPrivate(ctx, obj); /* from @window_class */
|
vs = JS_GetPrivate(ctx, obj); /* from @window_class */
|
||||||
doc_view = vs->doc_view;
|
doc_view = vs->doc_view;
|
||||||
ses = doc_view->session;
|
ses = doc_view->session;
|
||||||
|
@ -14,13 +14,19 @@
|
|||||||
#include "util/memory.h"
|
#include "util/memory.h"
|
||||||
|
|
||||||
|
|
||||||
|
static const JSClass bookmark_class, bookmark_folder_class; /* defined below */
|
||||||
|
|
||||||
|
|
||||||
/*** common code ***/
|
/*** common code ***/
|
||||||
|
|
||||||
static JSObject *
|
static JSObject *
|
||||||
smjs_get_bookmark_generic_object(struct bookmark *bookmark, JSClass *clasp)
|
smjs_get_bookmark_generic_object(struct bookmark *bookmark, JSClass *clasp)
|
||||||
{
|
{
|
||||||
JSObject *jsobj;
|
JSObject *jsobj;
|
||||||
|
|
||||||
|
assert(clasp == &bookmark_class || clasp == &bookmark_folder_class);
|
||||||
|
if_assert_failed return NULL;
|
||||||
|
|
||||||
jsobj = JS_NewObject(smjs_ctx, clasp, NULL, NULL);
|
jsobj = JS_NewObject(smjs_ctx, clasp, NULL, NULL);
|
||||||
if (!jsobj) return NULL;
|
if (!jsobj) return NULL;
|
||||||
|
|
||||||
@ -41,6 +47,10 @@ bookmark_finalize(JSContext *ctx, JSObject *obj)
|
|||||||
{
|
{
|
||||||
struct bookmark *bookmark;
|
struct bookmark *bookmark;
|
||||||
|
|
||||||
|
assert(JS_InstanceOf(ctx, obj, (JSClass *) &bookmark_class, NULL)
|
||||||
|
|| JS_InstanceOf(ctx, obj, (JSClass *) &bookmark_folder_class, NULL));
|
||||||
|
if_assert_failed return;
|
||||||
|
|
||||||
bookmark = JS_GetPrivate(ctx, obj); /* from @bookmark_class or @bookmark_folder_class */
|
bookmark = JS_GetPrivate(ctx, obj); /* from @bookmark_class or @bookmark_folder_class */
|
||||||
|
|
||||||
if (bookmark) object_unlock(bookmark);
|
if (bookmark) object_unlock(bookmark);
|
||||||
@ -70,6 +80,9 @@ bookmark_get_property(JSContext *ctx, JSObject *obj, jsval id, jsval *vp)
|
|||||||
{
|
{
|
||||||
struct bookmark *bookmark;
|
struct bookmark *bookmark;
|
||||||
|
|
||||||
|
assert(JS_InstanceOf(ctx, obj, (JSClass *) &bookmark_class, NULL));
|
||||||
|
if_assert_failed return JS_FALSE;
|
||||||
|
|
||||||
bookmark = JS_GetPrivate(ctx, obj); /* from @bookmark_class */
|
bookmark = JS_GetPrivate(ctx, obj); /* from @bookmark_class */
|
||||||
|
|
||||||
if (!bookmark) return JS_FALSE;
|
if (!bookmark) return JS_FALSE;
|
||||||
@ -108,6 +121,9 @@ bookmark_set_property(JSContext *ctx, JSObject *obj, jsval id, jsval *vp)
|
|||||||
{
|
{
|
||||||
struct bookmark *bookmark;
|
struct bookmark *bookmark;
|
||||||
|
|
||||||
|
assert(JS_InstanceOf(ctx, obj, (JSClass *) &bookmark_class, NULL));
|
||||||
|
if_assert_failed return JS_FALSE;
|
||||||
|
|
||||||
bookmark = JS_GetPrivate(ctx, obj); /* from @bookmark_class */
|
bookmark = JS_GetPrivate(ctx, obj); /* from @bookmark_class */
|
||||||
|
|
||||||
if (!bookmark) return JS_FALSE;
|
if (!bookmark) return JS_FALSE;
|
||||||
@ -175,6 +191,9 @@ bookmark_folder_get_property(JSContext *ctx, JSObject *obj, jsval id, jsval *vp)
|
|||||||
struct bookmark *folder;
|
struct bookmark *folder;
|
||||||
unsigned char *title;
|
unsigned char *title;
|
||||||
|
|
||||||
|
assert(JS_InstanceOf(ctx, obj, (JSClass *) &bookmark_folder_class, NULL));
|
||||||
|
if_assert_failed return JS_FALSE;
|
||||||
|
|
||||||
folder = JS_GetPrivate(ctx, obj); /* from @bookmark_folder_class */
|
folder = JS_GetPrivate(ctx, obj); /* from @bookmark_folder_class */
|
||||||
|
|
||||||
title = JS_GetStringBytes(JS_ValueToString(ctx, id));
|
title = JS_GetStringBytes(JS_ValueToString(ctx, id));
|
||||||
|
@ -14,6 +14,8 @@
|
|||||||
#include "util/error.h"
|
#include "util/error.h"
|
||||||
#include "util/memory.h"
|
#include "util/memory.h"
|
||||||
|
|
||||||
|
static const JSClass cache_entry_class; /* defined below */
|
||||||
|
|
||||||
enum cache_entry_prop {
|
enum cache_entry_prop {
|
||||||
CACHE_ENTRY_CONTENT,
|
CACHE_ENTRY_CONTENT,
|
||||||
CACHE_ENTRY_TYPE,
|
CACHE_ENTRY_TYPE,
|
||||||
@ -37,6 +39,9 @@ cache_entry_get_property(JSContext *ctx, JSObject *obj, jsval id, jsval *vp)
|
|||||||
{
|
{
|
||||||
struct cache_entry *cached;
|
struct cache_entry *cached;
|
||||||
|
|
||||||
|
assert(JS_InstanceOf(ctx, obj, (JSClass *) &cache_entry_class, NULL));
|
||||||
|
if_assert_failed return JS_FALSE;
|
||||||
|
|
||||||
cached = JS_GetPrivate(ctx, obj); /* from @cache_entry_class */
|
cached = JS_GetPrivate(ctx, obj); /* from @cache_entry_class */
|
||||||
|
|
||||||
if (!cache_entry_is_valid(cached)) return JS_FALSE;
|
if (!cache_entry_is_valid(cached)) return JS_FALSE;
|
||||||
@ -91,6 +96,9 @@ cache_entry_set_property(JSContext *ctx, JSObject *obj, jsval id, jsval *vp)
|
|||||||
{
|
{
|
||||||
struct cache_entry *cached;
|
struct cache_entry *cached;
|
||||||
|
|
||||||
|
assert(JS_InstanceOf(ctx, obj, (JSClass *) &cache_entry_class, NULL));
|
||||||
|
if_assert_failed return JS_FALSE;
|
||||||
|
|
||||||
cached = JS_GetPrivate(ctx, obj); /* from @cache_entry_class */
|
cached = JS_GetPrivate(ctx, obj); /* from @cache_entry_class */
|
||||||
|
|
||||||
if (!cache_entry_is_valid(cached)) return JS_FALSE;
|
if (!cache_entry_is_valid(cached)) return JS_FALSE;
|
||||||
@ -141,6 +149,9 @@ cache_entry_finalize(JSContext *ctx, JSObject *obj)
|
|||||||
{
|
{
|
||||||
struct cache_entry *cached;
|
struct cache_entry *cached;
|
||||||
|
|
||||||
|
assert(JS_InstanceOf(ctx, obj, (JSClass *) &cache_entry_class, NULL));
|
||||||
|
if_assert_failed return;
|
||||||
|
|
||||||
cached = JS_GetPrivate(ctx, obj); /* from @cache_entry_class */
|
cached = JS_GetPrivate(ctx, obj); /* from @cache_entry_class */
|
||||||
|
|
||||||
if (!cached) return;
|
if (!cached) return;
|
||||||
|
@ -13,6 +13,8 @@
|
|||||||
#include "scripting/smjs/elinks_object.h"
|
#include "scripting/smjs/elinks_object.h"
|
||||||
#include "util/memory.h"
|
#include "util/memory.h"
|
||||||
|
|
||||||
|
static const JSClass keymap_class; /* defined below */
|
||||||
|
|
||||||
/* @keymap_class.getProperty */
|
/* @keymap_class.getProperty */
|
||||||
static JSBool
|
static JSBool
|
||||||
keymap_get_property(JSContext *ctx, JSObject *obj, jsval id, jsval *vp)
|
keymap_get_property(JSContext *ctx, JSObject *obj, jsval id, jsval *vp)
|
||||||
@ -22,6 +24,9 @@ keymap_get_property(JSContext *ctx, JSObject *obj, jsval id, jsval *vp)
|
|||||||
int *data;
|
int *data;
|
||||||
enum keymap_id keymap_id = *data;
|
enum keymap_id keymap_id = *data;
|
||||||
|
|
||||||
|
assert(JS_InstanceOf(ctx, obj, (JSClass *) &keymap_class, NULL));
|
||||||
|
if_assert_failed return JS_FALSE;
|
||||||
|
|
||||||
data = JS_GetPrivate(ctx, obj); /* from @keymap_class */
|
data = JS_GetPrivate(ctx, obj); /* from @keymap_class */
|
||||||
|
|
||||||
keystroke_str = JS_GetStringBytes(JS_ValueToString(ctx, id));
|
keystroke_str = JS_GetStringBytes(JS_ValueToString(ctx, id));
|
||||||
@ -70,6 +75,9 @@ keymap_set_property(JSContext *ctx, JSObject *obj, jsval id, jsval *vp)
|
|||||||
unsigned char *keymap_str;
|
unsigned char *keymap_str;
|
||||||
unsigned char *keystroke_str;
|
unsigned char *keystroke_str;
|
||||||
|
|
||||||
|
assert(JS_InstanceOf(ctx, obj, (JSClass *) &keymap_class, NULL));
|
||||||
|
if_assert_failed return JS_FALSE;
|
||||||
|
|
||||||
data = JS_GetPrivate(ctx, obj); /* from @keymap_class */
|
data = JS_GetPrivate(ctx, obj); /* from @keymap_class */
|
||||||
|
|
||||||
/* Ugly fact: we need to get the string from the id to give to bind_do,
|
/* Ugly fact: we need to get the string from the id to give to bind_do,
|
||||||
@ -139,6 +147,9 @@ keymap_finalize(JSContext *ctx, JSObject *obj)
|
|||||||
{
|
{
|
||||||
void *data;
|
void *data;
|
||||||
|
|
||||||
|
assert(JS_InstanceOf(ctx, obj, (JSClass *) &keymap_class, NULL));
|
||||||
|
if_assert_failed return;
|
||||||
|
|
||||||
data = JS_GetPrivate(ctx, obj); /* from @keymap_class */
|
data = JS_GetPrivate(ctx, obj); /* from @keymap_class */
|
||||||
|
|
||||||
mem_free(data);
|
mem_free(data);
|
||||||
|
@ -16,6 +16,8 @@
|
|||||||
#include "util/memory.h"
|
#include "util/memory.h"
|
||||||
#include "viewer/text/vs.h"
|
#include "viewer/text/vs.h"
|
||||||
|
|
||||||
|
static const JSClass view_state_class; /* defined below */
|
||||||
|
|
||||||
enum view_state_prop {
|
enum view_state_prop {
|
||||||
VIEW_STATE_PLAIN,
|
VIEW_STATE_PLAIN,
|
||||||
VIEW_STATE_URI,
|
VIEW_STATE_URI,
|
||||||
@ -33,6 +35,9 @@ view_state_get_property(JSContext *ctx, JSObject *obj, jsval id, jsval *vp)
|
|||||||
{
|
{
|
||||||
struct view_state *vs;
|
struct view_state *vs;
|
||||||
|
|
||||||
|
assert(JS_InstanceOf(ctx, obj, (JSClass *) &view_state_class, NULL));
|
||||||
|
if_assert_failed return JS_FALSE;
|
||||||
|
|
||||||
vs = JS_GetPrivate(ctx, obj); /* from @view_state_class */
|
vs = JS_GetPrivate(ctx, obj); /* from @view_state_class */
|
||||||
|
|
||||||
undef_to_jsval(ctx, vp);
|
undef_to_jsval(ctx, vp);
|
||||||
@ -64,6 +69,9 @@ view_state_set_property(JSContext *ctx, JSObject *obj, jsval id, jsval *vp)
|
|||||||
{
|
{
|
||||||
struct view_state *vs;
|
struct view_state *vs;
|
||||||
|
|
||||||
|
assert(JS_InstanceOf(ctx, obj, (JSClass *) &view_state_class, NULL));
|
||||||
|
if_assert_failed return JS_FALSE;
|
||||||
|
|
||||||
vs = JS_GetPrivate(ctx, obj); /* from @view_state_class */
|
vs = JS_GetPrivate(ctx, obj); /* from @view_state_class */
|
||||||
|
|
||||||
if (!JSVAL_IS_INT(id))
|
if (!JSVAL_IS_INT(id))
|
||||||
|
Loading…
Reference in New Issue
Block a user