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 226 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
237 return strictContext; | 237 return strictContext; |
238 } | 238 } |
239 | 239 |
240 CSSParserContext::CSSParserContext(CSSParserMode mode, const KURL& baseURL) | 240 CSSParserContext::CSSParserContext(CSSParserMode mode, const KURL& baseURL) |
241 : baseURL(baseURL) | 241 : baseURL(baseURL) |
242 , mode(mode) | 242 , mode(mode) |
243 , isHTMLDocument(false) | 243 , isHTMLDocument(false) |
244 , isCSSCustomFilterEnabled(false) | 244 , isCSSCustomFilterEnabled(false) |
245 , isCSSStickyPositionEnabled(false) | 245 , isCSSStickyPositionEnabled(false) |
246 , isCSSGridLayoutEnabled(false) | 246 , isCSSGridLayoutEnabled(false) |
247 , isCSSVariablesEnabled(false) | |
248 , needsSiteSpecificQuirks(false) | 247 , needsSiteSpecificQuirks(false) |
249 { | 248 { |
250 } | 249 } |
251 | 250 |
252 CSSParserContext::CSSParserContext(Document* document, const KURL& baseURL, cons
t String& charset) | 251 CSSParserContext::CSSParserContext(Document* document, const KURL& baseURL, cons
t String& charset) |
253 : baseURL(baseURL.isNull() ? document->baseURL() : baseURL) | 252 : baseURL(baseURL.isNull() ? document->baseURL() : baseURL) |
254 , charset(charset) | 253 , charset(charset) |
255 , mode(document->inQuirksMode() ? CSSQuirksMode : CSSStrictMode) | 254 , mode(document->inQuirksMode() ? CSSQuirksMode : CSSStrictMode) |
256 , isHTMLDocument(document->isHTMLDocument()) | 255 , isHTMLDocument(document->isHTMLDocument()) |
257 , isCSSCustomFilterEnabled(document->settings() ? document->settings()->isCS
SCustomFilterEnabled() : false) | 256 , isCSSCustomFilterEnabled(document->settings() ? document->settings()->isCS
SCustomFilterEnabled() : false) |
258 , isCSSStickyPositionEnabled(document->cssStickyPositionEnabled()) | 257 , isCSSStickyPositionEnabled(document->cssStickyPositionEnabled()) |
259 , isCSSGridLayoutEnabled(document->cssGridLayoutEnabled()) | 258 , isCSSGridLayoutEnabled(document->cssGridLayoutEnabled()) |
260 , isCSSVariablesEnabled(document->settings() ? document->settings()->cssVari
ablesEnabled() : false) | |
261 , needsSiteSpecificQuirks(document->settings() ? document->settings()->needs
SiteSpecificQuirks() : false) | 259 , needsSiteSpecificQuirks(document->settings() ? document->settings()->needs
SiteSpecificQuirks() : false) |
262 { | 260 { |
263 } | 261 } |
264 | 262 |
265 bool operator==(const CSSParserContext& a, const CSSParserContext& b) | 263 bool operator==(const CSSParserContext& a, const CSSParserContext& b) |
266 { | 264 { |
267 return a.baseURL == b.baseURL | 265 return a.baseURL == b.baseURL |
268 && a.charset == b.charset | 266 && a.charset == b.charset |
269 && a.mode == b.mode | 267 && a.mode == b.mode |
270 && a.isHTMLDocument == b.isHTMLDocument | 268 && a.isHTMLDocument == b.isHTMLDocument |
271 && a.isCSSCustomFilterEnabled == b.isCSSCustomFilterEnabled | 269 && a.isCSSCustomFilterEnabled == b.isCSSCustomFilterEnabled |
272 && a.isCSSStickyPositionEnabled == b.isCSSStickyPositionEnabled | 270 && a.isCSSStickyPositionEnabled == b.isCSSStickyPositionEnabled |
273 && a.isCSSGridLayoutEnabled == b.isCSSGridLayoutEnabled | 271 && a.isCSSGridLayoutEnabled == b.isCSSGridLayoutEnabled |
274 && a.isCSSVariablesEnabled == b.isCSSVariablesEnabled | |
275 && a.needsSiteSpecificQuirks == b.needsSiteSpecificQuirks; | 272 && a.needsSiteSpecificQuirks == b.needsSiteSpecificQuirks; |
276 } | 273 } |
277 | 274 |
278 CSSParser::CSSParser(const CSSParserContext& context) | 275 CSSParser::CSSParser(const CSSParserContext& context) |
279 : m_context(context) | 276 : m_context(context) |
280 , m_important(false) | 277 , m_important(false) |
281 , m_id(CSSPropertyInvalid) | 278 , m_id(CSSPropertyInvalid) |
282 , m_styleSheet(0) | 279 , m_styleSheet(0) |
283 , m_supportsCondition(false) | 280 , m_supportsCondition(false) |
284 , m_selectorListForParseSelector(0) | 281 , m_selectorListForParseSelector(0) |
(...skipping 2820 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3105 // Add in clip values when we hit the corresponding origin property. | 3102 // Add in clip values when we hit the corresponding origin property. |
3106 if (properties[i] == CSSPropertyBackgroundOrigin && !foundClip) | 3103 if (properties[i] == CSSPropertyBackgroundOrigin && !foundClip) |
3107 addProperty(CSSPropertyBackgroundClip, clipValue.release(), importan
t); | 3104 addProperty(CSSPropertyBackgroundClip, clipValue.release(), importan
t); |
3108 else if (properties[i] == CSSPropertyWebkitMaskOrigin && !foundClip) | 3105 else if (properties[i] == CSSPropertyWebkitMaskOrigin && !foundClip) |
3109 addProperty(CSSPropertyWebkitMaskClip, clipValue.release(), importan
t); | 3106 addProperty(CSSPropertyWebkitMaskClip, clipValue.release(), importan
t); |
3110 } | 3107 } |
3111 | 3108 |
3112 return true; | 3109 return true; |
3113 } | 3110 } |
3114 | 3111 |
3115 bool CSSParser::cssVariablesEnabled() const | |
3116 { | |
3117 return m_context.isCSSVariablesEnabled; | |
3118 } | |
3119 | |
3120 void CSSParser::storeVariableDeclaration(const CSSParserString& name, PassOwnPtr
<CSSParserValueList> value, bool important) | 3112 void CSSParser::storeVariableDeclaration(const CSSParserString& name, PassOwnPtr
<CSSParserValueList> value, bool important) |
3121 { | 3113 { |
3122 // When CSSGrammar.y encounters an invalid declaration it passes null for th
e CSSParserValueList, just bail. | 3114 // When CSSGrammar.y encounters an invalid declaration it passes null for th
e CSSParserValueList, just bail. |
3123 if (!value) | 3115 if (!value) |
3124 return; | 3116 return; |
3125 | 3117 |
3126 static const unsigned prefixLength = sizeof("-webkit-var-") - 1; | 3118 static const unsigned prefixLength = sizeof("-webkit-var-") - 1; |
3127 | 3119 |
3128 ASSERT(name.length() > prefixLength); | 3120 ASSERT(name.length() > prefixLength); |
3129 AtomicString variableName = name.lowerSubstring(prefixLength, name.length()
- prefixLength); | 3121 AtomicString variableName = name.lowerSubstring(prefixLength, name.length()
- prefixLength); |
(...skipping 6890 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
10020 { | 10012 { |
10021 CharacterType* name = tokenStart<CharacterType>(); | 10013 CharacterType* name = tokenStart<CharacterType>(); |
10022 | 10014 |
10023 if (length == 11) { | 10015 if (length == 11) { |
10024 if (isASCIIAlphaCaselessEqual(name[10], 'y') && isEqualToCSSIdentifier(n
ame + 1, "webkit-an")) | 10016 if (isASCIIAlphaCaselessEqual(name[10], 'y') && isEqualToCSSIdentifier(n
ame + 1, "webkit-an")) |
10025 m_token = ANYFUNCTION; | 10017 m_token = ANYFUNCTION; |
10026 else if (isASCIIAlphaCaselessEqual(name[10], 'n') && isEqualToCSSIdentif
ier(name + 1, "webkit-mi")) | 10018 else if (isASCIIAlphaCaselessEqual(name[10], 'n') && isEqualToCSSIdentif
ier(name + 1, "webkit-mi")) |
10027 m_token = MINFUNCTION; | 10019 m_token = MINFUNCTION; |
10028 else if (isASCIIAlphaCaselessEqual(name[10], 'x') && isEqualToCSSIdentif
ier(name + 1, "webkit-ma")) | 10020 else if (isASCIIAlphaCaselessEqual(name[10], 'x') && isEqualToCSSIdentif
ier(name + 1, "webkit-ma")) |
10029 m_token = MAXFUNCTION; | 10021 m_token = MAXFUNCTION; |
10030 else if (cssVariablesEnabled() && isASCIIAlphaCaselessEqual(name[10], 'r
') && isEqualToCSSIdentifier(name + 1, "webkit-va")) | 10022 else if (RuntimeEnabledFeatures::cssVariablesEnabled() && isASCIIAlphaCa
selessEqual(name[10], 'r') && isEqualToCSSIdentifier(name + 1, "webkit-va")) |
10031 m_token = VARFUNCTION; | 10023 m_token = VARFUNCTION; |
10032 } else if (length == 12 && isEqualToCSSIdentifier(name + 1, "webkit-calc")) | 10024 } else if (length == 12 && isEqualToCSSIdentifier(name + 1, "webkit-calc")) |
10033 m_token = CALCFUNCTION; | 10025 m_token = CALCFUNCTION; |
10034 else if (length == 19 && isEqualToCSSIdentifier(name + 1, "webkit-distribute
d")) | 10026 else if (length == 19 && isEqualToCSSIdentifier(name + 1, "webkit-distribute
d")) |
10035 m_token = DISTRIBUTEDFUNCTION; | 10027 m_token = DISTRIBUTEDFUNCTION; |
10036 } | 10028 } |
10037 | 10029 |
10038 template <typename CharacterType> | 10030 template <typename CharacterType> |
10039 inline void CSSParser::detectAtToken(int length, bool hasEscape) | 10031 inline void CSSParser::detectAtToken(int length, bool hasEscape) |
10040 { | 10032 { |
(...skipping 414 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
10455 m_token = dotSeen ? FLOATTOKEN : INTEGER; | 10447 m_token = dotSeen ? FLOATTOKEN : INTEGER; |
10456 break; | 10448 break; |
10457 } | 10449 } |
10458 | 10450 |
10459 case CharacterDash: | 10451 case CharacterDash: |
10460 if (isIdentifierStartAfterDash(currentCharacter<SrcCharacterType>())) { | 10452 if (isIdentifierStartAfterDash(currentCharacter<SrcCharacterType>())) { |
10461 --currentCharacter<SrcCharacterType>(); | 10453 --currentCharacter<SrcCharacterType>(); |
10462 parseIdentifier(result, resultString, hasEscape); | 10454 parseIdentifier(result, resultString, hasEscape); |
10463 m_token = IDENT; | 10455 m_token = IDENT; |
10464 | 10456 |
10465 if (cssVariablesEnabled() && isEqualToCSSIdentifier(tokenStart<SrcCh
aracterType>() + 1, "webkit-var") && tokenStart<SrcCharacterType>()[11] == '-' &
& isIdentifierStartAfterDash(tokenStart<SrcCharacterType>() + 12)) | 10457 if (RuntimeEnabledFeatures::cssVariablesEnabled() && isEqualToCSSIde
ntifier(tokenStart<SrcCharacterType>() + 1, "webkit-var") && tokenStart<SrcChara
cterType>()[11] == '-' && isIdentifierStartAfterDash(tokenStart<SrcCharacterType
>() + 12)) |
10466 m_token = VAR_DEFINITION; | 10458 m_token = VAR_DEFINITION; |
10467 else if (*currentCharacter<SrcCharacterType>() == '(') { | 10459 else if (*currentCharacter<SrcCharacterType>() == '(') { |
10468 m_token = FUNCTION; | 10460 m_token = FUNCTION; |
10469 if (!hasEscape) | 10461 if (!hasEscape) |
10470 detectDashToken<SrcCharacterType>(result - tokenStart<SrcCha
racterType>()); | 10462 detectDashToken<SrcCharacterType>(result - tokenStart<SrcCha
racterType>()); |
10471 ++currentCharacter<SrcCharacterType>(); | 10463 ++currentCharacter<SrcCharacterType>(); |
10472 ++result; | 10464 ++result; |
10473 } else if (UNLIKELY(m_parsingMode == NthChildMode) && !hasEscape &&
isASCIIAlphaCaselessEqual(tokenStart<SrcCharacterType>()[1], 'n')) { | 10465 } else if (UNLIKELY(m_parsingMode == NthChildMode) && !hasEscape &&
isASCIIAlphaCaselessEqual(tokenStart<SrcCharacterType>()[1], 'n')) { |
10474 if (result - tokenStart<SrcCharacterType>() == 2) { | 10466 if (result - tokenStart<SrcCharacterType>() == 2) { |
10475 // String "-n" is IDENT but "-n+1" is NTH. | 10467 // String "-n" is IDENT but "-n+1" is NTH. |
(...skipping 1201 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
11677 { | 11669 { |
11678 // The tokenizer checks for the construct of an+b. | 11670 // The tokenizer checks for the construct of an+b. |
11679 // However, since the {ident} rule precedes the {nth} rule, some of those | 11671 // However, since the {ident} rule precedes the {nth} rule, some of those |
11680 // tokens are identified as string literal. Furthermore we need to accept | 11672 // tokens are identified as string literal. Furthermore we need to accept |
11681 // "odd" and "even" which does not match to an+b. | 11673 // "odd" and "even" which does not match to an+b. |
11682 return equalIgnoringCase(token, "odd") || equalIgnoringCase(token, "even") | 11674 return equalIgnoringCase(token, "odd") || equalIgnoringCase(token, "even") |
11683 || equalIgnoringCase(token, "n") || equalIgnoringCase(token, "-n"); | 11675 || equalIgnoringCase(token, "n") || equalIgnoringCase(token, "-n"); |
11684 } | 11676 } |
11685 | 11677 |
11686 } | 11678 } |
OLD | NEW |