From 22cb2fe809857915cdf920ab6513839dccccec64 Mon Sep 17 00:00:00 2001 From: James Bursa Date: Sun, 22 Feb 2004 22:27:31 +0000 Subject: [project @ 2004-02-22 22:27:31 by bursa] Fix calculate_widths() for floats. svn path=/import/netsurf/; revision=564 --- render/layout.c | 35 ++++++++++++++++++----------------- 1 file changed, 18 insertions(+), 17 deletions(-) (limited to 'render/layout.c') diff --git a/render/layout.c b/render/layout.c index 0d95aa3fb..b5fdc0723 100644 --- a/render/layout.c +++ b/render/layout.c @@ -1066,7 +1066,6 @@ void calculate_widths(struct box *box) assert(box->type == BOX_TABLE_CELL || box->type == BOX_BLOCK || box->type == BOX_INLINE_BLOCK || box->type == BOX_FLOAT_LEFT || box->type == BOX_FLOAT_RIGHT); - assert(style); /* check if the widths have already been calculated */ if (box->max_width != UNKNOWN_MAX_WIDTH) @@ -1103,22 +1102,24 @@ void calculate_widths(struct box *box) } /* add margins, border, padding to min, max widths */ - for (side = 1; side != 5; side += 2) { /* RIGHT, LEFT */ - if (style->padding[side].padding == CSS_PADDING_LENGTH) - extra_fixed += len(&style->padding[side].value.length, - style); - else if (style->padding[side].padding == CSS_PADDING_PERCENT) - extra_frac += style->padding[side].value.percent * 0.01; - - if (style->border[side].style != CSS_BORDER_STYLE_NONE) - extra_fixed += len(&style->border[side].width.value, - style); - - if (style->margin[side].margin == CSS_MARGIN_LENGTH) - extra_fixed += len(&style->margin[side].value.length, - style); - else if (style->margin[side].margin == CSS_MARGIN_PERCENT) - extra_frac += style->margin[side].value.percent * 0.01; + if (style) { + for (side = 1; side != 5; side += 2) { /* RIGHT, LEFT */ + if (style->padding[side].padding == CSS_PADDING_LENGTH) + extra_fixed += len(&style->padding[side].value.length, + style); + else if (style->padding[side].padding == CSS_PADDING_PERCENT) + extra_frac += style->padding[side].value.percent * 0.01; + + if (style->border[side].style != CSS_BORDER_STYLE_NONE) + extra_fixed += len(&style->border[side].width.value, + style); + + if (style->margin[side].margin == CSS_MARGIN_LENGTH) + extra_fixed += len(&style->margin[side].value.length, + style); + else if (style->margin[side].margin == CSS_MARGIN_PERCENT) + extra_frac += style->margin[side].value.percent * 0.01; + } } if (1.0 <= extra_frac) -- cgit v1.2.3