Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(462)

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

Issue 1729013002: blink: Rename enums and functions to not collide with chromium style. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: get-names-3: . Created 4 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
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/CSSCustomPropertyDeclaration.h" 7 #include "core/css/CSSCustomPropertyDeclaration.h"
8 #include "core/css/CSSKeyframesRule.h" 8 #include "core/css/CSSKeyframesRule.h"
9 #include "core/css/CSSStyleSheet.h" 9 #include "core/css/CSSStyleSheet.h"
10 #include "core/css/StylePropertySet.h" 10 #include "core/css/StylePropertySet.h"
(...skipping 23 matching lines...) Expand all
34 CSSParserImpl::CSSParserImpl(const CSSParserContext& context, StyleSheetContents * styleSheet) 34 CSSParserImpl::CSSParserImpl(const CSSParserContext& context, StyleSheetContents * styleSheet)
35 : m_context(context) 35 : m_context(context)
36 , m_styleSheet(styleSheet) 36 , m_styleSheet(styleSheet)
37 , m_observerWrapper(nullptr) 37 , m_observerWrapper(nullptr)
38 { 38 {
39 } 39 }
40 40
41 bool CSSParserImpl::parseValue(MutableStylePropertySet* declaration, CSSProperty ID unresolvedProperty, const String& string, bool important, const CSSParserCont ext& context) 41 bool CSSParserImpl::parseValue(MutableStylePropertySet* declaration, CSSProperty ID unresolvedProperty, const String& string, bool important, const CSSParserCont ext& context)
42 { 42 {
43 CSSParserImpl parser(context); 43 CSSParserImpl parser(context);
44 StyleRule::Type ruleType = StyleRule::Style; 44 StyleRule::RuleType ruleType = StyleRule::Style;
45 if (declaration->cssParserMode() == CSSViewportRuleMode) 45 if (declaration->cssParserMode() == CSSViewportRuleMode)
46 ruleType = StyleRule::Viewport; 46 ruleType = StyleRule::Viewport;
47 CSSTokenizer::Scope scope(string); 47 CSSTokenizer::Scope scope(string);
48 parser.consumeDeclarationValue(scope.tokenRange(), unresolvedProperty, impor tant, ruleType); 48 parser.consumeDeclarationValue(scope.tokenRange(), unresolvedProperty, impor tant, ruleType);
49 if (parser.m_parsedProperties.isEmpty()) 49 if (parser.m_parsedProperties.isEmpty())
50 return false; 50 return false;
51 return declaration->addParsedProperties(parser.m_parsedProperties); 51 return declaration->addParsedProperties(parser.m_parsedProperties);
52 } 52 }
53 53
54 bool CSSParserImpl::parseVariableValue(MutableStylePropertySet* declaration, con st AtomicString& propertyName, const String& value, bool important, const CSSPar serContext& context) 54 bool CSSParserImpl::parseVariableValue(MutableStylePropertySet* declaration, con st AtomicString& propertyName, const String& value, bool important, const CSSPar serContext& context)
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
107 context.setMode(mode); 107 context.setMode(mode);
108 CSSParserImpl parser(context, document.elementSheet().contents()); 108 CSSParserImpl parser(context, document.elementSheet().contents());
109 CSSTokenizer::Scope scope(string); 109 CSSTokenizer::Scope scope(string);
110 parser.consumeDeclarationList(scope.tokenRange(), StyleRule::Style); 110 parser.consumeDeclarationList(scope.tokenRange(), StyleRule::Style);
111 return createStylePropertySet(parser.m_parsedProperties, mode); 111 return createStylePropertySet(parser.m_parsedProperties, mode);
112 } 112 }
113 113
114 bool CSSParserImpl::parseDeclarationList(MutableStylePropertySet* declaration, c onst String& string, const CSSParserContext& context) 114 bool CSSParserImpl::parseDeclarationList(MutableStylePropertySet* declaration, c onst String& string, const CSSParserContext& context)
115 { 115 {
116 CSSParserImpl parser(context); 116 CSSParserImpl parser(context);
117 StyleRule::Type ruleType = StyleRule::Style; 117 StyleRule::RuleType ruleType = StyleRule::Style;
118 if (declaration->cssParserMode() == CSSViewportRuleMode) 118 if (declaration->cssParserMode() == CSSViewportRuleMode)
119 ruleType = StyleRule::Viewport; 119 ruleType = StyleRule::Viewport;
120 CSSTokenizer::Scope scope(string); 120 CSSTokenizer::Scope scope(string);
121 parser.consumeDeclarationList(scope.tokenRange(), ruleType); 121 parser.consumeDeclarationList(scope.tokenRange(), ruleType);
122 if (parser.m_parsedProperties.isEmpty()) 122 if (parser.m_parsedProperties.isEmpty())
123 return false; 123 return false;
124 124
125 BitArray<numCSSProperties> seenProperties; 125 BitArray<numCSSProperties> seenProperties;
126 size_t unusedEntries = parser.m_parsedProperties.size(); 126 size_t unusedEntries = parser.m_parsedProperties.size();
127 WillBeHeapVector<CSSProperty, 256> results(unusedEntries); 127 WillBeHeapVector<CSSProperty, 256> results(unusedEntries);
(...skipping 517 matching lines...) Expand 10 before | Expand all | Expand 10 after
645 return nullptr; // Parse error, invalid selector list 645 return nullptr; // Parse error, invalid selector list
646 646
647 if (m_observerWrapper) 647 if (m_observerWrapper)
648 observeSelectors(*m_observerWrapper, prelude); 648 observeSelectors(*m_observerWrapper, prelude);
649 649
650 consumeDeclarationList(block, StyleRule::Style); 650 consumeDeclarationList(block, StyleRule::Style);
651 651
652 return StyleRule::create(std::move(selectorList), createStylePropertySet(m_p arsedProperties, m_context.mode())); 652 return StyleRule::create(std::move(selectorList), createStylePropertySet(m_p arsedProperties, m_context.mode()));
653 } 653 }
654 654
655 void CSSParserImpl::consumeDeclarationList(CSSParserTokenRange range, StyleRule: :Type ruleType) 655 void CSSParserImpl::consumeDeclarationList(CSSParserTokenRange range, StyleRule: :RuleType ruleType)
656 { 656 {
657 ASSERT(m_parsedProperties.isEmpty()); 657 ASSERT(m_parsedProperties.isEmpty());
658 658
659 bool useObserver = m_observerWrapper && (ruleType == StyleRule::Style || rul eType == StyleRule::Keyframe); 659 bool useObserver = m_observerWrapper && (ruleType == StyleRule::Style || rul eType == StyleRule::Keyframe);
660 if (useObserver) { 660 if (useObserver) {
661 m_observerWrapper->observer().startRuleBody(m_observerWrapper->previousT okenStartOffset(range)); 661 m_observerWrapper->observer().startRuleBody(m_observerWrapper->previousT okenStartOffset(range));
662 m_observerWrapper->skipCommentsBefore(range, true); 662 m_observerWrapper->skipCommentsBefore(range, true);
663 } 663 }
664 664
665 while (!range.atEnd()) { 665 while (!range.atEnd()) {
(...skipping 29 matching lines...) Expand all
695 } 695 }
696 } 696 }
697 697
698 // Yield remaining comments 698 // Yield remaining comments
699 if (useObserver) { 699 if (useObserver) {
700 m_observerWrapper->yieldCommentsBefore(range); 700 m_observerWrapper->yieldCommentsBefore(range);
701 m_observerWrapper->observer().endRuleBody(m_observerWrapper->endOffset(r ange)); 701 m_observerWrapper->observer().endRuleBody(m_observerWrapper->endOffset(r ange));
702 } 702 }
703 } 703 }
704 704
705 void CSSParserImpl::consumeDeclaration(CSSParserTokenRange range, StyleRule::Typ e ruleType) 705 void CSSParserImpl::consumeDeclaration(CSSParserTokenRange range, StyleRule::Rul eType ruleType)
706 { 706 {
707 CSSParserTokenRange rangeCopy = range; // For inspector callbacks 707 CSSParserTokenRange rangeCopy = range; // For inspector callbacks
708 708
709 ASSERT(range.peek().type() == IdentToken); 709 ASSERT(range.peek().type() == IdentToken);
710 const CSSParserToken& token = range.consumeIncludingWhitespace(); 710 const CSSParserToken& token = range.consumeIncludingWhitespace();
711 CSSPropertyID unresolvedProperty = token.parseAsUnresolvedCSSPropertyID(); 711 CSSPropertyID unresolvedProperty = token.parseAsUnresolvedCSSPropertyID();
712 if (range.consume().type() != ColonToken) 712 if (range.consume().type() != ColonToken)
713 return; // Parse error 713 return; // Parse error
714 714
715 bool important = false; 715 bool important = false;
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
748 important, m_parsedProperties.size() != propertiesCount); 748 important, m_parsedProperties.size() != propertiesCount);
749 } 749 }
750 } 750 }
751 751
752 void CSSParserImpl::consumeVariableValue(CSSParserTokenRange range, const Atomic String& variableName, bool important) 752 void CSSParserImpl::consumeVariableValue(CSSParserTokenRange range, const Atomic String& variableName, bool important)
753 { 753 {
754 if (RefPtrWillBeRawPtr<CSSCustomPropertyDeclaration> value = CSSVariablePars er::parseDeclarationValue(variableName, range)) 754 if (RefPtrWillBeRawPtr<CSSCustomPropertyDeclaration> value = CSSVariablePars er::parseDeclarationValue(variableName, range))
755 m_parsedProperties.append(CSSProperty(CSSPropertyVariable, value.release (), important)); 755 m_parsedProperties.append(CSSProperty(CSSPropertyVariable, value.release (), important));
756 } 756 }
757 757
758 void CSSParserImpl::consumeDeclarationValue(CSSParserTokenRange range, CSSProper tyID unresolvedProperty, bool important, StyleRule::Type ruleType) 758 void CSSParserImpl::consumeDeclarationValue(CSSParserTokenRange range, CSSProper tyID unresolvedProperty, bool important, StyleRule::RuleType ruleType)
759 { 759 {
760 CSSPropertyParser::parseValue(unresolvedProperty, important, range, m_contex t, m_parsedProperties, ruleType); 760 CSSPropertyParser::parseValue(unresolvedProperty, important, range, m_contex t, m_parsedProperties, ruleType);
761 } 761 }
762 762
763 PassOwnPtr<Vector<double>> CSSParserImpl::consumeKeyframeKeyList(CSSParserTokenR ange range) 763 PassOwnPtr<Vector<double>> CSSParserImpl::consumeKeyframeKeyList(CSSParserTokenR ange range)
764 { 764 {
765 OwnPtr<Vector<double>> result = adoptPtr(new Vector<double>); 765 OwnPtr<Vector<double>> result = adoptPtr(new Vector<double>);
766 while (true) { 766 while (true) {
767 range.consumeWhitespace(); 767 range.consumeWhitespace();
768 const CSSParserToken& token = range.consumeIncludingWhitespace(); 768 const CSSParserToken& token = range.consumeIncludingWhitespace();
769 if (token.type() == PercentageToken && token.numericValue() >= 0 && toke n.numericValue() <= 100) 769 if (token.type() == PercentageToken && token.numericValue() >= 0 && toke n.numericValue() <= 100)
770 result->append(token.numericValue() / 100); 770 result->append(token.numericValue() / 100);
771 else if (token.type() == IdentToken && token.valueEqualsIgnoringASCIICas e("from")) 771 else if (token.type() == IdentToken && token.valueEqualsIgnoringASCIICas e("from"))
772 result->append(0); 772 result->append(0);
773 else if (token.type() == IdentToken && token.valueEqualsIgnoringASCIICas e("to")) 773 else if (token.type() == IdentToken && token.valueEqualsIgnoringASCIICas e("to"))
774 result->append(1); 774 result->append(1);
775 else 775 else
776 return nullptr; // Parser error, invalid value in keyframe selector 776 return nullptr; // Parser error, invalid value in keyframe selector
777 if (range.atEnd()) 777 if (range.atEnd())
778 return result.release(); 778 return result.release();
779 if (range.consume().type() != CommaToken) 779 if (range.consume().type() != CommaToken)
780 return nullptr; // Parser error 780 return nullptr; // Parser error
781 } 781 }
782 } 782 }
783 783
784 } // namespace blink 784 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698