Use Servo-specific pseudo element for InlineBlock fragment

This commit is contained in:
Pu Xingyu 2017-03-21 01:39:54 +08:00
parent 54e2b7b2d5
commit 836e554c30
5 changed files with 24 additions and 15 deletions

View file

@ -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);

View file

@ -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.
///

View file

@ -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(())
};

View file

@ -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 |

View file

@ -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;
}