Bug 1367225 - Don't process style attribute changes in animation-only restyle. r?birtles draft
authorHiroyuki Ikezoe <hikezoe@mozilla.com>
Wed, 24 May 2017 13:45:32 +0900
changeset 583501 f6176095a39f603984f9823c361ddf866de65ec1
parent 583500 09d9d0bd21bcf0fab951038c75115b07f8d12448
child 630075 d8fecbb01ae0f09b7a5eb3ac758234e42c1d53ab
push id60412
push userhikezoe@mozilla.com
push dateWed, 24 May 2017 04:47:52 +0000
reviewersbirtles
bugs1367225
milestone55.0a1
Bug 1367225 - Don't process style attribute changes in animation-only restyle. r?birtles MozReview-Commit-ID: DcBewFSVBxg
servo/components/style/matching.rs
--- a/servo/components/style/matching.rs
+++ b/servo/components/style/matching.rs
@@ -969,32 +969,45 @@ pub trait MatchMethods : TElement {
                      context: &StyleContext<Self>,
                      data: &mut ElementData)
                      -> bool {
         use properties::PropertyDeclarationBlock;
         use shared_lock::Locked;
 
         let element_styles = &mut data.styles_mut();
         let primary_rules = &mut element_styles.primary.rules;
-        let mut result = false;
 
         let replace_rule_node = |level: CascadeLevel,
                                  pdb: Option<&Arc<Locked<PropertyDeclarationBlock>>>,
                                  path: &mut StrongRuleNode| -> bool {
             let new_node = context.shared.stylist.rule_tree()
                 .update_rule_at_level(level, pdb, path, &context.shared.guards);
             match new_node {
                 Some(n) => {
                     *path = n;
                     level.is_important()
                 },
                 None => false,
             }
         };
 
+        if !context.shared.traversal_flags.for_animation_only() {
+            let mut result = false;
+            if replacements.contains(RESTYLE_STYLE_ATTRIBUTE) {
+                let style_attribute = self.style_attribute();
+                result |= replace_rule_node(CascadeLevel::StyleAttributeNormal,
+                                            style_attribute,
+                                            primary_rules);
+                result |= replace_rule_node(CascadeLevel::StyleAttributeImportant,
+                                            style_attribute,
+                                            primary_rules);
+            }
+            return result;
+        }
+
         // Animation restyle hints are processed prior to other restyle
         // hints in the animation-only traversal.
         //
         // Non-animation restyle hints will be processed in a subsequent
         // normal traversal.
         if replacements.intersects(RestyleReplacements::for_animations()) {
             debug_assert!(context.shared.traversal_flags.for_animation_only());
 
@@ -1018,27 +1031,19 @@ pub trait MatchMethods : TElement {
                 replace_rule_node_for_animation(CascadeLevel::Transitions,
                                                 primary_rules);
             }
 
             if replacements.contains(RESTYLE_CSS_ANIMATIONS) {
                 replace_rule_node_for_animation(CascadeLevel::Animations,
                                                 primary_rules);
             }
-        } else if replacements.contains(RESTYLE_STYLE_ATTRIBUTE) {
-            let style_attribute = self.style_attribute();
-            result |= replace_rule_node(CascadeLevel::StyleAttributeNormal,
-                                        style_attribute,
-                                        primary_rules);
-            result |= replace_rule_node(CascadeLevel::StyleAttributeImportant,
-                                        style_attribute,
-                                        primary_rules);
         }
 
-        result
+        false
     }
 
     /// Attempts to share a style with another node. This method is unsafe
     /// because it depends on the `style_sharing_candidate_cache` having only
     /// live nodes in it, and we have no way to guarantee that at the type
     /// system level yet.
     unsafe fn share_style_if_possible(&self,
                                       context: &mut StyleContext<Self>,