aboutsummaryrefslogtreecommitdiffhomepage
path: root/experimental/svg/model/SkSVGAttributeParser.h
diff options
context:
space:
mode:
authorGravatar fmalita <fmalita@chromium.org>2016-08-03 10:21:11 -0700
committerGravatar Commit bot <commit-bot@chromium.org>2016-08-03 10:21:11 -0700
commitbffc2566872f99d378a1113d0a49ec9ee0d60b7a (patch)
tree3a7fab8b6206e99201b1ea817c95454f340260c8 /experimental/svg/model/SkSVGAttributeParser.h
parent9e3d3d8b363edcdd81a13b2be046152c6bb839cd (diff)
[SVGDom] Initial SVGLength support
Mostly plumb new length types, but also introduce a stateful parser, rect shape and named color support. R=reed@google.com,robertphillips@google.com,stephana@google.com GOLD_TRYBOT_URL= https://gold.skia.org/search?issue=2202053002 Review-Url: https://codereview.chromium.org/2202053002
Diffstat (limited to 'experimental/svg/model/SkSVGAttributeParser.h')
-rw-r--r--experimental/svg/model/SkSVGAttributeParser.h45
1 files changed, 45 insertions, 0 deletions
diff --git a/experimental/svg/model/SkSVGAttributeParser.h b/experimental/svg/model/SkSVGAttributeParser.h
new file mode 100644
index 0000000000..aef0286504
--- /dev/null
+++ b/experimental/svg/model/SkSVGAttributeParser.h
@@ -0,0 +1,45 @@
+/*
+ * Copyright 2016 Google Inc.
+ *
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+#ifndef SkSVGAttributeParser_DEFINED
+#define SkSVGAttributeParser_DEFINED
+
+#include "SkSVGTypes.h"
+
+class SkSVGAttributeParser : public SkNoncopyable {
+public:
+ SkSVGAttributeParser(const char[]);
+
+ bool parseColor(SkSVGColor*);
+ bool parseNumber(SkSVGNumber*);
+ bool parseLength(SkSVGLength*);
+
+private:
+ // Stack-only
+ void* operator new(size_t) = delete;
+ void* operator new(size_t, void*) = delete;
+
+ template <typename F>
+ bool advanceWhile(F func);
+
+ bool parseWSToken();
+ bool parseEOSToken();
+ bool parseSepToken();
+ bool parseExpectedStringToken(const char*);
+ bool parseScalarToken(SkScalar*);
+ bool parseHexToken(uint32_t*);
+ bool parseLengthUnitToken(SkSVGLength::Unit*);
+ bool parseNamedColorToken(SkColor*);
+ bool parseHexColorToken(SkColor*);
+
+ // The current position in the input string.
+ const char* fCurPos;
+
+ typedef SkNoncopyable INHERITED;
+};
+
+#endif // SkSVGAttributeParser_DEFINED