From 1754c832d8ef7e96559cb3e1941b8cfdd48e4953 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Emilio=20Cobos=20=C3=81lvarez?= Date: Mon, 10 Feb 2020 17:36:49 +0100 Subject: [PATCH] layout_2020: Avoid decomposing mixed length / percentages in intrinsic sizing. As that makes no sense in presence of min / max. --- components/layout_2020/flow/inline.rs | 8 ++++++-- components/layout_2020/sizing.rs | 8 ++++++-- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/components/layout_2020/flow/inline.rs b/components/layout_2020/flow/inline.rs index 5d362fc34a72..58dfb6581dba 100644 --- a/components/layout_2020/flow/inline.rs +++ b/components/layout_2020/flow/inline.rs @@ -159,8 +159,12 @@ impl InlineFormattingContext { } fn add_lengthpercentage(&mut self, lp: LengthPercentage) { - self.add_length(lp.length_component()); - self.current_line_percentages += lp.percentage_component(); + if let Some(l) = lp.to_length() { + self.add_length(l); + } + if let Some(p) = lp.to_percentage() { + self.current_line_percentages += p; + } } fn add_length(&mut self, l: Length) { diff --git a/components/layout_2020/sizing.rs b/components/layout_2020/sizing.rs index 676c7eb347ab..f5dac929b846 100644 --- a/components/layout_2020/sizing.rs +++ b/components/layout_2020/sizing.rs @@ -148,8 +148,12 @@ impl BoxContentSizes { let margin = style.margin(); pbm_lengths += border.inline_sum(); let mut add = |x: LengthPercentage| { - pbm_lengths += x.length_component(); - pbm_percentages += x.percentage_component(); + if let Some(l) = x.to_length() { + pbm_lengths += l; + } + if let Some(p) = x.to_percentage() { + pbm_percentages += p; + } }; add(padding.inline_start); add(padding.inline_end);