Bug 1379203 - Don't cache style data if the element has running animations. r?bholley,birtles draft
authorHiroyuki Ikezoe <hikezoe@mozilla.com>
Wed, 23 Aug 2017 07:44:18 +0900
changeset 650833 a84ac67013d14a91f50b2ed8666632bce514c450
parent 650832 fa99ada38d28fbe9a9d2535d7353b6c8fc067273
child 727504 be0ea907d2e856982fb3aa84383f79ee803c1b30
push id75504
push userhikezoe@mozilla.com
push dateTue, 22 Aug 2017 22:52:40 +0000
reviewersbholley, birtles
bugs1379203
milestone57.0a1
Bug 1379203 - Don't cache style data if the element has running animations. r?bholley,birtles MozReview-Commit-ID: JtJ754CQZuw
servo/components/style/sharing/mod.rs
--- a/servo/components/style/sharing/mod.rs
+++ b/servo/components/style/sharing/mod.rs
@@ -504,16 +504,34 @@ impl<E: TElement> StyleSharingCandidateC
             }
         };
 
         if element.is_native_anonymous() {
             debug!("Failing to insert into the cache: NAC");
             return;
         }
 
+        // If the element has any kind of running animations, we don't cache
+        // the style since it can be manipulate its state by script (i.e. Web
+        // Animations APIs) without changing its styles. To check all the state
+        // is not pragmatic.
+        // Also this check needs for CSS animations/transitions since even if
+        // there is no specified style for CSS animations/transitions at this
+        // moment, there might be still animating style values since it might
+        // be just about to remove them in sequential tasks which will be run
+        // right after this traversal.
+        if element.has_animations() {
+            debug!("Failing to insert to the cache: running animations");
+            return;
+        }
+
+        // In addition to the above running animations check, we also need to
+        // check CSS animation and transition styles since it's possible that
+        // we are about to create CSS animations/transitions.
+        //
         // These are things we don't check in the candidate match because they
         // are either uncommon or expensive.
         let box_style = style.get_box();
         if box_style.specifies_transitions() {
             debug!("Failing to insert to the cache: transitions");
             return;
         }