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

Unified Diff: third_party/WebKit/Source/core/svg/SVGPathParser.h

Issue 1646543004: Refactor away SVGPathSource (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 11 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
Index: third_party/WebKit/Source/core/svg/SVGPathParser.h
diff --git a/third_party/WebKit/Source/core/svg/SVGPathParser.h b/third_party/WebKit/Source/core/svg/SVGPathParser.h
index 927458639ab95c2818bcab6a2e88531e95b0c4b0..c0683cedee4c212c501d6462280d7d8d098acd34 100644
--- a/third_party/WebKit/Source/core/svg/SVGPathParser.h
+++ b/third_party/WebKit/Source/core/svg/SVGPathParser.h
@@ -31,35 +31,12 @@
namespace blink {
class SVGPathConsumer;
-class SVGPathSource;
-class CORE_EXPORT SVGPathParser final {
- WTF_MAKE_NONCOPYABLE(SVGPathParser);
- STACK_ALLOCATED();
+class CORE_EXPORT SVGPathParser {
f(malita) 2016/01/28 16:34:06 Nit: class -> namespace?
fs 2016/01/28 19:09:37 Sure, unless pdr minds.
+ STATIC_ONLY(SVGPathParser);
public:
- SVGPathParser(SVGPathSource* source, SVGPathConsumer* consumer)
- : m_source(source)
- , m_consumer(consumer)
- {
- ASSERT(m_source);
- ASSERT(m_consumer);
- }
-
- bool parsePathDataFromSource(bool checkForInitialMoveTo = true)
- {
- ASSERT(m_source);
- ASSERT(m_consumer);
- if (checkForInitialMoveTo && !initialCommandIsMoveTo())
- return false;
- return parsePath();
- }
-
-private:
- bool initialCommandIsMoveTo();
- bool parsePath();
-
- SVGPathSource* m_source;
- SVGPathConsumer* m_consumer;
+ template<typename SourceType, typename ConsumerType>
+ static bool parsePath(SourceType&, ConsumerType&);
};
class SVGPathNormalizer {
@@ -84,6 +61,19 @@ private:
SVGPathSegType m_lastCommand;
};
+template<typename SourceType, typename ConsumerType>
+bool SVGPathParser::parsePath(SourceType& source, ConsumerType& consumer)
+{
+ while (source.hasMoreData()) {
+ PathSegmentData segment = source.parseSegment();
+ if (segment.command == PathSegUnknown)
+ return false;
+
+ consumer.emitSegment(segment);
+ }
+ return true;
+}
+
} // namespace blink
#endif // SVGPathParser_h
« no previous file with comments | « third_party/WebKit/Source/core/svg/SVGPathByteStreamSource.cpp ('k') | third_party/WebKit/Source/core/svg/SVGPathParser.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698