From a40727cd295f99e0bca5ba3bec792e44b830c986 Mon Sep 17 00:00:00 2001 From: Vincent Sanders Date: Sun, 3 May 2020 17:00:04 +0100 Subject: Improve hsndling of html content objects with no associated box --- content/handlers/html/object.c | 51 ++++++++++++++++++++++++++++++++---------- 1 file changed, 39 insertions(+), 12 deletions(-) (limited to 'content/handlers') diff --git a/content/handlers/html/object.c b/content/handlers/html/object.c index ba1470bd0..36726f1c5 100644 --- a/content/handlers/html/object.c +++ b/content/handlers/html/object.c @@ -125,10 +125,35 @@ html_object_done(struct box *box, } } + /** - * Callback for hlcache_handle_retrieve() for objects. + * Callback for hlcache_handle_retrieve() for objects with no box. */ +static nserror +html_object_nobox_callback(hlcache_handle *object, + const hlcache_event *event, + void *pw) +{ + struct content_html_object *chobject = pw; + + switch (event->type) { + case CONTENT_MSG_ERROR: + hlcache_handle_release(object); + chobject->content = NULL; + break; + + default: + break; + } + + return NSERROR_OK; +} + + +/** + * Callback for hlcache_handle_retrieve() for objects with a box. + */ static nserror html_object_callback(hlcache_handle *object, const hlcache_event *event, @@ -140,9 +165,6 @@ html_object_callback(hlcache_handle *object, struct box *box; box = o->box; - if (box == NULL && event->type != CONTENT_MSG_ERROR) { - return NSERROR_OK; - } switch (event->type) { case CONTENT_MSG_LOADING: @@ -204,14 +226,12 @@ html_object_callback(hlcache_handle *object, o->content = NULL; - if (box != NULL) { - c->base.active--; - NSLOG(netsurf, INFO, "%d fetches active", - c->base.active); + c->base.active--; + NSLOG(netsurf, INFO, "%d fetches active", c->base.active); + + content_add_error(&c->base, "?", 0); + html_object_failed(box, c, o->background); - content_add_error(&c->base, "?", 0); - html_object_failed(box, c, o->background); - } break; case CONTENT_MSG_REDRAW: @@ -693,6 +713,7 @@ html_fetch_object(html_content *c, bool background) { struct content_html_object *object; + hlcache_handle_callback object_callback; hlcache_child_context child; nserror error; @@ -708,6 +729,12 @@ html_fetch_object(html_content *c, return false; } + if (box == NULL) { + object_callback = html_object_nobox_callback; + } else { + object_callback = html_object_callback; + } + object->parent = (struct content *) c; object->next = NULL; object->content = NULL; @@ -719,7 +746,7 @@ html_fetch_object(html_content *c, HLCACHE_RETRIEVE_SNIFF_TYPE, content_get_url(&c->base), NULL, - html_object_callback, + object_callback, object, &child, object->permitted_types, -- cgit v1.2.3