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
--- 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)",