Chromium Code Reviews| Index: third_party/WebKit/Source/core/css/parser/CSSPropertyParserHelpers.cpp |
| diff --git a/third_party/WebKit/Source/core/css/parser/CSSPropertyParserHelpers.cpp b/third_party/WebKit/Source/core/css/parser/CSSPropertyParserHelpers.cpp |
| index ed502005d576616f98a37ef741888b1540a603e0..7562bfc98f6b48a09134d25594df430cb66d97b0 100644 |
| --- a/third_party/WebKit/Source/core/css/parser/CSSPropertyParserHelpers.cpp |
| +++ b/third_party/WebKit/Source/core/css/parser/CSSPropertyParserHelpers.cpp |
| @@ -41,6 +41,26 @@ bool addCSSPaintArgument(const Vector<CSSParserToken>& tokens, |
| return false; |
| } |
| +// Consume input arguments, if encounter function, will return the function |
| +// block as a Vector of CSSParserToken, otherwise, will just return a Vector of |
| +// a single CSSParserToken. |
| +Vector<CSSParserToken> consumeFunctionArgsOrNot(CSSParserTokenRange& args) { |
| + Vector<CSSParserToken> argumentTokens; |
| + if (args.peek().getBlockType() != CSSParserToken::BlockStart) { |
|
meade_UTC10
2017/02/17 06:40:04
Let's flip the if statement order - It's usually c
renjieliu1
2017/02/19 04:57:58
Done.
|
| + argumentTokens.push_back(args.consumeIncludingWhitespace()); |
| + } else { |
| + // Encounter function block. |
|
meade_UTC10
2017/02/17 06:40:04
Incidentally, what does it mean to have got here,
renjieliu1
2017/02/19 04:57:58
I think if it is not a function but got here, in t
meade_UTC10
2017/02/22 06:56:22
Could you please add that as a comment? It still s
|
| + argumentTokens.push_back(args.peek()); |
|
meade_UTC10
2017/02/17 06:40:04
Perhaps, then, a comment to explain this?
if (arg
renjieliu1
2017/02/19 04:57:58
thank you for the suggestion!
|
| + CSSParserTokenRange contents = args.consumeBlock(); |
| + while (!contents.atEnd()) { |
| + argumentTokens.push_back(contents.consume()); |
| + } |
| + argumentTokens.push_back( |
| + CSSParserToken(RightParenthesisToken, CSSParserToken::BlockEnd)); |
| + } |
| + return argumentTokens; |
| +} |
| + |
| } // namespace |
| void complete4Sides(CSSValue* side[4]) { |
| @@ -1165,15 +1185,14 @@ static CSSValue* consumePaint(CSSParserTokenRange& args, |
| if (!consumeCommaIncludingWhitespace(args)) |
| return nullptr; |
| - // Consume arguments. Currently does not support complicated arguments |
| - // like function calls. |
| + // Consume arguments. |
| // TODO(renjieliu): We may want to optimize the implementation by resolve |
| // variables early if paint function is registered. |
| Vector<CSSParserToken> argumentTokens; |
| Vector<RefPtr<CSSVariableData>> variableData; |
| while (!args.atEnd()) { |
| if (args.peek().type() != CommaToken) { |
| - argumentTokens.push_back(args.consumeIncludingWhitespace()); |
| + argumentTokens.appendVector(consumeFunctionArgsOrNot(args)); |
| } else { |
| if (!addCSSPaintArgument(argumentTokens, &variableData)) |
| return nullptr; |