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/ViewportStyleResolver.h" | 68 #include "core/css/resolver/ViewportStyleResolver.h" |
67 #include "core/dom/CSSSelectorWatch.h" | 69 #include "core/dom/CSSSelectorWatch.h" |
68 #include "core/dom/NodeRenderStyle.h" | 70 #include "core/dom/NodeRenderStyle.h" |
69 #include "core/dom/StyleEngine.h" | 71 #include "core/dom/StyleEngine.h" |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
131 if (rightToLeftDecl->isEmpty()) | 133 if (rightToLeftDecl->isEmpty()) |
132 rightToLeftDecl->setProperty(CSSPropertyDirection, CSSValueRtl); | 134 rightToLeftDecl->setProperty(CSSPropertyDirection, CSSValueRtl); |
133 return rightToLeftDecl.get(); | 135 return rightToLeftDecl.get(); |
134 } | 136 } |
135 | 137 |
136 StyleResolver::StyleResolver(Document& document, bool matchAuthorAndUserStyles) | 138 StyleResolver::StyleResolver(Document& document, bool matchAuthorAndUserStyles) |
137 : m_document(document) | 139 : m_document(document) |
138 , m_matchAuthorAndUserStyles(matchAuthorAndUserStyles) | 140 , m_matchAuthorAndUserStyles(matchAuthorAndUserStyles) |
139 , m_fontSelector(CSSFontSelector::create(&document)) | 141 , m_fontSelector(CSSFontSelector::create(&document)) |
140 , m_viewportStyleResolver(ViewportStyleResolver::create(&document)) | 142 , m_viewportStyleResolver(ViewportStyleResolver::create(&document)) |
143 , m_needCollectFeatures(false) | |
141 , m_styleResourceLoader(document.fetcher()) | 144 , m_styleResourceLoader(document.fetcher()) |
142 { | 145 { |
143 Element* root = document.documentElement(); | 146 Element* root = document.documentElement(); |
144 | 147 |
145 m_fontSelector->registerForInvalidationCallbacks(this); | 148 m_fontSelector->registerForInvalidationCallbacks(this); |
146 | 149 |
147 CSSDefaultStyleSheets::initDefaultStyle(root); | 150 CSSDefaultStyleSheets::initDefaultStyle(root); |
148 | 151 |
149 // construct document root element default style. this is needed | 152 // construct document root element default style. this is needed |
150 // to evaluate media queries that contain relative constraints, like "screen and (max-width: 10em)" | 153 // to evaluate media queries that contain relative constraints, like "screen and (max-width: 10em)" |
(...skipping 23 matching lines...) Expand all Loading... | |
174 const HashSet<SVGFontFaceElement*>& svgFontFaceElements = document.svgEx tensions()->svgFontFaceElements(); | 177 const HashSet<SVGFontFaceElement*>& svgFontFaceElements = document.svgEx tensions()->svgFontFaceElements(); |
175 HashSet<SVGFontFaceElement*>::const_iterator end = svgFontFaceElements.e nd(); | 178 HashSet<SVGFontFaceElement*>::const_iterator end = svgFontFaceElements.e nd(); |
176 for (HashSet<SVGFontFaceElement*>::const_iterator it = svgFontFaceElemen ts.begin(); it != end; ++it) | 179 for (HashSet<SVGFontFaceElement*>::const_iterator it = svgFontFaceElemen ts.begin(); it != end; ++it) |
177 fontSelector()->addFontFaceRule((*it)->fontFaceRule()); | 180 fontSelector()->addFontFaceRule((*it)->fontFaceRule()); |
178 } | 181 } |
179 #endif | 182 #endif |
180 | 183 |
181 styleSheetCollection->appendActiveAuthorStyleSheets(this); | 184 styleSheetCollection->appendActiveAuthorStyleSheets(this); |
182 } | 185 } |
183 | 186 |
187 void StyleResolver::filterFontFaceAndViewportRules(const Vector<RefPtr<StyleRule Base> >& rules, bool& needsResolveViewport) | |
188 { | |
189 for (unsigned i = 0; i < rules.size(); ++i) { | |
190 StyleRuleBase* rule = rules[i].get(); | |
191 | |
192 if (rule->isFontFaceRule()) { | |
193 const StyleRuleFontFace* fontFaceRule = static_cast<StyleRuleFontFac e*>(rule); | |
eseidel
2013/11/06 01:39:10
Do we have a toStyleRuleFontFace() method instead
tasak
2013/11/06 05:42:26
Done.
| |
194 fontSelector()->addFontFaceRule(fontFaceRule); | |
195 invalidateMatchedPropertiesCache(); | |
196 } else if (rule->isViewportRule()) { | |
197 m_styleTree.ensureScopedStyleResolver(m_document)->addViewportRule(s tatic_cast<StyleRuleViewport*>(rule)); | |
198 needsResolveViewport = true; | |
199 } else if (rule->isMediaRule()) { | |
200 StyleRuleMedia* mediaRule = static_cast<StyleRuleMedia*>(rule); | |
eseidel
2013/11/06 01:39:10
We've slowly been moving away from using static_ca
tasak
2013/11/06 05:42:26
Done.
| |
201 if ((!mediaRule->mediaQueries() || m_medium->eval(mediaRule->mediaQu eries(), viewportDependentMediaQueryResults()))) | |
202 filterFontFaceAndViewportRules(mediaRule->childRules(), needsRes olveViewport); | |
203 } | |
204 } | |
205 } | |
206 | |
207 void StyleResolver::filterFontFaceAndViewportRulesFromSheet(StyleSheetContents* sheet, bool& needsResolveViewport) | |
208 { | |
209 if (!sheet) | |
210 return; | |
211 | |
212 if (sheet->importRules().size() > 0) { | |
213 const Vector<RefPtr<StyleRuleImport> >& importRules = sheet->importRules (); | |
214 for (unsigned i = 0; i < importRules.size(); ++i) { | |
215 StyleRuleImport* importRule = importRules[i].get(); | |
216 filterFontFaceAndViewportRulesFromSheet(importRule->styleSheet(), ne edsResolveViewport); | |
217 } | |
218 } | |
219 filterFontFaceAndViewportRules(sheet->childRules(), needsResolveViewport); | |
220 } | |
221 | |
222 bool StyleResolver::filterFontFaceAndViewportRulesFromAuthorStyleSheets(unsigned firstNew, const Vector<RefPtr<CSSStyleSheet> >& styleSheets) | |
223 { | |
224 bool needsResolveViewport = false; | |
225 | |
226 unsigned size = styleSheets.size(); | |
227 for (unsigned i = firstNew; i < size; ++i) { | |
228 CSSStyleSheet* cssSheet = styleSheets[i].get(); | |
229 ASSERT(!cssSheet->disabled()); | |
230 if (cssSheet->mediaQueries() && !m_medium->eval(cssSheet->mediaQueries() , &m_viewportDependentMediaQueryResults)) | |
231 continue; | |
232 // @viewport and @font-face rules work only in document scope. | |
233 if (cssSheet->ownerNode()->isInShadowTree() || !isDocumentScope(ScopedSt yleResolver::scopingNodeFor(cssSheet))) | |
234 continue; | |
235 filterFontFaceAndViewportRulesFromSheet(cssSheet->contents(), needsResol veViewport); | |
236 } | |
237 return needsResolveViewport; | |
238 } | |
239 | |
240 void StyleResolver::lazyAppendAuthorStyleSheets(unsigned firstNew, const Vector< RefPtr<CSSStyleSheet> >& styleSheets) | |
241 { | |
242 // FIXME: Currently We cannot lazy apppend stylesheets if the sheets have @v iewport and @font-face rules. | |
243 // Need to find the best place to update pending stylesheets for "viewport" rules. | |
244 // Talking about @font-face rules, addFontFaceRule triggers loading font res ources. | |
245 // If we delays "addFontFaceRule", we probably wait more time until fonts ar e loaded. | |
246 // At least, we should filter @viewport and @font-face here and should lazil y add other rules if possible. | |
247 bool needsResolveViewport = filterFontFaceAndViewportRulesFromAuthorStyleShe ets(firstNew, styleSheets); | |
248 | |
249 unsigned size = styleSheets.size(); | |
250 for (unsigned i = firstNew; i < size; ++i) | |
251 m_pendingStyleSheets.add(styleSheets[i].get()); | |
252 | |
253 if (needsResolveViewport) | |
254 collectViewportRules(); | |
255 } | |
256 | |
257 void StyleResolver::removePendingAuthorStyleSheets(const Vector<RefPtr<CSSStyleS heet> >& styleSheets) | |
258 { | |
259 for (unsigned i = 0; i < styleSheets.size(); ++i) | |
260 m_pendingStyleSheets.remove(styleSheets[i].get()); | |
261 } | |
262 | |
263 void StyleResolver::appendPendingAuthorStyleSheets() | |
264 { | |
265 setBuildScopedStyleTreeInDocumentOrder(false); | |
266 for (ListHashSet<CSSStyleSheet*, 16>::iterator it = m_pendingStyleSheets.beg in(); it != m_pendingStyleSheets.end(); ++it) { | |
267 CSSStyleSheet* cssSheet = *it; | |
268 ASSERT(!cssSheet->disabled()); | |
269 if (cssSheet->mediaQueries() && !m_medium->eval(cssSheet->mediaQueries() , &m_viewportDependentMediaQueryResults)) | |
270 continue; | |
271 | |
272 StyleSheetContents* sheet = cssSheet->contents(); | |
273 const ContainerNode* scopingNode = ScopedStyleResolver::scopingNodeFor(c ssSheet); | |
274 if (!scopingNode && cssSheet->ownerNode() && cssSheet->ownerNode()->isIn ShadowTree()) | |
275 continue; | |
276 | |
277 ScopedStyleResolver* resolver = ensureScopedStyleResolver(scopingNode); | |
278 ASSERT(resolver); | |
279 resolver->addRulesFromSheet(sheet, *m_medium, this, false); | |
280 m_inspectorCSSOMWrappers.collectFromStyleSheetIfNeeded(cssSheet); | |
281 } | |
282 m_pendingStyleSheets.clear(); | |
283 finishAppendAuthorStyleSheets(); | |
284 } | |
285 | |
184 void StyleResolver::appendAuthorStyleSheets(unsigned firstNew, const Vector<RefP tr<CSSStyleSheet> >& styleSheets) | 286 void StyleResolver::appendAuthorStyleSheets(unsigned firstNew, const Vector<RefP tr<CSSStyleSheet> >& styleSheets) |
185 { | 287 { |
186 // This handles sheets added to the end of the stylesheet list only. In othe r cases the style resolver | 288 // This handles sheets added to the end of the stylesheet list only. In othe r cases the style resolver |
187 // needs to be reconstructed. To handle insertions too the rule order number s would need to be updated. | 289 // needs to be reconstructed. To handle insertions too the rule order number s would need to be updated. |
188 unsigned size = styleSheets.size(); | 290 unsigned size = styleSheets.size(); |
189 for (unsigned i = firstNew; i < size; ++i) { | 291 for (unsigned i = firstNew; i < size; ++i) { |
190 CSSStyleSheet* cssSheet = styleSheets[i].get(); | 292 CSSStyleSheet* cssSheet = styleSheets[i].get(); |
191 ASSERT(!cssSheet->disabled()); | 293 ASSERT(!cssSheet->disabled()); |
192 if (cssSheet->mediaQueries() && !m_medium->eval(cssSheet->mediaQueries() , &m_viewportDependentMediaQueryResults)) | 294 if (cssSheet->mediaQueries() && !m_medium->eval(cssSheet->mediaQueries() , &m_viewportDependentMediaQueryResults)) |
193 continue; | 295 continue; |
194 | 296 |
195 StyleSheetContents* sheet = cssSheet->contents(); | 297 StyleSheetContents* sheet = cssSheet->contents(); |
196 const ContainerNode* scopingNode = ScopedStyleResolver::scopingNodeFor(c ssSheet); | 298 const ContainerNode* scopingNode = ScopedStyleResolver::scopingNodeFor(c ssSheet); |
197 if (!scopingNode && cssSheet->ownerNode() && cssSheet->ownerNode()->isIn ShadowTree()) | 299 if (!scopingNode && cssSheet->ownerNode() && cssSheet->ownerNode()->isIn ShadowTree()) |
198 continue; | 300 continue; |
199 | 301 |
200 ScopedStyleResolver* resolver = ensureScopedStyleResolver(scopingNode); | 302 ScopedStyleResolver* resolver = ensureScopedStyleResolver(scopingNode); |
201 ASSERT(resolver); | 303 ASSERT(resolver); |
202 resolver->addRulesFromSheet(sheet, *m_medium, this); | 304 resolver->addRulesFromSheet(sheet, *m_medium, this, true); |
203 m_inspectorCSSOMWrappers.collectFromStyleSheetIfNeeded(cssSheet); | 305 m_inspectorCSSOMWrappers.collectFromStyleSheetIfNeeded(cssSheet); |
204 } | 306 } |
205 } | 307 } |
206 | 308 |
207 void StyleResolver::finishAppendAuthorStyleSheets() | 309 void StyleResolver::finishAppendAuthorStyleSheets() |
208 { | 310 { |
209 collectFeatures(); | 311 collectFeatures(); |
210 | 312 |
211 if (document().renderer() && document().renderer()->style()) | 313 if (document().renderer() && document().renderer()->style()) |
212 document().renderer()->style()->font().update(fontSelector()); | 314 document().renderer()->style()->font().update(fontSelector()); |
213 | 315 |
214 collectViewportRules(); | 316 collectViewportRules(); |
317 | |
318 document().styleEngine()->resetCSSFeatureFlags(ruleFeatureSet()); | |
319 } | |
320 | |
321 void StyleResolver::resetRuleFeatures() | |
322 { | |
323 // Need to recreate RuleFeatureSet. | |
324 m_features.clear(); | |
325 m_siblingRuleSet.clear(); | |
326 m_uncommonAttributeRuleSet.clear(); | |
327 m_needCollectFeatures = true; | |
215 } | 328 } |
216 | 329 |
217 void StyleResolver::resetAuthorStyle(const ContainerNode* scopingNode) | 330 void StyleResolver::resetAuthorStyle(const ContainerNode* scopingNode) |
218 { | 331 { |
219 // FIXME: When chanking scoped attribute, scopingNode's hasScopedHTMLStyleCh ild has been already modified. | 332 // FIXME: When chanking scoped attribute, scopingNode's hasScopedHTMLStyleCh ild has been already modified. |
220 // So we cannot use hasScopedHTMLStyleChild flag here. | 333 // So we cannot use hasScopedHTMLStyleChild flag here. |
221 ScopedStyleResolver* resolver = scopingNode ? m_styleTree.lookupScopedStyleR esolverFor(scopingNode) : m_styleTree.scopedStyleResolverForDocument(); | 334 ScopedStyleResolver* resolver = scopingNode ? m_styleTree.lookupScopedStyleR esolverFor(scopingNode) : m_styleTree.scopedStyleResolverForDocument(); |
222 if (!resolver) | 335 if (!resolver) |
223 return; | 336 return; |
224 | 337 |
225 m_ruleSets.treeBoundaryCrossingRules().reset(scopingNode); | 338 m_ruleSets.treeBoundaryCrossingRules().reset(scopingNode); |
226 | 339 |
227 resolver->resetAuthorStyle(); | 340 resolver->resetAuthorStyle(); |
341 resetRuleFeatures(); | |
228 if (!scopingNode) | 342 if (!scopingNode) |
229 return; | 343 return; |
230 | 344 |
231 if (scopingNode->isInShadowTree()) | 345 if (scopingNode->isInShadowTree()) |
232 resetAtHostRules(scopingNode->containingShadowRoot()); | 346 resetAtHostRules(scopingNode->containingShadowRoot()); |
233 | 347 |
234 if (!resolver->hasOnlyEmptyRuleSets()) | 348 if (!resolver->hasOnlyEmptyRuleSets()) |
235 return; | 349 return; |
236 | 350 |
237 m_styleTree.remove(scopingNode); | 351 m_styleTree.remove(scopingNode); |
(...skipping 29 matching lines...) Expand all Loading... | |
267 } | 381 } |
268 | 382 |
269 void StyleResolver::collectFeatures() | 383 void StyleResolver::collectFeatures() |
270 { | 384 { |
271 m_features.clear(); | 385 m_features.clear(); |
272 m_ruleSets.collectFeaturesTo(m_features, document().isViewSource()); | 386 m_ruleSets.collectFeaturesTo(m_features, document().isViewSource()); |
273 m_styleTree.collectFeaturesTo(m_features); | 387 m_styleTree.collectFeaturesTo(m_features); |
274 | 388 |
275 m_siblingRuleSet = makeRuleSet(m_features.siblingRules); | 389 m_siblingRuleSet = makeRuleSet(m_features.siblingRules); |
276 m_uncommonAttributeRuleSet = makeRuleSet(m_features.uncommonAttributeRules); | 390 m_uncommonAttributeRuleSet = makeRuleSet(m_features.uncommonAttributeRules); |
391 m_needCollectFeatures = false; | |
277 } | 392 } |
278 | 393 |
279 bool StyleResolver::hasRulesForId(const AtomicString& id) const | 394 bool StyleResolver::hasRulesForId(const AtomicString& id) const |
280 { | 395 { |
281 return m_features.idsInRules.contains(id.impl()); | 396 return m_features.idsInRules.contains(id.impl()); |
282 } | 397 } |
283 | 398 |
284 void StyleResolver::addToStyleSharingList(Element* element) | 399 void StyleResolver::addToStyleSharingList(Element* element) |
285 { | 400 { |
286 if (m_styleSharingList.size() >= styleSharingListSize) | 401 if (m_styleSharingList.size() >= styleSharingListSize) |
(...skipping 317 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
604 { | 719 { |
605 for (size_t i = 0; i < contentAttrValues.size(); ++i) | 720 for (size_t i = 0; i < contentAttrValues.size(); ++i) |
606 features.attrsInRules.add(contentAttrValues[i].impl()); | 721 features.attrsInRules.add(contentAttrValues[i].impl()); |
607 } | 722 } |
608 | 723 |
609 PassRefPtr<RenderStyle> StyleResolver::styleForElement(Element* element, RenderS tyle* defaultParent, StyleSharingBehavior sharingBehavior, | 724 PassRefPtr<RenderStyle> StyleResolver::styleForElement(Element* element, RenderS tyle* defaultParent, StyleSharingBehavior sharingBehavior, |
610 RuleMatchingBehavior matchingBehavior, RenderRegion* regionForStyling) | 725 RuleMatchingBehavior matchingBehavior, RenderRegion* regionForStyling) |
611 { | 726 { |
612 ASSERT(document().frame()); | 727 ASSERT(document().frame()); |
613 ASSERT(documentSettings()); | 728 ASSERT(documentSettings()); |
729 ASSERT(!hasPendingAuthorStyleSheets()); | |
730 ASSERT(!m_needCollectFeatures); | |
614 | 731 |
615 // Once an element has a renderer, we don't try to destroy it, since otherwi se the renderer | 732 // Once an element has a renderer, we don't try to destroy it, since otherwi se the renderer |
616 // will vanish if a style recalc happens during loading. | 733 // will vanish if a style recalc happens during loading. |
617 if (sharingBehavior == AllowStyleSharing && !element->document().haveStylesh eetsLoaded() && !element->renderer()) { | 734 if (sharingBehavior == AllowStyleSharing && !element->document().haveStylesh eetsLoaded() && !element->renderer()) { |
618 if (!s_styleNotYetAvailable) { | 735 if (!s_styleNotYetAvailable) { |
619 s_styleNotYetAvailable = RenderStyle::create().leakRef(); | 736 s_styleNotYetAvailable = RenderStyle::create().leakRef(); |
620 s_styleNotYetAvailable->setDisplay(NONE); | 737 s_styleNotYetAvailable->setDisplay(NONE); |
621 s_styleNotYetAvailable->font().update(m_fontSelector); | 738 s_styleNotYetAvailable->font().update(m_fontSelector); |
622 } | 739 } |
623 element->document().setHasNodesWithPlaceholderStyle(); | 740 element->document().setHasNodesWithPlaceholderStyle(); |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
700 element->ensureActiveAnimations()->cssAnimations().setPendingUpdate(stat e.takeAnimationUpdate()); | 817 element->ensureActiveAnimations()->cssAnimations().setPendingUpdate(stat e.takeAnimationUpdate()); |
701 | 818 |
702 // Now return the style. | 819 // Now return the style. |
703 return state.takeStyle(); | 820 return state.takeStyle(); |
704 } | 821 } |
705 | 822 |
706 PassRefPtr<RenderStyle> StyleResolver::styleForKeyframe(Element* e, const Render Style* elementStyle, const StyleKeyframe* keyframe) | 823 PassRefPtr<RenderStyle> StyleResolver::styleForKeyframe(Element* e, const Render Style* elementStyle, const StyleKeyframe* keyframe) |
707 { | 824 { |
708 ASSERT(document().frame()); | 825 ASSERT(document().frame()); |
709 ASSERT(documentSettings()); | 826 ASSERT(documentSettings()); |
827 ASSERT(!hasPendingAuthorStyleSheets()); | |
710 | 828 |
711 if (e == document().documentElement()) | 829 if (e == document().documentElement()) |
712 resetDirectionAndWritingModeOnDocument(document()); | 830 resetDirectionAndWritingModeOnDocument(document()); |
713 StyleResolverState state(document(), e); | 831 StyleResolverState state(document(), e); |
714 | 832 |
715 MatchResult result; | 833 MatchResult result; |
716 if (keyframe->properties()) | 834 if (keyframe->properties()) |
717 result.addMatchedProperties(keyframe->properties()); | 835 result.addMatchedProperties(keyframe->properties()); |
718 | 836 |
719 ASSERT(!state.style()); | 837 ASSERT(!state.style()); |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
775 | 893 |
776 void StyleResolver::keyframeStylesForAnimation(Element* e, const RenderStyle* el ementStyle, KeyframeList& list) | 894 void StyleResolver::keyframeStylesForAnimation(Element* e, const RenderStyle* el ementStyle, KeyframeList& list) |
777 { | 895 { |
778 ASSERT(!RuntimeEnabledFeatures::webAnimationsCSSEnabled()); | 896 ASSERT(!RuntimeEnabledFeatures::webAnimationsCSSEnabled()); |
779 list.clear(); | 897 list.clear(); |
780 | 898 |
781 // Get the keyframesRule for this name | 899 // Get the keyframesRule for this name |
782 if (!e || list.animationName().isEmpty()) | 900 if (!e || list.animationName().isEmpty()) |
783 return; | 901 return; |
784 | 902 |
903 if (hasPendingAuthorStyleSheets()) | |
904 appendPendingAuthorStyleSheets(); | |
905 | |
785 const StyleRuleKeyframes* keyframesRule = matchScopedKeyframesRule(e, list.a nimationName().impl()); | 906 const StyleRuleKeyframes* keyframesRule = matchScopedKeyframesRule(e, list.a nimationName().impl()); |
786 if (!keyframesRule) | 907 if (!keyframesRule) |
787 return; | 908 return; |
788 | 909 |
789 // Construct and populate the style for each keyframe | 910 // Construct and populate the style for each keyframe |
790 const Vector<RefPtr<StyleKeyframe> >& keyframes = keyframesRule->keyframes() ; | 911 const Vector<RefPtr<StyleKeyframe> >& keyframes = keyframesRule->keyframes() ; |
791 for (unsigned i = 0; i < keyframes.size(); ++i) { | 912 for (unsigned i = 0; i < keyframes.size(); ++i) { |
792 // Apply the declaration to the style. This is a simplified version of t he logic in styleForElement | 913 // Apply the declaration to the style. This is a simplified version of t he logic in styleForElement |
793 const StyleKeyframe* keyframe = keyframes[i].get(); | 914 const StyleKeyframe* keyframe = keyframes[i].get(); |
794 | 915 |
(...skipping 249 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1044 } | 1165 } |
1045 | 1166 |
1046 document().didAccessStyleResolver(); | 1167 document().didAccessStyleResolver(); |
1047 | 1168 |
1048 // Now return the style. | 1169 // Now return the style. |
1049 return state.takeStyle(); | 1170 return state.takeStyle(); |
1050 } | 1171 } |
1051 | 1172 |
1052 PassRefPtr<RenderStyle> StyleResolver::styleForPage(int pageIndex) | 1173 PassRefPtr<RenderStyle> StyleResolver::styleForPage(int pageIndex) |
1053 { | 1174 { |
1175 ASSERT(!hasPendingAuthorStyleSheets()); | |
1054 resetDirectionAndWritingModeOnDocument(document()); | 1176 resetDirectionAndWritingModeOnDocument(document()); |
1055 StyleResolverState state(document(), document().documentElement()); // m_roo tElementStyle will be set to the document style. | 1177 StyleResolverState state(document(), document().documentElement()); // m_roo tElementStyle will be set to the document style. |
1056 | 1178 |
1057 state.setStyle(RenderStyle::create()); | 1179 state.setStyle(RenderStyle::create()); |
1058 const RenderStyle* rootElementStyle = state.rootElementStyle() ? state.rootE lementStyle() : document().renderStyle(); | 1180 const RenderStyle* rootElementStyle = state.rootElementStyle() ? state.rootE lementStyle() : document().renderStyle(); |
1059 ASSERT(rootElementStyle); | 1181 ASSERT(rootElementStyle); |
1060 state.style()->inheritFrom(rootElementStyle); | 1182 state.style()->inheritFrom(rootElementStyle); |
1061 | 1183 |
1062 state.fontBuilder().initForStyleResolve(state.document(), state.style(), sta te.useSVGZoomRules()); | 1184 state.fontBuilder().initForStyleResolve(state.document(), state.style(), sta te.useSVGZoomRules()); |
1063 | 1185 |
(...skipping 522 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1586 m_matchedPropertiesSearches, m_matchedPropertiesHit, m_matchedProperties SharedInheritedHit, m_matchedPropertiesToCache, m_matchedPropertiesEnteredIntoCa che); | 1708 m_matchedPropertiesSearches, m_matchedPropertiesHit, m_matchedProperties SharedInheritedHit, m_matchedPropertiesToCache, m_matchedPropertiesEnteredIntoCa che); |
1587 | 1709 |
1588 fprintf(stderr, "Total:\n"); | 1710 fprintf(stderr, "Total:\n"); |
1589 printStyleStats(m_totalSearches, m_totalElementsEligibleForSharing, m_totalS tylesShared, m_totalSearchFoundSiblingForSharing, m_totalSearchesMissedSharing, | 1711 printStyleStats(m_totalSearches, m_totalElementsEligibleForSharing, m_totalS tylesShared, m_totalSearchFoundSiblingForSharing, m_totalSearchesMissedSharing, |
1590 m_totalMatchedPropertiesSearches, m_totalMatchedPropertiesHit, m_totalMa tchedPropertiesSharedInheritedHit, m_totalMatchedPropertiesToCache, m_totalMatch edPropertiesEnteredIntoCache); | 1712 m_totalMatchedPropertiesSearches, m_totalMatchedPropertiesHit, m_totalMa tchedPropertiesSharedInheritedHit, m_totalMatchedPropertiesToCache, m_totalMatch edPropertiesEnteredIntoCache); |
1591 fprintf(stderr, "----------------------------------------------------------- ---------------------\n"); | 1713 fprintf(stderr, "----------------------------------------------------------- ---------------------\n"); |
1592 } | 1714 } |
1593 #endif | 1715 #endif |
1594 | 1716 |
1595 } // namespace WebCore | 1717 } // namespace WebCore |
OLD | NEW |