From d117eb452763e1da14c89b9a5379285b56d6ad78 Mon Sep 17 00:00:00 2001 From: James Bursa Date: Sun, 31 Dec 2006 23:47:17 +0000 Subject: Stop animated images rendering for hidden or fallback boxes. svn path=/trunk/netsurf/; revision=3128 --- render/box.c | 28 ++++++++++++++++++++++++++++ render/box.h | 1 + render/html.c | 4 +++- 3 files changed, 32 insertions(+), 1 deletion(-) diff --git a/render/box.c b/render/box.c index fe70c61f8..6f5b3f158 100644 --- a/render/box.c +++ b/render/box.c @@ -458,6 +458,34 @@ struct box *box_find_by_id(struct box *box, const char *id) } +/** + * Determine if a box is visible when the tree is rendered. + * + * \param box box to check + * \return true iff the box is rendered + */ + +bool *box_visible(struct box *box) +{ + struct box *fallback; + + /* visibility: hidden */ + if (box->style && box->style->visibility == CSS_VISIBILITY_HIDDEN) + return false; + + /* check if a fallback */ + while (box->parent) { + for (fallback = box->parent->fallback; fallback; + fallback = fallback->next) + if (fallback == box) + return false; + box = box->parent; + } + + return true; +} + + /** * Print a box tree to stderr. */ diff --git a/render/box.h b/render/box.h index e932b7480..bdc2fdbdc 100644 --- a/render/box.h +++ b/render/box.h @@ -276,6 +276,7 @@ struct box *box_at_point(struct box *box, int x, int y, struct content **content); struct box *box_object_at_point(struct content *c, int x, int y); struct box *box_find_by_id(struct box *box, const char *id); +bool *box_visible(struct box *box); void box_dump(struct box *box, unsigned int depth); bool box_extract_link(const char *rel, const char *base, char **result); diff --git a/render/html.c b/render/html.c index ddf097cb3..1e50a77fb 100644 --- a/render/html.c +++ b/render/html.c @@ -503,7 +503,7 @@ bool html_head(struct content *c, xmlNode *head) for (node = head->children; node != 0; node = node->next) { if (node->type != XML_ELEMENT_NODE) continue; - + LOG(("Node: %s", node->name)); if (!c->title && strcmp(node->name, "title") == 0) { xmlChar *title = xmlNodeGetContent(node); @@ -1141,6 +1141,8 @@ void html_object_callback(content_msg msg, struct content *object, break; case CONTENT_MSG_REDRAW: + if (!box_visible(box)) + break; box_coords(box, &x, &y); if (object == data.redraw.object) { data.redraw.x = data.redraw.x * -- cgit v1.2.3