summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Drake <michael.drake@codethink.co.uk>2017-04-28 14:44:34 (GMT)
committer Michael Drake <michael.drake@codethink.co.uk>2017-04-28 14:44:34 (GMT)
commit6f7b5e3f221b4da4ff5da07281e0f2074b9e57fd (patch)
tree9007905370642825d4a0364f0a19d895b8451de2
parente431e6181b2cd480fc4ec2fb0d7f7474470d5669 (diff)
downloadnetsurf-6f7b5e3f221b4da4ff5da07281e0f2074b9e57fd.tar.gz
netsurf-6f7b5e3f221b4da4ff5da07281e0f2074b9e57fd.tar.bz2
Layout: Fix auto margins to be affected by {min|max}-width constraints.
-rw-r--r--render/layout.c28
1 files changed, 20 insertions, 8 deletions
diff --git a/render/layout.c b/render/layout.c
index 4086c04..d9b108c 100644
--- a/render/layout.c
+++ b/render/layout.c
@@ -1545,16 +1545,20 @@ layout_solve_width(struct box *box,
/* Find width */
if (width == AUTO) {
- /* any other 'auto' become 0 or the minimum required values */
- if (box->margin[LEFT] == AUTO)
- box->margin[LEFT] = lm;
- if (box->margin[RIGHT] == AUTO)
- box->margin[RIGHT] = rm;
+ int margin_left = box->margin[LEFT];
+ int margin_right = box->margin[RIGHT];
+
+ if (margin_left == AUTO) {
+ margin_left = lm;
+ }
+ if (margin_right == AUTO) {
+ margin_right = rm;
+ }
width = available_width -
- (box->margin[LEFT] + box->border[LEFT].width +
+ (margin_left + box->border[LEFT].width +
box->padding[LEFT] + box->padding[RIGHT] +
- box->border[RIGHT].width + box->margin[RIGHT]);
+ box->border[RIGHT].width + margin_right);
width = width < 0 ? 0 : width;
auto_width = true;
}
@@ -1572,8 +1576,16 @@ layout_solve_width(struct box *box,
}
/* Width was auto, and unconstrained by min/max width, so we're done */
- if (auto_width)
+ if (auto_width) {
+ /* any other 'auto' become 0 or the minimum required values */
+ if (box->margin[LEFT] == AUTO) {
+ box->margin[LEFT] = lm;
+ }
+ if (box->margin[RIGHT] == AUTO) {
+ box->margin[RIGHT] = rm;
+ }
return width;
+ }
/* Width was not auto, or was constrained by min/max width
* Need to compute left/right margins */