diff --git a/components/layout_2020/dom_traversal.rs b/components/layout_2020/dom_traversal.rs index c043d3b75d3..6d463608fe7 100644 --- a/components/layout_2020/dom_traversal.rs +++ b/components/layout_2020/dom_traversal.rs @@ -64,14 +64,14 @@ where &mut self, node: Node, text: Cow<'dom, str>, - parent_style: &ServoArc, + parent_style: ServoArc, ); /// Or pseudo-element fn handle_element( &mut self, node: Node, - style: &ServoArc, + style: ServoArc, display: DisplayGeneratingBox, contents: Contents, box_slot: BoxSlot<'dom>, @@ -89,7 +89,7 @@ fn traverse_children_of<'dom, Node>( for child in iter_child_nodes(parent_element) { if let Some(contents) = child.as_text() { - handler.handle_text(child, contents, &child.style(context)); + handler.handle_text(child, contents, child.style(context)); } else if child.is_element() { traverse_element(child, context, handler); } @@ -122,7 +122,7 @@ fn traverse_element<'dom, Node>( Display::GeneratingBox(display) => { let contents = replaced.map_or(Contents::OfElement, Contents::Replaced); let box_slot = element.element_box_slot(); - handler.handle_element(element, &style, display, contents, box_slot); + handler.handle_element(element, style, display, contents, box_slot); }, } } @@ -148,7 +148,7 @@ fn traverse_pseudo_element<'dom, Node>( let items = generate_pseudo_element_content(&style, element, context); let box_slot = element.pseudo_element_box_slot(which); let contents = Contents::OfPseudoElement(items); - handler.handle_element(element, &style, display, contents, box_slot); + handler.handle_element(element, style, display, contents, box_slot); }, } } else { @@ -169,7 +169,7 @@ fn traverse_pseudo_element_contents<'dom, Node>( for item in items { match item { PseudoElementContentItem::Text(text) => { - handler.handle_text(node, text.into(), pseudo_element_style) + handler.handle_text(node, text.into(), pseudo_element_style.clone()) }, PseudoElementContentItem::Replaced(contents) => { let item_style = anonymous_style.get_or_insert_with(|| { @@ -193,7 +193,7 @@ fn traverse_pseudo_element_contents<'dom, Node>( ); handler.handle_element( node, - item_style, + item_style.clone(), display_inline, Contents::Replaced(contents), // We don’t keep pointers to boxes generated by contents of pseudo-elements diff --git a/components/layout_2020/flexbox.rs b/components/layout_2020/flexbox.rs index 7a7b7414f5d..855f8c68ee5 100644 --- a/components/layout_2020/flexbox.rs +++ b/components/layout_2020/flexbox.rs @@ -80,11 +80,11 @@ where &mut self, node: Node, text: Cow<'dom, str>, - parent_style: &Arc, + parent_style: Arc, ) { self.contiguous_text_runs.push(TextRun { tag: node.as_opaque(), - parent_style: parent_style.clone(), + parent_style, text: text.into(), }) } @@ -93,7 +93,7 @@ where fn handle_element( &mut self, node: Node, - style: &Arc, + style: Arc, display: DisplayGeneratingBox, contents: Contents, box_slot: BoxSlot<'dom>, diff --git a/components/layout_2020/flow/construct.rs b/components/layout_2020/flow/construct.rs index a0f6af39357..f91330f45fb 100644 --- a/components/layout_2020/flow/construct.rs +++ b/components/layout_2020/flow/construct.rs @@ -273,7 +273,7 @@ where fn handle_element( &mut self, node: Node, - style: &Arc, + style: Arc, display: DisplayGeneratingBox, contents: Contents, box_slot: BoxSlot<'dom>, @@ -289,22 +289,12 @@ where // https://drafts.csswg.org/css2/visuren.html#dis-pos-flo if box_style.position.is_absolutely_positioned() { self.handle_absolutely_positioned_element( - node, - style.clone(), - inside, - contents, - box_slot, + node, style, inside, contents, box_slot, ) } else if box_style.float.is_floating() { - self.handle_float_element(node, style.clone(), inside, contents, box_slot) + self.handle_float_element(node, style, inside, contents, box_slot) } else { - self.handle_block_level_element( - node, - style.clone(), - inside, - contents, - box_slot, - ) + self.handle_block_level_element(node, style, inside, contents, box_slot) } }, }, @@ -315,7 +305,7 @@ where &mut self, node: Node, input: Cow<'dom, str>, - parent_style: &Arc, + parent_style: Arc, ) { let (leading_whitespace, mut input) = self.handle_leading_whitespace(&input); if leading_whitespace || !input.is_empty() { @@ -365,7 +355,6 @@ where } if let Some(text) = new_text_run_contents { - let parent_style = parent_style.clone(); inlines.push(ArcRefCell::new(InlineLevelBox::TextRun(TextRun { tag: node.as_opaque(), parent_style, @@ -442,7 +431,7 @@ where fn handle_inline_level_element( &mut self, node: Node, - style: &Arc, + style: Arc, display_inside: DisplayInside, contents: Contents, ) -> ArcRefCell { @@ -473,14 +462,15 @@ where inline_box.last_fragment = true; ArcRefCell::new(InlineLevelBox::InlineBox(inline_box)) } else { + let content_sizes = ContentSizesRequest::inline_if(!style.inline_size_is_length()); ArcRefCell::new(InlineLevelBox::Atomic( IndependentFormattingContext::construct( self.context, node, - style.clone(), + style, display_inside, contents, - ContentSizesRequest::inline_if(!style.inline_size_is_length()), + content_sizes, // Text decorations are not propagated to atomic inline-level descendants. TextDecorationLine::NONE, ),