summaryrefslogtreecommitdiff
path: root/render
diff options
context:
space:
mode:
authorMichael Drake <tlsa@netsurf-browser.org>2016-01-21 14:51:17 +0000
committerMichael Drake <tlsa@netsurf-browser.org>2016-01-21 14:51:17 +0000
commit82b298ac2c28dcaf7510e97b8a1379b34c8ab15c (patch)
tree12eec3c767a2e3cdbf66b797a0cb770525579812 /render
parent669448d7b6ae420dfce6e8b25eda143ca2b31109 (diff)
downloadnetsurf-82b298ac2c28dcaf7510e97b8a1379b34c8ab15c.tar.gz
netsurf-82b298ac2c28dcaf7510e97b8a1379b34c8ab15c.tar.bz2
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.
Diffstat (limited to 'render')
-rw-r--r--render/html.c29
1 files changed, 16 insertions, 13 deletions
diff --git a/render/html.c b/render/html.c
index 6d2421f6e..0c278a74c 100644
--- a/render/html.c
+++ b/render/html.c
@@ -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;
-
- 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);
+ 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);
+ }
}
}
dom_node_unref(node);