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

Side by Side Diff: Source/core/css/parser/CSSSelectorParser.cpp

Issue 1149913008: Compute the linkMatchType inside the CSSSelectorParser. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Do it inside consumeComplexSelector. Created 5 years, 6 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 | Annotate | Revision Log
« no previous file with comments | « Source/core/css/parser/CSSParserValues.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "config.h" 5 #include "config.h"
6 #include "core/css/parser/CSSSelectorParser.h" 6 #include "core/css/parser/CSSSelectorParser.h"
7 7
8 #include "core/css/CSSSelectorList.h" 8 #include "core/css/CSSSelectorList.h"
9 #include "core/css/StyleSheetContents.h" 9 #include "core/css/StyleSheetContents.h"
10 #include "core/frame/UseCounter.h" 10 #include "core/frame/UseCounter.h"
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
122 output.adoptSelectorVector(selectorList); 122 output.adoptSelectorVector(selectorList);
123 } 123 }
124 124
125 PassOwnPtr<CSSParserSelector> CSSSelectorParser::consumeComplexSelector(CSSParse rTokenRange& range) 125 PassOwnPtr<CSSParserSelector> CSSSelectorParser::consumeComplexSelector(CSSParse rTokenRange& range)
126 { 126 {
127 OwnPtr<CSSParserSelector> selector = consumeCompoundSelector(range); 127 OwnPtr<CSSParserSelector> selector = consumeCompoundSelector(range);
128 if (!selector) 128 if (!selector)
129 return nullptr; 129 return nullptr;
130 while (CSSSelector::Relation combinator = consumeCombinator(range)) { 130 while (CSSSelector::Relation combinator = consumeCombinator(range)) {
131 OwnPtr<CSSParserSelector> nextSelector = consumeCompoundSelector(range); 131 OwnPtr<CSSParserSelector> nextSelector = consumeCompoundSelector(range);
132 if (!nextSelector) 132 if (!nextSelector) {
133 return combinator == CSSSelector::Descendant ? selector.release() : nullptr; 133 if (combinator != CSSSelector::Descendant)
134 return nullptr;
135 break;
136 }
134 CSSParserSelector* end = nextSelector.get(); 137 CSSParserSelector* end = nextSelector.get();
135 while (end->tagHistory()) 138 while (end->tagHistory())
136 end = end->tagHistory(); 139 end = end->tagHistory();
137 end->setRelation(combinator); 140 end->setRelation(combinator);
138 if (selector->pseudoType() == CSSSelector::PseudoContent) 141 if (selector->pseudoType() == CSSSelector::PseudoContent)
139 end->setRelationIsAffectedByPseudoContent(); 142 end->setRelationIsAffectedByPseudoContent();
140 end->setTagHistory(selector.release()); 143 end->setTagHistory(selector.release());
141 144
142 selector = nextSelector.release(); 145 selector = nextSelector.release();
143 } 146 }
144 147
148 selector->updateLinkMatchType();
145 return selector.release(); 149 return selector.release();
146 } 150 }
147 151
148 PassOwnPtr<CSSParserSelector> CSSSelectorParser::consumeCompoundSelector(CSSPars erTokenRange& range) 152 PassOwnPtr<CSSParserSelector> CSSSelectorParser::consumeCompoundSelector(CSSPars erTokenRange& range)
149 { 153 {
150 OwnPtr<CSSParserSelector> compoundSelector; 154 OwnPtr<CSSParserSelector> compoundSelector;
151 155
152 AtomicString namespacePrefix; 156 AtomicString namespacePrefix;
153 AtomicString elementName; 157 AtomicString elementName;
154 bool hasNamespace; 158 bool hasNamespace;
(...skipping 507 matching lines...) Expand 10 before | Expand all | Expand 10 after
662 compoundSelector->insertTagHistory(CSSSelector::SubSelector, simpleSelec tor, relation); 666 compoundSelector->insertTagHistory(CSSSelector::SubSelector, simpleSelec tor, relation);
663 return compoundSelector; 667 return compoundSelector;
664 } 668 }
665 669
666 // All other simple selectors are added to the end of the compound. 670 // All other simple selectors are added to the end of the compound.
667 compoundSelector->appendTagHistory(CSSSelector::SubSelector, simpleSelector) ; 671 compoundSelector->appendTagHistory(CSSSelector::SubSelector, simpleSelector) ;
668 return compoundSelector; 672 return compoundSelector;
669 } 673 }
670 674
671 } // namespace blink 675 } // namespace blink
OLDNEW
« no previous file with comments | « Source/core/css/parser/CSSParserValues.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698