Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "core/css/parser/CSSPropertyParserHelpers.h" | 5 #include "core/css/parser/CSSPropertyParserHelpers.h" |
| 6 | 6 |
| 7 #include "core/css/CSSCalculationValue.h" | 7 #include "core/css/CSSCalculationValue.h" |
| 8 #include "core/css/CSSColorValue.h" | 8 #include "core/css/CSSColorValue.h" |
| 9 #include "core/css/CSSCrossfadeValue.h" | 9 #include "core/css/CSSCrossfadeValue.h" |
| 10 #include "core/css/CSSGradientValue.h" | 10 #include "core/css/CSSGradientValue.h" |
| (...skipping 23 matching lines...) Expand all Loading... | |
| 34 RefPtr<CSSVariableData> unparsedCSSVariableData = | 34 RefPtr<CSSVariableData> unparsedCSSVariableData = |
| 35 CSSVariableData::create(tokenRange, false, false); | 35 CSSVariableData::create(tokenRange, false, false); |
| 36 if (unparsedCSSVariableData.get()) { | 36 if (unparsedCSSVariableData.get()) { |
| 37 variableData->push_back(std::move(unparsedCSSVariableData)); | 37 variableData->push_back(std::move(unparsedCSSVariableData)); |
| 38 return true; | 38 return true; |
| 39 } | 39 } |
| 40 } | 40 } |
| 41 return false; | 41 return false; |
| 42 } | 42 } |
| 43 | 43 |
| 44 // Consume input arguments, if encounter function, will return the function | |
| 45 // block as a Vector of CSSParserToken, otherwise, will just return a Vector of | |
| 46 // a single CSSParserToken. | |
| 47 Vector<CSSParserToken> consumeFunctionArgsOrNot(CSSParserTokenRange& args) { | |
| 48 Vector<CSSParserToken> argumentTokens; | |
| 49 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.
| |
| 50 argumentTokens.push_back(args.consumeIncludingWhitespace()); | |
| 51 } else { | |
| 52 // 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
| |
| 53 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!
| |
| 54 CSSParserTokenRange contents = args.consumeBlock(); | |
| 55 while (!contents.atEnd()) { | |
| 56 argumentTokens.push_back(contents.consume()); | |
| 57 } | |
| 58 argumentTokens.push_back( | |
| 59 CSSParserToken(RightParenthesisToken, CSSParserToken::BlockEnd)); | |
| 60 } | |
| 61 return argumentTokens; | |
| 62 } | |
| 63 | |
| 44 } // namespace | 64 } // namespace |
| 45 | 65 |
| 46 void complete4Sides(CSSValue* side[4]) { | 66 void complete4Sides(CSSValue* side[4]) { |
| 47 if (side[3]) | 67 if (side[3]) |
| 48 return; | 68 return; |
| 49 if (!side[2]) { | 69 if (!side[2]) { |
| 50 if (!side[1]) | 70 if (!side[1]) |
| 51 side[1] = side[0]; | 71 side[1] = side[0]; |
| 52 side[2] = side[0]; | 72 side[2] = side[0]; |
| 53 } | 73 } |
| (...skipping 1104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1158 | 1178 |
| 1159 if (!RuntimeEnabledFeatures::cssPaintAPIArgumentsEnabled()) { | 1179 if (!RuntimeEnabledFeatures::cssPaintAPIArgumentsEnabled()) { |
| 1160 // Arguments not enabled, but exists. Invalid. | 1180 // Arguments not enabled, but exists. Invalid. |
| 1161 return nullptr; | 1181 return nullptr; |
| 1162 } | 1182 } |
| 1163 | 1183 |
| 1164 // Begin parse paint arguments. | 1184 // Begin parse paint arguments. |
| 1165 if (!consumeCommaIncludingWhitespace(args)) | 1185 if (!consumeCommaIncludingWhitespace(args)) |
| 1166 return nullptr; | 1186 return nullptr; |
| 1167 | 1187 |
| 1168 // Consume arguments. Currently does not support complicated arguments | 1188 // Consume arguments. |
| 1169 // like function calls. | |
| 1170 // TODO(renjieliu): We may want to optimize the implementation by resolve | 1189 // TODO(renjieliu): We may want to optimize the implementation by resolve |
| 1171 // variables early if paint function is registered. | 1190 // variables early if paint function is registered. |
| 1172 Vector<CSSParserToken> argumentTokens; | 1191 Vector<CSSParserToken> argumentTokens; |
| 1173 Vector<RefPtr<CSSVariableData>> variableData; | 1192 Vector<RefPtr<CSSVariableData>> variableData; |
| 1174 while (!args.atEnd()) { | 1193 while (!args.atEnd()) { |
| 1175 if (args.peek().type() != CommaToken) { | 1194 if (args.peek().type() != CommaToken) { |
| 1176 argumentTokens.push_back(args.consumeIncludingWhitespace()); | 1195 argumentTokens.appendVector(consumeFunctionArgsOrNot(args)); |
| 1177 } else { | 1196 } else { |
| 1178 if (!addCSSPaintArgument(argumentTokens, &variableData)) | 1197 if (!addCSSPaintArgument(argumentTokens, &variableData)) |
| 1179 return nullptr; | 1198 return nullptr; |
| 1180 argumentTokens.clear(); | 1199 argumentTokens.clear(); |
| 1181 if (!consumeCommaIncludingWhitespace(args)) | 1200 if (!consumeCommaIncludingWhitespace(args)) |
| 1182 return nullptr; | 1201 return nullptr; |
| 1183 } | 1202 } |
| 1184 } | 1203 } |
| 1185 if (!addCSSPaintArgument(argumentTokens, &variableData)) | 1204 if (!addCSSPaintArgument(argumentTokens, &variableData)) |
| 1186 return nullptr; | 1205 return nullptr; |
| (...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1318 | 1337 |
| 1319 // https://drafts.csswg.org/css-shapes-1/#typedef-shape-box | 1338 // https://drafts.csswg.org/css-shapes-1/#typedef-shape-box |
| 1320 CSSIdentifierValue* consumeShapeBox(CSSParserTokenRange& range) { | 1339 CSSIdentifierValue* consumeShapeBox(CSSParserTokenRange& range) { |
| 1321 return consumeIdent<CSSValueContentBox, CSSValuePaddingBox, CSSValueBorderBox, | 1340 return consumeIdent<CSSValueContentBox, CSSValuePaddingBox, CSSValueBorderBox, |
| 1322 CSSValueMarginBox>(range); | 1341 CSSValueMarginBox>(range); |
| 1323 } | 1342 } |
| 1324 | 1343 |
| 1325 } // namespace CSSPropertyParserHelpers | 1344 } // namespace CSSPropertyParserHelpers |
| 1326 | 1345 |
| 1327 } // namespace blink | 1346 } // namespace blink |
| OLD | NEW |