Skip to content

Commit

Permalink
Use Servo-specific pseudo element for InlineAbsolute fragment
Browse files Browse the repository at this point in the history
  • Loading branch information
stshine committed Mar 30, 2017
1 parent 836e554 commit 1677d47
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 15 deletions.
5 changes: 3 additions & 2 deletions components/layout/construct.rs
Expand Up @@ -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,
Expand Down
11 changes: 0 additions & 11 deletions components/style/properties/properties.mako.rs
Expand Up @@ -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) => {
Expand Down
13 changes: 12 additions & 1 deletion components/style/servo/selector_parser.rs
Expand Up @@ -40,6 +40,7 @@ pub enum PseudoElement {
ServoAnonymousTableCell,
ServoAnonymousBlock,
ServoInlineBlockWrapper,
ServoInlineAbsolute,
}

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

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

0 comments on commit 1677d47

Please sign in to comment.