| Index: Source/core/svg/SVGLength.cpp
|
| diff --git a/Source/core/svg/SVGLength.cpp b/Source/core/svg/SVGLength.cpp
|
| index 0fe1202a1c2e4d68acaa361060d8a8b5352a8c0c..ba4e00306833d07a117847440b29f4394ab0d009 100644
|
| --- a/Source/core/svg/SVGLength.cpp
|
| +++ b/Source/core/svg/SVGLength.cpp
|
| @@ -73,32 +73,41 @@ SVGLengthType stringToLengthType(const CharType*& ptr, const CharType* end)
|
| if (ptr == end)
|
| return LengthTypeNumber;
|
|
|
| - const UChar firstChar = *ptr;
|
| -
|
| - if (++ptr == end)
|
| - return firstChar == '%' ? LengthTypePercentage : LengthTypeUnknown;
|
| -
|
| - 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;
|
| + SVGLengthType type = LengthTypeUnknown;
|
| + const CharType firstChar = *ptr++;
|
| +
|
| + if (firstChar == '%') {
|
| + type = LengthTypePercentage;
|
| + } else if (isHTMLSpace<CharType>(firstChar)) {
|
| + type = LengthTypeNumber;
|
| + } else if (ptr < end) {
|
| + const CharType secondChar = *ptr++;
|
| +
|
| + if (firstChar == 'p') {
|
| + if (secondChar == 'x')
|
| + type = LengthTypePX;
|
| + if (secondChar == 't')
|
| + type = LengthTypePT;
|
| + if (secondChar == 'c')
|
| + type = LengthTypePC;
|
| + } else if (firstChar == 'e') {
|
| + if (secondChar == 'm')
|
| + type = LengthTypeEMS;
|
| + if (secondChar == 'x')
|
| + type = LengthTypeEXS;
|
| + } else if (firstChar == 'c' && secondChar == 'm') {
|
| + type = LengthTypeCM;
|
| + } else if (firstChar == 'm' && secondChar == 'm') {
|
| + type = LengthTypeMM;
|
| + } else if (firstChar == 'i' && secondChar == 'n') {
|
| + type = LengthTypeIN;
|
| + } else if (isHTMLSpace<CharType>(firstChar) && isHTMLSpace<CharType>(secondChar)) {
|
| + type = LengthTypeNumber;
|
| + }
|
| + }
|
| +
|
| + if (!skipOptionalSVGSpaces(ptr, end))
|
| + return type;
|
|
|
| return LengthTypeUnknown;
|
| }
|
| @@ -189,7 +198,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, AllowLeadingWhitespace))
|
| return false;
|
|
|
| type = stringToLengthType(ptr, end);
|
|
|