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

Side by Side Diff: sky/engine/core/css/resolver/StyleResolver.cpp

Issue 796583002: Use the HashSet of attribute names in SharedStyleFinder. (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Use C++11 loops. Created 6 years 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/resolver/StyleResolver.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 /* 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 185 matching lines...) Expand 10 before | Expand all | Expand 10 after
196 collectFeatures(); 196 collectFeatures();
197 197
198 if (document().renderView() && document().renderView()->style()) 198 if (document().renderView() && document().renderView()->style())
199 document().renderView()->style()->font().update(document().styleEngine() ->fontSelector()); 199 document().renderView()->style()->font().update(document().styleEngine() ->fontSelector());
200 } 200 }
201 201
202 void StyleResolver::resetRuleFeatures() 202 void StyleResolver::resetRuleFeatures()
203 { 203 {
204 // Need to recreate RuleFeatureSet. 204 // Need to recreate RuleFeatureSet.
205 m_features.clear(); 205 m_features.clear();
206 m_attributeRuleSet.clear();
207 m_needCollectFeatures = true; 206 m_needCollectFeatures = true;
208 } 207 }
209 208
210 void StyleResolver::processScopedRules(const RuleSet& authorRules, CSSStyleSheet * parentStyleSheet, unsigned parentIndex, ContainerNode& scope) 209 void StyleResolver::processScopedRules(const RuleSet& authorRules, CSSStyleSheet * parentStyleSheet, unsigned parentIndex, ContainerNode& scope)
211 { 210 {
212 const Vector<RawPtr<StyleRuleKeyframes> > keyframesRules = authorRules.keyfr amesRules(); 211 const Vector<RawPtr<StyleRuleKeyframes> > keyframesRules = authorRules.keyfr amesRules();
213 ScopedStyleResolver* resolver = &scope.treeScope().ensureScopedStyleResolver (); 212 ScopedStyleResolver* resolver = &scope.treeScope().ensureScopedStyleResolver ();
214 document().styleEngine()->addScopedStyleResolver(resolver); 213 document().styleEngine()->addScopedStyleResolver(resolver);
215 for (unsigned i = 0; i < keyframesRules.size(); ++i) 214 for (unsigned i = 0; i < keyframesRules.size(); ++i)
216 resolver->addKeyframeStyle(keyframesRules[i]); 215 resolver->addKeyframeStyle(keyframesRules[i]);
(...skipping 17 matching lines...) Expand all
234 resolver->resetAuthorStyle(); 233 resolver->resetAuthorStyle();
235 resetRuleFeatures(); 234 resetRuleFeatures();
236 if (treeScope.rootNode().isDocumentNode()) 235 if (treeScope.rootNode().isDocumentNode())
237 return; 236 return;
238 237
239 // resolver is going to be freed below. 238 // resolver is going to be freed below.
240 document().styleEngine()->removeScopedStyleResolver(resolver); 239 document().styleEngine()->removeScopedStyleResolver(resolver);
241 treeScope.clearScopedStyleResolver(); 240 treeScope.clearScopedStyleResolver();
242 } 241 }
243 242
244 static PassOwnPtr<RuleSet> makeRuleSet(const Vector<RuleFeature>& rules)
245 {
246 size_t size = rules.size();
247 if (!size)
248 return nullptr;
249 OwnPtr<RuleSet> ruleSet = RuleSet::create();
250 for (size_t i = 0; i < size; ++i)
251 ruleSet->addRule(rules[i].rule, rules[i].selectorIndex, RuleHasNoSpecial State);
252 return ruleSet.release();
253 }
254
255 void StyleResolver::collectFeatures() 243 void StyleResolver::collectFeatures()
256 { 244 {
257 m_features.clear(); 245 m_features.clear();
258 m_features.add(defaultStyles().features()); 246 m_features.add(defaultStyles().features());
259 247
260 document().styleEngine()->collectScopedStyleFeaturesTo(m_features); 248 document().styleEngine()->collectScopedStyleFeaturesTo(m_features);
261 249
262 m_attributeRuleSet = makeRuleSet(m_features.attributeRules);
263 m_needCollectFeatures = false; 250 m_needCollectFeatures = false;
264 } 251 }
265 252
266 bool StyleResolver::hasRulesForId(const AtomicString& id) const 253 bool StyleResolver::hasRulesForId(const AtomicString& id) const
267 { 254 {
268 return m_features.hasSelectorForId(id); 255 return m_features.hasSelectorForId(id);
269 } 256 }
270 257
271 void StyleResolver::addToStyleSharingList(Element& element) 258 void StyleResolver::addToStyleSharingList(Element& element)
272 { 259 {
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after
442 return s_styleNotYetAvailable; 429 return s_styleNotYetAvailable;
443 } 430 }
444 431
445 didAccess(); 432 didAccess();
446 433
447 if (element == document().documentElement()) 434 if (element == document().documentElement())
448 document().setDirectionSetOnDocumentElement(false); 435 document().setDirectionSetOnDocumentElement(false);
449 StyleResolverState state(document(), element, defaultParent); 436 StyleResolverState state(document(), element, defaultParent);
450 437
451 if (sharingBehavior == AllowStyleSharing && state.parentStyle()) { 438 if (sharingBehavior == AllowStyleSharing && state.parentStyle()) {
452 SharedStyleFinder styleFinder(state.elementContext(), m_features, m_attr ibuteRuleSet.get(), *this); 439 SharedStyleFinder styleFinder(state.elementContext(), m_features, *this) ;
453 if (RefPtr<RenderStyle> sharedStyle = styleFinder.findSharedStyle()) 440 if (RefPtr<RenderStyle> sharedStyle = styleFinder.findSharedStyle())
454 return sharedStyle.release(); 441 return sharedStyle.release();
455 } 442 }
456 443
457 if (state.parentStyle()) { 444 if (state.parentStyle()) {
458 state.setStyle(RenderStyle::create()); 445 state.setStyle(RenderStyle::create());
459 state.style()->inheritFrom(state.parentStyle(), isAtShadowBoundary(eleme nt) ? RenderStyle::AtShadowBoundary : RenderStyle::NotAtShadowBoundary); 446 state.style()->inheritFrom(state.parentStyle(), isAtShadowBoundary(eleme nt) ? RenderStyle::AtShadowBoundary : RenderStyle::NotAtShadowBoundary);
460 } else { 447 } else {
461 state.setStyle(defaultStyleForElement()); 448 state.setStyle(defaultStyleForElement());
462 state.setParentStyle(RenderStyle::clone(state.style())); 449 state.setParentStyle(RenderStyle::clone(state.style()));
(...skipping 487 matching lines...) Expand 10 before | Expand all | Expand 10 after
950 bool StyleResolver::mediaQueryAffectedByViewportChange() const 937 bool StyleResolver::mediaQueryAffectedByViewportChange() const
951 { 938 {
952 for (unsigned i = 0; i < m_viewportDependentMediaQueryResults.size(); ++i) { 939 for (unsigned i = 0; i < m_viewportDependentMediaQueryResults.size(); ++i) {
953 if (m_medium->eval(m_viewportDependentMediaQueryResults[i]->expression() ) != m_viewportDependentMediaQueryResults[i]->result()) 940 if (m_medium->eval(m_viewportDependentMediaQueryResults[i]->expression() ) != m_viewportDependentMediaQueryResults[i]->result())
954 return true; 941 return true;
955 } 942 }
956 return false; 943 return false;
957 } 944 }
958 945
959 } // namespace blink 946 } // namespace blink
OLDNEW
« no previous file with comments | « sky/engine/core/css/resolver/StyleResolver.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698