summaryrefslogtreecommitdiff
path: root/content/handlers/html
diff options
context:
space:
mode:
authorDaniel Silverstone <dsilvers@digital-scurf.org>2020-03-22 10:00:29 +0000
committerDaniel Silverstone <dsilvers@digital-scurf.org>2020-03-22 10:00:29 +0000
commitefbfaa0cb1808a3953f1595b9c5e1be9d7994469 (patch)
treeb26e51d0004397a3da6a4328b2b6048175e34bad /content/handlers/html
parent98e461a3b3580cfee2356459557d4f58b7db987c (diff)
downloadnetsurf-efbfaa0cb1808a3953f1595b9c5e1be9d7994469.tar.gz
netsurf-efbfaa0cb1808a3953f1595b9c5e1be9d7994469.tar.bz2
JS: Move ownership of jsthread from browser to htmlc
Since it makes more sense for the htmlc to be responsible for when the JS thread gets destroyed, move its lifetime from the responsibility of the browser window to the html content. Signed-off-by: Daniel Silverstone <dsilvers@digital-scurf.org>
Diffstat (limited to 'content/handlers/html')
-rw-r--r--content/handlers/html/html.c20
-rw-r--r--content/handlers/html/html_internal.h8
-rw-r--r--content/handlers/html/html_script.c7
3 files changed, 8 insertions, 27 deletions
diff --git a/content/handlers/html/html.c b/content/handlers/html/html.c
index 26be58d73..5b6a15f7d 100644
--- a/content/handlers/html/html.c
+++ b/content/handlers/html/html.c
@@ -1637,12 +1637,6 @@ static void html_stop(struct content *c)
{
html_content *htmlc = (html_content *) c;
- /* invalidate the html content reference to the javascript context
- * as it is about to become invalid and must not be used any
- * more.
- */
- html_script_invalidate_ctx(htmlc);
-
switch (c->status) {
case CONTENT_STATUS_LOADING:
/* Still loading; simply flag that we've been aborted
@@ -1853,6 +1847,14 @@ static void html_destroy(struct content *c)
if (html->base_url)
nsurl_unref(html->base_url);
+ /* At this point we can be moderately confident the JS is offline
+ * so we destroy the JS thread.
+ */
+ if (html->jsthread != NULL) {
+ js_destroythread(html->jsthread);
+ html->jsthread = NULL;
+ }
+
if (html->parser != NULL) {
dom_hubbub_parser_destroy(html->parser);
html->parser = NULL;
@@ -1977,12 +1979,6 @@ static nserror html_close(struct content *c)
/* clear the html content reference to the browser window */
htmlc->bw = NULL;
- /* invalidate the html content reference to the javascript context
- * as it is about to become invalid and must not be used any
- * more.
- */
- html_script_invalidate_ctx(htmlc);
-
/* remove all object references from the html content */
html_object_close_objects(htmlc);
diff --git a/content/handlers/html/html_internal.h b/content/handlers/html/html_internal.h
index a64078143..7340bd25c 100644
--- a/content/handlers/html/html_internal.h
+++ b/content/handlers/html/html_internal.h
@@ -321,14 +321,6 @@ nserror html_script_exec(html_content *htmlc, bool allow_defer);
nserror html_script_free(html_content *htmlc);
/**
- * Ensure the html content javascript context is invalidated.
- *
- * \param htmlc html content.
- * \return NSERROR_OK or error code.
- */
-nserror html_script_invalidate_ctx(html_content *htmlc);
-
-/**
* Check if any of the scripts loaded were insecure
*/
bool html_saw_insecure_scripts(html_content *htmlc);
diff --git a/content/handlers/html/html_script.c b/content/handlers/html/html_script.c
index 301acadd6..81bdccda9 100644
--- a/content/handlers/html/html_script.c
+++ b/content/handlers/html/html_script.c
@@ -664,10 +664,3 @@ nserror html_script_free(html_content *html)
return NSERROR_OK;
}
-
-/* exported internal interface documented in html/html_internal.h */
-nserror html_script_invalidate_ctx(html_content *htmlc)
-{
- htmlc->jsthread = NULL;
- return NSERROR_OK;
-}