Bug 1289049 Part 2 - Extract a helper function ExtractComputedValueFromShapeSource(). r=boris
authorTing-Yu Lin <tlin@mozilla.com>
Tue, 19 Sep 2017 17:20:14 +0800
changeset 381859 132a940e3e5f3d069cde7f4d04c178f14f43e918
parent 381858 1d5f95ad941eedae37a240fe2a4217b4ea54448c
child 381860 92bb93a96a44b37be998a7a1536e2f8751d528f7
push id32542
push userkwierso@gmail.com
push dateWed, 20 Sep 2017 21:07:55 +0000
treeherdermozilla-central@319a34bea9e4 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersboris
bugs1289049
milestone57.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1289049 Part 2 - Extract a helper function ExtractComputedValueFromShapeSource(). r=boris MozReview-Commit-ID: IhHaKhQTWbo
layout/style/StyleAnimationValue.cpp
--- a/layout/style/StyleAnimationValue.cpp
+++ b/layout/style/StyleAnimationValue.cpp
@@ -4235,16 +4235,45 @@ StyleShapeSourceToCSSArray(const StyleSh
     default:
       MOZ_ASSERT_UNREACHABLE("Unknown shape type");
       return false;
   }
   aResult->Item(1).SetEnumValue(aShapeSource.GetReferenceBox());
   return true;
 }
 
+static bool
+ExtractComputedValueFromShapeSource(const StyleShapeSource& aShapeSource,
+                                    StyleAnimationValue& aComputedValue)
+{
+  const StyleShapeSourceType type = aShapeSource.GetType();
+
+  if (type == StyleShapeSourceType::URL) {
+    auto result = MakeUnique<nsCSSValue>();
+    result->SetURLValue(aShapeSource.GetURL());
+    aComputedValue.SetAndAdoptCSSValueValue(result.release(),
+                                            StyleAnimationValue::eUnit_URL);
+  } else if (type == StyleShapeSourceType::Box) {
+    aComputedValue.SetEnumValue(aShapeSource.GetReferenceBox());
+  } else if (type == StyleShapeSourceType::Shape) {
+    RefPtr<nsCSSValue::Array> result = nsCSSValue::Array::Create(2);
+    if (!StyleShapeSourceToCSSArray(aShapeSource, result)) {
+      return false;
+    }
+    aComputedValue.SetCSSValueArrayValue(result,
+                                         StyleAnimationValue::eUnit_Shape);
+
+  } else {
+    MOZ_ASSERT(type == StyleShapeSourceType::None, "unknown type");
+    aComputedValue.SetNoneValue();
+  }
+
+  return true;
+}
+
 static void
 SetFallbackValue(nsCSSValuePair* aPair, const nsStyleSVGPaint& aPaint)
 {
   if (aPaint.GetFallbackType() == eStyleSVGFallbackType_Color) {
     aPair->mYValue.SetColorValue(aPaint.GetFallbackColor());
   } else {
     aPair->mYValue.SetNoneValue();
   }
@@ -4544,35 +4573,19 @@ StyleAnimationValue::ExtractComputedValu
           ExtractImageLayerSizePairList(layers, aComputedValue);
           break;
         }
 #endif
 
         case eCSSProperty_clip_path: {
           const nsStyleSVGReset* svgReset =
             static_cast<const nsStyleSVGReset*>(styleStruct);
-          const StyleShapeSource& clipPath = svgReset->mClipPath;
-          const StyleShapeSourceType type = clipPath.GetType();
-
-          if (type == StyleShapeSourceType::URL) {
-            auto result = MakeUnique<nsCSSValue>();
-            result->SetURLValue(clipPath.GetURL());
-            aComputedValue.SetAndAdoptCSSValueValue(result.release(), eUnit_URL);
-          } else if (type == StyleShapeSourceType::Box) {
-            aComputedValue.SetEnumValue(clipPath.GetReferenceBox());
-          } else if (type == StyleShapeSourceType::Shape) {
-            RefPtr<nsCSSValue::Array> result = nsCSSValue::Array::Create(2);
-            if (!StyleShapeSourceToCSSArray(clipPath, result)) {
-              return false;
-            }
-            aComputedValue.SetCSSValueArrayValue(result, eUnit_Shape);
-
-          } else {
-            MOZ_ASSERT(type == StyleShapeSourceType::None, "unknown type");
-            aComputedValue.SetNoneValue();
+          if (!ExtractComputedValueFromShapeSource(svgReset->mClipPath,
+                                                   aComputedValue)) {
+            return false;
           }
           break;
         }
 
         case eCSSProperty_filter: {
           const nsStyleEffects* effects =
             static_cast<const nsStyleEffects*>(styleStruct);
           const nsTArray<nsStyleFilter>& filters = effects->mFilters;