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

Side by Side Diff: Source/core/css/resolver/StyleResolver.cpp

Issue 42543007: StyleResolver should update RuleSets lazily. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Revised Created 7 years, 1 month 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 | Annotate | Revision Log
« no previous file with comments | « Source/core/css/resolver/StyleResolver.h ('k') | Source/core/dom/Document.cpp » ('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 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
50 #include "core/css/CSSRuleList.h" 50 #include "core/css/CSSRuleList.h"
51 #include "core/css/CSSSelector.h" 51 #include "core/css/CSSSelector.h"
52 #include "core/css/CSSStyleRule.h" 52 #include "core/css/CSSStyleRule.h"
53 #include "core/css/CSSValueList.h" 53 #include "core/css/CSSValueList.h"
54 #include "core/css/CSSVariableValue.h" 54 #include "core/css/CSSVariableValue.h"
55 #include "core/css/ElementRuleCollector.h" 55 #include "core/css/ElementRuleCollector.h"
56 #include "core/css/MediaQueryEvaluator.h" 56 #include "core/css/MediaQueryEvaluator.h"
57 #include "core/css/PageRuleCollector.h" 57 #include "core/css/PageRuleCollector.h"
58 #include "core/css/RuleSet.h" 58 #include "core/css/RuleSet.h"
59 #include "core/css/StylePropertySet.h" 59 #include "core/css/StylePropertySet.h"
60 #include "core/css/StyleRuleImport.h"
61 #include "core/css/StyleSheetContents.h"
60 #include "core/css/resolver/AnimatedStyleBuilder.h" 62 #include "core/css/resolver/AnimatedStyleBuilder.h"
61 #include "core/css/resolver/MatchResult.h" 63 #include "core/css/resolver/MatchResult.h"
62 #include "core/css/resolver/MediaQueryResult.h" 64 #include "core/css/resolver/MediaQueryResult.h"
63 #include "core/css/resolver/SharedStyleFinder.h" 65 #include "core/css/resolver/SharedStyleFinder.h"
64 #include "core/css/resolver/StyleAdjuster.h" 66 #include "core/css/resolver/StyleAdjuster.h"
65 #include "core/css/resolver/StyleBuilder.h" 67 #include "core/css/resolver/StyleBuilder.h"
66 #include "core/css/resolver/StyleResolverStats.h" 68 #include "core/css/resolver/StyleResolverStats.h"
67 #include "core/css/resolver/ViewportStyleResolver.h" 69 #include "core/css/resolver/ViewportStyleResolver.h"
68 #include "core/dom/CSSSelectorWatch.h" 70 #include "core/dom/CSSSelectorWatch.h"
69 #include "core/dom/NodeRenderStyle.h" 71 #include "core/dom/NodeRenderStyle.h"
(...skipping 29 matching lines...) Expand all
99 } 101 }
100 102
101 } // namespace 103 } // namespace
102 104
103 namespace WebCore { 105 namespace WebCore {
104 106
105 using namespace HTMLNames; 107 using namespace HTMLNames;
106 108
107 RenderStyle* StyleResolver::s_styleNotYetAvailable; 109 RenderStyle* StyleResolver::s_styleNotYetAvailable;
108 110
111 inline bool isDocumentScope(const ContainerNode* scope)
112 {
113 // FIXME: scope should not be null. scope should be a ShadowRoot or a Docume nt.
114 return !scope || scope->isDocumentNode();
115 }
116
109 static StylePropertySet* leftToRightDeclaration() 117 static StylePropertySet* leftToRightDeclaration()
110 { 118 {
111 DEFINE_STATIC_REF(MutableStylePropertySet, leftToRightDecl, (MutableStylePro pertySet::create())); 119 DEFINE_STATIC_REF(MutableStylePropertySet, leftToRightDecl, (MutableStylePro pertySet::create()));
112 if (leftToRightDecl->isEmpty()) 120 if (leftToRightDecl->isEmpty())
113 leftToRightDecl->setProperty(CSSPropertyDirection, CSSValueLtr); 121 leftToRightDecl->setProperty(CSSPropertyDirection, CSSValueLtr);
114 return leftToRightDecl; 122 return leftToRightDecl;
115 } 123 }
116 124
117 static StylePropertySet* rightToLeftDeclaration() 125 static StylePropertySet* rightToLeftDeclaration()
118 { 126 {
119 DEFINE_STATIC_REF(MutableStylePropertySet, rightToLeftDecl, (MutableStylePro pertySet::create())); 127 DEFINE_STATIC_REF(MutableStylePropertySet, rightToLeftDecl, (MutableStylePro pertySet::create()));
120 if (rightToLeftDecl->isEmpty()) 128 if (rightToLeftDecl->isEmpty())
121 rightToLeftDecl->setProperty(CSSPropertyDirection, CSSValueRtl); 129 rightToLeftDecl->setProperty(CSSPropertyDirection, CSSValueRtl);
122 return rightToLeftDecl; 130 return rightToLeftDecl;
123 } 131 }
124 132
125 StyleResolver::StyleResolver(Document& document) 133 StyleResolver::StyleResolver(Document& document)
126 : m_document(document) 134 : m_document(document)
127 , m_fontSelector(CSSFontSelector::create(&document)) 135 , m_fontSelector(CSSFontSelector::create(&document))
128 , m_viewportStyleResolver(ViewportStyleResolver::create(&document)) 136 , m_viewportStyleResolver(ViewportStyleResolver::create(&document))
137 , m_needCollectFeatures(false)
129 , m_styleResourceLoader(document.fetcher()) 138 , m_styleResourceLoader(document.fetcher())
130 , m_styleResolverStatsSequence(0) 139 , m_styleResolverStatsSequence(0)
131 , m_accessCount(0) 140 , m_accessCount(0)
132 { 141 {
133 m_fontSelector->registerForInvalidationCallbacks(this); 142 m_fontSelector->registerForInvalidationCallbacks(this);
134 143
135 // FIXME: Why do this here instead of as part of resolving style on the root ? 144 // FIXME: Why do this here instead of as part of resolving style on the root ?
136 CSSDefaultStyleSheets::loadDefaultStylesheetIfNecessary(); 145 CSSDefaultStyleSheets::loadDefaultStylesheetIfNecessary();
137 146
138 // Construct document root element default style. This is needed 147 // Construct document root element default style. This is needed
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
172 181
173 void StyleResolver::initWatchedSelectorRules(const Vector<RefPtr<StyleRule> >& w atchedSelectors) 182 void StyleResolver::initWatchedSelectorRules(const Vector<RefPtr<StyleRule> >& w atchedSelectors)
174 { 183 {
175 if (!watchedSelectors.size()) 184 if (!watchedSelectors.size())
176 return; 185 return;
177 m_watchedSelectorsRules = RuleSet::create(); 186 m_watchedSelectorsRules = RuleSet::create();
178 for (unsigned i = 0; i < watchedSelectors.size(); ++i) 187 for (unsigned i = 0; i < watchedSelectors.size(); ++i)
179 m_watchedSelectorsRules->addStyleRule(watchedSelectors[i].get(), RuleHas NoSpecialState); 188 m_watchedSelectorsRules->addStyleRule(watchedSelectors[i].get(), RuleHas NoSpecialState);
180 } 189 }
181 190
191 bool StyleResolver::filterViewportRules(const Vector<RefPtr<StyleRuleBase> >& ru les)
192 {
193 bool needsResolveViewport = false;
194
195 for (unsigned i = 0; i < rules.size(); ++i) {
196 StyleRuleBase* rule = rules[i].get();
197
198 if (rule->isViewportRule()) {
199 m_styleTree.ensureScopedStyleResolver(m_document)->addViewportRule(t oStyleRuleViewport(rule));
200 needsResolveViewport = true;
201 } else if (rule->isMediaRule()) {
202 const StyleRuleMedia* mediaRule = toStyleRuleMedia(rule);
203 if ((!mediaRule->mediaQueries() || m_medium->eval(mediaRule->mediaQu eries(), viewportDependentMediaQueryResults()))) {
204 if (filterViewportRules(mediaRule->childRules()))
205 needsResolveViewport = true;
206 }
207 }
208 }
209 return needsResolveViewport;
210 }
211
212 bool StyleResolver::filterViewportRulesFromSheet(StyleSheetContents* sheet)
213 {
214 if (!sheet)
215 return false;
216
217 bool needsResolveViewport = false;
218 const Vector<RefPtr<StyleRuleImport> >& importRules = sheet->importRules();
219 for (unsigned i = 0; i < importRules.size(); ++i) {
220 StyleRuleImport* importRule = importRules[i].get();
221 if (filterViewportRulesFromSheet(importRule->styleSheet()))
222 needsResolveViewport = true;
223 }
224
225 if (filterViewportRules(sheet->childRules()))
226 needsResolveViewport = true;
227 return needsResolveViewport;
228 }
229
230 bool StyleResolver::filterViewportRulesFromAuthorStyleSheets(unsigned firstNew, const Vector<RefPtr<CSSStyleSheet> >& styleSheets)
231 {
232 bool needsResolveViewport = false;
233
234 unsigned size = styleSheets.size();
235 for (unsigned i = firstNew; i < size; ++i) {
236 CSSStyleSheet* cssSheet = styleSheets[i].get();
237 ASSERT(!cssSheet->disabled());
238 if (cssSheet->mediaQueries() && !m_medium->eval(cssSheet->mediaQueries() , &m_viewportDependentMediaQueryResults))
239 continue;
240 if (cssSheet->ownerNode()->isInShadowTree() || !isDocumentScope(ScopedSt yleResolver::scopingNodeFor(cssSheet)))
241 continue;
242 if (filterViewportRulesFromSheet(cssSheet->contents()))
243 needsResolveViewport = true;
244 }
245 return needsResolveViewport;
246 }
247
248 void StyleResolver::lazyAppendAuthorStyleSheets(unsigned firstNew, const Vector< RefPtr<CSSStyleSheet> >& styleSheets)
249 {
250 // FIXME: Currently We cannot lazy apppend stylesheets if the sheets have @v iewport rules.
251 // Need to find the best place to update pending stylesheets for "viewport" rules.
252 bool needsResolveViewport = filterViewportRulesFromAuthorStyleSheets(firstNe w, styleSheets);
253
254 unsigned size = styleSheets.size();
255 for (unsigned i = firstNew; i < size; ++i)
256 m_pendingStyleSheets.add(styleSheets[i].get());
257
258 if (needsResolveViewport)
259 collectViewportRules();
260 }
261
262 void StyleResolver::removePendingAuthorStyleSheets(const Vector<RefPtr<CSSStyleS heet> >& styleSheets)
263 {
264 for (unsigned i = 0; i < styleSheets.size(); ++i)
265 m_pendingStyleSheets.remove(styleSheets[i].get());
266 }
267
268 void StyleResolver::appendPendingAuthorStyleSheets()
269 {
270 setBuildScopedStyleTreeInDocumentOrder(false);
271 for (ListHashSet<CSSStyleSheet*, 16>::iterator it = m_pendingStyleSheets.beg in(); it != m_pendingStyleSheets.end(); ++it) {
ojan 2013/11/19 17:35:05 Is it safe for StyleResolver to hold raw pointers
272 CSSStyleSheet* cssSheet = *it;
273 ASSERT(!cssSheet->disabled());
274 if (cssSheet->mediaQueries() && !m_medium->eval(cssSheet->mediaQueries() , &m_viewportDependentMediaQueryResults))
275 continue;
276
277 StyleSheetContents* sheet = cssSheet->contents();
278 ContainerNode* scopingNode = ScopedStyleResolver::scopingNodeFor(cssShee t);
279 if (!scopingNode && cssSheet->ownerNode() && cssSheet->ownerNode()->isIn ShadowTree())
280 continue;
281
282 ScopedStyleResolver* resolver = ensureScopedStyleResolver(scopingNode);
283 ASSERT(resolver);
284 resolver->addRulesFromSheet(sheet, *m_medium, this, true);
285 m_inspectorCSSOMWrappers.collectFromStyleSheetIfNeeded(cssSheet);
286 }
287 m_pendingStyleSheets.clear();
288 finishAppendAuthorStyleSheets();
289 }
290
182 void StyleResolver::appendAuthorStyleSheets(unsigned firstNew, const Vector<RefP tr<CSSStyleSheet> >& styleSheets) 291 void StyleResolver::appendAuthorStyleSheets(unsigned firstNew, const Vector<RefP tr<CSSStyleSheet> >& styleSheets)
183 { 292 {
184 // This handles sheets added to the end of the stylesheet list only. In othe r cases the style resolver 293 // This handles sheets added to the end of the stylesheet list only. In othe r cases the style resolver
185 // needs to be reconstructed. To handle insertions too the rule order number s would need to be updated. 294 // needs to be reconstructed. To handle insertions too the rule order number s would need to be updated.
186 unsigned size = styleSheets.size(); 295 unsigned size = styleSheets.size();
187 for (unsigned i = firstNew; i < size; ++i) { 296 for (unsigned i = firstNew; i < size; ++i) {
188 CSSStyleSheet* cssSheet = styleSheets[i].get(); 297 CSSStyleSheet* cssSheet = styleSheets[i].get();
189 ASSERT(!cssSheet->disabled()); 298 ASSERT(!cssSheet->disabled());
190 if (cssSheet->mediaQueries() && !m_medium->eval(cssSheet->mediaQueries() , &m_viewportDependentMediaQueryResults)) 299 if (cssSheet->mediaQueries() && !m_medium->eval(cssSheet->mediaQueries() , &m_viewportDependentMediaQueryResults))
191 continue; 300 continue;
192 301
193 StyleSheetContents* sheet = cssSheet->contents(); 302 StyleSheetContents* sheet = cssSheet->contents();
194 ContainerNode* scopingNode = ScopedStyleResolver::scopingNodeFor(cssShee t); 303 ContainerNode* scopingNode = ScopedStyleResolver::scopingNodeFor(cssShee t);
195 if (!scopingNode && cssSheet->ownerNode() && cssSheet->ownerNode()->isIn ShadowTree()) 304 if (!scopingNode && cssSheet->ownerNode() && cssSheet->ownerNode()->isIn ShadowTree())
196 continue; 305 continue;
197 306
198 ScopedStyleResolver* resolver = ensureScopedStyleResolver(scopingNode); 307 ScopedStyleResolver* resolver = ensureScopedStyleResolver(scopingNode);
199 ASSERT(resolver); 308 ASSERT(resolver);
200 resolver->addRulesFromSheet(sheet, *m_medium, this); 309 resolver->addRulesFromSheet(sheet, *m_medium, this, false);
201 m_inspectorCSSOMWrappers.collectFromStyleSheetIfNeeded(cssSheet); 310 m_inspectorCSSOMWrappers.collectFromStyleSheetIfNeeded(cssSheet);
202 } 311 }
203 } 312 }
204 313
205 void StyleResolver::finishAppendAuthorStyleSheets() 314 void StyleResolver::finishAppendAuthorStyleSheets()
206 { 315 {
207 collectFeatures(); 316 collectFeatures();
208 317
209 if (document().renderer() && document().renderer()->style()) 318 if (document().renderer() && document().renderer()->style())
210 document().renderer()->style()->font().update(fontSelector()); 319 document().renderer()->style()->font().update(fontSelector());
211 320
212 collectViewportRules(); 321 collectViewportRules();
322
323 document().styleEngine()->resetCSSFeatureFlags(m_features);
324 }
325
326 void StyleResolver::resetRuleFeatures()
327 {
328 // Need to recreate RuleFeatureSet.
329 m_features.clear();
330 m_siblingRuleSet.clear();
331 m_uncommonAttributeRuleSet.clear();
332 m_needCollectFeatures = true;
213 } 333 }
214 334
215 void StyleResolver::addTreeBoundaryCrossingRules(const Vector<MinimalRuleData>& rules, ContainerNode* scope) 335 void StyleResolver::addTreeBoundaryCrossingRules(const Vector<MinimalRuleData>& rules, ContainerNode* scope)
216 { 336 {
217 for (unsigned i = 0; i < rules.size(); ++i) { 337 for (unsigned i = 0; i < rules.size(); ++i) {
218 const MinimalRuleData& info = rules[i]; 338 const MinimalRuleData& info = rules[i];
219 m_treeBoundaryCrossingRules.addRule(info.m_rule, info.m_selectorIndex, s cope, info.m_flags); 339 m_treeBoundaryCrossingRules.addRule(info.m_rule, info.m_selectorIndex, s cope, info.m_flags);
220 } 340 }
221 } 341 }
222 342
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
265 { 385 {
266 // FIXME: When chanking scoped attribute, scopingNode's hasScopedHTMLStyleCh ild has been already modified. 386 // FIXME: When chanking scoped attribute, scopingNode's hasScopedHTMLStyleCh ild has been already modified.
267 // So we cannot use hasScopedHTMLStyleChild flag here. 387 // So we cannot use hasScopedHTMLStyleChild flag here.
268 ScopedStyleResolver* resolver = scopingNode ? m_styleTree.lookupScopedStyleR esolverFor(scopingNode) : m_styleTree.scopedStyleResolverForDocument(); 388 ScopedStyleResolver* resolver = scopingNode ? m_styleTree.lookupScopedStyleR esolverFor(scopingNode) : m_styleTree.scopedStyleResolverForDocument();
269 if (!resolver) 389 if (!resolver)
270 return; 390 return;
271 391
272 treeBoundaryCrossingRules().reset(scopingNode); 392 treeBoundaryCrossingRules().reset(scopingNode);
273 393
274 resolver->resetAuthorStyle(); 394 resolver->resetAuthorStyle();
395 resetRuleFeatures();
275 if (!scopingNode) 396 if (!scopingNode)
276 return; 397 return;
277 398
278 if (scopingNode->isInShadowTree()) 399 if (scopingNode->isInShadowTree())
279 resetAtHostRules(scopingNode->containingShadowRoot()); 400 resetAtHostRules(scopingNode->containingShadowRoot());
280 401
281 if (!resolver->hasOnlyEmptyRuleSets()) 402 if (!resolver->hasOnlyEmptyRuleSets())
282 return; 403 return;
283 404
284 m_styleTree.remove(scopingNode); 405 m_styleTree.remove(scopingNode);
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
327 448
328 if (m_watchedSelectorsRules) 449 if (m_watchedSelectorsRules)
329 m_features.add(m_watchedSelectorsRules->features()); 450 m_features.add(m_watchedSelectorsRules->features());
330 451
331 m_treeBoundaryCrossingRules.collectFeaturesTo(m_features); 452 m_treeBoundaryCrossingRules.collectFeaturesTo(m_features);
332 453
333 m_styleTree.collectFeaturesTo(m_features); 454 m_styleTree.collectFeaturesTo(m_features);
334 455
335 m_siblingRuleSet = makeRuleSet(m_features.siblingRules); 456 m_siblingRuleSet = makeRuleSet(m_features.siblingRules);
336 m_uncommonAttributeRuleSet = makeRuleSet(m_features.uncommonAttributeRules); 457 m_uncommonAttributeRuleSet = makeRuleSet(m_features.uncommonAttributeRules);
458 m_needCollectFeatures = false;
337 } 459 }
338 460
339 bool StyleResolver::hasRulesForId(const AtomicString& id) const 461 bool StyleResolver::hasRulesForId(const AtomicString& id) const
340 { 462 {
341 return m_features.idsInRules.contains(id.impl()); 463 return m_features.idsInRules.contains(id.impl());
342 } 464 }
343 465
344 void StyleResolver::addToStyleSharingList(Element& element) 466 void StyleResolver::addToStyleSharingList(Element& element)
345 { 467 {
346 // Never add elements to the style sharing list if we're not in a recalcStyl e, 468 // Never add elements to the style sharing list if we're not in a recalcStyl e,
(...skipping 308 matching lines...) Expand 10 before | Expand all | Expand 10 after
655 { 777 {
656 for (size_t i = 0; i < contentAttrValues.size(); ++i) 778 for (size_t i = 0; i < contentAttrValues.size(); ++i)
657 features.attrsInRules.add(contentAttrValues[i].impl()); 779 features.attrsInRules.add(contentAttrValues[i].impl());
658 } 780 }
659 781
660 PassRefPtr<RenderStyle> StyleResolver::styleForElement(Element* element, RenderS tyle* defaultParent, StyleSharingBehavior sharingBehavior, 782 PassRefPtr<RenderStyle> StyleResolver::styleForElement(Element* element, RenderS tyle* defaultParent, StyleSharingBehavior sharingBehavior,
661 RuleMatchingBehavior matchingBehavior, RenderRegion* regionForStyling) 783 RuleMatchingBehavior matchingBehavior, RenderRegion* regionForStyling)
662 { 784 {
663 ASSERT(document().frame()); 785 ASSERT(document().frame());
664 ASSERT(documentSettings()); 786 ASSERT(documentSettings());
787 ASSERT(!hasPendingAuthorStyleSheets());
788 ASSERT(!m_needCollectFeatures);
665 789
666 // Once an element has a renderer, we don't try to destroy it, since otherwi se the renderer 790 // Once an element has a renderer, we don't try to destroy it, since otherwi se the renderer
667 // will vanish if a style recalc happens during loading. 791 // will vanish if a style recalc happens during loading.
668 if (sharingBehavior == AllowStyleSharing && !element->document().haveStylesh eetsLoaded() && !element->renderer()) { 792 if (sharingBehavior == AllowStyleSharing && !element->document().haveStylesh eetsLoaded() && !element->renderer()) {
669 if (!s_styleNotYetAvailable) { 793 if (!s_styleNotYetAvailable) {
670 s_styleNotYetAvailable = RenderStyle::create().leakRef(); 794 s_styleNotYetAvailable = RenderStyle::create().leakRef();
671 s_styleNotYetAvailable->setDisplay(NONE); 795 s_styleNotYetAvailable->setDisplay(NONE);
672 s_styleNotYetAvailable->font().update(m_fontSelector); 796 s_styleNotYetAvailable->font().update(m_fontSelector);
673 } 797 }
674 element->document().setHasNodesWithPlaceholderStyle(); 798 element->document().setHasNodesWithPlaceholderStyle();
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
748 setAnimationUpdateIfNeeded(state, *element); 872 setAnimationUpdateIfNeeded(state, *element);
749 873
750 // Now return the style. 874 // Now return the style.
751 return state.takeStyle(); 875 return state.takeStyle();
752 } 876 }
753 877
754 PassRefPtr<RenderStyle> StyleResolver::styleForKeyframe(Element* e, const Render Style& elementStyle, const StyleKeyframe* keyframe) 878 PassRefPtr<RenderStyle> StyleResolver::styleForKeyframe(Element* e, const Render Style& elementStyle, const StyleKeyframe* keyframe)
755 { 879 {
756 ASSERT(document().frame()); 880 ASSERT(document().frame());
757 ASSERT(documentSettings()); 881 ASSERT(documentSettings());
882 ASSERT(!hasPendingAuthorStyleSheets());
758 883
759 if (e == document().documentElement()) 884 if (e == document().documentElement())
760 resetDirectionAndWritingModeOnDocument(document()); 885 resetDirectionAndWritingModeOnDocument(document());
761 StyleResolverState state(document(), e); 886 StyleResolverState state(document(), e);
762 887
763 MatchResult result; 888 MatchResult result;
764 if (keyframe->properties()) 889 if (keyframe->properties())
765 result.addMatchedProperties(keyframe->properties()); 890 result.addMatchedProperties(keyframe->properties());
766 891
767 ASSERT(!state.style()); 892 ASSERT(!state.style());
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
807 932
808 void StyleResolver::keyframeStylesForAnimation(Element* e, const RenderStyle& el ementStyle, KeyframeList& list) 933 void StyleResolver::keyframeStylesForAnimation(Element* e, const RenderStyle& el ementStyle, KeyframeList& list)
809 { 934 {
810 ASSERT(!RuntimeEnabledFeatures::webAnimationsCSSEnabled()); 935 ASSERT(!RuntimeEnabledFeatures::webAnimationsCSSEnabled());
811 list.clear(); 936 list.clear();
812 937
813 // Get the keyframesRule for this name 938 // Get the keyframesRule for this name
814 if (!e || list.animationName().isEmpty()) 939 if (!e || list.animationName().isEmpty())
815 return; 940 return;
816 941
942 ASSERT(!hasPendingAuthorStyleSheets());
817 const StyleRuleKeyframes* keyframesRule = CSSAnimations::matchScopedKeyframe sRule(this, e, list.animationName().impl()); 943 const StyleRuleKeyframes* keyframesRule = CSSAnimations::matchScopedKeyframe sRule(this, e, list.animationName().impl());
818 if (!keyframesRule) 944 if (!keyframesRule)
819 return; 945 return;
820 946
821 // Construct and populate the style for each keyframe 947 // Construct and populate the style for each keyframe
822 const Vector<RefPtr<StyleKeyframe> >& keyframes = keyframesRule->keyframes() ; 948 const Vector<RefPtr<StyleKeyframe> >& keyframes = keyframesRule->keyframes() ;
823 for (unsigned i = 0; i < keyframes.size(); ++i) { 949 for (unsigned i = 0; i < keyframes.size(); ++i) {
824 // Apply the declaration to the style. This is a simplified version of t he logic in styleForElement 950 // Apply the declaration to the style. This is a simplified version of t he logic in styleForElement
825 const StyleKeyframe* keyframe = keyframes[i].get(); 951 const StyleKeyframe* keyframe = keyframes[i].get();
826 952
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
915 1041
916 if (PseudoElement* pseudoElement = e->pseudoElement(pseudoStyleRequest.pseud oId)) 1042 if (PseudoElement* pseudoElement = e->pseudoElement(pseudoStyleRequest.pseud oId))
917 setAnimationUpdateIfNeeded(state, *pseudoElement); 1043 setAnimationUpdateIfNeeded(state, *pseudoElement);
918 1044
919 // Now return the style. 1045 // Now return the style.
920 return state.takeStyle(); 1046 return state.takeStyle();
921 } 1047 }
922 1048
923 PassRefPtr<RenderStyle> StyleResolver::styleForPage(int pageIndex) 1049 PassRefPtr<RenderStyle> StyleResolver::styleForPage(int pageIndex)
924 { 1050 {
1051 ASSERT(!hasPendingAuthorStyleSheets());
925 resetDirectionAndWritingModeOnDocument(document()); 1052 resetDirectionAndWritingModeOnDocument(document());
926 StyleResolverState state(document(), document().documentElement()); // m_roo tElementStyle will be set to the document style. 1053 StyleResolverState state(document(), document().documentElement()); // m_roo tElementStyle will be set to the document style.
927 1054
928 state.setStyle(RenderStyle::create()); 1055 state.setStyle(RenderStyle::create());
929 const RenderStyle* rootElementStyle = state.rootElementStyle() ? state.rootE lementStyle() : document().renderStyle(); 1056 const RenderStyle* rootElementStyle = state.rootElementStyle() ? state.rootE lementStyle() : document().renderStyle();
930 ASSERT(rootElementStyle); 1057 ASSERT(rootElementStyle);
931 state.style()->inheritFrom(rootElementStyle); 1058 state.style()->inheritFrom(rootElementStyle);
932 1059
933 state.fontBuilder().initForStyleResolve(state.document(), state.style(), sta te.useSVGZoomRules()); 1060 state.fontBuilder().initForStyleResolve(state.document(), state.style(), sta te.useSVGZoomRules());
934 1061
(...skipping 493 matching lines...) Expand 10 before | Expand all | Expand 10 after
1428 bool StyleResolver::affectedByViewportChange() const 1555 bool StyleResolver::affectedByViewportChange() const
1429 { 1556 {
1430 for (unsigned i = 0; i < m_viewportDependentMediaQueryResults.size(); ++i) { 1557 for (unsigned i = 0; i < m_viewportDependentMediaQueryResults.size(); ++i) {
1431 if (m_medium->eval(&m_viewportDependentMediaQueryResults[i]->m_expressio n) != m_viewportDependentMediaQueryResults[i]->m_result) 1558 if (m_medium->eval(&m_viewportDependentMediaQueryResults[i]->m_expressio n) != m_viewportDependentMediaQueryResults[i]->m_result)
1432 return true; 1559 return true;
1433 } 1560 }
1434 return false; 1561 return false;
1435 } 1562 }
1436 1563
1437 } // namespace WebCore 1564 } // namespace WebCore
OLDNEW
« no previous file with comments | « Source/core/css/resolver/StyleResolver.h ('k') | Source/core/dom/Document.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698