diff --git a/components/style/style_adjuster.rs b/components/style/style_adjuster.rs index b855b937dfb..09bdb2a6522 100644 --- a/components/style/style_adjuster.rs +++ b/components/style/style_adjuster.rs @@ -150,6 +150,35 @@ impl<'a, 'b: 'a> StyleAdjuster<'a, 'b> { } } + /// -webkit-box with line-clamp and vertical orientation gets turned into + /// flow-root at computed-value time. + /// + /// This makes the element not be a flex container, with all that it + /// implies, but it should be safe. It matches blink, see + /// https://bugzilla.mozilla.org/show_bug.cgi?id=1786147#c10 + fn adjust_for_webkit_line_clamp(&mut self) { + use crate::properties::longhands::_moz_box_orient::computed_value::T as BoxOrient; + use crate::values::specified::box_::{DisplayOutside, DisplayInside}; + let box_style= self.style.get_box(); + if box_style.clone__webkit_line_clamp().is_none() { + return; + } + let disp = box_style.clone_display(); + if disp.inside() != DisplayInside::WebkitBox { + return; + } + if self.style.get_xul().clone__moz_box_orient() != BoxOrient::Vertical { + return; + } + let new_display = if disp.outside() == DisplayOutside::Block { + Display::FlowRoot + } else { + debug_assert_eq!(disp.outside(), DisplayOutside::Inline); + Display::InlineBlock + }; + self.style.mutate_box().set_adjusted_display(new_display, false); + } + /// CSS 2.1 section 9.7: /// /// If 'position' has the value 'absolute' or 'fixed', [...] the computed @@ -856,6 +885,7 @@ impl<'a, 'b: 'a> StyleAdjuster<'a, 'b> { } self.adjust_for_top_layer(); self.blockify_if_necessary(layout_parent_style, element); + self.adjust_for_webkit_line_clamp(); self.adjust_for_position(); self.adjust_for_overflow(); #[cfg(feature = "gecko")]