2011-02-13 Simon Fraser <simon.fraser@apple.com>
authorsimon.fraser@apple.com <simon.fraser@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 14 Feb 2011 02:09:15 +0000 (02:09 +0000)
committersimon.fraser@apple.com <simon.fraser@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 14 Feb 2011 02:09:15 +0000 (02:09 +0000)
        Reviewed by Andreas Kling.

        Repeating gradients drawn incorrectly
        https://bugs.webkit.org/show_bug.cgi?id=53502

        The 'forward-fill' logic for repeating gradients used the wrong
        starting stop index (0 rather than the original first index), which
        resulted in incorrect gradients if backwards-fill had already been
        applied.

        Test: fast/gradients/css3-repeating-end-fill.html

        * css/CSSGradientValue.cpp:
        (WebCore::CSSGradientValue::addStops):

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

LayoutTests/ChangeLog
LayoutTests/fast/gradients/css3-repeating-end-fill-expected.checksum [new file with mode: 0644]
LayoutTests/fast/gradients/css3-repeating-end-fill-expected.png [new file with mode: 0644]
LayoutTests/fast/gradients/css3-repeating-end-fill-expected.txt [new file with mode: 0644]
LayoutTests/fast/gradients/css3-repeating-end-fill.html [new file with mode: 0644]
Source/WebCore/ChangeLog
Source/WebCore/css/CSSGradientValue.cpp

index 599d3fc..2438546 100644 (file)
@@ -1,3 +1,17 @@
+2011-02-13  Simon Fraser  <simon.fraser@apple.com>
+
+        Reviewed by Andreas Kling.
+
+        Repeating gradients drawn incorrectly
+        https://bugs.webkit.org/show_bug.cgi?id=53502
+        
+        Testcase for a gradient that requires both backward- and forward-fill.
+
+        * fast/gradients/css3-repeating-end-fill-expected.checksum: Added.
+        * fast/gradients/css3-repeating-end-fill-expected.png: Added.
+        * fast/gradients/css3-repeating-end-fill-expected.txt: Added.
+        * fast/gradients/css3-repeating-end-fill.html: Added.
+
 2011-02-13  Andreas Kling  <kling@webkit.org>
 
         Unreviewed, remove unnecessary platform expectations for now-passing test.
diff --git a/LayoutTests/fast/gradients/css3-repeating-end-fill-expected.checksum b/LayoutTests/fast/gradients/css3-repeating-end-fill-expected.checksum
new file mode 100644 (file)
index 0000000..41f5b4f
--- /dev/null
@@ -0,0 +1 @@
+62365f1e86638927e2f7ecc3ed502f69
\ No newline at end of file
diff --git a/LayoutTests/fast/gradients/css3-repeating-end-fill-expected.png b/LayoutTests/fast/gradients/css3-repeating-end-fill-expected.png
new file mode 100644 (file)
index 0000000..2061ac7
Binary files /dev/null and b/LayoutTests/fast/gradients/css3-repeating-end-fill-expected.png differ
diff --git a/LayoutTests/fast/gradients/css3-repeating-end-fill-expected.txt b/LayoutTests/fast/gradients/css3-repeating-end-fill-expected.txt
new file mode 100644 (file)
index 0000000..549ae7c
--- /dev/null
@@ -0,0 +1,10 @@
+layer at (0,0) size 800x600
+  RenderView at (0,0) size 800x600
+layer at (0,0) size 800x120
+  RenderBlock {HTML} at (0,0) size 800x120
+    RenderBody {BODY} at (8,8) size 784x104
+      RenderBlock {DIV} at (0,0) size 200x100
+      RenderText {#text} at (200,86) size 4x18
+        text run at (200,86) width 4: " "
+      RenderBlock {DIV} at (204,0) size 200x100
+      RenderText {#text} at (0,0) size 0x0
diff --git a/LayoutTests/fast/gradients/css3-repeating-end-fill.html b/LayoutTests/fast/gradients/css3-repeating-end-fill.html
new file mode 100644 (file)
index 0000000..6e24223
--- /dev/null
@@ -0,0 +1,24 @@
+<!DOCTYPE html>
+<html>
+<head>
+  <style>
+    div {
+      display: inline-block;
+      width: 200px;
+      height: 100px;
+      background-image: -webkit-repeating-linear-gradient(red 10%, green 10%, green 30%);
+    }
+
+    .ref {
+      background-image: -webkit-repeating-linear-gradient(green 10%, green 30%);
+    }
+  </style>
+</head>
+<body>
+
+  <!-- You should see two green rectangles, with no red. -->
+  <div></div>
+  <div class="ref"></div>
+
+</body>
+</html>
\ No newline at end of file
index 9811122..70b9da8 100644 (file)
@@ -1,3 +1,20 @@
+2011-02-13  Simon Fraser  <simon.fraser@apple.com>
+
+        Reviewed by Andreas Kling.
+
+        Repeating gradients drawn incorrectly
+        https://bugs.webkit.org/show_bug.cgi?id=53502
+        
+        The 'forward-fill' logic for repeating gradients used the wrong
+        starting stop index (0 rather than the original first index), which
+        resulted in incorrect gradients if backwards-fill had already been
+        applied.
+
+        Test: fast/gradients/css3-repeating-end-fill.html
+
+        * css/CSSGradientValue.cpp:
+        (WebCore::CSSGradientValue::addStops):
+
 2011-02-13  Benjamin Poulain  <benjamin.poulain@nokia.com>
 
         Reviewed by Andreas Kling.
index e1fb916..ede76da 100644 (file)
@@ -281,7 +281,7 @@ void CSSGradientValue::addStops(Gradient* gradient, RenderObject* renderer, Rend
             float lastOffset = stops[stops.size() - 1].offset;
             if (lastOffset < maxExtent) {
                 float currOffset = lastOffset;
-                size_t srcStopOrdinal = 0;
+                size_t srcStopOrdinal = originalFirstStopIndex;
 
                 while (true) {
                     GradientStop newStop = stops[srcStopOrdinal];
@@ -290,7 +290,7 @@ void CSSGradientValue::addStops(Gradient* gradient, RenderObject* renderer, Rend
                     if (currOffset > maxExtent)
                         break;
                     if (srcStopOrdinal < originalNumStops - 1)
-                        currOffset += stops[originalFirstStopIndex + srcStopOrdinal + 1].offset - stops[originalFirstStopIndex + srcStopOrdinal].offset;
+                        currOffset += stops[srcStopOrdinal + 1].offset - stops[srcStopOrdinal].offset;
                     srcStopOrdinal = (srcStopOrdinal + 1) % originalNumStops;
                 }
             }