Chromium Code Reviews| 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 |