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

Side by Side Diff: sky/engine/core/css/ElementRuleCollector.cpp

Issue 838863002: Remove SelectorChecker::ContextFlags. (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 5 years, 11 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
« no previous file with comments | « sky/engine/core/css/ElementRuleCollector.h ('k') | sky/engine/core/css/SelectorChecker.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org)
3 * (C) 2004-2005 Allan Sandfeld Jensen (kde@carewolf.com) 3 * (C) 2004-2005 Allan Sandfeld Jensen (kde@carewolf.com)
4 * Copyright (C) 2006, 2007 Nicholas Shanks (webkit@nickshanks.com) 4 * Copyright (C) 2006, 2007 Nicholas Shanks (webkit@nickshanks.com)
5 * Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013 Apple Inc. All rights reserved. 5 * Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013 Apple Inc. All rights reserved.
6 * Copyright (C) 2007 Alexey Proskuryakov <ap@webkit.org> 6 * Copyright (C) 2007 Alexey Proskuryakov <ap@webkit.org>
7 * Copyright (C) 2007, 2008 Eric Seidel <eric@webkit.org> 7 * Copyright (C) 2007, 2008 Eric Seidel <eric@webkit.org>
8 * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. (http://www.t orchmobile.com/) 8 * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. (http://www.t orchmobile.com/)
9 * Copyright (c) 2011, Code Aurora Forum. All rights reserved. 9 * Copyright (c) 2011, Code Aurora Forum. All rights reserved.
10 * Copyright (C) Research In Motion Limited 2011. All rights reserved. 10 * Copyright (C) Research In Motion Limited 2011. All rights reserved.
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
83 } 83 }
84 84
85 static bool rulesApplicableInCurrentTreeScope(const Element* element, const Cont ainerNode* scopingNode) 85 static bool rulesApplicableInCurrentTreeScope(const Element* element, const Cont ainerNode* scopingNode)
86 { 86 {
87 TreeScope& treeScope = element->treeScope(); 87 TreeScope& treeScope = element->treeScope();
88 return !scopingNode || 88 return !scopingNode ||
89 treeScope == scopingNode->treeScope() || 89 treeScope == scopingNode->treeScope() ||
90 SelectorChecker::isHostInItsShadowTree(*element, scopingNode); 90 SelectorChecker::isHostInItsShadowTree(*element, scopingNode);
91 } 91 }
92 92
93 void ElementRuleCollector::collectMatchingRules(const MatchRequest& matchRequest , RuleRange& ruleRange, SelectorChecker::ContextFlags contextFlags, CascadeScope cascadeScope, CascadeOrder cascadeOrder) 93 void ElementRuleCollector::collectMatchingRules(const MatchRequest& matchRequest , RuleRange& ruleRange, CascadeScope cascadeScope, CascadeOrder cascadeOrder)
94 { 94 {
95 ASSERT(matchRequest.ruleSet); 95 ASSERT(matchRequest.ruleSet);
96 ASSERT(m_context.element()); 96 ASSERT(m_context.element());
97 97
98 Element& element = *m_context.element(); 98 Element& element = *m_context.element();
99 99
100 if (!m_matchingUARules && !rulesApplicableInCurrentTreeScope(&element, match Request.scope)) 100 if (!m_matchingUARules && !rulesApplicableInCurrentTreeScope(&element, match Request.scope))
101 return; 101 return;
102 102
103 // We need to collect the rules for id, class, tag, and everything else into a buffer and 103 // We need to collect the rules for id, class, tag, and everything else into a buffer and
104 // then sort the buffer. 104 // then sort the buffer.
105 if (element.hasID()) 105 if (element.hasID())
106 collectMatchingRulesForList(matchRequest.ruleSet->idRules(element.idForS tyleResolution()), contextFlags, cascadeScope, cascadeOrder, matchRequest, ruleR ange); 106 collectMatchingRulesForList(matchRequest.ruleSet->idRules(element.idForS tyleResolution()), cascadeScope, cascadeOrder, matchRequest, ruleRange);
107 if (element.isStyledElement() && element.hasClass()) { 107 if (element.isStyledElement() && element.hasClass()) {
108 for (size_t i = 0; i < element.classNames().size(); ++i) 108 for (size_t i = 0; i < element.classNames().size(); ++i)
109 collectMatchingRulesForList(matchRequest.ruleSet->classRules(element .classNames()[i]), contextFlags, cascadeScope, cascadeOrder, matchRequest, ruleR ange); 109 collectMatchingRulesForList(matchRequest.ruleSet->classRules(element .classNames()[i]), cascadeScope, cascadeOrder, matchRequest, ruleRange);
110 } 110 }
111 111
112 collectMatchingRulesForList(matchRequest.ruleSet->tagRules(element.localName ()), contextFlags, cascadeScope, cascadeOrder, matchRequest, ruleRange); 112 collectMatchingRulesForList(matchRequest.ruleSet->tagRules(element.localName ()), cascadeScope, cascadeOrder, matchRequest, ruleRange);
113 collectMatchingRulesForList(matchRequest.ruleSet->universalRules(), contextF lags, cascadeScope, cascadeOrder, matchRequest, ruleRange); 113 collectMatchingRulesForList(matchRequest.ruleSet->universalRules(), cascadeS cope, cascadeOrder, matchRequest, ruleRange);
114 } 114 }
115 115
116 void ElementRuleCollector::sortAndTransferMatchedRules() 116 void ElementRuleCollector::sortAndTransferMatchedRules()
117 { 117 {
118 if (!m_matchedRules || m_matchedRules->isEmpty()) 118 if (!m_matchedRules || m_matchedRules->isEmpty())
119 return; 119 return;
120 120
121 sortMatchedRules(); 121 sortMatchedRules();
122 122
123 Vector<MatchedRule, 32>& matchedRules = *m_matchedRules; 123 Vector<MatchedRule, 32>& matchedRules = *m_matchedRules;
124 124
125 // Now transfer the set of matched rules over to our list of declarations. 125 // Now transfer the set of matched rules over to our list of declarations.
126 for (unsigned i = 0; i < matchedRules.size(); i++) { 126 for (unsigned i = 0; i < matchedRules.size(); i++) {
127 const RuleData* ruleData = matchedRules[i].ruleData(); 127 const RuleData* ruleData = matchedRules[i].ruleData();
128 m_result.addMatchedProperties(&ruleData->rule()->properties()); 128 m_result.addMatchedProperties(&ruleData->rule()->properties());
129 } 129 }
130 } 130 }
131 131
132 inline bool ElementRuleCollector::ruleMatches(const RuleData& ruleData, const Co ntainerNode* scope, SelectorChecker::ContextFlags contextFlags) 132 inline bool ElementRuleCollector::ruleMatches(const RuleData& ruleData, const Co ntainerNode* scope)
133 { 133 {
134 SelectorChecker selectorChecker(m_context.element()->document(), m_mode); 134 SelectorChecker selectorChecker(m_context.element()->document(), m_mode);
135 SelectorChecker::SelectorCheckingContext context(ruleData.selector(), m_cont ext.element()); 135 SelectorChecker::SelectorCheckingContext context(ruleData.selector(), m_cont ext.element());
136 context.elementStyle = m_style.get(); 136 context.elementStyle = m_style.get();
137 context.scope = scope; 137 context.scope = scope;
138 context.contextFlags = contextFlags;
139 return selectorChecker.match(context); 138 return selectorChecker.match(context);
140 } 139 }
141 140
142 void ElementRuleCollector::collectRuleIfMatches(const RuleData& ruleData, Select orChecker::ContextFlags contextFlags, CascadeScope cascadeScope, CascadeOrder ca scadeOrder, const MatchRequest& matchRequest, RuleRange& ruleRange) 141 void ElementRuleCollector::collectRuleIfMatches(const RuleData& ruleData, Cascad eScope cascadeScope, CascadeOrder cascadeOrder, const MatchRequest& matchRequest , RuleRange& ruleRange)
143 { 142 {
144 StyleRule* rule = ruleData.rule(); 143 StyleRule* rule = ruleData.rule();
145 if (ruleMatches(ruleData, matchRequest.scope, contextFlags)) { 144 if (ruleMatches(ruleData, matchRequest.scope)) {
146 // If the rule has no properties to apply, then ignore it in the non-deb ug mode. 145 // If the rule has no properties to apply, then ignore it in the non-deb ug mode.
147 const StylePropertySet& properties = rule->properties(); 146 const StylePropertySet& properties = rule->properties();
148 if (properties.isEmpty() && !matchRequest.includeEmptyRules) 147 if (properties.isEmpty() && !matchRequest.includeEmptyRules)
149 return; 148 return;
150 149
151 // Update our first/last rule indices in the matched rules array. 150 // Update our first/last rule indices in the matched rules array.
152 ++ruleRange.lastRuleIndex; 151 ++ruleRange.lastRuleIndex;
153 if (ruleRange.firstRuleIndex == -1) 152 if (ruleRange.firstRuleIndex == -1)
154 ruleRange.firstRuleIndex = ruleRange.lastRuleIndex; 153 ruleRange.firstRuleIndex = ruleRange.lastRuleIndex;
155 154
(...skipping 10 matching lines...) Expand all
166 return matchedRule1.position() < matchedRule2.position(); 165 return matchedRule1.position() < matchedRule2.position();
167 } 166 }
168 167
169 void ElementRuleCollector::sortMatchedRules() 168 void ElementRuleCollector::sortMatchedRules()
170 { 169 {
171 ASSERT(m_matchedRules); 170 ASSERT(m_matchedRules);
172 std::sort(m_matchedRules->begin(), m_matchedRules->end(), compareRules); 171 std::sort(m_matchedRules->begin(), m_matchedRules->end(), compareRules);
173 } 172 }
174 173
175 } // namespace blink 174 } // namespace blink
OLDNEW
« no previous file with comments | « sky/engine/core/css/ElementRuleCollector.h ('k') | sky/engine/core/css/SelectorChecker.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698