Bug 1289049 Part 2 - Extract a helper function ExtractComputedValueFromShapeSource().
MozReview-Commit-ID: IhHaKhQTWbo
--- 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;