summaryrefslogtreecommitdiff
path: root/render
diff options
context:
space:
mode:
authorJohn Mark Bell <jmb@netsurf-browser.org>2006-06-26 13:22:43 +0000
committerJohn Mark Bell <jmb@netsurf-browser.org>2006-06-26 13:22:43 +0000
commitf881db3654615244d617f439b28ad53b50fc2c7b (patch)
tree3e67f46b9be289598156bcd81d01070f29dee836 /render
parent8ee81a7d8e00c70739ece2bafee04c9dce5429c8 (diff)
downloadnetsurf-f881db3654615244d617f439b28ad53b50fc2c7b.tar.gz
netsurf-f881db3654615244d617f439b28ad53b50fc2c7b.tar.bz2
Fix calculation of right margin in case where margin right is auto
Initialise available_width correctly for shrink-to-fit widthing. svn path=/trunk/netsurf/; revision=2649
Diffstat (limited to 'render')
-rw-r--r--render/layout.c19
1 files changed, 14 insertions, 5 deletions
diff --git a/render/layout.c b/render/layout.c
index 7e1928042..d0a69b65a 100644
--- a/render/layout.c
+++ b/render/layout.c
@@ -368,7 +368,7 @@ bool layout_block_context(struct box *block, struct content *content)
/* Absolutely positioned children. */
if (!layout_absolute_children(block, content))
return false;
-
+
return true;
}
@@ -2364,7 +2364,7 @@ void layout_compute_relative_offset(struct box *box, int *x, int *y)
box->style->position == CSS_POSITION_RELATIVE);
layout_compute_offsets(box, box->parent, &top, &right, &bottom, &left);
-
+
if (left == AUTO && right == AUTO)
left = right = 0;
else if (left == AUTO)
@@ -2501,9 +2501,9 @@ bool layout_absolute(struct box *box, struct content *content)
} else if (margin[RIGHT] == AUTO) {
margin[RIGHT] = containing_block->width -
left -
- border[LEFT] - padding[LEFT] -
+ margin[LEFT] - border[LEFT] - padding[LEFT] -
width -
- padding[RIGHT] - border[RIGHT] - margin[RIGHT] -
+ padding[RIGHT] - border[RIGHT] -
right;
} else {
right = containing_block->width -
@@ -2517,7 +2517,14 @@ bool layout_absolute(struct box *box, struct content *content)
margin[LEFT] = 0;
if (margin[RIGHT] == AUTO)
margin[RIGHT] = 0;
+
+ available_width = containing_block->width -
+ margin[LEFT] - border[LEFT] - padding[LEFT] -
+ padding[RIGHT] - border[RIGHT] - margin[RIGHT];
+
if (left == AUTO && width == AUTO && right != AUTO) {
+ available_width -= right;
+
width = min(max(box->min_width, available_width), box->max_width);
left = containing_block->width -
margin[LEFT] - border[LEFT] - padding[LEFT] -
@@ -2532,6 +2539,8 @@ bool layout_absolute(struct box *box, struct content *content)
width -
padding[RIGHT] - border[RIGHT] - margin[RIGHT];
} else if (left != AUTO && width == AUTO && right == AUTO) {
+ available_width -= left;
+
width = min(max(box->min_width, available_width), box->max_width);
right = containing_block->width -
left -
@@ -2566,7 +2575,7 @@ bool layout_absolute(struct box *box, struct content *content)
box->x = left;
box->width = width;
box->height = height;
-
+
if (box->type == BOX_BLOCK || box->object) {
if (!layout_block_context(box, content))
return false;