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 250 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
261 , m_currentCharacter16(0) | 261 , m_currentCharacter16(0) |
262 , m_source(0) | 262 , m_source(0) |
263 , m_length(0) | 263 , m_length(0) |
264 , m_token(0) | 264 , m_token(0) |
265 , m_lineNumber(0) | 265 , m_lineNumber(0) |
266 , m_tokenStartLineNumber(0) | 266 , m_tokenStartLineNumber(0) |
267 , m_lastSelectorLineNumber(0) | 267 , m_lastSelectorLineNumber(0) |
268 , m_ruleHeaderType(CSSRuleSourceData::UNKNOWN_RULE) | 268 , m_ruleHeaderType(CSSRuleSourceData::UNKNOWN_RULE) |
269 , m_allowImportRules(true) | 269 , m_allowImportRules(true) |
270 , m_allowNamespaceDeclarations(true) | 270 , m_allowNamespaceDeclarations(true) |
271 #if ENABLE(CSS_DEVICE_ADAPTATION) | |
272 , m_inViewport(false) | 271 , m_inViewport(false) |
273 #endif | |
274 , m_useCounter(counter) | 272 , m_useCounter(counter) |
275 { | 273 { |
276 #if YYDEBUG > 0 | 274 #if YYDEBUG > 0 |
277 cssyydebug = 1; | 275 cssyydebug = 1; |
278 #endif | 276 #endif |
279 m_tokenStart.ptr8 = 0; | 277 m_tokenStart.ptr8 = 0; |
280 CSSPropertySourceData::init(); | 278 CSSPropertySourceData::init(); |
281 } | 279 } |
282 | 280 |
283 CSSParser::~CSSParser() | 281 CSSParser::~CSSParser() |
(...skipping 1414 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1698 | 1696 |
1699 if (isKeywordPropertyID(propId)) { | 1697 if (isKeywordPropertyID(propId)) { |
1700 if (!isValidKeywordPropertyAndValue(propId, id, m_context)) | 1698 if (!isValidKeywordPropertyAndValue(propId, id, m_context)) |
1701 return false; | 1699 return false; |
1702 if (m_valueList->next() && !inShorthand()) | 1700 if (m_valueList->next() && !inShorthand()) |
1703 return false; | 1701 return false; |
1704 addProperty(propId, cssValuePool().createIdentifierValue(id), important)
; | 1702 addProperty(propId, cssValuePool().createIdentifierValue(id), important)
; |
1705 return true; | 1703 return true; |
1706 } | 1704 } |
1707 | 1705 |
1708 #if ENABLE(CSS_DEVICE_ADAPTATION) | 1706 if (inViewport()) { |
1709 if (inViewport()) | 1707 if (!RuntimeEnabledFeatures::cssViewportEnabled()) |
| 1708 return false; |
| 1709 |
1710 return parseViewportProperty(propId, important); | 1710 return parseViewportProperty(propId, important); |
1711 #endif | 1711 } |
1712 | 1712 |
1713 bool validPrimitive = false; | 1713 bool validPrimitive = false; |
1714 RefPtr<CSSValue> parsedValue; | 1714 RefPtr<CSSValue> parsedValue; |
1715 | 1715 |
1716 switch (propId) { | 1716 switch (propId) { |
1717 case CSSPropertySize: // <length>{1,2} | auto | [ <page-size
> || [ portrait | landscape] ] | 1717 case CSSPropertySize: // <length>{1,2} | auto | [ <page-size
> || [ portrait | landscape] ] |
1718 return parseSize(propId, important); | 1718 return parseSize(propId, important); |
1719 | 1719 |
1720 case CSSPropertyQuotes: // [<string> <string>]+ | none | inher
it | 1720 case CSSPropertyQuotes: // [<string> <string>]+ | none | inher
it |
1721 if (id) | 1721 if (id) |
(...skipping 1114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2836 case CSSPropertyWebkitUserSelect: | 2836 case CSSPropertyWebkitUserSelect: |
2837 case CSSPropertyWebkitWrapFlow: | 2837 case CSSPropertyWebkitWrapFlow: |
2838 case CSSPropertyWebkitWrapThrough: | 2838 case CSSPropertyWebkitWrapThrough: |
2839 case CSSPropertyWebkitWritingMode: | 2839 case CSSPropertyWebkitWritingMode: |
2840 case CSSPropertyWhiteSpace: | 2840 case CSSPropertyWhiteSpace: |
2841 case CSSPropertyWordBreak: | 2841 case CSSPropertyWordBreak: |
2842 case CSSPropertyWordWrap: | 2842 case CSSPropertyWordWrap: |
2843 // These properties should be handled before in isValidKeywordPropertyAn
dValue(). | 2843 // These properties should be handled before in isValidKeywordPropertyAn
dValue(). |
2844 ASSERT_NOT_REACHED(); | 2844 ASSERT_NOT_REACHED(); |
2845 return false; | 2845 return false; |
2846 #if ENABLE(CSS_DEVICE_ADAPTATION) | |
2847 // Properties bellow are validated inside parseViewportProperty, because we | 2846 // Properties bellow are validated inside parseViewportProperty, because we |
2848 // check for parser state inViewportScope. We need to invalidate if someone | 2847 // check for parser state inViewportScope. We need to invalidate if someone |
2849 // adds them outside a @viewport rule. | 2848 // adds them outside a @viewport rule. |
2850 case CSSPropertyMaxZoom: | 2849 case CSSPropertyMaxZoom: |
2851 case CSSPropertyMinZoom: | 2850 case CSSPropertyMinZoom: |
2852 case CSSPropertyOrientation: | 2851 case CSSPropertyOrientation: |
2853 case CSSPropertyUserZoom: | 2852 case CSSPropertyUserZoom: |
2854 validPrimitive = false; | 2853 validPrimitive = false; |
2855 break; | 2854 break; |
2856 #endif | |
2857 default: | 2855 default: |
2858 return parseSVGValue(propId, important); | 2856 return parseSVGValue(propId, important); |
2859 } | 2857 } |
2860 | 2858 |
2861 if (validPrimitive) { | 2859 if (validPrimitive) { |
2862 parsedValue = parseValidPrimitive(id, value); | 2860 parsedValue = parseValidPrimitive(id, value); |
2863 m_valueList->next(); | 2861 m_valueList->next(); |
2864 } | 2862 } |
2865 ASSERT(!m_parsedCalculation); | 2863 ASSERT(!m_parsedCalculation); |
2866 if (parsedValue) { | 2864 if (parsedValue) { |
(...skipping 7383 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
10250 if (isASCIIAlphaCaselessEqual(name[15], 's') && isEqualToCSSIdentifi
er(name + 2, "internal-decl")) | 10248 if (isASCIIAlphaCaselessEqual(name[15], 's') && isEqualToCSSIdentifi
er(name + 2, "internal-decl")) |
10251 m_token = INTERNAL_DECLS_SYM; | 10249 m_token = INTERNAL_DECLS_SYM; |
10252 else if (isASCIIAlphaCaselessEqual(name[15], 'e') && isEqualToCSSIde
ntifier(name + 2, "internal-valu")) | 10250 else if (isASCIIAlphaCaselessEqual(name[15], 'e') && isEqualToCSSIde
ntifier(name + 2, "internal-valu")) |
10253 m_token = INTERNAL_VALUE_SYM; | 10251 m_token = INTERNAL_VALUE_SYM; |
10254 return; | 10252 return; |
10255 | 10253 |
10256 case 17: | 10254 case 17: |
10257 if (hasEscape) | 10255 if (hasEscape) |
10258 return; | 10256 return; |
10259 | 10257 |
10260 #if ENABLE(CSS_DEVICE_ADAPTATION) | |
10261 else if (isASCIIAlphaCaselessEqual(name[16], 't') && isEqualToCSSIde
ntifier(name + 2, "webkit-viewpor")) | 10258 else if (isASCIIAlphaCaselessEqual(name[16], 't') && isEqualToCSSIde
ntifier(name + 2, "webkit-viewpor")) |
10262 m_token = WEBKIT_VIEWPORT_RULE_SYM; | 10259 m_token = WEBKIT_VIEWPORT_RULE_SYM; |
10263 #endif | |
10264 return; | 10260 return; |
10265 | 10261 |
10266 case 18: | 10262 case 18: |
10267 if (isEqualToCSSIdentifier(name + 2, "webkit-keyframes")) | 10263 if (isEqualToCSSIdentifier(name + 2, "webkit-keyframes")) |
10268 m_token = WEBKIT_KEYFRAMES_SYM; | 10264 m_token = WEBKIT_KEYFRAMES_SYM; |
10269 return; | 10265 return; |
10270 | 10266 |
10271 case 19: | 10267 case 19: |
10272 if (!hasEscape && isASCIIAlphaCaselessEqual(name[18], 'r') && isEqua
lToCSSIdentifier(name + 2, "internal-selecto")) { | 10268 if (!hasEscape && isASCIIAlphaCaselessEqual(name[18], 'r') && isEqua
lToCSSIdentifier(name + 2, "internal-selecto")) { |
10273 m_token = INTERNAL_SELECTOR_SYM; | 10269 m_token = INTERNAL_SELECTOR_SYM; |
(...skipping 1179 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
11453 { | 11449 { |
11454 if (m_sourceDataHandler) | 11450 if (m_sourceDataHandler) |
11455 m_sourceDataHandler->startEndUnknownRule(); | 11451 m_sourceDataHandler->startEndUnknownRule(); |
11456 } | 11452 } |
11457 | 11453 |
11458 unsigned CSSParser::safeUserStringTokenOffset() | 11454 unsigned CSSParser::safeUserStringTokenOffset() |
11459 { | 11455 { |
11460 return min(tokenStartOffset(), static_cast<unsigned>(m_length - 1 - m_parsed
TextSuffixLength)) - m_parsedTextPrefixLength; | 11456 return min(tokenStartOffset(), static_cast<unsigned>(m_length - 1 - m_parsed
TextSuffixLength)) - m_parsedTextPrefixLength; |
11461 } | 11457 } |
11462 | 11458 |
11463 #if ENABLE(CSS_DEVICE_ADAPTATION) | |
11464 StyleRuleBase* CSSParser::createViewportRule() | 11459 StyleRuleBase* CSSParser::createViewportRule() |
11465 { | 11460 { |
| 11461 if (!RuntimeEnabledFeatures::cssViewportEnabled()) |
| 11462 return 0; |
| 11463 |
11466 m_allowImportRules = m_allowNamespaceDeclarations = false; | 11464 m_allowImportRules = m_allowNamespaceDeclarations = false; |
11467 | 11465 |
11468 RefPtr<StyleRuleViewport> rule = StyleRuleViewport::create(); | 11466 RefPtr<StyleRuleViewport> rule = StyleRuleViewport::create(); |
11469 | 11467 |
11470 rule->setProperties(createStylePropertySet()); | 11468 rule->setProperties(createStylePropertySet()); |
11471 clearProperties(); | 11469 clearProperties(); |
11472 | 11470 |
11473 StyleRuleViewport* result = rule.get(); | 11471 StyleRuleViewport* result = rule.get(); |
11474 m_parsedRules.append(rule.release()); | 11472 m_parsedRules.append(rule.release()); |
11475 endRuleBody(); | 11473 endRuleBody(); |
11476 | 11474 |
11477 return result; | 11475 return result; |
11478 } | 11476 } |
11479 | 11477 |
11480 bool CSSParser::parseViewportProperty(CSSPropertyID propId, bool important) | 11478 bool CSSParser::parseViewportProperty(CSSPropertyID propId, bool important) |
11481 { | 11479 { |
| 11480 ASSERT(RuntimeEnabledFeatures::cssViewportEnabled()); |
| 11481 |
11482 CSSParserValue* value = m_valueList->current(); | 11482 CSSParserValue* value = m_valueList->current(); |
11483 if (!value) | 11483 if (!value) |
11484 return false; | 11484 return false; |
11485 | 11485 |
11486 int id = value->id; | 11486 CSSValueID id = value->id; |
11487 bool validPrimitive = false; | 11487 bool validPrimitive = false; |
11488 | 11488 |
11489 switch (propId) { | 11489 switch (propId) { |
11490 case CSSPropertyMinWidth: // auto | device-width | device-height | <length>
| <percentage> | 11490 case CSSPropertyMinWidth: // auto | device-width | device-height | <length>
| <percentage> |
11491 case CSSPropertyMaxWidth: | 11491 case CSSPropertyMaxWidth: |
11492 case CSSPropertyMinHeight: | 11492 case CSSPropertyMinHeight: |
11493 case CSSPropertyMaxHeight: | 11493 case CSSPropertyMaxHeight: |
11494 if (id == CSSValueAuto || id == CSSValueDeviceWidth || id == CSSValueDev
iceHeight) | 11494 if (id == CSSValueAuto || id == CSSValueDeviceWidth || id == CSSValueDev
iceHeight) |
11495 validPrimitive = true; | 11495 validPrimitive = true; |
11496 else | 11496 else |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
11530 addProperty(propId, parsedValue.release(), important); | 11530 addProperty(propId, parsedValue.release(), important); |
11531 return true; | 11531 return true; |
11532 } | 11532 } |
11533 } | 11533 } |
11534 | 11534 |
11535 return false; | 11535 return false; |
11536 } | 11536 } |
11537 | 11537 |
11538 bool CSSParser::parseViewportShorthand(CSSPropertyID propId, CSSPropertyID first
, CSSPropertyID second, bool important) | 11538 bool CSSParser::parseViewportShorthand(CSSPropertyID propId, CSSPropertyID first
, CSSPropertyID second, bool important) |
11539 { | 11539 { |
| 11540 ASSERT(RuntimeEnabledFeatures::cssViewportEnabled()); |
11540 unsigned numValues = m_valueList->size(); | 11541 unsigned numValues = m_valueList->size(); |
11541 | 11542 |
11542 if (numValues > 2) | 11543 if (numValues > 2) |
11543 return false; | 11544 return false; |
11544 | 11545 |
11545 ShorthandScope scope(this, propId); | 11546 ShorthandScope scope(this, propId); |
11546 | 11547 |
11547 if (!parseViewportProperty(first, important)) | 11548 if (!parseViewportProperty(first, important)) |
11548 return false; | 11549 return false; |
11549 | 11550 |
11550 // If just one value is supplied, the second value | 11551 // If just one value is supplied, the second value |
11551 // is implicitly initialized with the first value. | 11552 // is implicitly initialized with the first value. |
11552 if (numValues == 1) | 11553 if (numValues == 1) |
11553 m_valueList->previous(); | 11554 m_valueList->previous(); |
11554 | 11555 |
11555 return parseViewportProperty(second, important); | 11556 return parseViewportProperty(second, important); |
11556 } | 11557 } |
11557 #endif | |
11558 | 11558 |
11559 template <typename CharacterType> | 11559 template <typename CharacterType> |
11560 static CSSPropertyID cssPropertyID(const CharacterType* propertyName, unsigned l
ength) | 11560 static CSSPropertyID cssPropertyID(const CharacterType* propertyName, unsigned l
ength) |
11561 { | 11561 { |
11562 char buffer[maxCSSPropertyNameLength + 1 + 1]; // 1 to turn "apple"/"khtml"
into "webkit", 1 for null character | 11562 char buffer[maxCSSPropertyNameLength + 1 + 1]; // 1 to turn "apple"/"khtml"
into "webkit", 1 for null character |
11563 | 11563 |
11564 for (unsigned i = 0; i != length; ++i) { | 11564 for (unsigned i = 0; i != length; ++i) { |
11565 CharacterType c = propertyName[i]; | 11565 CharacterType c = propertyName[i]; |
11566 if (c == 0 || c >= 0x7F) | 11566 if (c == 0 || c >= 0x7F) |
11567 return CSSPropertyInvalid; // illegal character | 11567 return CSSPropertyInvalid; // illegal character |
(...skipping 236 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
11804 { | 11804 { |
11805 // The tokenizer checks for the construct of an+b. | 11805 // The tokenizer checks for the construct of an+b. |
11806 // However, since the {ident} rule precedes the {nth} rule, some of those | 11806 // However, since the {ident} rule precedes the {nth} rule, some of those |
11807 // tokens are identified as string literal. Furthermore we need to accept | 11807 // tokens are identified as string literal. Furthermore we need to accept |
11808 // "odd" and "even" which does not match to an+b. | 11808 // "odd" and "even" which does not match to an+b. |
11809 return equalIgnoringCase(token, "odd") || equalIgnoringCase(token, "even") | 11809 return equalIgnoringCase(token, "odd") || equalIgnoringCase(token, "even") |
11810 || equalIgnoringCase(token, "n") || equalIgnoringCase(token, "-n"); | 11810 || equalIgnoringCase(token, "n") || equalIgnoringCase(token, "-n"); |
11811 } | 11811 } |
11812 | 11812 |
11813 } | 11813 } |
OLD | NEW |