Bug 1379203 - Don't cache style data if the element has running animations. r?bholley,birtles
MozReview-Commit-ID: JtJ754CQZuw
--- 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;
}