PathApplierFunction should take a reference to a PathElement
authorsimon.fraser@apple.com <simon.fraser@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 28 Jul 2015 18:22:00 +0000 (18:22 +0000)
committersimon.fraser@apple.com <simon.fraser@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 28 Jul 2015 18:22:00 +0000 (18:22 +0000)
https://bugs.webkit.org/show_bug.cgi?id=147337

Reviewed by Dan Bates.

Convert PathApplierFunction to take a const PathElement&, since it can never be null.

Source/WebCore:

* accessibility/mac/WebAccessibilityObjectWrapperBase.mm:
(ConvertPathToScreenSpaceFunction):
* inspector/InspectorOverlay.cpp:
(WebCore::appendPathSegment):
* platform/graphics/Path.cpp:
(WebCore::pathLengthApplierFunction):
* platform/graphics/Path.h:
* platform/graphics/PathTraversalState.h:
(WebCore::PathTraversalState::processPathElement):
* platform/graphics/cg/PathCG.cpp:
(WebCore::CGPathApplierToPathApplier):
* rendering/svg/SVGMarkerData.h:
(WebCore::SVGMarkerData::updateFromPathElement):
(WebCore::SVGMarkerData::updateMarkerDataForPathElement):
* rendering/svg/SVGSubpathData.h:
(WebCore::SVGSubpathData::updateFromPathElement):
* svg/SVGPathUtilities.cpp:
(WebCore::pathIteratorForBuildingString):

Source/WebKit2:

* Shared/WebCoreArgumentCoders.cpp:
(IPC::pathPointCountApplierFunction):
(IPC::pathEncodeApplierFunction):

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

13 files changed:
Source/WebCore/ChangeLog
Source/WebCore/accessibility/mac/WebAccessibilityObjectWrapperBase.mm
Source/WebCore/inspector/InspectorOverlay.cpp
Source/WebCore/platform/graphics/Path.cpp
Source/WebCore/platform/graphics/Path.h
Source/WebCore/platform/graphics/PathTraversalState.h
Source/WebCore/platform/graphics/cairo/FontCairo.cpp
Source/WebCore/platform/graphics/cg/PathCG.cpp
Source/WebCore/rendering/svg/SVGMarkerData.h
Source/WebCore/rendering/svg/SVGSubpathData.h
Source/WebCore/svg/SVGPathUtilities.cpp
Source/WebKit2/ChangeLog
Source/WebKit2/Shared/WebCoreArgumentCoders.cpp

index ac29d9b..9032101 100644 (file)
@@ -1,3 +1,31 @@
+2015-07-27  Simon Fraser  <simon.fraser@apple.com>
+
+        PathApplierFunction should take a reference to a PathElement
+        https://bugs.webkit.org/show_bug.cgi?id=147337
+
+        Reviewed by Dan Bates.
+
+        Convert PathApplierFunction to take a const PathElement&, since it can never be null.
+
+        * accessibility/mac/WebAccessibilityObjectWrapperBase.mm:
+        (ConvertPathToScreenSpaceFunction):
+        * inspector/InspectorOverlay.cpp:
+        (WebCore::appendPathSegment):
+        * platform/graphics/Path.cpp:
+        (WebCore::pathLengthApplierFunction):
+        * platform/graphics/Path.h:
+        * platform/graphics/PathTraversalState.h:
+        (WebCore::PathTraversalState::processPathElement):
+        * platform/graphics/cg/PathCG.cpp:
+        (WebCore::CGPathApplierToPathApplier):
+        * rendering/svg/SVGMarkerData.h:
+        (WebCore::SVGMarkerData::updateFromPathElement):
+        (WebCore::SVGMarkerData::updateMarkerDataForPathElement):
+        * rendering/svg/SVGSubpathData.h:
+        (WebCore::SVGSubpathData::updateFromPathElement):
+        * svg/SVGPathUtilities.cpp:
+        (WebCore::pathIteratorForBuildingString):
+
 2015-07-28  Jer Noble  <jer.noble@apple.com>
 
         [iOS] Notify fullscreen controller in UIProcess whether external playback is allowed
index 93534c2..830833c 100644 (file)
@@ -247,36 +247,36 @@ struct PathConversionInfo {
     CGMutablePathRef path;
 };
 
-static void ConvertPathToScreenSpaceFunction(void* info, const PathElement* element)
+static void ConvertPathToScreenSpaceFunction(void* info, const PathElement& element)
 {
     PathConversionInfo* conversion = (PathConversionInfo*)info;
     WebAccessibilityObjectWrapperBase *wrapper = conversion->wrapper;
     CGMutablePathRef newPath = conversion->path;
-    switch (element->type) {
+    switch (element.type) {
     case PathElementMoveToPoint:
     {
-        CGPoint newPoint = [wrapper convertPointToScreenSpace:element->points[0]];
+        CGPoint newPoint = [wrapper convertPointToScreenSpace:element.points[0]];
         CGPathMoveToPoint(newPath, nil, newPoint.x, newPoint.y);
         break;
     }
     case PathElementAddLineToPoint:
     {
-        CGPoint newPoint = [wrapper convertPointToScreenSpace:element->points[0]];
+        CGPoint newPoint = [wrapper convertPointToScreenSpace:element.points[0]];
         CGPathAddLineToPoint(newPath, nil, newPoint.x, newPoint.y);
         break;
     }
     case PathElementAddQuadCurveToPoint:
     {
-        CGPoint newPoint1 = [wrapper convertPointToScreenSpace:element->points[0]];
-        CGPoint newPoint2 = [wrapper convertPointToScreenSpace:element->points[1]];
+        CGPoint newPoint1 = [wrapper convertPointToScreenSpace:element.points[0]];
+        CGPoint newPoint2 = [wrapper convertPointToScreenSpace:element.points[1]];
         CGPathAddQuadCurveToPoint(newPath, nil, newPoint1.x, newPoint1.y, newPoint2.x, newPoint2.y);
         break;
     }
     case PathElementAddCurveToPoint:
     {
-        CGPoint newPoint1 = [wrapper convertPointToScreenSpace:element->points[0]];
-        CGPoint newPoint2 = [wrapper convertPointToScreenSpace:element->points[1]];
-        CGPoint newPoint3 = [wrapper convertPointToScreenSpace:element->points[2]];
+        CGPoint newPoint1 = [wrapper convertPointToScreenSpace:element.points[0]];
+        CGPoint newPoint2 = [wrapper convertPointToScreenSpace:element.points[1]];
+        CGPoint newPoint3 = [wrapper convertPointToScreenSpace:element.points[2]];
         CGPathAddCurveToPoint(newPath, nil, newPoint1.x, newPoint1.y, newPoint2.x, newPoint2.y, newPoint3.x, newPoint3.y);
         break;
     }
index 767f343..e828b8d 100644 (file)
@@ -609,26 +609,26 @@ static void appendPathCommandAndPoints(PathApplyInfo& info, const String& comman
 }
 
 // Used as a functor for Shape::apply, which has not been cleaned up to use modern C++.
-static void appendPathSegment(void* info, const PathElement* pathElement)
+static void appendPathSegment(void* info, const PathElement& pathElement)
 {
     PathApplyInfo& pathApplyInfo = *static_cast<PathApplyInfo*>(info);
     FloatPoint point;
-    switch (pathElement->type) {
+    switch (pathElement.type) {
     // The points member will contain 1 value.
     case PathElementMoveToPoint:
-        appendPathCommandAndPoints(pathApplyInfo, ASCIILiteral("M"), pathElement->points, 1);
+        appendPathCommandAndPoints(pathApplyInfo, ASCIILiteral("M"), pathElement.points, 1);
         break;
     // The points member will contain 1 value.
     case PathElementAddLineToPoint:
-        appendPathCommandAndPoints(pathApplyInfo, ASCIILiteral("L"), pathElement->points, 1);
+        appendPathCommandAndPoints(pathApplyInfo, ASCIILiteral("L"), pathElement.points, 1);
         break;
     // The points member will contain 3 values.
     case PathElementAddCurveToPoint:
-        appendPathCommandAndPoints(pathApplyInfo, ASCIILiteral("C"), pathElement->points, 3);
+        appendPathCommandAndPoints(pathApplyInfo, ASCIILiteral("C"), pathElement.points, 3);
         break;
     // The points member will contain 2 values.
     case PathElementAddQuadCurveToPoint:
-        appendPathCommandAndPoints(pathApplyInfo, ASCIILiteral("Q"), pathElement->points, 2);
+        appendPathCommandAndPoints(pathApplyInfo, ASCIILiteral("Q"), pathElement.points, 2);
         break;
     // The points member will contain no values.
     case PathElementCloseSubpath:
index 1acf729..5022b52 100644 (file)
@@ -39,7 +39,7 @@
 
 namespace WebCore {
 
-static void pathLengthApplierFunction(void* info, const PathElement* element)
+static void pathLengthApplierFunction(void* info, const PathElement& element)
 {
     PathTraversalState& traversalState = *static_cast<PathTraversalState*>(info);
     traversalState.processPathElement(element);
index 08b6f50..17eba48 100644 (file)
@@ -80,7 +80,7 @@ namespace WebCore {
         FloatPoint* points;
     };
 
-    typedef void (*PathApplierFunction)(void* info, const PathElement*);
+    typedef void (*PathApplierFunction)(void* info, const PathElement&);
 
     class Path {
         WTF_MAKE_FAST_ALLOCATED;
index a4c3538..bd3c0f1 100644 (file)
@@ -44,7 +44,7 @@ public:
 
 public:
     bool processPathElement(PathElementType, const FloatPoint*);
-    bool processPathElement(const PathElement* element) { return processPathElement(element->type, element->points); }
+    bool processPathElement(const PathElement& element) { return processPathElement(element.type, element.points); }
 
     Action action() const { return m_action; }
     void setAction(Action action) { m_action = action; }
index 4263cb8..64537c7 100644 (file)
@@ -174,27 +174,27 @@ static void updateX(GlyphIterationState& state, float x)
 // pseudo-contour and the vertical center of the underline found in GlyphIterationState::centerOfLine.
 // It keeps track of the leftmost and rightmost intersection in  GlyphIterationState::minX and 
 // GlyphIterationState::maxX.
-static void findPathIntersections(void* stateAsVoidPointer, const PathElement* element)
+static void findPathIntersections(void* stateAsVoidPointer, const PathElement& element)
 {
     auto& state = *static_cast<GlyphIterationState*>(stateAsVoidPointer);
     bool doIntersection = false;
     FloatPoint point = FloatPoint();
-    switch (element->type) {
+    switch (element.type) {
     case PathElementMoveToPoint:
-        state.startingPoint = element->points[0];
-        state.currentPoint = element->points[0];
+        state.startingPoint = element.points[0];
+        state.currentPoint = element.points[0];
         break;
     case PathElementAddLineToPoint:
         doIntersection = true;
-        point = element->points[0];
+        point = element.points[0];
         break;
     case PathElementAddQuadCurveToPoint:
         doIntersection = true;
-        point = element->points[1];
+        point = element.points[1];
         break;
     case PathElementAddCurveToPoint:
         doIntersection = true;
-        point = element->points[2];
+        point = element.points[2];
         break;
     case PathElementCloseSubpath:
         doIntersection = true;
index 63fa076..3d9c31b 100644 (file)
@@ -380,7 +380,7 @@ struct PathApplierInfo {
     PathApplierFunction function;
 };
 
-static void CGPathApplierToPathApplier(void *info, const CGPathElement *element)
+static void CGPathApplierToPathApplier(void *info, const CGPathElementelement)
 {
     PathApplierInfo* pinfo = (PathApplierInfo*)info;
     FloatPoint points[3];
@@ -405,7 +405,7 @@ static void CGPathApplierToPathApplier(void *info, const CGPathElement *element)
     case kCGPathElementCloseSubpath:
         break;
     }
-    pinfo->function(pinfo->info, &pelement);
+    pinfo->function(pinfo->info, pelement);
 }
 
 void Path::apply(void* info, PathApplierFunction function) const
index d953ef3..1f1bb54 100644 (file)
@@ -54,12 +54,12 @@ public:
     {
     }
 
-    static void updateFromPathElement(void* info, const PathElement* element)
+    static void updateFromPathElement(void* info, const PathElement& element)
     {
         SVGMarkerData* markerData = static_cast<SVGMarkerData*>(info);
 
         // First update the outslope for the previous element.
-        markerData->updateOutslope(element->points[0]);
+        markerData->updateOutslope(element.points[0]);
 
         // Record the marker for the previous element.
         if (markerData->m_elementIndex > 0) {
@@ -109,11 +109,11 @@ private:
         m_outslopePoints[1] = point;
     }
 
-    void updateMarkerDataForPathElement(const PathElement* element)
+    void updateMarkerDataForPathElement(const PathElement& element)
     {
-        FloatPoint* points = element->points;
+        FloatPoint* points = element.points;
 
-        switch (element->type) {
+        switch (element.type) {
         case PathElementAddQuadCurveToPoint:
             // FIXME: https://bugs.webkit.org/show_bug.cgi?id=33115 (PathElementAddQuadCurveToPoint not handled for <marker>)
             m_origin = points[1];
index 9cea740..d7bc113 100644 (file)
@@ -36,35 +36,35 @@ public:
         m_movePoint.set(0, 0);
     }
 
-    static void updateFromPathElement(void* info, const PathElement* element)
+    static void updateFromPathElement(void* info, const PathElement& element)
     {
         SVGSubpathData* subpathFinder = static_cast<SVGSubpathData*>(info);
-        switch (element->type) {
+        switch (element.type) {
         case PathElementMoveToPoint:
             if (subpathFinder->m_pathIsZeroLength && !subpathFinder->m_haveSeenMoveOnly)
                 subpathFinder->m_zeroLengthSubpathLocations.append(subpathFinder->m_lastPoint);
-            subpathFinder->m_lastPoint = subpathFinder->m_movePoint = element->points[0];
+            subpathFinder->m_lastPoint = subpathFinder->m_movePoint = element.points[0];
             subpathFinder->m_haveSeenMoveOnly = true;
             subpathFinder->m_pathIsZeroLength = true;
             break;
         case PathElementAddLineToPoint:
-            if (subpathFinder->m_lastPoint != element->points[0]) {
+            if (subpathFinder->m_lastPoint != element.points[0]) {
                 subpathFinder->m_pathIsZeroLength = false;
-                subpathFinder->m_lastPoint = element->points[0];
+                subpathFinder->m_lastPoint = element.points[0];
             }
             subpathFinder->m_haveSeenMoveOnly = false;
             break;
         case PathElementAddQuadCurveToPoint:
-            if (subpathFinder->m_lastPoint != element->points[0] || element->points[0] != element->points[1]) {
+            if (subpathFinder->m_lastPoint != element.points[0] || element.points[0] != element.points[1]) {
                 subpathFinder->m_pathIsZeroLength = false;
-                subpathFinder->m_lastPoint = element->points[1];
+                subpathFinder->m_lastPoint = element.points[1];
             }
             subpathFinder->m_haveSeenMoveOnly = false;
             break;
         case PathElementAddCurveToPoint:
-            if (subpathFinder->m_lastPoint != element->points[0] || element->points[0] != element->points[1] || element->points[1] != element->points[2]) {
+            if (subpathFinder->m_lastPoint != element.points[0] || element.points[0] != element.points[1] || element.points[1] != element.points[2]) {
                 subpathFinder->m_pathIsZeroLength = false;
-                subpathFinder->m_lastPoint = element->points[2];
+                subpathFinder->m_lastPoint = element.points[2];
             }
             subpathFinder->m_haveSeenMoveOnly = false;
             break;
index c41fa13..8ba8b45 100644 (file)
@@ -331,22 +331,22 @@ bool getPointAtLengthOfSVGPathByteStream(SVGPathByteStream* stream, float length
     return ok;
 }
 
-static void pathIteratorForBuildingString(void* info, const PathElement* pathElement)
+static void pathIteratorForBuildingString(void* info, const PathElement& pathElement)
 {
     SVGPathConsumer* consumer = static_cast<SVGPathConsumer*>(info);
 
-    switch (pathElement->type) {
+    switch (pathElement.type) {
     case PathElementMoveToPoint:
-        consumer->moveTo(pathElement->points[0], false, AbsoluteCoordinates);
+        consumer->moveTo(pathElement.points[0], false, AbsoluteCoordinates);
         break;
     case PathElementAddLineToPoint:
-        consumer->lineTo(pathElement->points[0], AbsoluteCoordinates);
+        consumer->lineTo(pathElement.points[0], AbsoluteCoordinates);
         break;
     case PathElementAddQuadCurveToPoint:
-        consumer->curveToQuadratic(pathElement->points[0], pathElement->points[1], AbsoluteCoordinates);
+        consumer->curveToQuadratic(pathElement.points[0], pathElement.points[1], AbsoluteCoordinates);
         break;
     case PathElementAddCurveToPoint:
-        consumer->curveToCubic(pathElement->points[0], pathElement->points[1], pathElement->points[2], AbsoluteCoordinates);
+        consumer->curveToCubic(pathElement.points[0], pathElement.points[1], pathElement.points[2], AbsoluteCoordinates);
         break;
     case PathElementCloseSubpath:
         consumer->closePath();
index 0f264df..aad8076 100644 (file)
@@ -1,3 +1,16 @@
+2015-07-27  Simon Fraser  <simon.fraser@apple.com>
+
+        PathApplierFunction should take a reference to a PathElement
+        https://bugs.webkit.org/show_bug.cgi?id=147337
+
+        Reviewed by Dan Bates.
+
+        Convert PathApplierFunction to take a const PathElement&, since it can never be null.
+
+        * Shared/WebCoreArgumentCoders.cpp:
+        (IPC::pathPointCountApplierFunction):
+        (IPC::pathEncodeApplierFunction):
+
 2015-07-28  Jer Noble  <jer.noble@apple.com>
 
         [iOS] Notify fullscreen controller in UIProcess whether external playback is allowed
index 26acf4a..86141e5 100644 (file)
@@ -373,33 +373,33 @@ bool ArgumentCoder<IntSize>::decode(ArgumentDecoder& decoder, IntSize& intSize)
     return SimpleArgumentCoder<IntSize>::decode(decoder, intSize);
 }
 
-static void pathPointCountApplierFunction(void* info, const PathElement*)
+static void pathPointCountApplierFunction(void* info, const PathElement&)
 {
     uint64_t* pointCount = static_cast<uint64_t*>(info);
     ++*pointCount;
 }
 
-static void pathEncodeApplierFunction(void* info, const PathElement* element)
+static void pathEncodeApplierFunction(void* info, const PathElement& element)
 {
     ArgumentEncoder& encoder = *static_cast<ArgumentEncoder*>(info);
 
-    encoder.encodeEnum(element->type);
+    encoder.encodeEnum(element.type);
 
-    switch (element->type) {
+    switch (element.type) {
     case PathElementMoveToPoint: // The points member will contain 1 value.
-        encoder << element->points[0];
+        encoder << element.points[0];
         break;
     case PathElementAddLineToPoint: // The points member will contain 1 value.
-        encoder << element->points[0];
+        encoder << element.points[0];
         break;
     case PathElementAddQuadCurveToPoint: // The points member will contain 2 values.
-        encoder << element->points[0];
-        encoder << element->points[1];
+        encoder << element.points[0];
+        encoder << element.points[1];
         break;
     case PathElementAddCurveToPoint: // The points member will contain 3 values.
-        encoder << element->points[0];
-        encoder << element->points[1];
-        encoder << element->points[2];
+        encoder << element.points[0];
+        encoder << element.points[1];
+        encoder << element.points[2];
         break;
     case PathElementCloseSubpath: // The points member will contain no values.
         break;