summaryrefslogtreecommitdiff
path: root/content/handlers/html/box_construct.c
diff options
context:
space:
mode:
authorDaniel Silverstone <dsilvers@digital-scurf.org>2019-08-23 21:58:07 +0100
committerDaniel Silverstone <dsilvers@digital-scurf.org>2019-08-23 21:58:07 +0100
commit524965b867e9aaef4ba75d6e077fdfd6c0b88401 (patch)
treeef8a9d4b25e7131a9a793338ec3cd896c3760e70 /content/handlers/html/box_construct.c
parentcb33f696a2683e7e848a0444f52945f2f56acc28 (diff)
downloadnetsurf-524965b867e9aaef4ba75d6e077fdfd6c0b88401.tar.gz
netsurf-524965b867e9aaef4ba75d6e077fdfd6c0b88401.tar.bz2
Box Conversion: Cancel conversion during html_destroy
If dom_to_box is still in progress when we destroy an HTML content, we need to cancel the conversion otherwise we will end up with a scheduled callback into infinity. Signed-off-by: Daniel Silverstone <dsilvers@digital-scurf.org>
Diffstat (limited to 'content/handlers/html/box_construct.c')
-rw-r--r--content/handlers/html/box_construct.c23
1 files changed, 22 insertions, 1 deletions
diff --git a/content/handlers/html/box_construct.c b/content/handlers/html/box_construct.c
index 1f15d82b7..f0d68ac2e 100644
--- a/content/handlers/html/box_construct.c
+++ b/content/handlers/html/box_construct.c
@@ -163,10 +163,12 @@ static const struct element_entry element_table[] = {
* \return netsurf error code indicating status of call
*/
-nserror dom_to_box(dom_node *n, html_content *c, box_construct_complete_cb cb)
+nserror dom_to_box(dom_node *n, html_content *c, box_construct_complete_cb cb, void **box_conversion_context)
{
struct box_construct_ctx *ctx;
+ assert(box_conversion_context != NULL);
+
if (c->bctx == NULL) {
/* create a context allocation for this box tree */
c->bctx = talloc_zero(0, int);
@@ -186,9 +188,28 @@ nserror dom_to_box(dom_node *n, html_content *c, box_construct_complete_cb cb)
ctx->cb = cb;
ctx->bctx = c->bctx;
+ *box_conversion_context = ctx;
+
return guit->misc->schedule(0, (void *)convert_xml_to_box, ctx);
}
+nserror cancel_dom_to_box(void *box_conversion_context)
+{
+ struct box_construct_ctx *ctx = box_conversion_context;
+ nserror err;
+
+ err = guit->misc->schedule(-1, (void *)convert_xml_to_box, ctx);
+ if (err != NSERROR_OK) {
+ return err;
+ }
+
+ dom_node_unref(ctx->n);
+ free(ctx);
+
+ return NSERROR_OK;
+}
+
+
/* mapping from CSS display to box type
* this table must be in sync with libcss' css_display enum */
static const box_type box_map[] = {