From b427a005b695431125d1b8b85187da2e6a2f7c20 Mon Sep 17 00:00:00 2001 From: John Mark Bell Date: Thu, 29 Jun 2006 15:53:17 +0000 Subject: Properly take account of padding on containing block. svn path=/trunk/netsurf/; revision=2673 --- render/layout.c | 31 ++++++++++++++++++++++--------- 1 file changed, 22 insertions(+), 9 deletions(-) diff --git a/render/layout.c b/render/layout.c index ac0c755a2..0af725bc0 100644 --- a/render/layout.c +++ b/render/layout.c @@ -2486,9 +2486,24 @@ bool layout_absolute(struct box *box, struct content *content) assert(box->type == BOX_BLOCK || box->type == BOX_TABLE); + if (containing_block->type == BOX_BLOCK || + containing_block->type == BOX_INLINE_BLOCK || + containing_block->type == BOX_TABLE_CELL) { + /* Block level container => temporarily increase containing + * block dimensions to include padding (we restore this + * again at the end) */ + containing_block->width += containing_block->padding[LEFT] + + containing_block->padding[RIGHT]; + containing_block->height += containing_block->padding[TOP] + + containing_block->padding[BOTTOM]; + } else { + /** \todo inline containers */ + } + layout_compute_offsets(box, containing_block, &top, &right, &bottom, &left); - layout_find_dimensions(containing_block->width, box->style, + + layout_find_dimensions(available_width, box->style, &width, &height, margin, padding, border); /* 10.3.7 */ @@ -2616,10 +2631,9 @@ bool layout_absolute(struct box *box, struct content *content) if (containing_block->type == BOX_BLOCK || containing_block->type == BOX_INLINE_BLOCK || containing_block->type == BOX_TABLE_CELL) { - /* Block-level ancestor => compensate for ancestor's - * l,r padding */ - box->x += containing_block->padding[RIGHT] - - containing_block->padding[LEFT]; + /* Block-level ancestor => reset container's width */ + containing_block->width -= containing_block->padding[LEFT] + + containing_block->padding[RIGHT]; } else { /** \todo inline ancestors */ } @@ -2739,10 +2753,9 @@ bool layout_absolute(struct box *box, struct content *content) if (containing_block->type == BOX_BLOCK || containing_block->type == BOX_INLINE_BLOCK || containing_block->type == BOX_TABLE_CELL) { - /* Block-level ancestor => compensate for ancestor's - * t,b padding */ - box->y += containing_block->padding[BOTTOM] - - containing_block->padding[TOP]; + /* Block-level ancestor => reset container's height */ + containing_block->height -= containing_block->padding[TOP] + + containing_block->padding[BOTTOM]; } else { /** \todo Inline ancestors */ } -- cgit v1.2.3