LayoutTests:
authordarin <darin@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 9 Mar 2006 16:32:31 +0000 (16:32 +0000)
committerdarin <darin@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 9 Mar 2006 16:32:31 +0000 (16:32 +0000)
        Reviewed by Darin.

        * fast/canvas: Added.

        - test for http://bugzilla.opendarwin.org/show_bug.cgi?id=6103
          Rectangles are not filled according to the Web Applications Working Draft

        * fast/canvas/fillrect_gradient-expected.checksum: Added.
        * fast/canvas/fillrect_gradient-expected.png: Added.
        * fast/canvas/fillrect_gradient-expected.txt: Added.
        * fast/canvas/fillrect_gradient.html: Added.

        - moved other canvas tests here

        * fast/canvas/image-object-in-canvas-expected.checksum: Added.
        * fast/canvas/image-object-in-canvas-expected.png: Added.
        * fast/canvas/image-object-in-canvas-expected.txt: Added.
        * fast/canvas/image-object-in-canvas.html: Added.
        * fast/canvas/quadraticCurveTo-expected.checksum: Added.
        * fast/canvas/quadraticCurveTo-expected.png: Added.
        * fast/canvas/quadraticCurveTo-expected.txt: Added.
        * fast/canvas/quadraticCurveTo.xml: Added.
        * fast/canvas/resources: Added.
        * fast/canvas/resources/apple.gif: Added.

        * fast/dom/image-object-in-canvas-expected.checksum: Removed.
        * fast/dom/image-object-in-canvas-expected.png: Removed.
        * fast/dom/image-object-in-canvas-expected.txt: Removed.
        * fast/dom/image-object-in-canvas.html: Removed.
        * fast/dom/quadraticCurveTo-expected.checksum: Removed.
        * fast/dom/quadraticCurveTo-expected.png: Removed.
        * fast/dom/quadraticCurveTo-expected.txt: Removed.
        * fast/dom/quadraticCurveTo.xml: Removed.

WebCore:

        Test: fast/canvas/fillrect_gradient.html

        Reviewed by Darin.

        - fix http://bugzilla.opendarwin.org/show_bug.cgi?id=6103
          Rectangles are not filled according to the Web Applications Working Draft

        * khtml/ecma/kjs_html.cpp: (KJS::Context2DFunction::callAsFunction):
        Modified fillrect function to check and use a gradient if set.
        Builds a path to fill rects with a gradient.

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

16 files changed:
LayoutTests/ChangeLog
LayoutTests/fast/canvas/fillrect_gradient-expected.checksum [new file with mode: 0644]
LayoutTests/fast/canvas/fillrect_gradient-expected.png [new file with mode: 0644]
LayoutTests/fast/canvas/fillrect_gradient-expected.txt [new file with mode: 0644]
LayoutTests/fast/canvas/fillrect_gradient.html [new file with mode: 0644]
LayoutTests/fast/canvas/image-object-in-canvas-expected.checksum [moved from LayoutTests/fast/dom/image-object-in-canvas-expected.checksum with 100% similarity]
LayoutTests/fast/canvas/image-object-in-canvas-expected.png [moved from LayoutTests/fast/dom/image-object-in-canvas-expected.png with 100% similarity]
LayoutTests/fast/canvas/image-object-in-canvas-expected.txt [moved from LayoutTests/fast/dom/image-object-in-canvas-expected.txt with 100% similarity]
LayoutTests/fast/canvas/image-object-in-canvas.html [moved from LayoutTests/fast/dom/image-object-in-canvas.html with 100% similarity]
LayoutTests/fast/canvas/quadraticCurveTo-expected.checksum [moved from LayoutTests/fast/dom/quadraticCurveTo-expected.checksum with 100% similarity]
LayoutTests/fast/canvas/quadraticCurveTo-expected.png [moved from LayoutTests/fast/dom/quadraticCurveTo-expected.png with 100% similarity]
LayoutTests/fast/canvas/quadraticCurveTo-expected.txt [moved from LayoutTests/fast/dom/quadraticCurveTo-expected.txt with 100% similarity]
LayoutTests/fast/canvas/quadraticCurveTo.xml [moved from LayoutTests/fast/dom/quadraticCurveTo.xml with 100% similarity]
LayoutTests/fast/canvas/resources/apple.gif [new file with mode: 0644]
WebCore/ChangeLog
WebCore/khtml/ecma/kjs_html.cpp

index dc65d69c06d93af4c3841cf14d272d0fd6c513e7..80a924d0b72ac0cd401343a4c8be0c643a21b11a 100644 (file)
@@ -1,3 +1,39 @@
+2006-03-09  David Carson  <dacarson@gmail.com>
+
+        Reviewed by Darin.
+
+        * fast/canvas: Added.
+
+        - test for http://bugzilla.opendarwin.org/show_bug.cgi?id=6103
+          Rectangles are not filled according to the Web Applications Working Draft
+
+        * fast/canvas/fillrect_gradient-expected.checksum: Added.
+        * fast/canvas/fillrect_gradient-expected.png: Added.
+        * fast/canvas/fillrect_gradient-expected.txt: Added.
+        * fast/canvas/fillrect_gradient.html: Added.
+
+        - moved other canvas tests here
+
+        * fast/canvas/image-object-in-canvas-expected.checksum: Added.
+        * fast/canvas/image-object-in-canvas-expected.png: Added.
+        * fast/canvas/image-object-in-canvas-expected.txt: Added.
+        * fast/canvas/image-object-in-canvas.html: Added.
+        * fast/canvas/quadraticCurveTo-expected.checksum: Added.
+        * fast/canvas/quadraticCurveTo-expected.png: Added.
+        * fast/canvas/quadraticCurveTo-expected.txt: Added.
+        * fast/canvas/quadraticCurveTo.xml: Added.
+        * fast/canvas/resources: Added.
+        * fast/canvas/resources/apple.gif: Added.
+
+        * fast/dom/image-object-in-canvas-expected.checksum: Removed.
+        * fast/dom/image-object-in-canvas-expected.png: Removed.
+        * fast/dom/image-object-in-canvas-expected.txt: Removed.
+        * fast/dom/image-object-in-canvas.html: Removed.
+        * fast/dom/quadraticCurveTo-expected.checksum: Removed.
+        * fast/dom/quadraticCurveTo-expected.png: Removed.
+        * fast/dom/quadraticCurveTo-expected.txt: Removed.
+        * fast/dom/quadraticCurveTo.xml: Removed.
+
 2006-03-09  Alexey Proskuryakov  <ap@nypop.com>
 
         Reviewed by Darin.
diff --git a/LayoutTests/fast/canvas/fillrect_gradient-expected.checksum b/LayoutTests/fast/canvas/fillrect_gradient-expected.checksum
new file mode 100644 (file)
index 0000000..9090c5d
--- /dev/null
@@ -0,0 +1 @@
+b02404bb0f8170a8f96ecde528ff923e
\ No newline at end of file
diff --git a/LayoutTests/fast/canvas/fillrect_gradient-expected.png b/LayoutTests/fast/canvas/fillrect_gradient-expected.png
new file mode 100644 (file)
index 0000000..8e828a3
Binary files /dev/null and b/LayoutTests/fast/canvas/fillrect_gradient-expected.png differ
diff --git a/LayoutTests/fast/canvas/fillrect_gradient-expected.txt b/LayoutTests/fast/canvas/fillrect_gradient-expected.txt
new file mode 100644 (file)
index 0000000..58e51fd
--- /dev/null
@@ -0,0 +1,11 @@
+layer at (0,0) size 800x600
+  RenderCanvas at (0,0) size 800x600
+layer at (0,0) size 800x600
+  RenderBlock {HTML} at (0,0) size 800x600
+    RenderBody {BODY} at (8,8) size 784x584
+      RenderText {TEXT} at (0,0) size 722x18
+        text run at (0,0) width 722: "The canvas below should show a gradient, starting at green at the top and fading to white at the bottom of the rect. "
+      RenderCanvasImage {CANVAS} at (0,18) size 150x150
+      RenderText {TEXT} at (0,0) size 0x0
+      RenderText {TEXT} at (0,0) size 0x0
+      RenderText {TEXT} at (0,0) size 0x0
diff --git a/LayoutTests/fast/canvas/fillrect_gradient.html b/LayoutTests/fast/canvas/fillrect_gradient.html
new file mode 100644 (file)
index 0000000..b4e030b
--- /dev/null
@@ -0,0 +1,18 @@
+<body>
+The canvas below should show a gradient, starting at green at the top and fading to white at the bottom of the rect.
+<canvas id="canvas" width="150" height="150"></canvas>
+<script>
+    var ctx = document.getElementById('canvas').getContext('2d');
+
+    // Create gradient
+    var lingrad = ctx.createLinearGradient(0,0,0,150);
+    lingrad.addColorStop(0, '#0f0');
+    lingrad.addColorStop(1, '#fff');
+
+    // assign gradient to fill
+    ctx.fillStyle = lingrad;
+        
+    // draw shapes
+    ctx.fillRect(10,10,130,130);
+</script>
+</body>
diff --git a/LayoutTests/fast/canvas/resources/apple.gif b/LayoutTests/fast/canvas/resources/apple.gif
new file mode 100644 (file)
index 0000000..55844c8
Binary files /dev/null and b/LayoutTests/fast/canvas/resources/apple.gif differ
index 2842dfbbc0c7e8fde13daaaea5c642cd192ae9d7..cb6c347fd5d796f85c93d4d465f0856351274a52 100644 (file)
@@ -1,3 +1,16 @@
+2006-03-09  David Carson  <dacarson@gmail.com>
+
+        Test: fast/canvas/fillrect_gradient.html
+
+        Reviewed by Darin.
+
+        - fix http://bugzilla.opendarwin.org/show_bug.cgi?id=6103
+          Rectangles are not filled according to the Web Applications Working Draft
+
+        * khtml/ecma/kjs_html.cpp: (KJS::Context2DFunction::callAsFunction):
+        Modified fillrect function to check and use a gradient if set.
+        Builds a path to fill rects with a gradient.
+
 2006-03-09  Mitz Pettel  <opendarwin.org@mitzpettel.com>
 
         No test because this fixes an existing pixel test (and does not affect
index 08403ff9c14ac805e67d6b60c235f6893fb35321..5088afcc088e307843e05cdc63d5733be77cff14 100644 (file)
@@ -3773,7 +3773,6 @@ JSValue *KJS::Context2DFunction::callAsFunction(ExecState *exec, JSObject *thisO
 
                 JSObject *o = static_cast<JSObject*>(contextObject->_strokeStyle);
                 Gradient *gradient = static_cast<Gradient*>(o);
-                
                 CGShadingRef shading = gradient->getShading();
                 CGContextDrawShading(drawingContext, shading);
                 
@@ -3910,9 +3909,29 @@ JSValue *KJS::Context2DFunction::callAsFunction(ExecState *exec, JSObject *thisO
             float y = (float)args[1]->toNumber(exec);
             float w = (float)args[2]->toNumber(exec);
             float h = (float)args[3]->toNumber(exec);
-            if (isImagePattern(contextObject->_fillStyle))
-                contextObject->updateFillImagePattern();
-            CGContextFillRect (drawingContext, CGRectMake(x,y,w,h));
+            
+            if (isGradient(contextObject->_fillStyle)) {
+                CGContextSaveGState(drawingContext);
+                
+                // Can't use a gradient fill with a FillRect, must use a path.
+                CGContextBeginPath(drawingContext);
+                CGContextAddRect(drawingContext, CGRectMake(x, y, w, h));
+
+                // Set the clip from the current path because shading only
+                // operates on clippin regions!  Odd, but true.
+                CGContextClip(drawingContext);
+
+                JSObject *o = static_cast<JSObject*>(contextObject->_fillStyle);
+                Gradient *gradient = static_cast<Gradient*>(o);
+                CGShadingRef shading = gradient->getShading();
+                CGContextDrawShading(drawingContext, shading);
+                
+                CGContextRestoreGState(drawingContext);
+            } else {
+                if (isImagePattern(contextObject->_fillStyle))
+                    contextObject->updateFillImagePattern();
+                CGContextFillRect(drawingContext, CGRectMake(x, y, w, h));
+            }
             renderer->setNeedsImageUpdate();
             break;
         }