Reviewed by Mitz.
authorrwlbuis@webkit.org <rwlbuis@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 6 Dec 2007 07:40:57 +0000 (07:40 +0000)
committerrwlbuis@webkit.org <rwlbuis@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 6 Dec 2007 07:40:57 +0000 (07:40 +0000)
        http://bugs.webkit.org/show_bug.cgi?id=15289
        WebKit does not respect clip paths of a 0x0 rect

        Make empty clip paths clip the whole referencing graphic.

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

14 files changed:
LayoutTests/ChangeLog
LayoutTests/platform/mac/svg/W3C-SVG-1.1/masking-path-04-b-expected.png
LayoutTests/platform/mac/svg/W3C-SVG-1.1/masking-path-04-b-expected.txt
LayoutTests/platform/mac/svg/batik/text/textEffect2-expected.checksum
LayoutTests/platform/mac/svg/batik/text/textEffect2-expected.png
LayoutTests/platform/mac/svg/batik/text/textProperties-expected.checksum
LayoutTests/platform/mac/svg/batik/text/textProperties-expected.png
LayoutTests/svg/custom/empty-clip-path-expected.checksum [new file with mode: 0644]
LayoutTests/svg/custom/empty-clip-path-expected.png [new file with mode: 0644]
LayoutTests/svg/custom/empty-clip-path-expected.txt [new file with mode: 0644]
LayoutTests/svg/custom/empty-clip-path.svg [new file with mode: 0644]
WebCore/ChangeLog
WebCore/svg/SVGClipPathElement.cpp
WebCore/svg/graphics/SVGResourceClipper.h

index 451382f..c088a5e 100644 (file)
@@ -1,3 +1,22 @@
+2007-12-05  Rob Buis  <buis@kde.org>
+
+        Reviewed by Mitz.
+
+        Testcase for:
+        http://bugs.webkit.org/show_bug.cgi?id=15289
+        WebKit does not respect clip paths of a 0x0 rect
+
+        * platform/mac/svg/W3C-SVG-1.1/masking-path-04-b-expected.png:
+        * platform/mac/svg/W3C-SVG-1.1/masking-path-04-b-expected.txt:
+        * platform/mac/svg/batik/text/textEffect2-expected.checksum:
+        * platform/mac/svg/batik/text/textEffect2-expected.png:
+        * platform/mac/svg/batik/text/textProperties-expected.checksum:
+        * platform/mac/svg/batik/text/textProperties-expected.png:
+        * svg/custom/empty-clip-path-expected.checksum: Added.
+        * svg/custom/empty-clip-path-expected.png: Added.
+        * svg/custom/empty-clip-path-expected.txt: Added.
+        * svg/custom/empty-clip-path.svg: Added.
+
 2007-12-05  Alice Liu  <alice.liu@apple.com>
 
         Reviewed by Antti.
index 77de231..ac5bbd1 100644 (file)
Binary files a/LayoutTests/platform/mac/svg/W3C-SVG-1.1/masking-path-04-b-expected.png and b/LayoutTests/platform/mac/svg/W3C-SVG-1.1/masking-path-04-b-expected.png differ
index 0c8b972..d0a33b4 100644 (file)
@@ -1,4 +1,4 @@
-KCanvasResource {id="sample" [type=CLIPPER] [clip data=[]]}
+KCanvasResource {id="sample" [type=CLIPPER] [clip data=[[winding=EVEN-ODD] [path=M0.00,0.00L0.00,0.00L0.00,0.00L0.00,0.00]]]}
 layer at (0,0) size 480x360
   RenderView at (0,0) size 480x360
 layer at (0,0) size 480x360
index 9ebd7c9..ede1b02 100644 (file)
Binary files a/LayoutTests/platform/mac/svg/batik/text/textEffect2-expected.png and b/LayoutTests/platform/mac/svg/batik/text/textEffect2-expected.png differ
index 2c8cc3b..861286a 100644 (file)
Binary files a/LayoutTests/platform/mac/svg/batik/text/textProperties-expected.png and b/LayoutTests/platform/mac/svg/batik/text/textProperties-expected.png differ
diff --git a/LayoutTests/svg/custom/empty-clip-path-expected.checksum b/LayoutTests/svg/custom/empty-clip-path-expected.checksum
new file mode 100644 (file)
index 0000000..d06729f
--- /dev/null
@@ -0,0 +1 @@
+1438bcc295fb5bf73c1dccd4de804baa
\ No newline at end of file
diff --git a/LayoutTests/svg/custom/empty-clip-path-expected.png b/LayoutTests/svg/custom/empty-clip-path-expected.png
new file mode 100644 (file)
index 0000000..5a519b0
Binary files /dev/null and b/LayoutTests/svg/custom/empty-clip-path-expected.png differ
diff --git a/LayoutTests/svg/custom/empty-clip-path-expected.txt b/LayoutTests/svg/custom/empty-clip-path-expected.txt
new file mode 100644 (file)
index 0000000..e7e4650
--- /dev/null
@@ -0,0 +1,19 @@
+KCanvasResource {id="nothing" [type=CLIPPER] [clip data=[[winding=EVEN-ODD] [path=M0.00,0.00L0.00,0.00L0.00,0.00L0.00,0.00]]]}
+KCanvasResource {id="emptyrect" [type=CLIPPER] [clip data=[[winding=EVEN-ODD] [path=M0.00,0.00L0.00,0.00L0.00,0.00L0.00,0.00]]]}
+layer at (0,0) size 800x600
+  RenderView at (0,0) size 800x600
+layer at (0,0) size 800x600
+  RenderSVGRoot {svg} at (0,0) size 452x154
+    RenderSVGHiddenContainer {defs} at (0,0) size 0x0
+    RenderPath {rect} at (0,0) size 100x100 [fill={[type=SOLID] [color=#008000]}] [data="M0.00,0.00L100.00,0.00L100.00,100.00L0.00,100.00"]
+    RenderSVGContainer {g} at (0,0) size 100x100 [clip path="#nothing"]
+      RenderPath {rect} at (0,0) size 100x100 [fill={[type=SOLID] [color=#FF0000]}] [data="M0.00,0.00L100.00,0.00L100.00,100.00L0.00,100.00"]
+    RenderSVGContainer {g} at (0,0) size 100x100 [clip path="#emptyrect"]
+      RenderPath {rect} at (0,0) size 100x100 [fill={[type=SOLID] [color=#FF0000]}] [data="M0.00,0.00L100.00,0.00L100.00,100.00L0.00,100.00"]
+    RenderSVGContainer {g} at (0,116) size 452x38
+      RenderSVGText {text} at (0,130) size 287x18 contains 1 chunk(s)
+        RenderSVGInlineText {#text} at (0,-14) size 287x18
+          chunk 1 text run 1 at (0.00,130.00) startOffset 0 endOffset 44 width 287.00: "Above a green rectangle should be displayed."
+      RenderSVGText {text} at (0,150) size 452x18 contains 1 chunk(s)
+        RenderSVGInlineText {#text} at (0,-14) size 452x18
+          chunk 1 text run 1 at (0.00,150.00) startOffset 0 endOffset 74 width 452.00: "It tests that an empty clip path clips the referencing graphic. Bug 15289."
diff --git a/LayoutTests/svg/custom/empty-clip-path.svg b/LayoutTests/svg/custom/empty-clip-path.svg
new file mode 100644 (file)
index 0000000..4f6e692
--- /dev/null
@@ -0,0 +1,23 @@
+<svg xmlns="http://www.w3.org/2000/svg">
+  <defs>
+    <clipPath id="nothing">
+    </clipPath>
+    <clipPath id="emptyrect">
+      <rect width="0" height="0"/>
+    </clipPath>
+  </defs>
+
+  <rect fill="green" width="100" height="100"/>
+  <g clip-path="url(#nothing)" >
+    <rect width="100" height="100" fill="red"/>
+  </g>
+  <g clip-path="url(#emptyrect)" >
+    <rect width="100" height="100" fill="red"/>
+  </g>
+
+  <g>
+    <text y="130">Above a green rectangle should be displayed.</text>
+    <text y="150">It tests that an empty clip path clips the referencing graphic. Bug 15289.</text>
+  </g>
+</svg>
+
index 43737ea..afe4eb7 100644 (file)
@@ -1,3 +1,17 @@
+2007-12-05  Rob Buis  <buis@kde.org>
+
+        Reviewed by Mitz.
+
+        http://bugs.webkit.org/show_bug.cgi?id=15289
+        WebKit does not respect clip paths of a 0x0 rect
+
+        Make empty clip paths clip the whole referencing graphic.
+
+        * svg/SVGClipPathElement.cpp:
+        (WebCore::SVGClipPathElement::canvasResource):
+        * svg/graphics/SVGResourceClipper.h:
+        (WebCore::ClipDataList::isEmpty):
+
 2007-12-05  Darin Adler  <darin@apple.com>
 
         Reviewed by Maciej.
index 25559eb..fd6cd30 100644 (file)
@@ -88,6 +88,11 @@ SVGResource* SVGClipPathElement::canvasResource()
             pathStyle->deref(document()->renderArena());
         }
     }
+    if (m_clipper->clipData().isEmpty() ) {
+        Path pathData;
+        pathData.addRect(FloatRect());
+        m_clipper->addClipData(pathData, RULE_EVENODD, bbox);
+    }
     clipPathStyle->deref(document()->renderArena());
     return m_clipper.get();
 }
index f7425d2..d5c1ab7 100644 (file)
@@ -54,6 +54,7 @@ namespace WebCore {
         
         void clear() { m_clipData.clear(); }
         const Vector<ClipData>& clipData() const { return m_clipData; }
+        bool isEmpty() const { return m_clipData.isEmpty(); }
     private:
         Vector<ClipData> m_clipData;
     };