summaryrefslogtreecommitdiff
path: root/render
diff options
context:
space:
mode:
authorMichael Drake <tlsa@netsurf-browser.org>2009-01-29 21:23:48 +0000
committerMichael Drake <tlsa@netsurf-browser.org>2009-01-29 21:23:48 +0000
commit56b48410bee02be1c774df14c1f1ca93cea56a21 (patch)
tree8ad0361c74dc714464d85a4cd510ef1a769ed9ce /render
parentab3da706594ddc09352bd58c3deb88debd7eb613 (diff)
downloadnetsurf-56b48410bee02be1c774df14c1f1ca93cea56a21.tar.gz
netsurf-56b48410bee02be1c774df14c1f1ca93cea56a21.tar.bz2
Include top margin when finding sides for block formatting contexts.
svn path=/trunk/netsurf/; revision=6293
Diffstat (limited to 'render')
-rw-r--r--render/layout.c34
1 files changed, 27 insertions, 7 deletions
diff --git a/render/layout.c b/render/layout.c
index c6eb81ab1..709f516be 100644
--- a/render/layout.c
+++ b/render/layout.c
@@ -325,7 +325,30 @@ bool layout_block_context(struct box *block, struct content *content)
if (box->style && box->style->clear != CSS_CLEAR_NONE)
y = layout_clear(block->float_children,
box->style->clear);
- /* no /required/ margins if box doesn't establisha new block
+
+ /* Get top margin */
+ switch (box->style->margin[TOP].margin) {
+ case CSS_MARGIN_LENGTH:
+ box->margin[TOP] = css_len2px(&box->style->margin[TOP].
+ value.length, box->style);
+ break;
+ case CSS_MARGIN_PERCENT:
+ box->margin[TOP] = box->parent->width *
+ box->style->margin[TOP].value.percent /
+ 100;
+ break;
+ case CSS_MARGIN_AUTO:
+ default:
+ box->margin[TOP] = 0;
+ break;
+ }
+
+ if (max_pos_margin < box->margin[TOP])
+ max_pos_margin = box->margin[TOP];
+ else if (max_neg_margin < -box->margin[TOP])
+ max_neg_margin = -box->margin[TOP];
+
+ /* no /required/ margins if box doesn't establish a new block
* formatting context */
lm = rm = 0;
@@ -339,6 +362,7 @@ bool layout_block_context(struct box *block, struct content *content)
int x0, x1, top;
struct box *left, *right;
top = cy > y ? cy : y;
+ top += max_pos_margin - max_neg_margin;
x0 = cx;
x1 = cx + box->parent->width -
box->parent->padding[LEFT] -
@@ -364,6 +388,7 @@ bool layout_block_context(struct box *block, struct content *content)
int x0, x1, top;
struct box *left, *right;
top = cy > y ? cy : y;
+ top += max_pos_margin - max_neg_margin;
x0 = cx;
x1 = cx + box->parent->width -
box->parent->padding[LEFT] -
@@ -391,12 +416,7 @@ bool layout_block_context(struct box *block, struct content *content)
box->border[LEFT];
cx += box->x;
- /* Position box: top margin. */
- if (max_pos_margin < box->margin[TOP])
- max_pos_margin = box->margin[TOP];
- else if (max_neg_margin < -box->margin[TOP])
- max_neg_margin = -box->margin[TOP];
-
+ /* Position box: vertical. */
if (box->type != BOX_BLOCK || y ||
box->border[TOP] || box->padding[TOP]) {
margin_box->y += max_pos_margin - max_neg_margin;