summaryrefslogtreecommitdiff
path: root/content/handlers
diff options
context:
space:
mode:
authorVincent Sanders <vince@kyllikki.org>2020-05-03 17:00:04 +0100
committerVincent Sanders <vince@kyllikki.org>2020-05-03 17:00:04 +0100
commita40727cd295f99e0bca5ba3bec792e44b830c986 (patch)
treeacb027bf8d321e23c4a73949096d1847955643fc /content/handlers
parentfcd8d5035965b57014c02bc6301f5b10b824b811 (diff)
downloadnetsurf-a40727cd295f99e0bca5ba3bec792e44b830c986.tar.gz
netsurf-a40727cd295f99e0bca5ba3bec792e44b830c986.tar.bz2
Improve hsndling of html content objects with no associated box
Diffstat (limited to 'content/handlers')
-rw-r--r--content/handlers/html/object.c51
1 files changed, 39 insertions, 12 deletions
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,