| 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 190 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 201 return strictContext; | 201 return strictContext; |
| 202 } | 202 } |
| 203 | 203 |
| 204 CSSParserContext::CSSParserContext(CSSParserMode mode, const KURL& baseURL) | 204 CSSParserContext::CSSParserContext(CSSParserMode mode, const KURL& baseURL) |
| 205 : baseURL(baseURL) | 205 : baseURL(baseURL) |
| 206 , mode(mode) | 206 , mode(mode) |
| 207 , isHTMLDocument(false) | 207 , isHTMLDocument(false) |
| 208 , isCSSCustomFilterEnabled(false) | 208 , isCSSCustomFilterEnabled(false) |
| 209 , isCSSStickyPositionEnabled(false) | 209 , isCSSStickyPositionEnabled(false) |
| 210 , isCSSGridLayoutEnabled(false) | 210 , isCSSGridLayoutEnabled(false) |
| 211 , isCSSVariablesEnabled(false) | |
| 212 , needsSiteSpecificQuirks(false) | 211 , needsSiteSpecificQuirks(false) |
| 213 { | 212 { |
| 214 } | 213 } |
| 215 | 214 |
| 216 CSSParserContext::CSSParserContext(Document* document, const KURL& baseURL, cons
t String& charset) | 215 CSSParserContext::CSSParserContext(Document* document, const KURL& baseURL, cons
t String& charset) |
| 217 : baseURL(baseURL.isNull() ? document->baseURL() : baseURL) | 216 : baseURL(baseURL.isNull() ? document->baseURL() : baseURL) |
| 218 , charset(charset) | 217 , charset(charset) |
| 219 , mode(document->inQuirksMode() ? CSSQuirksMode : CSSStrictMode) | 218 , mode(document->inQuirksMode() ? CSSQuirksMode : CSSStrictMode) |
| 220 , isHTMLDocument(document->isHTMLDocument()) | 219 , isHTMLDocument(document->isHTMLDocument()) |
| 221 , isCSSCustomFilterEnabled(document->settings() ? document->settings()->isCS
SCustomFilterEnabled() : false) | 220 , isCSSCustomFilterEnabled(document->settings() ? document->settings()->isCS
SCustomFilterEnabled() : false) |
| 222 , isCSSStickyPositionEnabled(document->cssStickyPositionEnabled()) | 221 , isCSSStickyPositionEnabled(document->cssStickyPositionEnabled()) |
| 223 , isCSSGridLayoutEnabled(document->cssGridLayoutEnabled()) | 222 , isCSSGridLayoutEnabled(document->cssGridLayoutEnabled()) |
| 224 , isCSSVariablesEnabled(document->settings() ? document->settings()->cssVari
ablesEnabled() : false) | |
| 225 , needsSiteSpecificQuirks(document->settings() ? document->settings()->needs
SiteSpecificQuirks() : false) | 223 , needsSiteSpecificQuirks(document->settings() ? document->settings()->needs
SiteSpecificQuirks() : false) |
| 226 { | 224 { |
| 227 } | 225 } |
| 228 | 226 |
| 229 bool operator==(const CSSParserContext& a, const CSSParserContext& b) | 227 bool operator==(const CSSParserContext& a, const CSSParserContext& b) |
| 230 { | 228 { |
| 231 return a.baseURL == b.baseURL | 229 return a.baseURL == b.baseURL |
| 232 && a.charset == b.charset | 230 && a.charset == b.charset |
| 233 && a.mode == b.mode | 231 && a.mode == b.mode |
| 234 && a.isHTMLDocument == b.isHTMLDocument | 232 && a.isHTMLDocument == b.isHTMLDocument |
| 235 && a.isCSSCustomFilterEnabled == b.isCSSCustomFilterEnabled | 233 && a.isCSSCustomFilterEnabled == b.isCSSCustomFilterEnabled |
| 236 && a.isCSSStickyPositionEnabled == b.isCSSStickyPositionEnabled | 234 && a.isCSSStickyPositionEnabled == b.isCSSStickyPositionEnabled |
| 237 && a.isCSSGridLayoutEnabled == b.isCSSGridLayoutEnabled | 235 && a.isCSSGridLayoutEnabled == b.isCSSGridLayoutEnabled |
| 238 && a.isCSSVariablesEnabled == b.isCSSVariablesEnabled | |
| 239 && a.needsSiteSpecificQuirks == b.needsSiteSpecificQuirks; | 236 && a.needsSiteSpecificQuirks == b.needsSiteSpecificQuirks; |
| 240 } | 237 } |
| 241 | 238 |
| 242 CSSParser::CSSParser(const CSSParserContext& context, UseCounter* counter) | 239 CSSParser::CSSParser(const CSSParserContext& context, UseCounter* counter) |
| 243 : m_context(context) | 240 : m_context(context) |
| 244 , m_important(false) | 241 , m_important(false) |
| 245 , m_id(CSSPropertyInvalid) | 242 , m_id(CSSPropertyInvalid) |
| 246 , m_styleSheet(0) | 243 , m_styleSheet(0) |
| 247 , m_supportsCondition(false) | 244 , m_supportsCondition(false) |
| 248 , m_selectorListForParseSelector(0) | 245 , m_selectorListForParseSelector(0) |
| (...skipping 2804 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3053 if (properties[i] == CSSPropertyBackgroundOrigin && !foundClip) | 3050 if (properties[i] == CSSPropertyBackgroundOrigin && !foundClip) |
| 3054 addProperty(CSSPropertyBackgroundClip, clipValue.release(), importan
t); | 3051 addProperty(CSSPropertyBackgroundClip, clipValue.release(), importan
t); |
| 3055 else if (properties[i] == CSSPropertyWebkitMaskOrigin && !foundClip) | 3052 else if (properties[i] == CSSPropertyWebkitMaskOrigin && !foundClip) |
| 3056 addProperty(CSSPropertyWebkitMaskClip, clipValue.release(), importan
t); | 3053 addProperty(CSSPropertyWebkitMaskClip, clipValue.release(), importan
t); |
| 3057 } | 3054 } |
| 3058 | 3055 |
| 3059 m_implicitShorthand = false; | 3056 m_implicitShorthand = false; |
| 3060 return true; | 3057 return true; |
| 3061 } | 3058 } |
| 3062 | 3059 |
| 3063 bool CSSParser::cssVariablesEnabled() const | |
| 3064 { | |
| 3065 return m_context.isCSSVariablesEnabled; | |
| 3066 } | |
| 3067 | |
| 3068 void CSSParser::storeVariableDeclaration(const CSSParserString& name, PassOwnPtr
<CSSParserValueList> value, bool important) | 3060 void CSSParser::storeVariableDeclaration(const CSSParserString& name, PassOwnPtr
<CSSParserValueList> value, bool important) |
| 3069 { | 3061 { |
| 3070 // When CSSGrammar.y encounters an invalid declaration it passes null for th
e CSSParserValueList, just bail. | 3062 // When CSSGrammar.y encounters an invalid declaration it passes null for th
e CSSParserValueList, just bail. |
| 3071 if (!value) | 3063 if (!value) |
| 3072 return; | 3064 return; |
| 3073 | 3065 |
| 3074 static const unsigned prefixLength = sizeof("-webkit-var-") - 1; | 3066 static const unsigned prefixLength = sizeof("-webkit-var-") - 1; |
| 3075 | 3067 |
| 3076 ASSERT(name.length() > prefixLength); | 3068 ASSERT(name.length() > prefixLength); |
| 3077 AtomicString variableName = name.atomicSubstring(prefixLength, name.length()
- prefixLength); | 3069 AtomicString variableName = name.atomicSubstring(prefixLength, name.length()
- prefixLength); |
| (...skipping 6915 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 9993 { | 9985 { |
| 9994 CharacterType* name = tokenStart<CharacterType>(); | 9986 CharacterType* name = tokenStart<CharacterType>(); |
| 9995 | 9987 |
| 9996 if (length == 11) { | 9988 if (length == 11) { |
| 9997 if (isASCIIAlphaCaselessEqual(name[10], 'y') && isEqualToCSSIdentifier(n
ame + 1, "webkit-an")) | 9989 if (isASCIIAlphaCaselessEqual(name[10], 'y') && isEqualToCSSIdentifier(n
ame + 1, "webkit-an")) |
| 9998 m_token = ANYFUNCTION; | 9990 m_token = ANYFUNCTION; |
| 9999 else if (isASCIIAlphaCaselessEqual(name[10], 'n') && isEqualToCSSIdentif
ier(name + 1, "webkit-mi")) | 9991 else if (isASCIIAlphaCaselessEqual(name[10], 'n') && isEqualToCSSIdentif
ier(name + 1, "webkit-mi")) |
| 10000 m_token = MINFUNCTION; | 9992 m_token = MINFUNCTION; |
| 10001 else if (isASCIIAlphaCaselessEqual(name[10], 'x') && isEqualToCSSIdentif
ier(name + 1, "webkit-ma")) | 9993 else if (isASCIIAlphaCaselessEqual(name[10], 'x') && isEqualToCSSIdentif
ier(name + 1, "webkit-ma")) |
| 10002 m_token = MAXFUNCTION; | 9994 m_token = MAXFUNCTION; |
| 10003 else if (cssVariablesEnabled() && isASCIIAlphaCaselessEqual(name[10], 'r
') && isEqualToCSSIdentifier(name + 1, "webkit-va")) | 9995 else if (RuntimeEnabledFeatures::cssVariablesEnabled() && isASCIIAlphaCa
selessEqual(name[10], 'r') && isEqualToCSSIdentifier(name + 1, "webkit-va")) |
| 10004 m_token = VARFUNCTION; | 9996 m_token = VARFUNCTION; |
| 10005 } else if (length == 12 && isEqualToCSSIdentifier(name + 1, "webkit-calc")) | 9997 } else if (length == 12 && isEqualToCSSIdentifier(name + 1, "webkit-calc")) |
| 10006 m_token = CALCFUNCTION; | 9998 m_token = CALCFUNCTION; |
| 10007 else if (length == 19 && isEqualToCSSIdentifier(name + 1, "webkit-distribute
d")) | 9999 else if (length == 19 && isEqualToCSSIdentifier(name + 1, "webkit-distribute
d")) |
| 10008 m_token = DISTRIBUTEDFUNCTION; | 10000 m_token = DISTRIBUTEDFUNCTION; |
| 10009 } | 10001 } |
| 10010 | 10002 |
| 10011 template <typename CharacterType> | 10003 template <typename CharacterType> |
| 10012 inline void CSSParser::detectAtToken(int length, bool hasEscape) | 10004 inline void CSSParser::detectAtToken(int length, bool hasEscape) |
| 10013 { | 10005 { |
| (...skipping 424 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 10438 m_token = dotSeen ? FLOATTOKEN : INTEGER; | 10430 m_token = dotSeen ? FLOATTOKEN : INTEGER; |
| 10439 break; | 10431 break; |
| 10440 } | 10432 } |
| 10441 | 10433 |
| 10442 case CharacterDash: | 10434 case CharacterDash: |
| 10443 if (isIdentifierStartAfterDash(currentCharacter<SrcCharacterType>())) { | 10435 if (isIdentifierStartAfterDash(currentCharacter<SrcCharacterType>())) { |
| 10444 --currentCharacter<SrcCharacterType>(); | 10436 --currentCharacter<SrcCharacterType>(); |
| 10445 parseIdentifier(result, resultString, hasEscape); | 10437 parseIdentifier(result, resultString, hasEscape); |
| 10446 m_token = IDENT; | 10438 m_token = IDENT; |
| 10447 | 10439 |
| 10448 if (cssVariablesEnabled() && detectCSSVariablesToken<SrcCharacterTyp
e>(result - tokenStart<SrcCharacterType>())) | 10440 if (RuntimeEnabledFeatures::cssVariablesEnabled() && detectCSSVariab
lesToken<SrcCharacterType>(result - tokenStart<SrcCharacterType>())) |
| 10449 m_token = VAR_DEFINITION; | 10441 m_token = VAR_DEFINITION; |
| 10450 else if (*currentCharacter<SrcCharacterType>() == '(') { | 10442 else if (*currentCharacter<SrcCharacterType>() == '(') { |
| 10451 m_token = FUNCTION; | 10443 m_token = FUNCTION; |
| 10452 if (!hasEscape) | 10444 if (!hasEscape) |
| 10453 detectDashToken<SrcCharacterType>(result - tokenStart<SrcCha
racterType>()); | 10445 detectDashToken<SrcCharacterType>(result - tokenStart<SrcCha
racterType>()); |
| 10454 ++currentCharacter<SrcCharacterType>(); | 10446 ++currentCharacter<SrcCharacterType>(); |
| 10455 ++result; | 10447 ++result; |
| 10456 } else if (UNLIKELY(m_parsingMode == NthChildMode) && !hasEscape &&
isASCIIAlphaCaselessEqual(tokenStart<SrcCharacterType>()[1], 'n')) { | 10448 } else if (UNLIKELY(m_parsingMode == NthChildMode) && !hasEscape &&
isASCIIAlphaCaselessEqual(tokenStart<SrcCharacterType>()[1], 'n')) { |
| 10457 if (result - tokenStart<SrcCharacterType>() == 2) { | 10449 if (result - tokenStart<SrcCharacterType>() == 2) { |
| 10458 // String "-n" is IDENT but "-n+1" is NTH. | 10450 // String "-n" is IDENT but "-n+1" is NTH. |
| (...skipping 1291 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 11750 { | 11742 { |
| 11751 // The tokenizer checks for the construct of an+b. | 11743 // The tokenizer checks for the construct of an+b. |
| 11752 // However, since the {ident} rule precedes the {nth} rule, some of those | 11744 // However, since the {ident} rule precedes the {nth} rule, some of those |
| 11753 // tokens are identified as string literal. Furthermore we need to accept | 11745 // tokens are identified as string literal. Furthermore we need to accept |
| 11754 // "odd" and "even" which does not match to an+b. | 11746 // "odd" and "even" which does not match to an+b. |
| 11755 return equalIgnoringCase(token, "odd") || equalIgnoringCase(token, "even") | 11747 return equalIgnoringCase(token, "odd") || equalIgnoringCase(token, "even") |
| 11756 || equalIgnoringCase(token, "n") || equalIgnoringCase(token, "-n"); | 11748 || equalIgnoringCase(token, "n") || equalIgnoringCase(token, "-n"); |
| 11757 } | 11749 } |
| 11758 | 11750 |
| 11759 } | 11751 } |
| OLD | NEW |