Index: Source/core/svg/SVGParserUtilities.h |
diff --git a/Source/core/svg/SVGParserUtilities.h b/Source/core/svg/SVGParserUtilities.h |
index 6e2e423b1c24853051d320577abd82dd32a039fc..8702e79a40fef900d02f9a5b304bf44b27aec1e2 100644 |
--- a/Source/core/svg/SVGParserUtilities.h |
+++ b/Source/core/svg/SVGParserUtilities.h |
@@ -22,6 +22,7 @@ |
#ifndef SVGParserUtilities_h |
#define SVGParserUtilities_h |
+#include "core/html/parser/HTMLParserIdioms.h" |
#include "core/svg/SVGTransform.h" |
#include "platform/text/ParserUtilities.h" |
#include "wtf/HashSet.h" |
@@ -35,11 +36,19 @@ class FloatPoint; |
class FloatRect; |
class SVGPointList; |
+enum WhitespaceMode { |
+ DisallowWhitespace = 0, |
+ AllowLeadingWhitespace = 0x1, |
+ AllowTrailingWhitespace = 0x2, |
+ AllowLeadingAndTrailingWhitespace = AllowLeadingWhitespace | AllowTrailingWhitespace |
+}; |
+ |
template <typename CharType> |
bool parseSVGNumber(CharType* ptr, size_t length, double& number); |
-bool parseNumber(const LChar*& ptr, const LChar* end, float& number, bool skip = true); |
-bool parseNumber(const UChar*& ptr, const UChar* end, float& number, bool skip = true); |
+bool parseNumber(const LChar*& ptr, const LChar* end, float& number, WhitespaceMode = AllowLeadingAndTrailingWhitespace); |
+bool parseNumber(const UChar*& ptr, const UChar* end, float& number, WhitespaceMode = AllowLeadingAndTrailingWhitespace); |
bool parseNumberOptionalNumber(const String& s, float& h, float& v); |
+bool parseNumberOrPercentage(const String& s, float& number); |
bool parseArcFlag(const LChar*& ptr, const LChar* end, bool& flag); |
bool parseArcFlag(const UChar*& ptr, const UChar* end, bool& flag); |
@@ -50,18 +59,10 @@ bool parseFloatPoint2(const CharType*& current, const CharType* end, FloatPoint& |
template <typename CharType> |
bool parseFloatPoint3(const CharType*& current, const CharType* end, FloatPoint&, FloatPoint&, FloatPoint&); |
-// SVG allows several different whitespace characters: |
-// http://www.w3.org/TR/SVG/paths.html#PathDataBNF |
-template <typename CharType> |
-inline bool isSVGSpace(CharType c) |
-{ |
- return c == ' ' || c == '\t' || c == '\n' || c == '\r'; |
-} |
- |
template <typename CharType> |
inline bool skipOptionalSVGSpaces(const CharType*& ptr, const CharType* end) |
{ |
- while (ptr < end && isSVGSpace(*ptr)) |
+ while (ptr < end && isHTMLSpace<CharType>(*ptr)) |
ptr++; |
return ptr < end; |
} |
@@ -69,7 +70,7 @@ inline bool skipOptionalSVGSpaces(const CharType*& ptr, const CharType* end) |
template <typename CharType> |
inline bool skipOptionalSVGSpacesOrDelimiter(const CharType*& ptr, const CharType* end, char delimiter = ',') |
{ |
- if (ptr < end && !isSVGSpace(*ptr) && *ptr != delimiter) |
+ if (ptr < end && !isHTMLSpace<CharType>(*ptr) && *ptr != delimiter) |
return false; |
if (skipOptionalSVGSpaces(ptr, end)) { |
if (ptr < end && *ptr == delimiter) { |