summaryrefslogtreecommitdiff
path: root/content/handlers/html
diff options
context:
space:
mode:
authorDaniel Silverstone <dsilvers@digital-scurf.org>2020-03-21 18:30:41 +0000
committerDaniel Silverstone <dsilvers@digital-scurf.org>2020-03-21 18:30:41 +0000
commit17b28e85c12309d60e3c45acb096b9989a7834ff (patch)
treed10a03b425d22b1c48be7356466b0420bfb36402 /content/handlers/html
parent313dc9b099a172914f312120f0f9d0260a3588cf (diff)
downloadnetsurf-17b28e85c12309d60e3c45acb096b9989a7834ff.tar.gz
netsurf-17b28e85c12309d60e3c45acb096b9989a7834ff.tar.bz2
JS: Split concept of JS context into heap and thread
In preparation for proper splitting of Javascript support into heaps and threads, this renames the types and corrects the no-js builds to still work. At this time no substantive change in semantics exists, and the duktape build won't work. Signed-off-by: Daniel Silverstone <dsilvers@digital-scurf.org>
Diffstat (limited to 'content/handlers/html')
-rw-r--r--content/handlers/html/html.c22
-rw-r--r--content/handlers/html/html_internal.h4
-rw-r--r--content/handlers/html/html_object.c5
-rw-r--r--content/handlers/html/html_script.c24
4 files changed, 28 insertions, 27 deletions
diff --git a/content/handlers/html/html.c b/content/handlers/html/html.c
index d1b810fbc..26be58d73 100644
--- a/content/handlers/html/html.c
+++ b/content/handlers/html/html.c
@@ -757,8 +757,8 @@ void html_finish_conversion(html_content *htmlc)
* object, but with its target set to the Document object (and
* the currentTarget set to the Window object)
*/
- if (htmlc->jscontext != NULL) {
- js_fire_event(htmlc->jscontext, "load", htmlc->document, NULL);
+ if (htmlc->jsthread != NULL) {
+ js_fire_event(htmlc->jsthread, "load", htmlc->document, NULL);
}
/* convert dom tree to box tree */
@@ -896,20 +896,20 @@ dom_default_action_DOMNodeInserted_cb(struct dom_event *evt, void *pw)
}
if (htmlc->enable_scripting) {
/* ensure javascript context is available */
- if (htmlc->jscontext == NULL) {
+ if (htmlc->jsthread == NULL) {
union content_msg_data msg_data;
- msg_data.jscontext = &htmlc->jscontext;
+ msg_data.jsthread = &htmlc->jsthread;
content_broadcast(&htmlc->base,
- CONTENT_MSG_GETCTX,
+ CONTENT_MSG_GETTHREAD,
&msg_data);
NSLOG(netsurf, INFO,
"javascript context: %p (htmlc: %p)",
- htmlc->jscontext,
+ htmlc->jsthread,
htmlc);
}
- if (htmlc->jscontext != NULL) {
- js_handle_new_element(htmlc->jscontext,
+ if (htmlc->jsthread != NULL) {
+ js_handle_new_element(htmlc->jsthread,
(dom_element *) node);
}
}
@@ -1015,8 +1015,8 @@ dom_default_action_finished_cb(struct dom_event *evt, void *pw)
{
html_content *htmlc = pw;
- if (htmlc->jscontext != NULL)
- js_event_cleanup(htmlc->jscontext, evt);
+ if (htmlc->jsthread != NULL)
+ js_event_cleanup(htmlc->jsthread, evt);
}
/* callback function selector
@@ -1136,7 +1136,7 @@ html_create_html_data(html_content *c, const http_parameter *params)
c->search_string = NULL;
c->scripts_count = 0;
c->scripts = NULL;
- c->jscontext = NULL;
+ c->jsthread = NULL;
c->enable_scripting = nsoption_bool(enable_javascript);
c->base.active = 1; /* The html content itself is active */
diff --git a/content/handlers/html/html_internal.h b/content/handlers/html/html_internal.h
index 9b363dc8b..a64078143 100644
--- a/content/handlers/html/html_internal.h
+++ b/content/handlers/html/html_internal.h
@@ -151,8 +151,8 @@ typedef struct html_content {
unsigned int scripts_count;
/** Scripts */
struct html_script *scripts;
- /** javascript context */
- struct jscontext *jscontext;
+ /** javascript thread in use */
+ struct jsthread *jsthread;
/** Number of entries in stylesheet_content. */
unsigned int stylesheet_count;
diff --git a/content/handlers/html/html_object.c b/content/handlers/html/html_object.c
index 223f5516d..3a60c47f1 100644
--- a/content/handlers/html/html_object.c
+++ b/content/handlers/html/html_object.c
@@ -340,8 +340,9 @@ html_object_callback(hlcache_handle *object,
/* Don't care about favicons that aren't on top level content */
break;
- case CONTENT_MSG_GETCTX:
- *(event->data.jscontext) = NULL;
+ case CONTENT_MSG_GETTHREAD:
+ /* Objects don't have JS threads */
+ *(event->data.jsthread) = NULL;
break;
case CONTENT_MSG_GETDIMS:
diff --git a/content/handlers/html/html_script.c b/content/handlers/html/html_script.c
index 4df5f3384..301acadd6 100644
--- a/content/handlers/html/html_script.c
+++ b/content/handlers/html/html_script.c
@@ -42,7 +42,7 @@
#include "html/html.h"
#include "html/html_internal.h"
-typedef bool (script_handler_t)(struct jscontext *jscontext, const uint8_t *data, size_t size, const char *name);
+typedef bool (script_handler_t)(struct jsthread *jsthread, const uint8_t *data, size_t size, const char *name);
static script_handler_t *select_script_handler(content_type ctype)
@@ -62,7 +62,7 @@ nserror html_script_exec(html_content *c, bool allow_defer)
script_handler_t *script_handler;
bool have_run_something = false;
- if (c->jscontext == NULL) {
+ if (c->jsthread == NULL) {
return NSERROR_BAD_PARAMETER;
}
@@ -95,7 +95,7 @@ nserror html_script_exec(html_content *c, bool allow_defer)
size_t size;
data = content_get_source_data(
s->data.handle, &size );
- script_handler(c->jscontext, data, size,
+ script_handler(c->jsthread, data, size,
nsurl_access(hlcache_handle_get_url(s->data.handle)));
have_run_something = true;
/* We have to re-acquire this here since the
@@ -319,12 +319,12 @@ convert_script_sync_cb(hlcache_handle *script,
/* attempt to execute script */
script_handler = select_script_handler(content_get_type(s->data.handle));
- if (script_handler != NULL && parent->jscontext != NULL) {
+ if (script_handler != NULL && parent->jsthread != NULL) {
/* script has a handler */
const uint8_t *data;
size_t size;
data = content_get_source_data(s->data.handle, &size );
- script_handler(parent->jscontext, data, size,
+ script_handler(parent->jsthread, data, size,
nsurl_access(hlcache_handle_get_url(s->data.handle)));
}
@@ -549,7 +549,7 @@ exec_inline_script(html_content *c, dom_node *node, dom_string *mimetype)
lwc_string_unref(lwcmimetype);
if (script_handler != NULL) {
- script_handler(c->jscontext,
+ script_handler(c->jsthread,
(const uint8_t *)dom_string_data(script),
dom_string_byte_length(script),
"?inline script?");
@@ -575,13 +575,13 @@ html_process_script(void *ctx, dom_node *node)
/* We should only ever be here if scripting was enabled for this
* content so it's correct to make a javascript context if there
* isn't one already. */
- if (c->jscontext == NULL) {
+ if (c->jsthread == NULL) {
union content_msg_data msg_data;
- msg_data.jscontext = &c->jscontext;
- content_broadcast(&c->base, CONTENT_MSG_GETCTX, &msg_data);
- NSLOG(netsurf, INFO, "javascript context %p ", c->jscontext);
- if (c->jscontext == NULL) {
+ msg_data.jsthread = &c->jsthread;
+ content_broadcast(&c->base, CONTENT_MSG_GETTHREAD, &msg_data);
+ NSLOG(netsurf, INFO, "javascript context %p ", c->jsthread);
+ if (c->jsthread == NULL) {
/* no context and it could not be created, abort */
return DOM_HUBBUB_OK;
}
@@ -668,6 +668,6 @@ nserror html_script_free(html_content *html)
/* exported internal interface documented in html/html_internal.h */
nserror html_script_invalidate_ctx(html_content *htmlc)
{
- htmlc->jscontext = NULL;
+ htmlc->jsthread = NULL;
return NSERROR_OK;
}