Bug 1346663 - Make cascade_internal() reusable with rule nodes. r?emilio
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.
MozReview-Commit-ID: GiwsuyIZ4TJ
--- a/servo/components/style/matching.rs
+++ b/servo/components/style/matching.rs
@@ -464,34 +464,25 @@ trait PrivateMatchMethods: TElement {
current.borrow_data().unwrap().styles().primary.values().is_display_contents();
if !is_display_contents {
return current;
}
}
}
- fn cascade_internal(&self,
- context: &StyleContext<Self>,
- primary_style: &ComputedStyle,
- pseudo_style: &Option<(&PseudoElement, &mut ComputedStyle)>,
- booleans: &CascadeBooleans)
- -> Arc<ComputedValues> {
+ fn cascade_with_rules(&self,
+ context: &StyleContext<Self>,
+ rule_node: &StrongRuleNode,
+ primary_style: &ComputedStyle,
+ pseudo_style: &Option<(&PseudoElement, &mut ComputedStyle)>,
+ cascade_flags: CascadeFlags)
+ -> Arc<ComputedValues> {
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;
let parent_data;
let inherited_values_ = if pseudo_style.is_none() {
parent_el = self.parent_element();
parent_data = parent_el.as_ref().and_then(|e| e.borrow_data());
let parent_values = parent_data.as_ref().map(|d| {
@@ -547,16 +538,35 @@ trait PrivateMatchMethods: TElement {
Some(&mut cascade_info),
&*shared_context.error_reporter,
cascade_flags));
cascade_info.finish(&self.as_node());
values
}
+ fn cascade_internal(&self,
+ context: &StyleContext<Self>,
+ primary_style: &ComputedStyle,
+ pseudo_style: &Option<(&PseudoElement, &mut ComputedStyle)>,
+ booleans: &CascadeBooleans)
+ -> Arc<ComputedValues> {
+ 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,
context: &mut StyleContext<Self>,
data: &mut ElementData,
pseudo: Option<&PseudoElement>,
possibly_expired_animations: &mut Vec<PropertyAnimation>,
booleans: CascadeBooleans) {