Bug 1294614 - Part 1: Test cases for SMIL animation for RGBA colors. r?dholbert draft
authorHiroyuki Ikezoe <hiikezoe@mozilla-japan.org>
Fri, 26 Aug 2016 09:10:25 +0900
changeset 405877 62d172201f44c09decccf67b3ba329dd0f32651b
parent 405457 7963ebdd52b93f96b812eff2eab8d94097147b9c
child 405878 0a9fae49472c5f04be62d5b8e40d220e8b7935bf
push id27583
push userhiikezoe@mozilla-japan.org
push dateFri, 26 Aug 2016 01:48:04 +0000
reviewersdholbert
bugs1294614
milestone51.0a1
Bug 1294614 - Part 1: Test cases for SMIL animation for RGBA colors. r?dholbert The second test case in db_smilCSSFromBy.js MozReview-Commit-ID: KEkjy2Y4uoq
dom/smil/test/db_smilCSSFromBy.js
dom/smil/test/db_smilCSSFromTo.js
dom/smil/test/db_smilCSSPaced.js
--- a/dom/smil/test/db_smilCSSFromBy.js
+++ b/dom/smil/test/db_smilCSSFromBy.js
@@ -14,16 +14,33 @@ var _fromByTestLists =
   color: [
     new AnimTestcaseFromBy("rgb(10, 20, 30)", "currentColor",
                            { midComp: "rgb(35, 45, 55)",
                              toComp:  "rgb(60, 70, 80)"}),
     new AnimTestcaseFromBy("currentColor", "rgb(30, 20, 10)",
                            { fromComp: "rgb(50, 50, 50)",
                              midComp:  "rgb(65, 60, 55)",
                              toComp:   "rgb(80, 70, 60)"}),
+    new AnimTestcaseFromBy("rgba(10, 20, 30, 0.2)", "rgba(50, 50, 50, 1)",
+                             // (rgb(10, 20, 30) * 0.2 * 0.5 + rgb(52, 54, 56) * 1.0 * 0.5) * (1 / 0.6)
+                           { midComp: "rgba(45, 48, 52, 0.6)",
+                             // (rgb(10, 20, 30) * 0.2 + rgb(50, 50, 50) * 1) / 1.0
+                             toComp:  "rgb(52, 54, 56)"}),
+    // Note: technically, the "from" and "by" values in the test case below
+    // would overflow the maxium color-channel values when added together.
+    // (e.g. for red [ignoring alpha for now], 100 + 240 = 340 which is > 255)
+    // The SVG Animation spec says we should clamp color values "as late as
+    // possible," i.e. allow the channel overflow and clamp at paint-time.
+    // But for now, we instead clamp the implicit "to" value for the animation
+    // and interpolate up to that clamped result.
+    new AnimTestcaseFromBy("rgba(100, 100, 100, 0.6)", "rgba(240, 240, 240, 1)",
+                             // (rgb(100, 100, 100) * 0.6 * 0.5 + rgb(255, 255, 255) * 1.0 * 0.5) * (1 / 0.8)
+                           { midComp: "rgba(197, 197, 197, 0.8)",
+                             // (rgb(100, 100, 100) * 0.6 + rgb(240, 240, 240) is overflowed
+                             toComp:  "rgb(255, 255, 255)"}),
   ],
   lengthNoUnits: [
     new AnimTestcaseFromBy("0", "50",  { fromComp: "0px", // 0 acts like 0px
                                          midComp:  "25px",
                                          toComp:   "50px"}),
     new AnimTestcaseFromBy("30", "10", { fromComp: "30px",
                                          midComp:  "35px",
                                          toComp:   "40px"}),
--- a/dom/smil/test/db_smilCSSFromTo.js
+++ b/dom/smil/test/db_smilCSSFromTo.js
@@ -28,16 +28,20 @@ var _fromToTestLists = {
                              toComp: "rgb(0, 128, 160)" }),
     new AnimTestcaseFromTo("crimson", "lawngreen",
                            { fromComp: "rgb(220, 20, 60)",
                              midComp: "rgb(172, 136, 30)",
                              toComp: "rgb(124, 252, 0)" }),
     new AnimTestcaseFromTo("currentColor", "rgb(100, 100, 100)",
                            { fromComp: "rgb(50, 50, 50)",
                              midComp: "rgb(75, 75, 75)" }),
+    new AnimTestcaseFromTo("rgba(10, 20, 30, 0.2)", "rgba(50, 50, 50, 1)",
+                             // (rgb(10, 20, 30) * 0.2 * 0.5 + rgb(50, 50, 50) * 1.0 * 0.5) * (1 / 0.6)
+                           { midComp: "rgba(43, 45, 47, 0.6)",
+                             toComp:  "rgb(50, 50, 50)"}),
   ],
   colorFromInheritBlack: [
     new AnimTestcaseFromTo("inherit", "rgb(200, 200, 200)",
                            { fromComp: "rgb(0, 0, 0)",
                              midComp: "rgb(100, 100, 100)" }),
   ],
   colorFromInheritWhite: [
     new AnimTestcaseFromTo("inherit", "rgb(205, 205, 205)",
--- a/dom/smil/test/db_smilCSSPaced.js
+++ b/dom/smil/test/db_smilCSSPaced.js
@@ -32,16 +32,27 @@ var _pacedTestLists =
                           "currentColor; " + // rgb(50, 50, 50)
                           "rgb(206, 150, 206)",
                           { comp0:   "rgb(128, 128, 0)",
                             comp1_6: "rgb(89, 89, 25)",
                             comp1_3: "rgb(50, 50, 50)",
                             comp2_3: "rgb(128, 100, 128)",
                             comp1:   "rgb(206, 150, 206)"
                           }),
+                          // Use the same RGB component values to make
+                          // premultication effect easier to compute.
+    new AnimTestcasePaced("rgba(20, 40, 60, 0.2); " +
+                          "rgba(20, 40, 60, 0.4); " +
+                          "rgba(20, 40, 60, 0.8)",
+                          { comp0: "rgba(20, 40, 60, 0.2)",
+                            comp1_6: "rgba(20, 40, 60, 0.3)",
+                            comp1_3: "rgba(20, 40, 60, 0.4)",
+                            comp2_3: "rgba(20, 40, 60, 0.6)",
+                            comp1:   "rgba(20, 40, 60, 0.8)"
+                          }),
   ],
   paintServer : [
     // Sanity check: These aren't interpolatable -- they should end up
     // ignoring the calcMode="paced" and falling into discrete-mode.
     new AnimTestcasePaced("url(#gradA); url(#gradB)",
           {
             comp0:   "url(\"" + document.URL + "#gradA\") rgb(0, 0, 0)",
             comp1_6: "url(\"" + document.URL + "#gradA\") rgb(0, 0, 0)",