LayoutTests:
authordarin <darin@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sun, 19 Mar 2006 06:05:00 +0000 (06:05 +0000)
committerdarin <darin@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sun, 19 Mar 2006 06:05:00 +0000 (06:05 +0000)
        Reviewed by Darin.

        - test for http://bugzilla.opendarwin.org/show_bug.cgi?id=7830
          <canvas> createPattern 'repeat' options fail

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

WebCore:

        Test: fast/canvas/patternfill-repeat.html

        Reviewed by Darin.

        - fix http://bugzilla.opendarwin.org/show_bug.cgi?id=7830
          <canvas> createPattern 'repeat' options fail

        * CanvasPattern.cpp (CanvasPattern::createPattern)
        Change stepping so that repeat-x, repeat-y, and no-repeat repeat
        outside the view area by using large values for repeat interval.

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

LayoutTests/ChangeLog
LayoutTests/fast/canvas/patternfill-repeat-expected.checksum [new file with mode: 0644]
LayoutTests/fast/canvas/patternfill-repeat-expected.txt [new file with mode: 0644]
LayoutTests/fast/canvas/patternfill-repeat.html [new file with mode: 0644]
WebCore/ChangeLog
WebCore/html/CanvasPattern.cpp

index d7af5fd8b175522a36f1438d867b355a2ea07ac9..9587a54249fd3e7a48db96cb740eb32cce0a625c 100644 (file)
@@ -1,3 +1,15 @@
+2006-03-18  David Carson  <dacarson@gmail.com>        
+
+        Reviewed by Darin.
+
+        - test for http://bugzilla.opendarwin.org/show_bug.cgi?id=7830
+          <canvas> createPattern 'repeat' options fail
+
+        * fast/canvas/patternfill-repeat-expected.checksum: Added.
+        * fast/canvas/patternfill-repeat-expected.png: Added.
+        * fast/canvas/patternfill-repeat-expected.txt: Added.
+        * fast/canvas/patternfill-repeat.html: Added.
+
 2006-03-18  Mitz Pettel  <opendarwin.org@mitzpettel.com>
 
         Reviewed by Darin.
diff --git a/LayoutTests/fast/canvas/patternfill-repeat-expected.checksum b/LayoutTests/fast/canvas/patternfill-repeat-expected.checksum
new file mode 100644 (file)
index 0000000..693ace7
--- /dev/null
@@ -0,0 +1 @@
+9473c7a33468930d21f2770b730e4d1c
\ No newline at end of file
diff --git a/LayoutTests/fast/canvas/patternfill-repeat-expected.txt b/LayoutTests/fast/canvas/patternfill-repeat-expected.txt
new file mode 100644 (file)
index 0000000..54259be
--- /dev/null
@@ -0,0 +1,13 @@
+layer at (0,0) size 800x600
+  RenderCanvas at (0,0) size 800x600
+layer at (0,0) size 800x460
+  RenderBlock {HTML} at (0,0) size 800x460
+    RenderBody {BODY} at (8,16) size 784x428
+      RenderBlock {P} at (0,0) size 784x72
+        RenderText {TEXT} at (0,0) size 773x72
+          text run at (0,0) width 751: "There should be one big square below containing four squares. Top left square should be filled with 3 rows of 2 and bit"
+          text run at (0,18) width 773: "Apple images. Top right square should be 2 and a bit rows with one Apple image column along the left edge of the square."
+          text run at (0,36) width 764: "Bottom left square should be one row with three Apple images along the top of the square. Bottom right square should be"
+          text run at (0,54) width 220: "one Apple image in top left corner."
+      RenderBlock {P} at (0,88) size 784x340
+        RenderCanvasImage {CANVAS} at (0,0) size 336x336 [border: (3px solid #000000)]
diff --git a/LayoutTests/fast/canvas/patternfill-repeat.html b/LayoutTests/fast/canvas/patternfill-repeat.html
new file mode 100644 (file)
index 0000000..38b8ce3
--- /dev/null
@@ -0,0 +1,51 @@
+<!DOCTYPE html>
+<html lang="en">
+ <head>
+  <title>createPattern repeat test</title>
+  <style> canvas { border:solid #000 } </style>
+  <script>
+   if (window.layoutTestController)
+     layoutTestController.waitUntilDone();
+   window.onload = function(){
+    var i = new Image();
+    i.src = "resources/apple.gif";
+    i.onload = function() {
+        var ctx = document.getElementsByTagName('canvas')[0].getContext('2d');
+        var p;
+    
+       //ctx.strokeWidth(1.0);
+       p = ctx.createPattern(i, "repeat");
+       ctx.fillStyle = p;
+       ctx.translate(10, 10);
+       ctx.strokeRect(0, 0, 150, 150);
+       ctx.fillRect(0, 0, 150, 150);
+    
+       px = ctx.createPattern(i, "repeat-x");
+       ctx.fillStyle = px;
+       ctx.translate(0, 160);
+       ctx.strokeRect(0, 0, 150, 150);
+       ctx.fillRect(0, 0, 150, 150);
+    
+       pn = ctx.createPattern(i, "no-repeat");
+       ctx.fillStyle = pn;
+       ctx.translate(160, 0);
+       ctx.strokeRect(0, 0, 150, 150);
+       ctx.fillRect(0, 0, 150, 150);
+    
+       py = ctx.createPattern(i, "repeat-y");
+       ctx.fillStyle = py;
+       ctx.translate(0, -160);
+       ctx.strokeRect(0, 0, 150, 150);
+       ctx.fillRect(0, 0, 150, 150);
+       
+       if (window.layoutTestController)
+           layoutTestController.notifyDone();
+               }
+   }
+  </script>
+ </head>
+ <body>
+  <p>There should be one big square below containing four squares. Top left square should be filled with 3 rows of 2 and bit Apple images. Top right square should be 2 and a bit rows with one Apple image column along the left edge of the square. Bottom left square should be one row with three Apple images along the top of the square. Bottom right square should be one Apple image in top left corner.</p>
+  <p><canvas height="330" width="330"></canvas></p>
+ </body>
+</html>
index f459ff77b0d0f634b6cd3b6a77a7044eab1ed9ed..7f6a6b8a2d9b9015df855b2b3095915fe474e63e 100644 (file)
@@ -1,3 +1,16 @@
+2006-03-18  David Carson  <dacarson@gmail.com>
+
+        Test: fast/canvas/patternfill-repeat.html
+
+        Reviewed by Darin.
+
+        - fix http://bugzilla.opendarwin.org/show_bug.cgi?id=7830
+          <canvas> createPattern 'repeat' options fail
+
+        * CanvasPattern.cpp (CanvasPattern::createPattern)
+        Change stepping so that repeat-x, repeat-y, and no-repeat repeat 
+        outside the view area by using large values for repeat interval.
+
 2006-03-18  Mitz Pettel  <opendarwin.org@mitzpettel.com>
 
         Test: fast/dom/Element/class-attribute-whitespace.html
index 65c91863cf12ee54a2f5a02c544a5b38608b1dad..2a4fd345726183d14b87a45d6e27b0d27de957c9 100644 (file)
@@ -85,8 +85,13 @@ CGPatternRef CanvasPattern::createPattern(const CGAffineTransform& transform)
     CGAffineTransform patternTransform =
         CGAffineTransformTranslate(CGAffineTransformScale(transform, 1, -1), 0, -image->height());
 
-    float xStep = m_repeatX ? image->width() : 0;
-    float yStep = m_repeatY ? image->height() : 0;
+    float xStep = m_repeatX ? image->width() : FLT_MAX;
+    // If FLT_MAX should also be used for yStep, nothing is rendered. Using fractions of FLT_MAX also
+    // result in nothing being rendered. This is not a problem with xStep.
+    // INT_MAX is almost correct, but there seems to be some number wrapping occuring making the fill
+    // pattern is not filled correctly. 
+    // So, just pick a really large number that works. 
+    float yStep = m_repeatY ? image->height() : (100000000.0);
 
     const CGPatternCallbacks patternCallbacks = { 0, patternCallback, patternReleaseCallback };
     ref();