2011-05-26 Simon Fraser <simon.fraser@apple.com>
authorsimon.fraser@apple.com <simon.fraser@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 26 May 2011 15:56:47 +0000 (15:56 +0000)
committersimon.fraser@apple.com <simon.fraser@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 26 May 2011 15:56:47 +0000 (15:56 +0000)
        Reviewed by Adam Roben.

        Some repeating linear gradients look wrong
        https://bugs.webkit.org/show_bug.cgi?id=61371

        Test: fast/gradients/css3-repeating-linear-gradients2.html

        Fix incorrect stop duplication code when filling forwards a repeating
        gradient. The "if (srcStopOrdinal < originalNumStops - 1)" test was wrong
        because srcStopOrdinal had been adjusted for stops added by start-filling,
        but originalNumStops had not. Fix by considering srcStopOrdinal as an index
        into the original stops, so comparing it with originalNumStops remains valid.

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

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

LayoutTests/ChangeLog
LayoutTests/fast/gradients/css3-repeating-linear-gradients2-expected.txt [new file with mode: 0644]
LayoutTests/fast/gradients/css3-repeating-linear-gradients2.html [new file with mode: 0644]
LayoutTests/platform/mac/fast/gradients/css3-repeating-linear-gradients2-expected.png [new file with mode: 0644]
Source/WebCore/ChangeLog
Source/WebCore/css/CSSGradientValue.cpp

index 8f2025e..905b8cd 100644 (file)
@@ -1,5 +1,18 @@
 2011-05-25  Simon Fraser  <simon.fraser@apple.com>
 
+        Reviewed by Adam Roben.
+
+        Some repeating linear gradients look wrong
+        https://bugs.webkit.org/show_bug.cgi?id=61371
+        
+        Pixel test for repeating linear gradient.
+
+        * fast/gradients/css3-repeating-linear-gradients2-expected.txt: Added.
+        * fast/gradients/css3-repeating-linear-gradients2.html: Added.
+        * platform/mac/fast/gradients/css3-repeating-linear-gradients2-expected.png: Added.
+
+2011-05-25  Simon Fraser  <simon.fraser@apple.com>
+
         Reviewed by Dan Bernstein.
 
         Always antialias table borders when scaling
diff --git a/LayoutTests/fast/gradients/css3-repeating-linear-gradients2-expected.txt b/LayoutTests/fast/gradients/css3-repeating-linear-gradients2-expected.txt
new file mode 100644 (file)
index 0000000..8b13789
--- /dev/null
@@ -0,0 +1 @@
+
diff --git a/LayoutTests/fast/gradients/css3-repeating-linear-gradients2.html b/LayoutTests/fast/gradients/css3-repeating-linear-gradients2.html
new file mode 100644 (file)
index 0000000..b340c4c
--- /dev/null
@@ -0,0 +1,32 @@
+<!DOCTYPE html>
+
+<html>
+<head>
+  <style>
+    .box {
+      display: inline-block;
+      height: 120px;
+      width: 400px;
+      margin: 10px;
+      border: 1px solid black;
+      background-repeat: no-repeat;
+    }
+
+    .linear1 {
+      background-image: -webkit-repeating-linear-gradient(0deg, green 150px, blue 175px, blue 200px);
+      background-image: -moz-repeating-linear-gradient(0deg, green 150px, blue 175px, blue 200px);
+    }
+  </style>
+  <script>
+    if (window.layoutTestController) {
+      var dumpPixels = true;
+      layoutTestController.dumpAsText(dumpPixels);
+    }
+  </script>
+</head>
+<body>
+
+  <div class="linear1 box"></div>
+
+</body>
+</html>
diff --git a/LayoutTests/platform/mac/fast/gradients/css3-repeating-linear-gradients2-expected.png b/LayoutTests/platform/mac/fast/gradients/css3-repeating-linear-gradients2-expected.png
new file mode 100644 (file)
index 0000000..6bdb3a6
Binary files /dev/null and b/LayoutTests/platform/mac/fast/gradients/css3-repeating-linear-gradients2-expected.png differ
index fc1e286..b569ec8 100644 (file)
@@ -1,3 +1,21 @@
+2011-05-26  Simon Fraser  <simon.fraser@apple.com>
+
+        Reviewed by Adam Roben.
+
+        Some repeating linear gradients look wrong
+        https://bugs.webkit.org/show_bug.cgi?id=61371
+
+        Test: fast/gradients/css3-repeating-linear-gradients2.html
+        
+        Fix incorrect stop duplication code when filling forwards a repeating
+        gradient. The "if (srcStopOrdinal < originalNumStops - 1)" test was wrong
+        because srcStopOrdinal had been adjusted for stops added by start-filling,
+        but originalNumStops had not. Fix by considering srcStopOrdinal as an index
+        into the original stops, so comparing it with originalNumStops remains valid.
+
+        * css/CSSGradientValue.cpp:
+        (WebCore::CSSGradientValue::addStops):
+
 2011-05-26  Vsevolod Vlasov  <vsevik@chromium.org>
 
         Reviewed by Yury Semikhatsky.
index 84e332a..9d561f5 100644 (file)
@@ -281,16 +281,17 @@ void CSSGradientValue::addStops(Gradient* gradient, RenderObject* renderer, Rend
             float lastOffset = stops[stops.size() - 1].offset;
             if (lastOffset < maxExtent) {
                 float currOffset = lastOffset;
-                size_t srcStopOrdinal = originalFirstStopIndex;
+                size_t srcStopOrdinal = 0;
 
                 while (true) {
-                    GradientStop newStop = stops[srcStopOrdinal];
+                    size_t srcStopIndex = originalFirstStopIndex + srcStopOrdinal;
+                    GradientStop newStop = stops[srcStopIndex];
                     newStop.offset = currOffset;
                     stops.append(newStop);
                     if (currOffset > maxExtent)
                         break;
                     if (srcStopOrdinal < originalNumStops - 1)
-                        currOffset += stops[srcStopOrdinal + 1].offset - stops[srcStopOrdinal].offset;
+                        currOffset += stops[srcStopIndex + 1].offset - stops[srcStopIndex].offset;
                     srcStopOrdinal = (srcStopOrdinal + 1) % originalNumStops;
                 }
             }