Fix color stop blending in conic gradients for stops past 1
authormegan_gardner@apple.com <megan_gardner@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 14 Sep 2018 00:25:14 +0000 (00:25 +0000)
committermegan_gardner@apple.com <megan_gardner@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 14 Sep 2018 00:25:14 +0000 (00:25 +0000)
https://bugs.webkit.org/show_bug.cgi?id=189532
<rdar://problem/44158221>

Reviewed by Simon Fraser.

Source/WebCore:

Calculation was wrong, fixed it, and wrote a test that failed
without the change, and passes with it.

Test: fast/gradients/conic-repeating-last-stop.html

* css/CSSGradientValue.cpp:
(WebCore::ConicGradientAdapter::normalizeStopsAndEndpointsOutsideRange):

LayoutTests:

Tests that last stop in the gradient is correct.

* fast/gradients/conic-repeating-last-stop-expected.html: Added.
* fast/gradients/conic-repeating-last-stop.html: Added.
* platform/ios-12/TestExpectations:
* platform/mac/TestExpectations:

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@235999 268f45cc-cd09-0410-ab3c-d52691b4dbfc

LayoutTests/ChangeLog
LayoutTests/TestExpectations
LayoutTests/fast/gradients/conic-repeating-last-stop-expected.html [new file with mode: 0644]
LayoutTests/fast/gradients/conic-repeating-last-stop.html [new file with mode: 0644]
LayoutTests/platform/ios-12/TestExpectations
LayoutTests/platform/mac/TestExpectations
Source/WebCore/ChangeLog
Source/WebCore/css/CSSGradientValue.cpp

index 2d3fd31..1e6d84e 100644 (file)
@@ -1,3 +1,18 @@
+2018-09-13  Megan Gardner  <megan_gardner@apple.com>
+
+        Fix color stop blending in conic gradients for stops past 1
+        https://bugs.webkit.org/show_bug.cgi?id=189532
+        <rdar://problem/44158221>
+
+        Reviewed by Simon Fraser.
+
+        Tests that last stop in the gradient is correct.
+
+        * fast/gradients/conic-repeating-last-stop-expected.html: Added.
+        * fast/gradients/conic-repeating-last-stop.html: Added.
+        * platform/ios-12/TestExpectations:
+        * platform/mac/TestExpectations:
+
 2018-09-13  Ryan Haddad  <ryanhaddad@apple.com>
 
         Unreviewed, rolling out r235954.
index 810a898..23d2877 100644 (file)
@@ -2243,6 +2243,7 @@ fast/gradients/conic-off-center.html [ Skip ]
 fast/gradients/conic-center-outside-box.html [ Skip ]
 fast/gradients/conic-extended-stops.html [ Skip ]
 fast/gradients/conic-from-angle.html [ Skip ]
+fast/gradients/conic-repeating-last-stop.html [ Skip ]
 
 webkit.org/b/187773 http/tests/webAPIStatistics [ Skip ]
 
diff --git a/LayoutTests/fast/gradients/conic-repeating-last-stop-expected.html b/LayoutTests/fast/gradients/conic-repeating-last-stop-expected.html
new file mode 100644 (file)
index 0000000..2e8a53c
--- /dev/null
@@ -0,0 +1,18 @@
+<html>
+<head>
+    <style>
+        div {
+            width: 200px;
+            height: 200px;
+        }
+
+        #box1 {
+            background-color: yellow;
+        }
+        
+    </style>
+</head>
+<body>
+    <div id="box1"></div>
+</body>
+</html>
diff --git a/LayoutTests/fast/gradients/conic-repeating-last-stop.html b/LayoutTests/fast/gradients/conic-repeating-last-stop.html
new file mode 100644 (file)
index 0000000..d766d24
--- /dev/null
@@ -0,0 +1,42 @@
+<html>
+<head>
+<style>
+svg {
+    width: 800px;
+    display: none;
+}
+
+.container {
+    width: 200px;
+    height: 200px;
+    overflow: hidden;
+}
+
+#test {
+    width: 200px;
+    height: 200px;
+    background-image: repeating-conic-gradient(gold, orange 20deg);
+    filter: url(#posterize);
+    transform: scale(20);
+    transform-origin: 45% top;
+}
+</style>
+</head>
+
+<body>
+<svg viewBox="0 0 700 100">
+<defs>
+    <filter id="posterize" filterUnits="objectBoundingBox" primitiveUnits="objectBoundingBox">
+        <feComponentTransfer>
+            <feFuncR type="discrete" tableValues="0 1"/>
+            <feFuncG type="discrete" tableValues="0 1"/>
+            <feFuncB type="discrete" tableValues="0 1"/>
+        </feComponentTransfer>
+    </filter>
+</defs>
+</svg>
+
+<div class="container">
+    <div id="test"></div>
+</div>
+</html>
index 362cd87..53ffd77 100644 (file)
@@ -32,4 +32,5 @@ fast/gradients/conic.html [ Pass ]
 fast/gradients/conic-off-center.html [ Pass ]
 fast/gradients/conic-center-outside-box.html [ Pass ]
 fast/gradients/conic-extended-stops.html [ Pass ]
-fast/gradients/conic-from-angle.html [ Pass ]
\ No newline at end of file
+fast/gradients/conic-from-angle.html [ Pass ]
+fast/gradients/conic-repeating-last-stop.html [ Pass ]
index 52af06c..fe9fa2d 100644 (file)
@@ -1764,3 +1764,6 @@ webkit.org/b/187393 imported/w3c/web-platform-tests/2dcontext/imagebitmap/create
 [ Mojave+ ] fast/gradients/conic-center-outside-box.html [ Pass ]
 [ Mojave+ ] fast/gradients/conic-extended-stops.html [ Pass ]
 [ Mojave+ ] fast/gradients/conic-from-angle.html [ Pass ]
+[ Mojave+ ] fast/gradients/conic-repeating-last-stop.html [ Pass ]
+
+
index f17b256..02b4b6b 100644 (file)
@@ -1,3 +1,19 @@
+2018-09-13  Megan Gardner  <megan_gardner@apple.com>
+
+        Fix color stop blending in conic gradients for stops past 1
+        https://bugs.webkit.org/show_bug.cgi?id=189532
+        <rdar://problem/44158221>
+
+        Reviewed by Simon Fraser.
+
+        Calculation was wrong, fixed it, and wrote a test that failed
+        without the change, and passes with it.
+
+        Test: fast/gradients/conic-repeating-last-stop.html
+
+        * css/CSSGradientValue.cpp:
+        (WebCore::ConicGradientAdapter::normalizeStopsAndEndpointsOutsideRange):
+
 2018-09-13  Chris Dumez  <cdumez@apple.com>
 
         Regression(PSON): setting window.opener to null allows process swapping in cases that are not web-compatible
index 700c63d..898b1e2 100644 (file)
@@ -280,7 +280,7 @@ public:
                 float prevOffset = stops[lastOneOrLessIndex].offset;
                 float nextOffset = stops[lastOneOrLessIndex + 1].offset;
                 
-                float interStopProportion = 1 / (nextOffset - prevOffset);
+                float interStopProportion = (1 - prevOffset) / (nextOffset - prevOffset);
                 // FIXME: when we interpolate gradients using premultiplied colors, this should do premultiplication.
                 Color blendedColor = blend(stops[lastOneOrLessIndex].color, stops[lastOneOrLessIndex + 1].color, interStopProportion);