Chromium Code Reviews

Unified Diff: Source/core/svg/SVGParserUtilities.h

Issue 319883002: Revert "[SVG2] Allow leading and trailing whitespace in svg attributes using" (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View side-by-side diff with in-line comments
« no previous file with comments | « Source/core/svg/SVGNumber.cpp ('k') | Source/core/svg/SVGParserUtilities.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/svg/SVGParserUtilities.h
diff --git a/Source/core/svg/SVGParserUtilities.h b/Source/core/svg/SVGParserUtilities.h
index 8702e79a40fef900d02f9a5b304bf44b27aec1e2..6e2e423b1c24853051d320577abd82dd32a039fc 100644
--- a/Source/core/svg/SVGParserUtilities.h
+++ b/Source/core/svg/SVGParserUtilities.h
@@ -22,7 +22,6 @@
#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"
@@ -36,19 +35,11 @@ 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, WhitespaceMode = AllowLeadingAndTrailingWhitespace);
-bool parseNumber(const UChar*& ptr, const UChar* end, float& number, WhitespaceMode = AllowLeadingAndTrailingWhitespace);
+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 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);
@@ -59,10 +50,18 @@ 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 && isHTMLSpace<CharType>(*ptr))
+ while (ptr < end && isSVGSpace(*ptr))
ptr++;
return ptr < end;
}
@@ -70,7 +69,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 && !isHTMLSpace<CharType>(*ptr) && *ptr != delimiter)
+ if (ptr < end && !isSVGSpace(*ptr) && *ptr != delimiter)
return false;
if (skipOptionalSVGSpaces(ptr, end)) {
if (ptr < end && *ptr == delimiter) {
« no previous file with comments | « Source/core/svg/SVGNumber.cpp ('k') | Source/core/svg/SVGParserUtilities.cpp » ('j') | no next file with comments »

Powered by Google App Engine