2006-08-11 Eric Seidel <eric@eseidel.com>
authoreseidel <eseidel@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 12 Aug 2006 04:07:25 +0000 (04:07 +0000)
committereseidel <eseidel@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 12 Aug 2006 04:07:25 +0000 (04:07 +0000)
        Reviewed by andersca.

        The outermost <svg> element needs to clip itself
        http://bugzilla.opendarwin.org/show_bug.cgi?id=5358

        * css/cssstyleselector.cpp:
        (WebCore::CSSStyleSelector::adjustRenderStyle): adjust for SVG overflow rules
        * kcanvas/RenderSVGContainer.cpp:
        (WebCore::RenderSVGContainer::requiresLayer): only require layers for absolute/relative positioning of outermost SVG
        (WebCore::RenderSVGContainer::paint):
        * kcanvas/device/KRenderingDevice.h:
        * kcanvas/device/quartz/KRenderingDeviceQuartz.h: remove dead methods
        * kcanvas/device/quartz/KRenderingDeviceQuartz.mm: remove dead methods
        (WebCore::KRenderingDeviceContextQuartz::KRenderingDeviceContextQuartz):
        * ksvg2/svg/SVGPaint.cpp: spacing changes
        (WebCore::SVGPaint::SVGPaint): spacing cleanup
        * ksvg2/svg/SVGSVGElement.cpp:
        (WebCore::SVGSVGElement::parseMappedAttribute): spacing cleanup
        * platform/GraphicsContext.h: Added concatCTM
        * platform/cg/GraphicsContextCG.cpp:
        (WebCore::GraphicsContext::concatCTM): Added.

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

19 files changed:
LayoutTests/ChangeLog
LayoutTests/svg/W3C-SVG-1.1/coords-viewattr-01-b-expected.checksum
LayoutTests/svg/W3C-SVG-1.1/coords-viewattr-01-b-expected.png
LayoutTests/svg/W3C-SVG-1.1/masking-path-03-b-expected.checksum
LayoutTests/svg/W3C-SVG-1.1/masking-path-03-b-expected.png
LayoutTests/svg/custom/svg-overflow-types-expected.checksum [new file with mode: 0644]
LayoutTests/svg/custom/svg-overflow-types-expected.png [new file with mode: 0644]
LayoutTests/svg/custom/svg-overflow-types-expected.txt [new file with mode: 0644]
LayoutTests/svg/custom/svg-overflow-types.svg [new file with mode: 0644]
WebCore/ChangeLog
WebCore/css/cssstyleselector.cpp
WebCore/kcanvas/RenderSVGContainer.cpp
WebCore/kcanvas/device/KRenderingDevice.h
WebCore/kcanvas/device/quartz/KRenderingDeviceQuartz.h
WebCore/kcanvas/device/quartz/KRenderingDeviceQuartz.mm
WebCore/ksvg2/svg/SVGPaint.cpp
WebCore/ksvg2/svg/SVGSVGElement.cpp
WebCore/platform/GraphicsContext.h
WebCore/platform/cg/GraphicsContextCG.cpp

index fd36b3f237316acbdadbb4615dbc9c7a8db4a21f..8b9357a47147fff4f38960fe6224e631825f0ece 100644 (file)
@@ -1,3 +1,20 @@
+2006-08-11  Eric Seidel  <eric@eseidel.com>
+
+        Reviewed by andersca.
+        
+        Updated results, and new test for:
+        The outermost <svg> element needs to clip itself
+        http://bugzilla.opendarwin.org/show_bug.cgi?id=5358
+
+        * svg/W3C-SVG-1.1/coords-viewattr-01-b-expected.checksum:
+        * svg/W3C-SVG-1.1/coords-viewattr-01-b-expected.png:
+        * svg/W3C-SVG-1.1/masking-path-03-b-expected.checksum:
+        * svg/W3C-SVG-1.1/masking-path-03-b-expected.png:
+        * svg/custom/svg-overflow-types-expected.checksum: Added.
+        * svg/custom/svg-overflow-types-expected.png: Added.
+        * svg/custom/svg-overflow-types-expected.txt: Added.
+        * svg/custom/svg-overflow-types.svg: Added.
+
 2006-08-11  Adele Peterson  <adele@apple.com>
 
         Reviewed by Brady.
index 94e10c47147cde575521e26a29e882ef24f57ac3..c5648d6646e2dcf99484cf287742959b870fddf0 100644 (file)
@@ -1 +1 @@
-9742a7f70e5cbd05e5e5355f9386931d
\ No newline at end of file
+4449e6ebccb1b1b0d9ec1159af17f1f3
\ No newline at end of file
index 7a36cef75041bf16d1f676b7dd9de89a3480e894..10c922d70270a8b7153d7e0cc45f61b76d4f2330 100644 (file)
Binary files a/LayoutTests/svg/W3C-SVG-1.1/coords-viewattr-01-b-expected.png and b/LayoutTests/svg/W3C-SVG-1.1/coords-viewattr-01-b-expected.png differ
index c1cbf0dae0b1f9b58966e611d161e0a3eae60576..05b1024e8ba244bb11d0690a636b1bba4c6c26e3 100644 (file)
@@ -1 +1 @@
-35926a21e4cfd298e0a02d9c56b14c42
\ No newline at end of file
+8aa4ab10cb39b335f46c9b5bd998dfcc
\ No newline at end of file
index 21292bf4db809448f1a640eb808955bf7d9b53f2..b6a869a7172ea877c69d59decfc0eeb142ee4981 100644 (file)
Binary files a/LayoutTests/svg/W3C-SVG-1.1/masking-path-03-b-expected.png and b/LayoutTests/svg/W3C-SVG-1.1/masking-path-03-b-expected.png differ
diff --git a/LayoutTests/svg/custom/svg-overflow-types-expected.checksum b/LayoutTests/svg/custom/svg-overflow-types-expected.checksum
new file mode 100644 (file)
index 0000000..da9d1ae
--- /dev/null
@@ -0,0 +1 @@
+76df8d127c7a82c815d0b0dc15cb2462
\ No newline at end of file
diff --git a/LayoutTests/svg/custom/svg-overflow-types-expected.png b/LayoutTests/svg/custom/svg-overflow-types-expected.png
new file mode 100644 (file)
index 0000000..1188001
Binary files /dev/null and b/LayoutTests/svg/custom/svg-overflow-types-expected.png differ
diff --git a/LayoutTests/svg/custom/svg-overflow-types-expected.txt b/LayoutTests/svg/custom/svg-overflow-types-expected.txt
new file mode 100644 (file)
index 0000000..32256fc
--- /dev/null
@@ -0,0 +1,29 @@
+layer at (0,0) size 800x600
+  RenderView at (0,0) size 800x600
+    KCanvasContainer {svg} at (0,0) size 400x400
+      KCanvasItem {rect} at (0,0) size 200x200 [fill={[type=SOLID] [color=#008000]}] [data="M0.00,0.00L200.00,0.00L200.00,200.00L0.00,200.00"]
+      KCanvasContainer {svg} at (0,0) size 200x200
+        KCanvasItem {rect} at (0,0) size 200x200 [fill={[type=SOLID] [color=#FF0000]}] [data="M0.00,0.00L200.00,0.00L200.00,200.00L0.00,200.00"]
+        KCanvasItem {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"]
+      RenderSVGText {text} at (0,0) size 785x18
+        RenderText {#text} at (0,0) size 108x18
+          text run at (0,0) width 108: "overflow: hidden"
+      KCanvasItem {rect} at (200,0) size 200x200 [fill={[type=SOLID] [color=#008000]}] [data="M200.00,0.00L400.00,0.00L400.00,200.00L200.00,200.00"]
+      KCanvasContainer {svg} at (0,0) size 200x200
+        KCanvasItem {rect} at (0,0) size 200x200 [fill={[type=SOLID] [color=#FF0000]}] [data="M0.00,0.00L200.00,0.00L200.00,200.00L0.00,200.00"]
+        KCanvasItem {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"]
+      RenderSVGText {text} at (0,0) size 785x18
+        RenderText {#text} at (0,0) size 99x18
+          text run at (0,0) width 99: "overflow: scroll"
+      KCanvasItem {rect} at (0,200) size 200x200 [fill={[type=SOLID] [color=#FF0000]}] [data="M0.00,200.00L200.00,200.00L200.00,400.00L0.00,400.00"]
+      KCanvasContainer {svg} at (0,0) size 200x200
+        KCanvasItem {rect} at (0,0) size 200x200 [fill={[type=SOLID] [color=#008000]}] [data="M0.00,0.00L200.00,0.00L200.00,200.00L0.00,200.00"]
+      RenderSVGText {text} at (0,0) size 785x18
+        RenderText {#text} at (0,0) size 92x18
+          text run at (0,0) width 92: "overflow: auto"
+      KCanvasItem {rect} at (200,200) size 200x200 [fill={[type=SOLID] [color=#FF0000]}] [data="M200.00,200.00L400.00,200.00L400.00,400.00L200.00,400.00"]
+      KCanvasContainer {svg} at (0,0) size 200x200
+        KCanvasItem {rect} at (0,0) size 200x200 [fill={[type=SOLID] [color=#008000]}] [data="M0.00,0.00L200.00,0.00L200.00,200.00L0.00,200.00"]
+      RenderSVGText {text} at (0,0) size 785x18
+        RenderText {#text} at (0,0) size 106x18
+          text run at (0,0) width 106: "overflow: visible"
diff --git a/LayoutTests/svg/custom/svg-overflow-types.svg b/LayoutTests/svg/custom/svg-overflow-types.svg
new file mode 100644 (file)
index 0000000..ac765f9
--- /dev/null
@@ -0,0 +1,33 @@
+<?xml version="1.0" ?> 
+<svg xmlns="http://www.w3.org/2000/svg" width="400" height="400">
+
+  <rect x='0' y='0' width='200' height='200' fill="green" />
+  <svg x='0' y='0' width="100" height="100" style="overflow: hidden">
+    <rect x='0' y='0' width='200' height='200' fill="red" />
+    <rect x='0' y='0' width='100' height='100' fill="green" />
+  </svg>
+  <text x='50' y='100'>overflow: hidden</text>
+  
+  
+  <rect x='200' y='0' width='200' height='200' fill="green" />
+  <svg x='200' y='0' width="100" height="100" style="overflow: scroll">
+    <rect x='0' y='0' width='200' height='200' fill="red" />
+    <rect x='0' y='0' width='100' height='100' fill="green" />
+  </svg>
+  <text x='250' y='100'>overflow: scroll</text>
+  
+  
+  <rect x='0' y='200' width='200' height='200' fill="red" />
+  <svg x='0' y='200' width="100" height="100" style="overflow: auto">
+    <rect x='0' y='0' width='200' height='200' fill="green" />
+  </svg>
+  <text x='50' y='300'>overflow: auto</text>
+  
+  
+  <rect x='200' y='200' width='200' height='200' fill="red" />
+  <svg x='200' y='200' width="100" height="100" style="overflow: visible">
+    <rect x='0' y='0' width='200' height='200' fill="green" />
+  </svg>
+  <text x='250' y='300'>overflow: visible</text>
+  
+</svg>
index 67d0e8abb413b66a50d61990960b27698c79ec66..ccab31af2bebb5903f04a92b4c0fbc3bf400a6e8 100644 (file)
@@ -1,3 +1,27 @@
+2006-08-11  Eric Seidel  <eric@eseidel.com>
+
+        Reviewed by andersca.
+
+        The outermost <svg> element needs to clip itself
+        http://bugzilla.opendarwin.org/show_bug.cgi?id=5358
+
+        * css/cssstyleselector.cpp:
+        (WebCore::CSSStyleSelector::adjustRenderStyle): adjust for SVG overflow rules
+        * kcanvas/RenderSVGContainer.cpp:
+        (WebCore::RenderSVGContainer::requiresLayer): only require layers for absolute/relative positioning of outermost SVG
+        (WebCore::RenderSVGContainer::paint):
+        * kcanvas/device/KRenderingDevice.h:
+        * kcanvas/device/quartz/KRenderingDeviceQuartz.h: remove dead methods
+        * kcanvas/device/quartz/KRenderingDeviceQuartz.mm: remove dead methods
+        (WebCore::KRenderingDeviceContextQuartz::KRenderingDeviceContextQuartz):
+        * ksvg2/svg/SVGPaint.cpp: spacing changes
+        (WebCore::SVGPaint::SVGPaint): spacing cleanup
+        * ksvg2/svg/SVGSVGElement.cpp:
+        (WebCore::SVGSVGElement::parseMappedAttribute): spacing cleanup
+        * platform/GraphicsContext.h: Added concatCTM
+        * platform/cg/GraphicsContextCG.cpp:
+        (WebCore::GraphicsContext::concatCTM): Added.
+
 2006-08-11  Brady Eidson  <beidson@apple.com>
 
         Reviewed by Maciej
index 5ce9e790673e92562bfc7d5a39fe459a8c60e1d3..a38adbd3870c126270d4d3abbe132281af102e5a 100644 (file)
@@ -1086,6 +1086,21 @@ void CSSStyleSelector::adjustRenderStyle(RenderStyle* style, Element *e)
         else
             theme()->adjustStyle(this, style, e);
     }
+    
+#ifdef SVG_SUPPORT
+    if (e->isSVGElement()) {
+        // Spec: http://www.w3.org/TR/SVG/masking.html#OverflowProperty
+        if (style->overflowY() == OSCROLL)
+            style->setOverflowY(OHIDDEN);
+        else if (style->overflowY() == OAUTO)
+            style->setOverflowY(OVISIBLE);
+        
+        if (style->overflowX() == OSCROLL)
+            style->setOverflowX(OHIDDEN);
+        else if (style->overflowX() == OAUTO)
+            style->setOverflowX(OVISIBLE);
+    }
+#endif
 }
 
 void CSSStyleSelector::updateFont()
index 4f88daaf56d672b31106bde270b583c9660ced7c..580c8dbb70beb4a39e74f9b1fc798e5a04d7d26e 100644 (file)
@@ -85,7 +85,8 @@ bool RenderSVGContainer::canHaveChildren() const
     
 bool RenderSVGContainer::requiresLayer()
 {
-    return false;
+    // Only allow an <svg> element to generate a layer when it's positioned in a non-SVG context
+    return (isPositioned() || isRelPositioned()) && (parent() && !parent()->element()->isSVGElement());
 }
 
 short RenderSVGContainer::lineHeight(bool b, bool isRootLineBox) const
@@ -126,7 +127,7 @@ void RenderSVGContainer::layout()
     RenderContainer::layout();
 }
 
-void RenderSVGContainer::paint(PaintInfo &paintInfo, int parentX, int parentY)
+void RenderSVGContainer::paint(PaintInfopaintInfo, int parentX, int parentY)
 {
     if (paintInfo.p->paintingDisabled())
         return;
@@ -165,8 +166,11 @@ void RenderSVGContainer::paint(PaintInfo &paintInfo, int parentX, int parentY)
         parentX = parentY = 0;
     }
     
-    if (!viewport().isEmpty())
+    if (!viewport().isEmpty()) {
+        if (style()->overflowX() != OVISIBLE)
+            paintInfo.p->addClip(enclosingIntRect(viewport())); // FIXME: Eventually we'll want float-precision clipping
         deviceContext->concatCTM(AffineTransform().translate(viewport().x(), viewport().y()));
+    }
     
     if (!localTransform().isIdentity())
         deviceContext->concatCTM(localTransform());
index 156a65dee79718ad9cc8deb90a94f3976c2eb25f..5fc729a3f457718789c65a4e6682ecb72c84cada 100644 (file)
@@ -39,10 +39,7 @@ public:
 
     virtual KCanvasMatrix concatCTM(const KCanvasMatrix &worldMatrix) = 0;
     virtual KCanvasMatrix ctm() const = 0;
-    
-    virtual IntRect mapFromVisual(const IntRect &rect) = 0;
-    virtual IntRect mapToVisual(const IntRect &rect) = 0;
-    
+        
     virtual void clearPath() = 0;
     virtual void addPath(const KCanvasPath*) = 0;
 
index a49970396dd07590f0054fbdc4de5879f600bf63..218e576a55c262ee20efb19b84136605fc1db530 100644 (file)
@@ -49,9 +49,6 @@ public:
     virtual KCanvasMatrix concatCTM(const KCanvasMatrix &worldMatrix);
     virtual KCanvasMatrix ctm() const;
     
-    virtual IntRect mapFromVisual(const IntRect &rect);
-    virtual IntRect mapToVisual(const IntRect &rect);
-    
     virtual void clearPath();
     virtual void addPath(const KCanvasPath*);
 
index 9bba0aa4b8bece1cf147eaf2f6cc4252a2e5f1b8..9cd535fd2b770c8f2c17489d84838424915668b2 100644 (file)
@@ -44,7 +44,9 @@
 
 namespace WebCore {
 
-KRenderingDeviceContextQuartz::KRenderingDeviceContextQuartz(CGContextRef context) : m_cgContext(CGContextRetain(context)), m_nsGraphicsContext(0)
+KRenderingDeviceContextQuartz::KRenderingDeviceContextQuartz(CGContextRef context)
+    : m_cgContext(CGContextRetain(context))
+    , m_nsGraphicsContext(0)
 {
     ASSERT(m_cgContext);
 }
@@ -70,16 +72,6 @@ KCanvasMatrix KRenderingDeviceContextQuartz::ctm() const
     return KCanvasMatrix(contextCTM.a, contextCTM.b, contextCTM.c, contextCTM.d, contextCTM.tx, contextCTM.ty);
 }
 
-IntRect KRenderingDeviceContextQuartz::mapFromVisual(const IntRect &rect)
-{
-    return IntRect();
-}
-
-IntRect KRenderingDeviceContextQuartz::mapToVisual(const IntRect &rect)
-{
-    return IntRect();
-}
-
 void KRenderingDeviceContextQuartz::clearPath()
 {
     CGContextBeginPath(m_cgContext);
index 4f586e3e14f19ac69805875b29ea947ce950cf98..2d65e51297b98b35bed5156094d72c14caee8120 100644 (file)
 #include "ksvg.h"
 #include "SVGPaint.h"
 
-using namespace WebCore;
+namespace WebCore {
 
-SVGPaint::SVGPaint() : SVGColor()
+SVGPaint::SVGPaint()
+    : SVGColor()
 {
     m_paintType = SVG_PAINTTYPE_UNKNOWN;
 }
 
-SVGPaint::SVGPaint(StringImpl *uri) : SVGColor()
+SVGPaint::SVGPaint(StringImpl *uri)
+    : SVGColor()
 {
     m_paintType = SVG_PAINTTYPE_URI;
     setUri(uri);
 }
 
-SVGPaint::SVGPaint(unsigned short paintType) : SVGColor()
+SVGPaint::SVGPaint(unsigned short paintType)
+    : SVGColor()
 {
     m_paintType = paintType;
 }
 
-SVGPaint::SVGPaint(unsigned short paintType, StringImpl *uri, StringImpl *rgbPaint, StringImpl *) : SVGColor(rgbPaint)
+SVGPaint::SVGPaint(unsigned short paintType, StringImpl *uri, StringImpl *rgbPaint, StringImpl *)
+    : SVGColor(rgbPaint)
 {
     m_paintType = paintType;
     setUri(uri);
@@ -90,6 +94,8 @@ String SVGPaint::cssText() const
     return SVGColor::cssText();
 }
 
+}
+
 // vim:ts=4:noet
 #endif // SVG_SUPPORT
 
index e5f3e9d18369972f37da3911bc9f695f8d983110..b2b08b6ab149ee9a17d177b55e5ced478d32965b 100644 (file)
@@ -247,16 +247,19 @@ void SVGSVGElement::parseMappedAttribute(MappedAttribute *attr)
     } else if (attr->name() == SVGNames::heightAttr) {
         height()->baseVal()->setValueAsString(value.impl());
         addCSSProperty(attr, CSS_PROP_HEIGHT, value);
-    } else
-    {
-        if(SVGTests::parseMappedAttribute(attr)) return;
-        if(SVGLangSpace::parseMappedAttribute(attr)) return;
-        if(SVGExternalResourcesRequired::parseMappedAttribute(attr)) return;
+    } else {
+        if (SVGTests::parseMappedAttribute(attr))
+            return;
+        if (SVGLangSpace::parseMappedAttribute(attr))
+            return;
+        if (SVGExternalResourcesRequired::parseMappedAttribute(attr))
+            return;
         if (SVGFitToViewBox::parseMappedAttribute(attr)) {
             if (renderer())
                 static_cast<RenderSVGContainer*>(renderer())->setViewBox(FloatRect(viewBox()->baseVal()->x(), viewBox()->baseVal()->y(), viewBox()->baseVal()->width(), viewBox()->baseVal()->height()));
         }
-        if(SVGZoomAndPan::parseMappedAttribute(attr)) return;
+        if (SVGZoomAndPan::parseMappedAttribute(attr))
+            return;
 
         SVGStyledLocatableElement::parseMappedAttribute(attr);
     }
index 4ebd4d8cff5ae2b034bcfd1d2243795bd2f7368e..304b6d6244108de7b17051f60ada7236ded57f74 100644 (file)
@@ -54,6 +54,7 @@ namespace WebCore {
     const int cMisspellingLinePatternWidth = 4;
     const int cMisspellingLinePatternGapWidth = 1;
 
+    class AffineTransform;
     class DeprecatedString;
     class Font;
     class GraphicsContextPrivate;
@@ -155,6 +156,8 @@ namespace WebCore {
         void scale(const FloatSize&);
         void rotate(float angleInRadians);
         void translate(const FloatSize&);
+        
+        void concatCTM(const AffineTransform&);
 
 #ifdef SVG_SUPPORT
         KRenderingDeviceContext* createRenderingDeviceContext();
index 76f86422f8a2995a824b916d9e5f9d54ff556349..5aa9c265304994d329e03f17537392f34138a3bb 100644 (file)
@@ -26,6 +26,7 @@
 #include "config.h"
 #include "GraphicsContext.h"
 
+#include "AffineTransform.h"
 #include "KRenderingDeviceQuartz.h"
 #include "Path.h"
 
@@ -634,6 +635,13 @@ void GraphicsContext::translate(const FloatSize& size)
     CGContextTranslateCTM(platformContext(), size.width(), size.height());
 }
 
+void GraphicsContext::concatCTM(const AffineTransform& transform)
+{
+    if (paintingDisabled())
+        return;
+    CGContextConcatCTM(platformContext(), transform);
+}
+
 FloatRect GraphicsContext::roundToDevicePixels(const FloatRect& rect)
 {
     // It is not enough just to round to pixels in device space. The rotation part of the