Bug 1329411 - Correct wrong alpha value caused by the sixth patch in bug 1323912, and a test case. draft
authorcku <cku@mozilla.com>
Mon, 09 Jan 2017 10:41:42 +0800 (2017-01-09)
changeset 457522 0df3c0383aa1cc15ae577f92da78c56ef57850a2
parent 456716 a14094edbad78fc1d16e8d4c57902537cf286fd1
child 541506 81e4b59d6edc3a822414fe6ab216c0e37b0aad0e
push id40806
push userbmo:cku@mozilla.com
push dateMon, 09 Jan 2017 06:07:10 +0000 (2017-01-09)
bugs1329411, 1323912
milestone53.0a1
Bug 1329411 - Correct wrong alpha value caused by the sixth patch in bug 1323912, and a test case. MozReview-Commit-ID: 8iSyUxQ1EnM
layout/painting/nsCSSRendering.cpp
layout/reftests/css-gradients/mask-gradient-translucent-end-color-1-ref.html
layout/reftests/css-gradients/mask-gradient-translucent-end-color-1.html
layout/reftests/css-gradients/reftest.list
--- a/layout/painting/nsCSSRendering.cpp
+++ b/layout/painting/nsCSSRendering.cpp
@@ -3207,17 +3207,17 @@ nsCSSRendering::PaintGradient(nsPresCont
       ctx->Rectangle(fillRect);
 
       gfxRect dirtyFillRect = fillRect.Intersect(dirtyAreaToFill);
       gfxRect fillRectRelativeToTile = dirtyFillRect - tileRect.TopLeft();
       Color edgeColor;
       if (aGradient->mShape == NS_STYLE_GRADIENT_SHAPE_LINEAR && !isRepeat &&
           RectIsBeyondLinearGradientEdge(fillRectRelativeToTile, matrix, stops,
                                          gradientStart, gradientEnd, &edgeColor)) {
-        edgeColor.a = aOpacity;
+        edgeColor.a *= aOpacity;
         ctx->SetColor(edgeColor);
       } else {
         ctx->SetMatrix(
           ctx->CurrentMatrix().Copy().Translate(tileRect.TopLeft()));
         ctx->SetPattern(gradientPattern);
       }
       ctx->Fill();
       ctx->SetMatrix(ctm);
new file mode 100644
--- /dev/null
+++ b/layout/reftests/css-gradients/mask-gradient-translucent-end-color-1-ref.html
@@ -0,0 +1,17 @@
+<!--
+     Any copyright is dedicated to the Public Domain.
+     http://creativecommons.org/publicdomain/zero/1.0/
+-->
+<!DOCTYPE html>
+<html lang="en">
+<meta charset="utf-8">
+<title>Make sure that gradient masks are painted correctly with translucent end-color</title>
+
+<style>
+
+html {
+  background: rgba(255, 0, 0, 0.5);
+  overflow: hidden;
+}
+
+</style>
new file mode 100644
--- /dev/null
+++ b/layout/reftests/css-gradients/mask-gradient-translucent-end-color-1.html
@@ -0,0 +1,34 @@
+<!--
+     Any copyright is dedicated to the Public Domain.
+     http://creativecommons.org/publicdomain/zero/1.0/
+-->
+<!DOCTYPE html>
+<html lang="en" class="reftest-wait">
+<meta charset="utf-8">
+<title>Make sure that gradient masks are painted correctly with translucent end-color</title>
+<!-- See https://bugzilla.mozilla.org/show_bug.cgi?id=1329411 -->
+
+<style>
+
+html {
+  background: white;
+  overflow: hidden;
+}
+
+div {
+  height: 5000px;
+  background-color: red;
+  mask-image: linear-gradient(transparent 0px, rgba(255, 0, 0, 0.5) 2000px);
+}
+
+</style>
+<body style="margin: 0px;">
+  <div></div>
+
+  <script>
+    window.addEventListener("MozReftestInvalidate", function () {
+      document.documentElement.scrollTop = 3000; // > 2000
+      document.documentElement.removeAttribute("class");
+    });
+  </script>
+</body>
--- a/layout/reftests/css-gradients/reftest.list
+++ b/layout/reftests/css-gradients/reftest.list
@@ -147,8 +147,10 @@ fuzzy-if(d2d,47,400) == linear-onestoppo
 == repeating-radial-onestopposition-1c.html orange-square.html
 == bug-916535-background-repeat-linear.html bug-916535-background-repeat-linear-ref.html
 fuzzy(1,800000) == large-gradient-1.html large-gradient-1-ref.html
 fuzzy-if(Android,4,1) == large-gradient-2.html large-gradient-2-ref.html # Bug 1182082
 fuzzy(1,800000) == large-gradient-3.html large-gradient-3-ref.html
 == large-gradient-4.html large-gradient-4-ref.html
 fuzzy(2,800000) == large-gradient-5.html large-gradient-5-ref.html
 == 1224761-1.html 1224761-1-ref.html
+
+fuzzy(1,800000) == mask-gradient-translucent-end-color-1.html mask-gradient-translucent-end-color-1-ref.html