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

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

Issue 840163003: Make SelectorChecker a const operation over element. (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
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 25 matching lines...) Expand all
36 #include "sky/engine/core/dom/shadow/ShadowRoot.h" 36 #include "sky/engine/core/dom/shadow/ShadowRoot.h"
37 #include "sky/engine/core/rendering/style/RenderStyle.h" 37 #include "sky/engine/core/rendering/style/RenderStyle.h"
38 #include "sky/engine/core/rendering/style/StyleInheritedData.h" 38 #include "sky/engine/core/rendering/style/StyleInheritedData.h"
39 39
40 namespace blink { 40 namespace blink {
41 41
42 ElementRuleCollector::ElementRuleCollector(const ElementResolveContext& context, 42 ElementRuleCollector::ElementRuleCollector(const ElementResolveContext& context,
43 RenderStyle* style) 43 RenderStyle* style)
44 : m_context(context) 44 : m_context(context)
45 , m_style(style) 45 , m_style(style)
46 , m_mode(SelectorChecker::ResolvingStyle)
47 , m_matchingUARules(false) 46 , m_matchingUARules(false)
48 { } 47 { }
49 48
50 ElementRuleCollector::~ElementRuleCollector() 49 ElementRuleCollector::~ElementRuleCollector()
51 { 50 {
52 } 51 }
53 52
54 MatchResult& ElementRuleCollector::matchedResult() 53 MatchResult& ElementRuleCollector::matchedResult()
55 { 54 {
56 return m_result; 55 return m_result;
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
124 123
125 // Now transfer the set of matched rules over to our list of declarations. 124 // Now transfer the set of matched rules over to our list of declarations.
126 for (unsigned i = 0; i < matchedRules.size(); i++) { 125 for (unsigned i = 0; i < matchedRules.size(); i++) {
127 const RuleData* ruleData = matchedRules[i].ruleData(); 126 const RuleData* ruleData = matchedRules[i].ruleData();
128 m_result.addMatchedProperties(&ruleData->rule()->properties()); 127 m_result.addMatchedProperties(&ruleData->rule()->properties());
129 } 128 }
130 } 129 }
131 130
132 inline bool ElementRuleCollector::ruleMatches(const RuleData& ruleData, const Co ntainerNode* scope) 131 inline bool ElementRuleCollector::ruleMatches(const RuleData& ruleData, const Co ntainerNode* scope)
133 { 132 {
134 SelectorChecker selectorChecker(m_context.element()->document(), m_mode); 133 SelectorChecker selectorChecker;
135 SelectorChecker::SelectorCheckingContext context(ruleData.selector(), m_cont ext.element()); 134 SelectorChecker::SelectorCheckingContext context(ruleData.selector(), m_cont ext.element());
136 context.elementStyle = m_style.get();
137 context.scope = scope; 135 context.scope = scope;
138 return selectorChecker.match(context); 136 if (selectorChecker.match(context)) {
137 if (selectorChecker.matchedAttributeSelector())
138 m_style->setUnique();
139 if (selectorChecker.matchedFocusSelector())
140 m_style->setAffectedByFocus();
141 if (selectorChecker.matchedHoverSelector())
142 m_style->setAffectedByHover();
143 if (selectorChecker.matchedActiveSelector())
144 m_style->setAffectedByActive();
145 return true;
146 }
147 return false;
139 } 148 }
140 149
141 void ElementRuleCollector::collectRuleIfMatches(const RuleData& ruleData, Cascad eScope cascadeScope, CascadeOrder cascadeOrder, const MatchRequest& matchRequest , RuleRange& ruleRange) 150 void ElementRuleCollector::collectRuleIfMatches(const RuleData& ruleData, Cascad eScope cascadeScope, CascadeOrder cascadeOrder, const MatchRequest& matchRequest , RuleRange& ruleRange)
142 { 151 {
143 StyleRule* rule = ruleData.rule(); 152 StyleRule* rule = ruleData.rule();
144 if (ruleMatches(ruleData, matchRequest.scope)) { 153 if (ruleMatches(ruleData, matchRequest.scope)) {
145 // If the rule has no properties to apply, then ignore it in the non-deb ug mode. 154 // If the rule has no properties to apply, then ignore it in the non-deb ug mode.
146 const StylePropertySet& properties = rule->properties(); 155 const StylePropertySet& properties = rule->properties();
147 if (properties.isEmpty()) 156 if (properties.isEmpty())
148 return; 157 return;
(...skipping 16 matching lines...) Expand all
165 return matchedRule1.position() < matchedRule2.position(); 174 return matchedRule1.position() < matchedRule2.position();
166 } 175 }
167 176
168 void ElementRuleCollector::sortMatchedRules() 177 void ElementRuleCollector::sortMatchedRules()
169 { 178 {
170 ASSERT(m_matchedRules); 179 ASSERT(m_matchedRules);
171 std::sort(m_matchedRules->begin(), m_matchedRules->end(), compareRules); 180 std::sort(m_matchedRules->begin(), m_matchedRules->end(), compareRules);
172 } 181 }
173 182
174 } // namespace blink 183 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698