Skip to content

Commit

Permalink
Use Servo-specific pseudo element for InlineBlock fragment
Browse files Browse the repository at this point in the history
  • Loading branch information
stshine committed Mar 30, 2017
1 parent 54e2b7b commit 836e554
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 15 deletions.
8 changes: 5 additions & 3 deletions components/layout/construct.rs
Expand Up @@ -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);
Expand Down
10 changes: 0 additions & 10 deletions components/style/properties/properties.mako.rs
Expand Up @@ -2544,16 +2544,6 @@ pub fn modify_border_style_for_inline_sides(style: &mut Arc<ComputedValues>,
}
}

/// 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<ComputedValues>) {
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.
///
Expand Down
11 changes: 10 additions & 1 deletion components/style/servo/selector_parser.rs
Expand Up @@ -39,6 +39,7 @@ pub enum PseudoElement {
ServoAnonymousTableRow,
ServoAnonymousTableCell,
ServoAnonymousBlock,
ServoInlineBlockWrapper,
}

impl ToCss for PseudoElement {
Expand All @@ -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",
})
}
}
Expand Down Expand Up @@ -89,7 +91,8 @@ impl PseudoElement {
PseudoElement::ServoAnonymousTable |
PseudoElement::ServoAnonymousTableRow |
PseudoElement::ServoAnonymousTableCell |
PseudoElement::ServoAnonymousBlock => PseudoElementCascadeType::Precomputed,
PseudoElement::ServoAnonymousBlock |
PseudoElement::ServoInlineBlockWrapper => PseudoElementCascadeType::Precomputed,
}
}
}
Expand Down Expand Up @@ -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(())
};

Expand Down
3 changes: 2 additions & 1 deletion components/style/stylist.rs
Expand Up @@ -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 |
Expand Down
7 changes: 7 additions & 0 deletions resources/servo.css
Expand Up @@ -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;
}

0 comments on commit 836e554

Please sign in to comment.