summaryrefslogtreecommitdiffstats
path: root/WebCore/svg/SVGPathSegList.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'WebCore/svg/SVGPathSegList.cpp')
-rw-r--r--WebCore/svg/SVGPathSegList.cpp12
1 files changed, 8 insertions, 4 deletions
diff --git a/WebCore/svg/SVGPathSegList.cpp b/WebCore/svg/SVGPathSegList.cpp
index 24bf455..d9d6310 100644
--- a/WebCore/svg/SVGPathSegList.cpp
+++ b/WebCore/svg/SVGPathSegList.cpp
@@ -26,6 +26,7 @@
#if ENABLE(SVG)
#include "SVGPathSegList.h"
+#include "FloatConversion.h"
#include "FloatPoint.h"
#include "Path.h"
#include "PathTraversalState.h"
@@ -51,12 +52,13 @@ SVGPathSegList::~SVGPathSegList()
{
}
-unsigned SVGPathSegList::getPathSegAtLength(double, ExceptionCode& ec)
+unsigned SVGPathSegList::getPathSegAtLength(double length, ExceptionCode& ec)
{
// FIXME : to be useful this will need to support non-normalized SVGPathSegLists
int len = numberOfItems();
// FIXME: Eventually this will likely move to a "path applier"-like model, until then PathTraversalState is less useful as we could just use locals
PathTraversalState traversalState(PathTraversalState::TraversalSegmentAtLength);
+ traversalState.m_desiredLength = narrowPrecisionToFloat(length);
for (int i = 0; i < len; ++i) {
SVGPathSeg* segment = getItem(i, ec).get();
if (ec)
@@ -92,13 +94,15 @@ unsigned SVGPathSegList::getPathSegAtLength(double, ExceptionCode& ec)
}
traversalState.m_totalLength += segmentLength;
if ((traversalState.m_action == PathTraversalState::TraversalSegmentAtLength)
- && (traversalState.m_totalLength > traversalState.m_desiredLength)) {
+ && (traversalState.m_totalLength >= traversalState.m_desiredLength)) {
return traversalState.m_segmentIndex;
}
traversalState.m_segmentIndex++;
}
-
- return 0; // The SVG spec is unclear as to what to return when the distance is not on the path
+
+ // The SVG spec is unclear as to what to return when the distance is not on the path.
+ // WebKit/Opera/FF all return the last path segment if the distance exceeds the actual path length:
+ return traversalState.m_segmentIndex ? traversalState.m_segmentIndex - 1 : 0;
}
Path SVGPathSegList::toPathData()