From dde46c5c90b1a1e0dcc68205957f0adc72785d87 Mon Sep 17 00:00:00 2001 From: Hiroyuki Ikezoe Date: Fri, 24 Mar 2017 09:55:36 +0900 Subject: [PATCH] Make cascade_internal() reusable with rule nodes. A new function, cascade_with_rules, takes StrongRuleNode and computes cascading result values with the StrongRuleNode. This new function will be used for getting after-change-style for CSS Transitions. --- components/style/matching.rs | 42 ++++++++++++++++++++++-------------- 1 file changed, 26 insertions(+), 16 deletions(-) diff --git a/components/style/matching.rs b/components/style/matching.rs index 2cd06236473..934072f2935 100644 --- a/components/style/matching.rs +++ b/components/style/matching.rs @@ -469,24 +469,15 @@ trait PrivateMatchMethods: TElement { } } - fn cascade_internal(&self, - context: &StyleContext, - primary_style: &ComputedStyle, - pseudo_style: &Option<(&PseudoElement, &mut ComputedStyle)>, - booleans: &CascadeBooleans) - -> Arc { + fn cascade_with_rules(&self, + context: &StyleContext, + rule_node: &StrongRuleNode, + primary_style: &ComputedStyle, + pseudo_style: &Option<(&PseudoElement, &mut ComputedStyle)>, + cascade_flags: CascadeFlags) + -> Arc { let shared_context = context.shared; let mut cascade_info = CascadeInfo::new(); - let mut cascade_flags = CascadeFlags::empty(); - if booleans.shareable { - cascade_flags.insert(SHAREABLE) - } - if self.skip_root_and_item_based_display_fixup() { - cascade_flags.insert(SKIP_ROOT_AND_ITEM_BASED_DISPLAY_FIXUP) - } - - // Grab the rule node. - let rule_node = &pseudo_style.as_ref().map_or(primary_style, |p| &*p.1).rules; // Grab the inherited values. let parent_el; @@ -552,6 +543,25 @@ trait PrivateMatchMethods: TElement { values } + fn cascade_internal(&self, + context: &StyleContext, + primary_style: &ComputedStyle, + pseudo_style: &Option<(&PseudoElement, &mut ComputedStyle)>, + booleans: &CascadeBooleans) + -> Arc { + let mut cascade_flags = CascadeFlags::empty(); + if booleans.shareable { + cascade_flags.insert(SHAREABLE) + } + if self.skip_root_and_item_based_display_fixup() { + cascade_flags.insert(SKIP_ROOT_AND_ITEM_BASED_DISPLAY_FIXUP) + } + + // Grab the rule node. + let rule_node = &pseudo_style.as_ref().map_or(primary_style, |p| &*p.1).rules; + self.cascade_with_rules(context, rule_node, primary_style, pseudo_style, cascade_flags) + } + /// Computes values and damage for the primary or pseudo style of an element, /// setting them on the ElementData. fn cascade_primary_or_pseudo<'a>(&self,