diff --git a/components/layout/construct.rs b/components/layout/construct.rs index 00cd46a079a..5533942e5a0 100644 --- a/components/layout/construct.rs +++ b/components/layout/construct.rs @@ -950,13 +950,15 @@ impl<'a, ConcreteThreadSafeLayoutNode: ThreadSafeLayoutNode> _ => unreachable!() }; - let mut modified_style = node.style(self.style_context()); - properties::modify_style_for_outer_inline_block_fragment(&mut modified_style); + let context = self.style_context(); + let style = node.style(context); + let style = context.stylist.style_for_anonymous_box( + &context.guards, &PseudoElement::ServoInlineBlockWrapper, &style); let fragment_info = SpecificFragmentInfo::InlineBlock(InlineBlockFragmentInfo::new( block_flow)); let fragment = Fragment::from_opaque_node_and_style(node.opaque(), node.get_pseudo_element_type().strip(), - modified_style, + style, node.selected_style(), node.restyle_damage(), fragment_info); diff --git a/components/style/properties/properties.mako.rs b/components/style/properties/properties.mako.rs index 9bb2b94749d..0dae0a7172d 100644 --- a/components/style/properties/properties.mako.rs +++ b/components/style/properties/properties.mako.rs @@ -2544,16 +2544,6 @@ pub fn modify_border_style_for_inline_sides(style: &mut Arc, } } -/// Adjusts the `position` property as necessary for the outer fragment wrapper -/// of an inline-block. -#[cfg(feature = "servo")] -#[inline] -pub fn modify_style_for_outer_inline_block_fragment(style: &mut Arc) { - let mut style = Arc::make_mut(style); - let box_style = Arc::make_mut(&mut style.box_); - box_style.position = longhands::position::computed_value::T::static_ -} - /// Adjusts the `position` and `padding` properties as necessary to account for /// text. /// diff --git a/components/style/servo/selector_parser.rs b/components/style/servo/selector_parser.rs index c853ff9af12..311a15284aa 100644 --- a/components/style/servo/selector_parser.rs +++ b/components/style/servo/selector_parser.rs @@ -39,6 +39,7 @@ pub enum PseudoElement { ServoAnonymousTableRow, ServoAnonymousTableCell, ServoAnonymousBlock, + ServoInlineBlockWrapper, } impl ToCss for PseudoElement { @@ -57,6 +58,7 @@ impl ToCss for PseudoElement { ServoAnonymousTableRow => "::-servo-anonymous-table-row", ServoAnonymousTableCell => "::-servo-anonymous-table-cell", ServoAnonymousBlock => "::-servo-anonymous-block", + ServoInlineBlockWrapper => "::-servo-inline-block-wrapper", }) } } @@ -89,7 +91,8 @@ impl PseudoElement { PseudoElement::ServoAnonymousTable | PseudoElement::ServoAnonymousTableRow | PseudoElement::ServoAnonymousTableCell | - PseudoElement::ServoAnonymousBlock => PseudoElementCascadeType::Precomputed, + PseudoElement::ServoAnonymousBlock | + PseudoElement::ServoInlineBlockWrapper => PseudoElementCascadeType::Precomputed, } } } @@ -320,6 +323,12 @@ impl<'a> ::selectors::Parser for SelectorParser<'a> { } ServoAnonymousBlock }, + "-servo-inline-block-wrapper" => { + if !self.in_user_agent_stylesheet() { + return Err(()) + } + ServoInlineBlockWrapper + }, _ => return Err(()) }; diff --git a/components/style/stylist.rs b/components/style/stylist.rs index f93d76a5879..6e2e8632f37 100644 --- a/components/style/stylist.rs +++ b/components/style/stylist.rs @@ -398,7 +398,8 @@ impl Stylist { PseudoElement::ServoAnonymousTableCell | PseudoElement::ServoAnonymousTableRow | PseudoElement::ServoAnonymousTableWrapper | - PseudoElement::ServoTableWrapper => true, + PseudoElement::ServoTableWrapper | + PseudoElement::ServoInlineBlockWrapper => true, PseudoElement::Before | PseudoElement::After | PseudoElement::Selection | diff --git a/resources/servo.css b/resources/servo.css index cc913977260..341a5ad077c 100644 --- a/resources/servo.css +++ b/resources/servo.css @@ -215,3 +215,10 @@ svg > * { height: auto; } +/* The outer fragment wrapper of an inline-block. */ +*|*::-servo-inline-block-wrapper { + position: static; + border: none; + padding: 0; + margin: 0; +}