diff options
author | Michael Drake <tlsa@netsurf-browser.org> | 2008-04-23 18:49:11 +0000 |
---|---|---|
committer | Michael Drake <tlsa@netsurf-browser.org> | 2008-04-23 18:49:11 +0000 |
commit | fc4e39f5b89e36c47cc4ebcf9df7f24511baaeff (patch) | |
tree | 35c6b22d9459ce6d93d92b4a4b5009b251028362 | |
parent | e6e0fa0b326ed8b14e3944e93b9fe6f1d594d6d3 (diff) | |
download | netsurf-fc4e39f5b89e36c47cc4ebcf9df7f24511baaeff.tar.gz netsurf-fc4e39f5b89e36c47cc4ebcf9df7f24511baaeff.tar.bz2 |
Make floats that follow a cleared float heed the clear. Fixes position of search form on BBC homepage.
svn path=/trunk/netsurf/; revision=4104
-rw-r--r-- | render/box.h | 3 | ||||
-rw-r--r-- | render/layout.c | 19 |
2 files changed, 18 insertions, 4 deletions
diff --git a/render/box.h b/render/box.h index ad02ccc55..f4c9cfe2d 100644 --- a/render/box.h +++ b/render/box.h @@ -205,6 +205,9 @@ struct box { struct box *float_children; /** Next sibling float box. */ struct box *next_float; + /** Level below which subsequent floats must be cleared. + * This is used only for boxes with float_children */ + int clear_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 a8de1e42d..3f87df319 100644 --- a/render/layout.c +++ b/render/layout.c @@ -227,6 +227,7 @@ bool layout_block_context(struct box *block, struct content *content) #endif block->float_children = 0; + block->clear_level = 0; /* special case if the block contains an object */ if (block->object) { @@ -1469,7 +1470,8 @@ bool layout_line(struct box *first, int *width, int *y, if (d->style && d->style->clear == CSS_CLEAR_NONE && (b->width <= (x1 - x0) - x || - (left == 0 && right == 0 && x == 0))) { + (left == 0 && right == 0 && x == 0)) && + cy >= cont->clear_level) { /* not cleared * fits next to this line, or this line is * empty with no floats */ @@ -1482,12 +1484,20 @@ bool layout_line(struct box *first, int *width, int *y, x1 -= b->width; right = b; } - b->y = cy; + /* Heed any previous clear */ + if (cy < cont->clear_level) { + b->y = cont->clear_level; + } else { + b->y = cy; + } } else { /* cleared or doesn't fit */ /* place below into next available space */ + fy = (cy > cont->clear_level) ? cy : + cont->clear_level; + place_float_below(b, *width, - cx, cy + height, cont); + cx, fy + height, cont); if (d->style && d->style->clear != CSS_CLEAR_NONE) { /* to be cleared below existing @@ -1503,9 +1513,10 @@ bool layout_line(struct box *first, int *width, int *y, } fy = layout_clear(cont->float_children, d->style->clear); + if (fy > cont->clear_level) + cont->clear_level = fy; if (b->y < fy) b->y = fy; - } } if (cont->float_children == b) { |