--- a/layout/style/StyleAnimationValue.cpp
+++ b/layout/style/StyleAnimationValue.cpp
@@ -1290,17 +1290,18 @@ AppendToCSSValueList(UniquePtr<nsCSSValu
*aTail = aHead.get();
} else {
(*aTail) = (*aTail)->mNext = aValueToAppend.release();
}
}
static UniquePtr<nsCSSValueList>
AddWeightedShadowItems(double aCoeff1, const nsCSSValue &aValue1,
- double aCoeff2, const nsCSSValue &aValue2)
+ double aCoeff2, const nsCSSValue &aValue2,
+ ColorAdditionType aColorAdditionType)
{
// X, Y, Radius, Spread, Color, Inset
MOZ_ASSERT(aValue1.GetUnit() == eCSSUnit_Array,
"wrong unit");
MOZ_ASSERT(aValue2.GetUnit() == eCSSUnit_Array,
"wrong unit");
nsCSSValue::Array *array1 = aValue1.GetArrayValue();
nsCSSValue::Array *array2 = aValue2.GetArrayValue();
@@ -1327,17 +1328,17 @@ AddWeightedShadowItems(double aCoeff1, c
return nullptr;
}
if (color1.GetUnit() != eCSSUnit_Null) {
if (aCoeff2 == 0.0 && aCoeff1 != 1.0) {
DiluteColor(color1, aCoeff1, resultArray->Item(4));
} else {
AddWeightedColors(aCoeff1, color1, aCoeff2, color2,
- ColorAdditionType::Clamped,
+ aColorAdditionType,
resultArray->Item(4));
}
}
MOZ_ASSERT(inset1 == inset2, "should match");
resultArray->Item(5) = inset1;
auto resultItem = MakeUnique<nsCSSValueList>();
@@ -1870,18 +1871,21 @@ AddFilterFunctionImpl(double aCoeff1, co
aCoeff2, funcArg2,
resultArg);
break;
case eCSSKeyword_drop_shadow: {
MOZ_ASSERT(!funcArg1.GetListValue()->mNext &&
!funcArg2.GetListValue()->mNext,
"drop-shadow filter func doesn't support lists");
UniquePtr<nsCSSValueList> shadowValue =
- AddWeightedShadowItems(aCoeff1, funcArg1.GetListValue()->mValue,
- aCoeff2, funcArg2.GetListValue()->mValue);
+ AddWeightedShadowItems(aCoeff1,
+ funcArg1.GetListValue()->mValue,
+ aCoeff2,
+ funcArg2.GetListValue()->mValue,
+ ColorAdditionType::Clamped);
if (!shadowValue) {
return false;
}
resultArg.AdoptListValue(Move(shadowValue));
break;
}
default:
MOZ_ASSERT(false, "unknown filter function");
@@ -2367,29 +2371,33 @@ AddPositionCoords(double aCoeff1, const
const nsCSSValue& v1 = posArray1->Item(1);
const nsCSSValue& v2 = posArray2->Item(1);
nsCSSValue& vr = resultPosArray->Item(1);
AddCSSValueCanonicalCalc(aCoeff1, v1,
aCoeff2, v2, vr);
}
static UniquePtr<nsCSSValueList>
-AddWeightedShadowList(double aCoeff1, const nsCSSValueList* aShadow1,
- double aCoeff2, const nsCSSValueList* aShadow2)
+AddWeightedShadowList(double aCoeff1,
+ const nsCSSValueList* aShadow1,
+ double aCoeff2,
+ const nsCSSValueList* aShadow2,
+ ColorAdditionType aColorAdditionType)
{
// This is implemented according to:
// http://dev.w3.org/csswg/css3-transitions/#animation-of-property-types-
// and the third item in the summary of:
// http://lists.w3.org/Archives/Public/www-style/2009Jul/0050.html
UniquePtr<nsCSSValueList> result;
nsCSSValueList* tail = nullptr;
while (aShadow1 && aShadow2) {
UniquePtr<nsCSSValueList> shadowValue =
AddWeightedShadowItems(aCoeff1, aShadow1->mValue,
- aCoeff2, aShadow2->mValue);
+ aCoeff2, aShadow2->mValue,
+ aColorAdditionType);
if (!shadowValue) {
return nullptr;
}
aShadow1 = aShadow1->mNext;
aShadow2 = aShadow2->mNext;
AppendToCSSValueList(result, Move(shadowValue), &tail);
}
if (aShadow1 || aShadow2) {
@@ -2404,17 +2412,18 @@ AddWeightedShadowList(double aCoeff1, co
}
while (longShadow) {
// Passing coefficients that add to less than 1 produces the
// desired result of interpolating "0 0 0 transparent" with
// the current shadow.
UniquePtr<nsCSSValueList> shadowValue =
AddWeightedShadowItems(longCoeff, longShadow->mValue,
- 0.0, longShadow->mValue);
+ 0.0, longShadow->mValue,
+ aColorAdditionType);
if (!shadowValue) {
return nullptr;
}
longShadow = longShadow->mNext;
AppendToCSSValueList(result, Move(shadowValue), &tail);
}
}
@@ -2715,18 +2724,21 @@ StyleAnimationValue::AddWeighted(nsCSSPr
}
aResultValue.SetAndAdoptCSSValueListValue(result.forget(),
eUnit_Dasharray);
return true;
}
case eUnit_Shadow: {
UniquePtr<nsCSSValueList> result =
- AddWeightedShadowList(aCoeff1, aValue1.GetCSSValueListValue(),
- aCoeff2, aValue2.GetCSSValueListValue());
+ AddWeightedShadowList(aCoeff1,
+ aValue1.GetCSSValueListValue(),
+ aCoeff2,
+ aValue2.GetCSSValueListValue(),
+ ColorAdditionType::Clamped);
if (!result) {
return false;
}
aResultValue.SetAndAdoptCSSValueListValue(result.release(), eUnit_Shadow);
return true;
}
case eUnit_Shape: {
RefPtr<nsCSSValue::Array> result =
@@ -2886,18 +2898,28 @@ StyleAnimationValue::Accumulate(nsCSSPro
StyleAnimationValue& aDest,
const StyleAnimationValue& aValueToAccumulate,
uint64_t aCount)
{
Unit commonUnit =
GetCommonUnit(aProperty, aDest.GetUnit(), aValueToAccumulate.GetUnit());
switch (commonUnit) {
// FIXME: implement them!
- //case eUnit_Shadow:
//case eUnit_Filter:
+ case eUnit_Shadow: {
+ UniquePtr<nsCSSValueList> result =
+ AddWeightedShadowList(1.0, aDest.GetCSSValueListValue(),
+ aCount, aValueToAccumulate.GetCSSValueListValue(),
+ ColorAdditionType::Unclamped);
+ if (!result) {
+ return false;
+ }
+ aDest.SetAndAdoptCSSValueListValue(result.release(), eUnit_Shadow);
+ return true;
+ }
case eUnit_Color: {
auto resultColor = MakeUnique<nsCSSValue>();
AddWeightedColors(1.0,
*aDest.GetCSSValueValue(),
aCount,
*aValueToAccumulate.GetCSSValueValue(),
ColorAdditionType::Unclamped,
*resultColor);