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

Unified Diff: third_party/WebKit/Source/core/css/parser/CSSParserFastPaths.cpp

Issue 1904633002: Add a fast path to CSSParserFastPaths for CSS transform rotate. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 8 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 | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 768add52802b42578eee606f601bf66e7054eaa2..6c3b49aa0a032847d81d1f19d2955434d8cdb17a 100644
--- a/third_party/WebKit/Source/core/css/parser/CSSParserFastPaths.cpp
+++ b/third_party/WebKit/Source/core/css/parser/CSSParserFastPaths.cpp
@@ -900,6 +900,31 @@ static bool parseTransformNumberArguments(CharType*& pos, CharType* end, unsigne
}
template <typename CharType>
+static bool parseTransformRotateArguments(CharType*& pos, CharType* end, CSSFunctionValue* transformValue)
+{
+ static const int kDegLength = 3;
+
+ size_t delimiter = WTF::find(pos, end - pos, ')');
+ if (delimiter == kNotFound)
+ return false;
+ CharType* degreeStart = pos + delimiter - kDegLength;
+ bool isDegree = degreeStart > pos // require at least one digit.
+ && toASCIILower(degreeStart[0]) == 'd'
+ && toASCIILower(degreeStart[1]) == 'e'
+ && toASCIILower(degreeStart[2]) == 'g';
+ if (!isDegree)
+ return false;
+ unsigned argumentLength = static_cast<unsigned>(delimiter - kDegLength);
+ bool ok;
+ double number = charactersToDouble(pos, argumentLength, &ok);
+ if (!ok)
+ return false;
+ transformValue->append(cssValuePool().createValue(number, CSSPrimitiveValue::UnitType::Degrees));
+ pos += delimiter + 1;
+ return true;
+}
+
+template <typename CharType>
static CSSFunctionValue* parseSimpleTransformValue(CharType*& pos, CharType* end)
{
static const int shortestValidTransformStringLength = 12;
@@ -981,6 +1006,36 @@ static CSSFunctionValue* parseSimpleTransformValue(CharType*& pos, CharType* end
return transformValue;
}
+ const bool isRotate = toASCIILower(pos[0]) == 'r'
+ && toASCIILower(pos[1]) == 'o'
+ && toASCIILower(pos[2]) == 't'
+ && toASCIILower(pos[3]) == 'a'
+ && toASCIILower(pos[4]) == 't'
+ && toASCIILower(pos[5]) == 'e';
+
+ if (isRotate) {
+ CSSValueID transformType;
+ unsigned argumentStart = 8;
+ CharType c6 = toASCIILower(pos[6]);
+ if (c6 == 'x' && pos[7] == '(') {
+ transformType = CSSValueRotateX;
+ } else if (c6 == 'y' && pos[7] == '(') {
+ transformType = CSSValueRotateY;
+ } else if (c6 == 'z' && pos[7] == '(') {
+ transformType = CSSValueRotateZ;
+ } else if (c6 == '(') {
+ transformType = CSSValueRotate;
+ argumentStart = 7;
+ } else {
+ return nullptr;
+ }
+ pos += argumentStart;
+ CSSFunctionValue* transformValue = CSSFunctionValue::create(transformType);
+ if (!parseTransformRotateArguments(pos, end, transformValue))
+ return nullptr;
+ return transformValue;
+ }
+
return nullptr;
}
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698