From 5bcc4192bf2c0723444ee62b8fbbbc2084d53175 Mon Sep 17 00:00:00 2001 From: Bobby Holley Date: Thu, 29 Sep 2016 17:59:02 -0700 Subject: [PATCH] Stop using Ref::map for selected_style and resolved_style. Same concept as the previous patch. MozReview-Commit-ID: RFC8s7qQPM --- components/layout/construct.rs | 20 ++++++------- components/layout/flow.rs | 6 ++-- components/layout/fragment.rs | 2 +- .../script_layout_interface/wrapper_traits.rs | 30 +++++++++---------- 4 files changed, 28 insertions(+), 30 deletions(-) diff --git a/components/layout/construct.rs b/components/layout/construct.rs index ed9283dcae9..225456956df 100644 --- a/components/layout/construct.rs +++ b/components/layout/construct.rs @@ -219,7 +219,7 @@ impl InlineFragmentsAccumulator { address: node.opaque(), pseudo: node.get_pseudo_element_type().strip(), style: node.style(style_context), - selected_style: node.selected_style(style_context).clone(), + selected_style: node.selected_style(style_context), flags: InlineFragmentNodeFlags::empty(), }), bidi_control_chars: None, @@ -360,7 +360,7 @@ impl<'a, ConcreteThreadSafeLayoutNode: ThreadSafeLayoutNode> let fragment = Fragment::from_opaque_node_and_style(child_node.opaque(), PseudoElementType::Normal, style, - child_node.selected_style(style_context).clone(), + child_node.selected_style(style_context), child_node.restyle_damage(), SpecificFragmentInfo::TableRow); let mut new_child: FlowRef = Arc::new(TableRowFlow::from_fragment(fragment)); @@ -374,7 +374,7 @@ impl<'a, ConcreteThreadSafeLayoutNode: ThreadSafeLayoutNode> let fragment = Fragment::from_opaque_node_and_style(child_node.opaque(), PseudoElementType::Normal, style, - child_node.selected_style(style_context).clone(), + child_node.selected_style(style_context), child_node.restyle_damage(), SpecificFragmentInfo::Table); let mut new_child: FlowRef = Arc::new(TableFlow::from_fragment(fragment)); @@ -389,7 +389,7 @@ impl<'a, ConcreteThreadSafeLayoutNode: ThreadSafeLayoutNode> Fragment::from_opaque_node_and_style(child_node.opaque(), PseudoElementType::Normal, style, - child_node.selected_style(style_context).clone(), + child_node.selected_style(style_context), child_node.restyle_damage(), SpecificFragmentInfo::TableWrapper); let mut new_child: FlowRef = Arc::new(TableWrapperFlow::from_fragment(fragment, None)); @@ -589,7 +589,7 @@ impl<'a, ConcreteThreadSafeLayoutNode: ThreadSafeLayoutNode> let fragment = Fragment::from_opaque_node_and_style(whitespace_node, whitespace_pseudo, whitespace_style, - node.selected_style(style_context).clone(), + node.selected_style(style_context), whitespace_damage, fragment_info); inline_fragment_accumulator.fragments.fragments.push_back(fragment); @@ -732,7 +732,7 @@ impl<'a, ConcreteThreadSafeLayoutNode: ThreadSafeLayoutNode> node.opaque(), node.get_pseudo_element_type().strip(), style, - selected_style.clone(), + selected_style, node.restyle_damage(), specific_fragment_info)) } @@ -882,7 +882,7 @@ impl<'a, ConcreteThreadSafeLayoutNode: ThreadSafeLayoutNode> Fragment::from_opaque_node_and_style(whitespace_node, whitespace_pseudo, whitespace_style, - node.selected_style(self.style_context()).clone(), + node.selected_style(self.style_context()), whitespace_damage, fragment_info); fragment_accumulator.fragments.fragments.push_back(fragment) @@ -905,7 +905,7 @@ impl<'a, ConcreteThreadSafeLayoutNode: ThreadSafeLayoutNode> let fragment = Fragment::from_opaque_node_and_style(node.opaque(), node.get_pseudo_element_type().strip(), modified_style, - node.selected_style(self.style_context()).clone(), + node.selected_style(self.style_context()), node.restyle_damage(), info); fragment_accumulator.fragments.fragments.push_back(fragment) @@ -1000,7 +1000,7 @@ impl<'a, ConcreteThreadSafeLayoutNode: ThreadSafeLayoutNode> let fragment = Fragment::from_opaque_node_and_style(node.opaque(), node.get_pseudo_element_type().strip(), modified_style, - node.selected_style(style_context).clone(), + node.selected_style(style_context), node.restyle_damage(), fragment_info); @@ -1035,7 +1035,7 @@ impl<'a, ConcreteThreadSafeLayoutNode: ThreadSafeLayoutNode> let fragment = Fragment::from_opaque_node_and_style(node.opaque(), PseudoElementType::Normal, style, - node.selected_style(style_context).clone(), + node.selected_style(style_context), node.restyle_damage(), fragment_info); diff --git a/components/layout/flow.rs b/components/layout/flow.rs index 06aa7cf6329..f206e9fc5a8 100644 --- a/components/layout/flow.rs +++ b/components/layout/flow.rs @@ -1282,7 +1282,7 @@ impl<'a> ImmutableFlowUtils for &'a Flow { node.opaque(), PseudoElementType::Normal, style, - node.selected_style(style_context).clone(), + node.selected_style(style_context), node.restyle_damage(), SpecificFragmentInfo::TableRow); Arc::new(TableRowFlow::from_fragment(fragment)) @@ -1295,7 +1295,7 @@ impl<'a> ImmutableFlowUtils for &'a Flow { node.opaque(), PseudoElementType::Normal, style, - node.selected_style(style_context).clone(), + node.selected_style(style_context), node.restyle_damage(), SpecificFragmentInfo::TableCell); let hide = node.style(style_context).get_inheritedtable().empty_cells == empty_cells::T::hide; @@ -1309,7 +1309,7 @@ impl<'a> ImmutableFlowUtils for &'a Flow { Fragment::from_opaque_node_and_style(node.opaque(), PseudoElementType::Normal, style, - node.selected_style(style_context).clone(), + node.selected_style(style_context), node.restyle_damage(), SpecificFragmentInfo::Generic); Arc::new(BlockFlow::from_fragment(fragment, None)) diff --git a/components/layout/fragment.rs b/components/layout/fragment.rs index faac72c26e6..9bd69518d98 100644 --- a/components/layout/fragment.rs +++ b/components/layout/fragment.rs @@ -865,7 +865,7 @@ impl Fragment { Fragment { node: node.opaque(), style: style, - selected_style: node.selected_style(style_context).clone(), + selected_style: node.selected_style(style_context), restyle_damage: restyle_damage, border_box: LogicalRect::zero(writing_mode), border_padding: LogicalMargin::zero(writing_mode), diff --git a/components/script_layout_interface/wrapper_traits.rs b/components/script_layout_interface/wrapper_traits.rs index 9becba2ddfe..bd0f2068271 100644 --- a/components/script_layout_interface/wrapper_traits.rs +++ b/components/script_layout_interface/wrapper_traits.rs @@ -18,7 +18,7 @@ use style::context::SharedStyleContext; use style::dom::{LayoutIterator, NodeInfo, PresentationalHintsSynthetizer, TNode}; use style::dom::OpaqueNode; use style::properties::ServoComputedValues; -use style::refcell::{Ref, RefCell}; +use style::refcell::RefCell; use style::selector_impl::{PseudoElement, PseudoElementCascadeType, ServoSelectorImpl}; use url::Url; @@ -303,24 +303,22 @@ pub trait ThreadSafeLayoutNode: Clone + Copy + NodeInfo + PartialEq + Sized { /// This should be used just for querying layout, or when we know the /// element style is precomputed, not from general layout itself. #[inline] - fn resolved_style(&self) -> Ref> { - Ref::map(self.get_style_data().unwrap().borrow(), |data| { - match self.get_pseudo_element_type() { - PseudoElementType::Normal - => data.style_data.style.as_ref().unwrap(), - other - => data.style_data.per_pseudo.get(&other.style_pseudo_element()).unwrap(), - } - }) + fn resolved_style(&self) -> Arc { + let data = self.get_style_data().unwrap().borrow(); + match self.get_pseudo_element_type() { + PseudoElementType::Normal + => data.style_data.style.as_ref().unwrap().clone(), + other + => data.style_data.per_pseudo.get(&other.style_pseudo_element()).unwrap().clone(), + } } #[inline] - fn selected_style(&self, _context: &SharedStyleContext) -> Ref> { - Ref::map(self.get_style_data().unwrap().borrow(), |data| { - data.style_data.per_pseudo - .get(&PseudoElement::Selection) - .unwrap_or(data.style_data.style.as_ref().unwrap()) - }) + fn selected_style(&self, _context: &SharedStyleContext) -> Arc { + let data = self.get_style_data().unwrap().borrow(); + data.style_data.per_pseudo + .get(&PseudoElement::Selection) + .unwrap_or(data.style_data.style.as_ref().unwrap()).clone() } /// Removes the style from this node.