Reviewed by Maciej. Landed by Adam.
authoraroben <aroben@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 31 Oct 2006 19:03:15 +0000 (19:03 +0000)
committeraroben <aroben@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 31 Oct 2006 19:03:15 +0000 (19:03 +0000)
Fixes: http://bugs.webkit.org/show_bug.cgi?id=11463
        Move KCanvasTreeDebug into rendering, named as SVGRenderTreeAsText.*,
        as dicussed with Dave. Also kill the outdated DESIGN document.

        * CMakeLists.txt:
        * WebCore.xcodeproj/project.pbxproj:
        * kcanvas/DESIGN: Removed.
        * kcanvas/KCanvasFilters.cpp:
        * kcanvas/KCanvasTreeDebug.cpp: Moved to rendering/SVGRenderTreeAsText
        * kcanvas/KCanvasTreeDebug.h: Ditto.
        * kcanvas/device/KRenderingPaintServerGradient.cpp:
        * kcanvas/device/KRenderingPaintServerPattern.cpp:
        * kcanvas/device/KRenderingPaintServerSolid.cpp:
        * platform/graphics/svg/SVGResourceClipper.cpp:
        * rendering/RenderTreeAsText.cpp:
        * rendering/SVGRenderTreeAsText.cpp: Added.
        * rendering/SVGRenderTreeAsText.h: Added.
        (WebCore::operator<<):

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

14 files changed:
WebCore/CMakeLists.txt
WebCore/ChangeLog
WebCore/WebCore.xcodeproj/project.pbxproj
WebCore/kcanvas/DESIGN [deleted file]
WebCore/kcanvas/KCanvasFilters.cpp
WebCore/kcanvas/device/KRenderingPaintServerGradient.cpp
WebCore/kcanvas/device/KRenderingPaintServerPattern.cpp
WebCore/kcanvas/device/KRenderingPaintServerSolid.cpp
WebCore/platform/graphics/svg/SVGResourceClipper.cpp
WebCore/rendering/RenderTreeAsText.cpp
WebCore/rendering/SVGRenderAsText.cpp [moved from WebCore/kcanvas/KCanvasTreeDebug.cpp with 100% similarity]
WebCore/rendering/SVGRenderAsText.h [moved from WebCore/kcanvas/KCanvasTreeDebug.h with 100% similarity]
WebCore/rendering/SVGRenderTreeAsText.cpp [new file with mode: 0644]
WebCore/rendering/SVGRenderTreeAsText.h [new file with mode: 0644]

index c4cba67deff6f310eb3fb85cfd22bee611224299..b57a76141edd505c877263c5399b8ef3e3b3930c 100644 (file)
@@ -646,7 +646,6 @@ set (SVG_SOURCES
     ksvg2/misc/KCanvasRenderingStyle.cpp
     ksvg2/events/JSSVGLazyEventListener.cpp
     ksvg2/events/SVGZoomEvent.cpp
-    kcanvas/KCanvasTreeDebug.cpp
     kcanvas/KCanvasFilters.cpp
     kcanvas/device/KRenderingPaintServerGradient.cpp
     kcanvas/device/KRenderingPaintServerSolid.cpp
@@ -1122,6 +1121,7 @@ set(WebCore_SRCS
     rendering/RenderTableCol.cpp
     rendering/RenderObject.cpp
     rendering/RenderTreeAsText.cpp
+    rendering/SVGRenderTreeAsText.cpp
     rendering/RootInlineBox.cpp
     rendering/RenderFormElement.cpp
     rendering/RenderBox.cpp
index 96c426404281ea282fe531f441ec6c255b91cc56..244e67f28b414029a0838ad03cf26d355cc6e68b 100644 (file)
@@ -1,3 +1,27 @@
+2006-10-31  Nikolas Zimmermann  <zimmermann@kde.org>
+
+        Reviewed by Maciej. Landed by Adam.
+
+        Fixes: http://bugs.webkit.org/show_bug.cgi?id=11463
+
+        Move KCanvasTreeDebug into rendering, named as SVGRenderTreeAsText.*,
+        as dicussed with Dave. Also kill the outdated DESIGN document.
+
+        * CMakeLists.txt:
+        * WebCore.xcodeproj/project.pbxproj:
+        * kcanvas/DESIGN: Removed.
+        * kcanvas/KCanvasFilters.cpp:
+        * kcanvas/KCanvasTreeDebug.cpp: Moved to rendering/SVGRenderTreeAsText
+        * kcanvas/KCanvasTreeDebug.h: Ditto.
+        * kcanvas/device/KRenderingPaintServerGradient.cpp:
+        * kcanvas/device/KRenderingPaintServerPattern.cpp:
+        * kcanvas/device/KRenderingPaintServerSolid.cpp:
+        * platform/graphics/svg/SVGResourceClipper.cpp:
+        * rendering/RenderTreeAsText.cpp:
+        * rendering/SVGRenderTreeAsText.cpp: Added.
+        * rendering/SVGRenderTreeAsText.h: Added.
+        (WebCore::operator<<):
+
 2006-10-31  MorganL  <morganl.webkit@yahoo.com>
 
         Reviewed by Maciej.
index 727fa020497802fa1fcf3093528f95502ab20ff7..5ddeebfc341e99e88bd7959464f82f2351064c19 100644 (file)
                A88AD3B50952486E001DD196 /* QuartzSupport.h in Headers */ = {isa = PBXBuildFile; fileRef = A8C0FB76089701F800BA5114 /* QuartzSupport.h */; };
                A88AD3B60952486E001DD196 /* QuartzSupport.mm in Sources */ = {isa = PBXBuildFile; fileRef = A8C0FB77089701F800BA5114 /* QuartzSupport.mm */; };
                A88AD3BE0952486E001DD196 /* KCanvasFilters.h in Headers */ = {isa = PBXBuildFile; fileRef = A8C0FB7F089701F800BA5114 /* KCanvasFilters.h */; };
-               A88AD3CB0952486E001DD196 /* KCanvasTreeDebug.h in Headers */ = {isa = PBXBuildFile; fileRef = A810E39308A4160F00333D98 /* KCanvasTreeDebug.h */; };
-               A88AD3CC0952486E001DD196 /* KCanvasTreeDebug.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A810E39408A4160F00333D98 /* KCanvasTreeDebug.cpp */; };
                A88AD401095248F0001DD196 /* SVGRenderStyle.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A8C0F6FF089701F100BA5114 /* SVGRenderStyle.cpp */; };
                A88AD402095248F0001DD196 /* SVGRenderStyle.h in Headers */ = {isa = PBXBuildFile; fileRef = A8C0F700089701F100BA5114 /* SVGRenderStyle.h */; settings = {ATTRIBUTES = (Private, ); }; };
                A88AD403095248F0001DD196 /* SVGRenderStyleDefs.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A8C0F701089701F100BA5114 /* SVGRenderStyleDefs.cpp */; };
                B2A015BA0AF6CD53006BCE0E /* SVGResourceMasker.h in Headers */ = {isa = PBXBuildFile; fileRef = B2A015A70AF6CD53006BCE0E /* SVGResourceMasker.h */; };
                B2CB41930AB75904004D9C45 /* SVGRenderingIntent.h in Headers */ = {isa = PBXBuildFile; fileRef = B2CB414C0AB75904004D9C45 /* SVGRenderingIntent.h */; };
                B2CB41A60AB75904004D9C45 /* SVGUnitTypes.h in Headers */ = {isa = PBXBuildFile; fileRef = B2CB415F0AB75904004D9C45 /* SVGUnitTypes.h */; };
+               B2EBDC9C0AF77E3400AE4A68 /* SVGRenderTreeAsText.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B2EBDC9A0AF77E3400AE4A68 /* SVGRenderTreeAsText.cpp */; };
+               B2EBDC9D0AF77E3400AE4A68 /* SVGRenderTreeAsText.h in Headers */ = {isa = PBXBuildFile; fileRef = B2EBDC9B0AF77E3400AE4A68 /* SVGRenderTreeAsText.h */; };
                B2FA3D360AB75A6F000E5AC4 /* JSSVGAnimateColorElement.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B2FA3C4E0AB75A6E000E5AC4 /* JSSVGAnimateColorElement.cpp */; };
                B2FA3D370AB75A6F000E5AC4 /* JSSVGAnimateColorElement.h in Headers */ = {isa = PBXBuildFile; fileRef = B2FA3C4F0AB75A6E000E5AC4 /* JSSVGAnimateColorElement.h */; };
                B2FA3D380AB75A6F000E5AC4 /* JSSVGAnimatedAngle.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B2FA3C500AB75A6E000E5AC4 /* JSSVGAnimatedAngle.cpp */; };
                A80E7E940A1A83E3007FB8C5 /* JSHTMLTextAreaElement.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = JSHTMLTextAreaElement.cpp; sourceTree = "<group>"; };
                A80E7E950A1A83E3007FB8C5 /* JSHTMLButtonElement.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = JSHTMLButtonElement.h; sourceTree = "<group>"; };
                A80E7E960A1A83E3007FB8C5 /* JSHTMLButtonElement.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = JSHTMLButtonElement.cpp; sourceTree = "<group>"; };
-               A810E39308A4160F00333D98 /* KCanvasTreeDebug.h */ = {isa = PBXFileReference; fileEncoding = 4; indentWidth = 4; lastKnownFileType = sourcecode.c.h; path = KCanvasTreeDebug.h; sourceTree = "<group>"; tabWidth = 8; usesTabs = 0; };
-               A810E39408A4160F00333D98 /* KCanvasTreeDebug.cpp */ = {isa = PBXFileReference; fileEncoding = 4; indentWidth = 4; lastKnownFileType = sourcecode.cpp.cpp; path = KCanvasTreeDebug.cpp; sourceTree = "<group>"; tabWidth = 8; usesTabs = 0; };
                A81369AE097374F500D74463 /* HTMLIsIndexElement.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = HTMLIsIndexElement.h; sourceTree = "<group>"; };
                A81369AF097374F500D74463 /* HTMLIsIndexElement.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = HTMLIsIndexElement.cpp; sourceTree = "<group>"; };
                A81369B0097374F500D74463 /* HTMLInputElement.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = HTMLInputElement.h; sourceTree = "<group>"; };
                B2E9548C0AB5FBA30076DE37 /* SVGPathSegMovetoAbs.idl */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = text; path = SVGPathSegMovetoAbs.idl; sourceTree = "<group>"; };
                B2E9548D0AB5FBA30076DE37 /* SVGPathSegMovetoRel.idl */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = text; path = SVGPathSegMovetoRel.idl; sourceTree = "<group>"; };
                B2E9548E0AB5FBA30076DE37 /* SVGPreserveAspectRatio.idl */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = text; path = SVGPreserveAspectRatio.idl; sourceTree = "<group>"; };
+               B2EBDC9A0AF77E3400AE4A68 /* SVGRenderTreeAsText.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = SVGRenderTreeAsText.cpp; sourceTree = "<group>"; };
+               B2EBDC9B0AF77E3400AE4A68 /* SVGRenderTreeAsText.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = SVGRenderTreeAsText.h; sourceTree = "<group>"; };
                B2FA3C4E0AB75A6E000E5AC4 /* JSSVGAnimateColorElement.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = JSSVGAnimateColorElement.cpp; sourceTree = "<group>"; };
                B2FA3C4F0AB75A6E000E5AC4 /* JSSVGAnimateColorElement.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = JSSVGAnimateColorElement.h; sourceTree = "<group>"; };
                B2FA3C500AB75A6E000E5AC4 /* JSSVGAnimatedAngle.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = JSSVGAnimatedAngle.cpp; sourceTree = "<group>"; };
                                A8C0FB53089701F700BA5114 /* device */,
                                A8415F990AC10C5D00F7D0DF /* KCanvasFilters.cpp */,
                                A8C0FB7F089701F800BA5114 /* KCanvasFilters.h */,
-                               A810E39408A4160F00333D98 /* KCanvasTreeDebug.cpp */,
-                               A810E39308A4160F00333D98 /* KCanvasTreeDebug.h */,
                        );
                        path = kcanvas;
                        sourceTree = "<group>";
                                BCEA484F097D93020094C9E4 /* RenderTextFragment.h */,
                                BCEA484A097D93020094C9E4 /* RenderTheme.cpp */,
                                BCEA484B097D93020094C9E4 /* RenderTheme.h */,
+                               B2EBDC9A0AF77E3400AE4A68 /* SVGRenderTreeAsText.cpp */,
+                               B2EBDC9B0AF77E3400AE4A68 /* SVGRenderTreeAsText.h */,
                                BCEA4849097D93020094C9E4 /* RenderThemeMac.mm */,
                                BCEA4848097D93020094C9E4 /* RenderThemeMac.h */,
                                93955A4203D72932008635CE /* RenderTreeAsText.cpp */,
                                A88AD3B30952486E001DD196 /* KRenderingPaintServerQuartz.h in Headers */,
                                A88AD3B50952486E001DD196 /* QuartzSupport.h in Headers */,
                                A88AD3BE0952486E001DD196 /* KCanvasFilters.h in Headers */,
-                               A88AD3CB0952486E001DD196 /* KCanvasTreeDebug.h in Headers */,
                                A88AD402095248F0001DD196 /* SVGRenderStyle.h in Headers */,
                                A88AD404095248F0001DD196 /* SVGRenderStyleDefs.h in Headers */,
                                A88AD40B095248F0001DD196 /* SVGZoomEvent.h in Headers */,
                                B2A015B60AF6CD53006BCE0E /* SVGResourceImage.h in Headers */,
                                B2A015B80AF6CD53006BCE0E /* SVGResourceMarker.h in Headers */,
                                B2A015BA0AF6CD53006BCE0E /* SVGResourceMasker.h in Headers */,
+                               B2EBDC9D0AF77E3400AE4A68 /* SVGRenderTreeAsText.h in Headers */,
                        );
                        runOnlyForDeploymentPostprocessing = 0;
                };
                                A88AD3B20952486E001DD196 /* KRenderingPaintServerGradientQuartz.mm in Sources */,
                                A88AD3B40952486E001DD196 /* KRenderingPaintServerQuartz.mm in Sources */,
                                A88AD3B60952486E001DD196 /* QuartzSupport.mm in Sources */,
-                               A88AD3CC0952486E001DD196 /* KCanvasTreeDebug.cpp in Sources */,
                                A88AD401095248F0001DD196 /* SVGRenderStyle.cpp in Sources */,
                                A88AD403095248F0001DD196 /* SVGRenderStyleDefs.cpp in Sources */,
                                A88AD40A095248F0001DD196 /* SVGZoomEvent.cpp in Sources */,
                                B2A015B40AF6CD53006BCE0E /* SVGResourceClipper.cpp in Sources */,
                                B2A015B70AF6CD53006BCE0E /* SVGResourceMarker.cpp in Sources */,
                                B2A015B90AF6CD53006BCE0E /* SVGResourceMasker.cpp in Sources */,
+                               B2EBDC9C0AF77E3400AE4A68 /* SVGRenderTreeAsText.cpp in Sources */,
                        );
                        runOnlyForDeploymentPostprocessing = 0;
                };
diff --git a/WebCore/kcanvas/DESIGN b/WebCore/kcanvas/DESIGN
deleted file mode 100644 (file)
index 3751a1d..0000000
+++ /dev/null
@@ -1,172 +0,0 @@
-KCanvas Design Document 0.1
----------------------------
-Last update: 25.07.2004
-
-1. What is (the history of) KCanvas?
-------------------------------------
-
-KCanvas is the result of four-year ksvg development.
-We had to create our "own" canvas for ksvg, some years
-ago as any existing implementation hasn't been able
-to fulfil our needs, which is mostly: flexibility.
-
-QCanvas is (of course) tied to Qt, which is good.
-But it wipes away ie. the functionality to paint
-with/to something else than a QPainter.
-
-The immediate result of our brainstorming, what
-we needed, was: KSVGCanvas. KSVGCanvas was basically
-a "port" of QCanvas code to ksvg with heavy modifications.
-We exclusively used libart at the beginning of KSVGCanvas
-hacking. Later we made it possible to use different
-rendering devices (implemented in ksvg: libart & agg).
-
-That was the first step to more flexibility. But it
-hasn't been enough to make a generic kde canvas out of it.
-
-KCanvas currently uses a very sophisticated approach,
-which will be explained in detail now....
-
-2. The main idea of the canvas
-------------------------------
-
-First of all, we have to differentiate between "Rendering Devices" and "Rendering Targets".
-
-Definition:
-       A "device" is used to paint onto a "target".  "Devices" are
-       dynamically loadable, whereas "targets" have to be linked against.
-
-Targets:
-       Qt (QWidget), OpenGL, SDL... are good examples for common "Rendering Targets".
-       As stated above, you cannot dynamically switch the rendering targets.
-
-       <code-snippet>
-               KCanvasTargetQt *targetQt = new KCanvasTargetQt(prefWidth, prefHeight);
-       </code-snippet>
-
-       You have to create a new target object manually depending on the target you'd like
-       to paint on. Currently we only have a 'Qt' rendering target.
-
-Devices:
-       Libart, agg2, QPainter etc.. are good examples for common "Rendering Devices".
-
-       <code-snippet>
-               KRenderingDevice *device = KRenderingDeviceFactory::self()->request("agg", targetQt);
-               if(!device)
-                       return false;
-       </code-snippet>
-
-       You can easily load available rendering devices by 'String'.
-       Additionally, you have to pass the rendering target pointer
-       as the 'request' function checks wheter your rendering device
-       needs a 'buffered' rendering target or a 'unbuffered' rendering
-       target. For example: targetQt -> buffered rendering target
-                                                agg -> buffered rendering device
-
-    An OpenGL target is a good example of an 'unbuffered' target,
-       because there would be no hardware acceleration advantage if we'd
-       use a software renderer like agg2 to create a rendering buffer
-       and then blit it onto the screen. That's why such a seperation is needed.
-
-Ok, as you know the difference between targets & devices now,
-we can start experimenting with the main 'KCanvas' class.....
-
-3. How to use the 'KCanvas' class?
-----------------------------------
-
-<code-snippet>
-       KCanvas(KCanvasTarget *target, KRenderingDevice *device)
-</code-snippet>
-
-The (only available) KCanvas constructor, takes a KCanvasTarget
-pointer and a KRenderingDevice pointer, which can be retrieved
-using the techniques from the article above.
-
-<code-snippet>
-       // First attach to canvas...
-       KCanvas *myCanvas = new KCanvas(target, device);
-
-    // ... then initialize the target & device!
-       target->init(this);
-       device->init(target);
-</code-snippet>
-
-The second important step is to initialize the rendering target.
-When using the 'KCanvasTargetQt' it takes a 'QPaintDevice'
-pointer as argument, which identifies the window to paint on.
-(Look into test/canvastest.cc & test/CanvasWidget.cc...)
-
-That knowledge should be sufficient to get an "empty" canvas
-onto screen. Next thing to know: How to use canvas items?
-
-4. Adding items onto your canvas [TODO]
---------------------------------
-- concept of paintservers
-
-Paint servers can be thought of as a way of filling up a arbitrary
-screen region using paint. The simplest and most commonly used is the
-solid paint server, which simply paints the area with a solid rgb color.
-More advanced paint servers are the gradient paint server, which can be used
-to create smooth color transitions or shadings. Currently KCanvas supports two
-gradient types (linear + radial), but other gradients are possible. Finally there
-is the pattern paint server, which takes a bitmap graphic and tiles it over the area,
-possible using a transformation matrix to rotate or skew the pattern tiles.
-
-Note that KCanvas has an abstract interface for paint servers, so new paint servers can
-be added in addition to the three current ones.
-
-Paint servers as used in KCanvas are heavily influenced by svg, see :
-http://www.w3.org/TR/SVG11/pservers.html
-
-- KCanvasResource
-
-Most paintservers are KCanvasResources. This class makes sure any change on
-the paint server invalidates every item using the paint server.
-For example, when a gradient resource changes a color stop, all items using
-said gradient will be invalidated and redrawn on the next update(). Since
-not every change on a parameter of a paintserver should trigger a redraw
-(for instance you don't want this while initializing the canvas) an
-explicit call named invalidate() has to be done on the KCanvasResource.
-
-- KRenderingStyle
-- KCanvasCreator
-
-Currently the following canvas items can be created using the
-KCanvasCreator singleton:
-
-- lines
-- rectangles (possibly rounded)
-- circles
-- ellipses
-- paths
-- containers
-
-Items are inserted into the canvas. Later additions are drawn above items
-added before, ie. the zIndex increases on every item insertion.
-Here is a code snippet of the creation of a canvas item, in this case a rounded rect:
-
-<code-snippet>
-       canvas->insertItem(KCanvasCreator::self()->createRoundedRectangle(canvas, rectStyle, 120, 100, 140, 160, 5, 10));
-</code-snippet>
-
-Note that for manipulating individual canvas items at a later time it is
-convenient to keep a pointer to the canvas item:
-
-<code-snippet>
-        KCanvasItem *item = KCanvasCreator::self()->createRoundedRectangle(canvas, rectStyle, 120, 100, 140, 160, 5, 10);
-</code-snippet>
-
-Do not worry about it being a pointer, the canvas keeps track of the item
-and will delete it when it is itself shutting down.
-Now that we have a pointer to the item, we can do things like lower()/raise(),
-get the bbox() of the item and hit detection using fillContains()/strokeContains().
-Have a look at KCanvasItem.h for what you can do with KCanvasItems.
-
-5. Writing rendering targets [TODO]
-----------------------------
-
-6. Writing rendering devices [TODO] 
-----------------------------
-
-Have fun with KCanvas!
-Your KCanvas Team :)
index 39e5960d42fb3d19b5eee5cc9198a15216a2654f..ee207a5463b962f453c24e0c19e8627b8fdd47bd 100644 (file)
@@ -26,9 +26,9 @@
 #include "KCanvasFilters.h"
 
 #include "CachedImage.h"
-
+#include "SVGRenderTreeAsText.h"
 #include "TextStream.h"
-#include "KCanvasTreeDebug.h"
+
 #include <wtf/Assertions.h>
 #include <math.h>
 
index e626f2e0f51c7bad43dfb90c0a8423ad852c4feb..7d456123882edc73ea3d463410248e16f713084f 100644 (file)
@@ -27,8 +27,8 @@
 #include "KRenderingPaintServerGradient.h"
 
 #include "AffineTransform.h"
+#include "SVGRenderTreeAsText.h"
 #include "TextStream.h"
-#include "KCanvasTreeDebug.h"
 
 namespace WebCore {
 
index e9687e7c114f9b3d7606228f5606c90a0aeab9e8..83a6bafca259e12fe4c9bb3aca28414373e6717b 100644 (file)
 #include "config.h"
 #ifdef SVG_SUPPORT
 #include "SVGResourceImage.h"
-#include "KRenderingPaintServerPattern.h"
 
 #include "AffineTransform.h"
+#include "KRenderingPaintServerPattern.h"
+#include "SVGRenderTreeAsText.h"
 #include "TextStream.h"
-#include "KCanvasTreeDebug.h"
 
 namespace WebCore {
 
index a2d9b68f7531aa711d6ceefa5597cf375f1278a2..b42c4e3b332bf290054e7ecf2769ba5e0f2811af 100644 (file)
 */
 
 #include "config.h"
+
 #ifdef SVG_SUPPORT
 #include "KRenderingPaintServerSolid.h"
+
+#include "SVGRenderTreeAsText.h"
 #include "TextStream.h"
-#include "KCanvasTreeDebug.h"
 
 namespace WebCore {
 
index c3d82c1f23b5e95f558943372a78321a7d46a8f8..e65b008e85407af3e76043fc9ef595bd821e5dae 100644 (file)
@@ -26,8 +26,8 @@
 #include "config.h"
 #include "SVGResourceClipper.h"
 
+#include "SVGRenderTreeAsText.h"
 #include "TextStream.h"
-#include <kcanvas/KCanvasTreeDebug.h>
 
 namespace WebCore {
 
index 8ac3243f21478d382c50ec32d76abee04104b337..15cad11dea827a9ce50dae7f5d224ce47d9a4ab2 100644 (file)
@@ -40,8 +40,8 @@
 #include <wtf/Vector.h>
 
 #ifdef SVG_SUPPORT
-#include "KCanvasTreeDebug.h"
 #include "RenderSVGContainer.h"
+#include "SVGRenderTreeAsText.h"
 #endif
 
 namespace WebCore {
diff --git a/WebCore/rendering/SVGRenderTreeAsText.cpp b/WebCore/rendering/SVGRenderTreeAsText.cpp
new file mode 100644 (file)
index 0000000..c80ddb1
--- /dev/null
@@ -0,0 +1,380 @@
+/*
+ * Copyright (C) 2004, 2005 Apple Computer, Inc.  All rights reserved.
+ *           (C) 2005 Rob Buis <buis@kde.org>
+ *           (C) 2006 Alexander Kellett <lypanov@kde.org>
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE COMPUTER, INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
+ */
+
+#include "config.h"
+#ifdef SVG_SUPPORT
+#include "SVGRenderTreeAsText.h"
+
+#include "SVGResourceClipper.h"
+#include "GraphicsTypes.h"
+#include "HTMLNames.h"
+#include "RenderTreeAsText.h"
+#include "RenderSVGContainer.h"
+#include "KRenderingDevice.h"
+#include "KRenderingPaintServerGradient.h"
+#include "KRenderingPaintServerPattern.h"
+#include "KRenderingPaintServerSolid.h"
+#include "KCanvasRenderingStyle.h"
+#include "SVGStyledElement.h"
+#include <math.h>
+
+namespace WebCore {
+
+/** class + iomanip to help streaming list separators, i.e. ", " in string "a, b, c, d"
+ * Can be used in cases where you don't know which item in the list is the first
+ * one to be printed, but still want to avoid strings like ", b, c", works like 
+ * DeprecatedStringList::join for streams
+ */
+class TextStreamSeparator
+{
+public:
+    TextStreamSeparator(const DeprecatedString &s) : m_separator(s), m_needToSeparate(false) {}
+private:
+    friend TextStream& operator<<(TextStream& ts, TextStreamSeparator &sep);
+    
+private:
+    DeprecatedString m_separator;
+    bool m_needToSeparate;
+};
+
+TextStream& operator<<(TextStream& ts, TextStreamSeparator &sep)
+{
+    if (sep.m_needToSeparate)
+        ts << sep.m_separator;
+    else 
+        sep.m_needToSeparate = true;
+    return ts;
+}
+
+TextStream& operator<<(TextStream& ts, const IntPoint &p)
+{
+    return ts << "(" << p.x() << "," << p.y() << ")";
+}
+
+TextStream& operator<<(TextStream& ts, const IntRect &r)
+{
+    return ts << "at (" << r.x() << "," << r.y() << ") size " << r.width() << "x" << r.height();
+}
+
+bool hasFractions(double val)
+{
+    double epsilon = 0.0001;
+    int ival = int(val);
+    double dval = double(ival);    
+    return (fabs(val-dval) > epsilon);
+}
+
+TextStream& operator<<(TextStream& ts, const FloatRect &r)
+{
+    ts << "at ("; 
+    if (hasFractions(r.x())) 
+        ts << r.x();
+    else 
+        ts << int(r.x());
+    ts << ",";
+    if (hasFractions(r.y())) 
+        ts << r.y();
+    else 
+        ts << int(r.y());
+    ts << ") size ";
+    if (hasFractions(r.width())) 
+        ts << r.width(); 
+    else 
+        ts << int(r.width()); 
+    ts << "x";
+    if (hasFractions(r.height())) 
+        ts << r.height();
+    else 
+        ts << int(r.height());
+    return ts;
+}
+
+TextStream& operator<<(TextStream& ts, const FloatPoint &p)
+{
+    ts << "(";    
+    if (hasFractions(p.x()))
+        ts << p.x();
+    else 
+        ts << int(p.x());    
+    ts << ",";
+    if (hasFractions(p.y())) 
+        ts << p.y();
+    else 
+        ts << int(p.y());    
+    return ts << ")";
+}
+
+TextStream& operator<<(TextStream& ts, const FloatSize &s)
+{   
+    ts << "width=";
+    if (hasFractions(s.width()))
+        ts << s.width();
+    else
+        ts << int(s.width());
+    ts << " height=";
+    if (hasFractions(s.height())) 
+        ts << s.height();
+    else
+        ts << int(s.height());
+     return ts;
+}
+
+
+TextStream& operator<<(TextStream& ts, const AffineTransform &m)
+{
+    if (m.isIdentity())
+        ts << "identity";
+    else 
+    {
+        ts << "{m=((" << m.m11() << "," << m.m12() << ")(" << m.m21() << "," << m.m22() << "))";
+        ts << " t=(" << m.dx() << "," << m.dy() << ")}";
+    }
+    return ts;
+}
+
+TextStream& operator<<(TextStream& ts, const Color &c)
+{
+    return ts << c.name();
+}
+
+static void writeIndent(TextStream& ts, int indent)
+{
+    for (int i = 0; i != indent; ++i) {
+        ts << "  ";
+    }
+}
+
+//FIXME: This should be in KRenderingStyle.cpp
+static TextStream& operator<<(TextStream& ts, const KCDashArray &a)
+{
+    ts << "{";
+    KCDashArray::const_iterator end = a.end();
+    for (KCDashArray::const_iterator it = a.begin(); it != end; ++it) {
+        if (it != a.begin())
+            ts << ", ";
+        ts << *it;
+    }
+    ts << "}";
+    return ts;
+}
+
+//FIXME: This should be in KRenderingStyle.cpp
+static TextStream& operator<<(TextStream& ts, LineCap style)
+{
+    switch (style) {
+    case ButtCap:
+        ts << "BUTT"; break;
+    case RoundCap:
+        ts << "ROUND"; break;
+    case SquareCap:
+        ts << "SQUARE"; break;
+    }
+    return ts;
+}
+
+//FIXME: This should be in KRenderingStyle.cpp
+static TextStream& operator<<(TextStream& ts, LineJoin style)
+{
+    switch (style) {
+    case MiterJoin:
+        ts << "MITER"; break;
+    case RoundJoin:
+        ts << "ROUND"; break;
+    case BevelJoin:
+        ts << "BEVEL"; break;
+    }
+    return ts;
+}
+
+#define DIFFERS_FROM_PARENT(path) (!parentStyle || (parentStyle->path != childStyle->path))
+// avoids testing path if pred is false. This is used with tests that have side-effects
+// for the parent object
+#define DIFFERS_FROM_PARENT_AVOID_TEST_IF_FALSE(pred, path) (!parentStyle || ((!parentStyle->pred) || (parentStyle->path != childStyle->path)))
+
+static void writeStyle(TextStream& ts, const RenderObject &object)
+{
+    const RenderStyle* style = object.style();
+    const SVGRenderStyle* svgStyle = style->svgStyle();
+    
+    if (!object.localTransform().isIdentity())
+        ts << " [transform=" << object.localTransform() << "]";
+    if (svgStyle->imageRendering() != SVGRenderStyle::initialImageRendering())
+        ts << " [image rendering=" << svgStyle->imageRendering() << "]";
+    if (style->opacity() != RenderStyle::initialOpacity())
+        ts << " [opacity=" << style->opacity() << "]";
+    if (object.isRenderPath()) {
+        const RenderPath& path = static_cast<const RenderPath&>(object);
+        KRenderingPaintServer *strokePaintServer = KSVGPainterFactory::strokePaintServer(style, &path);
+        if (strokePaintServer) {
+            TextStreamSeparator s(" ");
+            ts << " [stroke={";
+            if (strokePaintServer) {
+                if (!strokePaintServer->idInRegistry().isEmpty())
+                    ts << s << "[id=\""<< strokePaintServer->idInRegistry() << "\"]"; 
+                else
+                    ts << s << *strokePaintServer;
+            } 
+
+            double dashOffset = KSVGPainterFactory::cssPrimitiveToLength(&path, svgStyle->strokeDashOffset(), 0.0);
+            const KCDashArray& dashArray = KSVGPainterFactory::dashArrayFromRenderingStyle(style);
+            double strokeWidth = KSVGPainterFactory::cssPrimitiveToLength(&path, svgStyle->strokeWidth(), 1.0);
+            
+            if (svgStyle->strokeOpacity() != 1.0f)
+                ts << s << "[opacity=" << svgStyle->strokeOpacity() << "]";
+            if (strokeWidth != 1.0f)
+                ts << s << "[stroke width=" << strokeWidth << "]";
+            if (svgStyle->strokeMiterLimit() != 4)
+                ts << s << "[miter limit=" << svgStyle->strokeMiterLimit() << "]";
+            if (svgStyle->capStyle() != 0)
+                ts << s << "[line cap=" << svgStyle->capStyle() << "]";
+            if (svgStyle->joinStyle() != 0)
+                ts << s << "[line join=" << svgStyle->joinStyle() << "]";
+            if (dashOffset != 0.0f)
+                ts << s << "[dash offset=" << dashOffset << "]";
+            if (!dashArray.isEmpty())
+                ts << s << "[dash array=" << dashArray << "]";        
+            ts << "}]";
+        }
+        KRenderingPaintServer *fillPaintServer = KSVGPainterFactory::fillPaintServer(style, &path);
+        if (fillPaintServer) {
+            TextStreamSeparator s(" ");
+            ts << " [fill={";
+            if (fillPaintServer) {
+                if (!fillPaintServer->idInRegistry().isEmpty())
+                    ts << s << "[id=\"" << fillPaintServer->idInRegistry() << "\"]";
+                else
+                    ts << s << *fillPaintServer;
+            }
+            
+            if (style->svgStyle()->fillOpacity() != 1.0f)
+                ts << s << "[opacity=" << style->svgStyle()->fillOpacity() << "]";
+            if (style->svgStyle()->fillRule() != RULE_NONZERO)
+                ts << s << "[fill rule=" << style->svgStyle()->fillRule() << "]";
+            ts << "}]";
+        }
+    }
+    if (!svgStyle->clipPath().isEmpty())
+        ts << " [clip path=\"" << svgStyle->clipPath() << "\"]";
+    if (!svgStyle->startMarker().isEmpty())
+        ts << " [start marker=" << svgStyle->startMarker() << "]";
+    if (!svgStyle->midMarker().isEmpty())
+        ts << " [middle marker=" << svgStyle->midMarker() << "]";
+    if (!svgStyle->endMarker().isEmpty())
+        ts << " [end marker=" << svgStyle->endMarker() << "]";
+    if (!svgStyle->filter().isEmpty())
+        ts << " [filter=" << svgStyle->filter() << "]";
+}
+#undef DIFFERS_FROM_PARENT
+#undef DIFFERS_FROM_PARENT_AVOID_TEST_IF_FALSE
+
+static TextStream& operator<<(TextStream& ts, const RenderPath &o)
+{
+    ts << " " << o.absoluteTransform().mapRect(o.relativeBBox());
+    
+    writeStyle(ts, o);
+    
+    ts << " [data=\"" << o.path().debugString() << "\"]";
+    
+    return ts;
+}
+
+static TextStream& operator<<(TextStream& ts, const RenderSVGContainer &o)
+{
+    ts << " " << o.absoluteTransform().mapRect(o.relativeBBox());
+    
+    writeStyle(ts, o);
+    
+    return ts;
+}
+
+static DeprecatedString getTagName(void *node)
+{
+    SVGStyledElement *elem = static_cast<SVGStyledElement*>(node);
+    if (elem)
+        return String(elem->nodeName()).deprecatedString();
+    return DeprecatedString();
+}
+
+void write(TextStream& ts, const RenderSVGContainer &container, int indent)
+{
+    writeIndent(ts, indent);
+    ts << container.renderName();
+    
+    if (container.element()) {
+        DeprecatedString tagName = getTagName(container.element());
+        if (!tagName.isEmpty())
+            ts << " {" << tagName << "}";
+    }
+    
+    ts << container << endl;
+    
+    for (RenderObject *child = container.firstChild(); child != NULL; child = child->nextSibling())
+        write(ts, *child, indent + 1);
+}
+
+void write(TextStream& ts, const RenderPath &path, int indent)
+{
+    writeIndent(ts, indent);
+    ts << path.renderName();
+    
+    if (path.element()) {
+        DeprecatedString tagName = getTagName(path.element());
+        if (!tagName.isEmpty())
+            ts << " {" << tagName << "}";
+    }
+    
+    ts << path << endl;
+}
+
+void writeRenderResources(TextStream& ts, Node *parent)
+{
+    ASSERT(parent);
+    Node *node = parent;
+    do {
+        if (!node->isSVGElement())
+            continue;
+        SVGElement *svgElement = static_cast<SVGElement*>(node);
+        if (!svgElement->isStyled())
+            continue;
+
+        SVGStyledElement *styled = static_cast<SVGStyledElement*>(svgElement);
+        RefPtr<SVGResource> resource(styled->canvasResource());
+        if (!resource)
+            continue;
+        
+        DeprecatedString elementId = svgElement->getAttribute(HTMLNames::idAttr).deprecatedString();
+        if (resource->isPaintServer()) {
+            RefPtr<KRenderingPaintServer> paintServer = WTF::static_pointer_cast<KRenderingPaintServer>(resource);
+            ts << "KRenderingPaintServer {id=\"" << elementId << "\" " << *paintServer << "}" << endl;
+        } else
+            ts << "KCanvasResource {id=\"" << elementId << "\" " << *resource << "}" << endl;
+    } while ((node = node->traverseNextNode(parent)));
+}
+
+}
+
+#endif // SVG_SUPPORT
diff --git a/WebCore/rendering/SVGRenderTreeAsText.h b/WebCore/rendering/SVGRenderTreeAsText.h
new file mode 100644 (file)
index 0000000..5930baf
--- /dev/null
@@ -0,0 +1,94 @@
+/*
+ * Copyright (C) 2004, 2005 Apple Computer, Inc.  All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE COMPUTER, INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
+ */
+
+#include "DeprecatedString.h"
+#include "TextStream.h"
+#include "DeprecatedValueList.h"
+
+namespace WebCore {
+
+    class AffineTransform;
+    class Color;
+    class FloatPoint;
+    class FloatRect;
+    class FloatSize;
+    class IntPoint;
+    class IntRect;
+    class KCClipData;
+    class KCPathData;
+    class Node;
+    class RenderPath;
+    class RenderSVGContainer;
+
+// functions used by the main RenderTreeAsText code
+void write(TextStream&, const RenderSVGContainer&, int indent = 0);
+void write(TextStream&, const RenderPath&, int indent = 0);
+void writeRenderResources(TextStream&, Node* parent);
+
+// helper operators defined used in various classes to dump the render tree. 
+TextStream& operator<<(TextStream&, const AffineTransform&);
+TextStream& operator<<(TextStream&, const IntRect&);
+TextStream& operator<<(TextStream&, const Color&);
+TextStream& operator<<(TextStream&, const IntPoint&);
+TextStream& operator<<(TextStream&, const FloatSize&);
+TextStream& operator<<(TextStream&, const FloatRect&);
+TextStream& operator<<(TextStream&, const FloatPoint&);
+
+// helper operators specific to dumping the render tree. these are used in various classes to dump the render tree
+// these could be defined in separate namespace to avoid matching these generic signatures unintentionally.
+    
+template<typename Item>
+TextStream& operator<<(TextStream& ts, const DeprecatedValueList<Item*>& l)
+{
+    ts << "[";
+    typename DeprecatedValueList<Item*>::ConstIterator it = l.begin();
+    typename DeprecatedValueList<Item*>::ConstIterator it_e = l.end();
+    while (it != it_e) {
+        ts << *(*it);
+        ++it;
+        if (it != it_e) ts << ", ";
+    }
+    ts << "]";
+    
+    return ts;
+}
+
+template<typename Item>
+TextStream& operator<<(TextStream& ts, const DeprecatedValueList<Item>& l)
+{
+    ts << "[";
+    typename DeprecatedValueList<Item>::ConstIterator it = l.begin();
+    typename DeprecatedValueList<Item>::ConstIterator it_e = l.end();
+    while (it != it_e) {
+        ts << *it;
+        ++it;
+        if (it != it_e) ts << ", ";
+    }
+    ts << "]";
+    
+    return ts;
+}
+
+}