mirror of
https://github.com/servo/servo.git
synced 2025-08-03 12:40:06 +01:00
Handle anonymous style in traverse_pseudo_element_contents
This commit is contained in:
parent
0c156c60c2
commit
053a3d5a5a
1 changed files with 32 additions and 22 deletions
|
@ -14,6 +14,7 @@ use std::marker::PhantomData as marker;
|
||||||
use style::context::SharedStyleContext;
|
use style::context::SharedStyleContext;
|
||||||
use style::dom::TNode;
|
use style::dom::TNode;
|
||||||
use style::properties::ComputedValues;
|
use style::properties::ComputedValues;
|
||||||
|
use style::selector_parser::PseudoElement;
|
||||||
|
|
||||||
#[derive(Clone, Copy)]
|
#[derive(Clone, Copy)]
|
||||||
pub(super) enum WhichPseudoElement {
|
pub(super) enum WhichPseudoElement {
|
||||||
|
@ -130,7 +131,7 @@ fn traverse_pseudo_element<'dom, Node>(
|
||||||
Display::Contents => {
|
Display::Contents => {
|
||||||
element.unset_pseudo_element_box(which);
|
element.unset_pseudo_element_box(which);
|
||||||
let items = generate_pseudo_element_content(&style, element, context);
|
let items = generate_pseudo_element_content(&style, element, context);
|
||||||
traverse_pseudo_element_contents(&style, items, handler);
|
traverse_pseudo_element_contents(&style, context, handler, items);
|
||||||
},
|
},
|
||||||
Display::GeneratingBox(display) => {
|
Display::GeneratingBox(display) => {
|
||||||
let items = generate_pseudo_element_content(&style, element, context);
|
let items = generate_pseudo_element_content(&style, element, context);
|
||||||
|
@ -144,33 +145,42 @@ fn traverse_pseudo_element<'dom, Node>(
|
||||||
|
|
||||||
fn traverse_pseudo_element_contents<'dom, Node>(
|
fn traverse_pseudo_element_contents<'dom, Node>(
|
||||||
pseudo_element_style: &Arc<ComputedValues>,
|
pseudo_element_style: &Arc<ComputedValues>,
|
||||||
items: Vec<PseudoElementContentItem>,
|
context: &SharedStyleContext,
|
||||||
handler: &mut impl TraversalHandler<'dom, Node>,
|
handler: &mut impl TraversalHandler<'dom, Node>,
|
||||||
|
items: Vec<PseudoElementContentItem>,
|
||||||
) where
|
) where
|
||||||
Node: 'dom,
|
Node: NodeExt<'dom>,
|
||||||
{
|
{
|
||||||
// let mut anonymous_style = None;
|
let mut anonymous_style = None;
|
||||||
for item in items {
|
for item in items {
|
||||||
match item {
|
match item {
|
||||||
PseudoElementContentItem::Text(text) => handler.handle_text(text, pseudo_element_style),
|
PseudoElementContentItem::Text(text) => handler.handle_text(text, pseudo_element_style),
|
||||||
PseudoElementContentItem::Replaced(contents) => {
|
PseudoElementContentItem::Replaced(contents) => {
|
||||||
// FIXME
|
let item_style = anonymous_style.get_or_insert_with(|| {
|
||||||
// let item_style = anonymous_style.get_or_insert_with(|| {
|
context
|
||||||
// ComputedValues::anonymous_inheriting_from(Some(pseudo_element_style))
|
.stylist
|
||||||
// });
|
.style_for_anonymous::<Node::ConcreteElement>(
|
||||||
// let display_inline = DisplayGeneratingBox::OutsideInside {
|
&context.guards,
|
||||||
// outside: DisplayOutside::Inline,
|
&PseudoElement::ServoText,
|
||||||
// inside: DisplayInside::Flow,
|
&pseudo_element_style,
|
||||||
// };
|
)
|
||||||
// // `display` is not inherited, so we get the initial value
|
});
|
||||||
// debug_assert!(item_style.box_.display == Display::GeneratingBox(display_inline));
|
let display_inline = DisplayGeneratingBox::OutsideInside {
|
||||||
// handler.handle_element(
|
outside: DisplayOutside::Inline,
|
||||||
// item_style,
|
inside: DisplayInside::Flow,
|
||||||
// display_inline,
|
};
|
||||||
// Contents::Replaced(contents),
|
// `display` is not inherited, so we get the initial value
|
||||||
// // We don’t keep pointers to boxes generated by contents of pseudo-elements
|
debug_assert!(
|
||||||
// BoxSlot::dummy(),
|
Display::from(item_style.get_box().display) ==
|
||||||
// )
|
Display::GeneratingBox(display_inline)
|
||||||
|
);
|
||||||
|
handler.handle_element(
|
||||||
|
item_style,
|
||||||
|
display_inline,
|
||||||
|
Contents::Replaced(contents),
|
||||||
|
// We don’t keep pointers to boxes generated by contents of pseudo-elements
|
||||||
|
BoxSlot::dummy(),
|
||||||
|
)
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -210,7 +220,7 @@ where
|
||||||
match self {
|
match self {
|
||||||
NonReplacedContents::OfElement(node) => traverse_children_of(node, context, handler),
|
NonReplacedContents::OfElement(node) => traverse_children_of(node, context, handler),
|
||||||
NonReplacedContents::OfPseudoElement(items) => {
|
NonReplacedContents::OfPseudoElement(items) => {
|
||||||
traverse_pseudo_element_contents(inherited_style, items, handler)
|
traverse_pseudo_element_contents(inherited_style, context, handler, items)
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue