From a9f75b7c4f738987dc8129896196b05fdf9c072a Mon Sep 17 00:00:00 2001 From: Ms2ger Date: Thu, 15 Oct 2015 10:38:59 +0200 Subject: [PATCH] Define share_style_with_candidate_if_possible on LayoutElement. --- components/layout/css/matching.rs | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/components/layout/css/matching.rs b/components/layout/css/matching.rs index 9fc903a4f29..ddb6cbe06ab 100644 --- a/components/layout/css/matching.rs +++ b/components/layout/css/matching.rs @@ -420,7 +420,9 @@ trait PrivateMatchMethods { shareable: bool, animate_properties: bool) -> RestyleDamage; +} +trait PrivateElementMatchMethods { fn share_style_with_candidate_if_possible(&self, parent_node: Option, candidate: &StyleSharingCandidate) @@ -504,13 +506,13 @@ impl<'ln> PrivateMatchMethods for LayoutNode<'ln> { *style = Some(this_style); damage } +} +impl<'ln> PrivateElementMatchMethods for LayoutElement<'ln> { fn share_style_with_candidate_if_possible(&self, parent_node: Option, candidate: &StyleSharingCandidate) -> Option> { - let element = self.as_element().unwrap(); - let parent_node = match parent_node { Some(ref parent_node) if parent_node.as_element().is_some() => parent_node, Some(_) | None => return None, @@ -528,7 +530,7 @@ impl<'ln> PrivateMatchMethods for LayoutNode<'ln> { } // Check tag names, classes, etc. - if !candidate.can_share_style_with(&element) { + if !candidate.can_share_style_with(self) { return None } @@ -594,7 +596,7 @@ impl<'ln> MatchMethods for LayoutNode<'ln> { } for (i, &(ref candidate, ())) in style_sharing_candidate_cache.iter().enumerate() { - match self.share_style_with_candidate_if_possible(parent.clone(), candidate) { + match element.share_style_with_candidate_if_possible(parent.clone(), candidate) { Some(shared_style) => { // Yay, cache hit. Share the style. let mut layout_data_ref = self.mutate_layout_data();