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

Unified Diff: Source/core/svg/SVGAngle.cpp

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 | « LayoutTests/svg/hixie/error/015.xml ('k') | Source/core/svg/SVGAnimationElement.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/svg/SVGAngle.cpp
diff --git a/Source/core/svg/SVGAngle.cpp b/Source/core/svg/SVGAngle.cpp
index 7e91ef5049b310d911a361c838d39a01af558d6f..7768b9385ceb1bfb713a3631cf552d7a9b04e172 100644
--- a/Source/core/svg/SVGAngle.cpp
+++ b/Source/core/svg/SVGAngle.cpp
@@ -152,35 +152,27 @@ static SVGAngle::SVGAngleType stringToAngleType(const CharType*& ptr, const Char
if (ptr == end)
return SVGAngle::SVG_ANGLETYPE_UNSPECIFIED;
- const CharType firstChar = *ptr;
-
- // If the unit contains only one character, the angle type is unknown.
- ++ptr;
- if (ptr == end)
- return SVGAngle::SVG_ANGLETYPE_UNKNOWN;
-
- const CharType secondChar = *ptr;
-
- // If the unit contains only two characters, the angle type is unknown.
- ++ptr;
- if (ptr == end)
- return SVGAngle::SVG_ANGLETYPE_UNKNOWN;
-
- const CharType thirdChar = *ptr;
- if (firstChar == 'd' && secondChar == 'e' && thirdChar == 'g')
- return SVGAngle::SVG_ANGLETYPE_DEG;
- if (firstChar == 'r' && secondChar == 'a' && thirdChar == 'd')
- return SVGAngle::SVG_ANGLETYPE_RAD;
-
- // If the unit contains three characters, but is not deg or rad, then it's unknown.
- ++ptr;
- if (ptr == end)
- return SVGAngle::SVG_ANGLETYPE_UNKNOWN;
-
- const CharType fourthChar = *ptr;
+ SVGAngle::SVGAngleType type = SVGAngle::SVG_ANGLETYPE_UNKNOWN;
+ const CharType firstChar = *ptr++;
+
+ if (isHTMLSpace<CharType>(firstChar)) {
+ type = SVGAngle::SVG_ANGLETYPE_UNSPECIFIED;
+ } else if (end - ptr >= 2) {
+ const CharType secondChar = *ptr++;
+ const CharType thirdChar = *ptr++;
+ if (firstChar == 'd' && secondChar == 'e' && thirdChar == 'g') {
+ type = SVGAngle::SVG_ANGLETYPE_DEG;
+ } else if (firstChar == 'r' && secondChar == 'a' && thirdChar == 'd') {
+ type = SVGAngle::SVG_ANGLETYPE_RAD;
+ } else if (ptr != end) {
+ const CharType fourthChar = *ptr++;
+ if (firstChar == 'g' && secondChar == 'r' && thirdChar == 'a' && fourthChar == 'd')
+ type = SVGAngle::SVG_ANGLETYPE_GRAD;
+ }
+ }
- if (firstChar == 'g' && secondChar == 'r' && thirdChar == 'a' && fourthChar == 'd')
- return SVGAngle::SVG_ANGLETYPE_GRAD;
+ if (!skipOptionalSVGSpaces(ptr, end))
+ return type;
return SVGAngle::SVG_ANGLETYPE_UNKNOWN;
}
@@ -215,7 +207,7 @@ static bool parseValue(const String& value, float& valueInSpecifiedUnits, SVGAng
const CharType* ptr = value.getCharacters<CharType>();
const CharType* end = ptr + value.length();
- if (!parseNumber(ptr, end, valueInSpecifiedUnits, false))
+ if (!parseNumber(ptr, end, valueInSpecifiedUnits, AllowLeadingWhitespace))
return false;
unitType = stringToAngleType(ptr, end);
« no previous file with comments | « LayoutTests/svg/hixie/error/015.xml ('k') | Source/core/svg/SVGAnimationElement.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698