mirror of
https://github.com/rkd77/elinks.git
synced 2024-11-04 08:17:17 -05:00
DOM ecmascript: moved the ecmascript_ctx to the struct dom_node.
JSContext is accessible from every node.
This commit is contained in:
parent
4c81e5e1c8
commit
6949b91db1
@ -43,8 +43,7 @@ extern JSRuntime *jsrt;
|
||||
void
|
||||
done_dom_node_ecmascript_obj(struct dom_node *node)
|
||||
{
|
||||
struct dom_node *root = get_dom_root_node(node);
|
||||
JSContext *ctx = root->data.document.ecmascript_ctx;
|
||||
JSContext *ctx = node->ecmascript_ctx;
|
||||
JSObject *obj = node->ecmascript_obj;
|
||||
|
||||
assert(ctx && obj && JS_GetPrivate(ctx, obj) == node);
|
||||
@ -56,7 +55,7 @@ done_dom_node_ecmascript_obj(struct dom_node *node)
|
||||
void
|
||||
dom_add_attribute(struct dom_node *root, struct dom_node *node, struct dom_string *attr, struct dom_string *value)
|
||||
{
|
||||
JSContext *ctx = root->data.document.ecmascript_ctx;
|
||||
JSContext *ctx = node->ecmascript_ctx;
|
||||
JSObject *obj = node->ecmascript_obj;
|
||||
JSString *string;
|
||||
jsval vp;
|
||||
@ -73,7 +72,7 @@ dom_add_attribute(struct dom_node *root, struct dom_node *node, struct dom_strin
|
||||
} else {
|
||||
vp = JSVAL_NULL;
|
||||
}
|
||||
tmp = attr->length;
|
||||
tmp = attr->string[attr->length];
|
||||
attr->string[attr->length] = '\0';
|
||||
JS_SetProperty(ctx, obj, attr->string, &vp);
|
||||
attr->string[attr->length] = tmp;
|
||||
|
@ -97,6 +97,9 @@ make_dom_node_html_data(JSContext *ctx, struct dom_node *node)
|
||||
{
|
||||
int type = node->data.element.type;
|
||||
|
||||
if (func[type].make)
|
||||
if (func[type].make) {
|
||||
func[type].make(ctx, node);
|
||||
if (node->ecmascript_obj)
|
||||
node->ecmascript_ctx = ctx;
|
||||
}
|
||||
}
|
||||
|
@ -89,10 +89,6 @@ struct dom_document_node {
|
||||
/* The document. */
|
||||
struct dom_document *document;
|
||||
|
||||
#ifdef CONFIG_ECMASCRIPT
|
||||
/* The ECMAScript context used by the SpiderMonkey. */
|
||||
void *ecmascript_ctx;
|
||||
#endif
|
||||
/* The child nodes. May be NULL. Ordered like they where inserted. */
|
||||
/* FIXME: Should be just one element (root) node reference. */
|
||||
struct dom_node_list *children;
|
||||
@ -261,7 +257,7 @@ struct dom_node {
|
||||
struct dom_node *parent;
|
||||
|
||||
#ifdef CONFIG_ECMASCRIPT
|
||||
void *ctx;
|
||||
void *ecmascript_ctx;
|
||||
/** The ECMAScript object related to this node.
|
||||
* NULL when the object was not used yet. */
|
||||
void *ecmascript_obj;
|
||||
|
Loading…
Reference in New Issue
Block a user