From 61dc91e0c553ef6c1e7bf3e4061fdbbbfa28fad4 Mon Sep 17 00:00:00 2001 From: John Mark Bell Date: Mon, 26 Jun 2006 22:24:42 +0000 Subject: Relative positioning for absolutely positioned boxes svn path=/trunk/netsurf/; revision=2653 --- render/layout.c | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) (limited to 'render/layout.c') diff --git a/render/layout.c b/render/layout.c index 391f884b5..6875bce61 100644 --- a/render/layout.c +++ b/render/layout.c @@ -2318,6 +2318,7 @@ void layout_position_relative(struct box *root) if (!root) return; + /* Normal children */ for (box = root->children; box; box = box->next) { int x, y; @@ -2349,6 +2350,39 @@ void layout_position_relative(struct box *root) } } } + + /* Absolute children */ + for (box = root->absolute_children; box; box = box->next) { + int x, y; + + if (box->type == BOX_TEXT) + continue; + + /* recurse first */ + layout_position_relative(box); + + /* Ignore things we're not interested in. */ + if (!box->style || (box->style && + box->style->position != CSS_POSITION_RELATIVE)) + continue; + + layout_compute_relative_offset(box, &x, &y); + + box->x += x; + box->y += y; + + /* Handle INLINEs - their "children" are in fact + * the sibling boxes between the INLINE and + * INLINE_END boxes */ + if (box->type == BOX_INLINE && box->inline_end) { + struct box *b; + for (b = box->next; b && b != box->inline_end; + b = b->next) { + b->x += x; + b->y += y; + } + } + } } -- cgit v1.2.3