summaryrefslogtreecommitdiff
path: root/desktop
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 /desktop
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 'desktop')
-rw-r--r--desktop/browser_private.h3
-rw-r--r--desktop/browser_window.c28
2 files changed, 18 insertions, 13 deletions
diff --git a/desktop/browser_private.h b/desktop/browser_private.h
index c9f9bbcf6..562abf131 100644
--- a/desktop/browser_private.h
+++ b/desktop/browser_private.h
@@ -263,7 +263,8 @@ struct browser_window {
bool can_edit;
/** current javascript context */
- struct jscontext *jsctx;
+ struct jsheap *jsheap;
+ struct jsthread *jsthread;
/** cache of the currently displayed status text. */
struct {
diff --git a/desktop/browser_window.c b/desktop/browser_window.c
index 3d1a19f60..bd446a072 100644
--- a/desktop/browser_window.c
+++ b/desktop/browser_window.c
@@ -1485,15 +1485,19 @@ browser_window_callback(hlcache_handle *c, const hlcache_event *event, void *pw)
}
break;
- case CONTENT_MSG_GETCTX:
- /* only the content object created by the browser
- * window requires a new global compartment object
- */
- assert(bw->loading_content == c);
- if (js_newcompartment(bw->jsctx,
- bw,
- hlcache_handle_get_content(c)) != NULL) {
- *(event->data.jscontext) = bw->jsctx;
+ case CONTENT_MSG_GETTHREAD:
+ {
+ /* only the content object created by the browser
+ * window requires a new global compartment object
+ */
+ jsthread *thread;
+ assert(bw->loading_content == c);
+ if (js_newthread(bw->jsheap,
+ bw,
+ hlcache_handle_get_content(c),
+ &thread) == NSERROR_OK) {
+ *(event->data.jsthread) = thread;
+ }
}
break;
@@ -1760,8 +1764,8 @@ static void browser_window_destroy_internal(struct browser_window *bw)
bw->box = NULL;
}
- if (bw->jsctx != NULL) {
- js_destroycontext(bw->jsctx);
+ if (bw->jsheap != NULL) {
+ js_destroyheap(bw->jsheap);
}
/* These simply free memory, so are safe here */
@@ -3085,7 +3089,7 @@ browser_window_initialise_common(enum browser_window_create_flags flags,
assert(bw);
/* new javascript context for each window/(i)frame */
- err = js_newcontext(nsoption_int(script_timeout), &bw->jsctx);
+ err = js_newheap(nsoption_int(script_timeout), &bw->jsheap);
if (err != NSERROR_OK)
return err;