diff options
author | Pu Xingyu <pu.stshine@gmail.com> | 2017-03-21 14:15:20 +0800 |
---|---|---|
committer | Pu Xingyu <pu.stshine@gmail.com> | 2017-03-31 02:45:09 +0800 |
commit | 1677d479f61351ad22149eb577de6713a16b9908 (patch) | |
tree | f846d6acb8426aee969856d29b5c19752c25a887 | |
parent | 836e554c3046d578858d3f4d9687e5c2e2892db2 (diff) | |
download | servo-1677d479f61351ad22149eb577de6713a16b9908.tar.gz servo-1677d479f61351ad22149eb577de6713a16b9908.zip |
Use Servo-specific pseudo element for InlineAbsolute fragment
-rw-r--r-- | components/layout/construct.rs | 5 | ||||
-rw-r--r-- | components/style/properties/properties.mako.rs | 11 | ||||
-rw-r--r-- | components/style/servo/selector_parser.rs | 13 | ||||
-rw-r--r-- | components/style/stylist.rs | 3 | ||||
-rw-r--r-- | resources/servo.css | 8 |
5 files changed, 25 insertions, 15 deletions
diff --git a/components/layout/construct.rs b/components/layout/construct.rs index 5533942e5a0..7dd4da8ada4 100644 --- a/components/layout/construct.rs +++ b/components/layout/construct.rs @@ -989,8 +989,9 @@ impl<'a, ConcreteThreadSafeLayoutNode: ThreadSafeLayoutNode> let fragment_info = SpecificFragmentInfo::InlineAbsoluteHypothetical( InlineAbsoluteHypotheticalFragmentInfo::new(block_flow)); let style_context = self.style_context(); - let mut style = node.style(style_context); - properties::modify_style_for_inline_absolute_hypothetical_fragment(&mut style); + let style = node.style(style_context); + let style = style_context.stylist.style_for_anonymous_box( + &style_context.guards, &PseudoElement::ServoInlineAbsolute, &style); let fragment = Fragment::from_opaque_node_and_style(node.opaque(), PseudoElementType::Normal, style, diff --git a/components/style/properties/properties.mako.rs b/components/style/properties/properties.mako.rs index 0dae0a7172d..319fc9cecfa 100644 --- a/components/style/properties/properties.mako.rs +++ b/components/style/properties/properties.mako.rs @@ -2582,17 +2582,6 @@ pub fn modify_style_for_text(style: &mut Arc<ComputedValues>) { } } -/// Adjusts the `clip` property so that an inline absolute hypothetical fragment -/// doesn't clip its children. -#[cfg(feature = "servo")] -pub fn modify_style_for_inline_absolute_hypothetical_fragment(style: &mut Arc<ComputedValues>) { - if !style.get_effects().clip.is_auto() { - let mut style = Arc::make_mut(style); - let effects_style = Arc::make_mut(&mut style.effects); - effects_style.clip = Either::auto() - } -} - #[macro_export] macro_rules! css_properties_accessors { ($macro_name: ident) => { diff --git a/components/style/servo/selector_parser.rs b/components/style/servo/selector_parser.rs index 311a15284aa..563e7b89c44 100644 --- a/components/style/servo/selector_parser.rs +++ b/components/style/servo/selector_parser.rs @@ -40,6 +40,7 @@ pub enum PseudoElement { ServoAnonymousTableCell, ServoAnonymousBlock, ServoInlineBlockWrapper, + ServoInlineAbsolute, } impl ToCss for PseudoElement { @@ -59,6 +60,7 @@ impl ToCss for PseudoElement { ServoAnonymousTableCell => "::-servo-anonymous-table-cell", ServoAnonymousBlock => "::-servo-anonymous-block", ServoInlineBlockWrapper => "::-servo-inline-block-wrapper", + ServoInlineAbsolute => "::-servo-inline-absolute", }) } } @@ -92,7 +94,8 @@ impl PseudoElement { PseudoElement::ServoAnonymousTableRow | PseudoElement::ServoAnonymousTableCell | PseudoElement::ServoAnonymousBlock | - PseudoElement::ServoInlineBlockWrapper => PseudoElementCascadeType::Precomputed, + PseudoElement::ServoInlineBlockWrapper | + PseudoElement::ServoInlineAbsolute => PseudoElementCascadeType::Precomputed, } } } @@ -329,6 +332,12 @@ impl<'a> ::selectors::Parser for SelectorParser<'a> { } ServoInlineBlockWrapper }, + "-servo-input-absolute" => { + if !self.in_user_agent_stylesheet() { + return Err(()) + } + ServoInlineAbsolute + }, _ => return Err(()) }; @@ -368,6 +377,8 @@ impl SelectorImpl { fun(PseudoElement::ServoAnonymousTableRow); fun(PseudoElement::ServoAnonymousTableCell); fun(PseudoElement::ServoAnonymousBlock); + fun(PseudoElement::ServoInlineBlockWrapper); + fun(PseudoElement::ServoInlineAbsolute); } /// Returns the pseudo-class state flag for selector matching. diff --git a/components/style/stylist.rs b/components/style/stylist.rs index 6e2e8632f37..e9533a7cb65 100644 --- a/components/style/stylist.rs +++ b/components/style/stylist.rs @@ -399,7 +399,8 @@ impl Stylist { PseudoElement::ServoAnonymousTableRow | PseudoElement::ServoAnonymousTableWrapper | PseudoElement::ServoTableWrapper | - PseudoElement::ServoInlineBlockWrapper => true, + PseudoElement::ServoInlineBlockWrapper | + PseudoElement::ServoInlineAbsolute => true, PseudoElement::Before | PseudoElement::After | PseudoElement::Selection | diff --git a/resources/servo.css b/resources/servo.css index 341a5ad077c..31e3c073e8e 100644 --- a/resources/servo.css +++ b/resources/servo.css @@ -222,3 +222,11 @@ svg > * { padding: 0; margin: 0; } + +/* The outer fragment wrapper of an inline absolute hypothetical fragment. */ +*|*::-servo-inline-absolute { + clip: auto; + border: none; + padding: 0; + margin: 0; +} |