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 1148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1159 if (!RuntimeEnabledFeatures::cssPaintAPIArgumentsEnabled()) { | 1159 if (!RuntimeEnabledFeatures::cssPaintAPIArgumentsEnabled()) { |
1160 // Arguments not enabled, but exists. Invalid. | 1160 // Arguments not enabled, but exists. Invalid. |
1161 return nullptr; | 1161 return nullptr; |
1162 } | 1162 } |
1163 | 1163 |
1164 // Begin parse paint arguments. | 1164 // Begin parse paint arguments. |
1165 if (!consumeCommaIncludingWhitespace(args)) | 1165 if (!consumeCommaIncludingWhitespace(args)) |
1166 return nullptr; | 1166 return nullptr; |
1167 | 1167 |
1168 // Consume arguments. Currently does not support complicated arguments | 1168 // Consume arguments. Currently does not support complicated arguments |
1169 // like function calls. | 1169 // like function calls. |
meade_UTC10
2017/02/16 02:44:59
Sounds like this comment needs to be updated.
renjieliu1
2017/02/16 04:38:42
Done.
| |
1170 // TODO(renjieliu): We may want to optimize the implementation by resolve | 1170 // TODO(renjieliu): We may want to optimize the implementation by resolve |
1171 // variables early if paint function is registered. | 1171 // variables early if paint function is registered. |
1172 Vector<CSSParserToken> argumentTokens; | 1172 Vector<CSSParserToken> argumentTokens; |
1173 Vector<RefPtr<CSSVariableData>> variableData; | 1173 Vector<RefPtr<CSSVariableData>> variableData; |
1174 while (!args.atEnd()) { | 1174 while (!args.atEnd()) { |
1175 if (args.peek().type() != CommaToken) { | 1175 if (args.peek().type() != CommaToken) { |
1176 argumentTokens.push_back(args.consumeIncludingWhitespace()); | 1176 if (args.peek().getBlockType() != CSSParserToken::BlockStart) { |
meade_UTC10
2017/02/16 02:44:59
There's a lot of nested ifs in this while loop now
renjieliu1
2017/02/16 04:38:42
Done.
| |
1177 argumentTokens.push_back(args.consumeIncludingWhitespace()); | |
1178 } else { | |
1179 // Encounter function block. | |
1180 argumentTokens.push_back(args.peek()); | |
meade_UTC10
2017/02/16 02:44:59
So this pushes an open brace, then the contents of
renjieliu1
2017/02/16 04:38:42
I totally agree that's what we should do, however,
| |
1181 CSSParserTokenRange contents = args.consumeBlock(); | |
1182 while (!contents.atEnd()) { | |
1183 argumentTokens.push_back(contents.consume()); | |
1184 } | |
1185 // Assume it is a function. | |
meade_UTC10
2017/02/16 02:44:59
This comment is confusing, suggest removing it.
renjieliu1
2017/02/16 04:38:42
Done.
| |
1186 argumentTokens.push_back( | |
1187 CSSParserToken(RightParenthesisToken, CSSParserToken::BlockEnd)); | |
1188 } | |
1177 } else { | 1189 } else { |
1178 if (!addCSSPaintArgument(argumentTokens, &variableData)) | 1190 if (!addCSSPaintArgument(argumentTokens, &variableData)) |
1179 return nullptr; | 1191 return nullptr; |
1180 argumentTokens.clear(); | 1192 argumentTokens.clear(); |
1181 if (!consumeCommaIncludingWhitespace(args)) | 1193 if (!consumeCommaIncludingWhitespace(args)) |
1182 return nullptr; | 1194 return nullptr; |
1183 } | 1195 } |
1184 } | 1196 } |
1185 if (!addCSSPaintArgument(argumentTokens, &variableData)) | 1197 if (!addCSSPaintArgument(argumentTokens, &variableData)) |
1186 return nullptr; | 1198 return nullptr; |
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1318 | 1330 |
1319 // https://drafts.csswg.org/css-shapes-1/#typedef-shape-box | 1331 // https://drafts.csswg.org/css-shapes-1/#typedef-shape-box |
1320 CSSIdentifierValue* consumeShapeBox(CSSParserTokenRange& range) { | 1332 CSSIdentifierValue* consumeShapeBox(CSSParserTokenRange& range) { |
1321 return consumeIdent<CSSValueContentBox, CSSValuePaddingBox, CSSValueBorderBox, | 1333 return consumeIdent<CSSValueContentBox, CSSValuePaddingBox, CSSValueBorderBox, |
1322 CSSValueMarginBox>(range); | 1334 CSSValueMarginBox>(range); |
1323 } | 1335 } |
1324 | 1336 |
1325 } // namespace CSSPropertyParserHelpers | 1337 } // namespace CSSPropertyParserHelpers |
1326 | 1338 |
1327 } // namespace blink | 1339 } // namespace blink |
OLD | NEW |