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 * | 10 * |
(...skipping 10270 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
10281 if (isASCIIAlphaCaselessEqual(name[0], 'o') && isASCIIAlphaCaselessEqual (name[1], 'r')) | 10281 if (isASCIIAlphaCaselessEqual(name[0], 'o') && isASCIIAlphaCaselessEqual (name[1], 'r')) |
10282 m_token = SUPPORTS_OR; | 10282 m_token = SUPPORTS_OR; |
10283 } else if (length == 3) { | 10283 } else if (length == 3) { |
10284 if (isASCIIAlphaCaselessEqual(name[0], 'a') && isASCIIAlphaCaselessEqual (name[1], 'n') && isASCIIAlphaCaselessEqual(name[2], 'd')) | 10284 if (isASCIIAlphaCaselessEqual(name[0], 'a') && isASCIIAlphaCaselessEqual (name[1], 'n') && isASCIIAlphaCaselessEqual(name[2], 'd')) |
10285 m_token = SUPPORTS_AND; | 10285 m_token = SUPPORTS_AND; |
10286 else if (isASCIIAlphaCaselessEqual(name[0], 'n') && isASCIIAlphaCaseless Equal(name[1], 'o') && isASCIIAlphaCaselessEqual(name[2], 't')) | 10286 else if (isASCIIAlphaCaselessEqual(name[0], 'n') && isASCIIAlphaCaseless Equal(name[1], 'o') && isASCIIAlphaCaselessEqual(name[2], 't')) |
10287 m_token = SUPPORTS_NOT; | 10287 m_token = SUPPORTS_NOT; |
10288 } | 10288 } |
10289 } | 10289 } |
10290 | 10290 |
10291 template <typename CharacterType> | |
10292 inline bool CSSParser::detectCSSVariablesToken(int length) | |
10293 { | |
10294 ASSERT(tokenStart<CharacterType>()[0] == '-'); | |
10295 if (length < sizeof("-webkit-var-*") - 1) | |
10296 return false; | |
10297 CharacterType* name = tokenStart<CharacterType>(); | |
10298 return name[11] == '-' && isIdentifierStartAfterDash(name + 12) && isEqualTo CSSIdentifier(name + 1, "webkit-var")); | |
eseidel
2013/05/22 07:11:43
Soooo many magic numbers!
| |
10299 } | |
10300 | |
10301 | |
10291 template <typename SrcCharacterType> | 10302 template <typename SrcCharacterType> |
10292 int CSSParser::realLex(void* yylvalWithoutType) | 10303 int CSSParser::realLex(void* yylvalWithoutType) |
10293 { | 10304 { |
10294 YYSTYPE* yylval = static_cast<YYSTYPE*>(yylvalWithoutType); | 10305 YYSTYPE* yylval = static_cast<YYSTYPE*>(yylvalWithoutType); |
10295 // Write pointer for the next character. | 10306 // Write pointer for the next character. |
10296 SrcCharacterType* result; | 10307 SrcCharacterType* result; |
10297 CSSParserString resultString; | 10308 CSSParserString resultString; |
10298 bool hasEscape; | 10309 bool hasEscape; |
10299 | 10310 |
10300 // The input buffer is terminated by a \0 character, so | 10311 // The input buffer is terminated by a \0 character, so |
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
10465 m_token = dotSeen ? FLOATTOKEN : INTEGER; | 10476 m_token = dotSeen ? FLOATTOKEN : INTEGER; |
10466 break; | 10477 break; |
10467 } | 10478 } |
10468 | 10479 |
10469 case CharacterDash: | 10480 case CharacterDash: |
10470 if (isIdentifierStartAfterDash(currentCharacter<SrcCharacterType>())) { | 10481 if (isIdentifierStartAfterDash(currentCharacter<SrcCharacterType>())) { |
10471 --currentCharacter<SrcCharacterType>(); | 10482 --currentCharacter<SrcCharacterType>(); |
10472 parseIdentifier(result, resultString, hasEscape); | 10483 parseIdentifier(result, resultString, hasEscape); |
10473 m_token = IDENT; | 10484 m_token = IDENT; |
10474 | 10485 |
10475 if (cssVariablesEnabled() && isEqualToCSSIdentifier(tokenStart<SrcCh aracterType>() + 1, "webkit-var") && tokenStart<SrcCharacterType>()[11] == '-' & & isIdentifierStartAfterDash(tokenStart<SrcCharacterType>() + 12)) | 10486 if (cssVariablesEnabled() && detectCSSVariablesToken<SrcCharacterTyp e>(result - tokenStart<SrcCharacterType>())) |
10476 m_token = VAR_DEFINITION; | 10487 m_token = VAR_DEFINITION; |
10477 else if (*currentCharacter<SrcCharacterType>() == '(') { | 10488 else if (*currentCharacter<SrcCharacterType>() == '(') { |
10478 m_token = FUNCTION; | 10489 m_token = FUNCTION; |
10479 if (!hasEscape) | 10490 if (!hasEscape) |
10480 detectDashToken<SrcCharacterType>(result - tokenStart<SrcCha racterType>()); | 10491 detectDashToken<SrcCharacterType>(result - tokenStart<SrcCha racterType>()); |
10481 ++currentCharacter<SrcCharacterType>(); | 10492 ++currentCharacter<SrcCharacterType>(); |
10482 ++result; | 10493 ++result; |
10483 } else if (UNLIKELY(m_parsingMode == NthChildMode) && !hasEscape && isASCIIAlphaCaselessEqual(tokenStart<SrcCharacterType>()[1], 'n')) { | 10494 } else if (UNLIKELY(m_parsingMode == NthChildMode) && !hasEscape && isASCIIAlphaCaselessEqual(tokenStart<SrcCharacterType>()[1], 'n')) { |
10484 if (result - tokenStart<SrcCharacterType>() == 2) { | 10495 if (result - tokenStart<SrcCharacterType>() == 2) { |
10485 // String "-n" is IDENT but "-n+1" is NTH. | 10496 // String "-n" is IDENT but "-n+1" is NTH. |
(...skipping 1225 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
11711 result.lineNumber = lineNumber; | 11722 result.lineNumber = lineNumber; |
11712 result.content = content; | 11723 result.content = content; |
11713 size_t newLength = content.length(); | 11724 size_t newLength = content.length(); |
11714 while (newLength > 0 && isHTMLSpace(result.content[newLength - 1])) | 11725 while (newLength > 0 && isHTMLSpace(result.content[newLength - 1])) |
11715 --newLength; | 11726 --newLength; |
11716 result.content.setLength(newLength); | 11727 result.content.setLength(newLength); |
11717 return result; | 11728 return result; |
11718 } | 11729 } |
11719 | 11730 |
11720 } | 11731 } |
OLD | NEW |