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

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

Issue 838313002: Move StyleResolver code out of ScopedStyleResolver. (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/RuleSet.h ('k') | sky/engine/core/css/StyleSheetContents.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 Apple Inc. All r ights reserved. 5 * Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012 Apple Inc. All r ights 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/css/SelectorChecker.h" 36 #include "sky/engine/core/css/SelectorChecker.h"
37 #include "sky/engine/core/css/StyleRuleKeyframes.h" 37 #include "sky/engine/core/css/StyleRuleKeyframes.h"
38 #include "sky/engine/core/css/StyleSheetContents.h" 38 #include "sky/engine/core/css/StyleSheetContents.h"
39 #include "sky/engine/platform/TraceEvent.h" 39 #include "sky/engine/platform/TraceEvent.h"
40 #include "sky/engine/wtf/TerminatedArrayBuilder.h" 40 #include "sky/engine/wtf/TerminatedArrayBuilder.h"
41 41
42 namespace blink { 42 namespace blink {
43 43
44 // ----------------------------------------------------------------- 44 // -----------------------------------------------------------------
45 45
46 RuleData::RuleData(StyleRule* rule, unsigned selectorIndex, unsigned position, A ddRuleFlags addRuleFlags) 46 RuleData::RuleData(StyleRule* rule, unsigned selectorIndex, unsigned position)
47 : m_rule(rule) 47 : m_rule(rule)
48 , m_selectorIndex(selectorIndex) 48 , m_selectorIndex(selectorIndex)
49 , m_isLastInArray(false) 49 , m_isLastInArray(false)
50 , m_position(position) 50 , m_position(position)
51 { 51 {
52 ASSERT(m_position == position); 52 ASSERT(m_position == position);
53 ASSERT(m_selectorIndex == selectorIndex); 53 ASSERT(m_selectorIndex == selectorIndex);
54 } 54 }
55 55
56 void RuleSet::addToRuleSet(const AtomicString& key, PendingRuleMap& map, const R uleData& ruleData) 56 void RuleSet::addToRuleSet(const AtomicString& key, PendingRuleMap& map, const R uleData& ruleData)
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
119 } 119 }
120 120
121 if (!tagName.isEmpty()) { 121 if (!tagName.isEmpty()) {
122 addToRuleSet(tagName, ensurePendingRules()->tagRules, ruleData); 122 addToRuleSet(tagName, ensurePendingRules()->tagRules, ruleData);
123 return true; 123 return true;
124 } 124 }
125 125
126 return false; 126 return false;
127 } 127 }
128 128
129 void RuleSet::addRule(StyleRule* rule, unsigned selectorIndex, AddRuleFlags addR uleFlags) 129 void RuleSet::addRule(StyleRule* rule, unsigned selectorIndex)
130 { 130 {
131 RuleData ruleData(rule, selectorIndex, m_ruleCount++, addRuleFlags); 131 RuleData ruleData(rule, selectorIndex, m_ruleCount++);
132 m_features.collectFeaturesFromSelector(ruleData.selector()); 132 m_features.collectFeaturesFromSelector(ruleData.selector());
133 133
134 if (!findBestRuleSetAndAdd(ruleData.selector(), ruleData)) { 134 if (!findBestRuleSetAndAdd(ruleData.selector(), ruleData)) {
135 // If we didn't find a specialized map to stick it in, file under univer sal rules. 135 // If we didn't find a specialized map to stick it in, file under univer sal rules.
136 m_universalRules.append(ruleData); 136 m_universalRules.append(ruleData);
137 } 137 }
138 } 138 }
139 139
140 void RuleSet::addFontFaceRule(StyleRuleFontFace* rule) 140 void RuleSet::addFontFaceRule(StyleRuleFontFace* rule)
141 { 141 {
142 ensurePendingRules(); // So that m_fontFaceRules.shrinkToFit() gets called. 142 ensurePendingRules(); // So that m_fontFaceRules.shrinkToFit() gets called.
143 m_fontFaceRules.append(rule); 143 m_fontFaceRules.append(rule);
144 } 144 }
145 145
146 void RuleSet::addKeyframesRule(StyleRuleKeyframes* rule) 146 void RuleSet::addKeyframesRule(StyleRuleKeyframes* rule)
147 { 147 {
148 ensurePendingRules(); // So that m_keyframesRules.shrinkToFit() gets called. 148 ensurePendingRules(); // So that m_keyframesRules.shrinkToFit() gets called.
149 m_keyframesRules.append(rule); 149 m_keyframesRules.append(rule);
150 } 150 }
151 151
152 void RuleSet::addChildRules(const Vector<RefPtr<StyleRuleBase> >& rules, AddRule Flags addRuleFlags) 152 void RuleSet::addChildRules(const Vector<RefPtr<StyleRuleBase> >& rules)
153 { 153 {
154 for (unsigned i = 0; i < rules.size(); ++i) { 154 for (unsigned i = 0; i < rules.size(); ++i) {
155 StyleRuleBase* rule = rules[i].get(); 155 StyleRuleBase* rule = rules[i].get();
156 156
157 if (rule->isStyleRule()) { 157 if (rule->isStyleRule()) {
158 StyleRule* styleRule = toStyleRule(rule); 158 StyleRule* styleRule = toStyleRule(rule);
159 159
160 const CSSSelectorList& selectorList = styleRule->selectorList(); 160 const CSSSelectorList& selectorList = styleRule->selectorList();
161 for (size_t selectorIndex = 0; selectorIndex != kNotFound; selectorI ndex = selectorList.indexOfNextSelectorAfter(selectorIndex)) 161 for (size_t selectorIndex = 0; selectorIndex != kNotFound; selectorI ndex = selectorList.indexOfNextSelectorAfter(selectorIndex))
162 addRule(styleRule, selectorIndex, addRuleFlags); 162 addRule(styleRule, selectorIndex);
163 } else if (rule->isFontFaceRule()) { 163 } else if (rule->isFontFaceRule()) {
164 addFontFaceRule(toStyleRuleFontFace(rule)); 164 addFontFaceRule(toStyleRuleFontFace(rule));
165 } else if (rule->isKeyframesRule()) { 165 } else if (rule->isKeyframesRule()) {
166 addKeyframesRule(toStyleRuleKeyframes(rule)); 166 addKeyframesRule(toStyleRuleKeyframes(rule));
167 } else if (rule->isSupportsRule() && toStyleRuleSupports(rule)->conditio nIsSupported()) { 167 } else if (rule->isSupportsRule() && toStyleRuleSupports(rule)->conditio nIsSupported()) {
168 addChildRules(toStyleRuleSupports(rule)->childRules(), addRuleFlags) ; 168 addChildRules(toStyleRuleSupports(rule)->childRules());
169 } 169 }
170 } 170 }
171 } 171 }
172 172
173 void RuleSet::addRulesFromSheet(StyleSheetContents* sheet, AddRuleFlags addRuleF lags) 173 void RuleSet::addRulesFromSheet(StyleSheetContents* sheet)
174 { 174 {
175 TRACE_EVENT0("blink", "RuleSet::addRulesFromSheet"); 175 TRACE_EVENT0("blink", "RuleSet::addRulesFromSheet");
176 ASSERT(sheet); 176 ASSERT(sheet);
177 addRuleFlags = static_cast<AddRuleFlags>(addRuleFlags | RuleCanUseFastCheckS elector); 177 addChildRules(sheet->childRules());
178 addChildRules(sheet->childRules(), addRuleFlags);
179 } 178 }
180 179
181 void RuleSet::addStyleRule(StyleRule* rule, AddRuleFlags addRuleFlags) 180 void RuleSet::addStyleRule(StyleRule* rule)
182 { 181 {
183 for (size_t selectorIndex = 0; selectorIndex != kNotFound; selectorIndex = r ule->selectorList().indexOfNextSelectorAfter(selectorIndex)) 182 for (size_t selectorIndex = 0; selectorIndex != kNotFound; selectorIndex = r ule->selectorList().indexOfNextSelectorAfter(selectorIndex))
184 addRule(rule, selectorIndex, addRuleFlags); 183 addRule(rule, selectorIndex);
185 } 184 }
186 185
187 void RuleSet::compactPendingRules(PendingRuleMap& pendingMap, CompactRuleMap& co mpactMap) 186 void RuleSet::compactPendingRules(PendingRuleMap& pendingMap, CompactRuleMap& co mpactMap)
188 { 187 {
189 PendingRuleMap::iterator end = pendingMap.end(); 188 PendingRuleMap::iterator end = pendingMap.end();
190 for (PendingRuleMap::iterator it = pendingMap.begin(); it != end; ++it) { 189 for (PendingRuleMap::iterator it = pendingMap.begin(); it != end; ++it) {
191 OwnPtr<LinkedStack<RuleData> > pendingRules = it->value.release(); 190 OwnPtr<LinkedStack<RuleData> > pendingRules = it->value.release();
192 CompactRuleMap::ValueType* compactRules = compactMap.add(it->key, nullpt r).storedValue; 191 CompactRuleMap::ValueType* compactRules = compactMap.add(it->key, nullpt r).storedValue;
193 192
194 TerminatedArrayBuilder<RuleData> builder(compactRules->value.release()); 193 TerminatedArrayBuilder<RuleData> builder(compactRules->value.release());
(...skipping 22 matching lines...) Expand all
217 216
218 #ifndef NDEBUG 217 #ifndef NDEBUG
219 void RuleSet::show() 218 void RuleSet::show()
220 { 219 {
221 for (Vector<RuleData>::const_iterator it = m_allRules.begin(); it != m_allRu les.end(); ++it) 220 for (Vector<RuleData>::const_iterator it = m_allRules.begin(); it != m_allRu les.end(); ++it)
222 it->selector().show(); 221 it->selector().show();
223 } 222 }
224 #endif 223 #endif
225 224
226 } // namespace blink 225 } // namespace blink
OLDNEW
« no previous file with comments | « sky/engine/core/css/RuleSet.h ('k') | sky/engine/core/css/StyleSheetContents.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698