Chromium Code Reviews

Side by Side Diff: third_party/WebKit/Source/core/css/parser/CSSParserImpl.cpp

Issue 2398013002: Reflow comments in core/css/parser (Closed)
Patch Set: Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff |
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "core/css/parser/CSSParserImpl.h" 5 #include "core/css/parser/CSSParserImpl.h"
6 6
7 #include "core/css/CSSCustomIdentValue.h" 7 #include "core/css/CSSCustomIdentValue.h"
8 #include "core/css/CSSCustomPropertyDeclaration.h" 8 #include "core/css/CSSCustomPropertyDeclaration.h"
9 #include "core/css/CSSKeyframesRule.h" 9 #include "core/css/CSSKeyframesRule.h"
10 #include "core/css/CSSStyleSheet.h" 10 #include "core/css/CSSStyleSheet.h"
(...skipping 61 matching lines...)
72 return declaration->addParsedProperties(parser.m_parsedProperties); 72 return declaration->addParsedProperties(parser.m_parsedProperties);
73 } 73 }
74 74
75 static inline void filterProperties( 75 static inline void filterProperties(
76 bool important, 76 bool important,
77 const HeapVector<CSSProperty, 256>& input, 77 const HeapVector<CSSProperty, 256>& input,
78 HeapVector<CSSProperty, 256>& output, 78 HeapVector<CSSProperty, 256>& output,
79 size_t& unusedEntries, 79 size_t& unusedEntries,
80 std::bitset<numCSSProperties>& seenProperties, 80 std::bitset<numCSSProperties>& seenProperties,
81 HashSet<AtomicString>& seenCustomProperties) { 81 HashSet<AtomicString>& seenCustomProperties) {
82 // Add properties in reverse order so that highest priority definitions are re ached first. Duplicate definitions can then be ignored when found. 82 // Add properties in reverse order so that highest priority definitions are
83 // reached first. Duplicate definitions can then be ignored when found.
83 for (size_t i = input.size(); i--;) { 84 for (size_t i = input.size(); i--;) {
84 const CSSProperty& property = input[i]; 85 const CSSProperty& property = input[i];
85 if (property.isImportant() != important) 86 if (property.isImportant() != important)
86 continue; 87 continue;
87 const unsigned propertyIDIndex = property.id() - firstCSSProperty; 88 const unsigned propertyIDIndex = property.id() - firstCSSProperty;
88 89
89 if (property.id() == CSSPropertyVariable) { 90 if (property.id() == CSSPropertyVariable) {
90 const AtomicString& name = 91 const AtomicString& name =
91 toCSSCustomPropertyDeclaration(property.value())->name(); 92 toCSSCustomPropertyDeclaration(property.value())->name();
92 if (seenCustomProperties.contains(name)) 93 if (seenCustomProperties.contains(name))
(...skipping 329 matching lines...)
422 consumeApplyRule(prelude); 423 consumeApplyRule(prelude);
423 return nullptr; // consumeApplyRule just updates m_parsedProperties 424 return nullptr; // consumeApplyRule just updates m_parsedProperties
424 } 425 }
425 return nullptr; // Parse error, unrecognised at-rule without block 426 return nullptr; // Parse error, unrecognised at-rule without block
426 } 427 }
427 428
428 CSSParserTokenRange block = range.consumeBlock(); 429 CSSParserTokenRange block = range.consumeBlock();
429 if (allowedRules == KeyframeRules) 430 if (allowedRules == KeyframeRules)
430 return nullptr; // Parse error, no at-rules supported inside @keyframes 431 return nullptr; // Parse error, no at-rules supported inside @keyframes
431 if (allowedRules == NoRules || allowedRules == ApplyRules) 432 if (allowedRules == NoRules || allowedRules == ApplyRules)
432 return nullptr; // Parse error, no at-rules with blocks supported inside de claration lists 433 return nullptr; // Parse error, no at-rules with blocks supported inside
434 // declaration lists
433 435
434 ASSERT(allowedRules <= RegularRules); 436 ASSERT(allowedRules <= RegularRules);
435 437
436 switch (id) { 438 switch (id) {
437 case CSSAtRuleMedia: 439 case CSSAtRuleMedia:
438 return consumeMediaRule(prelude, block); 440 return consumeMediaRule(prelude, block);
439 case CSSAtRuleSupports: 441 case CSSAtRuleSupports:
440 return consumeSupportsRule(prelude, block); 442 return consumeSupportsRule(prelude, block);
441 case CSSAtRuleViewport: 443 case CSSAtRuleViewport:
442 return consumeViewportRule(prelude, block); 444 return consumeViewportRule(prelude, block);
(...skipping 195 matching lines...)
638 createStylePropertySet(m_parsedProperties, CSSFontFaceRuleMode)); 640 createStylePropertySet(m_parsedProperties, CSSFontFaceRuleMode));
639 } 641 }
640 642
641 StyleRuleKeyframes* CSSParserImpl::consumeKeyframesRule( 643 StyleRuleKeyframes* CSSParserImpl::consumeKeyframesRule(
642 bool webkitPrefixed, 644 bool webkitPrefixed,
643 CSSParserTokenRange prelude, 645 CSSParserTokenRange prelude,
644 CSSParserTokenRange block) { 646 CSSParserTokenRange block) {
645 CSSParserTokenRange rangeCopy = prelude; // For inspector callbacks 647 CSSParserTokenRange rangeCopy = prelude; // For inspector callbacks
646 const CSSParserToken& nameToken = prelude.consumeIncludingWhitespace(); 648 const CSSParserToken& nameToken = prelude.consumeIncludingWhitespace();
647 if (!prelude.atEnd()) 649 if (!prelude.atEnd())
648 return nullptr; // Parse error; expected single non-whitespace token in @ke yframes header 650 return nullptr; // Parse error; expected single non-whitespace token in
651 // @keyframes header
649 652
650 String name; 653 String name;
651 if (nameToken.type() == IdentToken) { 654 if (nameToken.type() == IdentToken) {
652 name = nameToken.value().toString(); 655 name = nameToken.value().toString();
653 } else if (nameToken.type() == StringToken && webkitPrefixed) { 656 } else if (nameToken.type() == StringToken && webkitPrefixed) {
654 if (m_context.useCounter()) 657 if (m_context.useCounter())
655 m_context.useCounter()->count(UseCounter::QuotedKeyframesRule); 658 m_context.useCounter()->count(UseCounter::QuotedKeyframesRule);
656 name = nameToken.value().toString(); 659 name = nameToken.value().toString();
657 } else { 660 } else {
658 return nullptr; // Parse error; expected ident token in @keyframes header 661 return nullptr; // Parse error; expected ident token in @keyframes header
(...skipping 262 matching lines...)
921 else 924 else
922 return nullptr; // Parser error, invalid value in keyframe selector 925 return nullptr; // Parser error, invalid value in keyframe selector
923 if (range.atEnd()) 926 if (range.atEnd())
924 return result; 927 return result;
925 if (range.consume().type() != CommaToken) 928 if (range.consume().type() != CommaToken)
926 return nullptr; // Parser error 929 return nullptr; // Parser error
927 } 930 }
928 } 931 }
929 932
930 } // namespace blink 933 } // namespace blink
OLDNEW

Powered by Google App Engine