Chromium Code Reviews| Index: Source/core/svg/SVGLength.cpp |
| diff --git a/Source/core/svg/SVGLength.cpp b/Source/core/svg/SVGLength.cpp |
| index 958157f365f2db639f460f33a3855588c09378fe..1cd7668ad5acee9fdc4862d3312d53ea5ba5659a 100644 |
| --- a/Source/core/svg/SVGLength.cpp |
| +++ b/Source/core/svg/SVGLength.cpp |
| @@ -76,29 +76,37 @@ SVGLengthType stringToLengthType(const CharType*& ptr, const CharType* end) |
| const UChar firstChar = *ptr; |
| if (++ptr == end) |
| - return firstChar == '%' ? LengthTypePercentage : LengthTypeUnknown; |
| + return firstChar == '%' ? LengthTypePercentage : (isSVGSpace(firstChar) ? LengthTypeNumber : LengthTypeUnknown); |
|
pdr.
2014/06/02 14:35:19
This isn't needed: if the first character is a per
fs
2014/06/03 14:35:37
Nested ternary expressions FTW? =)
if (firstChar
|
| const UChar secondChar = *ptr; |
| - |
| - if (++ptr != end) |
| - return LengthTypeUnknown; |
| - |
| - if (firstChar == 'e' && secondChar == 'm') |
| - return LengthTypeEMS; |
| - if (firstChar == 'e' && secondChar == 'x') |
| - return LengthTypeEXS; |
| - if (firstChar == 'p' && secondChar == 'x') |
| - return LengthTypePX; |
| - if (firstChar == 'c' && secondChar == 'm') |
| - return LengthTypeCM; |
| - if (firstChar == 'm' && secondChar == 'm') |
| - return LengthTypeMM; |
| - if (firstChar == 'i' && secondChar == 'n') |
| - return LengthTypeIN; |
| - if (firstChar == 'p' && secondChar == 't') |
| - return LengthTypePT; |
| - if (firstChar == 'p' && secondChar == 'c') |
| - return LengthTypePC; |
| + ptr++; |
| + |
| + skipOptionalSVGSpaces(ptr, end); |
| + |
| + if (ptr == end) { |
| + if (firstChar == 'e' && secondChar == 'm') |
| + return LengthTypeEMS; |
| + if (firstChar == 'e' && secondChar == 'x') |
| + return LengthTypeEXS; |
| + if (firstChar == 'p' && secondChar == 'x') |
| + return LengthTypePX; |
| + if (firstChar == 'c' && secondChar == 'm') |
| + return LengthTypeCM; |
| + if (firstChar == 'm' && secondChar == 'm') |
| + return LengthTypeMM; |
| + if (firstChar == 'i' && secondChar == 'n') |
| + return LengthTypeIN; |
| + if (firstChar == 'p' && secondChar == 't') |
| + return LengthTypePT; |
| + if (firstChar == 'p' && secondChar == 'c') |
| + return LengthTypePC; |
| + if (isSVGSpace(secondChar)) { |
| + if (isSVGSpace(firstChar)) |
| + return LengthTypeNumber; |
|
pdr.
2014/06/02 14:35:19
Two spaces are a number?
fs
2014/06/03 14:35:37
More like "two spaces are not a unit".
"42 "
An
|
| + if (firstChar == '%') |
| + return LengthTypePercentage; |
| + } |
| + } |
| return LengthTypeUnknown; |
| } |
| @@ -189,7 +197,7 @@ static bool parseValueInternal(const String& string, float& convertedNumber, SVG |
| const CharType* ptr = string.getCharacters<CharType>(); |
| const CharType* end = ptr + string.length(); |
| - if (!parseNumber(ptr, end, convertedNumber, false)) |
| + if (!parseNumber(ptr, end, convertedNumber, ALLOW_LEADING)) |
| return false; |
| type = stringToLengthType(ptr, end); |