Title: [87011] trunk/Source/WebCore
Revision
87011
Author
k...@webkit.org
Date
2011-05-20 23:44:01 -0700 (Fri, 20 May 2011)

Log Message

2011-05-20  Dirk Schulze  <k...@webkit.org>

        Reviewed by Nikolas Zimmermann.

        Share more code in PathTraversalState
        https://bugs.webkit.org/show_bug.cgi?id=61238

        Share more code between SVGPathTraversalStateBuilder and Path in PathTraversalState.

        No change in functionality, so no new tests.

        * platform/graphics/Path.cpp:
        (WebCore::pathLengthApplierFunction):
        * platform/graphics/PathTraversalState.cpp:
        (WebCore::PathTraversalState::processSegment):
        * platform/graphics/PathTraversalState.h:
        * svg/SVGPathTraversalStateBuilder.cpp:
        (WebCore::SVGPathTraversalStateBuilder::continueConsuming):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (87010 => 87011)


--- trunk/Source/WebCore/ChangeLog	2011-05-21 06:15:40 UTC (rev 87010)
+++ trunk/Source/WebCore/ChangeLog	2011-05-21 06:44:01 UTC (rev 87011)
@@ -1,3 +1,22 @@
+2011-05-20  Dirk Schulze  <k...@webkit.org>
+
+        Reviewed by Nikolas Zimmermann.
+
+        Share more code in PathTraversalState
+        https://bugs.webkit.org/show_bug.cgi?id=61238
+
+        Share more code between SVGPathTraversalStateBuilder and Path in PathTraversalState.
+
+        No change in functionality, so no new tests.
+
+        * platform/graphics/Path.cpp:
+        (WebCore::pathLengthApplierFunction):
+        * platform/graphics/PathTraversalState.cpp:
+        (WebCore::PathTraversalState::processSegment):
+        * platform/graphics/PathTraversalState.h:
+        * svg/SVGPathTraversalStateBuilder.cpp:
+        (WebCore::SVGPathTraversalStateBuilder::continueConsuming):
+
 2011-05-21  Nikolas Zimmermann  <nzimmerm...@rim.com>
 
         Reviewed by Rob Buis.

Modified: trunk/Source/WebCore/platform/graphics/Path.cpp (87010 => 87011)


--- trunk/Source/WebCore/platform/graphics/Path.cpp	2011-05-21 06:15:40 UTC (rev 87010)
+++ trunk/Source/WebCore/platform/graphics/Path.cpp	2011-05-21 06:44:01 UTC (rev 87011)
@@ -46,7 +46,6 @@
     PathTraversalState& traversalState = *static_cast<PathTraversalState*>(info);
     if (traversalState.m_success)
         return;
-    traversalState.m_previous = traversalState.m_current;
     FloatPoint* points = element->points;
     float segmentLength = 0;
     switch (element->type) {
@@ -67,20 +66,7 @@
             break;
     }
     traversalState.m_totalLength += segmentLength; 
-    if ((traversalState.m_action == PathTraversalState::TraversalPointAtLength || 
-         traversalState.m_action == PathTraversalState::TraversalNormalAngleAtLength) &&
-        (traversalState.m_totalLength >= traversalState.m_desiredLength)) {
-        FloatSize change = traversalState.m_current - traversalState.m_previous;
-        float slope = atan2f(change.height(), change.width());
-
-        if (traversalState.m_action == PathTraversalState::TraversalPointAtLength) {
-            float offset = traversalState.m_desiredLength - traversalState.m_totalLength;
-            traversalState.m_current.move(offset * cosf(slope), offset * sinf(slope));
-        } else
-            traversalState.m_normalAngle = rad2deg(slope);
-
-        traversalState.m_success = true;
-    }
+    traversalState.processSegment();
 }
 
 float Path::length() const

Modified: trunk/Source/WebCore/platform/graphics/PathTraversalState.cpp (87010 => 87011)


--- trunk/Source/WebCore/platform/graphics/PathTraversalState.cpp	2011-05-21 06:15:40 UTC (rev 87010)
+++ trunk/Source/WebCore/platform/graphics/PathTraversalState.cpp	2011-05-21 06:44:01 UTC (rev 87011)
@@ -203,5 +203,23 @@
     return distance;
 }
 
+void PathTraversalState::processSegment()
+{
+    if (m_action == TraversalSegmentAtLength && m_totalLength >= m_desiredLength)
+        m_success = true;
+        
+    if ((m_action == TraversalPointAtLength || m_action == TraversalNormalAngleAtLength) && m_totalLength >= m_desiredLength) {
+        FloatSize change = m_current - m_previous;
+        float slope = atan2f(change.height(), change.width());
+        if (m_action == TraversalPointAtLength) {
+            float offset = m_desiredLength - m_totalLength;
+            m_current.move(offset * cosf(slope), offset * sinf(slope));
+        } else
+            m_normalAngle = rad2deg(slope);
+        m_success = true;
+    }
+    m_previous = m_current;
 }
 
+}
+

Modified: trunk/Source/WebCore/platform/graphics/PathTraversalState.h (87010 => 87011)


--- trunk/Source/WebCore/platform/graphics/PathTraversalState.h	2011-05-21 06:15:40 UTC (rev 87010)
+++ trunk/Source/WebCore/platform/graphics/PathTraversalState.h	2011-05-21 06:44:01 UTC (rev 87011)
@@ -46,6 +46,8 @@
     float lineTo(const FloatPoint&);
     float quadraticBezierTo(const FloatPoint& newControl, const FloatPoint& newEnd);
     float cubicBezierTo(const FloatPoint& newControl1, const FloatPoint& newControl2, const FloatPoint& newEnd);
+    
+    void processSegment();
 
 public:
     PathTraversalAction m_action;

Modified: trunk/Source/WebCore/svg/SVGPathTraversalStateBuilder.cpp (87010 => 87011)


--- trunk/Source/WebCore/svg/SVGPathTraversalStateBuilder.cpp	2011-05-21 06:15:40 UTC (rev 87010)
+++ trunk/Source/WebCore/svg/SVGPathTraversalStateBuilder.cpp	2011-05-21 06:44:01 UTC (rev 87011)
@@ -66,24 +66,7 @@
 bool SVGPathTraversalStateBuilder::continueConsuming()
 {
     ASSERT(m_traversalState);    
-    if (m_traversalState->m_action == PathTraversalState::TraversalSegmentAtLength
-        && m_traversalState->m_totalLength >= m_traversalState->m_desiredLength)
-        m_traversalState->m_success = true;
-    
-    if ((m_traversalState->m_action == PathTraversalState::TraversalPointAtLength
-         || m_traversalState->m_action == PathTraversalState::TraversalNormalAngleAtLength)
-        && m_traversalState->m_totalLength >= m_traversalState->m_desiredLength) {
-        FloatSize change = m_traversalState->m_current - m_traversalState->m_previous;
-        float slope = atan2f(change.height(), change.width());
-        if (m_traversalState->m_action == PathTraversalState::TraversalPointAtLength) {
-            float offset = m_traversalState->m_desiredLength - m_traversalState->m_totalLength;
-            m_traversalState->m_current.move(offset * cosf(slope), offset * sinf(slope));
-        } else
-            m_traversalState->m_normalAngle = rad2deg(slope);
-        m_traversalState->m_success = true;
-    }
-    m_traversalState->m_previous = m_traversalState->m_current;
-
+    m_traversalState->processSegment();
     return !m_traversalState->m_success;
 }
 
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to