Fixes: http://bugs.webkit.org/show_bug.cgi?id=14153
authoroliver <oliver@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 12 Oct 2007 13:39:10 +0000 (13:39 +0000)
committeroliver <oliver@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 12 Oct 2007 13:39:10 +0000 (13:39 +0000)
Final, long-awaited RenderSVGContainer split. Make RenderSVGContainer really a simple
container without special cases for inner <svg> elements or <marker>. Create a new
RenderSVGViewportContainer class handling these cases now.

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

16 files changed:
LayoutTests/ChangeLog
LayoutTests/svg/custom/container-opacity-clip-viewBox-expected.txt
LayoutTests/svg/custom/root-container-opacity-clip-viewBox-expected.txt
LayoutTests/svg/custom/use-on-disallowed-foreign-object-5-expected.txt
LayoutTests/svg/custom/use-on-disallowed-foreign-object-6-expected.txt
LayoutTests/svg/custom/use-on-g-containing-symbol-expected.txt
WebCore/ChangeLog
WebCore/WebCore.xcodeproj/project.pbxproj
WebCore/ksvg2/svg/SVGMarkerElement.cpp
WebCore/ksvg2/svg/SVGSVGElement.cpp
WebCore/ksvg2/svg/SVGSVGElement.h
WebCore/rendering/RenderSVGContainer.cpp
WebCore/rendering/RenderSVGContainer.h
WebCore/rendering/RenderSVGRoot.cpp
WebCore/rendering/RenderSVGViewportContainer.cpp [new file with mode: 0644]
WebCore/rendering/RenderSVGViewportContainer.h [new file with mode: 0644]

index 06670113fd53c26b2c55567491437b21e40eb898..c0aac9279a791aa769060b486cee4d20f5e869c5 100644 (file)
@@ -1,3 +1,68 @@
+2007-08-10  Nikolas Zimmermann  <zimmermann@kde.org>
+
+        Reviewed by Rob.
+
+        Update tests after the RenderSVGViewportContainer introduction.
+
+        * svg/W3C-SVG-1.1/coords-viewattr-01-b-expected.txt:
+        * svg/W3C-SVG-1.1/coords-viewattr-03-b-expected.txt:
+        * svg/W3C-SVG-1.1/filters-color-01-b-expected.txt:
+        * svg/W3C-SVG-1.1/filters-comptran-01-b-expected.txt:
+        * svg/W3C-SVG-1.1/filters-example-01-b-expected.txt:
+        * svg/W3C-SVG-1.1/interact-events-01-b-expected.txt:
+        * svg/W3C-SVG-1.1/masking-path-03-b-expected.txt:
+        * svg/W3C-SVG-1.1/painting-marker-01-f-expected.txt:
+        * svg/W3C-SVG-1.1/painting-marker-02-f-expected.txt:
+        * svg/W3C-SVG-1.1/painting-marker-03-f-expected.txt:
+        * svg/W3C-SVG-1.1/struct-group-02-b-expected.txt:
+        * svg/W3C-SVG-1.1/struct-image-02-b-expected.txt:
+        * svg/W3C-SVG-1.1/struct-symbol-01-b-expected.txt:
+        * svg/W3C-SVG-1.1/types-basicDOM-01-b-expected.txt:
+        * svg/carto.net/button-expected.txt:
+        * svg/carto.net/colourpicker-expected.txt:
+        * svg/carto.net/scrollbar-expected.txt:
+        * svg/carto.net/slider-expected.txt:
+        * svg/carto.net/textbox-expected.txt:
+        * svg/carto.net/window-expected.txt:
+        * svg/custom/circular-marker-reference-1-expected.txt:
+        * svg/custom/circular-marker-reference-2-expected.txt:
+        * svg/custom/circular-marker-reference-3-expected.txt:
+        * svg/custom/circular-marker-reference-4-expected.txt:
+        * svg/custom/container-opacity-clip-viewBox-expected.txt:
+        * svg/custom/deep-dynamic-updates-expected.txt:
+        * svg/custom/feComponentTransfer-Discrete-expected.txt:
+        * svg/custom/feComponentTransfer-Gamma-expected.txt:
+        * svg/custom/feComponentTransfer-Linear-expected.txt:
+        * svg/custom/feComponentTransfer-Table-expected.txt:
+        * svg/custom/image-clipped-hit-expected.txt:
+        * svg/custom/inner-percent-expected.txt:
+        * svg/custom/inner-svg-hit-test-expected.txt:
+        * svg/custom/invalid-css-expected.txt:
+        * svg/custom/js-late-marker-and-object-creation-expected.txt:
+        * svg/custom/js-late-marker-creation-expected.txt:
+        * svg/custom/marker-changes-expected.txt:
+        * svg/custom/marker-child-changes-expected.txt:
+        * svg/custom/marker-default-width-height-expected.txt:
+        * svg/custom/marker-overflow-clip-expected.txt:
+        * svg/custom/marker-viewBox-changes-expected.txt:
+        * svg/custom/non-circular-marker-reference-expected.txt:
+        * svg/custom/preserve-aspect-ratio-syntax-expected.txt:
+        * svg/custom/root-container-opacity-clip-viewBox-expected.txt:
+        * svg/custom/shapes-supporting-markers-expected.txt:
+        * svg/custom/struct-use-09-b-expected.txt:
+        * svg/custom/svg-overflow-types-expected.txt:
+        * svg/custom/text-ctm-expected.txt:
+        * svg/custom/use-clipped-hit-expected.txt:
+        * svg/custom/use-css-events-expected.txt:
+        * svg/custom/use-modify-target-symbol-expected.txt:
+        * svg/custom/use-on-disallowed-foreign-object-5-expected.txt:
+        * svg/custom/use-on-disallowed-foreign-object-6-expected.txt:
+        * svg/custom/use-on-g-containing-symbol-expected.txt:
+        * svg/custom/use-on-symbol-expected.txt:
+        * svg/custom/use-on-symbol-inside-pattern-expected.txt:
+        * svg/custom/use-symbol-overflow-expected.txt:
+        * svg/custom/viewbox-syntax-expected.txt:
+
 2007-08-10  Nikolas Zimmermann  <zimmermann@kde.org>
 
         Reviewed by Oliver & Rob.
index 72b9754655388315ea8cf134ede55003706f83ab..876d6cca83a0f4b1d82be584acbf1c2b32d95e58 100644 (file)
@@ -2,9 +2,9 @@ layer at (0,0) size 800x600
   RenderView at (0,0) size 800x600
 layer at (0,0) size 800x600
   RenderSVGRoot {svg} at (50,38.20) size 363x225.80
-    RenderSVGContainer {svg} at (59.52,38.20) size 166x148 [opacity=0.90]
+    RenderSVGViewportContainer {svg} at (59.52,38.20) size 166x148 [opacity=0.90]
       RenderSVGContainer {g} at (59.52,38.20) size 166x148 [transform={m=((1.00,0.00)(0.00,1.00)) t=(59.52,38.20)}]
-        RenderSVGContainer {svg} at (59.52,38.20) size 166x148
+        RenderSVGViewportContainer {svg} at (59.52,38.20) size 166x148
           RenderPath {rect} at (59.52,38.20) size 166x148 [fill={[type=SOLID] [color=#008000]}] [data="M-83.00,-84.00L83.00,-84.00L83.00,64.00L-83.00,64.00"]
     RenderSVGContainer {g} at (50,216) size 363x48 [transform={m=((1.00,0.00)(0.00,1.00)) t=(50.00,230.00)}]
       RenderSVGText {text} at (0,0) size 363x48 contains 3 chunk(s)
index e949d6d72c632603eed23f3116c67822b828d041..e5ffe64ba0dd61ec5ac011ef7e123a729f643189 100644 (file)
@@ -2,5 +2,5 @@ layer at (0,0) size 800x600
   RenderView at (0,0) size 800x600
 layer at (0,0) size 800x600
   RenderSVGRoot {svg} at (0,0) size 166x148 [opacity=0.90]
-    RenderSVGContainer {svg} at (0,0) size 166x148
+    RenderSVGViewportContainer {svg} at (0,0) size 166x148
       RenderPath {rect} at (0,0) size 166x148 [fill={[type=SOLID] [color=#008000]}] [data="M-83.00,-84.00L83.00,-84.00L83.00,64.00L-83.00,64.00"]
index 914ef4819f39c1d631a52d78436f1c6ee514c513..3d4230a38376177c46366c0a8ccfc8130c29c034 100644 (file)
@@ -9,8 +9,8 @@ layer at (0,0) size 800x600
           text run at (0,0) width 244: "You should only see this string ONCE"
     RenderSVGContainer {use} at (0,0) size 0x0
       RenderSVGContainer {g} at (25,25) size 0x0 [transform={m=((1.00,0.00)(0.00,1.00)) t=(25.00,25.00)}]
-        RenderSVGContainer {svg} at (25,25) size 0x0
+        RenderSVGViewportContainer {svg} at (25,25) size 0x0
     RenderSVGContainer {use} at (0,0) size 0x0
       RenderSVGContainer {g} at (10,10) size 0x0 [transform={m=((1.00,0.00)(0.00,1.00)) t=(10.00,10.00)}]
         RenderSVGContainer {g} at (35,35) size 0x0 [transform={m=((1.00,0.00)(0.00,1.00)) t=(25.00,25.00)}]
-          RenderSVGContainer {svg} at (35,35) size 0x0
+          RenderSVGViewportContainer {svg} at (35,35) size 0x0
index 6c3ffaf8adbd589506119f4e71dee9fd967c471e..0bc48bfccd0ad541900a85ea1dd37986f6a76bd8 100644 (file)
@@ -3,7 +3,7 @@ layer at (0,0) size 800x600
 layer at (0,0) size 800x600
   RenderSVGRoot {svg} at (0,0) size 0x0
     RenderSVGHiddenContainer {defs} at (0,0) size 0x0
-      RenderSVGContainer {svg} at (0,0) size 0x0
+      RenderSVGViewportContainer {svg} at (0,0) size 0x0
         RenderForeignObject {foreignObject} at (0,0) size 580x380
           RenderBlock {xhtml:div} at (0,0) size 580x18
             RenderText {#text} at (0,0) size 244x18
@@ -14,8 +14,8 @@ layer at (0,0) size 800x600
           text run at (0,0) width 244: "You should only see this string ONCE"
     RenderSVGContainer {use} at (0,0) size 0x0
       RenderSVGContainer {g} at (25,25) size 0x0 [transform={m=((1.00,0.00)(0.00,1.00)) t=(25.00,25.00)}]
-        RenderSVGContainer {svg} at (25,25) size 0x0
+        RenderSVGViewportContainer {svg} at (25,25) size 0x0
     RenderSVGContainer {use} at (0,0) size 0x0
       RenderSVGContainer {g} at (10,10) size 0x0 [transform={m=((1.00,0.00)(0.00,1.00)) t=(10.00,10.00)}]
         RenderSVGContainer {g} at (35,35) size 0x0 [transform={m=((1.00,0.00)(0.00,1.00)) t=(25.00,25.00)}]
-          RenderSVGContainer {svg} at (35,35) size 0x0
+          RenderSVGViewportContainer {svg} at (35,35) size 0x0
index be5462c0cc0b850ef2587fd8cef8a6efb86942ae..f8e416b1b96c09ee562179e5f978ed72149cf223 100644 (file)
@@ -12,5 +12,5 @@ layer at (0,0) size 800x600
     RenderSVGContainer {use} at (45,45) size 130x30
       RenderSVGContainer {g} at (45,45) size 130x30 [transform={m=((1.00,0.00)(0.00,1.00)) t=(25.00,25.00)}]
         RenderSVGContainer {g} at (45,45) size 130x30
-          RenderSVGContainer {svg} at (45,45) size 130x30
+          RenderSVGViewportContainer {svg} at (45,45) size 130x30
             RenderPath {rect} at (45,45) size 130x30 [stroke={[type=SOLID] [color=#000080] [stroke width=5.00]}] [fill={[type=SOLID] [color=#FF0000]}] [data="M0.00,0.00L60.00,0.00L60.00,10.00L0.00,10.00"]
index e3eff1d6fe353936cfb3be5a39450d7dcb841df7..7bb53c6b1e8a12f9461ca6281e7d591d19dfa305 100644 (file)
@@ -1,3 +1,45 @@
+2007-08-10  Nikolas Zimmermann  <zimmermann@kde.org>
+
+        Reviewed by Rob.
+
+        Fixes: http://bugs.webkit.org/show_bug.cgi?id=14153
+
+        Final, long-awaited RenderSVGContainer split. Make RenderSVGContainer really a simple
+        container without special cases for inner <svg> elements or <marker>. Create a new
+        RenderSVGViewportContainer class handling these cases now.
+
+        * WebCore.xcodeproj/project.pbxproj:
+        * ksvg2/svg/SVGMarkerElement.cpp:
+        (WebCore::SVGMarkerElement::createRenderer):
+        * ksvg2/svg/SVGSVGElement.cpp:
+        (WebCore::SVGSVGElement::createRenderer):
+        * ksvg2/svg/SVGSVGElement.h:
+        * rendering/RenderSVGContainer.cpp:
+        (WebCore::RenderSVGContainer::layout):
+        (WebCore::RenderSVGContainer::applyContentTransforms):
+        (WebCore::RenderSVGContainer::applyAdditionalTransforms):
+        (WebCore::RenderSVGContainer::paint):
+        (WebCore::RenderSVGContainer::viewportTransform):
+        (WebCore::RenderSVGContainer::relativeBBox):
+        (WebCore::RenderSVGContainer::nodeAtPoint):
+        * rendering/RenderSVGContainer.h:
+        * rendering/RenderSVGRoot.cpp:
+        * rendering/RenderSVGViewportContainer.cpp: Added.
+        (WebCore::RenderSVGViewportContainer::RenderSVGViewportContainer):
+        (WebCore::RenderSVGViewportContainer::~RenderSVGViewportContainer):
+        (WebCore::RenderSVGViewportContainer::layout):
+        (WebCore::RenderSVGViewportContainer::paint):
+        (WebCore::RenderSVGViewportContainer::applyContentTransforms):
+        (WebCore::RenderSVGViewportContainer::applyAdditionalTransforms):
+        (WebCore::RenderSVGViewportContainer::viewport):
+        (WebCore::RenderSVGViewportContainer::calcViewport):
+        (WebCore::RenderSVGViewportContainer::viewportTransform):
+        (WebCore::RenderSVGViewportContainer::absoluteTransform):
+        (WebCore::RenderSVGViewportContainer::nodeAtPoint):
+        * rendering/RenderSVGViewportContainer.h: Added.
+        (WebCore::RenderSVGViewportContainer::isSVGContainer):
+        (WebCore::RenderSVGViewportContainer::renderName):
+
 2007-08-10  Nikolas Zimmermann  <zimmermann@kde.org>
 
         Reviewed by Oliver & Rob.
index a132a879fdcf93fdbc187bd1b46d0e67c0b131ec..7ca55f954903f9b55dc90fc729bba80657751d15 100644 (file)
                B2CB92620B5BDA02009BAA78 /* DOMSVGElementInstance.mm in Sources */ = {isa = PBXBuildFile; fileRef = B2CB925E0B5BDA02009BAA78 /* DOMSVGElementInstance.mm */; };
                B2CB92630B5BDA02009BAA78 /* DOMSVGElementInstanceList.h in Headers */ = {isa = PBXBuildFile; fileRef = B2CB925F0B5BDA02009BAA78 /* DOMSVGElementInstanceList.h */; };
                B2CB92640B5BDA02009BAA78 /* DOMSVGElementInstanceList.mm in Sources */ = {isa = PBXBuildFile; fileRef = B2CB92600B5BDA02009BAA78 /* DOMSVGElementInstanceList.mm */; };
+               B2CCEC470C6CA9F1006A5424 /* RenderSVGViewportContainer.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B2CCEC450C6CA9F1006A5424 /* RenderSVGViewportContainer.cpp */; };
+               B2CCEC480C6CA9F1006A5424 /* RenderSVGViewportContainer.h in Headers */ = {isa = PBXBuildFile; fileRef = B2CCEC460C6CA9F1006A5424 /* RenderSVGViewportContainer.h */; };
                B2D3FC8A0C2212CB00CF3618 /* JSSVGTransformListCustom.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B2D3FC890C2212CB00CF3618 /* JSSVGTransformListCustom.cpp */; };
                B2D87C770B124E7300B0DE1E /* SVGPaintServer.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B2D87C6B0B124E7300B0DE1E /* SVGPaintServer.cpp */; };
                B2D87C780B124E7300B0DE1E /* SVGPaintServer.h in Headers */ = {isa = PBXBuildFile; fileRef = B2D87C6C0B124E7300B0DE1E /* SVGPaintServer.h */; };
                B2CB925E0B5BDA02009BAA78 /* DOMSVGElementInstance.mm */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.objcpp; path = DOMSVGElementInstance.mm; sourceTree = "<group>"; };
                B2CB925F0B5BDA02009BAA78 /* DOMSVGElementInstanceList.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = DOMSVGElementInstanceList.h; sourceTree = "<group>"; };
                B2CB92600B5BDA02009BAA78 /* DOMSVGElementInstanceList.mm */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.objcpp; path = DOMSVGElementInstanceList.mm; sourceTree = "<group>"; };
+               B2CCEC450C6CA9F1006A5424 /* RenderSVGViewportContainer.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = RenderSVGViewportContainer.cpp; sourceTree = "<group>"; };
+               B2CCEC460C6CA9F1006A5424 /* RenderSVGViewportContainer.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = RenderSVGViewportContainer.h; sourceTree = "<group>"; };
                B2D3FC890C2212CB00CF3618 /* JSSVGTransformListCustom.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = JSSVGTransformListCustom.cpp; sourceTree = "<group>"; };
                B2D87C6B0B124E7300B0DE1E /* SVGPaintServer.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = SVGPaintServer.cpp; sourceTree = "<group>"; };
                B2D87C6C0B124E7300B0DE1E /* SVGPaintServer.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = SVGPaintServer.h; sourceTree = "<group>"; };
                                B26554E90B80D74900A50EC3 /* RenderSVGTextPath.h */,
                                853CA9D40AEEC5E9002372DC /* RenderSVGTSpan.cpp */,
                                853CA9D50AEEC5E9002372DC /* RenderSVGTSpan.h */,
+                               B2CCEC450C6CA9F1006A5424 /* RenderSVGViewportContainer.cpp */,
+                               B2CCEC460C6CA9F1006A5424 /* RenderSVGViewportContainer.h */,
                                A8DF4AE20980C42C0052981B /* RenderTable.cpp */,
                                A8DF4AE10980C42C0052981B /* RenderTable.h */,
                                A8DF4AE00980C42C0052981B /* RenderTableCell.cpp */,
                                B223622E0C3AF0710008CA9B /* DOMSVGTextPathElement.h in Headers */,
                                B223622F0C3AF0710008CA9B /* DOMSVGTextPathElementInternal.h in Headers */,
                                AA4038910C4C0D8B00DB56DC /* SVGViewSpec.h in Headers */,
+                               B2CCEC480C6CA9F1006A5424 /* RenderSVGViewportContainer.h in Headers */,
                        );
                        runOnlyForDeploymentPostprocessing = 0;
                };
                                B22362280C3AF04A0008CA9B /* JSSVGTextPathElement.cpp in Sources */,
                                B2AE9B9D0C3AF27400F23F7F /* DOMSVGTextPathElement.mm in Sources */,
                                AA4038900C4C0D8B00DB56DC /* SVGViewSpec.cpp in Sources */,
+                               B2CCEC470C6CA9F1006A5424 /* RenderSVGViewportContainer.cpp in Sources */,
                        );
                        runOnlyForDeploymentPostprocessing = 0;
                };
index 7004d3683b6f2c5c2857760562e314fd5080f7d8..93699c08908a74817906238dd9f4dcafec34867e 100644 (file)
@@ -26,7 +26,7 @@
 #include "SVGMarkerElement.h"
 
 #include "PlatformString.h"
-#include "RenderSVGContainer.h"
+#include "RenderSVGViewportContainer.h"
 #include "SVGAngle.h"
 #include "SVGFitToViewBox.h"
 #include "SVGLength.h"
@@ -135,7 +135,7 @@ SVGResource* SVGMarkerElement::canvasResource()
 
 RenderObject* SVGMarkerElement::createRenderer(RenderArena* arena, RenderStyle* style)
 {
-    RenderSVGContainer* markerContainer = new (arena) RenderSVGContainer(this);
+    RenderSVGViewportContainer* markerContainer = new (arena) RenderSVGViewportContainer(this);
     markerContainer->setDrawsContents(false); // Marker contents will be explicitly drawn.
     return markerContainer;
 }
index 9165670e823bc0d042f74f930d267fb4c7fc68f4..26a46e6789eed9a828223065021acac89ee4aef1 100644 (file)
@@ -36,7 +36,7 @@
 #include "FloatRect.h"
 #include "Frame.h"
 #include "HTMLNames.h"
-#include "RenderSVGContainer.h"
+#include "RenderSVGViewportContainer.h"
 #include "RenderSVGRoot.h"
 #include "SVGAngle.h"
 #include "SVGLength.h"
@@ -406,7 +406,7 @@ RenderObject* SVGSVGElement::createRenderer(RenderArena* arena, RenderStyle*)
     if (!parentNode()->isSVGElement())
         return new (arena) RenderSVGRoot(this);
     else
-        return new (arena) RenderSVGContainer(this);
+        return new (arena) RenderSVGViewportContainer(this);
 }
 
 void SVGSVGElement::insertedIntoDocument()
index 9bcb4470bd9f9e5f360e0f65e9adeb599393a352..a7e0f22a1cc71e5f5117eb4d17ae7732e9a642ae 100644 (file)
@@ -132,6 +132,8 @@ namespace WebCore
 
         friend class RenderSVGContainer;
         friend class RenderSVGRoot;
+        friend class RenderSVGViewportContainer;
+
         virtual bool hasRelativeValues() const;
 
     private:
index 0b586fe484c37096802268e6998beb1e69f32c23..16e46bea8307fff9a299b4b76adb2aa8f1834a2a 100644 (file)
 #include "AXObjectCache.h"
 #include "GraphicsContext.h"
 #include "RenderView.h"
-#include "SVGFitToViewBox.h"
-#include "SVGLength.h"
-#include "SVGMarkerElement.h"
 #include "SVGRenderSupport.h"
 #include "SVGResourceFilter.h"
-#include "SVGSVGElement.h"
 #include "SVGStyledElement.h"
 #include "SVGURIReference.h"
 
@@ -232,8 +228,6 @@ void RenderSVGContainer::layout()
 {
     ASSERT(needsLayout());
 
-    calcViewport();
-
     // Arbitrary affine transforms are incompatible with LayoutState.
     view()->disableLayoutState();
 
@@ -300,30 +294,20 @@ int RenderSVGContainer::calcReplacedHeight() const
 
 void RenderSVGContainer::applyContentTransforms(PaintInfo& paintInfo)
 {
-    // Only the root <svg> element should need any translations using the HTML/CSS system
-    // parentX, parentY are also non-zero for first-level kids of these
-    // CSS-transformed <svg> root-elements (due to RenderBox::paint) for any other element
-    // they should be 0.   m_x, m_y should always be 0 for non-root svg containers
-    if (!viewport().isEmpty()) {
-        if (style()->overflowX() != OVISIBLE)
-            paintInfo.context->clip(enclosingIntRect(viewport())); // FIXME: Eventually we'll want float-precision clipping
-        
-        paintInfo.context->concatCTM(AffineTransform().translate(viewport().x(), viewport().y()));
-    }
-
     if (!localTransform().isIdentity())
         paintInfo.context->concatCTM(localTransform());
 }
 
+void RenderSVGContainer::applyAdditionalTransforms(PaintInfo& paintInfo)
+{
+    // no-op
+}
+
 void RenderSVGContainer::paint(PaintInfo& paintInfo, int parentX, int parentY)
 {
     if (paintInfo.context->paintingDisabled() || !drawsContents())
         return;
 
-    // A value of zero disables rendering of the element. 
-    if (!viewport().isEmpty() && (viewport().width() <= 0. || viewport().height() <= 0.))
-        return;
-
     if (!firstChild()) {
 #if ENABLE(SVG_EXPERIMENTAL_FEATURES)
         // Spec: groups w/o children still may render filter content.
@@ -339,14 +323,13 @@ void RenderSVGContainer::paint(PaintInfo& paintInfo, int parentX, int parentY)
     applyContentTransforms(paintInfo);
 
     SVGResourceFilter* filter = 0;
-
     PaintInfo savedInfo(paintInfo);
 
     FloatRect boundingBox = relativeBBox(true);
     if (paintInfo.phase == PaintPhaseForeground)
         prepareToRenderSVGContent(this, paintInfo, boundingBox, filter); 
 
-    paintInfo.context->concatCTM(viewportTransform());
+    applyAdditionalTransforms(paintInfo);
 
     // default implementation. Just pass paint through to the children
     PaintInfo childInfo(paintInfo);
@@ -363,50 +346,8 @@ void RenderSVGContainer::paint(PaintInfo& paintInfo, int parentX, int parentY)
         paintOutline(paintInfo.context, m_absoluteBounds.x(), m_absoluteBounds.y(), m_absoluteBounds.width(), m_absoluteBounds.height(), style());
 }
 
-FloatRect RenderSVGContainer::viewport() const
-{
-    return m_viewport;
-}
-
-void RenderSVGContainer::calcViewport()
-{
-    SVGElement* svgelem = static_cast<SVGElement*>(element());
-    if (svgelem->hasTagName(SVGNames::svgTag)) {
-        SVGSVGElement* svg = static_cast<SVGSVGElement*>(element());
-
-        if (!selfNeedsLayout() && !svg->hasRelativeValues())
-            return;
-
-        float x = 0.0f;
-        float y = 0.0f;
-        if (parent()->isSVGContainer()) {
-            x = svg->x().value();
-            y = svg->y().value();
-        }
-        float w = svg->width().value();
-        float h = svg->height().value();
-        m_viewport = FloatRect(x, y, w, h);
-    } else if (svgelem->hasTagName(SVGNames::markerTag)) {
-        if (!selfNeedsLayout())
-            return;
-
-        SVGMarkerElement* svg = static_cast<SVGMarkerElement*>(element());
-        float w = svg->markerWidth().value();
-        float h = svg->markerHeight().value();
-        m_viewport = FloatRect(0.0f, 0.0f, w, h);
-    }
-}
-
 AffineTransform RenderSVGContainer::viewportTransform() const
 {
-    if (element()->hasTagName(SVGNames::svgTag)) {
-        SVGSVGElement* svg = static_cast<SVGSVGElement*>(element());
-        return svg->viewBoxToViewTransform(viewport().width(), viewport().height());
-    } else if (element()->hasTagName(SVGNames::markerTag)) {
-        SVGMarkerElement* marker = static_cast<SVGMarkerElement*>(element());
-        return marker->viewBoxToViewTransform(viewport().width(), viewport().height());
-    }
      return AffineTransform();
 }
 
@@ -440,39 +381,6 @@ void RenderSVGContainer::absoluteRects(Vector<IntRect>& rects, int, int, bool)
     rects.append(absoluteClippedOverflowRect());
 }
 
-AffineTransform RenderSVGContainer::absoluteTransform() const
-{
-    AffineTransform ctm = RenderObject::absoluteTransform();
-    ctm.translate(viewport().x(), viewport().y());
-    return viewportTransform() * ctm;
-}
-
-bool RenderSVGContainer::fillContains(const FloatPoint& p) const
-{
-    RenderObject* current = firstChild();
-    while (current != 0) {
-        if (current->isRenderPath() && static_cast<RenderPath*>(current)->fillContains(p))
-            return true;
-
-        current = current->nextSibling();
-    }
-
-    return false;
-}
-
-bool RenderSVGContainer::strokeContains(const FloatPoint& p) const
-{
-    RenderObject* current = firstChild();
-    while (current != 0) {
-        if (current->isRenderPath() && static_cast<RenderPath*>(current)->strokeContains(p))
-            return true;
-
-        current = current->nextSibling();
-    }
-
-    return false;
-}
-
 FloatRect RenderSVGContainer::relativeBBox(bool includeStroke) const
 {
     FloatRect rect;
@@ -481,9 +389,11 @@ FloatRect RenderSVGContainer::relativeBBox(bool includeStroke) const
     for (; current != 0; current = current->nextSibling()) {
         FloatRect childBBox = current->relativeBBox(includeStroke);
         FloatRect mappedBBox = current->localTransform().mapRect(childBBox);
+
         // <svg> can have a viewBox contributing to the bbox
         if (current->isSVGContainer())
             mappedBBox = static_cast<RenderSVGContainer*>(current)->viewportTransform().mapRect(mappedBBox);
+
         rect.unite(mappedBBox);
     }
 
@@ -492,32 +402,8 @@ FloatRect RenderSVGContainer::relativeBBox(bool includeStroke) const
 
 bool RenderSVGContainer::nodeAtPoint(const HitTestRequest& request, HitTestResult& result, int _x, int _y, int _tx, int _ty, HitTestAction hitTestAction)
 {
-    if (!viewport().isEmpty()
-        && style()->overflowX() == OHIDDEN
-        && style()->overflowY() == OHIDDEN) {
-        // Check if we need to do anything at all.
-        IntRect overflowBox = overflowRect(false);
-        overflowBox.move(_tx, _ty);
-        AffineTransform ctm = RenderObject::absoluteTransform();
-        ctm.translate(viewport().x(), viewport().y());
-        double localX, localY;
-        ctm.inverse().map(_x - _tx, _y - _ty, &localX, &localY);
-        if (!overflowBox.contains((int)localX, (int)localY))
-            return false;
-    }
-
-    int sx = 0;
-    int sy = 0;
-
-    // Respect parent translation offset for non-outermost <svg> elements.
-    // Outermost <svg> element is handled by RenderSVGRoot.
-    if (element()->hasTagName(SVGNames::svgTag)) {
-        sx = _tx;
-        sy = _ty;
-    }
-
     for (RenderObject* child = lastChild(); child; child = child->previousSibling()) {
-        if (child->nodeAtPoint(request, result, _x - sx, _y - sy, _tx, _ty, hitTestAction)) {
+        if (child->nodeAtPoint(request, result, _x, _y, _tx, _ty, hitTestAction)) {
             updateHitTestResult(result, IntPoint(_x - _tx, _y - _ty));
             return true;
         }
index b25849219d7aa3b461d833d990cf53d2b17dacfa..f8fbf31a1019ba0305966127fb1f2073ee0f3cef 100644 (file)
@@ -68,40 +68,35 @@ public:
 
     virtual bool isSVGContainer() const { return true; }
     virtual const char* renderName() const { return "RenderSVGContainer"; }
-        
+
     virtual bool requiresLayer();
     virtual short lineHeight(bool b, bool isRootLineBox = false) const;
     virtual short baselinePosition(bool b, bool isRootLineBox = false) const;
-    
+
     virtual void layout();
     virtual void paint(PaintInfo&, int parentX, int parentY);
-    
+
     virtual IntRect absoluteClippedOverflowRect();
     virtual void absoluteRects(Vector<IntRect>& rects, int tx, int ty, bool topLevel = true);
     virtual void addFocusRingRects(GraphicsContext*, int tx, int ty);
 
-    virtual AffineTransform absoluteTransform() const;
-
-    bool fillContains(const FloatPoint&) const;
-    bool strokeContains(const FloatPoint&) const;
     FloatRect relativeBBox(bool includeStroke = true) const;
-    
+
     virtual AffineTransform localTransform() const;
     void setLocalTransform(const AffineTransform&);
-   
-    FloatRect viewport() const;
 
-    AffineTransform viewportTransform() const;
-    
+    virtual AffineTransform viewportTransform() const;
+
     virtual bool nodeAtPoint(const HitTestRequest&, HitTestResult&, int x, int y, int tx, int ty, HitTestAction);
-    
+
+protected:
+    virtual void applyContentTransforms(PaintInfo&);
+    virtual void applyAdditionalTransforms(PaintInfo&);
+
 private:
-    void calcViewport(); 
     int calcReplacedWidth() const;
     int calcReplacedHeight() const;
 
-    void applyContentTransforms(PaintInfo&);
-
     RenderObject* m_firstChild;
     RenderObject* m_lastChild;
 
@@ -110,10 +105,9 @@ private:
 
     bool m_drawsContents : 1;
 
-    AffineTransform m_matrix;
-    
-    FloatRect m_viewport;
     IntRect m_absoluteBounds;
+
+    AffineTransform m_matrix;
 };
   
 } // namespace WebCore
index 0307fc8d3ad2cd0ed3fab3d75a20599aa91b30e2..56ee32b27a0aa029c1d32838a85794f40d5b5082 100644 (file)
@@ -249,32 +249,6 @@ AffineTransform RenderSVGRoot::absoluteTransform() const
     return svg->viewBoxToViewTransform(width(), height()) * ctm;
 }
 
-bool RenderSVGRoot::fillContains(const FloatPoint& p) const
-{
-    RenderObject* current = firstChild();
-    while (current != 0) {
-        if (current->isRenderPath() && static_cast<RenderPath*>(current)->fillContains(p))
-            return true;
-
-        current = current->nextSibling();
-    }
-
-    return false;
-}
-
-bool RenderSVGRoot::strokeContains(const FloatPoint& p) const
-{
-    RenderObject* current = firstChild();
-    while (current != 0) {
-        if (current->isRenderPath() && static_cast<RenderPath*>(current)->strokeContains(p))
-            return true;
-
-        current = current->nextSibling();
-    }
-
-    return false;
-}
-
 FloatRect RenderSVGRoot::relativeBBox(bool includeStroke) const
 {
     FloatRect rect;
diff --git a/WebCore/rendering/RenderSVGViewportContainer.cpp b/WebCore/rendering/RenderSVGViewportContainer.cpp
new file mode 100644 (file)
index 0000000..a649938
--- /dev/null
@@ -0,0 +1,170 @@
+/*
+    Copyright (C) 2004, 2005, 2007 Nikolas Zimmermann <zimmermann@kde.org>
+                  2004, 2005, 2007 Rob Buis <buis@kde.org>
+                  2007 Eric Seidel <eric@webkit.org>
+
+    This file is part of the KDE project
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Library General Public
+    License as published by the Free Software Foundation; either
+    version 2 of the License, or (at your option) any later version.
+
+    This library is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+    Library General Public License for more details.
+
+    You should have received a copy of the GNU Library General Public License
+    aint with this library; see the file COPYING.LIB.  If not, write to
+    the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+    Boston, MA 02111-1307, USA.
+*/
+
+#include "config.h"
+
+#if ENABLE(SVG)
+#include "RenderSVGViewportContainer.h"
+
+#include "GraphicsContext.h"
+#include "SVGMarkerElement.h"
+#include "SVGSVGElement.h"
+
+namespace WebCore {
+
+RenderSVGViewportContainer::RenderSVGViewportContainer(SVGStyledElement* node)
+    : RenderSVGContainer(node)
+{
+    setReplaced(true);
+}
+
+RenderSVGViewportContainer::~RenderSVGViewportContainer()
+{
+}
+
+void RenderSVGViewportContainer::layout()
+{
+    calcViewport();
+    RenderSVGContainer::layout();
+}
+
+void RenderSVGViewportContainer::paint(PaintInfo& paintInfo, int parentX, int parentY)
+{
+    // A value of zero disables rendering of the element. 
+    if (!viewport().isEmpty() && (viewport().width() <= 0. || viewport().height() <= 0.))
+        return;
+
+    RenderSVGContainer::paint(paintInfo, parentX, parentY);
+}
+
+void RenderSVGViewportContainer::applyContentTransforms(PaintInfo& paintInfo)
+{
+    if (!viewport().isEmpty()) {
+        if (style()->overflowX() != OVISIBLE)
+            paintInfo.context->clip(enclosingIntRect(viewport())); // FIXME: Eventually we'll want float-precision clipping
+        
+        paintInfo.context->concatCTM(AffineTransform().translate(viewport().x(), viewport().y()));
+    }
+
+    RenderSVGContainer::applyContentTransforms(paintInfo);
+}
+
+void RenderSVGViewportContainer::applyAdditionalTransforms(PaintInfo& paintInfo)
+{
+    paintInfo.context->concatCTM(viewportTransform());
+    RenderSVGContainer::applyAdditionalTransforms(paintInfo);
+}
+
+FloatRect RenderSVGViewportContainer::viewport() const
+{
+    return m_viewport;
+}
+
+void RenderSVGViewportContainer::calcViewport()
+{
+    SVGElement* svgelem = static_cast<SVGElement*>(element());
+    if (svgelem->hasTagName(SVGNames::svgTag)) {
+        SVGSVGElement* svg = static_cast<SVGSVGElement*>(element());
+
+        if (!selfNeedsLayout() && !svg->hasRelativeValues())
+            return;
+
+        double x = svg->x().value();
+        double y = svg->y().value();
+        double w = svg->width().value();
+        double h = svg->height().value();
+        m_viewport = FloatRect(x, y, w, h);
+    } else if (svgelem->hasTagName(SVGNames::markerTag)) {
+        if (!selfNeedsLayout())
+            return;
+
+        SVGMarkerElement* svg = static_cast<SVGMarkerElement*>(element());
+        double w = svg->markerWidth().value();
+        double h = svg->markerHeight().value();
+        m_viewport = FloatRect(0, 0, w, h);
+    }
+}
+
+AffineTransform RenderSVGViewportContainer::viewportTransform() const
+{
+    if (element()->hasTagName(SVGNames::svgTag)) {
+        SVGSVGElement* svg = static_cast<SVGSVGElement*>(element());
+        return svg->viewBoxToViewTransform(viewport().width(), viewport().height());
+    } else if (element()->hasTagName(SVGNames::markerTag)) {
+        SVGMarkerElement* marker = static_cast<SVGMarkerElement*>(element());
+        return marker->viewBoxToViewTransform(viewport().width(), viewport().height());
+    }
+     return AffineTransform();
+}
+
+AffineTransform RenderSVGViewportContainer::absoluteTransform() const
+{
+    AffineTransform ctm = RenderObject::absoluteTransform();
+    ctm.translate(viewport().x(), viewport().y());
+    return viewportTransform() * ctm;
+}
+
+bool RenderSVGViewportContainer::nodeAtPoint(const HitTestRequest& request, HitTestResult& result, int _x, int _y, int _tx, int _ty, HitTestAction hitTestAction)
+{
+    if (!viewport().isEmpty()
+        && style()->overflowX() == OHIDDEN
+        && style()->overflowY() == OHIDDEN) {
+        // Check if we need to do anything at all.
+        IntRect overflowBox = overflowRect(false);
+        overflowBox.move(_tx, _ty);
+        AffineTransform ctm = RenderObject::absoluteTransform();
+        ctm.translate(viewport().x(), viewport().y());
+        double localX, localY;
+        ctm.inverse().map(_x - _tx, _y - _ty, &localX, &localY);
+        if (!overflowBox.contains((int)localX, (int)localY))
+            return false;
+    }
+
+    int sx = 0;
+    int sy = 0;
+
+    // Respect parent translation offset for non-outermost <svg> elements.
+    // Outermost <svg> element is handled by RenderSVGRoot.
+    if (element()->hasTagName(SVGNames::svgTag)) {
+        sx = _tx;
+        sy = _ty;
+    }
+
+    for (RenderObject* child = lastChild(); child; child = child->previousSibling()) {
+        if (child->nodeAtPoint(request, result, _x - sx, _y - sy, _tx, _ty, hitTestAction)) {
+            updateHitTestResult(result, IntPoint(_x - _tx, _y - _ty));
+            return true;
+        }
+    }
+
+    // Spec: Only graphical elements can be targeted by the mouse, period.
+    // 16.4: "If there are no graphics elements whose relevant graphics content is under the pointer (i.e., there is no target element), the event is not dispatched."
+    return false;
+}
+
+}
+
+#endif // ENABLE(SVG)
+
+// vim:ts=4:noet
diff --git a/WebCore/rendering/RenderSVGViewportContainer.h b/WebCore/rendering/RenderSVGViewportContainer.h
new file mode 100644 (file)
index 0000000..c200a61
--- /dev/null
@@ -0,0 +1,67 @@
+/*
+    Copyright (C) 2004, 2005, 2007 Nikolas Zimmermann <zimmermann@kde.org>
+                  2004, 2005, 2007 Rob Buis <buis@kde.org>
+
+    This file is part of the KDE project
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Library General Public
+    License as published by the Free Software Foundation; either
+    version 2 of the License, or (at your option) any later version.
+
+    This library is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+    Library General Public License for more details.
+
+    You should have received a copy of the GNU Library General Public License
+    aint with this library; see the file COPYING.LIB.  If not, write to
+    the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+    Boston, MA 02111-1307, USA.
+*/
+
+#ifndef RenderSVGViewportContainer_h
+#define RenderSVGViewportContainer_h
+
+#if ENABLE(SVG)
+
+#include "RenderSVGContainer.h"
+
+namespace WebCore {
+
+class RenderSVGViewportContainer : public RenderSVGContainer {
+public:
+    RenderSVGViewportContainer(SVGStyledElement*);
+    ~RenderSVGViewportContainer();
+
+    virtual bool isSVGContainer() const { return true; }
+    virtual const char* renderName() const { return "RenderSVGViewportContainer"; }
+
+    virtual void layout();
+    virtual void paint(PaintInfo&, int parentX, int parentY);
+
+    virtual AffineTransform absoluteTransform() const;
+    virtual AffineTransform viewportTransform() const;
+
+    virtual bool nodeAtPoint(const HitTestRequest&, HitTestResult&, int x, int y, int tx, int ty, HitTestAction);
+
+    FloatRect viewport() const;
+
+private:
+    void calcViewport(); 
+
+    virtual void applyContentTransforms(PaintInfo&);
+    virtual void applyAdditionalTransforms(PaintInfo&);
+
+    AffineTransform m_matrix;
+    
+    FloatRect m_viewport;
+    IntRect m_absoluteBounds;
+};
+  
+} // namespace WebCore
+
+#endif // ENABLE(SVG)
+#endif // RenderSVGViewportContainer_h
+
+// vim:ts=4:noet