Skip to content
Permalink
Browse files

Use Servo-specific pseudo element for InlineBlock fragment

  • Loading branch information
stshine committed Mar 30, 2017
1 parent 54e2b7b commit 836e554c3046d578858d3f4d9687e5c2e2892db2
@@ -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);
@@ -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.
///
@@ -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(())
};

@@ -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 |
@@ -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.
You can’t perform that action at this time.