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 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
119 DEFINE_STATIC_REF(MutableStylePropertySet, rightToLeftDecl, (MutableStylePro pertySet::create())); | 121 DEFINE_STATIC_REF(MutableStylePropertySet, rightToLeftDecl, (MutableStylePro pertySet::create())); |
120 if (rightToLeftDecl->isEmpty()) | 122 if (rightToLeftDecl->isEmpty()) |
121 rightToLeftDecl->setProperty(CSSPropertyDirection, CSSValueRtl); | 123 rightToLeftDecl->setProperty(CSSPropertyDirection, CSSValueRtl); |
122 return rightToLeftDecl; | 124 return rightToLeftDecl; |
123 } | 125 } |
124 | 126 |
125 StyleResolver::StyleResolver(Document& document) | 127 StyleResolver::StyleResolver(Document& document) |
126 : m_document(document) | 128 : m_document(document) |
127 , m_fontSelector(CSSFontSelector::create(&document)) | 129 , m_fontSelector(CSSFontSelector::create(&document)) |
128 , m_viewportStyleResolver(ViewportStyleResolver::create(&document)) | 130 , m_viewportStyleResolver(ViewportStyleResolver::create(&document)) |
131 , m_needCollectFeatures(false) | |
129 , m_styleResourceLoader(document.fetcher()) | 132 , m_styleResourceLoader(document.fetcher()) |
130 , m_styleResolverStatsSequence(0) | 133 , m_styleResolverStatsSequence(0) |
131 { | 134 { |
132 Element* root = document.documentElement(); | 135 Element* root = document.documentElement(); |
133 | 136 |
134 m_fontSelector->registerForInvalidationCallbacks(this); | 137 m_fontSelector->registerForInvalidationCallbacks(this); |
135 | 138 |
136 CSSDefaultStyleSheets::initDefaultStyle(root); | 139 CSSDefaultStyleSheets::initDefaultStyle(root); |
137 | 140 |
138 // construct document root element default style. this is needed | 141 // construct document root element default style. this is needed |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
171 | 174 |
172 void StyleResolver::initWatchedSelectorRules(const Vector<RefPtr<StyleRule> >& w atchedSelectors) | 175 void StyleResolver::initWatchedSelectorRules(const Vector<RefPtr<StyleRule> >& w atchedSelectors) |
173 { | 176 { |
174 if (!watchedSelectors.size()) | 177 if (!watchedSelectors.size()) |
175 return; | 178 return; |
176 m_watchedSelectorsRules = RuleSet::create(); | 179 m_watchedSelectorsRules = RuleSet::create(); |
177 for (unsigned i = 0; i < watchedSelectors.size(); ++i) | 180 for (unsigned i = 0; i < watchedSelectors.size(); ++i) |
178 m_watchedSelectorsRules->addStyleRule(watchedSelectors[i].get(), RuleHas NoSpecialState); | 181 m_watchedSelectorsRules->addStyleRule(watchedSelectors[i].get(), RuleHas NoSpecialState); |
179 } | 182 } |
180 | 183 |
184 void StyleResolver::filterViewportRules(const Vector<RefPtr<StyleRuleBase> >& ru les, bool& needsResolveViewport) | |
185 { | |
186 for (unsigned i = 0; i < rules.size(); ++i) { | |
187 StyleRuleBase* rule = rules[i].get(); | |
188 | |
189 if (rule->isViewportRule()) { | |
190 m_styleTree.ensureScopedStyleResolver(m_document)->addViewportRule(t oStyleRuleViewport(rule)); | |
191 needsResolveViewport = true; | |
192 } else if (rule->isMediaRule()) { | |
193 const StyleRuleMedia* mediaRule = toStyleRuleMedia(rule); | |
194 if ((!mediaRule->mediaQueries() || m_medium->eval(mediaRule->mediaQu eries(), viewportDependentMediaQueryResults()))) | |
195 filterViewportRules(mediaRule->childRules(), needsResolveViewpor t); | |
196 } | |
197 } | |
198 } | |
199 | |
200 void StyleResolver::filterViewportRulesFromSheet(StyleSheetContents* sheet, bool & needsResolveViewport) | |
201 { | |
202 if (!sheet) | |
203 return; | |
204 | |
205 if (sheet->importRules().size() > 0) { | |
206 const Vector<RefPtr<StyleRuleImport> >& importRules = sheet->importRules (); | |
207 for (unsigned i = 0; i < importRules.size(); ++i) { | |
208 StyleRuleImport* importRule = importRules[i].get(); | |
209 filterViewportRulesFromSheet(importRule->styleSheet(), needsResolveV iewport); | |
210 } | |
211 } | |
212 filterViewportRules(sheet->childRules(), needsResolveViewport); | |
213 } | |
214 | |
215 bool StyleResolver::filterViewportRulesFromAuthorStyleSheets(unsigned firstNew, const Vector<RefPtr<CSSStyleSheet> >& styleSheets) | |
216 { | |
217 bool needsResolveViewport = false; | |
218 | |
219 unsigned size = styleSheets.size(); | |
220 for (unsigned i = firstNew; i < size; ++i) { | |
221 CSSStyleSheet* cssSheet = styleSheets[i].get(); | |
222 ASSERT(!cssSheet->disabled()); | |
223 if (cssSheet->mediaQueries() && !m_medium->eval(cssSheet->mediaQueries() , &m_viewportDependentMediaQueryResults)) | |
224 continue; | |
225 if (cssSheet->ownerNode()->isInShadowTree() || !isDocumentScope(ScopedSt yleResolver::scopingNodeFor(cssSheet))) | |
226 continue; | |
227 filterViewportRulesFromSheet(cssSheet->contents(), needsResolveViewport) ; | |
228 } | |
229 return needsResolveViewport; | |
230 } | |
231 | |
232 void StyleResolver::lazyAppendAuthorStyleSheets(unsigned firstNew, const Vector< RefPtr<CSSStyleSheet> >& styleSheets) | |
233 { | |
234 // FIXME: Currently We cannot lazy apppend stylesheets if the sheets have @v iewport and @font-face rules. | |
235 // Need to find the best place to update pending stylesheets for "viewport" rules. | |
236 // Talking about @font-face rules, addFontFaceRule triggers loading font res ources. | |
237 // If we delays "addFontFaceRule", we probably wait more time until fonts ar e loaded. | |
dglazkov
2013/11/13 16:29:22
/delays/delay/s ... /probably/could/s
tasak
2013/11/14 11:25:46
I removed this, because now we can lazily add @fon
| |
238 // At least, we should filter @viewport and @font-face here and should lazil y add other rules if possible. | |
239 bool needsResolveViewport = filterViewportRulesFromAuthorStyleSheets(firstNe w, styleSheets); | |
240 | |
241 unsigned size = styleSheets.size(); | |
242 for (unsigned i = firstNew; i < size; ++i) | |
243 m_pendingStyleSheets.add(styleSheets[i].get()); | |
244 | |
245 if (needsResolveViewport) | |
246 collectViewportRules(); | |
247 } | |
248 | |
249 void StyleResolver::removePendingAuthorStyleSheets(const Vector<RefPtr<CSSStyleS heet> >& styleSheets) | |
250 { | |
251 for (unsigned i = 0; i < styleSheets.size(); ++i) | |
252 m_pendingStyleSheets.remove(styleSheets[i].get()); | |
253 } | |
254 | |
255 void StyleResolver::appendPendingAuthorStyleSheets() | |
256 { | |
257 setBuildScopedStyleTreeInDocumentOrder(false); | |
258 for (ListHashSet<CSSStyleSheet*, 16>::iterator it = m_pendingStyleSheets.beg in(); it != m_pendingStyleSheets.end(); ++it) { | |
259 CSSStyleSheet* cssSheet = *it; | |
260 ASSERT(!cssSheet->disabled()); | |
261 if (cssSheet->mediaQueries() && !m_medium->eval(cssSheet->mediaQueries() , &m_viewportDependentMediaQueryResults)) | |
262 continue; | |
263 | |
264 StyleSheetContents* sheet = cssSheet->contents(); | |
265 const ContainerNode* scopingNode = ScopedStyleResolver::scopingNodeFor(c ssSheet); | |
266 if (!scopingNode && cssSheet->ownerNode() && cssSheet->ownerNode()->isIn ShadowTree()) | |
267 continue; | |
268 | |
269 ScopedStyleResolver* resolver = ensureScopedStyleResolver(scopingNode); | |
270 ASSERT(resolver); | |
271 resolver->addRulesFromSheet(sheet, *m_medium, this, true); | |
272 m_inspectorCSSOMWrappers.collectFromStyleSheetIfNeeded(cssSheet); | |
273 } | |
274 m_pendingStyleSheets.clear(); | |
275 finishAppendAuthorStyleSheets(); | |
276 } | |
277 | |
181 void StyleResolver::appendAuthorStyleSheets(unsigned firstNew, const Vector<RefP tr<CSSStyleSheet> >& styleSheets) | 278 void StyleResolver::appendAuthorStyleSheets(unsigned firstNew, const Vector<RefP tr<CSSStyleSheet> >& styleSheets) |
182 { | 279 { |
183 // This handles sheets added to the end of the stylesheet list only. In othe r cases the style resolver | 280 // 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. | 281 // needs to be reconstructed. To handle insertions too the rule order number s would need to be updated. |
185 unsigned size = styleSheets.size(); | 282 unsigned size = styleSheets.size(); |
186 for (unsigned i = firstNew; i < size; ++i) { | 283 for (unsigned i = firstNew; i < size; ++i) { |
187 CSSStyleSheet* cssSheet = styleSheets[i].get(); | 284 CSSStyleSheet* cssSheet = styleSheets[i].get(); |
188 ASSERT(!cssSheet->disabled()); | 285 ASSERT(!cssSheet->disabled()); |
189 if (cssSheet->mediaQueries() && !m_medium->eval(cssSheet->mediaQueries() , &m_viewportDependentMediaQueryResults)) | 286 if (cssSheet->mediaQueries() && !m_medium->eval(cssSheet->mediaQueries() , &m_viewportDependentMediaQueryResults)) |
190 continue; | 287 continue; |
191 | 288 |
192 StyleSheetContents* sheet = cssSheet->contents(); | 289 StyleSheetContents* sheet = cssSheet->contents(); |
193 const ContainerNode* scopingNode = ScopedStyleResolver::scopingNodeFor(c ssSheet); | 290 const ContainerNode* scopingNode = ScopedStyleResolver::scopingNodeFor(c ssSheet); |
194 if (!scopingNode && cssSheet->ownerNode() && cssSheet->ownerNode()->isIn ShadowTree()) | 291 if (!scopingNode && cssSheet->ownerNode() && cssSheet->ownerNode()->isIn ShadowTree()) |
195 continue; | 292 continue; |
196 | 293 |
197 ScopedStyleResolver* resolver = ensureScopedStyleResolver(scopingNode); | 294 ScopedStyleResolver* resolver = ensureScopedStyleResolver(scopingNode); |
198 ASSERT(resolver); | 295 ASSERT(resolver); |
199 resolver->addRulesFromSheet(sheet, *m_medium, this); | 296 resolver->addRulesFromSheet(sheet, *m_medium, this, false); |
200 m_inspectorCSSOMWrappers.collectFromStyleSheetIfNeeded(cssSheet); | 297 m_inspectorCSSOMWrappers.collectFromStyleSheetIfNeeded(cssSheet); |
201 } | 298 } |
202 } | 299 } |
203 | 300 |
204 void StyleResolver::finishAppendAuthorStyleSheets() | 301 void StyleResolver::finishAppendAuthorStyleSheets() |
205 { | 302 { |
206 collectFeatures(); | 303 collectFeatures(); |
207 | 304 |
208 if (document().renderer() && document().renderer()->style()) | 305 if (document().renderer() && document().renderer()->style()) |
209 document().renderer()->style()->font().update(fontSelector()); | 306 document().renderer()->style()->font().update(fontSelector()); |
210 | 307 |
211 collectViewportRules(); | 308 collectViewportRules(); |
309 | |
310 document().styleEngine()->resetCSSFeatureFlags(m_features); | |
311 } | |
312 | |
313 void StyleResolver::resetRuleFeatures() | |
314 { | |
315 // Need to recreate RuleFeatureSet. | |
316 m_features.clear(); | |
317 m_siblingRuleSet.clear(); | |
318 m_uncommonAttributeRuleSet.clear(); | |
319 m_needCollectFeatures = true; | |
212 } | 320 } |
213 | 321 |
214 void StyleResolver::processScopedRules(const RuleSet& authorRules, const KURL& s heetBaseURL, const ContainerNode* scope) | 322 void StyleResolver::processScopedRules(const RuleSet& authorRules, const KURL& s heetBaseURL, const ContainerNode* scope) |
215 { | 323 { |
216 const Vector<StyleRuleKeyframes*> keyframesRules = authorRules.keyframesRule s(); | 324 const Vector<StyleRuleKeyframes*> keyframesRules = authorRules.keyframesRule s(); |
217 for (unsigned i = 0; i < keyframesRules.size(); ++i) | 325 for (unsigned i = 0; i < keyframesRules.size(); ++i) |
218 ensureScopedStyleResolver(scope)->addKeyframeStyle(keyframesRules[i]); | 326 ensureScopedStyleResolver(scope)->addKeyframeStyle(keyframesRules[i]); |
219 | 327 |
220 const Vector<StyleRuleHost*> hostRules = authorRules.hostRules(); | 328 const Vector<StyleRuleHost*> hostRules = authorRules.hostRules(); |
221 if (hostRules.size() && scope && scope->isInShadowTree()) { | 329 if (hostRules.size() && scope && scope->isInShadowTree()) { |
(...skipping 19 matching lines...) Expand all Loading... | |
241 { | 349 { |
242 // FIXME: When chanking scoped attribute, scopingNode's hasScopedHTMLStyleCh ild has been already modified. | 350 // FIXME: When chanking scoped attribute, scopingNode's hasScopedHTMLStyleCh ild has been already modified. |
243 // So we cannot use hasScopedHTMLStyleChild flag here. | 351 // So we cannot use hasScopedHTMLStyleChild flag here. |
244 ScopedStyleResolver* resolver = scopingNode ? m_styleTree.lookupScopedStyleR esolverFor(scopingNode) : m_styleTree.scopedStyleResolverForDocument(); | 352 ScopedStyleResolver* resolver = scopingNode ? m_styleTree.lookupScopedStyleR esolverFor(scopingNode) : m_styleTree.scopedStyleResolverForDocument(); |
245 if (!resolver) | 353 if (!resolver) |
246 return; | 354 return; |
247 | 355 |
248 treeBoundaryCrossingRules().reset(scopingNode); | 356 treeBoundaryCrossingRules().reset(scopingNode); |
249 | 357 |
250 resolver->resetAuthorStyle(); | 358 resolver->resetAuthorStyle(); |
359 resetRuleFeatures(); | |
251 if (!scopingNode) | 360 if (!scopingNode) |
252 return; | 361 return; |
253 | 362 |
254 if (scopingNode->isInShadowTree()) | 363 if (scopingNode->isInShadowTree()) |
255 resetAtHostRules(scopingNode->containingShadowRoot()); | 364 resetAtHostRules(scopingNode->containingShadowRoot()); |
256 | 365 |
257 if (!resolver->hasOnlyEmptyRuleSets()) | 366 if (!resolver->hasOnlyEmptyRuleSets()) |
258 return; | 367 return; |
259 | 368 |
260 m_styleTree.remove(scopingNode); | 369 m_styleTree.remove(scopingNode); |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
303 | 412 |
304 if (m_watchedSelectorsRules) | 413 if (m_watchedSelectorsRules) |
305 m_features.add(m_watchedSelectorsRules->features()); | 414 m_features.add(m_watchedSelectorsRules->features()); |
306 | 415 |
307 m_treeBoundaryCrossingRules.collectFeaturesTo(m_features); | 416 m_treeBoundaryCrossingRules.collectFeaturesTo(m_features); |
308 | 417 |
309 m_styleTree.collectFeaturesTo(m_features); | 418 m_styleTree.collectFeaturesTo(m_features); |
310 | 419 |
311 m_siblingRuleSet = makeRuleSet(m_features.siblingRules); | 420 m_siblingRuleSet = makeRuleSet(m_features.siblingRules); |
312 m_uncommonAttributeRuleSet = makeRuleSet(m_features.uncommonAttributeRules); | 421 m_uncommonAttributeRuleSet = makeRuleSet(m_features.uncommonAttributeRules); |
422 m_needCollectFeatures = false; | |
313 } | 423 } |
314 | 424 |
315 bool StyleResolver::hasRulesForId(const AtomicString& id) const | 425 bool StyleResolver::hasRulesForId(const AtomicString& id) const |
316 { | 426 { |
317 return m_features.idsInRules.contains(id.impl()); | 427 return m_features.idsInRules.contains(id.impl()); |
318 } | 428 } |
319 | 429 |
320 void StyleResolver::addToStyleSharingList(Element& element) | 430 void StyleResolver::addToStyleSharingList(Element& element) |
321 { | 431 { |
322 // Never add elements to the style sharing list if we're not in a recalcStyl e, | 432 // Never add elements to the style sharing list if we're not in a recalcStyl e, |
(...skipping 317 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
640 { | 750 { |
641 for (size_t i = 0; i < contentAttrValues.size(); ++i) | 751 for (size_t i = 0; i < contentAttrValues.size(); ++i) |
642 features.attrsInRules.add(contentAttrValues[i].impl()); | 752 features.attrsInRules.add(contentAttrValues[i].impl()); |
643 } | 753 } |
644 | 754 |
645 PassRefPtr<RenderStyle> StyleResolver::styleForElement(Element* element, RenderS tyle* defaultParent, StyleSharingBehavior sharingBehavior, | 755 PassRefPtr<RenderStyle> StyleResolver::styleForElement(Element* element, RenderS tyle* defaultParent, StyleSharingBehavior sharingBehavior, |
646 RuleMatchingBehavior matchingBehavior, RenderRegion* regionForStyling) | 756 RuleMatchingBehavior matchingBehavior, RenderRegion* regionForStyling) |
647 { | 757 { |
648 ASSERT(document().frame()); | 758 ASSERT(document().frame()); |
649 ASSERT(documentSettings()); | 759 ASSERT(documentSettings()); |
760 ASSERT(!hasPendingAuthorStyleSheets()); | |
761 ASSERT(!m_needCollectFeatures); | |
650 | 762 |
651 // Once an element has a renderer, we don't try to destroy it, since otherwi se the renderer | 763 // Once an element has a renderer, we don't try to destroy it, since otherwi se the renderer |
652 // will vanish if a style recalc happens during loading. | 764 // will vanish if a style recalc happens during loading. |
653 if (sharingBehavior == AllowStyleSharing && !element->document().haveStylesh eetsLoaded() && !element->renderer()) { | 765 if (sharingBehavior == AllowStyleSharing && !element->document().haveStylesh eetsLoaded() && !element->renderer()) { |
654 if (!s_styleNotYetAvailable) { | 766 if (!s_styleNotYetAvailable) { |
655 s_styleNotYetAvailable = RenderStyle::create().leakRef(); | 767 s_styleNotYetAvailable = RenderStyle::create().leakRef(); |
656 s_styleNotYetAvailable->setDisplay(NONE); | 768 s_styleNotYetAvailable->setDisplay(NONE); |
657 s_styleNotYetAvailable->font().update(m_fontSelector); | 769 s_styleNotYetAvailable->font().update(m_fontSelector); |
658 } | 770 } |
659 element->document().setHasNodesWithPlaceholderStyle(); | 771 element->document().setHasNodesWithPlaceholderStyle(); |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
733 setAnimationUpdateIfNeeded(state, *element); | 845 setAnimationUpdateIfNeeded(state, *element); |
734 | 846 |
735 // Now return the style. | 847 // Now return the style. |
736 return state.takeStyle(); | 848 return state.takeStyle(); |
737 } | 849 } |
738 | 850 |
739 PassRefPtr<RenderStyle> StyleResolver::styleForKeyframe(Element* e, const Render Style& elementStyle, const StyleKeyframe* keyframe) | 851 PassRefPtr<RenderStyle> StyleResolver::styleForKeyframe(Element* e, const Render Style& elementStyle, const StyleKeyframe* keyframe) |
740 { | 852 { |
741 ASSERT(document().frame()); | 853 ASSERT(document().frame()); |
742 ASSERT(documentSettings()); | 854 ASSERT(documentSettings()); |
855 ASSERT(!hasPendingAuthorStyleSheets()); | |
743 | 856 |
744 if (e == document().documentElement()) | 857 if (e == document().documentElement()) |
745 resetDirectionAndWritingModeOnDocument(document()); | 858 resetDirectionAndWritingModeOnDocument(document()); |
746 StyleResolverState state(document(), e); | 859 StyleResolverState state(document(), e); |
747 | 860 |
748 MatchResult result; | 861 MatchResult result; |
749 if (keyframe->properties()) | 862 if (keyframe->properties()) |
750 result.addMatchedProperties(keyframe->properties()); | 863 result.addMatchedProperties(keyframe->properties()); |
751 | 864 |
752 ASSERT(!state.style()); | 865 ASSERT(!state.style()); |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
791 | 904 |
792 void StyleResolver::keyframeStylesForAnimation(Element* e, const RenderStyle& el ementStyle, KeyframeList& list) | 905 void StyleResolver::keyframeStylesForAnimation(Element* e, const RenderStyle& el ementStyle, KeyframeList& list) |
793 { | 906 { |
794 ASSERT(!RuntimeEnabledFeatures::webAnimationsCSSEnabled()); | 907 ASSERT(!RuntimeEnabledFeatures::webAnimationsCSSEnabled()); |
795 list.clear(); | 908 list.clear(); |
796 | 909 |
797 // Get the keyframesRule for this name | 910 // Get the keyframesRule for this name |
798 if (!e || list.animationName().isEmpty()) | 911 if (!e || list.animationName().isEmpty()) |
799 return; | 912 return; |
800 | 913 |
914 if (hasPendingAuthorStyleSheets()) | |
915 appendPendingAuthorStyleSheets(); | |
916 | |
801 const StyleRuleKeyframes* keyframesRule = CSSAnimations::matchScopedKeyframe sRule(this, e, list.animationName().impl()); | 917 const StyleRuleKeyframes* keyframesRule = CSSAnimations::matchScopedKeyframe sRule(this, e, list.animationName().impl()); |
802 if (!keyframesRule) | 918 if (!keyframesRule) |
803 return; | 919 return; |
804 | 920 |
805 // Construct and populate the style for each keyframe | 921 // Construct and populate the style for each keyframe |
806 const Vector<RefPtr<StyleKeyframe> >& keyframes = keyframesRule->keyframes() ; | 922 const Vector<RefPtr<StyleKeyframe> >& keyframes = keyframesRule->keyframes() ; |
807 for (unsigned i = 0; i < keyframes.size(); ++i) { | 923 for (unsigned i = 0; i < keyframes.size(); ++i) { |
808 // Apply the declaration to the style. This is a simplified version of t he logic in styleForElement | 924 // Apply the declaration to the style. This is a simplified version of t he logic in styleForElement |
809 const StyleKeyframe* keyframe = keyframes[i].get(); | 925 const StyleKeyframe* keyframe = keyframes[i].get(); |
810 | 926 |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
899 | 1015 |
900 if (PseudoElement* pseudoElement = e->pseudoElement(pseudoStyleRequest.pseud oId)) | 1016 if (PseudoElement* pseudoElement = e->pseudoElement(pseudoStyleRequest.pseud oId)) |
901 setAnimationUpdateIfNeeded(state, *pseudoElement); | 1017 setAnimationUpdateIfNeeded(state, *pseudoElement); |
902 | 1018 |
903 // Now return the style. | 1019 // Now return the style. |
904 return state.takeStyle(); | 1020 return state.takeStyle(); |
905 } | 1021 } |
906 | 1022 |
907 PassRefPtr<RenderStyle> StyleResolver::styleForPage(int pageIndex) | 1023 PassRefPtr<RenderStyle> StyleResolver::styleForPage(int pageIndex) |
908 { | 1024 { |
1025 ASSERT(!hasPendingAuthorStyleSheets()); | |
909 resetDirectionAndWritingModeOnDocument(document()); | 1026 resetDirectionAndWritingModeOnDocument(document()); |
910 StyleResolverState state(document(), document().documentElement()); // m_roo tElementStyle will be set to the document style. | 1027 StyleResolverState state(document(), document().documentElement()); // m_roo tElementStyle will be set to the document style. |
911 | 1028 |
912 state.setStyle(RenderStyle::create()); | 1029 state.setStyle(RenderStyle::create()); |
913 const RenderStyle* rootElementStyle = state.rootElementStyle() ? state.rootE lementStyle() : document().renderStyle(); | 1030 const RenderStyle* rootElementStyle = state.rootElementStyle() ? state.rootE lementStyle() : document().renderStyle(); |
914 ASSERT(rootElementStyle); | 1031 ASSERT(rootElementStyle); |
915 state.style()->inheritFrom(rootElementStyle); | 1032 state.style()->inheritFrom(rootElementStyle); |
916 | 1033 |
917 state.fontBuilder().initForStyleResolve(state.document(), state.style(), sta te.useSVGZoomRules()); | 1034 state.fontBuilder().initForStyleResolve(state.document(), state.style(), sta te.useSVGZoomRules()); |
918 | 1035 |
(...skipping 492 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1411 { | 1528 { |
1412 unsigned s = m_viewportDependentMediaQueryResults.size(); | 1529 unsigned s = m_viewportDependentMediaQueryResults.size(); |
1413 for (unsigned i = 0; i < s; i++) { | 1530 for (unsigned i = 0; i < s; i++) { |
1414 if (m_medium->eval(&m_viewportDependentMediaQueryResults[i]->m_expressio n) != m_viewportDependentMediaQueryResults[i]->m_result) | 1531 if (m_medium->eval(&m_viewportDependentMediaQueryResults[i]->m_expressio n) != m_viewportDependentMediaQueryResults[i]->m_result) |
1415 return true; | 1532 return true; |
1416 } | 1533 } |
1417 return false; | 1534 return false; |
1418 } | 1535 } |
1419 | 1536 |
1420 } // namespace WebCore | 1537 } // namespace WebCore |
OLD | NEW |