From 3c3685eb9635cc46fe78b31d54967b62b948581e Mon Sep 17 00:00:00 2001 From: Michael Drake Date: Mon, 2 Apr 2018 20:25:19 +0100 Subject: Layout: Percentage max-width constrained boxes don't affect min on minmax pass. --- render/layout.c | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/render/layout.c b/render/layout.c index b1d5557bd..121137adc 100644 --- a/render/layout.c +++ b/render/layout.c @@ -503,6 +503,23 @@ static void layout_minmax_table(struct box *table, assert(0 <= table->min_width && table->min_width <= table->max_width); } +/** + * Helper to check if a box has percentage max width. + * + * \param[in] b Box to check. + * \return true iff box has percnetage max width. + */ +static inline bool box_has_percentage_max_width(struct box *b) +{ + css_unit unit = CSS_UNIT_PX; + enum css_max_width_e type; + css_fixed value = 0; + + assert(b != NULL); + + type = css_computed_max_width(b->style, &value, &unit); + return ((type == CSS_MAX_WIDTH_SET) && (unit == CSS_UNIT_PCT)); +} /** * Calculate minimum and maximum width of a line. @@ -834,7 +851,7 @@ layout_minmax_line(struct box *first, b->style)); } - if (min < width) + if (min < width && !box_has_percentage_max_width(b)) min = width; if (width > 0) max += width; -- cgit v1.2.3