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

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

Issue 302643004: [SVG2] Allow leading and trailing whitespace in svg attributes (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@relax_todouble_wtf
Patch Set: split tests to combat slow xp trybots Created 6 years, 6 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
« 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 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) {
« 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
This is Rietveld 408576698