Reviewed by Eric.
authorrwlbuis <rwlbuis@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sun, 27 Aug 2006 10:47:15 +0000 (10:47 +0000)
committerrwlbuis <rwlbuis@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sun, 27 Aug 2006 10:47:15 +0000 (10:47 +0000)
        http://bugzilla.opendarwin.org/show_bug.cgi?id=10557
        KCanvasPath should be replace by platform/Path

        Refactoring out the KCanvasPath class.

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

64 files changed:
LayoutTests/ChangeLog
LayoutTests/svg/W3C-SVG-1.1/struct-dom-06-b-expected.txt
WebCore/CMakeLists.txt
WebCore/ChangeLog
WebCore/WebCore.xcodeproj/project.pbxproj
WebCore/kcanvas/KCanvasCreator.cpp
WebCore/kcanvas/KCanvasCreator.h
WebCore/kcanvas/KCanvasPath.cpp [deleted file]
WebCore/kcanvas/KCanvasPath.h [deleted file]
WebCore/kcanvas/KCanvasResources.cpp
WebCore/kcanvas/KCanvasResources.h
WebCore/kcanvas/KCanvasTreeDebug.cpp
WebCore/kcanvas/RenderPath.cpp
WebCore/kcanvas/RenderPath.h
WebCore/kcanvas/device/KRenderingDevice.h
WebCore/kcanvas/device/KRenderingFillPainter.cpp
WebCore/kcanvas/device/KRenderingFillPainter.h
WebCore/kcanvas/device/qt/KCanvasClipperQt.cpp
WebCore/kcanvas/device/qt/KCanvasPathQt.cpp [deleted file]
WebCore/kcanvas/device/qt/KCanvasPathQt.h [deleted file]
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/KCanvasPathQuartz.h [deleted file]
WebCore/kcanvas/device/quartz/KCanvasPathQuartz.mm [deleted file]
WebCore/kcanvas/device/quartz/KCanvasResourcesQuartz.mm
WebCore/kcanvas/device/quartz/KRenderingDeviceQuartz.h
WebCore/kcanvas/device/quartz/KRenderingDeviceQuartz.mm
WebCore/kcanvas/device/quartz/QuartzSupport.h
WebCore/kcanvas/device/quartz/QuartzSupport.mm
WebCore/ksvg2/css/SVGCSSParser.cpp
WebCore/ksvg2/css/SVGCSSStyleSelector.cpp
WebCore/ksvg2/css/SVGRenderStyle.h
WebCore/ksvg2/css/SVGRenderStyleDefs.h
WebCore/ksvg2/misc/KCanvasRenderingStyle.cpp
WebCore/ksvg2/svg/SVGCircleElement.cpp
WebCore/ksvg2/svg/SVGCircleElement.h
WebCore/ksvg2/svg/SVGClipPathElement.cpp
WebCore/ksvg2/svg/SVGEllipseElement.cpp
WebCore/ksvg2/svg/SVGEllipseElement.h
WebCore/ksvg2/svg/SVGGradientElement.cpp
WebCore/ksvg2/svg/SVGImageElement.cpp
WebCore/ksvg2/svg/SVGLineElement.cpp
WebCore/ksvg2/svg/SVGLineElement.h
WebCore/ksvg2/svg/SVGMaskElement.cpp
WebCore/ksvg2/svg/SVGPathElement.cpp
WebCore/ksvg2/svg/SVGPathElement.h
WebCore/ksvg2/svg/SVGPatternElement.cpp
WebCore/ksvg2/svg/SVGPolygonElement.cpp
WebCore/ksvg2/svg/SVGPolygonElement.h
WebCore/ksvg2/svg/SVGPolylineElement.cpp
WebCore/ksvg2/svg/SVGPolylineElement.h
WebCore/ksvg2/svg/SVGRectElement.cpp
WebCore/ksvg2/svg/SVGRectElement.h
WebCore/ksvg2/svg/SVGStyledElement.cpp
WebCore/ksvg2/svg/SVGStyledElement.h
WebCore/ksvg2/svg/SVGTextContentElement.cpp
WebCore/ksvg2/svg/SVGTextElement.cpp
WebCore/platform/Path.h
WebCore/platform/cg/PathCG.cpp
WebCore/platform/qt/PathQt.cpp

index 09888ae..28595e0 100644 (file)
@@ -1,3 +1,13 @@
+2006-08-27  Rob Buis  <buis@kde.org>
+
+        Reviewed by Eric.
+
+        Changed test result because of:
+        http://bugzilla.opendarwin.org/show_bug.cgi?id=10557
+        KCanvasPath should be replace by platform/Path
+
+        * svg/W3C-SVG-1.1/struct-dom-06-b-expected.txt:
+
 2006-08-26  Eric Seidel  <eric@eseidel.com>
 
         Reviewed by hyatt.
index 3fa691c..a3c22c9 100644 (file)
@@ -2,7 +2,7 @@ layer at (0,0) size 480x360
   RenderView at (0,0) size 480x360
     KCanvasContainer {svg} at (0.50,0.50) size 479x359
       KCanvasContainer {g} at (0,0) size 0x0
-        KCanvasItem {rect} at (inf,inf) size 0x0 [fill={[type=SOLID] [color=#FF0000]}] [data=""]
+        KCanvasItem {rect} at (0,0) size 0x0 [fill={[type=SOLID] [color=#FF0000]}] [data="M0.00,0.00L0.00,0.00L0.00,0.00L0.00,0.00"]
         RenderSVGText {text} at (0,0) size 465x18
           RenderText {#text} at (0,0) size 148x18
             text run at (0,0) width 148: "DOM API is supported"
index d678270..2ceea42 100644 (file)
@@ -494,7 +494,6 @@ set (SVG_STUFF
     ksvg2/events/JSSVGLazyEventListener.cpp
     ksvg2/events/SVGZoomEvent.cpp
     kcanvas/KCanvasCreator.cpp
-    kcanvas/KCanvasPath.cpp
     kcanvas/KCanvasTreeDebug.cpp
     kcanvas/KCanvasFilters.cpp
     kcanvas/RenderSVGText.cpp
@@ -505,7 +504,6 @@ set (SVG_STUFF
     kcanvas/device/KRenderingPaintServerPattern.cpp
     kcanvas/device/KRenderingDevice.cpp
     kcanvas/device/qt/RenderPathQt.cpp
-    kcanvas/device/qt/KCanvasPathQt.cpp
     kcanvas/device/qt/KRenderingDeviceQt.cpp
     kcanvas/device/qt/KRenderingPaintServerSolidQt.cpp
     kcanvas/device/qt/KRenderingPaintServerGradientQt.cpp
index 5388c54..15049ca 100644 (file)
@@ -1,3 +1,141 @@
+2006-08-27  Rob Buis  <buis@kde.org>
+
+        Reviewed by Eric.
+
+        http://bugzilla.opendarwin.org/show_bug.cgi?id=10557
+        KCanvasPath should be replace by platform/Path
+
+        Refactoring out the KCanvasPath class.
+
+        * CMakeLists.txt:
+        * WebCore.xcodeproj/project.pbxproj:
+        * kcanvas/KCanvasCreator.cpp:
+        (WebCore::KCanvasCreator::createRoundedRectangle):
+        (WebCore::KCanvasCreator::createRectangle):
+        (WebCore::KCanvasCreator::createEllipse):
+        (WebCore::KCanvasCreator::createCircle):
+        (WebCore::KCanvasCreator::createLine):
+        * kcanvas/KCanvasCreator.h:
+        * kcanvas/KCanvasPath.cpp: Removed.
+        * kcanvas/KCanvasPath.h: Removed.
+        * kcanvas/KCanvasResources.cpp:
+        (WebCore::operator<<):
+        (WebCore::KCanvasResource::clients):
+        (WebCore::KCanvasResource::invalidate):
+        (WebCore::KCanvasClipper::addClipData):
+        * kcanvas/KCanvasResources.h:
+        (WebCore::KCClipData::windRule):
+        (WebCore::KCClipDataList::KCClipDataList):
+        (WebCore::KCClipDataList::addPath):
+        * kcanvas/KCanvasTreeDebug.cpp:
+        (WebCore::operator<<):
+        * kcanvas/RenderPath.cpp:
+        (WebCore::RenderPath::fillContains):
+        (WebCore::RenderPath::relativeBBox):
+        (WebCore::RenderPath::setPath):
+        (WebCore::RenderPath::path):
+        (WebCore::RenderPath::paint):
+        (WebCore::RenderPath::nodeAtPoint):
+        * kcanvas/RenderPath.h:
+        * kcanvas/device/KRenderingDevice.h:
+        * kcanvas/device/KRenderingFillPainter.cpp:
+        (WebCore::KRenderingFillPainter::fillRule):
+        (WebCore::KRenderingFillPainter::setFillRule):
+        * kcanvas/device/KRenderingFillPainter.h:
+        * kcanvas/device/qt/KCanvasClipperQt.cpp:
+        (WebCore::KCanvasClipperQt::applyClip):
+        * kcanvas/device/qt/KCanvasPathQt.cpp: Removed.
+        * kcanvas/device/qt/KCanvasPathQt.h: Removed.
+        * kcanvas/device/qt/KRenderingDeviceQt.cpp:
+        (WebCore::KRenderingDeviceContextQt::addPath):
+        (WebCore::KRenderingDeviceContextQt::setFillRule):
+        (WebCore::KRenderingDeviceQt::createItem):
+        * kcanvas/device/qt/KRenderingDeviceQt.h:
+        * kcanvas/device/qt/RenderPathQt.cpp:
+        (WebCore::RenderPathQt::drawMarkersIfNeeded):
+        (WebCore::RenderPathQt::strokeContains):
+        (WebCore::getPathStroke):
+        (WebCore::RenderPathQt::strokeBBox):
+        * kcanvas/device/qt/RenderPathQt.h:
+        * kcanvas/device/quartz/KCanvasItemQuartz.h:
+        * kcanvas/device/quartz/KCanvasItemQuartz.mm:
+        (WebCore::KCanvasItemQuartz::drawMarkersIfNeeded):
+        (WebCore::KCanvasItemQuartz::strokeBBox):
+        (WebCore::KCanvasItemQuartz::strokeContains):
+        * kcanvas/device/quartz/KCanvasPathQuartz.h: Removed.
+        * kcanvas/device/quartz/KCanvasPathQuartz.mm: Removed.
+        * kcanvas/device/quartz/KCanvasResourcesQuartz.mm:
+        (WebCore::KCanvasClipperQuartz::applyClip):
+        * kcanvas/device/quartz/KRenderingDeviceQuartz.h:
+        * kcanvas/device/quartz/KRenderingDeviceQuartz.mm:
+        (WebCore::KRenderingDeviceContextQuartz::addPath):
+        (WebCore::KRenderingDeviceQuartz::createItem):
+        * kcanvas/device/quartz/QuartzSupport.h:
+        * kcanvas/device/quartz/QuartzSupport.mm:
+        (WebCore::scratchContext):
+        (WebCore::strokeBoundingBox):
+        (WebCore::pathContainsPoint):
+        * ksvg2/css/SVGCSSParser.cpp:
+        (WebCore::CSSParser::parseSVGValue):
+        * ksvg2/css/SVGCSSStyleSelector.cpp:
+        (WebCore::CSSStyleSelector::applySVGProperty):
+        * ksvg2/css/SVGRenderStyle.h:
+        (WebCore::SVGRenderStyle::InheritedFlags::):
+        * ksvg2/css/SVGRenderStyleDefs.h:
+        * ksvg2/misc/KCanvasRenderingStyle.cpp:
+        (WebCore::KSVGPainterFactory::fillPainter):
+        * ksvg2/svg/SVGCircleElement.cpp:
+        (SVGCircleElement::toPathData):
+        * ksvg2/svg/SVGCircleElement.h:
+        * ksvg2/svg/SVGClipPathElement.cpp:
+        (SVGClipPathElement::canvasResource):
+        * ksvg2/svg/SVGEllipseElement.cpp:
+        (WebCore::SVGEllipseElement::toPathData):
+        * ksvg2/svg/SVGEllipseElement.h:
+        * ksvg2/svg/SVGGradientElement.cpp:
+        (SVGGradientElement::notifyAttributeChange):
+        * ksvg2/svg/SVGImageElement.cpp:
+        * ksvg2/svg/SVGLineElement.cpp:
+        (SVGLineElement::toPathData):
+        * ksvg2/svg/SVGLineElement.h:
+        * ksvg2/svg/SVGMaskElement.cpp:
+        * ksvg2/svg/SVGPathElement.cpp:
+        (WebCore::SVGPathElement::toPathData):
+        * ksvg2/svg/SVGPathElement.h:
+        * ksvg2/svg/SVGPatternElement.cpp:
+        (WebCore::SVGPatternElement::notifyClientsToRepaint):
+        * ksvg2/svg/SVGPolygonElement.cpp:
+        (SVGPolygonElement::toPathData):
+        * ksvg2/svg/SVGPolygonElement.h:
+        * ksvg2/svg/SVGPolylineElement.cpp:
+        (SVGPolylineElement::toPathData):
+        * ksvg2/svg/SVGPolylineElement.h:
+        * ksvg2/svg/SVGRectElement.cpp:
+        (WebCore::SVGRectElement::toPathData):
+        * ksvg2/svg/SVGRectElement.h:
+        * ksvg2/svg/SVGStyledElement.cpp:
+        (WebCore::SVGStyledElement::createRenderer):
+        * ksvg2/svg/SVGStyledElement.h:
+        (WebCore::SVGStyledElement::toPathData):
+        * ksvg2/svg/SVGTextContentElement.cpp:
+        * ksvg2/svg/SVGTextElement.cpp:
+        * platform/Path.h:
+        (WebCore::):
+        (WebCore::Path::setWindingRule):
+        (WebCore::Path::windingRule):
+        * platform/cg/PathCG.cpp:
+        (WebCore::Path::contains):
+        (WebCore::Path::isEmpty):
+        (WebCore::CGPathToCFStringApplierFunction):
+        (WebCore::CFStringFromCGPath):
+        (WebCore::Path::debugString):
+        * platform/qt/FrameQt.cpp:
+        (WebCore::FrameQt::openURL):
+        * platform/qt/PathQt.cpp:
+        (WebCore::Path::contains):
+        (WebCore::Path::isEmpty):
+        (WebCore::Path::debugString):
+
 2006-08-26  Eric Seidel  <eric@eseidel.com>
 
         Reviewed by hyatt.
index bed6d58..25dbdbf 100644 (file)
                A88AD3B40952486E001DD196 /* KRenderingPaintServerQuartz.mm in Sources */ = {isa = PBXBuildFile; fileRef = A8C0FB75089701F800BA5114 /* KRenderingPaintServerQuartz.mm */; };
                A88AD3B50952486E001DD196 /* QuartzSupport.h in Headers */ = {isa = PBXBuildFile; fileRef = A8C0FB76089701F800BA5114 /* QuartzSupport.h */; };
                A88AD3B60952486E001DD196 /* QuartzSupport.mm in Sources */ = {isa = PBXBuildFile; fileRef = A8C0FB77089701F800BA5114 /* QuartzSupport.mm */; };
-               A88AD3B70952486E001DD196 /* KCanvasPathQuartz.h in Headers */ = {isa = PBXBuildFile; fileRef = A8ABC99909445EC00013945F /* KCanvasPathQuartz.h */; };
-               A88AD3B80952486E001DD196 /* KCanvasPathQuartz.mm in Sources */ = {isa = PBXBuildFile; fileRef = A8ABC99A09445EC00013945F /* KCanvasPathQuartz.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 */; };
                A88AD3C00952486E001DD196 /* KCanvasImage.h in Headers */ = {isa = PBXBuildFile; fileRef = A8C0FB81089701F800BA5114 /* KCanvasImage.h */; };
                A88AD3C10952486E001DD196 /* RenderPath.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A8C0FB82089701F800BA5114 /* RenderPath.cpp */; };
                A88AD3C20952486E001DD196 /* RenderPath.h in Headers */ = {isa = PBXBuildFile; fileRef = A8C0FB83089701F800BA5114 /* RenderPath.h */; };
-               A88AD3C50952486E001DD196 /* KCanvasPath.h in Headers */ = {isa = PBXBuildFile; fileRef = A8C0FB86089701F800BA5114 /* KCanvasPath.h */; };
-               A88AD3C60952486E001DD196 /* KCanvasPath.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4758C44308C5F217009BAF05 /* KCanvasPath.cpp */; };
                A88AD3C70952486E001DD196 /* KCanvasResourceListener.h in Headers */ = {isa = PBXBuildFile; fileRef = A8C0FB89089701F800BA5114 /* KCanvasResourceListener.h */; };
                A88AD3C80952486E001DD196 /* KCanvasResources.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A8C0FB8A089701F800BA5114 /* KCanvasResources.cpp */; };
                A88AD3C90952486E001DD196 /* KCanvasResources.h in Headers */ = {isa = PBXBuildFile; fileRef = A8C0FB8B089701F800BA5114 /* KCanvasResources.h */; };
                448A29BD0A46D9CB0030759F /* JSHTMLOptionsCollection.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = JSHTMLOptionsCollection.h; sourceTree = "<group>"; };
                448A29BE0A46D9CB0030759F /* JSHTMLOptionsCollection.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = JSHTMLOptionsCollection.cpp; sourceTree = "<group>"; };
                448AD27A0A4813790023D179 /* JSHTMLOptionsCollectionCustom.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSHTMLOptionsCollectionCustom.cpp; sourceTree = "<group>"; };
-               4758C44308C5F217009BAF05 /* KCanvasPath.cpp */ = {isa = PBXFileReference; fileEncoding = 4; indentWidth = 4; lastKnownFileType = sourcecode.cpp.cpp; path = KCanvasPath.cpp; sourceTree = "<group>"; tabWidth = 8; usesTabs = 0; };
                4E19591F0A39DABA00220FE5 /* MediaFeatureNames.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = MediaFeatureNames.cpp; sourceTree = "<group>"; };
                4E1959200A39DABA00220FE5 /* MediaFeatureNames.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = MediaFeatureNames.h; sourceTree = "<group>"; };
                4E1959230A39DACC00220FE5 /* MediaQuery.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = MediaQuery.cpp; sourceTree = "<group>"; };
                A890DF1C0930974800513F88 /* SVGStyledTransformableElement.cpp */ = {isa = PBXFileReference; fileEncoding = 4; indentWidth = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SVGStyledTransformableElement.cpp; sourceTree = "<group>"; tabWidth = 8; usesTabs = 0; };
                A890DF1D0930974800513F88 /* SVGStyledLocatableElement.h */ = {isa = PBXFileReference; fileEncoding = 4; indentWidth = 4; lastKnownFileType = sourcecode.c.h; path = SVGStyledLocatableElement.h; sourceTree = "<group>"; tabWidth = 8; usesTabs = 0; };
                A890DF1E0930974800513F88 /* SVGStyledLocatableElement.cpp */ = {isa = PBXFileReference; fileEncoding = 4; indentWidth = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SVGStyledLocatableElement.cpp; sourceTree = "<group>"; tabWidth = 8; usesTabs = 0; };
-               A8ABC99909445EC00013945F /* KCanvasPathQuartz.h */ = {isa = PBXFileReference; fileEncoding = 4; indentWidth = 4; lastKnownFileType = sourcecode.c.h; path = KCanvasPathQuartz.h; sourceTree = "<group>"; tabWidth = 8; usesTabs = 0; };
-               A8ABC99A09445EC00013945F /* KCanvasPathQuartz.mm */ = {isa = PBXFileReference; fileEncoding = 4; indentWidth = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = KCanvasPathQuartz.mm; sourceTree = "<group>"; tabWidth = 8; usesTabs = 0; };
                A8C0F6EB089701F100BA5114 /* KCanvasRenderingStyle.cpp */ = {isa = PBXFileReference; fileEncoding = 4; indentWidth = 4; lastKnownFileType = sourcecode.cpp.cpp; path = KCanvasRenderingStyle.cpp; sourceTree = "<group>"; tabWidth = 8; usesTabs = 0; };
                A8C0F6EC089701F100BA5114 /* KCanvasRenderingStyle.h */ = {isa = PBXFileReference; fileEncoding = 4; indentWidth = 4; lastKnownFileType = sourcecode.c.h; path = KCanvasRenderingStyle.h; sourceTree = "<group>"; tabWidth = 8; usesTabs = 0; };
                A8C0F6EF089701F100BA5114 /* KSVGTimeScheduler.cpp */ = {isa = PBXFileReference; fileEncoding = 4; indentWidth = 4; lastKnownFileType = sourcecode.cpp.cpp; path = KSVGTimeScheduler.cpp; 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; };
                A8C0FB82089701F800BA5114 /* RenderPath.cpp */ = {isa = PBXFileReference; fileEncoding = 4; indentWidth = 4; lastKnownFileType = sourcecode.cpp.cpp; path = RenderPath.cpp; sourceTree = "<group>"; tabWidth = 8; usesTabs = 0; };
                A8C0FB83089701F800BA5114 /* RenderPath.h */ = {isa = PBXFileReference; fileEncoding = 4; indentWidth = 4; lastKnownFileType = sourcecode.c.h; path = RenderPath.h; sourceTree = "<group>"; tabWidth = 8; usesTabs = 0; };
-               A8C0FB86089701F800BA5114 /* KCanvasPath.h */ = {isa = PBXFileReference; fileEncoding = 4; indentWidth = 4; lastKnownFileType = sourcecode.c.h; path = KCanvasPath.h; sourceTree = "<group>"; tabWidth = 8; usesTabs = 0; };
                A8C0FB89089701F800BA5114 /* KCanvasResourceListener.h */ = {isa = PBXFileReference; fileEncoding = 4; indentWidth = 4; lastKnownFileType = sourcecode.c.h; path = KCanvasResourceListener.h; sourceTree = "<group>"; tabWidth = 8; usesTabs = 0; };
                A8C0FB8A089701F800BA5114 /* KCanvasResources.cpp */ = {isa = PBXFileReference; fileEncoding = 4; indentWidth = 4; lastKnownFileType = sourcecode.cpp.cpp; path = KCanvasResources.cpp; sourceTree = "<group>"; tabWidth = 8; usesTabs = 0; };
                A8C0FB8B089701F800BA5114 /* KCanvasResources.h */ = {isa = PBXFileReference; fileEncoding = 4; indentWidth = 4; lastKnownFileType = sourcecode.c.h; path = KCanvasResources.h; sourceTree = "<group>"; tabWidth = 8; usesTabs = 0; };
                                A8C0FB7E089701F800BA5114 /* KCanvasFilters.cpp */,
                                A8C0FB7F089701F800BA5114 /* KCanvasFilters.h */,
                                A8C0FB81089701F800BA5114 /* KCanvasImage.h */,
-                               4758C44308C5F217009BAF05 /* KCanvasPath.cpp */,
-                               A8C0FB86089701F800BA5114 /* KCanvasPath.h */,
                                A8C0FB89089701F800BA5114 /* KCanvasResourceListener.h */,
                                A8C0FB8A089701F800BA5114 /* KCanvasResources.cpp */,
                                A8C0FB8B089701F800BA5114 /* KCanvasResources.h */,
                                A8C0FB6C089701F800BA5114 /* KCanvasItemQuartz.mm */,
                                A81655D2096BBEAC00601058 /* KCanvasMaskerQuartz.h */,
                                A81655D3096BBEAC00601058 /* KCanvasMaskerQuartz.mm */,
-                               A8ABC99909445EC00013945F /* KCanvasPathQuartz.h */,
-                               A8ABC99A09445EC00013945F /* KCanvasPathQuartz.mm */,
                                A8C0FB6D089701F800BA5114 /* KCanvasResourcesQuartz.h */,
                                A8C0FB6E089701F800BA5114 /* KCanvasResourcesQuartz.mm */,
                                A8C0FB71089701F800BA5114 /* KRenderingDeviceQuartz.h */,
                                A88AD3B00952486E001DD196 /* KRenderingDeviceQuartz.h in Headers */,
                                A88AD3B30952486E001DD196 /* KRenderingPaintServerQuartz.h in Headers */,
                                A88AD3B50952486E001DD196 /* QuartzSupport.h in Headers */,
-                               A88AD3B70952486E001DD196 /* KCanvasPathQuartz.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 */,
-                               A88AD3C50952486E001DD196 /* KCanvasPath.h in Headers */,
                                A88AD3C70952486E001DD196 /* KCanvasResourceListener.h in Headers */,
                                A88AD3C90952486E001DD196 /* KCanvasResources.h in Headers */,
                                A88AD3CB0952486E001DD196 /* KCanvasTreeDebug.h in Headers */,
                                A88AD3B20952486E001DD196 /* KRenderingPaintServerGradientQuartz.mm in Sources */,
                                A88AD3B40952486E001DD196 /* KRenderingPaintServerQuartz.mm in Sources */,
                                A88AD3B60952486E001DD196 /* QuartzSupport.mm in Sources */,
-                               A88AD3B80952486E001DD196 /* KCanvasPathQuartz.mm in Sources */,
                                A88AD3B90952486E001DD196 /* RenderSVGContainer.cpp in Sources */,
                                A88AD3BB0952486E001DD196 /* KCanvasCreator.cpp in Sources */,
                                A88AD3BD0952486E001DD196 /* KCanvasFilters.cpp in Sources */,
                                A88AD3C10952486E001DD196 /* RenderPath.cpp in Sources */,
-                               A88AD3C60952486E001DD196 /* KCanvasPath.cpp in Sources */,
                                A88AD3C80952486E001DD196 /* KCanvasResources.cpp in Sources */,
                                A88AD3CC0952486E001DD196 /* KCanvasTreeDebug.cpp in Sources */,
                                A88AD401095248F0001DD196 /* SVGRenderStyle.cpp in Sources */,
index 6c7ccca..31071bf 100644 (file)
@@ -28,6 +28,7 @@
 
 #include "KRenderingDevice.h"
 #include "RenderSVGContainer.h"
+#include "Path.h"
 
 namespace WebCore {
 
@@ -49,11 +50,16 @@ KCanvasCreator *KCanvasCreator::self()
     return s_creator;
 }
 
-KCanvasPath* KCanvasCreator::createRoundedRectangle(float x, float y, float width, float height, float rx, float ry) const
+Path KCanvasCreator::createRoundedRectangle(const FloatRect& box, const FloatSize& roundingRadii) const
 {
-    KCanvasPath* path = renderingDevice()->createPath();
-
-    if (width <= 0.0f || height <= 0.0f || !path)
+    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;
@@ -67,52 +73,58 @@ KCanvasPath* KCanvasCreator::createRoundedRectangle(float x, float y, float widt
     if (nry > height / 2)
         nry = height / 2;
 
-    path->moveTo(x + nrx, y);
+    path.moveTo(FloatPoint(x + nrx, y));
 
     if (nrx < width / 2)
-        path->lineTo(x + width - rx, y);
+        path.addLineTo(FloatPoint(x + width - rx, y));
 
-    path->curveTo(x + width - nrx * (1 - 0.552), y, x + width, y + nry * (1 - 0.552), x + width, y + nry);
+    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->lineTo(x + width, y + height - nry);
+        path.addLineTo(FloatPoint(x + width, y + height - nry));
 
-    path->curveTo(x + width, y + height - nry * (1 - 0.552), x + width - nrx * (1 - 0.552), y + height, x + width - nrx, y + height);
+    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->lineTo(x + nrx, y + height);
+        path.addLineTo(FloatPoint(x + nrx, y + height));
 
-    path->curveTo(x + nrx * (1 - 0.552), y + height, x, y + height - nry * (1 - 0.552), x, y + height - nry);
+    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->lineTo(x, y + nry);
+        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->curveTo(x, y + nry * (1 - 0.552), x + nrx * (1 - 0.552), y, x + nrx, y);
+    path.closeSubpath();
 
-    path->closeSubpath();
     return path;
 }
 
-KCanvasPath* KCanvasCreator::createRectangle(float x, float y, float width, float height) const
+Path KCanvasCreator::createRectangle(const FloatRect& box) const
 {
-    KCanvasPath* path = renderingDevice()->createPath();
-    
-    if (width <= 0.0f || height <= 0.0f || !path)
+    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(x, y);
-    path->lineTo(x + width, y);
-    path->lineTo(x + width, y + height);
-    path->lineTo(x, y + height);
-    path->closeSubpath();
+    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;
 }
 
-KCanvasPath* KCanvasCreator::createEllipse(float cx, float cy, float rx, float ry) const
+Path KCanvasCreator::createEllipse(const FloatPoint&c, float rx, float ry) const
 {
-    KCanvasPath* path = renderingDevice()->createPath();
-
-    if (rx <= 0.0f || ry <= 0.0f || !path)
+    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
@@ -134,29 +146,30 @@ KCanvasPath* KCanvasCreator::createEllipse(float cx, float cy, float rx, float r
 
         step++;
         if(step == 1)
-            path->moveTo(x, y);
+            path.moveTo(FloatPoint(x, y));
         else
-            path->lineTo(x, y);
+            path.addLineTo(FloatPoint(x, y));
     }
 
-    path->closeSubpath();
+    path.closeSubpath();
+
     return path;
 }
 
-KCanvasPath* KCanvasCreator::createCircle(float cx, float cy, float r) const
+Path KCanvasCreator::createCircle(const FloatPoint& c, float r) const
 {
-    return createEllipse(cx, cy, r, r);
+    return createEllipse(c, r, r);
 }
 
-KCanvasPath* KCanvasCreator::createLine(float x1, float y1, float x2, float y2) const
+Path KCanvasCreator::createLine(const FloatPoint& start, const FloatPoint& end) const
 {
-    KCanvasPath* path = renderingDevice()->createPath();
-    
-    if ((x1 == x2 && y1 == y2) || !path)
+    Path path;
+    if (start.x() == end.x() && start.y() == end.y())
         return path;
 
-    path->moveTo(x1, y1);
-    path->lineTo(x2, y2);
+    path.moveTo(start);
+    path.addLineTo(end);
+
     return path;
 }
 
index 58cf233..6ae9e91 100644 (file)
 #define KCanvasCreator_H
 #ifdef SVG_SUPPORT
 
-#include <kcanvas/KCanvasPath.h>
-
 namespace WebCore {
 
+class Path;
+class FloatPoint;
+class FloatRect;
+class FloatSize;
+
 class KCanvasCreator
 {
 public:
@@ -37,11 +40,11 @@ public:
     static KCanvasCreator *self();
 
     // Canvas path creation
-    KCanvasPath* createRoundedRectangle(float x, float y, float width, float height, float rx, float ry) const;
-    KCanvasPath* createRectangle(float x, float y, float width, float height) const;
-    KCanvasPath* createEllipse(float cx, float cy, float rx, float ry) const;
-    KCanvasPath* createCircle(float cx, float cy, float r) const;
-    KCanvasPath* createLine(float x1, float y1, float x2, float y2) const;
+    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;
diff --git a/WebCore/kcanvas/KCanvasPath.cpp b/WebCore/kcanvas/KCanvasPath.cpp
deleted file mode 100644 (file)
index 3107c07..0000000
+++ /dev/null
@@ -1,62 +0,0 @@
-/*
- * Copyright (C) 2005 Kimmo Kinnunen <kimmo.t.kinnunen@nokia.com>.  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 THE AUTHOR ``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 THE AUTHOR 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 "TextStream.h"
-
-#include "KCanvasPath.h"
-#include "KCanvasTreeDebug.h"
-#include "KRenderingDevice.h"
-
-namespace WebCore {
-
-//KCWindRule
-TextStream &operator<<(TextStream &ts, KCWindRule rule)
-{
-    switch (rule) 
-    {
-        case RULE_NONZERO:
-            ts << "NON-ZERO"; break;
-        case RULE_EVENODD:
-            ts << "EVEN-ODD"; break;
-    }
-    return ts;
-}
-
-//KCClipData
-TextStream &operator<<(TextStream &ts, const KCClipData &d)
-{
-    ts << "[winding=" << d.windRule() << "]";
-    if (d.bboxUnits)
-        ts << " [bounding box mode=" << d.bboxUnits  << "]";    
-    ts << " [path=" << renderingDevice()->stringForPath(d.path.get()) << "]";
-    return ts;
-}
-
-}
-
-#endif // SVG_SUPPORT
diff --git a/WebCore/kcanvas/KCanvasPath.h b/WebCore/kcanvas/KCanvasPath.h
deleted file mode 100644 (file)
index 4ab369c..0000000
+++ /dev/null
@@ -1,104 +0,0 @@
-/*
-    Copyright (C) 2005 Apple Computer, Inc.
-    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 KCanvasPath_H
-#define KCanvasPath_H
-#ifdef SVG_SUPPORT
-
-#include "DeprecatedValueList.h"
-#include <wtf/Assertions.h>
-#include "Shared.h"
-#include "FloatRect.h"
-
-namespace WebCore {
-
-class KRenderingStrokePainter;
-class RenderStyle;
-class TextStream;
-
-enum KCWindRule {
-    RULE_NONZERO = 0,
-    RULE_EVENODD = 1
-};
-
-// Path related data structures
-typedef enum
-{
-    CMD_MOVE = 0,
-    CMD_LINE = 1,
-    CMD_CURVE = 2,
-    CMD_CLOSE_SUBPATH = 3
-} KCPathCommand;
-
-class KCanvasPath : public Shared<KCanvasPath>
-{
-public:
-    virtual ~KCanvasPath() { }
-    
-    virtual bool isEmpty() const = 0;
-
-    virtual void moveTo(float x, float y) = 0;
-    virtual void lineTo(float x, float y) = 0;
-    virtual void curveTo(float x1, float y1, float x2, float y2, float x3, float y3) = 0;
-    virtual void closeSubpath() = 0;
-
-    virtual FloatRect boundingBox() = 0;
-    virtual FloatRect strokeBoundingBox(const KRenderingStrokePainter&) = 0;
-    virtual bool strokeContainsPoint(const FloatPoint&) = 0;
-    virtual bool containsPoint(const FloatPoint&, KCWindRule) = 0;
-};
-
-// Clipping paths
-struct KCClipData
-{
-    KCWindRule windRule() const { return static_cast<KCWindRule>(m_windRule); }
-    unsigned m_windRule : 1; // KCWindRule
-    bool bboxUnits : 1;
-    RefPtr<KCanvasPath> path;
-};
-
-class KCClipDataList : public DeprecatedValueList<KCClipData>
-{
-public:
-    KCClipDataList() { }
-
-    inline void addPath(KCanvasPath *pathData, KCWindRule windRule, bool bboxUnits)
-    {
-        ASSERT(pathData);
-        KCClipData clipData;
-        clipData.m_windRule = windRule;
-        clipData.bboxUnits = bboxUnits;
-        clipData.path = pathData;
-        append(clipData);
-    }
-};
-
-TextStream &operator<<(TextStream &ts, KCWindRule rule);
-TextStream &operator<<(TextStream &ts, const KCClipData &d);
-
-}
-
-#endif // SVG_SUPPORT
-#endif
-
-// vim:ts=4:noet
index b467f2d..122123e 100644 (file)
@@ -42,6 +42,29 @@ TextStream &operator<<(TextStream& ts, const KCanvasResource& r)
     return r.externalRepresentation(ts); 
 }
 
+//WindRule
+TextStream &operator<<(TextStream &ts, WindRule rule)
+{
+    switch (rule) 
+    {
+        case RULE_NONZERO:
+            ts << "NON-ZERO"; break;
+        case RULE_EVENODD:
+            ts << "EVEN-ODD"; break;
+    }
+    return ts;
+}
+
+//KCClipData
+TextStream &operator<<(TextStream &ts, const KCClipData &d)
+{
+    ts << "[winding=" << d.windRule() << "]";
+    if (d.bboxUnits)
+        ts << " [bounding box mode=" << d.bboxUnits  << "]";    
+    ts << " [path=" << d.path.debugString() << "]";
+    return ts;
+}
+
 // KCanvasResource
 KCanvasResource::KCanvasResource()
 {
@@ -59,15 +82,15 @@ void KCanvasResource::addClient(const RenderPath *item)
     m_clients.append(item);
 }
 
-const KCanvasItemList &KCanvasResource::clients() const
+const RenderPathList &KCanvasResource::clients() const
 {
     return m_clients;
 }
 
 void KCanvasResource::invalidate()
 {
-    KCanvasItemList::ConstIterator it = m_clients.begin();
-    KCanvasItemList::ConstIterator end = m_clients.end();
+    RenderPathList::ConstIterator it = m_clients.begin();
+    RenderPathList::ConstIterator end = m_clients.end();
 
     for(; it != end; ++it)
         const_cast<RenderPath *>(*it)->repaint();
@@ -102,7 +125,7 @@ void KCanvasClipper::resetClipData()
     m_clipData.clear();
 }
 
-void KCanvasClipper::addClipData(KCanvasPath* path, KCWindRule rule, bool bboxUnits)
+void KCanvasClipper::addClipData(const Path& path, WindRule rule, bool bboxUnits)
 {
     m_clipData.addPath(path, rule, bboxUnits);
 }
index 2ac6a3c..53e43b7 100644 (file)
 #define KCanvasResources_H
 #ifdef SVG_SUPPORT
 
-#include <kcanvas/RenderPath.h>
-#include <kcanvas/KCanvasPath.h>
+#include "DeprecatedValueList.h"
+#include "Path.h"
+#include "RenderPath.h"
 #include <kcanvas/KCanvasResourceListener.h>
 
 namespace WebCore {
 
+typedef DeprecatedValueList<const RenderPath *> RenderPathList;
+
 class TextStream;
 
 // Enumerations
@@ -54,7 +57,7 @@ public:
     virtual void invalidate();
     void addClient(const RenderPath *item);
 
-    const KCanvasItemList &clients() const;
+    const RenderPathList &clients() const;
     
     DeprecatedString idInRegistry() const;
     void setIdInRegistry(const DeprecatedString& newId);
@@ -67,10 +70,34 @@ public:
     
     virtual TextStream& externalRepresentation(TextStream &) const; 
 private:
-    KCanvasItemList m_clients;
+    RenderPathList m_clients;
     DeprecatedString registryId;
 };
 
+// Clipping paths
+struct KCClipData
+{
+    WindRule windRule() const { return m_windRule; }
+    WindRule m_windRule;
+    bool bboxUnits : 1;
+    Path path;
+};
+
+class KCClipDataList : public DeprecatedValueList<KCClipData>
+{
+public:
+    KCClipDataList() { }
+
+    inline void addPath(const Path& pathData, WindRule windRule, bool bboxUnits)
+    {
+        KCClipData clipData;
+        clipData.bboxUnits = bboxUnits;
+        clipData.m_windRule = windRule;
+        clipData.path = pathData;
+        append(clipData);
+    }
+};
+
 class KCanvasClipper : public KCanvasResource
 {
 public:
@@ -80,7 +107,7 @@ public:
     virtual bool isClipper() const { return true; }
 
     void resetClipData();
-    void addClipData(KCanvasPath *path, KCWindRule rule, bool bboxUnits);
+    void addClipData(const Path& path, WindRule rule, bool bboxUnits);
     
     virtual void applyClip(const FloatRect& boundingBox) const = 0;
 
@@ -146,6 +173,8 @@ private:
     bool m_useStrokeWidth;
 };
 
+
+
 KCanvasResource *getResourceById(Document *document, const AtomicString &id);
 KCanvasMarker *getMarkerById(Document *document, const AtomicString &id);
 KCanvasClipper *getClipperById(Document *document, const AtomicString &id);
@@ -153,6 +182,8 @@ KCanvasMasker *getMaskerById(Document *document, const AtomicString &id);
 KRenderingPaintServer *getPaintServerById(Document *document, const AtomicString &id);
 
 TextStream &operator<<(TextStream &ts, const KCanvasResource &r);
+TextStream &operator<<(TextStream &ts, WindRule rule);
+TextStream &operator<<(TextStream &ts, const KCClipData &d);
 
 }
 
index a0be1ee..4b7320b 100644 (file)
@@ -291,7 +291,7 @@ static TextStream &operator<<(TextStream &ts, const RenderPath &o)
     
     writeStyle(ts, o);
     
-    ts << " [data=\"" << renderingDevice()->stringForPath(o.path()) << "\"]";
+    ts << " [data=\"" << o.path().debugString() << "\"]";
     
     return ts;
 }
index 1792022..946db93 100644 (file)
@@ -37,7 +37,7 @@ namespace WebCore {
 
 class RenderPath::Private {
 public:
-    RefPtr<KCanvasPath> path;
+    Path path;
 
     FloatRect fillBBox;
     FloatRect strokeBbox;
@@ -80,40 +80,19 @@ FloatPoint RenderPath::mapAbsolutePointToLocal(const FloatPoint& point) const
 
 bool RenderPath::fillContains(const FloatPoint& point) const
 {
-    if (!d->path)
+    if (d->path.isEmpty())
         return false;
 
     if (!KSVGPainterFactory::fillPaintServer(style(), this))
         return false;
 
-    return path()->containsPoint(mapAbsolutePointToLocal(point),
-                                 KSVGPainterFactory::fillPainter(style(), this).fillRule());
-}
-
-bool RenderPath::strokeContains(const FloatPoint& point) const
-{
-    if (!d->path)
-        return false;
-
-    if (!KSVGPainterFactory::strokePaintServer(style(), this))
-        return false;
-
-    return path()->strokeContainsPoint(mapAbsolutePointToLocal(point));
-}
-
-FloatRect RenderPath::strokeBBox() const
-{
-    if (KSVGPainterFactory::isStroked(style())) {
-        KRenderingStrokePainter strokePainter = KSVGPainterFactory::strokePainter(style(), this);
-        return path()->strokeBoundingBox(strokePainter);
-    }
-
-    return path()->boundingBox();
+    return path().contains(mapAbsolutePointToLocal(point),
+                           KSVGPainterFactory::fillPainter(style(), this).fillRule());
 }
 
 FloatRect RenderPath::relativeBBox(bool includeStroke) const
 {
-    if (!d->path)
+    if (d->path.isEmpty())
         return FloatRect();
 
     if (includeStroke) {
@@ -123,20 +102,20 @@ FloatRect RenderPath::relativeBBox(bool includeStroke) const
     }
 
     if (d->fillBBox.isEmpty())
-        d->fillBBox = path()->boundingBox();
+        d->fillBBox = path().boundingRect();
     return d->fillBBox;
 }
 
-void RenderPath::setPath(KCanvasPath* newPath)
+void RenderPath::setPath(const Path& newPath)
 {
     d->path = newPath;
     d->strokeBbox = FloatRect();
     d->fillBBox = FloatRect();
 }
 
-KCanvasPath* RenderPath::path() const
+const Path& RenderPath::path() const
 {
-    return d->path.get();
+    return d->path;
 }
 
 void RenderPath::layout()
@@ -198,7 +177,7 @@ void RenderPath::paint(PaintInfo &paintInfo, int parentX, int parentY)
     //ASSERT(parentX == 0);
     //ASSERT(parentY == 0);
 
-    if (paintInfo.p->paintingDisabled() || (paintInfo.phase != PaintPhaseForeground) || style()->visibility() == HIDDEN || !path())
+    if (paintInfo.p->paintingDisabled() || (paintInfo.phase != PaintPhaseForeground) || style()->visibility() == HIDDEN || path().isEmpty())
         return;
     
     KRenderingDevice* device = renderingDevice();
@@ -317,7 +296,6 @@ bool RenderPath::nodeAtPoint(NodeInfo& info, int _x, int _y, int _tx, int _ty, H
     // We only draw in the forground phase, so we only hit-test then.
     if (hitTestAction != HitTestForeground)
         return false;
-    
     PointerEventsHitRules hitRules = pointerEventsHitRules();
     
     bool isVisible = (style()->visibility() == VISIBLE);
index d613ee1..d86f596 100644 (file)
@@ -36,7 +36,7 @@ namespace WebCore {
 class FloatPoint;
 class SVGStyledElement;
 
-class KCanvasPath;
+class Path;
 class RenderSVGContainer;
 
 class RenderPath : public RenderObject
@@ -47,13 +47,13 @@ public:
 
     // Hit-detection seperated for the fill and the stroke
     virtual bool fillContains(const FloatPoint &p) const;
-    virtual bool strokeContains(const FloatPoint &p) const;
+    virtual bool strokeContains(const FloatPoint &p) const = 0;
 
     // Returns an unscaled bounding box (not even including localTransform()) for this vector path
     virtual FloatRect relativeBBox(bool includeStroke = true) const;
 
-    void setPath(KCanvasPath* newPath);
-    KCanvasPath* path() const;
+    void setPath(const Path& newPath);
+    const Path& path() const;
 
     virtual bool isRenderPath() const { return true; }
     virtual const char *renderName() const { return "KCanvasItem"; }
@@ -90,10 +90,10 @@ public:
     };
 
 protected:
-    virtual void drawMarkersIfNeeded(GraphicsContext*, const FloatRect&, const KCanvasPath*) const = 0;
+    virtual void drawMarkersIfNeeded(GraphicsContext*, const FloatRect&, const Path&) const = 0;
+    virtual FloatRect strokeBBox() const = 0;
 
 private:
-    FloatRect strokeBBox() const;
     FloatPoint mapAbsolutePointToLocal(const FloatPoint&) const;
     
     PointerEventsHitRules pointerEventsHitRules();
@@ -102,9 +102,6 @@ private:
     Private *d;
 };
 
-// Helper data structure
-typedef DeprecatedValueList<const RenderPath *> KCanvasItemList;
-
 }
 
 #endif // SVG_SUPPORT
index a175e39..92cf53b 100644 (file)
@@ -40,7 +40,7 @@ public:
     virtual AffineTransform ctm() const = 0;
         
     virtual void clearPath() = 0;
-    virtual void addPath(const KCanvasPath*) = 0;
+    virtual void addPath(const Path&) = 0;
 
     virtual GraphicsContext* createGraphicsContext() = 0;
 };
@@ -64,16 +64,13 @@ public:
     virtual void pushContext(KRenderingDeviceContext *context);
     
     virtual KRenderingDeviceContext *contextForImage(KCanvasImage *image) const = 0;
-    
-    virtual DeprecatedString stringForPath(const KCanvasPath* path) = 0;
 
     // Creation tools
     virtual KCanvasResource *createResource(const KCResourceType &type) const = 0;
     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, KCanvasPath* path) const = 0;
-    virtual KCanvasPath* createPath() const = 0;
+    virtual RenderPath *createItem(RenderArena *arena, RenderStyle *style, SVGStyledElement *node, const Path& path) const = 0;
 
 private:
     Vector<KRenderingDeviceContext*> m_contextStack;
index 2241cb8..c83af7a 100644 (file)
@@ -38,7 +38,7 @@ public:
     }
 
     float opacity;
-    KCWindRule fillRule;
+    WindRule fillRule;
 };
 
 KRenderingFillPainter::KRenderingFillPainter() : d(new Private())
@@ -50,12 +50,12 @@ KRenderingFillPainter::~KRenderingFillPainter()
     delete d;
 }
 
-KCWindRule KRenderingFillPainter::fillRule() const
+WindRule KRenderingFillPainter::fillRule() const
 {
     return d->fillRule;
 }
 
-void KRenderingFillPainter::setFillRule(KCWindRule rule)
+void KRenderingFillPainter::setFillRule(WindRule rule)
 {
     d->fillRule = rule;
 }
index dd218c2..941518f 100644 (file)
@@ -24,7 +24,7 @@
 #define KRenderingFillPainter_H
 #ifdef SVG_SUPPORT
 
-#include <kcanvas/KCanvasPath.h>
+#include "Path.h"
 
 namespace WebCore {
 
@@ -36,8 +36,8 @@ public:
     KRenderingFillPainter();
     virtual ~KRenderingFillPainter();
 
-    KCWindRule fillRule() const;
-    void setFillRule(KCWindRule rule);
+    WindRule fillRule() const;
+    void setFillRule(WindRule rule);
 
     float opacity() const;
     void setOpacity(float opacity);
index 4aaa760..6890e42 100644 (file)
@@ -23,7 +23,6 @@
 
 #include "config.h"
 
-#include "KCanvasPathQt.h"
 #include "KCanvasClipperQt.h"
 #include "KRenderingDeviceQt.h"
 
@@ -41,14 +40,14 @@ void KCanvasClipperQt::applyClip(const FloatRect& boundingBox) const
     QPainterPath newPath;
 
     bool heterogenousClipRules = false;
-    KCWindRule clipRule = m_clipData[0].windRule();
+    WindRule clipRule = m_clipData[0].windRule();
 
     for (unsigned int x = 0; x < m_clipData.count(); x++) {
         KCClipData clipData = m_clipData[x];
         if (clipData.windRule() != clipRule)
             heterogenousClipRules = true;
        
-        QPainterPath path = static_cast<KCanvasPathQt*>(clipData.path.get())->qtPath(); 
+        QPainterPath path = *(clipData.path.platformPath());
         if (path.isEmpty())
             continue;
 
diff --git a/WebCore/kcanvas/device/qt/KCanvasPathQt.cpp b/WebCore/kcanvas/device/qt/KCanvasPathQt.cpp
deleted file mode 100644 (file)
index 57ca60b..0000000
+++ /dev/null
@@ -1,92 +0,0 @@
-/*
-    Copyright (C) 2004, 2005, 2006 Nikolas Zimmermann <wildfox@kde.org>
-                  2004, 2005, 2006 Rob Buis <buis@kde.org>
-                  2005 Apple Computer, Inc.
-
-    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"
-#include "KCanvasPathQt.h"
-
-namespace WebCore {
-
-KCanvasPathQt::KCanvasPathQt()
-{
-}
-
-KCanvasPathQt::~KCanvasPathQt()
-{
-}
-
-bool KCanvasPathQt::isEmpty() const
-{
-    return m_path.isEmpty();
-}
-
-void KCanvasPathQt::moveTo(float x, float y)
-{
-    m_path.moveTo(x, y);
-}
-
-void KCanvasPathQt::lineTo(float x, float y)
-{
-    m_path.lineTo(x, y);
-}
-
-void KCanvasPathQt::curveTo(float x1, float y1, float x2, float y2, float x3, float y3)
-{
-    m_path.cubicTo(x1, y1, x2, y2, x3, y3);
-}
-
-void KCanvasPathQt::closeSubpath()
-{
-    m_path.closeSubpath();
-}
-
-FloatRect KCanvasPathQt::boundingBox()
-{
-    return FloatRect(m_path.boundingRect());
-}
-
-FloatRect KCanvasPathQt::strokeBoundingBox(const KRenderingStrokePainter& strokePainter)
-{
-    qDebug("KCanvasPathQt::strokeBoundingBox() TODO!");
-    return boundingBox();
-}
-
-bool KCanvasPathQt::strokeContainsPoint(const FloatPoint& point)
-{
-    qDebug("KCanvasPathQt::strokeContainsPoint() TODO!");    
-    return containsPoint(point, RULE_EVENODD);
-}
-
-bool KCanvasPathQt::containsPoint(const FloatPoint& point, KCWindRule rule)
-{
-    Qt::FillRule savedRule = m_path.fillRule();
-    m_path.setFillRule(rule == RULE_EVENODD ? Qt::OddEvenFill : Qt::WindingFill);
-
-    bool contains = m_path.contains(point);
-
-    m_path.setFillRule(savedRule);
-    return contains;
-}
-
-}
-
-// vim:ts=4:noet
diff --git a/WebCore/kcanvas/device/qt/KCanvasPathQt.h b/WebCore/kcanvas/device/qt/KCanvasPathQt.h
deleted file mode 100644 (file)
index 20022d4..0000000
+++ /dev/null
@@ -1,62 +0,0 @@
-/*
-    Copyright (C) 2004, 2005, 2006 Nikolas Zimmermann <wildfox@kde.org>
-                  2004, 2005, 2006 Rob Buis <buis@kde.org>
-                  2005 Apple Computer, Inc.
-
-    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 KCanvasPathQt_H
-#define KCanvasPathQt_H
-
-#include <QPainterPath>
-
-#include "KCanvasPath.h"
-
-namespace WebCore {
-
-class KCanvasPathQt : public KCanvasPath
-{
-public:
-    KCanvasPathQt();
-    virtual ~KCanvasPathQt();
-
-    virtual bool isEmpty() const;
-
-    virtual void moveTo(float x, float y);
-    virtual void lineTo(float x, float y);
-    virtual void curveTo(float x1, float y1, float x2, float y2, float x3, float y3);
-    virtual void closeSubpath();
-
-    virtual FloatRect boundingBox();
-    virtual FloatRect strokeBoundingBox(const KRenderingStrokePainter&);
-    virtual bool strokeContainsPoint(const FloatPoint&);
-    virtual bool containsPoint(const FloatPoint&, KCWindRule);
-
-    // Qt specific stuff
-    const QPainterPath &qtPath() const { return m_path; }
-
-private:
-    QPainterPath m_path;
-};
-
-}
-
-#endif
-
-// vim:ts=4:noet
index 539430d..af9d430 100644 (file)
@@ -24,7 +24,6 @@
 
 #include "IntRect.h"
 #include "RenderPathQt.h"
-#include "KCanvasPathQt.h"
 #include "AffineTransform.h"
 #include "GraphicsContext.h"
 #include "KCanvasClipperQt.h"
@@ -73,9 +72,9 @@ void KRenderingDeviceContextQt::clearPath()
     m_path = QPainterPath();
 }
 
-void KRenderingDeviceContextQt::addPath(const KCanvasPath* path)
+void KRenderingDeviceContextQt::addPath(const Path& path)
 {
-    m_path.addPath(static_cast<const KCanvasPathQt*>(path)->qtPath());
+    m_path.addPath(*(path.platformPath()));
 }
 
 GraphicsContext* KRenderingDeviceContextQt::createGraphicsContext()
@@ -93,7 +92,7 @@ QRectF KRenderingDeviceContextQt::pathBBox() const
     return m_path.boundingRect();
 }
 
-void KRenderingDeviceContextQt::setFillRule(KCWindRule rule)
+void KRenderingDeviceContextQt::setFillRule(WindRule rule)
 {
     m_path.setFillRule(rule == RULE_EVENODD ? Qt::OddEvenFill : Qt::WindingFill);
 }
@@ -141,12 +140,6 @@ KRenderingDeviceContext* KRenderingDeviceQt::contextForImage(KCanvasImage* image
     return 0;
 }
 
-DeprecatedString KRenderingDeviceQt::stringForPath(const KCanvasPath* path)
-{
-    qDebug("KRenderingDeviceQt::stringForPath() TODO!");
-    return 0;
-}
-
 // Resource creation
 KCanvasResource* KRenderingDeviceQt::createResource(const KCResourceType& type) const
 {
@@ -190,13 +183,8 @@ KCanvasFilterEffect* KRenderingDeviceQt::createFilterEffect(const KCFilterEffect
     return 0;
 }
 
-KCanvasPath* KRenderingDeviceQt::createPath() const
-{
-    return new KCanvasPathQt();
-}
-
 // item creation
-RenderPath* KRenderingDeviceQt::createItem(RenderArena* arena, RenderStyle* style, SVGStyledElement* node, KCanvasPath* path) const
+RenderPath* KRenderingDeviceQt::createItem(RenderArena* arena, RenderStyle* style, SVGStyledElement* node, const Path& path) const
 {
     RenderPath* item = new (arena) RenderPathQt(style, node);
     item->setPath(path);
index c64598f..6146eab 100644 (file)
@@ -43,7 +43,7 @@ public:
     virtual IntRect mapToVisual(const IntRect&);
 
     virtual void clearPath();
-    virtual void addPath(const KCanvasPath*);
+    virtual void addPath(const Path&);
 
     virtual GraphicsContext* createGraphicsContext();
     
@@ -51,7 +51,7 @@ public:
     QPainter& painter();
     QRectF pathBBox() const;
 
-    void setFillRule(KCWindRule);
+    void setFillRule(WindRule);
 
     void fillPath();
     void strokePath();
@@ -76,16 +76,13 @@ public:
     KRenderingDeviceContextQt* qtContext() const;
     virtual KRenderingDeviceContext* contextForImage(KCanvasImage*) const;
 
-    virtual DeprecatedString stringForPath(const KCanvasPath*);
-
     // Resource creation
     virtual KCanvasResource* createResource(const KCResourceType&) const;
     virtual KRenderingPaintServer* createPaintServer(const KCPaintServerType&) const;
     virtual KCanvasFilterEffect* createFilterEffect(const KCFilterEffectType&) const;
-    virtual KCanvasPath* createPath() const;
 
     // item creation
-    virtual RenderPath* createItem(RenderArena*, RenderStyle*, SVGStyledElement*, KCanvasPath*) const;
+    virtual RenderPath* createItem(RenderArena*, RenderStyle*, SVGStyledElement*, const Path&) const;
 };
 
 }
index df210cb..c93db7e 100644 (file)
 
 #include "config.h"
 #include "RenderPathQt.h"
+#include "KCanvasRenderingStyle.h"
+#include "KRenderingStrokePainter.h"
 
 #include <QDebug>
+#include <QPainterPathStroker>
 
 namespace WebCore {
     
@@ -33,11 +36,60 @@ RenderPathQt::RenderPathQt(RenderStyle* style, SVGStyledElement* node)
 {
 }
 
-void RenderPathQt::drawMarkersIfNeeded(GraphicsContext*, const FloatRect&, const KCanvasPath*) const
+void RenderPathQt::drawMarkersIfNeeded(GraphicsContext*, const FloatRect&, const Path&) const
 {
     qDebug("RenderPathQt::drawMarkersIfNeeded() TODO!");
 }
 
+bool RenderPathQt::strokeContains(const FloatPoint& point) const
+{
+    if (path().isEmpty())
+        return false;
+
+    if (!KSVGPainterFactory::strokePaintServer(style(), this))
+        return false;
+
+    return false;
+}
+
+static QPainterPath getPathStroke(const QPainterPath &path, const KRenderingStrokePainter &strokePainter)
+{
+    QPainterPathStroker s;
+    s.setWidth(strokePainter.strokeWidth());
+    if(strokePainter.strokeCapStyle() == CAP_BUTT)
+        s.setCapStyle(Qt::FlatCap);
+    else if(strokePainter.strokeCapStyle() == CAP_ROUND)
+        s.setCapStyle(Qt::RoundCap);
+
+    if(strokePainter.strokeJoinStyle() == JOIN_MITER) {
+        s.setJoinStyle(Qt::MiterJoin);
+        s.setMiterLimit((qreal)strokePainter.strokeMiterLimit());
+    } else if(strokePainter.strokeJoinStyle() == JOIN_ROUND)
+        s.setJoinStyle(Qt::RoundJoin);
+
+    KCDashArray dashes = strokePainter.dashArray();
+    unsigned int dashLength = !dashes.isEmpty() ? dashes.count() : 0;
+    if(dashLength) {
+        QVector<qreal> pattern;
+        unsigned int count = (dashLength % 2) == 0 ? dashLength : dashLength * 2;
+
+        for(unsigned int i = 0; i < count; i++)
+            pattern.append(dashes[i % dashLength] / (float)s.width());
+
+        s.setDashPattern(pattern);
+        // TODO: dash-offset, does/will qt4 API allow it? (Rob)
+    }
+
+    return s.createStroke(path);
+}
+
+FloatRect RenderPathQt::strokeBBox() const
+{
+    KRenderingStrokePainter strokePainter = KSVGPainterFactory::strokePainter(style(), this);
+    QPainterPath outline = getPathStroke(*(path().platformPath()), strokePainter);
+    return outline.boundingRect();
+}
+
 }
 
 // vim:ts=4:noet
index 5683784..1d7c008 100644 (file)
@@ -33,8 +33,11 @@ class RenderPathQt : public RenderPath
 public:
     RenderPathQt(RenderStyle*, SVGStyledElement*);
 
+    virtual bool strokeContains(const FloatPoint& point) const;
+    virtual FloatRect strokeBBox() const;
+
 protected:
-    virtual void drawMarkersIfNeeded(GraphicsContext*, const FloatRect&, const KCanvasPath*) const;
+    virtual void drawMarkersIfNeeded(GraphicsContext*, const FloatRect&, const Path&) const;
 };
 
 }
index 76bec75..00989cd 100644 (file)
@@ -37,7 +37,9 @@ public:
     KCanvasItemQuartz(RenderStyle*, SVGStyledElement*);
     virtual ~KCanvasItemQuartz() { }
     
-    virtual void drawMarkersIfNeeded(GraphicsContext*, const FloatRect&, const KCanvasPath*) const;
+    virtual bool strokeContains(const FloatPoint& point) const;
+    virtual void drawMarkersIfNeeded(GraphicsContext*, const FloatRect&, const Path&) const;
+    virtual FloatRect strokeBBox() const;
 };
 
 }
index 5507d78..3a1588f 100644 (file)
@@ -36,7 +36,6 @@
 #import "KRenderingFillPainter.h"
 #import "KRenderingStrokePainter.h"
 
-#import "KCanvasPathQuartz.h"
 #import "KRenderingDeviceQuartz.h"
 #import "KCanvasFilterQuartz.h"
 #import "KCanvasResourcesQuartz.h"
@@ -163,7 +162,7 @@ static void drawStartAndMidMarkers(void *info, const CGPathElement *element)
     data.elementIndex++;
 }
 
-void KCanvasItemQuartz::drawMarkersIfNeeded(GraphicsContext* context, const FloatRect& rect, const KCanvasPath *path) const
+void KCanvasItemQuartz::drawMarkersIfNeeded(GraphicsContext* context, const FloatRect& rect, const Path& path) const
 {
     Document *doc = document();
     const SVGRenderStyle *svgStyle = style()->svgStyle();
@@ -179,7 +178,7 @@ void KCanvasItemQuartz::drawMarkersIfNeeded(GraphicsContext* context, const Floa
 
     DrawMarkersData data(context, startMarker, midMarker, strokeWidth);
 
-    CGPathRef cgPath = static_cast<const KCanvasPathQuartz*>(path)->cgPath();
+    CGPathRef cgPath = path.platformPath();
     CGPathApply(cgPath, &data, drawStartAndMidMarkers);
 
     data.previousMarkerData.marker = endMarker;
@@ -187,6 +186,29 @@ void KCanvasItemQuartz::drawMarkersIfNeeded(GraphicsContext* context, const Floa
     drawMarkerWithData(context, data.previousMarkerData);
 }
 
+FloatRect KCanvasItemQuartz::strokeBBox() const
+{
+    if (KSVGPainterFactory::isStroked(style())) {
+        KRenderingStrokePainter strokePainter = KSVGPainterFactory::strokePainter(style(), this);
+        return strokeBoundingBox(path(), strokePainter);
+    }
+
+    return path().boundingRect();
+}
+
+
+bool KCanvasItemQuartz::strokeContains(const FloatPoint& point) const
+{
+    if (path().isEmpty())
+        return false;
+
+    if (!KSVGPainterFactory::strokePaintServer(style(), this))
+        return false;
+
+    CGMutablePathRef cgPath = path().platformPath();
+    return pathContainsPoint(cgPath, point, kCGPathStroke);
+}
+
 }
 
 #endif // SVG_SUPPORT
diff --git a/WebCore/kcanvas/device/quartz/KCanvasPathQuartz.h b/WebCore/kcanvas/device/quartz/KCanvasPathQuartz.h
deleted file mode 100644 (file)
index cb21895..0000000
+++ /dev/null
@@ -1,61 +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 KCanvasPathQuartz_h
-#define KCanvasPathQuartz_h
-
-#include <kcanvas/KCanvasPath.h>
-
-typedef struct CGPath *CGMutablePathRef;
-typedef const struct CGPath *CGPathRef;
-
-namespace WebCore {
-
-class KCanvasPathQuartz : public KCanvasPath {
-public:
-    KCanvasPathQuartz();
-    virtual ~KCanvasPathQuartz();
-    
-    virtual bool isEmpty() const;
-
-    virtual void moveTo(float x, float y);
-    virtual void lineTo(float x, float y);
-    virtual void curveTo(float x1, float y1, float x2, float y2, float x3, float y3);
-    virtual void closeSubpath();
-
-    virtual FloatRect boundingBox();
-    virtual FloatRect strokeBoundingBox(const KRenderingStrokePainter&);
-    virtual bool containsPoint(const FloatPoint&, KCWindRule);
-    virtual bool strokeContainsPoint(const FloatPoint&);
-    
-    CGPathRef cgPath() const { return m_cgPath; }
-    
-private:
-    CGMutablePathRef m_cgPath;
-};
-
-}
-
-#endif
diff --git a/WebCore/kcanvas/device/quartz/KCanvasPathQuartz.mm b/WebCore/kcanvas/device/quartz/KCanvasPathQuartz.mm
deleted file mode 100644 (file)
index 5115225..0000000
+++ /dev/null
@@ -1,144 +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. 
- */
-
-#include "config.h"
-#ifdef SVG_SUPPORT
-#include "KCanvasPathQuartz.h"
-#include "QuartzSupport.h"
-
-namespace WebCore {
-
-KCanvasPathQuartz::KCanvasPathQuartz()
-{
-    m_cgPath = CGPathCreateMutable();
-}
-
-KCanvasPathQuartz::~KCanvasPathQuartz()
-{
-    CGPathRelease(m_cgPath);
-}
-
-bool KCanvasPathQuartz::isEmpty() const
-{
-    return CGPathIsEmpty(m_cgPath);
-}
-
-void KCanvasPathQuartz::moveTo(float x, float y)
-{
-    CGPathMoveToPoint(m_cgPath, 0, x, y);
-}
-
-void KCanvasPathQuartz::lineTo(float x, float y)
-{
-    CGPathAddLineToPoint(m_cgPath, 0, x, y);
-}
-
-void KCanvasPathQuartz::curveTo(float x1, float y1, float x2, float y2, float x3, float y3)
-{
-    CGPathAddCurveToPoint(m_cgPath, 0, x1, y1, x2, y2, x3, y3);
-}
-
-void KCanvasPathQuartz::closeSubpath()
-{
-    CGPathCloseSubpath(m_cgPath);
-}
-
-FloatRect KCanvasPathQuartz::boundingBox()
-{
-    return CGPathGetBoundingBox(m_cgPath);
-}
-
-CGContextRef scratchContext()
-{
-    static CGContextRef scratch = 0;
-    if (!scratch) {
-        CFMutableDataRef empty = CFDataCreateMutable(NULL, 0);
-        CGDataConsumerRef consumer = CGDataConsumerCreateWithCFData(empty);
-        scratch = CGPDFContextCreate(consumer, NULL, NULL);
-        CGDataConsumerRelease(consumer);
-        CFRelease(empty);
-
-        CGFloat black[4] = {0, 0, 0, 1};
-        CGContextSetFillColor(scratch, black);
-        CGContextSetStrokeColor(scratch, black);
-    }
-    return scratch;
-}
-
-FloatRect KCanvasPathQuartz::strokeBoundingBox(const KRenderingStrokePainter& strokePainter)
-{
-    // the bbox might grow if the path is stroked.
-    // and CGPathGetBoundingBox doesn't support that, so we'll have
-    // to make an alternative call...
-
-    // FIXME: since this is mainly used to decide what to repaint,
-    // perhaps it would be sufficien to just outset the fill bbox by
-    // the stroke width - that should be way cheaper and simpler than
-    // what we do here.
-    if (isEmpty())
-        return CGRectNull;
-
-    CGContextRef context = scratchContext();
-    CGContextSaveGState(context);
-
-    CGContextBeginPath(context);
-    CGContextAddPath(context, m_cgPath);
-    applyStrokeStyleToContext(context, strokePainter);
-    CGContextReplacePathWithStrokedPath(context);
-    CGRect box = CGContextGetPathBoundingBox(context);
-        
-    CGContextRestoreGState(context);
-
-    return FloatRect(box);
-}
-
-static bool pathContainsPoint(CGMutablePathRef cgPath, const FloatPoint& point, CGPathDrawingMode drawMode)
-{
-   CGContextRef context = scratchContext();
-   CGContextSaveGState(context);
-   
-   CGContextBeginPath(context);
-   CGContextAddPath(context, cgPath);
-   bool hitSuccess = CGContextPathContainsPoint(context, point, drawMode);
-
-   CGContextRestoreGState(context);
-
-   return hitSuccess;
-}
-
-bool KCanvasPathQuartz::containsPoint(const FloatPoint& point, KCWindRule fillRule)
-{
-    return pathContainsPoint(m_cgPath, point, fillRule == RULE_EVENODD ? kCGPathEOFill : kCGPathFill);
-}
-
-bool KCanvasPathQuartz::strokeContainsPoint(const FloatPoint& point)
-{
-    return pathContainsPoint(m_cgPath, point, kCGPathStroke);
-}
-
-}
-
-#endif // SVG_SUPPORT
-
index b833b79..dd4b8e8 100644 (file)
@@ -32,7 +32,6 @@
 #import "GraphicsContext.h"
 #import "KCanvasFilterQuartz.h"
 #import "KCanvasMaskerQuartz.h"
-#import "KCanvasPathQuartz.h"
 #import "KRenderingDeviceQuartz.h"
 #import "QuartzSupport.h"
 
@@ -46,7 +45,7 @@ void KCanvasClipperQuartz::applyClip(const FloatRect& boundingBox) const
         return;
 
     BOOL heterogenousClipRules = NO;
-    KCWindRule clipRule = m_clipData[0].windRule();
+    WindRule clipRule = m_clipData[0].windRule();
 
     context->clearPath();
 
@@ -57,8 +56,7 @@ void KCanvasClipperQuartz::applyClip(const FloatRect& boundingBox) const
         if (data.windRule() != clipRule)
             heterogenousClipRules = YES;
         
-        KCanvasPathQuartz *path = static_cast<KCanvasPathQuartz*>(data.path.get());        
-        CGPathRef clipPath = static_cast<KCanvasPathQuartz*>(path)->cgPath();
+        CGPathRef clipPath = data.path.platformPath();
 
         if (data.bboxUnits) {
             CGMutablePathRef transformedPath = CGPathCreateMutable();
index 7eae39d..a0f4834 100644 (file)
@@ -47,11 +47,11 @@ public:
     KRenderingDeviceContextQuartz(CGContextRef context);
     virtual ~KRenderingDeviceContextQuartz();
     
-    virtual AffineTransform concatCTM(const AffineTransform&);
+    virtual AffineTransform concatCTM(const AffineTransform &);
     virtual AffineTransform ctm() const;
     
     virtual void clearPath();
-    virtual void addPath(const KCanvasPath*);
+    virtual void addPath(const Path&);
 
     virtual GraphicsContext* createGraphicsContext();
     
@@ -78,16 +78,13 @@ public:
     CGContextRef currentCGContext() const;
     virtual KRenderingDeviceContext *contextForImage(KCanvasImage *) const;
 
-    virtual DeprecatedString stringForPath(const KCanvasPath* path);
-
     // Resource creation
     virtual KCanvasResource *createResource(const KCResourceType &type) const;
     virtual KRenderingPaintServer *createPaintServer(const KCPaintServerType &type) const;
     virtual KCanvasFilterEffect *createFilterEffect(const KCFilterEffectType &type) const;
-    virtual KCanvasPath* createPath() const;
     
     // item creation
-    virtual RenderPath *createItem(RenderArena *arena, RenderStyle *style, SVGStyledElement *node, KCanvasPath* path) const;
+    virtual RenderPath *createItem(RenderArena *arena, RenderStyle *style, SVGStyledElement *node, const Path& path) const;
 
     // filters (mostly debugging)
     static bool filtersEnabled();
index 6cc3c79..94be281 100644 (file)
@@ -33,7 +33,6 @@
 #import "KCanvasFilterQuartz.h"
 #import "KCanvasItemQuartz.h"
 #import "KCanvasMaskerQuartz.h"
-#import "KCanvasPathQuartz.h"
 #import "KCanvasResourcesQuartz.h"
 #import "KRenderingFillPainter.h"
 #import "KRenderingPaintServerQuartz.h"
@@ -75,9 +74,9 @@ void KRenderingDeviceContextQuartz::clearPath()
     CGContextBeginPath(m_cgContext);
 }
 
-void KRenderingDeviceContextQuartz::addPath(const KCanvasPath *path)
+void KRenderingDeviceContextQuartz::addPath(const Path& path)
 {
-    CGContextAddPath(m_cgContext, static_cast<const KCanvasPathQuartz*>(path)->cgPath());
+    CGContextAddPath(m_cgContext, path.platformPath());
 }
 
 NSGraphicsContext *KRenderingDeviceContextQuartz::nsGraphicsContext()
@@ -163,26 +162,6 @@ KRenderingDeviceContext *KRenderingDeviceQuartz::contextForImage(KCanvasImage *i
 }
 
 #pragma mark -
-#pragma mark Path Management
-
-KCanvasPath* KRenderingDeviceQuartz::createPath() const
-{
-    return new KCanvasPathQuartz();
-}
-
-DeprecatedString KRenderingDeviceQuartz::stringForPath(const KCanvasPath *path)
-{
-    DeprecatedString result;
-    if (path) {
-        CGPathRef cgPath = static_cast<const KCanvasPathQuartz *>(path)->cgPath();
-        CFStringRef pathString = CFStringFromCGPath(cgPath);
-        result = DeprecatedString::fromCFString(pathString);
-        CFRelease(pathString);
-    }
-    return result;
-}
-
-#pragma mark -
 #pragma mark Resource Creation
 
 KRenderingPaintServer *KRenderingDeviceQuartz::createPaintServer(const KCPaintServerType &type) const
@@ -205,7 +184,7 @@ KRenderingPaintServer *KRenderingDeviceQuartz::createPaintServer(const KCPaintSe
     return newServer;
 }
 
-RenderPath *KRenderingDeviceQuartz::createItem(RenderArena *arena, RenderStyle *style, SVGStyledElement *node, KCanvasPath* path) const
+RenderPath *KRenderingDeviceQuartz::createItem(RenderArena *arena, RenderStyle *style, SVGStyledElement *node, const Path& path) const
 {
     RenderPath *item = new (arena) KCanvasItemQuartz(style, node);
     item->setPath(path);
index c783908..3e2ef65 100644 (file)
 
 namespace WebCore {
 
+typedef struct CGPath *CGMutablePathRef;
+
+class Path;
 class IntRect;
+class FloatRect;
+class FloatPoint;
 class RenderStyle;
 class RenderObject;
+class KRenderingStrokePainter;
 
 #ifndef NDEBUG
 void debugDumpCGImageToFile(NSString *filename, CGImageRef image, int width, int height);
@@ -46,6 +52,9 @@ CGAffineTransform CGAffineTransformMakeMapBetweenRects(CGRect source, CGRect des
 void applyStrokeStyleToContext(CGContextRef, const KRenderingStrokePainter&);
 void applyStrokeStyleToContext(CGContextRef, RenderStyle*, const RenderObject*);
 
+FloatRect strokeBoundingBox(const Path& path, const KRenderingStrokePainter& strokePainter);
+bool pathContainsPoint(CGMutablePathRef cgPath, const FloatPoint& point, CGPathDrawingMode drawMode);
+
 static inline CGLineCap CGLineCapFromKC(KCCapStyle cap)
 {
     if (cap == CAP_BUTT)
index 323a0fa..b293149 100644 (file)
@@ -125,41 +125,62 @@ void applyStrokeStyleToContext(CGContextRef context, RenderStyle* renderStyle, c
     applyStrokeStyleToContext(context, strokePainter);
 }
 
-void CGPathToCFStringApplierFunction(void *info, const CGPathElement *element)
+CGContextRef scratchContext()
 {
-    CFMutableStringRef string = (CFMutableStringRef)info;
-    CFStringRef typeString = CFSTR("");
-    CGPoint *points = element->points;
-    switch(element->type) {
-    case kCGPathElementMoveToPoint:
-        CFStringAppendFormat(string, 0, CFSTR("M%.2f,%.2f"), points[0].x, points[0].y);
-        break;
-    case kCGPathElementAddLineToPoint:
-        CFStringAppendFormat(string, 0, CFSTR("L%.2f,%.2f"), points[0].x, points[0].y);
-        break;
-    case kCGPathElementAddQuadCurveToPoint:
-        CFStringAppendFormat(string, 0, CFSTR("Q%.2f,%.2f,%.2f,%.2f"),
-                points[0].x, points[0].y, points[1].x, points[1].y);
-        break;
-    case kCGPathElementAddCurveToPoint:
-        CFStringAppendFormat(string, 0, CFSTR("C%.2f,%.2f,%.2f,%.2f,%.2f,%.2f"),
-                points[0].x, points[0].y, points[1].x, points[1].y,
-                points[2].x, points[2].y);
-        break;
-    case kCGPathElementCloseSubpath:
-        typeString = CFSTR("X"); break;
-    }
+    static CGContextRef scratch = 0;
+    if (!scratch) {
+        CFMutableDataRef empty = CFDataCreateMutable(NULL, 0);
+        CGDataConsumerRef consumer = CGDataConsumerCreateWithCFData(empty);
+        scratch = CGPDFContextCreate(consumer, NULL, NULL);
+        CGDataConsumerRelease(consumer);
+        CFRelease(empty);
+
+        CGFloat black[4] = {0, 0, 0, 1};
+        CGContextSetFillColor(scratch, black);
+        CGContextSetStrokeColor(scratch, black);
+     }
+    return scratch;
+}
+
+FloatRect strokeBoundingBox(const Path& path, const KRenderingStrokePainter& strokePainter)
+ {
+    // the bbox might grow if the path is stroked.
+    // and CGPathGetBoundingBox doesn't support that, so we'll have
+    // to make an alternative call...
+    // FIXME: since this is mainly used to decide what to repaint,
+    // perhaps it would be sufficien to just outset the fill bbox by
+    // the stroke width - that should be way cheaper and simpler than
+    // what we do here.
+    CGPathRef cgPath = path.platformPath();
+
+    CGContextRef context = scratchContext();
+    CGContextSaveGState(context);
+
+    CGContextBeginPath(context);
+    CGContextAddPath(context, cgPath);
+    applyStrokeStyleToContext(context, strokePainter);
+    CGContextReplacePathWithStrokedPath(context);
+    CGRect box = CGContextGetPathBoundingBox(context);
+        
+    CGContextRestoreGState(context);
+
+    return FloatRect(box);
 }
 
-CFStringRef CFStringFromCGPath(CGPathRef path)
+bool pathContainsPoint(CGMutablePathRef cgPath, const FloatPoint& point, CGPathDrawingMode drawMode)
 {
-    if (!path)
-        return 0;
+   CGContextRef context = scratchContext();
+   CGContextSaveGState(context);
+   
+   CGContextBeginPath(context);
+   CGContextAddPath(context, cgPath);
+   bool hitSuccess = CGContextPathContainsPoint(context, point, drawMode);
 
-    CFMutableStringRef string = CFStringCreateMutable(NULL, 0);
-    CGPathApply(path, string, CGPathToCFStringApplierFunction);
+   CGContextRestoreGState(context);
 
-    return string;
+   return hitSuccess;
 }
 
 }
index cfd66d7..3a25260 100644 (file)
@@ -187,7 +187,7 @@ bool CSSParser::parseSVGValue(int propId, bool important)
      */
 
     case SVGCSS_PROP_POINTER_EVENTS:
-    // visiblePainted | visibleFill | visibleStroke | visible |
+    // none | visiblePainted | visibleFill | visibleStroke | visible |
     // painted | fill | stroke | none | all | inherit
         if (id == CSS_VAL_VISIBLE || id == CSS_VAL_NONE ||
           (id >= SVGCSS_VAL_VISIBLEPAINTED && id <= SVGCSS_VAL_ALL))
index 6ce3982..1ee1cf4 100644 (file)
@@ -299,10 +299,10 @@ void CSSStyleSelector::applySVGProperty(int id, CSSValue* value)
             switch (primitiveValue->getIdent())
             {
                 case SVGCSS_VAL_NONZERO:
-                    svgstyle->setClipRule(WR_NONZERO);
+                    svgstyle->setClipRule(RULE_NONZERO);
                     break;
                 case SVGCSS_VAL_EVENODD:
-                    svgstyle->setClipRule(WR_EVENODD);
+                    svgstyle->setClipRule(RULE_EVENODD);
                     break;
                 default:
                     break;
@@ -319,10 +319,10 @@ void CSSStyleSelector::applySVGProperty(int id, CSSValue* value)
             switch (primitiveValue->getIdent())
             {
                 case SVGCSS_VAL_NONZERO:
-                    svgstyle->setFillRule(WR_NONZERO);
+                    svgstyle->setFillRule(RULE_NONZERO);
                     break;
                 case SVGCSS_VAL_EVENODD:
-                    svgstyle->setFillRule(WR_EVENODD);
+                    svgstyle->setFillRule(RULE_EVENODD);
                 default:
                     return;
             }
index 0b2d839..964e969 100644 (file)
@@ -78,11 +78,11 @@ namespace WebCore {
         SVG_RS_DEFINE_ATTRIBUTE(EDominantBaseline, DominantBaseline, dominantBaseline, DB_AUTO)
 
         SVG_RS_DEFINE_ATTRIBUTE_INHERITED(ECapStyle, CapStyle, capStyle, CS_BUTT)
-        SVG_RS_DEFINE_ATTRIBUTE_INHERITED(EWindRule, ClipRule, clipRule, WR_NONZERO)
+        SVG_RS_DEFINE_ATTRIBUTE_INHERITED(WindRule, ClipRule, clipRule, RULE_NONZERO)
         SVG_RS_DEFINE_ATTRIBUTE_INHERITED(EColorInterpolation, ColorInterpolation, colorInterpolation, CI_SRGB)
         SVG_RS_DEFINE_ATTRIBUTE_INHERITED(EColorInterpolation, ColorInterpolationFilters, colorInterpolationFilters, CI_LINEARRGB)
         SVG_RS_DEFINE_ATTRIBUTE_INHERITED(EColorRendering, ColorRendering, colorRendering, CR_AUTO)
-        SVG_RS_DEFINE_ATTRIBUTE_INHERITED(EWindRule, FillRule, fillRule, WR_NONZERO)
+        SVG_RS_DEFINE_ATTRIBUTE_INHERITED(WindRule, FillRule, fillRule, RULE_NONZERO)
         SVG_RS_DEFINE_ATTRIBUTE_INHERITED(EImageRendering, ImageRendering, imageRendering, IR_AUTO)
         SVG_RS_DEFINE_ATTRIBUTE_INHERITED(EJoinStyle, JoinStyle, joinStyle, JS_MITER)
         SVG_RS_DEFINE_ATTRIBUTE_INHERITED(EPointerEvents, PointerEvents, pointerEvents, PE_VISIBLE_PAINTED)
@@ -129,8 +129,8 @@ namespace WebCore {
                     unsigned _imageRendering : 2; // EImageRendering 
                     unsigned _shapeRendering : 2; // EShapeRendering 
                     unsigned _textRendering : 2; // ETextRendering
-                    unsigned _clipRule : 1; // EWindRule
-                    unsigned _fillRule : 1; // EWindRule
+                    unsigned _clipRule : 1; // WindRule
+                    unsigned _fillRule : 1; // WindRule
                     unsigned _capStyle : 2; // ECapStyle
                     unsigned _joinStyle : 2; // EJoinStyle
                     unsigned _textAnchor : 2; // ETextAnchor
index 587dbe9..73d5ab5 100644 (file)
@@ -31,6 +31,7 @@
 #ifdef SVG_SUPPORT
 
 #include "DeprecatedString.h"
+#include "Path.h"
 
 // Helper macros for 'SVGRenderStyle'
 #define SVG_RS_DEFINE_ATTRIBUTE(Data, Type, Name, Initial) \
 
 namespace WebCore {
 
-    enum EWindRule {
-        WR_NONZERO = 0, WR_EVENODD = 1
-    };
-
     enum ECapStyle {
         CS_BUTT = 1, CS_ROUND = 2, CS_SQUARE = 3
     };
index aa91650..8571483 100644 (file)
@@ -26,7 +26,6 @@
 
 #include "CSSValueList.h"
 #include "Document.h"
-#include "KCanvasPath.h"
 #include "KCanvasRenderingStyle.h"
 #include "KRenderingDevice.h"
 #include "KRenderingFillPainter.h"
@@ -178,7 +177,7 @@ KRenderingFillPainter KSVGPainterFactory::fillPainter(const RenderStyle* style,
 {
     KRenderingFillPainter fillPainter;
     
-    fillPainter.setFillRule(style->svgStyle()->fillRule() == WR_NONZERO ? RULE_NONZERO : RULE_EVENODD);
+    fillPainter.setFillRule(style->svgStyle()->fillRule());
     fillPainter.setOpacity(style->svgStyle()->fillOpacity());
 
     return fillPainter;
index d1057a5..d660c48 100644 (file)
@@ -24,6 +24,8 @@
 #ifdef SVG_SUPPORT
 #include "Attr.h"
 
+#include "FloatPoint.h"
+
 #include "SVGNames.h"
 #include "SVGHelper.h"
 #include "SVGCircleElement.h"
@@ -75,12 +77,12 @@ void SVGCircleElement::parseMappedAttribute(MappedAttribute *attr)
     }
 }
 
-KCanvasPath* SVGCircleElement::toPathData() const
+Path SVGCircleElement::toPathData() const
 {
     float _cx = cx()->baseVal()->value(), _cy = cy()->baseVal()->value();
     float _r = r()->baseVal()->value();
 
-    return KCanvasCreator::self()->createCircle(_cx, _cy, _r);
+    return KCanvasCreator::self()->createCircle(FloatPoint(_cx, _cy), _r);
 }
 
 const SVGStyledElement *SVGCircleElement::pushAttributeContext(const SVGStyledElement *context)
index 30d05cd..dff37ac 100644 (file)
@@ -51,7 +51,7 @@ namespace WebCore
         virtual void parseMappedAttribute(MappedAttribute *attr);
 
         virtual bool rendererIsNeeded(RenderStyle *style) { return StyledElement::rendererIsNeeded(style); }
-        virtual KCanvasPath* toPathData() const;
+        virtual Path toPathData() const;
 
         virtual const SVGStyledElement *pushAttributeContext(const SVGStyledElement *context);
 
index 69b9545..d8c19ae 100644 (file)
@@ -33,7 +33,6 @@
 #include "SVGRenderStyle.h"
 #include "cssstyleselector.h"
 #include "ksvg.h"
-#include <kcanvas/KCanvasPath.h>
 #include <kcanvas/device/KRenderingDevice.h>
 
 using namespace WebCore;
@@ -96,8 +95,9 @@ KCanvasClipper *SVGClipPathElement::canvasResource()
         if (e && e->isStyled()) {
             SVGStyledElement *styled = static_cast<SVGStyledElement *>(e);
             RenderStyle *pathStyle = document()->styleSelector()->styleForElement(styled, clipPathStyle);
-            if (KCanvasPath* pathData = styled->toPathData())
-                m_clipper->addClipData(pathData, (KCWindRule) pathStyle->svgStyle()->clipRule(), bbox);
+            Path pathData = styled->toPathData();
+            if (!pathData.isEmpty())
+                m_clipper->addClipData(pathData, pathStyle->svgStyle()->clipRule(), bbox);
             pathStyle->deref(view()->renderArena());
         }
     }
index f6361f9..99b1257 100644 (file)
@@ -24,6 +24,8 @@
 #ifdef SVG_SUPPORT
 #include "Attr.h"
 
+#include "FloatPoint.h"
+
 #include "SVGNames.h"
 #include "SVGHelper.h"
 #include "SVGEllipseElement.h"
@@ -82,12 +84,12 @@ void SVGEllipseElement::parseMappedAttribute(MappedAttribute *attr)
     }
 }
 
-KCanvasPath* SVGEllipseElement::toPathData() const
+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(_cx, _cy, _rx, _ry);
+    return KCanvasCreator::self()->createEllipse(FloatPoint(_cx, _cy), _rx, _ry);
 }
 
 const SVGStyledElement *SVGEllipseElement::pushAttributeContext(const SVGStyledElement *context)
index 55aa512..505cbe7 100644 (file)
@@ -52,7 +52,7 @@ namespace WebCore
         virtual void parseMappedAttribute(MappedAttribute *attr);
 
         virtual bool rendererIsNeeded(RenderStyle *style) { return StyledElement::rendererIsNeeded(style); }
-        virtual KCanvasPath* toPathData() const;
+        virtual Path toPathData() const;
 
         virtual const SVGStyledElement *pushAttributeContext(const SVGStyledElement *context);
 
index abe7c92..5c65ef0 100644 (file)
@@ -111,8 +111,8 @@ void SVGGradientElement::notifyAttributeChange() const
     
     m_resource->invalidate();  // should this be added to build gradient?
     
-    const KCanvasItemList &clients = m_resource->clients();
-    for(KCanvasItemList::ConstIterator it = clients.begin(); it != clients.end(); ++it)
+    const RenderPathList &clients = m_resource->clients();
+    for(RenderPathList::ConstIterator it = clients.begin(); it != clients.end(); ++it)
     {
         const RenderPath *current = (*it);
         SVGStyledElement *styled = (current ? static_cast<SVGStyledElement *>(current->element()) : 0);
index 30ab4ab..0a5884a 100644 (file)
@@ -41,7 +41,6 @@
 #include <kcanvas/RenderSVGContainer.h>
 #include <kcanvas/KCanvasCreator.h>
 #include <kcanvas/KCanvasImage.h>
-#include <kcanvas/KCanvasPath.h>
 #include <wtf/Assertions.h>
 
 using namespace WebCore;
index 9c2d5ed..f6a2b52 100644 (file)
@@ -24,6 +24,8 @@
 #ifdef SVG_SUPPORT
 #include "Attr.h"
 
+#include "FloatPoint.h"
+
 #include "SVGNames.h"
 #include "SVGHelper.h"
 #include "SVGLineElement.h"
@@ -82,12 +84,12 @@ void SVGLineElement::parseMappedAttribute(MappedAttribute *attr)
     }
 }
 
-KCanvasPath* SVGLineElement::toPathData() const
+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(_x1, _y1, _x2, _y2);
+    return KCanvasCreator::self()->createLine(FloatPoint(_x1, _y1), FloatPoint(_x2, _y2));
 }
 
 const SVGStyledElement *SVGLineElement::pushAttributeContext(const SVGStyledElement *context)
index 4ee721e..3e3d01d 100644 (file)
@@ -52,7 +52,7 @@ namespace WebCore
         virtual void parseMappedAttribute(MappedAttribute *attr);
 
         virtual bool rendererIsNeeded(RenderStyle *style) { return StyledElement::rendererIsNeeded(style); }
-        virtual KCanvasPath* toPathData() const;
+        virtual Path toPathData() const;
 
         virtual const SVGStyledElement *pushAttributeContext(const SVGStyledElement *context);
 
index d458a73..6fb329d 100644 (file)
@@ -28,7 +28,6 @@
 #include "GraphicsContext.h"
 #include "RenderSVGContainer.h"
 #include "KCanvasImage.h"
-#include "KCanvasPath.h"
 #include "KRenderingDevice.h"
 #include "SVGAnimatedLength.h"
 #include "SVGHelper.h"
index 13773c9..4d3aa58 100644 (file)
@@ -379,14 +379,14 @@ SVGPathSegList *SVGPathElement::animatedNormalizedPathSegList() const
 }
 
 // FIXME: This probably belongs on SVGPathSegList instead. -- ecs 12/5/05
-KCanvasPath* SVGPathElement::toPathData() const
+Path SVGPathElement::toPathData() const
 {
+    Path pathData;
     // TODO : also support non-normalized mode, at least in dom structure
     int len = pathSegList()->numberOfItems();
     if(len < 1)
-        return 0;
+        return pathData;
 
-    KCanvasPath* pathData = renderingDevice()->createPath();
     for(int i = 0; i < len; ++i)
     {
         SVGPathSeg *p = pathSegList()->getItem(i);
@@ -395,25 +395,25 @@ KCanvasPath* SVGPathElement::toPathData() const
             case PATHSEG_MOVETO_ABS:
             {
                 SVGPathSegMovetoAbs *moveTo = static_cast<SVGPathSegMovetoAbs *>(p);
-                pathData->moveTo(moveTo->x(), moveTo->y());
+                pathData.moveTo(FloatPoint(moveTo->x(), moveTo->y()));
                 break;
             }
             case PATHSEG_LINETO_ABS:
             {
                 SVGPathSegLinetoAbs *lineTo = static_cast<SVGPathSegLinetoAbs *>(p);
-                pathData->lineTo(lineTo->x(), lineTo->y());
+                pathData.addLineTo(FloatPoint(lineTo->x(), lineTo->y()));
                 break;
             }
             case PATHSEG_CURVETO_CUBIC_ABS:
             {
                 SVGPathSegCurvetoCubicAbs *curveTo = static_cast<SVGPathSegCurvetoCubicAbs *>(p);
-                pathData->curveTo(curveTo->x1(), curveTo->y1(),
-                                 curveTo->x2(), curveTo->y2(),
-                                 curveTo->x(), curveTo->y());
+                pathData.addBezierCurveTo(FloatPoint(curveTo->x1(), curveTo->y1()),
+                                 FloatPoint(curveTo->x2(), curveTo->y2()),
+                                 FloatPoint(curveTo->x(), curveTo->y()));
                 break;
             }
             case PATHSEG_CLOSEPATH:
-                pathData->closeSubpath();
+                pathData.closeSubpath();
             default:
                 break;
         }
index 23f49ae..dcbfbcb 100644 (file)
@@ -101,7 +101,7 @@ namespace WebCore
         virtual void parseMappedAttribute(MappedAttribute *attr);
 
         virtual bool rendererIsNeeded(RenderStyle *style) { return StyledElement::rendererIsNeeded(style); }
-        virtual KCanvasPath* toPathData() const;
+        virtual Path toPathData() const;
 
     private:
         mutable RefPtr<SVGPathSegList> m_pathSegList;
index 9279446..fb06571 100644 (file)
@@ -287,10 +287,10 @@ void SVGPatternElement::drawPatternContentIntoTile(const SVGPatternElement* targ
 
 void SVGPatternElement::notifyClientsToRepaint() const
 {
-    const KCanvasItemList &clients = m_paintServer->clients();
+    const RenderPathList &clients = m_paintServer->clients();
 
-    KCanvasItemList::ConstIterator it = clients.begin();
-    KCanvasItemList::ConstIterator end = clients.end();
+    RenderPathList::ConstIterator it = clients.begin();
+    RenderPathList::ConstIterator end = clients.end();
 
     for(; it != end; ++it)
     {
index 4687927..b469882 100644 (file)
@@ -39,20 +39,21 @@ SVGPolygonElement::~SVGPolygonElement()
 {
 }
 
-KCanvasPath* SVGPolygonElement::toPathData() const
+Path SVGPolygonElement::toPathData() const
 {
+    Path polyData;
     int len = points()->numberOfItems();
     if(len < 1)
-        return 0;
+        return polyData;
     
-    KCanvasPath* polyData = renderingDevice()->createPath();
-    polyData->moveTo(points()->getItem(0)->x(), points()->getItem(0)->y());
+    polyData.moveTo(FloatPoint(points()->getItem(0)->x(), points()->getItem(0)->y()));
     for (int i = 1; i < len; ++i) {
         SVGPoint *p = points()->getItem(i);
-        polyData->lineTo(p->x(), p->y());
+        polyData.addLineTo(FloatPoint(p->x(), p->y()));
     }
 
-    polyData->closeSubpath();
+    polyData.closeSubpath();
+
     return polyData;
 }
 
index e615cbe..181e0da 100644 (file)
@@ -34,7 +34,7 @@ namespace WebCore
         SVGPolygonElement(const QualifiedName&, Document*);
         virtual ~SVGPolygonElement();
 
-        virtual KCanvasPath* toPathData() const;
+        virtual Path toPathData() const;
     };
 
 } // namespace WebCore
index 1c0ac62..60ecb3b 100644 (file)
@@ -39,19 +39,18 @@ SVGPolylineElement::~SVGPolylineElement()
 {
 }
 
-KCanvasPath* SVGPolylineElement::toPathData() const
+Path SVGPolylineElement::toPathData() const
 {
+    Path polyData;
     int len = points()->numberOfItems();
     if(len < 1)
-        return 0;
+        return polyData;
 
-    KCanvasPath* polyData = renderingDevice()->createPath();
-    polyData->moveTo(points()->getItem(0)->x(), points()->getItem(0)->y());
+    polyData.moveTo(FloatPoint(points()->getItem(0)->x(), points()->getItem(0)->y()));
     for (int i = 1; i < len; ++i) {
         SVGPoint *p = points()->getItem(i);
-        polyData->lineTo(p->x(), p->y());
+        polyData.addLineTo(FloatPoint(p->x(), p->y()));
     }
-
     return polyData;
 }
 
index b67c03d..618feea 100644 (file)
@@ -34,7 +34,7 @@ namespace WebCore
         SVGPolylineElement(const QualifiedName&, Document*);
         virtual ~SVGPolylineElement();
 
-        virtual KCanvasPath* toPathData() const;
+        virtual Path toPathData() const;
     };
 
 } // namespace WebCore
index 09ff69b..d4550bf 100644 (file)
@@ -100,7 +100,7 @@ void SVGRectElement::parseMappedAttribute(MappedAttribute *attr)
     }
 }
 
-KCanvasPath* SVGRectElement::toPathData() const
+Path SVGRectElement::toPathData() const
 {
     float _x = x()->baseVal()->value(), _y = y()->baseVal()->value();
     float _width = width()->baseVal()->value(), _height = height()->baseVal()->value();
@@ -111,10 +111,10 @@ KCanvasPath* 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(_x, _y, _width, _height, _rx, _ry);
+        return KCanvasCreator::self()->createRoundedRectangle(FloatRect(_x, _y, _width, _height), FloatSize(_rx, _ry));
     }
 
-    return KCanvasCreator::self()->createRectangle(_x, _y, _width, _height);
+    return KCanvasCreator::self()->createRectangle(FloatRect(_x, _y, _width, _height));
 }
 
 const SVGStyledElement *SVGRectElement::pushAttributeContext(const SVGStyledElement *context)
index ea02407..76da608 100644 (file)
@@ -56,7 +56,7 @@ namespace WebCore
         virtual void parseMappedAttribute(MappedAttribute *attr);
 
         virtual bool rendererIsNeeded(RenderStyle *style) { return StyledElement::rendererIsNeeded(style); }
-        virtual KCanvasPath* toPathData() const;
+        virtual Path toPathData() const;
 
         virtual const SVGStyledElement *pushAttributeContext(const SVGStyledElement *context);
 
index c785aa6..3bac764 100644 (file)
@@ -68,10 +68,10 @@ SVGAnimatedString* SVGStyledElement::className() const
 
 RenderObject* SVGStyledElement::createRenderer(RenderArena* arena, RenderStyle* style)
 {
-    RefPtr<KCanvasPath> pathData = toPathData();
-    if (!pathData)
+    Path pathData = toPathData();
+    if (pathData.isEmpty())
         return 0;
-    return renderingDevice()->createItem(arena, style, this, pathData.get());
+    return renderingDevice()->createItem(arena, style, this, pathData);
 }
 
 void SVGStyledElement::parseMappedAttribute(MappedAttribute* attr)
index 5b4f70f..84e6bcf 100644 (file)
@@ -28,7 +28,7 @@
 #include "RenderStyle.h"
 #include "SVGElement.h"
 #include "SVGStylable.h"
-#include <kcanvas/KCanvasPath.h>
+#include "Path.h"
 
 namespace WebCore {
 
@@ -51,7 +51,7 @@ namespace WebCore {
 
         // These need to be implemented.
         virtual bool rendererIsNeeded(RenderStyle*) { return false; }
-        virtual KCanvasPath* toPathData() const { return 0; }
+        virtual Path toPathData() const { return Path(); }
         virtual RenderObject* createRenderer(RenderArena*, RenderStyle*);
         virtual KCanvasResource* canvasResource() { return 0; }
         
index e89ec31..cf3de44 100644 (file)
@@ -30,6 +30,8 @@
 #include "SVGTextContentElement.h"
 #include "SVGAnimatedLength.h"
 #include "SVGAnimatedEnumeration.h"
+#include "FloatPoint.h"
+#include "FloatRect.h"
 
 using namespace WebCore;
 
index 8fad042..44b6cf7 100644 (file)
@@ -33,6 +33,7 @@
 #include "RenderStyle.h"
 #include <kcanvas/KCanvasCreator.h>
 #include <kcanvas/RenderSVGText.h>
+#include "FloatRect.h"
 
 namespace WebCore {
 
index 0349fe1..ba1d0d3 100644 (file)
@@ -1,5 +1,6 @@
 /*
  * Copyright (C) 2003, 2006 Apple Computer, Inc.  All rights reserved.
+ *                     2006 Rob Buis <buis@kde.org>
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -37,9 +38,15 @@ typedef void PlatformPath;
 
 namespace WebCore {
 
+    enum WindRule {
+        RULE_NONZERO = 0,
+        RULE_EVENODD = 1
+    };
+
     class FloatPoint;
     class FloatSize;
     class FloatRect;
+    class String;
 
     class Path {
     public:
@@ -49,10 +56,11 @@ namespace WebCore {
         Path(const Path&);
         Path& operator=(const Path&);
 
-        bool contains(const FloatPoint&) const;
+        bool contains(const FloatPoint&, WindRule rule = RULE_NONZERO) const;
         FloatRect boundingRect() const;
 
         void clear();
+        bool isEmpty() const;
 
         void moveTo(const FloatPoint&);
         void addLineTo(const FloatPoint&);
@@ -67,10 +75,16 @@ namespace WebCore {
 
         void translate(const FloatSize&);
 
+        void setWindingRule(WindRule rule) { m_rule = rule; }
+        WindRule windingRule() const { return m_rule; }
+
+        String debugString() const;
+
         PlatformPath* platformPath() const { return m_path; }
 
     private:
         PlatformPath* m_path;
+        WindRule m_rule;
     };
 
 }
index 1d97371..297bc25 100644 (file)
@@ -1,5 +1,6 @@
 /*
  * Copyright (C) 2003, 2006 Apple Computer, Inc.  All rights reserved.
+ *                     2006 Rob Buis <buis@kde.org>
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -29,6 +30,7 @@
 #if PLATFORM(CG)
 
 #include "FloatRect.h"
+#include "PlatformString.h"
 #include <ApplicationServices/ApplicationServices.h>
 
 namespace WebCore {
@@ -56,9 +58,9 @@ Path& Path::operator=(const Path& other)
     return *this;
 }
 
-bool Path::contains(const FloatPoint& point) const
+bool Path::contains(const FloatPoint &point, WindRule rule) const
 {
-    return CGPathContainsPoint(m_path, 0, point, false);
+    return CGPathContainsPoint(m_path, 0, point, rule == RULE_EVENODD ? true : false);
 }
 
 void Path::translate(const FloatSize& size)
@@ -126,6 +128,63 @@ void Path::clear()
     m_path = CGPathCreateMutable();
 }
 
+bool Path::isEmpty() const
+{
+    return CGPathIsEmpty(m_path);
+ }
+
+void CGPathToCFStringApplierFunction(void *info, const CGPathElement *element)
+{
+    CFMutableStringRef string = (CFMutableStringRef)info;
+    CFStringRef typeString = CFSTR("");
+    CGPoint *points = element->points;
+    switch(element->type) {
+    case kCGPathElementMoveToPoint:
+        CFStringAppendFormat(string, 0, CFSTR("M%.2f,%.2f"), points[0].x, points[0].y);
+        break;
+    case kCGPathElementAddLineToPoint:
+        CFStringAppendFormat(string, 0, CFSTR("L%.2f,%.2f"), points[0].x, points[0].y);
+        break;
+    case kCGPathElementAddQuadCurveToPoint:
+        CFStringAppendFormat(string, 0, CFSTR("Q%.2f,%.2f,%.2f,%.2f"),
+                points[0].x, points[0].y, points[1].x, points[1].y);
+        break;
+    case kCGPathElementAddCurveToPoint:
+        CFStringAppendFormat(string, 0, CFSTR("C%.2f,%.2f,%.2f,%.2f,%.2f,%.2f"),
+                points[0].x, points[0].y, points[1].x, points[1].y,
+                points[2].x, points[2].y);
+        break;
+    case kCGPathElementCloseSubpath:
+        typeString = CFSTR("X"); break;
+    }
+}
+
+CFStringRef CFStringFromCGPath(CGPathRef path)
+{
+    if (!path)
+        return 0;
+
+    CFMutableStringRef string = CFStringCreateMutable(NULL, 0);
+    CGPathApply(path, string, CGPathToCFStringApplierFunction);
+
+    return string;
+}
+
+
+#pragma mark -
+#pragma mark Path Management
+
+String Path::debugString() const
+{
+    String result;
+    if (!isEmpty()) {
+        CFStringRef pathString = CFStringFromCGPath(m_path);
+        result = String(pathString);
+        CFRelease(pathString);
+    }
+    return result;
+}
+
 }
 
 #endif // PLATFORM(CG)
index 41ba37f..d0dccc5 100644 (file)
@@ -1,5 +1,6 @@
 /*
  * Copyright (C) 2006 Zack Rusin <zack@kde.org>
+ *               2006 Rob Buis   <buis@kde.org>
  *
  * All rights reserved.
  *
 #include "Path.h"
 
 #include "FloatRect.h"
+#include "PlatformString.h"
 #include <QPainterPath>
 #include <QMatrix>
+#include <QString>
 
 #include <math.h>
 
@@ -61,9 +64,15 @@ Path& Path::operator=(const Path& other)
     return *this;
 }
 
-bool Path::contains(const FloatPoint& point) const
+bool Path::contains(const FloatPoint& point, WindRule rule) const
 {
-    return m_path->contains(point);
+    Qt::FillRule savedRule = m_path->fillRule();
+    m_path->setFillRule(rule == RULE_EVENODD ? Qt::OddEvenFill : Qt::WindingFill);
+
+    bool contains = m_path->contains(point);
+
+    m_path->setFillRule(savedRule);
+    return contains;
 }
 
 void Path::translate(const FloatSize& size)
@@ -170,6 +179,46 @@ void Path::clear()
     *m_path = QPainterPath();
 }
 
+bool Path::isEmpty() const
+{
+    return m_path->isEmpty();
+}
+
+String Path::debugString() const
+{
+    QString ret;
+    for (int i = 0; i < m_path->elementCount(); ++i) {
+        const QPainterPath::Element &cur = m_path->elementAt(i);
+
+        switch (cur.type) {
+            case QPainterPath::MoveToElement:
+                ret += QString("M %1 %2").arg(cur.x).arg(cur.y);
+                break;
+            case QPainterPath::LineToElement:
+                ret += QString("L %1 %2").arg(cur.x).arg(cur.y);
+                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);
+
+                ret += QString("C %1 %2 %3 %4 %5 %6").arg(cur.x).arg(cur.y).arg(c1.x).arg(c1.y).arg(c2.x).arg(c2.y);
+
+                i += 2;
+                break;
+            }
+            case QPainterPath::CurveToDataElement:
+                Q_ASSERT(false);
+                break;
+        }
+    }
+
+    return ret;
+}
+
 }
 
 // vim: ts=4 sw=4 et