Bug 1216843 - Part 5: Reuse AddWeightedColors and DiluteColor in AddShadowItems(). r?dholbert draft
authorHiroyuki Ikezoe <hiikezoe@mozilla-japan.org>
Mon, 12 Sep 2016 07:05:03 +0900
changeset 412499 e57fc4ccec639d95d06aec1038b23c2c0d6f2674
parent 412498 1d0e0187a91e7d48af506b205c9b0a2bd0d0fc3b
child 412500 1234e3ed7de00fe4de7cc67e9980e033752d4fcf
child 412510 b90c310d82775882461e77ec6346c9564eff4e6a
child 412520 d316777c993b4764c7549739d9b3ec7243473211
push id29190
push userbmo:hiikezoe@mozilla-japan.org
push dateMon, 12 Sep 2016 05:22:33 +0000
reviewersdholbert
bugs1216843
milestone51.0a1
Bug 1216843 - Part 5: Reuse AddWeightedColors and DiluteColor in AddShadowItems(). r?dholbert Now we can modify AddWeightedColors to use for accumulation. MozReview-Commit-ID: JQb2fhhDj7g
layout/style/StyleAnimationValue.cpp
--- a/layout/style/StyleAnimationValue.cpp
+++ b/layout/style/StyleAnimationValue.cpp
@@ -1264,29 +1264,21 @@ AddShadowItems(double aCoeff1, const nsC
   if (color1.GetUnit() != color2.GetUnit() ||
       inset1.GetUnit() != inset2.GetUnit()) {
     // We don't know how to animate between color and no-color, or
     // between inset and not-inset.
     return false;
   }
 
   if (color1.GetUnit() != eCSSUnit_Null) {
-    StyleAnimationValue color1Value
-      (color1.GetColorValue(), StyleAnimationValue::ColorConstructor);
-    StyleAnimationValue color2Value
-      (color2.GetColorValue(), StyleAnimationValue::ColorConstructor);
-    StyleAnimationValue resultColorValue;
-    DebugOnly<bool> ok =
-      StyleAnimationValue::AddWeighted(eCSSProperty_color,
-                                       aCoeff1, color1Value,
-                                       aCoeff2, color2Value,
-                                       resultColorValue);
-    MOZ_ASSERT(ok, "should not fail");
-    resultArray->Item(4).SetColorValue(
-      resultColorValue.GetCSSValueValue()->GetColorValue());
+    if (aCoeff2 == 0.0 && aCoeff1 != 1.0) {
+      DiluteColor(color1, aCoeff1, resultArray->Item(4));
+    } else {
+      AddWeightedColors(aCoeff1, color1, aCoeff2, color2, resultArray->Item(4));
+    }
   }
 
   MOZ_ASSERT(inset1 == inset2, "should match");
   resultArray->Item(5) = inset1;
 
   nsCSSValueList *resultItem = new nsCSSValueList;
   resultItem->mValue.SetArrayValue(resultArray, eCSSUnit_Array);
   *aResultTail = resultItem;