From 0bbc03c5776fdcf6006bb0447341f82967d2b5d1 Mon Sep 17 00:00:00 2001 From: Michael Drake Date: Wed, 20 Jan 2016 19:24:12 +0000 Subject: Cache place below level, to avoid pointless calls to find_sides. --- render/box.c | 1 + render/box.h | 3 +++ render/layout.c | 9 ++++++++- 3 files changed, 12 insertions(+), 1 deletion(-) (limited to 'render') diff --git a/render/box.c b/render/box.c index 0d92b594c..7111f1a6e 100644 --- a/render/box.c +++ b/render/box.c @@ -156,6 +156,7 @@ struct box * box_create(css_select_results *styles, css_computed_style *style, box->float_children = NULL; box->float_container = NULL; box->next_float = NULL; + box->cached_place_below_level = 0; box->list_marker = NULL; box->col = NULL; box->gadget = NULL; diff --git a/render/box.h b/render/box.h index 8e5aef8f5..5501f88c8 100644 --- a/render/box.h +++ b/render/box.h @@ -244,6 +244,9 @@ struct box { * This is used only for boxes with float_children */ int clear_level; + /* Level below which floats have been placed. */ + int cached_place_below_level; + /** List marker box if this is a list-item, or 0. */ struct box *list_marker; diff --git a/render/layout.c b/render/layout.c index 95f3681aa..f069cd665 100644 --- a/render/layout.c +++ b/render/layout.c @@ -227,6 +227,7 @@ bool layout_block_context(struct box *block, int viewport_height, assert(block->width != AUTO); block->float_children = NULL; + block->cached_place_below_level = 0; block->clear_level = 0; /* special case if the block contains an object */ @@ -2737,6 +2738,7 @@ bool layout_line(struct box *first, int *width, int *y, d = b->children; d->float_children = 0; + d->cached_place_below_level = 0; b->float_container = d->float_container = cont; if (!layout_float(d, *width, content)) @@ -3439,10 +3441,13 @@ bool layout_float(struct box *b, int width, html_content *content) void place_float_below(struct box *c, int width, int cx, int y, struct box *cont) { - int x0, x1, yy = y; + int x0, x1, yy; struct box *left; struct box *right; + yy = y > cont->cached_place_below_level ? + y : cont->cached_place_below_level; + #ifdef LAYOUT_DEBUG LOG("c %p, width %i, cx %i, y %i, cont %p", c, width, cx, y, cont); #endif @@ -3471,6 +3476,7 @@ void place_float_below(struct box *c, int width, int cx, int y, c->x = x1 - c->width; } c->y = y; + cont->cached_place_below_level = y; } @@ -3864,6 +3870,7 @@ bool layout_table(struct box *table, int available_width, c->padding[RIGHT] - c->border[RIGHT].width; c->float_children = 0; + c->cached_place_below_level = 0; c->height = AUTO; if (!layout_block_context(c, -1, content)) { -- cgit v1.2.3