OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2003 Lars Knoll (knoll@kde.org) | 2 * Copyright (C) 2003 Lars Knoll (knoll@kde.org) |
3 * Copyright (C) 2005 Allan Sandfeld Jensen (kde@carewolf.com) | 3 * Copyright (C) 2005 Allan Sandfeld Jensen (kde@carewolf.com) |
4 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012 Apple Inc.
All rights reserved. | 4 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012 Apple Inc.
All rights reserved. |
5 * Copyright (C) 2007 Nicholas Shanks <webkit@nickshanks.com> | 5 * Copyright (C) 2007 Nicholas Shanks <webkit@nickshanks.com> |
6 * Copyright (C) 2008 Eric Seidel <eric@webkit.org> | 6 * Copyright (C) 2008 Eric Seidel <eric@webkit.org> |
7 * Copyright (C) 2009 Torch Mobile Inc. All rights reserved. (http://www.torchmo
bile.com/) | 7 * Copyright (C) 2009 Torch Mobile Inc. All rights reserved. (http://www.torchmo
bile.com/) |
8 * Copyright (C) 2012 Adobe Systems Incorporated. All rights reserved. | 8 * Copyright (C) 2012 Adobe Systems Incorporated. All rights reserved. |
9 * Copyright (C) 2012 Intel Corporation. All rights reserved. | 9 * Copyright (C) 2012 Intel Corporation. All rights reserved. |
| 10 * Copyright (C) 2013 Opera Software ASA. All rights reserved. |
10 * | 11 * |
11 * This library is free software; you can redistribute it and/or | 12 * This library is free software; you can redistribute it and/or |
12 * modify it under the terms of the GNU Library General Public | 13 * modify it under the terms of the GNU Library General Public |
13 * License as published by the Free Software Foundation; either | 14 * License as published by the Free Software Foundation; either |
14 * version 2 of the License, or (at your option) any later version. | 15 * version 2 of the License, or (at your option) any later version. |
15 * | 16 * |
16 * This library is distributed in the hope that it will be useful, | 17 * This library is distributed in the hope that it will be useful, |
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of | 18 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
19 * Library General Public License for more details. | 20 * Library General Public License for more details. |
(...skipping 292 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
312 , m_length(0) | 313 , m_length(0) |
313 , m_token(0) | 314 , m_token(0) |
314 , m_lineNumber(0) | 315 , m_lineNumber(0) |
315 , m_tokenStartLineNumber(0) | 316 , m_tokenStartLineNumber(0) |
316 , m_lastSelectorLineNumber(0) | 317 , m_lastSelectorLineNumber(0) |
317 , m_allowImportRules(true) | 318 , m_allowImportRules(true) |
318 , m_allowNamespaceDeclarations(true) | 319 , m_allowNamespaceDeclarations(true) |
319 #if ENABLE(CSS_DEVICE_ADAPTATION) | 320 #if ENABLE(CSS_DEVICE_ADAPTATION) |
320 , m_inViewport(false) | 321 , m_inViewport(false) |
321 #endif | 322 #endif |
| 323 , m_reEmissionState(DontEmit) |
| 324 , m_storedBlockLevel(0) |
322 { | 325 { |
323 #if YYDEBUG > 0 | 326 #if YYDEBUG > 0 |
324 cssyydebug = 1; | 327 cssyydebug = 1; |
325 #endif | 328 #endif |
326 m_tokenStart.ptr8 = 0; | 329 m_tokenStart.ptr8 = 0; |
327 CSSPropertySourceData::init(); | 330 CSSPropertySourceData::init(); |
328 } | 331 } |
329 | 332 |
330 CSSParser::~CSSParser() | 333 CSSParser::~CSSParser() |
331 { | 334 { |
(...skipping 1098 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1430 return ok; | 1433 return ok; |
1431 } | 1434 } |
1432 | 1435 |
1433 PassOwnPtr<MediaQuery> CSSParser::parseMediaQuery(const String& string) | 1436 PassOwnPtr<MediaQuery> CSSParser::parseMediaQuery(const String& string) |
1434 { | 1437 { |
1435 if (string.isEmpty()) | 1438 if (string.isEmpty()) |
1436 return nullptr; | 1439 return nullptr; |
1437 | 1440 |
1438 ASSERT(!m_mediaQuery); | 1441 ASSERT(!m_mediaQuery); |
1439 | 1442 |
1440 // can't use { because tokenizer state switches from mediaquery to initial s
tate when it sees { token. | 1443 // Can't use { because tokenizer state switches from mediaquery to initial |
1441 // instead insert one " " (which is WHITESPACE in CSSGrammar.y) | 1444 // state when it sees { token. instead insert one " " (which is WHITESPACE |
1442 setupParser("@-webkit-mediaquery ", string, "} "); | 1445 // in CSSGrammar.y). Also, can't use } because of error handling. |
| 1446 setupParser("@-webkit-mediaquery ", string, ""); |
1443 cssyyparse(this); | 1447 cssyyparse(this); |
1444 | 1448 |
1445 return m_mediaQuery.release(); | 1449 return m_mediaQuery.release(); |
1446 } | 1450 } |
1447 | 1451 |
1448 static inline void filterProperties(bool important, const CSSParser::ParsedPrope
rtyVector& input, Vector<CSSProperty, 256>& output, size_t& unusedEntries, BitAr
ray<numCSSProperties>& seenProperties, HashSet<AtomicString>& seenVariables) | 1452 static inline void filterProperties(bool important, const CSSParser::ParsedPrope
rtyVector& input, Vector<CSSProperty, 256>& output, size_t& unusedEntries, BitAr
ray<numCSSProperties>& seenProperties, HashSet<AtomicString>& seenVariables) |
1449 { | 1453 { |
1450 // Add properties in reverse order so that highest priority definitions are
reached first. Duplicate definitions can then be ignored when found. | 1454 // Add properties in reverse order so that highest priority definitions are
reached first. Duplicate definitions can then be ignored when found. |
1451 for (int i = input.size() - 1; i >= 0; --i) { | 1455 for (int i = input.size() - 1; i >= 0; --i) { |
1452 const CSSProperty& property = input[i]; | 1456 const CSSProperty& property = input[i]; |
(...skipping 7782 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
9235 CharacterAsterisk, | 9239 CharacterAsterisk, |
9236 CharacterPlus, | 9240 CharacterPlus, |
9237 CharacterDot, | 9241 CharacterDot, |
9238 CharacterSlash, | 9242 CharacterSlash, |
9239 CharacterLess, | 9243 CharacterLess, |
9240 CharacterAt, | 9244 CharacterAt, |
9241 CharacterBackSlash, | 9245 CharacterBackSlash, |
9242 CharacterXor, | 9246 CharacterXor, |
9243 CharacterVerticalBar, | 9247 CharacterVerticalBar, |
9244 CharacterTilde, | 9248 CharacterTilde, |
| 9249 CharacterOpeningBracket, |
| 9250 CharacterClosingBracket |
9245 }; | 9251 }; |
9246 | 9252 |
9247 // 128 ASCII codes | 9253 // 128 ASCII codes |
9248 static const CharacterType typesOfASCIICharacters[128] = { | 9254 static const CharacterType typesOfASCIICharacters[128] = { |
9249 /* 0 - Null */ CharacterNull, | 9255 /* 0 - Null */ CharacterNull, |
9250 /* 1 - Start of Heading */ CharacterOther, | 9256 /* 1 - Start of Heading */ CharacterOther, |
9251 /* 2 - Start of Text */ CharacterOther, | 9257 /* 2 - Start of Text */ CharacterOther, |
9252 /* 3 - End of Text */ CharacterOther, | 9258 /* 3 - End of Text */ CharacterOther, |
9253 /* 4 - End of Transm. */ CharacterOther, | 9259 /* 4 - End of Transm. */ CharacterOther, |
9254 /* 5 - Enquiry */ CharacterOther, | 9260 /* 5 - Enquiry */ CharacterOther, |
(...skipping 24 matching lines...) Expand all Loading... |
9279 /* 30 - Record Separator */ CharacterOther, | 9285 /* 30 - Record Separator */ CharacterOther, |
9280 /* 31 - Unit Separator */ CharacterOther, | 9286 /* 31 - Unit Separator */ CharacterOther, |
9281 /* 32 - Space */ CharacterWhiteSpace, | 9287 /* 32 - Space */ CharacterWhiteSpace, |
9282 /* 33 - ! */ CharacterExclamationMark, | 9288 /* 33 - ! */ CharacterExclamationMark, |
9283 /* 34 - " */ CharacterQuote, | 9289 /* 34 - " */ CharacterQuote, |
9284 /* 35 - # */ CharacterHashmark, | 9290 /* 35 - # */ CharacterHashmark, |
9285 /* 36 - $ */ CharacterDollar, | 9291 /* 36 - $ */ CharacterDollar, |
9286 /* 37 - % */ CharacterOther, | 9292 /* 37 - % */ CharacterOther, |
9287 /* 38 - & */ CharacterOther, | 9293 /* 38 - & */ CharacterOther, |
9288 /* 39 - ' */ CharacterQuote, | 9294 /* 39 - ' */ CharacterQuote, |
9289 /* 40 - ( */ CharacterOther, | 9295 /* 40 - ( */ CharacterOpeningBracket, |
9290 /* 41 - ) */ CharacterEndNthChild, | 9296 /* 41 - ) */ CharacterEndNthChild, |
9291 /* 42 - * */ CharacterAsterisk, | 9297 /* 42 - * */ CharacterAsterisk, |
9292 /* 43 - + */ CharacterPlus, | 9298 /* 43 - + */ CharacterPlus, |
9293 /* 44 - , */ CharacterOther, | 9299 /* 44 - , */ CharacterOther, |
9294 /* 45 - - */ CharacterDash, | 9300 /* 45 - - */ CharacterDash, |
9295 /* 46 - . */ CharacterDot, | 9301 /* 46 - . */ CharacterDot, |
9296 /* 47 - / */ CharacterSlash, | 9302 /* 47 - / */ CharacterSlash, |
9297 /* 48 - 0 */ CharacterNumber, | 9303 /* 48 - 0 */ CharacterNumber, |
9298 /* 49 - 1 */ CharacterNumber, | 9304 /* 49 - 1 */ CharacterNumber, |
9299 /* 50 - 2 */ CharacterNumber, | 9305 /* 50 - 2 */ CharacterNumber, |
(...skipping 30 matching lines...) Expand all Loading... |
9330 /* 81 - Q */ CharacterIdentifierStart, | 9336 /* 81 - Q */ CharacterIdentifierStart, |
9331 /* 82 - R */ CharacterIdentifierStart, | 9337 /* 82 - R */ CharacterIdentifierStart, |
9332 /* 83 - S */ CharacterIdentifierStart, | 9338 /* 83 - S */ CharacterIdentifierStart, |
9333 /* 84 - T */ CharacterIdentifierStart, | 9339 /* 84 - T */ CharacterIdentifierStart, |
9334 /* 85 - U */ CharacterCaselessU, | 9340 /* 85 - U */ CharacterCaselessU, |
9335 /* 86 - V */ CharacterIdentifierStart, | 9341 /* 86 - V */ CharacterIdentifierStart, |
9336 /* 87 - W */ CharacterIdentifierStart, | 9342 /* 87 - W */ CharacterIdentifierStart, |
9337 /* 88 - X */ CharacterIdentifierStart, | 9343 /* 88 - X */ CharacterIdentifierStart, |
9338 /* 89 - Y */ CharacterIdentifierStart, | 9344 /* 89 - Y */ CharacterIdentifierStart, |
9339 /* 90 - Z */ CharacterIdentifierStart, | 9345 /* 90 - Z */ CharacterIdentifierStart, |
9340 /* 91 - [ */ CharacterOther, | 9346 /* 91 - [ */ CharacterOpeningBracket, |
9341 /* 92 - \ */ CharacterBackSlash, | 9347 /* 92 - \ */ CharacterBackSlash, |
9342 /* 93 - ] */ CharacterOther, | 9348 /* 93 - ] */ CharacterClosingBracket, |
9343 /* 94 - ^ */ CharacterXor, | 9349 /* 94 - ^ */ CharacterXor, |
9344 /* 95 - _ */ CharacterIdentifierStart, | 9350 /* 95 - _ */ CharacterIdentifierStart, |
9345 /* 96 - ` */ CharacterOther, | 9351 /* 96 - ` */ CharacterOther, |
9346 /* 97 - a */ CharacterIdentifierStart, | 9352 /* 97 - a */ CharacterIdentifierStart, |
9347 /* 98 - b */ CharacterIdentifierStart, | 9353 /* 98 - b */ CharacterIdentifierStart, |
9348 /* 99 - c */ CharacterIdentifierStart, | 9354 /* 99 - c */ CharacterIdentifierStart, |
9349 /* 100 - d */ CharacterIdentifierStart, | 9355 /* 100 - d */ CharacterIdentifierStart, |
9350 /* 101 - e */ CharacterIdentifierStart, | 9356 /* 101 - e */ CharacterIdentifierStart, |
9351 /* 102 - f */ CharacterIdentifierStart, | 9357 /* 102 - f */ CharacterIdentifierStart, |
9352 /* 103 - g */ CharacterIdentifierStart, | 9358 /* 103 - g */ CharacterIdentifierStart, |
(...skipping 11 matching lines...) Expand all Loading... |
9364 /* 115 - s */ CharacterIdentifierStart, | 9370 /* 115 - s */ CharacterIdentifierStart, |
9365 /* 116 - t */ CharacterIdentifierStart, | 9371 /* 116 - t */ CharacterIdentifierStart, |
9366 /* 117 - u */ CharacterCaselessU, | 9372 /* 117 - u */ CharacterCaselessU, |
9367 /* 118 - v */ CharacterIdentifierStart, | 9373 /* 118 - v */ CharacterIdentifierStart, |
9368 /* 119 - w */ CharacterIdentifierStart, | 9374 /* 119 - w */ CharacterIdentifierStart, |
9369 /* 120 - x */ CharacterIdentifierStart, | 9375 /* 120 - x */ CharacterIdentifierStart, |
9370 /* 121 - y */ CharacterIdentifierStart, | 9376 /* 121 - y */ CharacterIdentifierStart, |
9371 /* 122 - z */ CharacterIdentifierStart, | 9377 /* 122 - z */ CharacterIdentifierStart, |
9372 /* 123 - { */ CharacterEndMediaQuery, | 9378 /* 123 - { */ CharacterEndMediaQuery, |
9373 /* 124 - | */ CharacterVerticalBar, | 9379 /* 124 - | */ CharacterVerticalBar, |
9374 /* 125 - } */ CharacterOther, | 9380 /* 125 - } */ CharacterClosingBracket, |
9375 /* 126 - ~ */ CharacterTilde, | 9381 /* 126 - ~ */ CharacterTilde, |
9376 /* 127 - Delete */ CharacterOther, | 9382 /* 127 - Delete */ CharacterOther, |
9377 }; | 9383 }; |
9378 | 9384 |
9379 // Utility functions for the CSS tokenizer. | 9385 // Utility functions for the CSS tokenizer. |
9380 | 9386 |
9381 template <typename CharacterType> | 9387 template <typename CharacterType> |
9382 static inline bool isCSSLetter(CharacterType character) | 9388 static inline bool isCSSLetter(CharacterType character) |
9383 { | 9389 { |
9384 return character >= 128 || typesOfASCIICharacters[character] <= CharacterDas
h; | 9390 return character >= 128 || typesOfASCIICharacters[character] <= CharacterDas
h; |
(...skipping 939 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
10324 if (isASCIIAlphaCaselessEqual(name[0], 'a') && isASCIIAlphaCaselessEqual
(name[1], 'n') && isASCIIAlphaCaselessEqual(name[2], 'd')) | 10330 if (isASCIIAlphaCaselessEqual(name[0], 'a') && isASCIIAlphaCaselessEqual
(name[1], 'n') && isASCIIAlphaCaselessEqual(name[2], 'd')) |
10325 m_token = SUPPORTS_AND; | 10331 m_token = SUPPORTS_AND; |
10326 else if (isASCIIAlphaCaselessEqual(name[0], 'n') && isASCIIAlphaCaseless
Equal(name[1], 'o') && isASCIIAlphaCaselessEqual(name[2], 't')) | 10332 else if (isASCIIAlphaCaselessEqual(name[0], 'n') && isASCIIAlphaCaseless
Equal(name[1], 'o') && isASCIIAlphaCaselessEqual(name[2], 't')) |
10327 m_token = SUPPORTS_NOT; | 10333 m_token = SUPPORTS_NOT; |
10328 } | 10334 } |
10329 } | 10335 } |
10330 | 10336 |
10331 template <typename SrcCharacterType> | 10337 template <typename SrcCharacterType> |
10332 int CSSParser::realLex(void* yylvalWithoutType) | 10338 int CSSParser::realLex(void* yylvalWithoutType) |
10333 { | 10339 { |
| 10340 if (m_reEmissionState == ReEmit) { |
| 10341 m_reEmissionState = DidReEmit; |
| 10342 return token(); |
| 10343 } |
| 10344 |
| 10345 if (m_reEmissionState == DidReEmit) |
| 10346 m_reEmissionState = DontEmit; |
| 10347 |
10334 YYSTYPE* yylval = static_cast<YYSTYPE*>(yylvalWithoutType); | 10348 YYSTYPE* yylval = static_cast<YYSTYPE*>(yylvalWithoutType); |
10335 // Write pointer for the next character. | 10349 // Write pointer for the next character. |
10336 SrcCharacterType* result; | 10350 SrcCharacterType* result; |
10337 CSSParserString resultString; | 10351 CSSParserString resultString; |
10338 bool hasEscape; | 10352 bool hasEscape; |
10339 | 10353 |
10340 // The input buffer is terminated by a \0 character, so | 10354 // The input buffer is terminated by a \0 character, so |
10341 // it is safe to read one character ahead of a known non-null. | 10355 // it is safe to read one character ahead of a known non-null. |
10342 #ifndef NDEBUG | 10356 #ifndef NDEBUG |
10343 // In debug we check with an ASSERT that the length is > 0 for string types. | 10357 // In debug we check with an ASSERT that the length is > 0 for string types. |
(...skipping 23 matching lines...) Expand all Loading... |
10367 m_token = IDENT; | 10381 m_token = IDENT; |
10368 | 10382 |
10369 if (UNLIKELY(*currentCharacter<SrcCharacterType>() == '(')) { | 10383 if (UNLIKELY(*currentCharacter<SrcCharacterType>() == '(')) { |
10370 if (m_parsingMode == SupportsMode && !hasEscape) { | 10384 if (m_parsingMode == SupportsMode && !hasEscape) { |
10371 detectSupportsToken<SrcCharacterType>(result - tokenStart<SrcCha
racterType>()); | 10385 detectSupportsToken<SrcCharacterType>(result - tokenStart<SrcCha
racterType>()); |
10372 if (m_token != IDENT) | 10386 if (m_token != IDENT) |
10373 break; | 10387 break; |
10374 } | 10388 } |
10375 | 10389 |
10376 m_token = FUNCTION; | 10390 m_token = FUNCTION; |
10377 bool shouldSkipParenthesis = true; | |
10378 if (!hasEscape) { | |
10379 bool detected = detectFunctionTypeToken<SrcCharacterType>(result
- tokenStart<SrcCharacterType>()); | |
10380 if (!detected && m_parsingMode == MediaQueryMode) { | |
10381 // ... and(max-width: 480px) ... looks like a function, but
in fact it is not, | |
10382 // so run more detection code in the MediaQueryMode. | |
10383 detectMediaQueryToken<SrcCharacterType>(result - tokenStart<
SrcCharacterType>()); | |
10384 shouldSkipParenthesis = false; | |
10385 } | |
10386 } | |
10387 | 10391 |
10388 if (LIKELY(shouldSkipParenthesis)) { | 10392 if (!hasEscape) |
10389 ++currentCharacter<SrcCharacterType>(); | 10393 detectFunctionTypeToken<SrcCharacterType>(result - tokenStart<Sr
cCharacterType>()); |
10390 ++result; | 10394 ++currentCharacter<SrcCharacterType>(); |
10391 ++yylval->string.m_length; | 10395 ++result; |
10392 } | 10396 ++yylval->string.m_length; |
10393 | 10397 |
10394 if (token() == URI) { | 10398 if (token() == URI) { |
10395 m_token = FUNCTION; | 10399 m_token = FUNCTION; |
10396 // Check whether it is really an URI. | 10400 // Check whether it is really an URI. |
10397 if (yylval->string.is8Bit()) | 10401 if (yylval->string.is8Bit()) |
10398 parseURI<LChar>(yylval->string); | 10402 parseURI<LChar>(yylval->string); |
10399 else | 10403 else |
10400 parseURI<UChar>(yylval->string); | 10404 parseURI<UChar>(yylval->string); |
10401 } | 10405 } |
| 10406 |
| 10407 // URI consumes the ')'. For other function tokens, push the |
| 10408 // opening parenthesis to match the closing one when it comes. |
| 10409 if (token() != URI) |
| 10410 m_brackets.push('('); |
| 10411 |
10402 } else if (UNLIKELY(m_parsingMode != NormalMode) && !hasEscape) { | 10412 } else if (UNLIKELY(m_parsingMode != NormalMode) && !hasEscape) { |
10403 if (m_parsingMode == MediaQueryMode) | 10413 if (m_parsingMode == MediaQueryMode) |
10404 detectMediaQueryToken<SrcCharacterType>(result - tokenStart<SrcC
haracterType>()); | 10414 detectMediaQueryToken<SrcCharacterType>(result - tokenStart<SrcC
haracterType>()); |
10405 else if (m_parsingMode == SupportsMode) | 10415 else if (m_parsingMode == SupportsMode) |
10406 detectSupportsToken<SrcCharacterType>(result - tokenStart<SrcCha
racterType>()); | 10416 detectSupportsToken<SrcCharacterType>(result - tokenStart<SrcCha
racterType>()); |
10407 else if (m_parsingMode == NthChildMode && isASCIIAlphaCaselessEqual(
tokenStart<SrcCharacterType>()[0], 'n')) { | 10417 else if (m_parsingMode == NthChildMode && isASCIIAlphaCaselessEqual(
tokenStart<SrcCharacterType>()[0], 'n')) { |
10408 if (result - tokenStart<SrcCharacterType>() == 1) { | 10418 if (result - tokenStart<SrcCharacterType>() == 1) { |
10409 // String "n" is IDENT but "n+1" is NTH. | 10419 // String "n" is IDENT but "n+1" is NTH. |
10410 if (parseNthChildExtra<SrcCharacterType>()) { | 10420 if (parseNthChildExtra<SrcCharacterType>()) { |
10411 m_token = NTH; | 10421 m_token = NTH; |
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
10509 case CharacterDash: | 10519 case CharacterDash: |
10510 if (isIdentifierStartAfterDash(currentCharacter<SrcCharacterType>())) { | 10520 if (isIdentifierStartAfterDash(currentCharacter<SrcCharacterType>())) { |
10511 --currentCharacter<SrcCharacterType>(); | 10521 --currentCharacter<SrcCharacterType>(); |
10512 parseIdentifier(result, resultString, hasEscape); | 10522 parseIdentifier(result, resultString, hasEscape); |
10513 m_token = IDENT; | 10523 m_token = IDENT; |
10514 | 10524 |
10515 if (cssVariablesEnabled() && isEqualToCSSIdentifier(tokenStart<SrcCh
aracterType>() + 1, "webkit-var") && tokenStart<SrcCharacterType>()[11] == '-' &
& isIdentifierStartAfterDash(tokenStart<SrcCharacterType>() + 12)) | 10525 if (cssVariablesEnabled() && isEqualToCSSIdentifier(tokenStart<SrcCh
aracterType>() + 1, "webkit-var") && tokenStart<SrcCharacterType>()[11] == '-' &
& isIdentifierStartAfterDash(tokenStart<SrcCharacterType>() + 12)) |
10516 m_token = VAR_DEFINITION; | 10526 m_token = VAR_DEFINITION; |
10517 else if (*currentCharacter<SrcCharacterType>() == '(') { | 10527 else if (*currentCharacter<SrcCharacterType>() == '(') { |
10518 m_token = FUNCTION; | 10528 m_token = FUNCTION; |
| 10529 m_brackets.push('('); |
10519 if (!hasEscape) | 10530 if (!hasEscape) |
10520 detectDashToken<SrcCharacterType>(result - tokenStart<SrcCha
racterType>()); | 10531 detectDashToken<SrcCharacterType>(result - tokenStart<SrcCha
racterType>()); |
10521 ++currentCharacter<SrcCharacterType>(); | 10532 ++currentCharacter<SrcCharacterType>(); |
10522 ++result; | 10533 ++result; |
10523 } else if (UNLIKELY(m_parsingMode == NthChildMode) && !hasEscape &&
isASCIIAlphaCaselessEqual(tokenStart<SrcCharacterType>()[1], 'n')) { | 10534 } else if (UNLIKELY(m_parsingMode == NthChildMode) && !hasEscape &&
isASCIIAlphaCaselessEqual(tokenStart<SrcCharacterType>()[1], 'n')) { |
10524 if (result - tokenStart<SrcCharacterType>() == 2) { | 10535 if (result - tokenStart<SrcCharacterType>() == 2) { |
10525 // String "-n" is IDENT but "-n+1" is NTH. | 10536 // String "-n" is IDENT but "-n+1" is NTH. |
10526 if (parseNthChildExtra<SrcCharacterType>()) { | 10537 if (parseNthChildExtra<SrcCharacterType>()) { |
10527 m_token = NTH; | 10538 m_token = NTH; |
10528 result = currentCharacter<SrcCharacterType>(); | 10539 result = currentCharacter<SrcCharacterType>(); |
(...skipping 25 matching lines...) Expand all Loading... |
10554 yylval->string.init(tokenStart<SrcCharacterType>(), currentChara
cter<SrcCharacterType>() - tokenStart<SrcCharacterType>()); | 10565 yylval->string.init(tokenStart<SrcCharacterType>(), currentChara
cter<SrcCharacterType>() - tokenStart<SrcCharacterType>()); |
10555 } | 10566 } |
10556 } | 10567 } |
10557 break; | 10568 break; |
10558 | 10569 |
10559 case CharacterOther: | 10570 case CharacterOther: |
10560 // m_token is simply the current character. | 10571 // m_token is simply the current character. |
10561 break; | 10572 break; |
10562 | 10573 |
10563 case CharacterNull: | 10574 case CharacterNull: |
| 10575 if (m_brackets.level() > 0) |
| 10576 m_token = m_brackets.pop(); |
10564 // Do not advance pointer at the end of input. | 10577 // Do not advance pointer at the end of input. |
10565 --currentCharacter<SrcCharacterType>(); | 10578 --currentCharacter<SrcCharacterType>(); |
10566 break; | 10579 break; |
10567 | 10580 |
10568 case CharacterWhiteSpace: | 10581 case CharacterWhiteSpace: |
10569 m_token = WHITESPACE; | 10582 m_token = WHITESPACE; |
10570 // Might start with a '\n'. | 10583 // Might start with a '\n'. |
10571 --currentCharacter<SrcCharacterType>(); | 10584 --currentCharacter<SrcCharacterType>(); |
10572 do { | 10585 do { |
10573 if (*currentCharacter<SrcCharacterType>() == '\n') | 10586 if (*currentCharacter<SrcCharacterType>() == '\n') |
10574 ++m_lineNumber; | 10587 ++m_lineNumber; |
10575 ++currentCharacter<SrcCharacterType>(); | 10588 ++currentCharacter<SrcCharacterType>(); |
10576 } while (*currentCharacter<SrcCharacterType>() <= ' ' && (typesOfASCIICh
aracters[*currentCharacter<SrcCharacterType>()] == CharacterWhiteSpace)); | 10589 } while (*currentCharacter<SrcCharacterType>() <= ' ' && (typesOfASCIICh
aracters[*currentCharacter<SrcCharacterType>()] == CharacterWhiteSpace)); |
10577 break; | 10590 break; |
10578 | 10591 |
10579 case CharacterEndMediaQuery: | 10592 case CharacterEndMediaQuery: |
10580 if (m_parsingMode == MediaQueryMode) | 10593 if (m_parsingMode == MediaQueryMode) |
10581 m_parsingMode = NormalMode; | 10594 m_parsingMode = NormalMode; |
| 10595 if (m_token == '{') |
| 10596 m_brackets.push('{'); |
10582 break; | 10597 break; |
10583 | 10598 |
10584 case CharacterEndNthChild: | 10599 case CharacterEndNthChild: |
10585 if (m_parsingMode == NthChildMode) | 10600 if (m_parsingMode == NthChildMode) |
10586 m_parsingMode = NormalMode; | 10601 m_parsingMode = NormalMode; |
| 10602 m_brackets.pop(')'); |
10587 break; | 10603 break; |
10588 | 10604 |
10589 case CharacterQuote: | 10605 case CharacterQuote: |
10590 if (checkAndSkipString(currentCharacter<SrcCharacterType>(), m_token)) { | 10606 if (checkAndSkipString(currentCharacter<SrcCharacterType>(), m_token)) { |
10591 ++result; | 10607 ++result; |
10592 parseString<SrcCharacterType>(result, yylval->string, m_token); | 10608 parseString<SrcCharacterType>(result, yylval->string, m_token); |
10593 m_token = STRING; | 10609 m_token = STRING; |
10594 } | 10610 } |
10595 break; | 10611 break; |
10596 | 10612 |
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
10724 } | 10740 } |
10725 break; | 10741 break; |
10726 | 10742 |
10727 case CharacterTilde: | 10743 case CharacterTilde: |
10728 if (*currentCharacter<SrcCharacterType>() == '=') { | 10744 if (*currentCharacter<SrcCharacterType>() == '=') { |
10729 ++currentCharacter<SrcCharacterType>(); | 10745 ++currentCharacter<SrcCharacterType>(); |
10730 m_token = INCLUDES; | 10746 m_token = INCLUDES; |
10731 } | 10747 } |
10732 break; | 10748 break; |
10733 | 10749 |
| 10750 case CharacterOpeningBracket: |
| 10751 m_brackets.push(m_token); |
| 10752 break; |
| 10753 |
| 10754 case CharacterClosingBracket: |
| 10755 m_brackets.pop(m_token); |
| 10756 break; |
| 10757 |
10734 default: | 10758 default: |
10735 ASSERT_NOT_REACHED(); | 10759 ASSERT_NOT_REACHED(); |
10736 break; | 10760 break; |
10737 } | 10761 } |
10738 | 10762 |
10739 return token(); | 10763 return token(); |
10740 } | 10764 } |
10741 | 10765 |
10742 CSSParserSelector* CSSParser::createFloatingSelectorWithTagName(const QualifiedN
ame& tagQName) | 10766 CSSParserSelector* CSSParser::createFloatingSelectorWithTagName(const QualifiedN
ame& tagQName) |
10743 { | 10767 { |
(...skipping 728 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
11472 | 11496 |
11473 // If just one value is supplied, the second value | 11497 // If just one value is supplied, the second value |
11474 // is implicitly initialized with the first value. | 11498 // is implicitly initialized with the first value. |
11475 if (numValues == 1) | 11499 if (numValues == 1) |
11476 m_valueList->previous(); | 11500 m_valueList->previous(); |
11477 | 11501 |
11478 return parseViewportProperty(second, important); | 11502 return parseViewportProperty(second, important); |
11479 } | 11503 } |
11480 #endif | 11504 #endif |
11481 | 11505 |
| 11506 void CSSParser::markMediaListStart() |
| 11507 { |
| 11508 m_storedBlockLevel = m_brackets.level(); |
| 11509 if (m_storedBlockLevel > 0 && token() == m_brackets.top()) { |
| 11510 // Don't take the currently pushed lookahead token into account. |
| 11511 // This could happen for "@media{}", "@media()", etc. |
| 11512 --m_storedBlockLevel; |
| 11513 } |
| 11514 } |
| 11515 |
| 11516 MediaQuery* CSSParser::recoverMediaQuery() |
| 11517 { |
| 11518 size_t blockLevel = m_brackets.level(); |
| 11519 if (blockLevel >= m_storedBlockLevel) { |
| 11520 YYSTYPE yyval; |
| 11521 |
| 11522 while (token() != TOKEN_EOF) { |
| 11523 // End media query at ',', ';', or '{' at the same block level as th
e |
| 11524 // media list started. |
| 11525 if (blockLevel == m_storedBlockLevel && (token() == ',' || token() =
= ';')) |
| 11526 break; |
| 11527 // The '{' token will have increased the block level by 1 already. |
| 11528 if (blockLevel == m_storedBlockLevel + 1 && token() == '{') |
| 11529 break; |
| 11530 |
| 11531 lex(&yyval); |
| 11532 blockLevel = m_brackets.level(); |
| 11533 } |
| 11534 } else { |
| 11535 // Recovering from error token when we are at a block level above the |
| 11536 // block level where the media list started. That should only happen |
| 11537 // when synchronizing on a closing '}' just one level above the stored |
| 11538 // level. Typically happens when an @media rule is terminated |
| 11539 // prematurely: |
| 11540 // |
| 11541 // "@supports (color: red) { @media all and }" |
| 11542 ASSERT(token() == '}' && blockLevel == m_storedBlockLevel - 1); |
| 11543 } |
| 11544 |
| 11545 markCurrentTokenForReEmission(); |
| 11546 |
| 11547 return createFloatingMediaQuery(MediaQuery::Not, "all", sinkFloatingMediaQue
ryExpList(createFloatingMediaQueryExpList())); |
| 11548 } |
| 11549 |
11482 template <typename CharacterType> | 11550 template <typename CharacterType> |
11483 static CSSPropertyID cssPropertyID(const CharacterType* propertyName, unsigned l
ength) | 11551 static CSSPropertyID cssPropertyID(const CharacterType* propertyName, unsigned l
ength) |
11484 { | 11552 { |
11485 char buffer[maxCSSPropertyNameLength + 1 + 1]; // 1 to turn "apple"/"khtml"
into "webkit", 1 for null character | 11553 char buffer[maxCSSPropertyNameLength + 1 + 1]; // 1 to turn "apple"/"khtml"
into "webkit", 1 for null character |
11486 | 11554 |
11487 for (unsigned i = 0; i != length; ++i) { | 11555 for (unsigned i = 0; i != length; ++i) { |
11488 CharacterType c = propertyName[i]; | 11556 CharacterType c = propertyName[i]; |
11489 if (c == 0 || c >= 0x7F) | 11557 if (c == 0 || c >= 0x7F) |
11490 return CSSPropertyInvalid; // illegal character | 11558 return CSSPropertyInvalid; // illegal character |
11491 buffer[i] = toASCIILower(c); | 11559 buffer[i] = toASCIILower(c); |
(...skipping 235 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
11727 { | 11795 { |
11728 // The tokenizer checks for the construct of an+b. | 11796 // The tokenizer checks for the construct of an+b. |
11729 // However, since the {ident} rule precedes the {nth} rule, some of those | 11797 // However, since the {ident} rule precedes the {nth} rule, some of those |
11730 // tokens are identified as string literal. Furthermore we need to accept | 11798 // tokens are identified as string literal. Furthermore we need to accept |
11731 // "odd" and "even" which does not match to an+b. | 11799 // "odd" and "even" which does not match to an+b. |
11732 return equalIgnoringCase(token, "odd") || equalIgnoringCase(token, "even") | 11800 return equalIgnoringCase(token, "odd") || equalIgnoringCase(token, "even") |
11733 || equalIgnoringCase(token, "n") || equalIgnoringCase(token, "-n"); | 11801 || equalIgnoringCase(token, "n") || equalIgnoringCase(token, "-n"); |
11734 } | 11802 } |
11735 | 11803 |
11736 } | 11804 } |
OLD | NEW |