Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(479)

Unified Diff: Source/core/svg/SVGPathParser.cpp

Issue 1045343002: Split normalized reading from non-normalized in SVGPathParser (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 5 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « Source/core/svg/SVGPathParser.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/svg/SVGPathParser.cpp
diff --git a/Source/core/svg/SVGPathParser.cpp b/Source/core/svg/SVGPathParser.cpp
index e81624d18fed5b3a9bc16116551063f299b1b18e..60ac27d988b9bc08fc3cdea3e5729e3970a7c042 100644
--- a/Source/core/svg/SVGPathParser.cpp
+++ b/Source/core/svg/SVGPathParser.cpp
@@ -47,6 +47,24 @@ bool SVGPathParser::initialCommandIsMoveTo()
return command == PathSegMoveToAbs || command == PathSegMoveToRel;
}
+bool SVGPathParser::parsePath()
+{
+ while (m_source->hasMoreData()) {
+ PathSegmentData segment = m_source->parseSegment();
+ if (segment.command == PathSegUnknown)
+ return false;
+
+ m_consumer->emitSegment(segment);
+
+ if (!m_consumer->continueConsuming())
+ return true;
+
+ if (m_source->hasMoreData())
+ m_consumer->incrementPathSegmentCount();
+ }
+ return true;
+}
+
class NormalizingConsumer {
STACK_ALLOCATED();
public:
@@ -207,36 +225,6 @@ void NormalizingConsumer::emitSegment(PathSegmentData& segment)
m_lastCommand = originalCommand;
}
-bool SVGPathParser::parsePathDataFromSource(PathParsingMode pathParsingMode, bool checkForInitialMoveTo)
-{
- ASSERT(m_source);
- ASSERT(m_consumer);
-
- if (checkForInitialMoveTo && !initialCommandIsMoveTo())
- return false;
-
- NormalizingConsumer normalizer(m_consumer);
-
- while (m_source->hasMoreData()) {
- PathSegmentData segment = m_source->parseSegment();
- if (segment.command == PathSegUnknown)
- return false;
-
- if (pathParsingMode == NormalizedParsing) {
- normalizer.emitSegment(segment);
- } else {
- m_consumer->emitSegment(segment);
- }
-
- if (!m_consumer->continueConsuming())
- return true;
-
- if (m_source->hasMoreData())
- m_consumer->incrementPathSegmentCount();
- }
- return true;
-}
-
// This works by converting the SVG arc to "simple" beziers.
// Partly adapted from Niko's code in kdelibs/kdecore/svgicons.
// See also SVG implementation notes: http://www.w3.org/TR/SVG/implnote.html#ArcConversionEndpointToCenter
@@ -342,4 +330,24 @@ bool NormalizingConsumer::decomposeArcToCubic(const FloatPoint& currentPoint, co
return true;
}
+bool SVGPathParser::parseAndNormalizePath()
f(malita) 2015/04/01 03:59:21 These two are quite similar - would it be feasible
fs 2015/04/01 08:55:29 Yes, I hope to get to that point eventually. Haven
+{
+ NormalizingConsumer normalizer(m_consumer);
+
+ while (m_source->hasMoreData()) {
+ PathSegmentData segment = m_source->parseSegment();
+ if (segment.command == PathSegUnknown)
+ return false;
+
+ normalizer.emitSegment(segment);
+
+ if (!m_consumer->continueConsuming())
+ return true;
+
+ if (m_source->hasMoreData())
+ m_consumer->incrementPathSegmentCount();
+ }
+ return true;
+}
+
}
« no previous file with comments | « Source/core/svg/SVGPathParser.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698