Reviewed by Darin.
authorrwlbuis <rwlbuis@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sun, 3 Sep 2006 21:31:30 +0000 (21:31 +0000)
committerrwlbuis <rwlbuis@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sun, 3 Sep 2006 21:31:30 +0000 (21:31 +0000)
        http://bugzilla.opendarwin.org/show_bug.cgi?id=10696
        RenderPathQuartz and RenderPathQt should not be needed

        Cleanup of code related to RenderPath.

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

38 files changed:
WebCore/CMakeLists.txt
WebCore/ChangeLog
WebCore/WebCore.xcodeproj/project.pbxproj
WebCore/kcanvas/KCanvasCreator.cpp
WebCore/kcanvas/KCanvasCreator.h
WebCore/kcanvas/RenderPath.cpp
WebCore/kcanvas/RenderPath.h
WebCore/kcanvas/device/KRenderingDevice.h
WebCore/kcanvas/device/qt/KRenderingDeviceQt.cpp
WebCore/kcanvas/device/qt/KRenderingDeviceQt.h
WebCore/kcanvas/device/qt/RenderPathQt.cpp
WebCore/kcanvas/device/qt/RenderPathQt.h
WebCore/kcanvas/device/quartz/KCanvasItemQuartz.h
WebCore/kcanvas/device/quartz/KCanvasItemQuartz.mm
WebCore/kcanvas/device/quartz/KRenderingDeviceQuartz.h
WebCore/kcanvas/device/quartz/KRenderingDeviceQuartz.mm
WebCore/kcanvas/device/quartz/QuartzSupport.h
WebCore/ksvg2/svg/SVGAElement.cpp
WebCore/ksvg2/svg/SVGCircleElement.cpp
WebCore/ksvg2/svg/SVGEllipseElement.cpp
WebCore/ksvg2/svg/SVGFEImageElement.cpp
WebCore/ksvg2/svg/SVGGElement.cpp
WebCore/ksvg2/svg/SVGImageElement.cpp
WebCore/ksvg2/svg/SVGLineElement.cpp
WebCore/ksvg2/svg/SVGMarkerElement.cpp
WebCore/ksvg2/svg/SVGPathElement.cpp
WebCore/ksvg2/svg/SVGPatternElement.cpp
WebCore/ksvg2/svg/SVGPolygonElement.cpp
WebCore/ksvg2/svg/SVGPolylineElement.cpp
WebCore/ksvg2/svg/SVGRectElement.cpp
WebCore/ksvg2/svg/SVGSVGElement.cpp
WebCore/ksvg2/svg/SVGStyledElement.cpp
WebCore/ksvg2/svg/SVGSwitchElement.cpp
WebCore/ksvg2/svg/SVGTextElement.cpp
WebCore/ksvg2/svg/SVGUseElement.cpp
WebCore/platform/Path.h
WebCore/platform/cg/PathCG.cpp
WebCore/platform/qt/PathQt.cpp

index 9caf6d0c6a53be3f8064f61763ffb6fe140d1da5..7089846e67847223b8de08b1a78f6615b197bf0f 100644 (file)
@@ -866,6 +866,7 @@ set(WebCore_SRCS
     platform/StringImpl.cpp
     platform/FloatRect.cpp
     platform/ResourceLoader.cpp
+    platform/Path.cpp
     platform/qt/AffineTransformQt.cpp
     platform/qt/StringQt.cpp
     platform/qt/ColorQt.cpp
index 82aa3f38b81e3daa9457ea9a98313aa922bc8bc7..d77d0d55ed42303ce5568e35b15ce60dde32f6ad 100644 (file)
@@ -1,3 +1,71 @@
+2006-09-03  Rob Buis  <buis@kde.org>
+
+        Reviewed by Darin.
+
+        http://bugzilla.opendarwin.org/show_bug.cgi?id=10696
+        RenderPathQuartz and RenderPathQt should not be needed
+
+        Cleanup of code related to RenderPath.
+
+        * CMakeLists.txt:
+        * WebCore.xcodeproj/project.pbxproj:
+        * kcanvas/KCanvasCreator.cpp:
+        * kcanvas/KCanvasCreator.h:
+        * kcanvas/RenderPath.cpp:
+        (WebCore::):
+        (WebCore::DrawMarkersData::DrawMarkersData):
+        (WebCore::drawMarkerWithData):
+        (WebCore::updateMarkerDataForElement):
+        (WebCore::drawStartAndMidMarkers):
+        (WebCore::RenderPath::drawMarkersIfNeeded):
+        * kcanvas/RenderPath.h:
+        * kcanvas/device/KRenderingDevice.h:
+        * kcanvas/device/qt/KRenderingDeviceQt.cpp:
+        * kcanvas/device/qt/KRenderingDeviceQt.h:
+        * kcanvas/device/qt/RenderPathQt.cpp:
+        (WebCore::RenderPath::strokeContains):
+        (WebCore::RenderPath::strokeBBox):
+        * kcanvas/device/qt/RenderPathQt.h:
+        * kcanvas/device/quartz/KCanvasItemQuartz.h:
+        * kcanvas/device/quartz/KCanvasItemQuartz.mm:
+        (WebCore::RenderPath::strokeBBox):
+        (WebCore::RenderPath::strokeContains):
+        * kcanvas/device/quartz/KRenderingDeviceQuartz.h:
+        * kcanvas/device/quartz/KRenderingDeviceQuartz.mm:
+        * kcanvas/device/quartz/QuartzSupport.h:
+        * ksvg2/svg/SVGAElement.cpp:
+        * ksvg2/svg/SVGCircleElement.cpp:
+        (SVGCircleElement::toPathData):
+        * ksvg2/svg/SVGEllipseElement.cpp:
+        (WebCore::SVGEllipseElement::toPathData):
+        * ksvg2/svg/SVGFEImageElement.cpp:
+        * ksvg2/svg/SVGGElement.cpp:
+        * ksvg2/svg/SVGImageElement.cpp:
+        * ksvg2/svg/SVGLineElement.cpp:
+        (SVGLineElement::toPathData):
+        * ksvg2/svg/SVGMarkerElement.cpp:
+        * ksvg2/svg/SVGPathElement.cpp:
+        * ksvg2/svg/SVGPatternElement.cpp:
+        * ksvg2/svg/SVGPolygonElement.cpp:
+        * ksvg2/svg/SVGPolylineElement.cpp:
+        * ksvg2/svg/SVGRectElement.cpp:
+        (WebCore::SVGRectElement::toPathData):
+        * ksvg2/svg/SVGSVGElement.cpp:
+        * ksvg2/svg/SVGStyledElement.cpp:
+        (WebCore::SVGStyledElement::createRenderer):
+        * ksvg2/svg/SVGSwitchElement.cpp:
+        * ksvg2/svg/SVGTextElement.cpp:
+        * ksvg2/svg/SVGUseElement.cpp:
+        * platform/Path.h:
+        (WebCore::):
+        * platform/cg/PathCG.cpp:
+        (WebCore::CGPathToCFStringApplierFunction):
+        (WebCore::CGPathApplierToPathApplier):
+        (WebCore::Path::apply):
+        (WebCore::Path::transform):
+        * platform/qt/PathQt.cpp:
+        (WebCore::Path::apply):
+
 2006-09-03  Timothy Hatcher  <timothy@apple.com>
 
         Reviewed by Darin.
index 2e1225cc5d5d2a5dee037b235a515c5391addf5e..5e1cd754d3316b2eb850a4c78072ad0420c314c7 100644 (file)
                A88AD3B60952486E001DD196 /* QuartzSupport.mm in Sources */ = {isa = PBXBuildFile; fileRef = A8C0FB77089701F800BA5114 /* QuartzSupport.mm */; };
                A88AD3B90952486E001DD196 /* RenderSVGContainer.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A8C0FB7A089701F800BA5114 /* RenderSVGContainer.cpp */; };
                A88AD3BA0952486E001DD196 /* RenderSVGContainer.h in Headers */ = {isa = PBXBuildFile; fileRef = A8C0FB7B089701F800BA5114 /* RenderSVGContainer.h */; };
-               A88AD3BB0952486E001DD196 /* KCanvasCreator.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A8C0FB7C089701F800BA5114 /* KCanvasCreator.cpp */; };
-               A88AD3BC0952486E001DD196 /* KCanvasCreator.h in Headers */ = {isa = PBXBuildFile; fileRef = A8C0FB7D089701F800BA5114 /* KCanvasCreator.h */; };
                A88AD3BD0952486E001DD196 /* KCanvasFilters.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A8C0FB7E089701F800BA5114 /* KCanvasFilters.cpp */; };
                A88AD3BE0952486E001DD196 /* KCanvasFilters.h in Headers */ = {isa = PBXBuildFile; fileRef = A8C0FB7F089701F800BA5114 /* KCanvasFilters.h */; };
                A88AD3C00952486E001DD196 /* KCanvasImage.h in Headers */ = {isa = PBXBuildFile; fileRef = A8C0FB81089701F800BA5114 /* KCanvasImage.h */; };
                A8FEFB320979F4F6005839FD /* SVGForeignObjectElement.h in Headers */ = {isa = PBXBuildFile; fileRef = A8FEFB300979F4F6005839FD /* SVGForeignObjectElement.h */; };
                AA84FC850AA0FE08007699AF /* JSSVGMetadataElement.cpp in Sources */ = {isa = PBXBuildFile; fileRef = AA84FC830AA0FE08007699AF /* JSSVGMetadataElement.cpp */; };
                AA84FC860AA0FE08007699AF /* JSSVGMetadataElement.h in Headers */ = {isa = PBXBuildFile; fileRef = AA84FC840AA0FE08007699AF /* JSSVGMetadataElement.h */; };
+               AA98B87D0AAA02F8001A44C2 /* Path.cpp in Sources */ = {isa = PBXBuildFile; fileRef = AA98B87C0AAA02F8001A44C2 /* Path.cpp */; };
                AAC8DAB10AA1002000DC0907 /* SVGMetadataElement.cpp in Sources */ = {isa = PBXBuildFile; fileRef = AAC8DAAF0AA1002000DC0907 /* SVGMetadataElement.cpp */; };
                AAC8DAB20AA1002000DC0907 /* SVGMetadataElement.h in Headers */ = {isa = PBXBuildFile; fileRef = AAC8DAB00AA1002000DC0907 /* SVGMetadataElement.h */; };
                AB23A31209BBA7760067CC53 /* HTMLTextFieldInnerElement.cpp in Sources */ = {isa = PBXBuildFile; fileRef = AB23A31009BBA7760067CC53 /* HTMLTextFieldInnerElement.cpp */; };
                A8C0FB77089701F800BA5114 /* QuartzSupport.mm */ = {isa = PBXFileReference; fileEncoding = 4; indentWidth = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = QuartzSupport.mm; sourceTree = "<group>"; tabWidth = 8; usesTabs = 0; };
                A8C0FB7A089701F800BA5114 /* RenderSVGContainer.cpp */ = {isa = PBXFileReference; fileEncoding = 4; indentWidth = 4; lastKnownFileType = sourcecode.cpp.cpp; path = RenderSVGContainer.cpp; sourceTree = "<group>"; tabWidth = 8; usesTabs = 0; };
                A8C0FB7B089701F800BA5114 /* RenderSVGContainer.h */ = {isa = PBXFileReference; fileEncoding = 4; indentWidth = 4; lastKnownFileType = sourcecode.c.h; path = RenderSVGContainer.h; sourceTree = "<group>"; tabWidth = 8; usesTabs = 0; };
-               A8C0FB7C089701F800BA5114 /* KCanvasCreator.cpp */ = {isa = PBXFileReference; fileEncoding = 4; indentWidth = 4; lastKnownFileType = sourcecode.cpp.cpp; path = KCanvasCreator.cpp; sourceTree = "<group>"; tabWidth = 8; usesTabs = 0; };
-               A8C0FB7D089701F800BA5114 /* KCanvasCreator.h */ = {isa = PBXFileReference; fileEncoding = 4; indentWidth = 4; lastKnownFileType = sourcecode.c.h; path = KCanvasCreator.h; sourceTree = "<group>"; tabWidth = 8; usesTabs = 0; };
                A8C0FB7E089701F800BA5114 /* KCanvasFilters.cpp */ = {isa = PBXFileReference; fileEncoding = 4; indentWidth = 4; lastKnownFileType = sourcecode.cpp.cpp; path = KCanvasFilters.cpp; sourceTree = "<group>"; tabWidth = 8; usesTabs = 0; };
                A8C0FB7F089701F800BA5114 /* KCanvasFilters.h */ = {isa = PBXFileReference; fileEncoding = 4; indentWidth = 4; lastKnownFileType = sourcecode.c.h; path = KCanvasFilters.h; sourceTree = "<group>"; tabWidth = 8; usesTabs = 0; };
                A8C0FB81089701F800BA5114 /* KCanvasImage.h */ = {isa = PBXFileReference; fileEncoding = 4; indentWidth = 4; lastKnownFileType = sourcecode.c.h; path = KCanvasImage.h; sourceTree = "<group>"; tabWidth = 8; usesTabs = 0; };
                A8FEFB300979F4F6005839FD /* SVGForeignObjectElement.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = SVGForeignObjectElement.h; sourceTree = "<group>"; };
                AA84FC830AA0FE08007699AF /* JSSVGMetadataElement.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = JSSVGMetadataElement.cpp; sourceTree = "<group>"; };
                AA84FC840AA0FE08007699AF /* JSSVGMetadataElement.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = JSSVGMetadataElement.h; sourceTree = "<group>"; };
+               AA98B87C0AAA02F8001A44C2 /* Path.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = Path.cpp; sourceTree = "<group>"; };
                AAC8DAAF0AA1002000DC0907 /* SVGMetadataElement.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = SVGMetadataElement.cpp; sourceTree = "<group>"; };
                AAC8DAB00AA1002000DC0907 /* SVGMetadataElement.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = SVGMetadataElement.h; sourceTree = "<group>"; };
                AB23A31009BBA7760067CC53 /* HTMLTextFieldInnerElement.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = HTMLTextFieldInnerElement.cpp; sourceTree = "<group>"; };
                                A8C0FB53089701F700BA5114 /* device */,
                                A8C0FB7A089701F800BA5114 /* RenderSVGContainer.cpp */,
                                A8C0FB7B089701F800BA5114 /* RenderSVGContainer.h */,
-                               A8C0FB7C089701F800BA5114 /* KCanvasCreator.cpp */,
-                               A8C0FB7D089701F800BA5114 /* KCanvasCreator.h */,
                                A8C0FB7E089701F800BA5114 /* KCanvasFilters.cpp */,
                                A8C0FB7F089701F800BA5114 /* KCanvasFilters.h */,
                                A8C0FB81089701F800BA5114 /* KCanvasImage.h */,
                BCF1A5BA097832090061A123 /* platform */ = {
                        isa = PBXGroup;
                        children = (
+                               AA98B87C0AAA02F8001A44C2 /* Path.cpp */,
                                1AE42F670AA4B8CB00C8612D /* cf */,
                                93032CCC09AEC36200F82A18 /* cg */,
                                6582A14809999D6C00BEEB6D /* mac */,
                                A88AD3B30952486E001DD196 /* KRenderingPaintServerQuartz.h in Headers */,
                                A88AD3B50952486E001DD196 /* QuartzSupport.h in Headers */,
                                A88AD3BA0952486E001DD196 /* RenderSVGContainer.h in Headers */,
-                               A88AD3BC0952486E001DD196 /* KCanvasCreator.h in Headers */,
                                A88AD3BE0952486E001DD196 /* KCanvasFilters.h in Headers */,
                                A88AD3C00952486E001DD196 /* KCanvasImage.h in Headers */,
                                A88AD3C20952486E001DD196 /* RenderPath.h in Headers */,
                                A88AD3B40952486E001DD196 /* KRenderingPaintServerQuartz.mm in Sources */,
                                A88AD3B60952486E001DD196 /* QuartzSupport.mm in Sources */,
                                A88AD3B90952486E001DD196 /* RenderSVGContainer.cpp in Sources */,
-                               A88AD3BB0952486E001DD196 /* KCanvasCreator.cpp in Sources */,
                                A88AD3BD0952486E001DD196 /* KCanvasFilters.cpp in Sources */,
                                A88AD3C10952486E001DD196 /* RenderPath.cpp in Sources */,
                                A88AD3C80952486E001DD196 /* KCanvasResources.cpp in Sources */,
                                852B9E8A0AA79C47002ADA6E /* DOMHTMLOptionElement.mm in Sources */,
                                1A98955C0AA78149005EF5EF /* CString.cpp in Sources */,
                                1A98956B0AA78F80005EF5EF /* KURLCFNet.cpp in Sources */,
+                               AA98B87D0AAA02F8001A44C2 /* Path.cpp in Sources */,
                                85032DD80AA8C9BE007D3B7D /* DOMCSSCharsetRule.mm in Sources */,
                                85032DDA0AA8C9BE007D3B7D /* DOMCSSFontFaceRule.mm in Sources */,
                                85032DDC0AA8C9BE007D3B7D /* DOMCSSImportRule.mm in Sources */,
index 31071bf873f790c763e285fdc95599c180028d2c..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 100644 (file)
@@ -1,180 +0,0 @@
-/*
-    Copyright (C) 2004, 2005 Nikolas Zimmermann <wildfox@kde.org>
-                  2004, 2005 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.
-*/
-
-#include "config.h"
-#ifdef SVG_SUPPORT
-#include "KCanvasCreator.h"
-
-#include <math.h>
-
-#include "KRenderingDevice.h"
-#include "RenderSVGContainer.h"
-#include "Path.h"
-
-namespace WebCore {
-
-KCanvasCreator *KCanvasCreator::s_creator = 0;
-
-KCanvasCreator::KCanvasCreator()
-{
-}
-
-KCanvasCreator::~KCanvasCreator()
-{
-}
-
-KCanvasCreator *KCanvasCreator::self()
-{
-    if(!s_creator)
-        s_creator = new KCanvasCreator();
-
-    return s_creator;
-}
-
-Path KCanvasCreator::createRoundedRectangle(const FloatRect& box, const FloatSize& roundingRadii) const
-{
-    Path path;
-    float x = box.x();
-    float y = box.y();
-    float width = box.width();
-    float height = box.height();
-    float rx = roundingRadii.width();
-    float ry = roundingRadii.height();
-    if (width <= 0.0f || height <= 0.0f)
-        return path;
-
-    double nrx = rx, nry = ry;
-    // If rx is greater than half of the width of the rectangle
-    // then set rx to half of the width (required in SVG spec)
-    if (nrx > width / 2)
-        nrx = width / 2;
-
-    // If ry is greater than half of the height of the rectangle
-    // then set ry to half of the height (required in SVG spec)
-    if (nry > height / 2)
-        nry = height / 2;
-
-    path.moveTo(FloatPoint(x + nrx, y));
-
-    if (nrx < width / 2)
-        path.addLineTo(FloatPoint(x + width - rx, y));
-
-    path.addBezierCurveTo(FloatPoint(x + width - nrx * (1 - 0.552), y), FloatPoint(x + width, y + nry * (1 - 0.552)), FloatPoint(x + width, y + nry));
-
-    if (nry < height / 2)
-        path.addLineTo(FloatPoint(x + width, y + height - nry));
-
-    path.addBezierCurveTo(FloatPoint(x + width, y + height - nry * (1 - 0.552)), FloatPoint(x + width - nrx * (1 - 0.552), y + height), FloatPoint(x + width - nrx, y + height));
-
-    if (nrx < width / 2)
-        path.addLineTo(FloatPoint(x + nrx, y + height));
-
-    path.addBezierCurveTo(FloatPoint(x + nrx * (1 - 0.552), y + height), FloatPoint(x, y + height - nry * (1 - 0.552)), FloatPoint(x, y + height - nry));
-
-    if (nry < height / 2)
-        path.addLineTo(FloatPoint(x, y + nry));
-
-    path.addBezierCurveTo(FloatPoint(x, y + nry * (1 - 0.552)), FloatPoint(x + nrx * (1 - 0.552), y), FloatPoint(x + nrx, y));
-
-    path.closeSubpath();
-
-    return path;
-}
-
-Path KCanvasCreator::createRectangle(const FloatRect& box) const
-{
-    Path path;
-    float x = box.x();
-    float y = box.y();
-    float width = box.width();
-    float height = box.height();
-    if (width < 0.0f || height < 0.0f)
-        return path;
-    
-    path.moveTo(FloatPoint(x, y));
-    path.addLineTo(FloatPoint(x + width, y));
-    path.addLineTo(FloatPoint(x + width, y + height));
-    path.addLineTo(FloatPoint(x, y + height));
-    path.closeSubpath();
-
-    return path;
-}
-
-Path KCanvasCreator::createEllipse(const FloatPoint&c, float rx, float ry) const
-{
-    float cx = c.x();
-    float cy = c.y();
-    Path path;
-    if (rx <= 0.0f || ry <= 0.0f)
-        return path;
-
-    // Ellipse creation - nice & clean agg2 code
-    double x = cx, y = cy;
-
-    unsigned step = 0, num = 100;
-    bool running = true;
-    while(running)
-    {
-        if(step == num)
-        {
-            running = false;
-            break;
-        }
-
-        double angle = double(step) / double(num) * 2.0 * M_PI;
-        x = cx + cos(angle) * rx;
-        y = cy + sin(angle) * ry;
-
-        step++;
-        if(step == 1)
-            path.moveTo(FloatPoint(x, y));
-        else
-            path.addLineTo(FloatPoint(x, y));
-    }
-
-    path.closeSubpath();
-
-    return path;
-}
-
-Path KCanvasCreator::createCircle(const FloatPoint& c, float r) const
-{
-    return createEllipse(c, r, r);
-}
-
-Path KCanvasCreator::createLine(const FloatPoint& start, const FloatPoint& end) const
-{
-    Path path;
-    if (start.x() == end.x() && start.y() == end.y())
-        return path;
-
-    path.moveTo(start);
-    path.addLineTo(end);
-
-    return path;
-}
-
-}
-
-// vim:ts=4:noet
-#endif // SVG_SUPPORT
-
index 6ae9e9130faa3c7da3073f3997703584fcec3ed7..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 100644 (file)
@@ -1,58 +0,0 @@
-/*
-    Copyright (C) 2004, 2005 Nikolas Zimmermann <wildfox@kde.org>
-                  2004, 2005 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 KCanvasCreator_H
-#define KCanvasCreator_H
-#ifdef SVG_SUPPORT
-
-namespace WebCore {
-
-class Path;
-class FloatPoint;
-class FloatRect;
-class FloatSize;
-
-class KCanvasCreator
-{
-public:
-    KCanvasCreator();
-    virtual ~KCanvasCreator();
-
-    static KCanvasCreator *self();
-
-    // Canvas path creation
-    Path createRoundedRectangle(const FloatRect&, const FloatSize&) const;
-    Path createRectangle(const FloatRect&) const;
-    Path createEllipse(const FloatPoint&, float rx, float ry) const;
-    Path createCircle(const FloatPoint&, float r) const;
-    Path createLine(const FloatPoint&, const FloatPoint&) const;
-
-private:
-    static KCanvasCreator *s_creator;
-};
-
-}
-
-#endif // SVG_SUPPORT
-#endif
-
-// vim:ts=4:noet
index 89454dbfec72d656434db728683bbc51516fbc90..f70fff13fc633a0b2858b9121f7791e08540daa8 100644 (file)
@@ -25,6 +25,8 @@
 #ifdef SVG_SUPPORT
 #include "RenderPath.h"
 
+#include <math.h>
+
 #include "GraphicsContext.h"
 #include "RenderSVGContainer.h"
 #include "KRenderingDevice.h"
@@ -312,8 +314,142 @@ bool RenderPath::nodeAtPoint(NodeInfo& info, int _x, int _y, int _tx, int _ty, H
     return false;
 }
 
+enum MarkerType {
+    Start,
+    Mid,
+    End
+};
+
+struct MarkerData {
+    FloatPoint origin;
+    double strokeWidth;
+    FloatPoint inslopePoints[2];
+    FloatPoint outslopePoints[2];
+    MarkerType type;
+    KCanvasMarker *marker;
+};
+
+struct DrawMarkersData {
+    DrawMarkersData(GraphicsContext*, KCanvasMarker* startMarker, KCanvasMarker* midMarker, double strokeWidth);
+    GraphicsContext* context;
+    int elementIndex;
+    MarkerData previousMarkerData;
+    KCanvasMarker* midMarker;
+};
+
+DrawMarkersData::DrawMarkersData(GraphicsContext* c, KCanvasMarker *start, KCanvasMarker *mid, double strokeWidth)
+    : context(c)
+    , elementIndex(0)
+    , midMarker(mid)
+{
+    previousMarkerData.origin = FloatPoint();
+    previousMarkerData.strokeWidth = strokeWidth;
+    previousMarkerData.marker = start;
+    previousMarkerData.type = Start;
 }
 
-// vim:ts=4:noet
-#endif // SVG_SUPPORT
+static void drawMarkerWithData(GraphicsContext* context, MarkerData &data)
+{
+    if (!data.marker)
+        return;
+    
+    FloatPoint inslopeChange = data.inslopePoints[1] - FloatSize(data.inslopePoints[0].x(), data.inslopePoints[0].y());
+    FloatPoint outslopeChange = data.outslopePoints[1] - FloatSize(data.outslopePoints[0].x(), data.outslopePoints[0].y());
+    
+    static const double deg2rad = M_PI/180.0;
+    double inslope = atan2(inslopeChange.y(), inslopeChange.x()) / deg2rad;
+    double outslope = atan2(outslopeChange.y(), outslopeChange.x()) / deg2rad;
+    
+    double angle = 0.0;
+    switch (data.type) {
+        case Start:
+            angle = outslope;
+            break;
+        case Mid:
+            angle = (inslope + outslope) / 2;
+            break;
+        case End:
+            angle = inslope;
+    }
+    
+    data.marker->draw(context, FloatRect(), data.origin.x(), data.origin.y(), data.strokeWidth, angle);
+}
+
+static inline void updateMarkerDataForElement(MarkerData &previousMarkerData, const PathElement *element)
+{
+    FloatPoint *points = element->points;
+    
+    switch (element->type) {
+    case PathElementAddQuadCurveToPoint:
+        // TODO
+        previousMarkerData.origin = points[1];
+        break;
+    case PathElementAddCurveToPoint:
+        previousMarkerData.inslopePoints[0] = points[1];
+        previousMarkerData.inslopePoints[1] = points[2];
+        previousMarkerData.origin = points[2];
+        break;
+    case PathElementMoveToPoint:
+    case PathElementAddLineToPoint:
+    case PathElementCloseSubpath:
+        previousMarkerData.inslopePoints[0] = previousMarkerData.origin;
+        previousMarkerData.inslopePoints[1] = points[0];
+        previousMarkerData.origin = points[0];
+    }
+}
+
+static void drawStartAndMidMarkers(void *info, const PathElement *element)
+{
+    DrawMarkersData &data = *(DrawMarkersData *)info;
+
+    int elementIndex = data.elementIndex;
+    MarkerData &previousMarkerData = data.previousMarkerData;
 
+    FloatPoint *points = element->points;
+
+    // First update the outslope for the previous element
+    previousMarkerData.outslopePoints[0] = previousMarkerData.origin;
+    previousMarkerData.outslopePoints[1] = points[0];
+
+    // Draw the marker for the previous element
+    if (elementIndex != 0)
+        drawMarkerWithData(data.context, previousMarkerData);
+
+    // Update our marker data for this element
+    updateMarkerDataForElement(previousMarkerData, element);
+
+    if (elementIndex == 1) {
+        // After drawing the start marker, switch to drawing mid markers
+        previousMarkerData.marker = data.midMarker;
+        previousMarkerData.type = Mid;
+    }
+
+    data.elementIndex++;
+}
+
+void RenderPath::drawMarkersIfNeeded(GraphicsContext* context, const FloatRect& rect, const Path& path) const
+{
+    Document *doc = document();
+    const SVGRenderStyle *svgStyle = style()->svgStyle();
+
+    KCanvasMarker *startMarker = getMarkerById(doc, svgStyle->startMarker().mid(1));
+    KCanvasMarker *midMarker = getMarkerById(doc, svgStyle->midMarker().mid(1));
+    KCanvasMarker *endMarker = getMarkerById(doc, svgStyle->endMarker().mid(1));
+    
+    if (!startMarker && !midMarker && !endMarker)
+        return;
+
+    double strokeWidth = KSVGPainterFactory::cssPrimitiveToLength(this, style()->svgStyle()->strokeWidth(), 1.0);
+
+    DrawMarkersData data(context, startMarker, midMarker, strokeWidth);
+
+    path.apply(&data, drawStartAndMidMarkers);
+
+    data.previousMarkerData.marker = endMarker;
+    data.previousMarkerData.type = End;
+    drawMarkerWithData(context, data.previousMarkerData);
+}
+
+}
+
+#endif // SVG_SUPPORT
index 4236c0a959a756fc19c817739b67a199210b24b9..302d12b7ba65730c761369be084e1418168e3edc 100644 (file)
@@ -22,8 +22,8 @@
     Boston, MA 02111-1307, USA.
 */
 
-#ifndef KCanvasItem_H
-#define KCanvasItem_H
+#ifndef RenderPath_H
+#define RenderPath_H
 #ifdef SVG_SUPPORT
 
 #include "DeprecatedValueList.h"
@@ -47,7 +47,7 @@ public:
 
     // Hit-detection seperated for the fill and the stroke
     virtual bool fillContains(const FloatPoint&, bool requiresFill = true) const;
-    virtual bool strokeContains(const FloatPoint&, bool requiresStroke = true) const = 0;
+    virtual bool strokeContains(const FloatPoint&, bool requiresStroke = true) const;
 
     // Returns an unscaled bounding box (not even including localTransform()) for this vector path
     virtual FloatRect relativeBBox(bool includeStroke = true) const;
@@ -89,9 +89,8 @@ public:
         bool canHitFill;  
     };
 
-protected:
-    virtual void drawMarkersIfNeeded(GraphicsContext*, const FloatRect&, const Path&) const = 0;
-    virtual FloatRect strokeBBox() const = 0;
+    virtual void drawMarkersIfNeeded(GraphicsContext*, const FloatRect&, const Path&) const;
+    virtual FloatRect strokeBBox() const;
 
 private:
     FloatPoint mapAbsolutePointToLocal(const FloatPoint&) const;
index 92cf53b75f7f6dfdb5248a7f6155326d3fbf25f6..248a549d3904cad79bb45ce61ec2ec71e3e93b3b 100644 (file)
@@ -70,8 +70,6 @@ public:
     virtual KCanvasFilterEffect *createFilterEffect(const KCFilterEffectType &type) const = 0;
     virtual KRenderingPaintServer *createPaintServer(const KCPaintServerType &type) const = 0;
 
-    virtual RenderPath *createItem(RenderArena *arena, RenderStyle *style, SVGStyledElement *node, const Path& path) const = 0;
-
 private:
     Vector<KRenderingDeviceContext*> m_contextStack;
 };
index af9d4303e984a6946928794e073b107adf052582..222f94294319cb3cbfab72cf98981864f3034192 100644 (file)
@@ -183,14 +183,6 @@ KCanvasFilterEffect* KRenderingDeviceQt::createFilterEffect(const KCFilterEffect
     return 0;
 }
 
-// item creation
-RenderPath* KRenderingDeviceQt::createItem(RenderArena* arena, RenderStyle* style, SVGStyledElement* node, const Path& path) const
-{
-    RenderPath* item = new (arena) RenderPathQt(style, node);
-    item->setPath(path);
-    return item;
-}
-
 KRenderingDevice* renderingDevice()
 {
     static KRenderingDevice *sharedRenderingDevice = new KRenderingDeviceQt();
index 6146eab9f2b42c81ff6a17113887e678b29de0fa..0c15fc75be8a8bc5abedddb035dc0f50c421962e 100644 (file)
@@ -80,9 +80,6 @@ public:
     virtual KCanvasResource* createResource(const KCResourceType&) const;
     virtual KRenderingPaintServer* createPaintServer(const KCPaintServerType&) const;
     virtual KCanvasFilterEffect* createFilterEffect(const KCFilterEffectType&) const;
-
-    // item creation
-    virtual RenderPath* createItem(RenderArena*, RenderStyle*, SVGStyledElement*, const Path&) const;
 };
 
 }
index c512ed2aaa12648aa3886a7b22d127cdcc5562d5..382cd5a42e1faf5eb2c1c2ba2ca9cf34fcc0224c 100644 (file)
@@ -22,7 +22,7 @@
 */
 
 #include "config.h"
-#include "RenderPathQt.h"
+#include "RenderPath.h"
 #include "KCanvasRenderingStyle.h"
 #include "KRenderingStrokePainter.h"
 
 
 namespace WebCore {
     
-RenderPathQt::RenderPathQt(RenderStyle* style, SVGStyledElement* node)
-    : RenderPath(style, node)
-{
-}
-
-void RenderPathQt::drawMarkersIfNeeded(GraphicsContext*, const FloatRect&, const Path&) const
-{
-    qDebug("RenderPathQt::drawMarkersIfNeeded() TODO!");
-}
-
-bool RenderPathQt::strokeContains(const FloatPoint& point, bool requiresStroke) const
+bool RenderPath::strokeContains(const FloatPoint& point, bool requiresStroke) const
 {
     if (path().isEmpty())
         return false;
@@ -83,7 +73,7 @@ static QPainterPath getPathStroke(const QPainterPath &path, const KRenderingStro
     return s.createStroke(path);
 }
 
-FloatRect RenderPathQt::strokeBBox() const
+FloatRect RenderPath::strokeBBox() const
 {
     KRenderingStrokePainter strokePainter = KSVGPainterFactory::strokePainter(style(), this);
     QPainterPath outline = getPathStroke(*(path().platformPath()), strokePainter);
index 217c7c5ff8309393a192f2d6b5fe6f11b0500a4e..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 100644 (file)
@@ -1,47 +0,0 @@
-/*
-    Copyright (C) 2004, 2005, 2006 Nikolas Zimmermann <wildfox@kde.org>
-                  2004, 2005, 2006 Rob Buis <buis@kde.org>
-                  2005 Eric Seidel <eric.seidel@kdemail.net>
-
-    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 RenderPathQt_H
-#define RenderPathQt_H
-
-#include "RenderPath.h"
-
-namespace WebCore {
-
-class RenderPathQt : public RenderPath
-{
-public:
-    RenderPathQt(RenderStyle*, SVGStyledElement*);
-
-    virtual bool strokeContains(const FloatPoint&, bool requiresStroke) const;
-    virtual FloatRect strokeBBox() const;
-
-protected:
-    virtual void drawMarkersIfNeeded(GraphicsContext*, const FloatRect&, const Path&) const;
-};
-
-}
-
-#endif
-
-// vim:ts=4:noet
index a570063a5e4ce7a25b06f9542c55c49510f58c6b..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 100644 (file)
@@ -1,47 +0,0 @@
-/*
- * Copyright (C) 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. 
- */
-
-#ifndef KCanvasItemQuartz_h
-#define KCanvasItemQuartz_h
-
-#import "kcanvas/RenderPath.h"
-
-#include "AffineTransform.h"
-
-namespace WebCore {
-
-class KCanvasItemQuartz : public RenderPath {
-public:
-    KCanvasItemQuartz(RenderStyle*, SVGStyledElement*);
-    virtual ~KCanvasItemQuartz() { }
-    
-    virtual bool strokeContains(const FloatPoint& point, bool = true) const;
-    virtual void drawMarkersIfNeeded(GraphicsContext*, const FloatRect&, const Path&) const;
-    virtual FloatRect strokeBBox() const;
-};
-
-}
-
-#endif
index 34003507915ae8319ab3e9b836108acec397c5ca..492418d2c1fff78182a7c070acbfb4afe5bf88de 100644 (file)
@@ -27,7 +27,6 @@
 
 #include "config.h"
 #ifdef SVG_SUPPORT
-#import "KCanvasItemQuartz.h"
 
 #import <wtf/Assertions.h>
 
 
 namespace WebCore {
 
-KCanvasItemQuartz::KCanvasItemQuartz(RenderStyle *style, SVGStyledElement *node) : RenderPath(style, node)
-{
-}
-
-typedef enum {
-    Start,
-    Mid,
-    End
-} MarkerType;
-
-struct MarkerData {
-    CGPoint origin;
-    double strokeWidth;
-    CGPoint inslopePoints[2];
-    CGPoint outslopePoints[2];
-    MarkerType type;
-    KCanvasMarker *marker;
-};
-
-struct DrawMarkersData {
-    DrawMarkersData(GraphicsContext*, KCanvasMarker* startMarker, KCanvasMarker* midMarker, double strokeWidth);
-    GraphicsContext* context;
-    int elementIndex;
-    MarkerData previousMarkerData;
-    KCanvasMarker* midMarker;
-};
-
-DrawMarkersData::DrawMarkersData(GraphicsContext* c, KCanvasMarker *start, KCanvasMarker *mid, double strokeWidth)
-    : context(c)
-{
-    elementIndex = 0;
-    midMarker = mid;
-    
-    previousMarkerData.origin = CGPointZero;
-    previousMarkerData.strokeWidth = strokeWidth;
-    previousMarkerData.marker = start;
-    previousMarkerData.type = Start;
-}
-
-static void drawMarkerWithData(GraphicsContext* context, MarkerData &data)
-{
-    if (!data.marker)
-        return;
-    
-    CGPoint inslopeChange = CGPointSubtractPoints(data.inslopePoints[1], data.inslopePoints[0]);
-    CGPoint outslopeChange = CGPointSubtractPoints(data.outslopePoints[1], data.outslopePoints[0]);
-    
-    static const double deg2rad = M_PI/180.0;
-    double inslope = atan2(inslopeChange.y, inslopeChange.x) / deg2rad;
-    double outslope = atan2(outslopeChange.y, outslopeChange.x) / deg2rad;
-    
-    double angle;
-    if (data.type == Start)
-        angle = outslope;
-    else if (data.type == Mid)
-        angle = (inslope + outslope) / 2;
-    else // (data.type == End)
-        angle = inslope;
-    
-    data.marker->draw(context, FloatRect(), data.origin.x, data.origin.y, data.strokeWidth, angle);
-}
-
-static inline void updateMarkerDataForElement(MarkerData &previousMarkerData, const CGPathElement *element)
-{
-    CGPoint *points = element->points;
-    
-    switch (element->type) {
-    case kCGPathElementAddQuadCurveToPoint:
-        // TODO
-        previousMarkerData.origin = points[1];
-        break;
-    case kCGPathElementAddCurveToPoint:
-        previousMarkerData.inslopePoints[0] = points[1];
-        previousMarkerData.inslopePoints[1] = points[2];
-        previousMarkerData.origin = points[2];
-        break;
-    default:
-        previousMarkerData.inslopePoints[0] = previousMarkerData.origin;
-        previousMarkerData.inslopePoints[1] = points[0];
-        previousMarkerData.origin = points[0];
-        break;
-    }
-}
-
-static void drawStartAndMidMarkers(void *info, const CGPathElement *element)
-{
-    DrawMarkersData &data = *(DrawMarkersData *)info;
-
-    int elementIndex = data.elementIndex;
-    MarkerData &previousMarkerData = data.previousMarkerData;
-
-    CGPoint *points = element->points;
-
-    // First update the outslope for the previous element
-    previousMarkerData.outslopePoints[0] = previousMarkerData.origin;
-    previousMarkerData.outslopePoints[1] = points[0];
-
-    // Draw the marker for the previous element
-    if (elementIndex != 0)
-        drawMarkerWithData(data.context, previousMarkerData);
-
-    // Update our marker data for this element
-    updateMarkerDataForElement(previousMarkerData, element);
-
-    if (elementIndex == 1) {
-        // After drawing the start marker, switch to drawing mid markers
-        previousMarkerData.marker = data.midMarker;
-        previousMarkerData.type = Mid;
-    }
-
-    data.elementIndex++;
-}
-
-void KCanvasItemQuartz::drawMarkersIfNeeded(GraphicsContext* context, const FloatRect& rect, const Path& path) const
-{
-    Document *doc = document();
-    const SVGRenderStyle *svgStyle = style()->svgStyle();
-
-    KCanvasMarker *startMarker = getMarkerById(doc, svgStyle->startMarker().mid(1));
-    KCanvasMarker *midMarker = getMarkerById(doc, svgStyle->midMarker().mid(1));
-    KCanvasMarker *endMarker = getMarkerById(doc, svgStyle->endMarker().mid(1));
-    
-    if (!startMarker && !midMarker && !endMarker)
-        return;
-
-    double strokeWidth = KSVGPainterFactory::cssPrimitiveToLength(this, style()->svgStyle()->strokeWidth(), 1.0);
-
-    DrawMarkersData data(context, startMarker, midMarker, strokeWidth);
-
-    CGPathRef cgPath = path.platformPath();
-    CGPathApply(cgPath, &data, drawStartAndMidMarkers);
-
-    data.previousMarkerData.marker = endMarker;
-    data.previousMarkerData.type = End;
-    drawMarkerWithData(context, data.previousMarkerData);
-}
-
-FloatRect KCanvasItemQuartz::strokeBBox() const
+FloatRect RenderPath::strokeBBox() const
 {
     if (KSVGPainterFactory::isStroked(style())) {
         KRenderingStrokePainter strokePainter = KSVGPainterFactory::strokePainter(style(), this);
@@ -197,7 +59,7 @@ FloatRect KCanvasItemQuartz::strokeBBox() const
 }
 
 
-bool KCanvasItemQuartz::strokeContains(const FloatPoint& point, bool requiresStroke) const
+bool RenderPath::strokeContains(const FloatPoint& point, bool requiresStroke) const
 {
     if (path().isEmpty())
         return false;
index a0f483432ef1ada0cec1fcb023f9d602704ce7d9..e3b17b1a6e8461c8d37938757a87709ae1a4a57a 100644 (file)
@@ -83,9 +83,6 @@ public:
     virtual KRenderingPaintServer *createPaintServer(const KCPaintServerType &type) const;
     virtual KCanvasFilterEffect *createFilterEffect(const KCFilterEffectType &type) const;
     
-    // item creation
-    virtual RenderPath *createItem(RenderArena *arena, RenderStyle *style, SVGStyledElement *node, const Path& path) const;
-
     // filters (mostly debugging)
     static bool filtersEnabled();
     static void setFiltersEnabled(bool enabled);
index 94be2811021d02efc3d03be9cfaab68926b9fe83..0df1b878a40f8d3e47f9de724942a275d9c29ea4 100644 (file)
@@ -31,7 +31,6 @@
 #import "FoundationExtras.h"
 #import "GraphicsContext.h"
 #import "KCanvasFilterQuartz.h"
-#import "KCanvasItemQuartz.h"
 #import "KCanvasMaskerQuartz.h"
 #import "KCanvasResourcesQuartz.h"
 #import "KRenderingFillPainter.h"
@@ -184,13 +183,6 @@ KRenderingPaintServer *KRenderingDeviceQuartz::createPaintServer(const KCPaintSe
     return newServer;
 }
 
-RenderPath *KRenderingDeviceQuartz::createItem(RenderArena *arena, RenderStyle *style, SVGStyledElement *node, const Path& path) const
-{
-    RenderPath *item = new (arena) KCanvasItemQuartz(style, node);
-    item->setPath(path);
-    return item;
-}
-
 KCanvasResource *KRenderingDeviceQuartz::createResource(const KCResourceType &type) const
 {
     switch (type) {
index 3e2ef65276f01590df65ff5abca262a04df6f12d..cab9a5473d434469668d49534b45671fc013ac40 100644 (file)
@@ -79,11 +79,6 @@ static inline CGLineJoin CGLineJoinFromKC(KCJoinStyle join)
     return kCGLineJoinMiter;
 }
 
-static inline CGPoint CGPointSubtractPoints(CGPoint a, CGPoint b)
-{
-    return CGPointMake(a.x - b.x, a.y - b.y);
-}
-
 }
 
 #endif // SVG_SUPPORT
index 591ceb10b78ce85cd941fd47394616f73ccf949b..1b19ec20b82f4ec94be1b255b1db8ca768b0775e 100644 (file)
@@ -36,7 +36,6 @@
 #include "SVGNames.h"
 #include "csshelper.h"
 #include <kcanvas/RenderSVGContainer.h>
-#include <kcanvas/KCanvasCreator.h>
 #include <kcanvas/device/KRenderingDevice.h>
 
 namespace WebCore {
index d660c481652d918a0f9153c1f8becc23770c01a0..739b4c161b612444b4ff0ab24bd6c8f8a6770ea8 100644 (file)
@@ -31,8 +31,6 @@
 #include "SVGCircleElement.h"
 #include "SVGAnimatedLength.h"
 
-#include <kcanvas/KCanvasCreator.h>
-
 using namespace WebCore;
 
 SVGCircleElement::SVGCircleElement(const QualifiedName& tagName, Document *doc)
@@ -82,7 +80,7 @@ Path SVGCircleElement::toPathData() const
     float _cx = cx()->baseVal()->value(), _cy = cy()->baseVal()->value();
     float _r = r()->baseVal()->value();
 
-    return KCanvasCreator::self()->createCircle(FloatPoint(_cx, _cy), _r);
+    return Path::createCircle(FloatPoint(_cx, _cy), _r);
 }
 
 const SVGStyledElement *SVGCircleElement::pushAttributeContext(const SVGStyledElement *context)
index 99b1257abee8be9a1c1732bf7cf6b941e4da6c76..21be1014071c529aea5f3bf2855e6f3ccde9fb7e 100644 (file)
@@ -31,8 +31,6 @@
 #include "SVGEllipseElement.h"
 #include "SVGAnimatedLength.h"
 
-#include <kcanvas/KCanvasCreator.h>
-
 namespace WebCore {
 
 SVGEllipseElement::SVGEllipseElement(const QualifiedName& tagName, Document *doc)
@@ -89,7 +87,7 @@ Path SVGEllipseElement::toPathData() const
     float _cx = cx()->baseVal()->value(), _cy = cy()->baseVal()->value();
     float _rx = rx()->baseVal()->value(), _ry = ry()->baseVal()->value();
 
-    return KCanvasCreator::self()->createEllipse(FloatPoint(_cx, _cy), _rx, _ry);
+    return Path::createEllipse(FloatPoint(_cx, _cy), _rx, _ry);
 }
 
 const SVGStyledElement *SVGEllipseElement::pushAttributeContext(const SVGStyledElement *context)
index 0ec32b33d555993d16a0ce631842a26ee4be29a3..c14c7ea5db0b21fdeabe7212c30500c21e0184e3 100644 (file)
@@ -35,7 +35,6 @@
 #include "SVGAnimatedString.h"
 #include "SVGHelper.h"
 #include "SVGNames.h"
-#include <kcanvas/KCanvasCreator.h>
 #include <kcanvas/KCanvasImage.h>
 #include <kcanvas/device/KRenderingDevice.h>
 #include <kcanvas/device/KRenderingFillPainter.h>
index fe324203af39636a3c0056d073c297771fd4b635..d09b79fa2d4e3181b19ab0244b3f542ea43153f1 100644 (file)
@@ -24,7 +24,6 @@
 #ifdef SVG_SUPPORT
 #include "SVGGElement.h"
 
-#include <kcanvas/KCanvasCreator.h>
 #include <kcanvas/RenderSVGContainer.h>
 #include <kcanvas/device/KRenderingDevice.h>
 
index 0a5884a1a7438a5c4bdcb440be52613c5af8612a..b568ff5478e2f32e5e419c2441ec610e4be1ff99 100644 (file)
@@ -39,7 +39,6 @@
 #include "SVGSVGElement.h"
 #include "XLinkNames.h"
 #include <kcanvas/RenderSVGContainer.h>
-#include <kcanvas/KCanvasCreator.h>
 #include <kcanvas/KCanvasImage.h>
 #include <wtf/Assertions.h>
 
index f6a2b52d1245eb6fc140247845fdd5899c45724f..f851d14460f86399cef0bdb5cc83c263c75451e1 100644 (file)
@@ -31,8 +31,6 @@
 #include "SVGLineElement.h"
 #include "SVGAnimatedLength.h"
 
-#include <kcanvas/KCanvasCreator.h>
-
 using namespace WebCore;
 
 SVGLineElement::SVGLineElement(const QualifiedName& tagName, Document *doc)
@@ -89,7 +87,7 @@ Path SVGLineElement::toPathData() const
     float _x1 = x1()->baseVal()->value(), _y1 = y1()->baseVal()->value();
     float _x2 = x2()->baseVal()->value(), _y2 = y2()->baseVal()->value();
 
-    return KCanvasCreator::self()->createLine(FloatPoint(_x1, _y1), FloatPoint(_x2, _y2));
+    return Path::createLine(FloatPoint(_x1, _y1), FloatPoint(_x2, _y2));
 }
 
 const SVGStyledElement *SVGLineElement::pushAttributeContext(const SVGStyledElement *context)
index 63384daf4d1ed9cb0b27d576df3531bf93351307..f62ab8839dbe3cafff9fc5b443b639ff75abfddb 100644 (file)
@@ -37,7 +37,6 @@
 #include "SVGSVGElement.h"
 #include "ksvg.h"
 #include <kcanvas/RenderSVGContainer.h>
-#include <kcanvas/KCanvasCreator.h>
 #include <kcanvas/device/KRenderingDevice.h>
 
 namespace WebCore {
index 59e72a7e8ba18cac10e477679c6a8c9f52774426..ae4dc7e4a8ede3dbec949f3fc45168400e608ca5 100644 (file)
@@ -43,7 +43,6 @@
 #include "SVGPathSegCurvetoCubicSmooth.h"
 #include "SVGPathSegCurvetoQuadraticSmooth.h"
 
-#include <kcanvas/KCanvasCreator.h>
 #include <kcanvas/device/KRenderingDevice.h>
 
 namespace WebCore {
index fb06571c9e59b09515e4280b733fa1d49ca94808..4a97bf7cd949fdb1da980c0a47a7ad1a27d2be74 100644 (file)
@@ -28,7 +28,6 @@
 #include "Document.h"
 #include "GraphicsContext.h"
 #include "RenderSVGContainer.h"
-#include "KCanvasCreator.h"
 #include "KCanvasImage.h"
 #include "KCanvasRenderingStyle.h"
 #include "KRenderingDevice.h"
index b46988231a08ab3662510267b8c0e4d6a9d213af..28264268022ce6586b8a3be9f18a6a887bcb1258 100644 (file)
@@ -25,7 +25,6 @@
 #include "SVGPointList.h"
 #include "SVGPolygonElement.h"
 
-#include <kcanvas/KCanvasCreator.h>
 #include <kcanvas/device/KRenderingDevice.h>
 
 using namespace WebCore;
index 60ecb3b594887c7974a156db1625c315cef60d89..e9828f1d8a1c548d646e316f26002736e1aaad14 100644 (file)
@@ -25,7 +25,6 @@
 #include "SVGPointList.h"
 #include "SVGPolylineElement.h"
 
-#include <kcanvas/KCanvasCreator.h>
 #include <kcanvas/device/KRenderingDevice.h>
 
 using namespace WebCore;
index d4550bf24daeab6ee3d1d38dfa305472217e4ad1..823a356d74f1a55c7e99461cf2d513f20d4e46c6 100644 (file)
@@ -33,7 +33,6 @@
 #include <kcanvas/device/KRenderingDevice.h>
 #include <kcanvas/device/KRenderingFillPainter.h>
 #include <kcanvas/device/KRenderingPaintServerSolid.h>
-#include <kcanvas/KCanvasCreator.h>
 
 namespace WebCore {
 
@@ -111,10 +110,10 @@ Path SVGRectElement::toPathData() const
     {
         float _rx = hasRx ? rx()->baseVal()->value() : ry()->baseVal()->value();
         float _ry = hasRy ? ry()->baseVal()->value() : rx()->baseVal()->value();
-        return KCanvasCreator::self()->createRoundedRectangle(FloatRect(_x, _y, _width, _height), FloatSize(_rx, _ry));
+        return Path::createRoundedRectangle(FloatRect(_x, _y, _width, _height), FloatSize(_rx, _ry));
     }
 
-    return KCanvasCreator::self()->createRectangle(FloatRect(_x, _y, _width, _height));
+    return Path::createRectangle(FloatRect(_x, _y, _width, _height));
 }
 
 const SVGStyledElement *SVGRectElement::pushAttributeContext(const SVGStyledElement *context)
index 527f45a8157fb4030e8b46f485edbeef93d1f9d1..5ea94b271cb7d239f607befeb93693f3cd9e8fed 100644 (file)
@@ -42,7 +42,6 @@
 #include "SVGZoomEvent.h"
 #include "ksvg.h"
 #include <kcanvas/RenderSVGContainer.h>
-#include <kcanvas/KCanvasCreator.h>
 #include <kcanvas/device/KRenderingDevice.h>
 #include "TextStream.h"
 
index 3bac764c3c9e2a191fd5c111766c760aeaa797c7..87ce88d4522104801d2637e3d63213209ae15940 100644 (file)
@@ -26,7 +26,6 @@
 
 #include "Attr.h"
 #include "Document.h"
-#include "KCanvasCreator.h"
 #include "KCanvasRenderingStyle.h"
 #include "KRenderingDevice.h"
 #include "PlatformString.h"
@@ -71,7 +70,10 @@ RenderObject* SVGStyledElement::createRenderer(RenderArena* arena, RenderStyle*
     Path pathData = toPathData();
     if (pathData.isEmpty())
         return 0;
-    return renderingDevice()->createItem(arena, style, this, pathData);
+
+    RenderPath *item = new (arena) RenderPath(style, this);
+    item->setPath(pathData);
+    return item;
 }
 
 void SVGStyledElement::parseMappedAttribute(MappedAttribute* attr)
index 5fea452d0c558c1a9b7f28d1832dc8696f1689cb..ac21e5f6e02e96e46d71bae18cf9590e13f07ac6 100644 (file)
@@ -24,7 +24,6 @@
 #ifdef SVG_SUPPORT
 #include "Attr.h"
 
-#include <kcanvas/KCanvasCreator.h>
 #include <kcanvas/RenderSVGContainer.h>
 #include <kcanvas/device/KRenderingDevice.h>
 
index 44b6cf7fe1ff2662846500ccc425b4f670d1aaf5..1c65b00daee525bffb68401021de650ae687bf45 100644 (file)
@@ -31,7 +31,6 @@
 #include "SVGRenderStyle.h"
 #include "SVGTSpanElement.h"
 #include "RenderStyle.h"
-#include <kcanvas/KCanvasCreator.h>
 #include <kcanvas/RenderSVGText.h>
 #include "FloatRect.h"
 
index 5aa980c3d882b8c285ccdb941bf013264c4f3a55..553d00d2fa9084caa7a83a7316f3ba33cfc1fc4e 100644 (file)
@@ -38,7 +38,6 @@
 #include "SVGSymbolElement.h"
 #include "ksvg.h"
 #include <kcanvas/RenderSVGContainer.h>
-#include <kcanvas/KCanvasCreator.h>
 #include <kcanvas/device/KRenderingDevice.h>
 
 using namespace WebCore;
index ba1d0d3520c0a9c62604964b411423494d90f30f..4b3642be1a6a2efa7691ba94a71af904cebbfd74 100644 (file)
@@ -38,15 +38,31 @@ typedef void PlatformPath;
 
 namespace WebCore {
 
+    class AffineTransform;
+    class FloatPoint;
+    class FloatSize;
+    class FloatRect;
+    class String;
+
     enum WindRule {
         RULE_NONZERO = 0,
         RULE_EVENODD = 1
     };
 
-    class FloatPoint;
-    class FloatSize;
-    class FloatRect;
-    class String;
+    enum PathElementType {
+        PathElementMoveToPoint,
+        PathElementAddLineToPoint,
+        PathElementAddQuadCurveToPoint,
+        PathElementAddCurveToPoint,
+        PathElementCloseSubpath
+    };
+
+    struct PathElement {
+        PathElementType type;
+        FloatPoint* points;
+    };
+
+    typedef void (*PathApplierFunction) (void* info, const PathElement*);
 
     class Path {
     public:
@@ -82,6 +98,15 @@ namespace WebCore {
 
         PlatformPath* platformPath() const { return m_path; }
 
+        static Path createRoundedRectangle(const FloatRect&, const FloatSize& roundingRadii);
+        static Path createRectangle(const FloatRect&);
+        static Path createEllipse(const FloatPoint& center, float rx, float ry);
+        static Path createCircle(const FloatPoint& center, float r);
+        static Path createLine(const FloatPoint&, const FloatPoint&);
+
+        void apply(void* info, PathApplierFunction) const;
+        void transform(const AffineTransform&);
+
     private:
         PlatformPath* m_path;
         WindRule m_rule;
index 297bc252dd2664edf192c87466026ab78f8d26b7..6f3964572ca202ab78a5a5b0df451e39a45aa3b6 100644 (file)
@@ -31,6 +31,7 @@
 
 #include "FloatRect.h"
 #include "PlatformString.h"
+#include "AffineTransform.h"
 #include <ApplicationServices/ApplicationServices.h>
 
 namespace WebCore {
@@ -133,12 +134,12 @@ bool Path::isEmpty() const
     return CGPathIsEmpty(m_path);
  }
 
-void CGPathToCFStringApplierFunction(void *info, const CGPathElement *element)
+void CGPathToCFStringApplierFunction(voidinfo, const CGPathElement *element)
 {
     CFMutableStringRef string = (CFMutableStringRef)info;
     CFStringRef typeString = CFSTR("");
-    CGPoint *points = element->points;
-    switch(element->type) {
+    CGPointpoints = element->points;
+    switch (element->type) {
     case kCGPathElementMoveToPoint:
         CFStringAppendFormat(string, 0, CFSTR("M%.2f,%.2f"), points[0].x, points[0].y);
         break;
@@ -185,6 +186,56 @@ String Path::debugString() const
     return result;
 }
 
+struct PathApplierInfo {
+    void* info;
+    PathApplierFunction function;
+};
+
+void CGPathApplierToPathApplier(void *info, const CGPathElement *element)
+{
+    PathApplierInfo* pinfo = (PathApplierInfo*)info;
+    FloatPoint points[2];
+    PathElement pelement;
+    pelement.type = (PathElementType)element->type;
+    pelement.points = points;
+    CGPoint* cgPoints = element->points;
+    switch (element->type) {
+    case kCGPathElementMoveToPoint:
+    case kCGPathElementAddLineToPoint:
+        points[0] = cgPoints[0];
+        break;
+    case kCGPathElementAddQuadCurveToPoint:
+        points[0] = cgPoints[0];
+        points[1] = cgPoints[1];
+        break;
+    case kCGPathElementAddCurveToPoint:
+        points[0] = cgPoints[0];
+        points[1] = cgPoints[1];
+        points[2] = cgPoints[2];
+        break;
+    case kCGPathElementCloseSubpath:
+        break;
+    }
+    pinfo->function(pinfo->info, &pelement);
+}
+
+void Path::apply(void* info, PathApplierFunction function) const
+{
+    PathApplierInfo pinfo;
+    pinfo.info = info;
+    pinfo.function = function;
+    CGPathApply(m_path, &pinfo, CGPathApplierToPathApplier);
+}
+
+void Path::transform(const AffineTransform& transform)
+{
+    CGMutablePathRef path = CGPathCreateMutable();
+    CGAffineTransform transformCG = transform;
+    CGPathAddPath(path, &transformCG, m_path);
+    CGPathRelease(m_path);
+    m_path = path;
+}
+
 }
 
 #endif // PLATFORM(CG)
index d0dccc5e94eb050275baa3c099d459be2ba41247..a366b61addd4261a86edf3e2cf4ad509abf2e1c4 100644 (file)
@@ -219,6 +219,48 @@ String Path::debugString() const
     return ret;
 }
 
+void Path::apply(void* info, PathApplierFunction function) const
+{
+    PathElement pelement;
+    FloatPoint points[2];
+    pelement.points = points;
+    for (int i = 0; i < m_path->elementCount(); ++i) {
+        const QPainterPath::Element& cur = m_path->elementAt(i);
+
+        switch (cur.type) {
+            case QPainterPath::MoveToElement:
+                pelement.type = PathElementMoveToPoint;
+                pelement.points[0] = cur;
+                function(info, &pelement);
+                break;
+            case QPainterPath::LineToElement:
+                pelement.type = PathElementAddLineToPoint;
+                pelement.points[0] = cur;
+                function(info, &pelement);
+                break;
+            case QPainterPath::CurveToElement:
+            {
+                const QPainterPath::Element& c1 = m_path->elementAt(i + 1);
+                const QPainterPath::Element& c2 = m_path->elementAt(i + 2);
+
+                Q_ASSERT(c1.type == QPainterPath::CurveToDataElement);
+                Q_ASSERT(c2.type == QPainterPath::CurveToDataElement);
+
+                pelement.type = PathElementAddCurveToPoint;
+                pelement.points[0] = cur;
+                pelement.points[1] = c1;
+                pelement.points[2] = c2;
+                function(info, &pelement);
+
+                i += 2;
+                break;
+            }
+            case QPainterPath::CurveToDataElement:
+                Q_ASSERT(false);
+        }
+    }
+}
+
 }
 
 // vim: ts=4 sw=4 et