diff --git a/components/layout_2020/dom_traversal.rs b/components/layout_2020/dom_traversal.rs index 8310751b517..b3a58cb2ade 100644 --- a/components/layout_2020/dom_traversal.rs +++ b/components/layout_2020/dom_traversal.rs @@ -274,7 +274,7 @@ impl Drop for BoxSlot<'_> { } } -pub(crate) trait NodeExt<'dom>: 'dom + Copy + Send + Sync { +pub(crate) trait NodeExt<'dom>: 'dom + Copy + LayoutNode + Send + Sync { fn is_element(self) -> bool; fn as_text(self) -> Option; fn first_child(self) -> Option; @@ -291,7 +291,7 @@ pub(crate) trait NodeExt<'dom>: 'dom + Copy + Send + Sync { impl<'dom, T> NodeExt<'dom> for T where - T: 'dom + LayoutNode + Send + Sync, + T: 'dom + Copy + LayoutNode + Send + Sync, { fn is_element(self) -> bool { self.to_threadsafe().as_element().is_some() diff --git a/components/layout_2020/flow/construct.rs b/components/layout_2020/flow/construct.rs index 23cc84a5f8b..6b2027a8794 100644 --- a/components/layout_2020/flow/construct.rs +++ b/components/layout_2020/flow/construct.rs @@ -16,6 +16,7 @@ use servo_arc::Arc; use std::convert::TryInto; use style::context::SharedStyleContext; use style::properties::ComputedValues; +use style::selector_parser::PseudoElement; impl BlockFormattingContext { pub fn construct<'dom>( @@ -511,22 +512,25 @@ where return; } + let context = self.context; let block_container_style = self.block_container_style; - // FIXME - // let anonymous_style = self.anonymous_style.get_or_insert_with(|| { - // // If parent_style is None, the parent is the document node, - // // in which case anonymous inline boxes should inherit their - // // styles from initial values. - // ComputedValues::anonymous_inheriting_from(Some(block_container_style)) - // }); + let anonymous_style = self.anonymous_style.get_or_insert_with(|| { + context + .stylist + .style_for_anonymous::( + &context.guards, + &PseudoElement::ServoText, + &block_container_style, + ) + }); - // let box_ = IntermediateBlockLevelBox::SameFormattingContextBlock { - // style: anonymous_style.clone(), - // contents: IntermediateBlockContainer::InlineFormattingContext(take( - // &mut self.ongoing_inline_formatting_context, - // )), - // }; - // self.block_level_boxes.push((box_, BoxSlot::dummy())) + let box_ = IntermediateBlockLevelBox::SameFormattingContextBlock { + style: anonymous_style.clone(), + contents: IntermediateBlockContainer::InlineFormattingContext(take( + &mut self.ongoing_inline_formatting_context, + )), + }; + self.block_level_boxes.push((box_, BoxSlot::dummy())) } fn current_inline_level_boxes(&mut self) -> &mut Vec> {