| Index: third_party/WebKit/Source/core/css/parser/CSSParserFastPaths.cpp
|
| diff --git a/third_party/WebKit/Source/core/css/parser/CSSParserFastPaths.cpp b/third_party/WebKit/Source/core/css/parser/CSSParserFastPaths.cpp
|
| index d821037ff926b3ec06cd3696381837e8777f3acb..2fc2a0c8185e4acd717d354e62ad42e334ca5684 100644
|
| --- a/third_party/WebKit/Source/core/css/parser/CSSParserFastPaths.cpp
|
| +++ b/third_party/WebKit/Source/core/css/parser/CSSParserFastPaths.cpp
|
| @@ -901,12 +901,12 @@
|
| return true;
|
| }
|
|
|
| -static const int kShortestValidTransformStringLength = 12;
|
| -
|
| template <typename CharType>
|
| static CSSFunctionValue* parseSimpleTransformValue(CharType*& pos, CharType* end)
|
| {
|
| - if (end - pos < kShortestValidTransformStringLength)
|
| + static const int shortestValidTransformStringLength = 12;
|
| +
|
| + if (end - pos < shortestValidTransformStringLength)
|
| return nullptr;
|
|
|
| const bool isTranslate = toASCIILower(pos[0]) == 't'
|
| @@ -987,56 +987,8 @@
|
| }
|
|
|
| template <typename CharType>
|
| -static bool transformCanLikelyUseFastPath(const CharType* chars, unsigned length)
|
| -{
|
| - // Very fast scan that attempts to reject most transforms that couldn't
|
| - // take the fast path. This avoids doing the malloc and string->double
|
| - // conversions in parseSimpleTransformValue only to discard them when we
|
| - // run into a transform component we don't understand.
|
| - unsigned i = 0;
|
| - while (i < length) {
|
| - if (isCSSSpace(chars[i])) {
|
| - ++i;
|
| - continue;
|
| - }
|
| - if (length - i < kShortestValidTransformStringLength)
|
| - return false;
|
| - switch (toASCIILower(chars[i])) {
|
| - case 't':
|
| - // translate, translateX, translateY, translateZ, translate3d.
|
| - if (toASCIILower(chars[i + 8]) != 'e')
|
| - return false;
|
| - i += 9;
|
| - break;
|
| - case 'm':
|
| - // matrix3d.
|
| - if (toASCIILower(chars[i + 7]) != 'd')
|
| - return false;
|
| - i += 8;
|
| - break;
|
| - case 's':
|
| - // scale3d.
|
| - if (toASCIILower(chars[i + 6]) != 'd')
|
| - return false;
|
| - i += 7;
|
| - break;
|
| - default:
|
| - // All other things, ex. rotate.
|
| - return false;
|
| - }
|
| - // Advance to the end of the arguments.
|
| - i = WTF::find(chars, length, ')', i) + 1;
|
| - }
|
| - return i == length;
|
| -}
|
| -
|
| -template <typename CharType>
|
| -static CSSValueList* parseSimpleTransformList(const CharType* chars, unsigned length)
|
| -{
|
| - if (!transformCanLikelyUseFastPath(chars, length))
|
| - return nullptr;
|
| - const CharType*& pos = chars;
|
| - const CharType* end = chars + length;
|
| +static CSSValueList* parseSimpleTransformList(CharType*& pos, CharType* end)
|
| +{
|
| CSSValueList* transformList = nullptr;
|
| while (pos < end) {
|
| while (pos < end && isCSSSpace(*pos))
|
| @@ -1059,9 +1011,14 @@
|
|
|
| if (propertyID != CSSPropertyTransform)
|
| return nullptr;
|
| - if (string.is8Bit())
|
| - return parseSimpleTransformList(string.characters8(), string.length());
|
| - return parseSimpleTransformList(string.characters16(), string.length());
|
| + if (string.is8Bit()) {
|
| + const LChar* pos = string.characters8();
|
| + const LChar* end = pos + string.length();
|
| + return parseSimpleTransformList(pos, end);
|
| + }
|
| + const UChar* pos = string.characters16();
|
| + const UChar* end = pos + string.length();
|
| + return parseSimpleTransformList(pos, end);
|
| }
|
|
|
| CSSValue* CSSParserFastPaths::maybeParseValue(CSSPropertyID propertyID, const String& string, CSSParserMode parserMode)
|
|
|