mirror of
https://github.com/netsurf-browser/netsurf
synced 2024-12-19 10:42:36 +03:00
Ensure we do on-demand JS context creation only when JS is enabled.
An alternative approach which may be better would be to create the JavaScript context when the html_content is created, rather than on demand. This code checks for the JS context and creates one every time we add a node to the DOM. So when JS is on, every doc with a single node in it has a JS context. This seems to make on-demand creation a redundant overhead.
This commit is contained in:
parent
669448d7b6
commit
82b298ac2c
@ -671,19 +671,22 @@ dom_default_action_DOMNodeInserted_cb(struct dom_event *evt, void *pw)
|
||||
|
||||
dom_string_unref(name);
|
||||
}
|
||||
/* ensure javascript context is available */
|
||||
if (htmlc->jscontext == NULL) {
|
||||
union content_msg_data msg_data;
|
||||
if (htmlc->enable_scripting) {
|
||||
/* ensure javascript context is available */
|
||||
if (htmlc->jscontext == NULL) {
|
||||
union content_msg_data msg_data;
|
||||
|
||||
msg_data.jscontext = &htmlc->jscontext;
|
||||
content_broadcast(&htmlc->base,
|
||||
CONTENT_MSG_GETCTX,
|
||||
msg_data);
|
||||
LOG("javascript context %p ", htmlc->jscontext);
|
||||
}
|
||||
if (htmlc->jscontext != NULL) {
|
||||
js_handle_new_element(htmlc->jscontext,
|
||||
(dom_element *) node);
|
||||
msg_data.jscontext = &htmlc->jscontext;
|
||||
content_broadcast(&htmlc->base,
|
||||
CONTENT_MSG_GETCTX,
|
||||
msg_data);
|
||||
LOG("javascript context: %p",
|
||||
htmlc->jscontext);
|
||||
}
|
||||
if (htmlc->jscontext != NULL) {
|
||||
js_handle_new_element(htmlc->jscontext,
|
||||
(dom_element *) node);
|
||||
}
|
||||
}
|
||||
}
|
||||
dom_node_unref(node);
|
||||
|
Loading…
Reference in New Issue
Block a user