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

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

Issue 810893002: Remove global set of ScopedStyleResolvers. (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: 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/ScopedStyleResolver.cpp ('k') | sky/engine/core/dom/StyleEngine.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 149 matching lines...) Expand 10 before | Expand all | Expand 10 after
160 { 160 {
161 ASSERT(cssSheet); 161 ASSERT(cssSheet);
162 if (cssSheet->mediaQueries() && !m_medium->eval(cssSheet->mediaQueries(), &m _viewportDependentMediaQueryResults)) 162 if (cssSheet->mediaQueries() && !m_medium->eval(cssSheet->mediaQueries(), &m _viewportDependentMediaQueryResults))
163 return; 163 return;
164 164
165 Node* ownerNode = cssSheet->ownerNode(); 165 Node* ownerNode = cssSheet->ownerNode();
166 if (!ownerNode) 166 if (!ownerNode)
167 return; 167 return;
168 168
169 TreeScope& treeScope = ownerNode->treeScope(); 169 TreeScope& treeScope = ownerNode->treeScope();
170 ScopedStyleResolver& resolver = treeScope.ensureScopedStyleResolver(); 170 ScopedStyleResolver& resolver = treeScope.scopedStyleResolver();
171 document().styleEngine()->addScopedStyleResolver(&resolver);
172 resolver.addRulesFromSheet(cssSheet, this); 171 resolver.addRulesFromSheet(cssSheet, this);
173 } 172 }
174 173
175 void StyleResolver::appendPendingAuthorStyleSheets() 174 void StyleResolver::appendPendingAuthorStyleSheets()
176 { 175 {
177 for (ListHashSet<RawPtr<CSSStyleSheet>, 16>::iterator it = m_pendingStyleShe ets.begin(); it != m_pendingStyleSheets.end(); ++it) 176 for (ListHashSet<RawPtr<CSSStyleSheet>, 16>::iterator it = m_pendingStyleShe ets.begin(); it != m_pendingStyleSheets.end(); ++it)
178 appendCSSStyleSheet(*it); 177 appendCSSStyleSheet(*it);
179 178
180 m_pendingStyleSheets.clear(); 179 m_pendingStyleSheets.clear();
181 finishAppendAuthorStyleSheets(); 180 finishAppendAuthorStyleSheets();
(...skipping 19 matching lines...) Expand all
201 void StyleResolver::resetRuleFeatures() 200 void StyleResolver::resetRuleFeatures()
202 { 201 {
203 // Need to recreate RuleFeatureSet. 202 // Need to recreate RuleFeatureSet.
204 m_features.clear(); 203 m_features.clear();
205 m_needCollectFeatures = true; 204 m_needCollectFeatures = true;
206 } 205 }
207 206
208 void StyleResolver::processScopedRules(const RuleSet& authorRules, CSSStyleSheet * parentStyleSheet, unsigned parentIndex, ContainerNode& scope) 207 void StyleResolver::processScopedRules(const RuleSet& authorRules, CSSStyleSheet * parentStyleSheet, unsigned parentIndex, ContainerNode& scope)
209 { 208 {
210 const Vector<RawPtr<StyleRuleKeyframes> > keyframesRules = authorRules.keyfr amesRules(); 209 const Vector<RawPtr<StyleRuleKeyframes> > keyframesRules = authorRules.keyfr amesRules();
211 ScopedStyleResolver* resolver = &scope.treeScope().ensureScopedStyleResolver (); 210 ScopedStyleResolver* resolver = &scope.treeScope().scopedStyleResolver();
212 document().styleEngine()->addScopedStyleResolver(resolver);
213 for (unsigned i = 0; i < keyframesRules.size(); ++i) 211 for (unsigned i = 0; i < keyframesRules.size(); ++i)
214 resolver->addKeyframeStyle(keyframesRules[i]); 212 resolver->addKeyframeStyle(keyframesRules[i]);
215 213
216 // FIXME(BUG 72461): We don't add @font-face rules of scoped style sheets fo r the moment. 214 // FIXME(BUG 72461): We don't add @font-face rules of scoped style sheets fo r the moment.
217 if (scope.isDocumentNode()) { 215 if (scope.isDocumentNode()) {
218 const Vector<RawPtr<StyleRuleFontFace> > fontFaceRules = authorRules.fon tFaceRules(); 216 const Vector<RawPtr<StyleRuleFontFace> > fontFaceRules = authorRules.fon tFaceRules();
219 for (unsigned i = 0; i < fontFaceRules.size(); ++i) 217 for (unsigned i = 0; i < fontFaceRules.size(); ++i)
220 addFontFaceRule(m_document, document().styleEngine()->fontSelector() , fontFaceRules[i]); 218 addFontFaceRule(m_document, document().styleEngine()->fontSelector() , fontFaceRules[i]);
221 if (fontFaceRules.size()) 219 if (fontFaceRules.size())
222 invalidateMatchedPropertiesCache(); 220 invalidateMatchedPropertiesCache();
223 } 221 }
224 } 222 }
225 223
226 void StyleResolver::resetAuthorStyle(TreeScope& treeScope) 224 void StyleResolver::resetAuthorStyle(TreeScope& treeScope)
227 { 225 {
228 ScopedStyleResolver* resolver = treeScope.scopedStyleResolver(); 226 treeScope.scopedStyleResolver().resetAuthorStyle();
229 if (!resolver)
230 return;
231
232 resolver->resetAuthorStyle();
233 resetRuleFeatures(); 227 resetRuleFeatures();
234 if (treeScope.rootNode().isDocumentNode())
235 return;
236
237 // resolver is going to be freed below.
238 document().styleEngine()->removeScopedStyleResolver(resolver);
239 treeScope.clearScopedStyleResolver();
240 } 228 }
241 229
242 void StyleResolver::collectFeatures() 230 void StyleResolver::collectFeatures()
243 { 231 {
244 m_features.clear(); 232 m_features.clear();
245 m_features.add(defaultStyles().features()); 233 m_features.add(defaultStyles().features());
246 234
247 document().styleEngine()->collectScopedStyleFeaturesTo(m_features); 235 document().styleEngine()->collectScopedStyleFeaturesTo(m_features);
248 236
249 m_needCollectFeatures = false; 237 m_needCollectFeatures = false;
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
315 303
316 collector.sortAndTransferMatchedRules(); 304 collector.sortAndTransferMatchedRules();
317 } 305 }
318 306
319 void StyleResolver::matchAuthorRules(Element* element, ElementRuleCollector& col lector, bool includeEmptyRules) 307 void StyleResolver::matchAuthorRules(Element* element, ElementRuleCollector& col lector, bool includeEmptyRules)
320 { 308 {
321 collector.clearMatchedRules(); 309 collector.clearMatchedRules();
322 collector.matchedResult().ranges.lastAuthorRule = collector.matchedResult(). matchedProperties.size() - 1; 310 collector.matchedResult().ranges.lastAuthorRule = collector.matchedResult(). matchedProperties.size() - 1;
323 311
324 bool applyAuthorStyles = applyAuthorStylesOf(element); 312 bool applyAuthorStyles = applyAuthorStylesOf(element);
325 if (document().styleEngine()->hasOnlyScopedResolverForDocument()) {
326 document().scopedStyleResolver()->collectMatchingAuthorRules(collector, includeEmptyRules, applyAuthorStyles, ignoreCascadeScope);
327 collector.sortAndTransferMatchedRules();
328 return;
329 }
330 313
331 Vector<RawPtr<ScopedStyleResolver>, 8> resolvers; 314 Vector<RawPtr<ScopedStyleResolver>, 8> resolvers;
332 if (ScopedStyleResolver* resolver = element->treeScope().scopedStyleResolver ()) 315 resolvers.append(&element->treeScope().scopedStyleResolver());
333 resolvers.append(resolver);
334 316
335 Vector<RawPtr<ScopedStyleResolver>, 8> resolversInShadowTree; 317 Vector<RawPtr<ScopedStyleResolver>, 8> resolversInShadowTree;
336 collectScopedResolversForHostedShadowTrees(element, resolversInShadowTree); 318 collectScopedResolversForHostedShadowTrees(element, resolversInShadowTree);
337 if (!resolversInShadowTree.isEmpty()) { 319 if (!resolversInShadowTree.isEmpty()) {
338 matchAuthorRulesForShadowHost(element, collector, includeEmptyRules, res olvers, resolversInShadowTree); 320 matchAuthorRulesForShadowHost(element, collector, includeEmptyRules, res olvers, resolversInShadowTree);
339 return; 321 return;
340 } 322 }
341 323
342 if (resolvers.isEmpty()) 324 if (resolvers.isEmpty())
343 return; 325 return;
(...skipping 279 matching lines...) Expand 10 before | Expand all | Expand 10 after
623 return true; 605 return true;
624 } 606 }
625 607
626 void StyleResolver::collectScopedResolversForHostedShadowTrees(const Element* el ement, Vector<RawPtr<ScopedStyleResolver>, 8>& resolvers) 608 void StyleResolver::collectScopedResolversForHostedShadowTrees(const Element* el ement, Vector<RawPtr<ScopedStyleResolver>, 8>& resolvers)
627 { 609 {
628 ElementShadow* shadow = element->shadow(); 610 ElementShadow* shadow = element->shadow();
629 if (!shadow) 611 if (!shadow)
630 return; 612 return;
631 613
632 // Adding scoped resolver for active shadow roots for shadow host styling. 614 // Adding scoped resolver for active shadow roots for shadow host styling.
633 if (ShadowRoot* shadowRoot = shadow->shadowRoot()) { 615 if (ShadowRoot* shadowRoot = shadow->shadowRoot())
634 if (ScopedStyleResolver* resolver = shadowRoot->scopedStyleResolver()) 616 resolvers.append(&shadowRoot->scopedStyleResolver());
635 resolvers.append(resolver);
636 }
637 } 617 }
638 618
639 void StyleResolver::styleTreeResolveScopedKeyframesRules(const Element* element, Vector<RawPtr<ScopedStyleResolver>, 8>& resolvers) 619 void StyleResolver::styleTreeResolveScopedKeyframesRules(const Element* element, Vector<RawPtr<ScopedStyleResolver>, 8>& resolvers)
640 { 620 {
641 // Add resolvers for shadow roots hosted by the given element. 621 // Add resolvers for shadow roots hosted by the given element.
642 collectScopedResolversForHostedShadowTrees(element, resolvers); 622 collectScopedResolversForHostedShadowTrees(element, resolvers);
643 623 resolvers.append(&element->treeScope().scopedStyleResolver());
644 // Add resolvers while walking up DOM tree from the given element.
645 if (ScopedStyleResolver* resolver = element->treeScope().scopedStyleResolver ())
646 resolvers.append(resolver);
647 } 624 }
648 625
649 template <StyleResolver::StyleApplicationPass pass> 626 template <StyleResolver::StyleApplicationPass pass>
650 void StyleResolver::applyAnimatedProperties(StyleResolverState& state, const Has hMap<CSSPropertyID, RefPtr<Interpolation> >& activeInterpolations) 627 void StyleResolver::applyAnimatedProperties(StyleResolverState& state, const Has hMap<CSSPropertyID, RefPtr<Interpolation> >& activeInterpolations)
651 { 628 {
652 for (HashMap<CSSPropertyID, RefPtr<Interpolation> >::const_iterator iter = a ctiveInterpolations.begin(); iter != activeInterpolations.end(); ++iter) { 629 for (HashMap<CSSPropertyID, RefPtr<Interpolation> >::const_iterator iter = a ctiveInterpolations.begin(); iter != activeInterpolations.end(); ++iter) {
653 CSSPropertyID property = iter->key; 630 CSSPropertyID property = iter->key;
654 if (!isPropertyForPass<pass>(property)) 631 if (!isPropertyForPass<pass>(property))
655 continue; 632 continue;
656 const StyleInterpolation* interpolation = toStyleInterpolation(iter->val ue.get()); 633 const StyleInterpolation* interpolation = toStyleInterpolation(iter->val ue.get());
(...skipping 278 matching lines...) Expand 10 before | Expand all | Expand 10 after
935 bool StyleResolver::mediaQueryAffectedByViewportChange() const 912 bool StyleResolver::mediaQueryAffectedByViewportChange() const
936 { 913 {
937 for (unsigned i = 0; i < m_viewportDependentMediaQueryResults.size(); ++i) { 914 for (unsigned i = 0; i < m_viewportDependentMediaQueryResults.size(); ++i) {
938 if (m_medium->eval(m_viewportDependentMediaQueryResults[i]->expression() ) != m_viewportDependentMediaQueryResults[i]->result()) 915 if (m_medium->eval(m_viewportDependentMediaQueryResults[i]->expression() ) != m_viewportDependentMediaQueryResults[i]->result())
939 return true; 916 return true;
940 } 917 }
941 return false; 918 return false;
942 } 919 }
943 920
944 } // namespace blink 921 } // namespace blink
OLDNEW
« no previous file with comments | « sky/engine/core/css/resolver/ScopedStyleResolver.cpp ('k') | sky/engine/core/dom/StyleEngine.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698