From 1304964f92249a1f8e685db89aa694f77307d6ae Mon Sep 17 00:00:00 2001 From: Michael Drake Date: Wed, 27 Apr 2011 13:50:49 +0000 Subject: Reduce number of page reflows and viewport redraws as images are fetched: + Flag known-sized boxes generated by images. + Treat them as replaced all through layout. + Only reflow the document for fetched images if we don't already have the box at the right size. svn path=/trunk/netsurf/; revision=12243 --- render/box_construct.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'render/box_construct.c') diff --git a/render/box_construct.c b/render/box_construct.c index b47405c12..f780d0714 100644 --- a/render/box_construct.c +++ b/render/box_construct.c @@ -1159,6 +1159,11 @@ bool box_image(BOX_SPECIAL_PARAMS) bool ok; char *s, *url; xmlChar *alt, *src; + enum css_width_e wtype; + enum css_height_e htype; + css_fixed value = 0; + css_unit wunit = CSS_UNIT_PX; + css_unit hunit = CSS_UNIT_PX; if (box->style && css_computed_display(box->style, n->parent == NULL) == CSS_DISPLAY_NONE) @@ -1196,6 +1201,17 @@ bool box_image(BOX_SPECIAL_PARAMS) ok = html_fetch_object(content, url, box, image_types, content->available_width, 1000, false); free(url); + + wtype = css_computed_width(box->style, &value, &wunit); + htype = css_computed_height(box->style, &value, &hunit); + + if (wtype == CSS_WIDTH_SET && wunit != CSS_UNIT_PCT && + htype == CSS_HEIGHT_SET && hunit != CSS_UNIT_PCT) { + /* We know the dimensions the image will be shown at before it's + * fetched. */ + box->flags |= REPLACE_DIM; + } + return ok; } -- cgit v1.2.3