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 227 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
238 return strictContext; | 238 return strictContext; |
239 } | 239 } |
240 | 240 |
241 CSSParserContext::CSSParserContext(CSSParserMode mode, const KURL& baseURL) | 241 CSSParserContext::CSSParserContext(CSSParserMode mode, const KURL& baseURL) |
242 : baseURL(baseURL) | 242 : baseURL(baseURL) |
243 , mode(mode) | 243 , mode(mode) |
244 , isHTMLDocument(false) | 244 , isHTMLDocument(false) |
245 , isCSSCustomFilterEnabled(false) | 245 , isCSSCustomFilterEnabled(false) |
246 , isCSSStickyPositionEnabled(false) | 246 , isCSSStickyPositionEnabled(false) |
247 , isCSSGridLayoutEnabled(false) | 247 , isCSSGridLayoutEnabled(false) |
| 248 , isCSSVariablesEnabled(false) |
248 , needsSiteSpecificQuirks(false) | 249 , needsSiteSpecificQuirks(false) |
249 { | 250 { |
250 } | 251 } |
251 | 252 |
252 CSSParserContext::CSSParserContext(Document* document, const KURL& baseURL, cons
t String& charset) | 253 CSSParserContext::CSSParserContext(Document* document, const KURL& baseURL, cons
t String& charset) |
253 : baseURL(baseURL.isNull() ? document->baseURL() : baseURL) | 254 : baseURL(baseURL.isNull() ? document->baseURL() : baseURL) |
254 , charset(charset) | 255 , charset(charset) |
255 , mode(document->inQuirksMode() ? CSSQuirksMode : CSSStrictMode) | 256 , mode(document->inQuirksMode() ? CSSQuirksMode : CSSStrictMode) |
256 , isHTMLDocument(document->isHTMLDocument()) | 257 , isHTMLDocument(document->isHTMLDocument()) |
257 , isCSSCustomFilterEnabled(document->settings() ? document->settings()->isCS
SCustomFilterEnabled() : false) | 258 , isCSSCustomFilterEnabled(document->settings() ? document->settings()->isCS
SCustomFilterEnabled() : false) |
258 , isCSSStickyPositionEnabled(document->cssStickyPositionEnabled()) | 259 , isCSSStickyPositionEnabled(document->cssStickyPositionEnabled()) |
259 , isCSSGridLayoutEnabled(document->cssGridLayoutEnabled()) | 260 , isCSSGridLayoutEnabled(document->cssGridLayoutEnabled()) |
| 261 , isCSSVariablesEnabled(document->settings() ? document->settings()->cssVari
ablesEnabled() : false) |
260 , needsSiteSpecificQuirks(document->settings() ? document->settings()->needs
SiteSpecificQuirks() : false) | 262 , needsSiteSpecificQuirks(document->settings() ? document->settings()->needs
SiteSpecificQuirks() : false) |
261 { | 263 { |
262 } | 264 } |
263 | 265 |
264 bool operator==(const CSSParserContext& a, const CSSParserContext& b) | 266 bool operator==(const CSSParserContext& a, const CSSParserContext& b) |
265 { | 267 { |
266 return a.baseURL == b.baseURL | 268 return a.baseURL == b.baseURL |
267 && a.charset == b.charset | 269 && a.charset == b.charset |
268 && a.mode == b.mode | 270 && a.mode == b.mode |
269 && a.isHTMLDocument == b.isHTMLDocument | 271 && a.isHTMLDocument == b.isHTMLDocument |
270 && a.isCSSCustomFilterEnabled == b.isCSSCustomFilterEnabled | 272 && a.isCSSCustomFilterEnabled == b.isCSSCustomFilterEnabled |
271 && a.isCSSStickyPositionEnabled == b.isCSSStickyPositionEnabled | 273 && a.isCSSStickyPositionEnabled == b.isCSSStickyPositionEnabled |
272 && a.isCSSGridLayoutEnabled == b.isCSSGridLayoutEnabled | 274 && a.isCSSGridLayoutEnabled == b.isCSSGridLayoutEnabled |
| 275 && a.isCSSVariablesEnabled == b.isCSSVariablesEnabled |
273 && a.needsSiteSpecificQuirks == b.needsSiteSpecificQuirks; | 276 && a.needsSiteSpecificQuirks == b.needsSiteSpecificQuirks; |
274 } | 277 } |
275 | 278 |
276 CSSParser::CSSParser(const CSSParserContext& context) | 279 CSSParser::CSSParser(const CSSParserContext& context) |
277 : m_context(context) | 280 : m_context(context) |
278 , m_important(false) | 281 , m_important(false) |
279 , m_id(CSSPropertyInvalid) | 282 , m_id(CSSPropertyInvalid) |
280 , m_styleSheet(0) | 283 , m_styleSheet(0) |
281 , m_supportsCondition(false) | 284 , m_supportsCondition(false) |
282 , m_selectorListForParseSelector(0) | 285 , m_selectorListForParseSelector(0) |
(...skipping 2821 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3104 if (properties[i] == CSSPropertyBackgroundOrigin && !foundClip) | 3107 if (properties[i] == CSSPropertyBackgroundOrigin && !foundClip) |
3105 addProperty(CSSPropertyBackgroundClip, clipValue.release(), importan
t); | 3108 addProperty(CSSPropertyBackgroundClip, clipValue.release(), importan
t); |
3106 else if (properties[i] == CSSPropertyWebkitMaskOrigin && !foundClip) | 3109 else if (properties[i] == CSSPropertyWebkitMaskOrigin && !foundClip) |
3107 addProperty(CSSPropertyWebkitMaskClip, clipValue.release(), importan
t); | 3110 addProperty(CSSPropertyWebkitMaskClip, clipValue.release(), importan
t); |
3108 } | 3111 } |
3109 | 3112 |
3110 m_implicitShorthand = false; | 3113 m_implicitShorthand = false; |
3111 return true; | 3114 return true; |
3112 } | 3115 } |
3113 | 3116 |
| 3117 bool CSSParser::cssVariablesEnabled() const |
| 3118 { |
| 3119 return m_context.isCSSVariablesEnabled; |
| 3120 } |
| 3121 |
3114 void CSSParser::storeVariableDeclaration(const CSSParserString& name, PassOwnPtr
<CSSParserValueList> value, bool important) | 3122 void CSSParser::storeVariableDeclaration(const CSSParserString& name, PassOwnPtr
<CSSParserValueList> value, bool important) |
3115 { | 3123 { |
3116 // When CSSGrammar.y encounters an invalid declaration it passes null for th
e CSSParserValueList, just bail. | 3124 // When CSSGrammar.y encounters an invalid declaration it passes null for th
e CSSParserValueList, just bail. |
3117 if (!value) | 3125 if (!value) |
3118 return; | 3126 return; |
3119 | 3127 |
3120 static const unsigned prefixLength = sizeof("-webkit-var-") - 1; | 3128 static const unsigned prefixLength = sizeof("-webkit-var-") - 1; |
3121 | 3129 |
3122 ASSERT(name.length() > prefixLength); | 3130 ASSERT(name.length() > prefixLength); |
3123 AtomicString variableName = name.lowerSubstring(prefixLength, name.length()
- prefixLength); | 3131 AtomicString variableName = name.lowerSubstring(prefixLength, name.length()
- prefixLength); |
(...skipping 6908 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
10032 { | 10040 { |
10033 CharacterType* name = tokenStart<CharacterType>(); | 10041 CharacterType* name = tokenStart<CharacterType>(); |
10034 | 10042 |
10035 if (length == 11) { | 10043 if (length == 11) { |
10036 if (isASCIIAlphaCaselessEqual(name[10], 'y') && isEqualToCSSIdentifier(n
ame + 1, "webkit-an")) | 10044 if (isASCIIAlphaCaselessEqual(name[10], 'y') && isEqualToCSSIdentifier(n
ame + 1, "webkit-an")) |
10037 m_token = ANYFUNCTION; | 10045 m_token = ANYFUNCTION; |
10038 else if (isASCIIAlphaCaselessEqual(name[10], 'n') && isEqualToCSSIdentif
ier(name + 1, "webkit-mi")) | 10046 else if (isASCIIAlphaCaselessEqual(name[10], 'n') && isEqualToCSSIdentif
ier(name + 1, "webkit-mi")) |
10039 m_token = MINFUNCTION; | 10047 m_token = MINFUNCTION; |
10040 else if (isASCIIAlphaCaselessEqual(name[10], 'x') && isEqualToCSSIdentif
ier(name + 1, "webkit-ma")) | 10048 else if (isASCIIAlphaCaselessEqual(name[10], 'x') && isEqualToCSSIdentif
ier(name + 1, "webkit-ma")) |
10041 m_token = MAXFUNCTION; | 10049 m_token = MAXFUNCTION; |
10042 else if (RuntimeEnabledFeatures::cssVariablesEnabled() && isASCIIAlphaCa
selessEqual(name[10], 'r') && isEqualToCSSIdentifier(name + 1, "webkit-va")) | 10050 else if (cssVariablesEnabled() && isASCIIAlphaCaselessEqual(name[10], 'r
') && isEqualToCSSIdentifier(name + 1, "webkit-va")) |
10043 m_token = VARFUNCTION; | 10051 m_token = VARFUNCTION; |
10044 } else if (length == 12 && isEqualToCSSIdentifier(name + 1, "webkit-calc")) | 10052 } else if (length == 12 && isEqualToCSSIdentifier(name + 1, "webkit-calc")) |
10045 m_token = CALCFUNCTION; | 10053 m_token = CALCFUNCTION; |
10046 else if (length == 19 && isEqualToCSSIdentifier(name + 1, "webkit-distribute
d")) | 10054 else if (length == 19 && isEqualToCSSIdentifier(name + 1, "webkit-distribute
d")) |
10047 m_token = DISTRIBUTEDFUNCTION; | 10055 m_token = DISTRIBUTEDFUNCTION; |
10048 } | 10056 } |
10049 | 10057 |
10050 template <typename CharacterType> | 10058 template <typename CharacterType> |
10051 inline void CSSParser::detectAtToken(int length, bool hasEscape) | 10059 inline void CSSParser::detectAtToken(int length, bool hasEscape) |
10052 { | 10060 { |
(...skipping 414 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
10467 m_token = dotSeen ? FLOATTOKEN : INTEGER; | 10475 m_token = dotSeen ? FLOATTOKEN : INTEGER; |
10468 break; | 10476 break; |
10469 } | 10477 } |
10470 | 10478 |
10471 case CharacterDash: | 10479 case CharacterDash: |
10472 if (isIdentifierStartAfterDash(currentCharacter<SrcCharacterType>())) { | 10480 if (isIdentifierStartAfterDash(currentCharacter<SrcCharacterType>())) { |
10473 --currentCharacter<SrcCharacterType>(); | 10481 --currentCharacter<SrcCharacterType>(); |
10474 parseIdentifier(result, resultString, hasEscape); | 10482 parseIdentifier(result, resultString, hasEscape); |
10475 m_token = IDENT; | 10483 m_token = IDENT; |
10476 | 10484 |
10477 if (RuntimeEnabledFeatures::cssVariablesEnabled() && isEqualToCSSIde
ntifier(tokenStart<SrcCharacterType>() + 1, "webkit-var") && tokenStart<SrcChara
cterType>()[11] == '-' && isIdentifierStartAfterDash(tokenStart<SrcCharacterType
>() + 12)) | 10485 if (cssVariablesEnabled() && isEqualToCSSIdentifier(tokenStart<SrcCh
aracterType>() + 1, "webkit-var") && tokenStart<SrcCharacterType>()[11] == '-' &
& isIdentifierStartAfterDash(tokenStart<SrcCharacterType>() + 12)) |
10478 m_token = VAR_DEFINITION; | 10486 m_token = VAR_DEFINITION; |
10479 else if (*currentCharacter<SrcCharacterType>() == '(') { | 10487 else if (*currentCharacter<SrcCharacterType>() == '(') { |
10480 m_token = FUNCTION; | 10488 m_token = FUNCTION; |
10481 if (!hasEscape) | 10489 if (!hasEscape) |
10482 detectDashToken<SrcCharacterType>(result - tokenStart<SrcCha
racterType>()); | 10490 detectDashToken<SrcCharacterType>(result - tokenStart<SrcCha
racterType>()); |
10483 ++currentCharacter<SrcCharacterType>(); | 10491 ++currentCharacter<SrcCharacterType>(); |
10484 ++result; | 10492 ++result; |
10485 } else if (UNLIKELY(m_parsingMode == NthChildMode) && !hasEscape &&
isASCIIAlphaCaselessEqual(tokenStart<SrcCharacterType>()[1], 'n')) { | 10493 } else if (UNLIKELY(m_parsingMode == NthChildMode) && !hasEscape &&
isASCIIAlphaCaselessEqual(tokenStart<SrcCharacterType>()[1], 'n')) { |
10486 if (result - tokenStart<SrcCharacterType>() == 2) { | 10494 if (result - tokenStart<SrcCharacterType>() == 2) { |
10487 // String "-n" is IDENT but "-n+1" is NTH. | 10495 // String "-n" is IDENT but "-n+1" is NTH. |
(...skipping 1209 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
11697 { | 11705 { |
11698 // The tokenizer checks for the construct of an+b. | 11706 // The tokenizer checks for the construct of an+b. |
11699 // However, since the {ident} rule precedes the {nth} rule, some of those | 11707 // However, since the {ident} rule precedes the {nth} rule, some of those |
11700 // tokens are identified as string literal. Furthermore we need to accept | 11708 // tokens are identified as string literal. Furthermore we need to accept |
11701 // "odd" and "even" which does not match to an+b. | 11709 // "odd" and "even" which does not match to an+b. |
11702 return equalIgnoringCase(token, "odd") || equalIgnoringCase(token, "even") | 11710 return equalIgnoringCase(token, "odd") || equalIgnoringCase(token, "even") |
11703 || equalIgnoringCase(token, "n") || equalIgnoringCase(token, "-n"); | 11711 || equalIgnoringCase(token, "n") || equalIgnoringCase(token, "-n"); |
11704 } | 11712 } |
11705 | 11713 |
11706 } | 11714 } |
OLD | NEW |