Bug 1416540 - Convert AnimationValue::GetStyleValue to return a float-based Size. r?mattwoodrow draft
authorKartikaya Gupta <kgupta@mozilla.com>
Sun, 12 Nov 2017 18:37:33 -0500
changeset 696908 0845666302cbf8c4eac3ff2a6987bcb7438364a6
parent 696907 1bc7d3dc967d8b4217caf641ed87f75678ada857
child 739957 727df7362f88398d27734057a2d8adcf45ed3f03
push id88821
push userkgupta@mozilla.com
push dateSun, 12 Nov 2017 23:37:55 +0000
reviewersmattwoodrow
bugs1416540
milestone58.0a1
Bug 1416540 - Convert AnimationValue::GetStyleValue to return a float-based Size. r?mattwoodrow This follows from the previous patch; these values feed into UpdateMinMaxScale as well, which explicitly wants to use floats, so there's no point in creating doubles. The source of this information is also a float-based matrix. MozReview-Commit-ID: LPk4Xm9AaJJ
dom/animation/KeyframeEffectReadOnly.cpp
layout/base/nsLayoutUtils.cpp
layout/style/StyleAnimationValue.cpp
layout/style/StyleAnimationValue.h
layout/style/nsStyleTransformMatrix.cpp
layout/style/nsStyleTransformMatrix.h
--- a/dom/animation/KeyframeEffectReadOnly.cpp
+++ b/dom/animation/KeyframeEffectReadOnly.cpp
@@ -1923,34 +1923,34 @@ KeyframeEffectReadOnly::ContainsAnimated
     }
 
     AnimationValue baseStyle = BaseStyle(prop.mProperty);
     if (baseStyle.IsNull()) {
       // If we failed to get the base style, we consider it has scale value
       // here just to be safe.
       return true;
     }
-    gfxSize size = baseStyle.GetScaleValue(aFrame);
-    if (size != gfxSize(1.0f, 1.0f)) {
+    gfx::Size size = baseStyle.GetScaleValue(aFrame);
+    if (size != gfx::Size(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)) {
+        gfx::Size from = segment.mFromValue.GetScaleValue(aFrame);
+        if (from != gfx::Size(1.0f, 1.0f)) {
           return true;
         }
       }
       if (!segment.mToValue.IsNull()) {
-        gfxSize to = segment.mToValue.GetScaleValue(aFrame);
-        if (to != gfxSize(1.0f, 1.0f)) {
+        gfx::Size to = segment.mToValue.GetScaleValue(aFrame);
+        if (to != gfx::Size(1.0f, 1.0f)) {
           return true;
         }
       }
     }
   }
 
   return false;
 }
--- a/layout/base/nsLayoutUtils.cpp
+++ b/layout/base/nsLayoutUtils.cpp
@@ -541,17 +541,17 @@ GetSuitableScale(float aMaxScale, float 
 }
 
 static inline void
 UpdateMinMaxScale(const nsIFrame* aFrame,
                   const AnimationValue& aValue,
                   Size& aMinScale,
                   Size& aMaxScale)
 {
-  gfxSize size = aValue.GetScaleValue(aFrame);
+  Size size = aValue.GetScaleValue(aFrame);
   aMaxScale.width = std::max<float>(aMaxScale.width, size.width);
   aMaxScale.height = std::max<float>(aMaxScale.height, size.height);
   aMinScale.width = std::min<float>(aMinScale.width, size.width);
   aMinScale.height = std::min<float>(aMinScale.height, size.height);
 }
 
 static void
 GetMinAndMaxScaleForAnimationProperty(const nsIFrame* aFrame,
--- a/layout/style/StyleAnimationValue.cpp
+++ b/layout/style/StyleAnimationValue.cpp
@@ -4886,17 +4886,17 @@ StyleAnimationValue::ExtractComputedValu
       return true;
     }
     case eStyleAnimType_None:
       NS_NOTREACHED("shouldn't use on non-animatable properties");
   }
   return false;
 }
 
-gfxSize
+Size
 StyleAnimationValue::GetScaleValue(const nsIFrame* aForFrame) const
 {
   MOZ_ASSERT(GetUnit() == StyleAnimationValue::eUnit_Transform);
 
   nsCSSValueSharedList* list = GetCSSValueSharedListValue();
   return nsStyleTransformMatrix::GetScaleValue(list, aForFrame);
 }
 
@@ -5356,17 +5356,17 @@ AnimationValue::GetTransformList() const
   if (mServo) {
     Servo_AnimationValue_GetTransform(mServo, &transform);
   } else {
     transform = mGecko.GetCSSValueSharedListValue();
   }
   return transform.forget();
 }
 
-gfxSize
+Size
 AnimationValue::GetScaleValue(const nsIFrame* aFrame) const
 {
   MOZ_ASSERT(!mServo != mGecko.IsNull());
   if (mServo) {
     RefPtr<nsCSSValueSharedList> list;
     Servo_AnimationValue_GetTransform(mServo, &list);
     return nsStyleTransformMatrix::GetScaleValue(list, aFrame);
   }
--- a/layout/style/StyleAnimationValue.h
+++ b/layout/style/StyleAnimationValue.h
@@ -4,18 +4,18 @@
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 /* Utilities for animation of computed style values */
 
 #ifndef mozilla_StyleAnimationValue_h_
 #define mozilla_StyleAnimationValue_h_
 
-#include "gfxPoint.h"
 #include "mozilla/gfx/MatrixFwd.h"
+#include "mozilla/gfx/Point.h"
 #include "mozilla/ServoBindingTypes.h"
 #include "mozilla/UniquePtr.h"
 #include "nsStringFwd.h"
 #include "nsStringBuffer.h"
 #include "nsCoord.h"
 #include "nsColor.h"
 #include "nsCSSProps.h"
 #include "nsCSSValue.h"
@@ -419,17 +419,17 @@ public:
   void GetStringValue(nsAString& aBuffer) const {
     NS_ASSERTION(IsStringUnit(mUnit), "unit mismatch");
     aBuffer.Truncate();
     uint32_t len = NS_strlen(GetBufferValue(mValue.mString));
     mValue.mString->ToString(len, aBuffer);
   }
 
   /// @return the scale for this value, calculated with reference to @aForFrame.
-  gfxSize GetScaleValue(const nsIFrame* aForFrame) const;
+  mozilla::gfx::Size GetScaleValue(const nsIFrame* aForFrame) const;
 
   const css::ComplexColorData& GetComplexColorData() const {
     MOZ_ASSERT(mUnit == eUnit_ComplexColor, "unit mismatch");
     return *mValue.mComplexColor;
   }
   StyleComplexColor GetStyleComplexColorValue() const {
     return GetComplexColorData().ToComplexColor();
   }
@@ -607,17 +607,17 @@ struct AnimationValue
 
   float GetOpacity() const;
 
   // Return the transform list as a RefPtr.
   already_AddRefed<const nsCSSValueSharedList> GetTransformList() const;
 
   // Return the scale for mGecko or mServo, which are calculated with
   // reference to aFrame.
-  gfxSize GetScaleValue(const nsIFrame* aFrame) const;
+  mozilla::gfx::Size GetScaleValue(const nsIFrame* aFrame) const;
 
   // Uncompute this AnimationValue and then serialize it.
   void SerializeSpecifiedValue(nsCSSPropertyID aProperty,
                                nsAString& aString) const;
 
   // Check if |*this| and |aToValue| can be interpolated.
   bool IsInterpolableWith(nsCSSPropertyID aProperty,
                           const AnimationValue& aToValue) const;
--- a/layout/style/nsStyleTransformMatrix.cpp
+++ b/layout/style/nsStyleTransformMatrix.cpp
@@ -1396,17 +1396,17 @@ CSSValueArrayTo3DMatrix(nsCSSValue::Arra
   gfx::Float array[16];
   for (size_t i = 0; i < 16; ++i) {
     array[i] = aArray->Item(i+1).GetFloatValue();
   }
   Matrix4x4 m(array);
   return m;
 }
 
-gfxSize
+Size
 GetScaleValue(const nsCSSValueSharedList* aList,
               const nsIFrame* aForFrame)
 {
   MOZ_ASSERT(aList && aList->mHead);
   MOZ_ASSERT(aForFrame);
 
   RuleNodeCacheConditions dontCare;
   bool dontCareBool;
@@ -1415,15 +1415,15 @@ GetScaleValue(const nsCSSValueSharedList
                           aList->mHead,
                           aForFrame->StyleContext(),
                           aForFrame->PresContext(), dontCare, refBox,
                           aForFrame->PresContext()->AppUnitsPerDevPixel(),
                           &dontCareBool);
   Matrix transform2d;
   bool canDraw2D = transform.CanDraw2D(&transform2d);
   if (!canDraw2D) {
-    return gfxSize();
+    return Size();
   }
 
-  return ThebesMatrix(transform2d).ScaleFactors(true);
+  return transform2d.ScaleFactors(true);
 }
 
 } // namespace nsStyleTransformMatrix
--- a/layout/style/nsStyleTransformMatrix.h
+++ b/layout/style/nsStyleTransformMatrix.h
@@ -244,13 +244,13 @@ namespace nsStyleTransformMatrix {
                          ShearArray& aShear,
                          gfxQuaternion& aRotate,
                          mozilla::gfx::Point3D& aTranslate,
                          mozilla::gfx::Point4D& aPerspective);
 
   mozilla::gfx::Matrix CSSValueArrayTo2DMatrix(nsCSSValue::Array* aArray);
   mozilla::gfx::Matrix4x4 CSSValueArrayTo3DMatrix(nsCSSValue::Array* aArray);
 
-  gfxSize GetScaleValue(const nsCSSValueSharedList* aList,
-                        const nsIFrame* aForFrame);
+  mozilla::gfx::Size GetScaleValue(const nsCSSValueSharedList* aList,
+                                   const nsIFrame* aForFrame);
 } // namespace nsStyleTransformMatrix
 
 #endif