OLD | NEW |
---|---|
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 Loading... | |
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 Loading... | |
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 return !scope || scope->isDocumentNode(); | |
esprehn
2013/11/15 10:36:32
We should really fix this so scope is never null,
tasak
2013/11/18 08:30:53
I added FIXME.
| |
114 } | |
115 | |
109 static StylePropertySet* leftToRightDeclaration() | 116 static StylePropertySet* leftToRightDeclaration() |
110 { | 117 { |
111 DEFINE_STATIC_REF(MutableStylePropertySet, leftToRightDecl, (MutableStylePro pertySet::create())); | 118 DEFINE_STATIC_REF(MutableStylePropertySet, leftToRightDecl, (MutableStylePro pertySet::create())); |
112 if (leftToRightDecl->isEmpty()) | 119 if (leftToRightDecl->isEmpty()) |
113 leftToRightDecl->setProperty(CSSPropertyDirection, CSSValueLtr); | 120 leftToRightDecl->setProperty(CSSPropertyDirection, CSSValueLtr); |
114 return leftToRightDecl; | 121 return leftToRightDecl; |
115 } | 122 } |
116 | 123 |
117 static StylePropertySet* rightToLeftDeclaration() | 124 static StylePropertySet* rightToLeftDeclaration() |
118 { | 125 { |
119 DEFINE_STATIC_REF(MutableStylePropertySet, rightToLeftDecl, (MutableStylePro pertySet::create())); | 126 DEFINE_STATIC_REF(MutableStylePropertySet, rightToLeftDecl, (MutableStylePro pertySet::create())); |
120 if (rightToLeftDecl->isEmpty()) | 127 if (rightToLeftDecl->isEmpty()) |
121 rightToLeftDecl->setProperty(CSSPropertyDirection, CSSValueRtl); | 128 rightToLeftDecl->setProperty(CSSPropertyDirection, CSSValueRtl); |
122 return rightToLeftDecl; | 129 return rightToLeftDecl; |
123 } | 130 } |
124 | 131 |
125 StyleResolver::StyleResolver(Document& document) | 132 StyleResolver::StyleResolver(Document& document) |
126 : m_document(document) | 133 : m_document(document) |
127 , m_fontSelector(CSSFontSelector::create(&document)) | 134 , m_fontSelector(CSSFontSelector::create(&document)) |
128 , m_viewportStyleResolver(ViewportStyleResolver::create(&document)) | 135 , m_viewportStyleResolver(ViewportStyleResolver::create(&document)) |
136 , m_needCollectFeatures(false) | |
129 , m_styleResourceLoader(document.fetcher()) | 137 , m_styleResourceLoader(document.fetcher()) |
130 , m_styleResolverStatsSequence(0) | 138 , m_styleResolverStatsSequence(0) |
131 { | 139 { |
132 Element* root = document.documentElement(); | 140 Element* root = document.documentElement(); |
133 | 141 |
134 m_fontSelector->registerForInvalidationCallbacks(this); | 142 m_fontSelector->registerForInvalidationCallbacks(this); |
135 | 143 |
136 CSSDefaultStyleSheets::initDefaultStyle(root); | 144 CSSDefaultStyleSheets::initDefaultStyle(root); |
137 | 145 |
138 // construct document root element default style. this is needed | 146 // construct document root element default style. this is needed |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
171 | 179 |
172 void StyleResolver::initWatchedSelectorRules(const Vector<RefPtr<StyleRule> >& w atchedSelectors) | 180 void StyleResolver::initWatchedSelectorRules(const Vector<RefPtr<StyleRule> >& w atchedSelectors) |
173 { | 181 { |
174 if (!watchedSelectors.size()) | 182 if (!watchedSelectors.size()) |
175 return; | 183 return; |
176 m_watchedSelectorsRules = RuleSet::create(); | 184 m_watchedSelectorsRules = RuleSet::create(); |
177 for (unsigned i = 0; i < watchedSelectors.size(); ++i) | 185 for (unsigned i = 0; i < watchedSelectors.size(); ++i) |
178 m_watchedSelectorsRules->addStyleRule(watchedSelectors[i].get(), RuleHas NoSpecialState); | 186 m_watchedSelectorsRules->addStyleRule(watchedSelectors[i].get(), RuleHas NoSpecialState); |
179 } | 187 } |
180 | 188 |
189 void StyleResolver::filterViewportRules(const Vector<RefPtr<StyleRuleBase> >& ru les, bool& needsResolveViewport) | |
esprehn
2013/11/15 10:36:32
Return a boolean instead.
tasak
2013/11/18 08:30:53
Done.
| |
190 { | |
191 for (unsigned i = 0; i < rules.size(); ++i) { | |
192 StyleRuleBase* rule = rules[i].get(); | |
193 | |
194 if (rule->isViewportRule()) { | |
195 m_styleTree.ensureScopedStyleResolver(m_document)->addViewportRule(t oStyleRuleViewport(rule)); | |
196 needsResolveViewport = true; | |
197 } else if (rule->isMediaRule()) { | |
198 const StyleRuleMedia* mediaRule = toStyleRuleMedia(rule); | |
199 if ((!mediaRule->mediaQueries() || m_medium->eval(mediaRule->mediaQu eries(), viewportDependentMediaQueryResults()))) | |
200 filterViewportRules(mediaRule->childRules(), needsResolveViewpor t); | |
201 } | |
202 } | |
203 } | |
204 | |
205 void StyleResolver::filterViewportRulesFromSheet(StyleSheetContents* sheet, bool & needsResolveViewport) | |
esprehn
2013/11/15 10:36:32
Ditto, return a boolean.
tasak
2013/11/18 08:30:53
Done.
| |
206 { | |
207 if (!sheet) | |
208 return; | |
209 | |
210 if (sheet->importRules().size() > 0) { | |
esprehn
2013/11/15 10:36:32
There's no reason to check if the Vector size is >
tasak
2013/11/18 08:30:53
Done.
| |
211 const Vector<RefPtr<StyleRuleImport> >& importRules = sheet->importRules (); | |
212 for (unsigned i = 0; i < importRules.size(); ++i) { | |
213 StyleRuleImport* importRule = importRules[i].get(); | |
214 filterViewportRulesFromSheet(importRule->styleSheet(), needsResolveV iewport); | |
215 } | |
216 } | |
217 filterViewportRules(sheet->childRules(), needsResolveViewport); | |
218 } | |
219 | |
220 bool StyleResolver::filterViewportRulesFromAuthorStyleSheets(unsigned firstNew, const Vector<RefPtr<CSSStyleSheet> >& styleSheets) | |
221 { | |
222 bool needsResolveViewport = false; | |
223 | |
224 unsigned size = styleSheets.size(); | |
225 for (unsigned i = firstNew; i < size; ++i) { | |
226 CSSStyleSheet* cssSheet = styleSheets[i].get(); | |
227 ASSERT(!cssSheet->disabled()); | |
228 if (cssSheet->mediaQueries() && !m_medium->eval(cssSheet->mediaQueries() , &m_viewportDependentMediaQueryResults)) | |
229 continue; | |
230 if (cssSheet->ownerNode()->isInShadowTree() || !isDocumentScope(ScopedSt yleResolver::scopingNodeFor(cssSheet))) | |
231 continue; | |
232 filterViewportRulesFromSheet(cssSheet->contents(), needsResolveViewport) ; | |
233 } | |
234 return needsResolveViewport; | |
235 } | |
236 | |
237 void StyleResolver::lazyAppendAuthorStyleSheets(unsigned firstNew, const Vector< RefPtr<CSSStyleSheet> >& styleSheets) | |
238 { | |
239 // FIXME: Currently We cannot lazy apppend stylesheets if the sheets have @v iewport rules. | |
240 // Need to find the best place to update pending stylesheets for "viewport" rules. | |
241 bool needsResolveViewport = filterViewportRulesFromAuthorStyleSheets(firstNe w, styleSheets); | |
242 | |
243 unsigned size = styleSheets.size(); | |
244 for (unsigned i = firstNew; i < size; ++i) | |
245 m_pendingStyleSheets.add(styleSheets[i].get()); | |
246 | |
247 if (needsResolveViewport) | |
248 collectViewportRules(); | |
249 } | |
250 | |
251 void StyleResolver::removePendingAuthorStyleSheets(const Vector<RefPtr<CSSStyleS heet> >& styleSheets) | |
252 { | |
253 for (unsigned i = 0; i < styleSheets.size(); ++i) | |
254 m_pendingStyleSheets.remove(styleSheets[i].get()); | |
255 } | |
256 | |
257 void StyleResolver::appendPendingAuthorStyleSheets() | |
258 { | |
259 setBuildScopedStyleTreeInDocumentOrder(false); | |
260 for (ListHashSet<CSSStyleSheet*, 16>::iterator it = m_pendingStyleSheets.beg in(); it != m_pendingStyleSheets.end(); ++it) { | |
261 CSSStyleSheet* cssSheet = *it; | |
262 ASSERT(!cssSheet->disabled()); | |
263 if (cssSheet->mediaQueries() && !m_medium->eval(cssSheet->mediaQueries() , &m_viewportDependentMediaQueryResults)) | |
264 continue; | |
265 | |
266 StyleSheetContents* sheet = cssSheet->contents(); | |
267 ContainerNode* scopingNode = ScopedStyleResolver::scopingNodeFor(cssShee t); | |
268 if (!scopingNode && cssSheet->ownerNode() && cssSheet->ownerNode()->isIn ShadowTree()) | |
269 continue; | |
270 | |
271 ScopedStyleResolver* resolver = ensureScopedStyleResolver(scopingNode); | |
272 ASSERT(resolver); | |
273 resolver->addRulesFromSheet(sheet, *m_medium, this, true); | |
274 m_inspectorCSSOMWrappers.collectFromStyleSheetIfNeeded(cssSheet); | |
275 } | |
276 m_pendingStyleSheets.clear(); | |
277 finishAppendAuthorStyleSheets(); | |
278 } | |
279 | |
181 void StyleResolver::appendAuthorStyleSheets(unsigned firstNew, const Vector<RefP tr<CSSStyleSheet> >& styleSheets) | 280 void StyleResolver::appendAuthorStyleSheets(unsigned firstNew, const Vector<RefP tr<CSSStyleSheet> >& styleSheets) |
182 { | 281 { |
183 // This handles sheets added to the end of the stylesheet list only. In othe r cases the style resolver | 282 // This handles sheets added to the end of the stylesheet list only. In othe r cases the style resolver |
184 // needs to be reconstructed. To handle insertions too the rule order number s would need to be updated. | 283 // needs to be reconstructed. To handle insertions too the rule order number s would need to be updated. |
185 unsigned size = styleSheets.size(); | 284 unsigned size = styleSheets.size(); |
186 for (unsigned i = firstNew; i < size; ++i) { | 285 for (unsigned i = firstNew; i < size; ++i) { |
187 CSSStyleSheet* cssSheet = styleSheets[i].get(); | 286 CSSStyleSheet* cssSheet = styleSheets[i].get(); |
188 ASSERT(!cssSheet->disabled()); | 287 ASSERT(!cssSheet->disabled()); |
189 if (cssSheet->mediaQueries() && !m_medium->eval(cssSheet->mediaQueries() , &m_viewportDependentMediaQueryResults)) | 288 if (cssSheet->mediaQueries() && !m_medium->eval(cssSheet->mediaQueries() , &m_viewportDependentMediaQueryResults)) |
190 continue; | 289 continue; |
191 | 290 |
192 StyleSheetContents* sheet = cssSheet->contents(); | 291 StyleSheetContents* sheet = cssSheet->contents(); |
193 ContainerNode* scopingNode = ScopedStyleResolver::scopingNodeFor(cssShee t); | 292 ContainerNode* scopingNode = ScopedStyleResolver::scopingNodeFor(cssShee t); |
194 if (!scopingNode && cssSheet->ownerNode() && cssSheet->ownerNode()->isIn ShadowTree()) | 293 if (!scopingNode && cssSheet->ownerNode() && cssSheet->ownerNode()->isIn ShadowTree()) |
195 continue; | 294 continue; |
196 | 295 |
197 ScopedStyleResolver* resolver = ensureScopedStyleResolver(scopingNode); | 296 ScopedStyleResolver* resolver = ensureScopedStyleResolver(scopingNode); |
198 ASSERT(resolver); | 297 ASSERT(resolver); |
199 resolver->addRulesFromSheet(sheet, *m_medium, this); | 298 resolver->addRulesFromSheet(sheet, *m_medium, this, false); |
200 m_inspectorCSSOMWrappers.collectFromStyleSheetIfNeeded(cssSheet); | 299 m_inspectorCSSOMWrappers.collectFromStyleSheetIfNeeded(cssSheet); |
201 } | 300 } |
202 } | 301 } |
203 | 302 |
204 void StyleResolver::finishAppendAuthorStyleSheets() | 303 void StyleResolver::finishAppendAuthorStyleSheets() |
205 { | 304 { |
206 collectFeatures(); | 305 collectFeatures(); |
207 | 306 |
208 if (document().renderer() && document().renderer()->style()) | 307 if (document().renderer() && document().renderer()->style()) |
209 document().renderer()->style()->font().update(fontSelector()); | 308 document().renderer()->style()->font().update(fontSelector()); |
210 | 309 |
211 collectViewportRules(); | 310 collectViewportRules(); |
311 | |
312 document().styleEngine()->resetCSSFeatureFlags(m_features); | |
313 } | |
314 | |
315 void StyleResolver::resetRuleFeatures() | |
316 { | |
317 // Need to recreate RuleFeatureSet. | |
318 m_features.clear(); | |
319 m_siblingRuleSet.clear(); | |
320 m_uncommonAttributeRuleSet.clear(); | |
321 m_needCollectFeatures = true; | |
212 } | 322 } |
213 | 323 |
214 void StyleResolver::addTreeBoundaryCrossingRules(const Vector<MinimalRuleData>& rules, ContainerNode* scope) | 324 void StyleResolver::addTreeBoundaryCrossingRules(const Vector<MinimalRuleData>& rules, ContainerNode* scope) |
215 { | 325 { |
216 for (unsigned i = 0; i < rules.size(); ++i) { | 326 for (unsigned i = 0; i < rules.size(); ++i) { |
217 const MinimalRuleData& info = rules[i]; | 327 const MinimalRuleData& info = rules[i]; |
218 m_treeBoundaryCrossingRules.addRule(info.m_rule, info.m_selectorIndex, s cope, info.m_flags); | 328 m_treeBoundaryCrossingRules.addRule(info.m_rule, info.m_selectorIndex, s cope, info.m_flags); |
219 } | 329 } |
220 } | 330 } |
221 | 331 |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
253 { | 363 { |
254 // FIXME: When chanking scoped attribute, scopingNode's hasScopedHTMLStyleCh ild has been already modified. | 364 // FIXME: When chanking scoped attribute, scopingNode's hasScopedHTMLStyleCh ild has been already modified. |
255 // So we cannot use hasScopedHTMLStyleChild flag here. | 365 // So we cannot use hasScopedHTMLStyleChild flag here. |
256 ScopedStyleResolver* resolver = scopingNode ? m_styleTree.lookupScopedStyleR esolverFor(scopingNode) : m_styleTree.scopedStyleResolverForDocument(); | 366 ScopedStyleResolver* resolver = scopingNode ? m_styleTree.lookupScopedStyleR esolverFor(scopingNode) : m_styleTree.scopedStyleResolverForDocument(); |
257 if (!resolver) | 367 if (!resolver) |
258 return; | 368 return; |
259 | 369 |
260 treeBoundaryCrossingRules().reset(scopingNode); | 370 treeBoundaryCrossingRules().reset(scopingNode); |
261 | 371 |
262 resolver->resetAuthorStyle(); | 372 resolver->resetAuthorStyle(); |
373 resetRuleFeatures(); | |
263 if (!scopingNode) | 374 if (!scopingNode) |
264 return; | 375 return; |
265 | 376 |
266 if (scopingNode->isInShadowTree()) | 377 if (scopingNode->isInShadowTree()) |
267 resetAtHostRules(scopingNode->containingShadowRoot()); | 378 resetAtHostRules(scopingNode->containingShadowRoot()); |
268 | 379 |
269 if (!resolver->hasOnlyEmptyRuleSets()) | 380 if (!resolver->hasOnlyEmptyRuleSets()) |
270 return; | 381 return; |
271 | 382 |
272 m_styleTree.remove(scopingNode); | 383 m_styleTree.remove(scopingNode); |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
315 | 426 |
316 if (m_watchedSelectorsRules) | 427 if (m_watchedSelectorsRules) |
317 m_features.add(m_watchedSelectorsRules->features()); | 428 m_features.add(m_watchedSelectorsRules->features()); |
318 | 429 |
319 m_treeBoundaryCrossingRules.collectFeaturesTo(m_features); | 430 m_treeBoundaryCrossingRules.collectFeaturesTo(m_features); |
320 | 431 |
321 m_styleTree.collectFeaturesTo(m_features); | 432 m_styleTree.collectFeaturesTo(m_features); |
322 | 433 |
323 m_siblingRuleSet = makeRuleSet(m_features.siblingRules); | 434 m_siblingRuleSet = makeRuleSet(m_features.siblingRules); |
324 m_uncommonAttributeRuleSet = makeRuleSet(m_features.uncommonAttributeRules); | 435 m_uncommonAttributeRuleSet = makeRuleSet(m_features.uncommonAttributeRules); |
436 m_needCollectFeatures = false; | |
325 } | 437 } |
326 | 438 |
327 bool StyleResolver::hasRulesForId(const AtomicString& id) const | 439 bool StyleResolver::hasRulesForId(const AtomicString& id) const |
328 { | 440 { |
329 return m_features.idsInRules.contains(id.impl()); | 441 return m_features.idsInRules.contains(id.impl()); |
330 } | 442 } |
331 | 443 |
332 void StyleResolver::addToStyleSharingList(Element& element) | 444 void StyleResolver::addToStyleSharingList(Element& element) |
333 { | 445 { |
334 // Never add elements to the style sharing list if we're not in a recalcStyl e, | 446 // Never add elements to the style sharing list if we're not in a recalcStyl e, |
(...skipping 312 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
647 { | 759 { |
648 for (size_t i = 0; i < contentAttrValues.size(); ++i) | 760 for (size_t i = 0; i < contentAttrValues.size(); ++i) |
649 features.attrsInRules.add(contentAttrValues[i].impl()); | 761 features.attrsInRules.add(contentAttrValues[i].impl()); |
650 } | 762 } |
651 | 763 |
652 PassRefPtr<RenderStyle> StyleResolver::styleForElement(Element* element, RenderS tyle* defaultParent, StyleSharingBehavior sharingBehavior, | 764 PassRefPtr<RenderStyle> StyleResolver::styleForElement(Element* element, RenderS tyle* defaultParent, StyleSharingBehavior sharingBehavior, |
653 RuleMatchingBehavior matchingBehavior, RenderRegion* regionForStyling) | 765 RuleMatchingBehavior matchingBehavior, RenderRegion* regionForStyling) |
654 { | 766 { |
655 ASSERT(document().frame()); | 767 ASSERT(document().frame()); |
656 ASSERT(documentSettings()); | 768 ASSERT(documentSettings()); |
769 ASSERT(!hasPendingAuthorStyleSheets()); | |
770 ASSERT(!m_needCollectFeatures); | |
657 | 771 |
658 // Once an element has a renderer, we don't try to destroy it, since otherwi se the renderer | 772 // Once an element has a renderer, we don't try to destroy it, since otherwi se the renderer |
659 // will vanish if a style recalc happens during loading. | 773 // will vanish if a style recalc happens during loading. |
660 if (sharingBehavior == AllowStyleSharing && !element->document().haveStylesh eetsLoaded() && !element->renderer()) { | 774 if (sharingBehavior == AllowStyleSharing && !element->document().haveStylesh eetsLoaded() && !element->renderer()) { |
661 if (!s_styleNotYetAvailable) { | 775 if (!s_styleNotYetAvailable) { |
662 s_styleNotYetAvailable = RenderStyle::create().leakRef(); | 776 s_styleNotYetAvailable = RenderStyle::create().leakRef(); |
663 s_styleNotYetAvailable->setDisplay(NONE); | 777 s_styleNotYetAvailable->setDisplay(NONE); |
664 s_styleNotYetAvailable->font().update(m_fontSelector); | 778 s_styleNotYetAvailable->font().update(m_fontSelector); |
665 } | 779 } |
666 element->document().setHasNodesWithPlaceholderStyle(); | 780 element->document().setHasNodesWithPlaceholderStyle(); |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
740 setAnimationUpdateIfNeeded(state, *element); | 854 setAnimationUpdateIfNeeded(state, *element); |
741 | 855 |
742 // Now return the style. | 856 // Now return the style. |
743 return state.takeStyle(); | 857 return state.takeStyle(); |
744 } | 858 } |
745 | 859 |
746 PassRefPtr<RenderStyle> StyleResolver::styleForKeyframe(Element* e, const Render Style& elementStyle, const StyleKeyframe* keyframe) | 860 PassRefPtr<RenderStyle> StyleResolver::styleForKeyframe(Element* e, const Render Style& elementStyle, const StyleKeyframe* keyframe) |
747 { | 861 { |
748 ASSERT(document().frame()); | 862 ASSERT(document().frame()); |
749 ASSERT(documentSettings()); | 863 ASSERT(documentSettings()); |
864 ASSERT(!hasPendingAuthorStyleSheets()); | |
750 | 865 |
751 if (e == document().documentElement()) | 866 if (e == document().documentElement()) |
752 resetDirectionAndWritingModeOnDocument(document()); | 867 resetDirectionAndWritingModeOnDocument(document()); |
753 StyleResolverState state(document(), e); | 868 StyleResolverState state(document(), e); |
754 | 869 |
755 MatchResult result; | 870 MatchResult result; |
756 if (keyframe->properties()) | 871 if (keyframe->properties()) |
757 result.addMatchedProperties(keyframe->properties()); | 872 result.addMatchedProperties(keyframe->properties()); |
758 | 873 |
759 ASSERT(!state.style()); | 874 ASSERT(!state.style()); |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
798 | 913 |
799 void StyleResolver::keyframeStylesForAnimation(Element* e, const RenderStyle& el ementStyle, KeyframeList& list) | 914 void StyleResolver::keyframeStylesForAnimation(Element* e, const RenderStyle& el ementStyle, KeyframeList& list) |
800 { | 915 { |
801 ASSERT(!RuntimeEnabledFeatures::webAnimationsCSSEnabled()); | 916 ASSERT(!RuntimeEnabledFeatures::webAnimationsCSSEnabled()); |
802 list.clear(); | 917 list.clear(); |
803 | 918 |
804 // Get the keyframesRule for this name | 919 // Get the keyframesRule for this name |
805 if (!e || list.animationName().isEmpty()) | 920 if (!e || list.animationName().isEmpty()) |
806 return; | 921 return; |
807 | 922 |
923 ASSERT(!hasPendingAuthorStyleSheets()); | |
808 const StyleRuleKeyframes* keyframesRule = CSSAnimations::matchScopedKeyframe sRule(this, e, list.animationName().impl()); | 924 const StyleRuleKeyframes* keyframesRule = CSSAnimations::matchScopedKeyframe sRule(this, e, list.animationName().impl()); |
809 if (!keyframesRule) | 925 if (!keyframesRule) |
810 return; | 926 return; |
811 | 927 |
812 // Construct and populate the style for each keyframe | 928 // Construct and populate the style for each keyframe |
813 const Vector<RefPtr<StyleKeyframe> >& keyframes = keyframesRule->keyframes() ; | 929 const Vector<RefPtr<StyleKeyframe> >& keyframes = keyframesRule->keyframes() ; |
814 for (unsigned i = 0; i < keyframes.size(); ++i) { | 930 for (unsigned i = 0; i < keyframes.size(); ++i) { |
815 // Apply the declaration to the style. This is a simplified version of t he logic in styleForElement | 931 // Apply the declaration to the style. This is a simplified version of t he logic in styleForElement |
816 const StyleKeyframe* keyframe = keyframes[i].get(); | 932 const StyleKeyframe* keyframe = keyframes[i].get(); |
817 | 933 |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
906 | 1022 |
907 if (PseudoElement* pseudoElement = e->pseudoElement(pseudoStyleRequest.pseud oId)) | 1023 if (PseudoElement* pseudoElement = e->pseudoElement(pseudoStyleRequest.pseud oId)) |
908 setAnimationUpdateIfNeeded(state, *pseudoElement); | 1024 setAnimationUpdateIfNeeded(state, *pseudoElement); |
909 | 1025 |
910 // Now return the style. | 1026 // Now return the style. |
911 return state.takeStyle(); | 1027 return state.takeStyle(); |
912 } | 1028 } |
913 | 1029 |
914 PassRefPtr<RenderStyle> StyleResolver::styleForPage(int pageIndex) | 1030 PassRefPtr<RenderStyle> StyleResolver::styleForPage(int pageIndex) |
915 { | 1031 { |
1032 ASSERT(!hasPendingAuthorStyleSheets()); | |
916 resetDirectionAndWritingModeOnDocument(document()); | 1033 resetDirectionAndWritingModeOnDocument(document()); |
917 StyleResolverState state(document(), document().documentElement()); // m_roo tElementStyle will be set to the document style. | 1034 StyleResolverState state(document(), document().documentElement()); // m_roo tElementStyle will be set to the document style. |
918 | 1035 |
919 state.setStyle(RenderStyle::create()); | 1036 state.setStyle(RenderStyle::create()); |
920 const RenderStyle* rootElementStyle = state.rootElementStyle() ? state.rootE lementStyle() : document().renderStyle(); | 1037 const RenderStyle* rootElementStyle = state.rootElementStyle() ? state.rootE lementStyle() : document().renderStyle(); |
921 ASSERT(rootElementStyle); | 1038 ASSERT(rootElementStyle); |
922 state.style()->inheritFrom(rootElementStyle); | 1039 state.style()->inheritFrom(rootElementStyle); |
923 | 1040 |
924 state.fontBuilder().initForStyleResolve(state.document(), state.style(), sta te.useSVGZoomRules()); | 1041 state.fontBuilder().initForStyleResolve(state.document(), state.style(), sta te.useSVGZoomRules()); |
925 | 1042 |
(...skipping 491 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1417 bool StyleResolver::affectedByViewportChange() const | 1534 bool StyleResolver::affectedByViewportChange() const |
1418 { | 1535 { |
1419 for (unsigned i = 0; i < m_viewportDependentMediaQueryResults.size(); ++i) { | 1536 for (unsigned i = 0; i < m_viewportDependentMediaQueryResults.size(); ++i) { |
1420 if (m_medium->eval(&m_viewportDependentMediaQueryResults[i]->m_expressio n) != m_viewportDependentMediaQueryResults[i]->m_result) | 1537 if (m_medium->eval(&m_viewportDependentMediaQueryResults[i]->m_expressio n) != m_viewportDependentMediaQueryResults[i]->m_result) |
1421 return true; | 1538 return true; |
1422 } | 1539 } |
1423 return false; | 1540 return false; |
1424 } | 1541 } |
1425 | 1542 |
1426 } // namespace WebCore | 1543 } // namespace WebCore |
OLD | NEW |