Bug 1333846 - Part 2: Evaluate scale values for additive or accumulative animations. r=birtles a=gchang
authorHiroyuki Ikezoe <hikezoe@mozilla.com>
Thu, 09 Feb 2017 11:28:47 +0900
changeset 376077 a6a8ca19a0112bd6e4ab098e48ffc64a6c5a7229
parent 376076 e77ccea909001c46cb84cd7fd0e5809343e8bc83
child 376078 71d115ba551cc5ae7a7fe77a178e30a9f4606468
push id6996
push userjlorenzo@mozilla.com
push dateMon, 06 Mar 2017 20:48:21 +0000
treeherdermozilla-beta@d89512dab048 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbirtles, gchang
bugs1333846
milestone53.0a2
Bug 1333846 - Part 2: Evaluate scale values for additive or accumulative animations. r=birtles a=gchang MozReview-Commit-ID: LSKJNH5OJbs
dom/animation/KeyframeEffectReadOnly.cpp
--- a/dom/animation/KeyframeEffectReadOnly.cpp
+++ b/dom/animation/KeyframeEffectReadOnly.cpp
@@ -1704,24 +1704,46 @@ KeyframeEffectReadOnly::ContainsAnimated
     return false;
   }
 
   for (const AnimationProperty& prop : mProperties) {
     if (prop.mProperty != eCSSProperty_transform) {
       continue;
     }
 
-    for (const AnimationPropertySegment& segment : prop.mSegments) {
-      gfxSize from = segment.mFromValue.GetScaleValue(aFrame);
-      if (from != gfxSize(1.0f, 1.0f)) {
+    if (NeedsBaseStyle(prop.mProperty)) {
+      StyleAnimationValue baseStyle =
+        EffectCompositor::GetBaseStyle(prop.mProperty, aFrame);
+      MOZ_ASSERT(!baseStyle.IsNull(), "The base value should be set");
+      if (baseStyle.IsNull()) {
+        // If we failed to get the base style, we consider it has scale value
+        // here for the safety.
+        return true;
+      }
+      gfxSize size = baseStyle.GetScaleValue(aFrame);
+      if (size != gfxSize(1.0f, 1.0f)) {
         return true;
       }
-      gfxSize to = segment.mToValue.GetScaleValue(aFrame);
-      if (to != gfxSize(1.0f, 1.0f)) {
-        return true;
+    }
+
+    // This is actually overestimate because there are some cases that combining
+    // the base value and from/to value produces 1:1 scale. But it doesn't
+    // really matter.
+    for (const AnimationPropertySegment& segment : prop.mSegments) {
+      if (!segment.mFromValue.IsNull()) {
+        gfxSize from = segment.mFromValue.GetScaleValue(aFrame);
+        if (from != gfxSize(1.0f, 1.0f)) {
+          return true;
+        }
+      }
+      if (!segment.mToValue.IsNull()) {
+        gfxSize to = segment.mToValue.GetScaleValue(aFrame);
+        if (to != gfxSize(1.0f, 1.0f)) {
+          return true;
+        }
       }
     }
   }
 
   return false;
 }
 
 } // namespace dom