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 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
116 static StylePropertySet* rightToLeftDeclaration() | 116 static StylePropertySet* rightToLeftDeclaration() |
117 { | 117 { |
118 DEFINE_STATIC_REF(MutableStylePropertySet, rightToLeftDecl, (MutableStylePro
pertySet::create())); | 118 DEFINE_STATIC_REF(MutableStylePropertySet, rightToLeftDecl, (MutableStylePro
pertySet::create())); |
119 if (rightToLeftDecl->isEmpty()) | 119 if (rightToLeftDecl->isEmpty()) |
120 rightToLeftDecl->setProperty(CSSPropertyDirection, CSSValueRtl); | 120 rightToLeftDecl->setProperty(CSSPropertyDirection, CSSValueRtl); |
121 return rightToLeftDecl; | 121 return rightToLeftDecl; |
122 } | 122 } |
123 | 123 |
124 StyleResolver::StyleResolver(Document& document) | 124 StyleResolver::StyleResolver(Document& document) |
125 : m_document(document) | 125 : m_document(document) |
126 , m_fontSelector(CSSFontSelector::create(&document)) | |
127 , m_viewportStyleResolver(ViewportStyleResolver::create(&document)) | 126 , m_viewportStyleResolver(ViewportStyleResolver::create(&document)) |
128 , m_needCollectFeatures(false) | 127 , m_needCollectFeatures(false) |
129 , m_styleResourceLoader(document.fetcher()) | 128 , m_styleResourceLoader(document.fetcher()) |
130 , m_styleResolverStatsSequence(0) | 129 , m_styleResolverStatsSequence(0) |
131 , m_accessCount(0) | 130 , m_accessCount(0) |
132 { | 131 { |
133 m_fontSelector->registerForInvalidationCallbacks(this); | |
134 | |
135 // FIXME: Why do this here instead of as part of resolving style on the root
? | 132 // FIXME: Why do this here instead of as part of resolving style on the root
? |
136 CSSDefaultStyleSheets::loadDefaultStylesheetIfNecessary(); | 133 CSSDefaultStyleSheets::loadDefaultStylesheetIfNecessary(); |
137 | 134 |
138 // Construct document root element default style. This is needed | 135 // Construct document root element default style. This is needed |
139 // to evaluate media queries that contain relative constraints, like "screen
and (max-width: 10em)" | 136 // to evaluate media queries that contain relative constraints, like "screen
and (max-width: 10em)" |
140 // This is here instead of constructor because when constructor is run, | 137 // This is here instead of constructor because when constructor is run, |
141 // Document doesn't have documentElement. | 138 // Document doesn't have documentElement. |
142 // NOTE: This assumes that element that gets passed to the styleForElement c
all | 139 // NOTE: This assumes that element that gets passed to the styleForElement c
all |
143 // is always from the document that owns the StyleResolver. | 140 // is always from the document that owns the StyleResolver. |
144 FrameView* view = document.view(); | 141 FrameView* view = document.view(); |
(...skipping 11 matching lines...) Expand all Loading... |
156 | 153 |
157 m_styleTree.clear(); | 154 m_styleTree.clear(); |
158 | 155 |
159 initWatchedSelectorRules(CSSSelectorWatch::from(document).watchedCallbackSel
ectors()); | 156 initWatchedSelectorRules(CSSSelectorWatch::from(document).watchedCallbackSel
ectors()); |
160 | 157 |
161 #if ENABLE(SVG_FONTS) | 158 #if ENABLE(SVG_FONTS) |
162 if (document.svgExtensions()) { | 159 if (document.svgExtensions()) { |
163 const HashSet<SVGFontFaceElement*>& svgFontFaceElements = document.svgEx
tensions()->svgFontFaceElements(); | 160 const HashSet<SVGFontFaceElement*>& svgFontFaceElements = document.svgEx
tensions()->svgFontFaceElements(); |
164 HashSet<SVGFontFaceElement*>::const_iterator end = svgFontFaceElements.e
nd(); | 161 HashSet<SVGFontFaceElement*>::const_iterator end = svgFontFaceElements.e
nd(); |
165 for (HashSet<SVGFontFaceElement*>::const_iterator it = svgFontFaceElemen
ts.begin(); it != end; ++it) | 162 for (HashSet<SVGFontFaceElement*>::const_iterator it = svgFontFaceElemen
ts.begin(); it != end; ++it) |
166 fontSelector()->addFontFaceRule((*it)->fontFaceRule()); | 163 document.fontSelector()->addFontFaceRule((*it)->fontFaceRule()); |
167 } | 164 } |
168 #endif | 165 #endif |
169 | 166 |
170 document.styleEngine()->appendActiveAuthorStyleSheets(this); | 167 document.styleEngine()->appendActiveAuthorStyleSheets(this); |
171 } | 168 } |
172 | 169 |
173 void StyleResolver::initWatchedSelectorRules(const Vector<RefPtr<StyleRule> >& w
atchedSelectors) | 170 void StyleResolver::initWatchedSelectorRules(const Vector<RefPtr<StyleRule> >& w
atchedSelectors) |
174 { | 171 { |
175 if (!watchedSelectors.size()) | 172 if (!watchedSelectors.size()) |
176 return; | 173 return; |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
227 unsigned size = styleSheets.size(); | 224 unsigned size = styleSheets.size(); |
228 for (unsigned i = firstNew; i < size; ++i) | 225 for (unsigned i = firstNew; i < size; ++i) |
229 appendCSSStyleSheet(styleSheets[i].get()); | 226 appendCSSStyleSheet(styleSheets[i].get()); |
230 } | 227 } |
231 | 228 |
232 void StyleResolver::finishAppendAuthorStyleSheets() | 229 void StyleResolver::finishAppendAuthorStyleSheets() |
233 { | 230 { |
234 collectFeatures(); | 231 collectFeatures(); |
235 | 232 |
236 if (document().renderer() && document().renderer()->style()) | 233 if (document().renderer() && document().renderer()->style()) |
237 document().renderer()->style()->font().update(fontSelector()); | 234 document().renderer()->style()->font().update(document().fontSelector())
; |
238 | 235 |
239 collectViewportRules(); | 236 collectViewportRules(); |
240 | 237 |
241 document().styleEngine()->resetCSSFeatureFlags(m_features); | 238 document().styleEngine()->resetCSSFeatureFlags(m_features); |
242 } | 239 } |
243 | 240 |
244 void StyleResolver::resetRuleFeatures() | 241 void StyleResolver::resetRuleFeatures() |
245 { | 242 { |
246 // Need to recreate RuleFeatureSet. | 243 // Need to recreate RuleFeatureSet. |
247 m_features.clear(); | 244 m_features.clear(); |
(...skipping 15 matching lines...) Expand all Loading... |
263 const Vector<StyleRuleKeyframes*> keyframesRules = authorRules.keyframesRule
s(); | 260 const Vector<StyleRuleKeyframes*> keyframesRules = authorRules.keyframesRule
s(); |
264 for (unsigned i = 0; i < keyframesRules.size(); ++i) | 261 for (unsigned i = 0; i < keyframesRules.size(); ++i) |
265 ensureScopedStyleResolver(scope)->addKeyframeStyle(keyframesRules[i]); | 262 ensureScopedStyleResolver(scope)->addKeyframeStyle(keyframesRules[i]); |
266 | 263 |
267 addTreeBoundaryCrossingRules(authorRules.treeBoundaryCrossingRules(), scope)
; | 264 addTreeBoundaryCrossingRules(authorRules.treeBoundaryCrossingRules(), scope)
; |
268 | 265 |
269 // FIXME(BUG 72461): We don't add @font-face rules of scoped style sheets fo
r the moment. | 266 // FIXME(BUG 72461): We don't add @font-face rules of scoped style sheets fo
r the moment. |
270 if (!scope || scope->isDocumentNode()) { | 267 if (!scope || scope->isDocumentNode()) { |
271 const Vector<StyleRuleFontFace*> fontFaceRules = authorRules.fontFaceRul
es(); | 268 const Vector<StyleRuleFontFace*> fontFaceRules = authorRules.fontFaceRul
es(); |
272 for (unsigned i = 0; i < fontFaceRules.size(); ++i) | 269 for (unsigned i = 0; i < fontFaceRules.size(); ++i) |
273 fontSelector()->addFontFaceRule(fontFaceRules[i]); | 270 document().fontSelector()->addFontFaceRule(fontFaceRules[i]); |
274 if (fontFaceRules.size()) | 271 if (fontFaceRules.size()) |
275 invalidateMatchedPropertiesCache(); | 272 invalidateMatchedPropertiesCache(); |
276 } else { | 273 } else { |
277 addTreeBoundaryCrossingRules(authorRules.shadowDistributedRules(), scope
); | 274 addTreeBoundaryCrossingRules(authorRules.shadowDistributedRules(), scope
); |
278 } | 275 } |
279 } | 276 } |
280 | 277 |
281 void StyleResolver::resetFontSelector() | |
282 { | |
283 ASSERT(m_fontSelector); | |
284 m_fontSelector->unregisterForInvalidationCallbacks(this); | |
285 m_fontSelector->clearDocument(); | |
286 invalidateMatchedPropertiesCache(); | |
287 | |
288 m_fontSelector = CSSFontSelector::create(&m_document); | |
289 m_fontSelector->registerForInvalidationCallbacks(this); | |
290 } | |
291 | |
292 void StyleResolver::resetAuthorStyle(const ContainerNode* scopingNode) | 278 void StyleResolver::resetAuthorStyle(const ContainerNode* scopingNode) |
293 { | 279 { |
294 // FIXME: When chanking scoped attribute, scopingNode's hasScopedHTMLStyleCh
ild has been already modified. | 280 // FIXME: When chanking scoped attribute, scopingNode's hasScopedHTMLStyleCh
ild has been already modified. |
295 // So we cannot use hasScopedHTMLStyleChild flag here. | 281 // So we cannot use hasScopedHTMLStyleChild flag here. |
296 ScopedStyleResolver* resolver = scopingNode ? m_styleTree.lookupScopedStyleR
esolverFor(scopingNode) : m_styleTree.scopedStyleResolverForDocument(); | 282 ScopedStyleResolver* resolver = scopingNode ? m_styleTree.lookupScopedStyleR
esolverFor(scopingNode) : m_styleTree.scopedStyleResolverForDocument(); |
297 if (!resolver) | 283 if (!resolver) |
298 return; | 284 return; |
299 | 285 |
300 treeBoundaryCrossingRules().reset(scopingNode); | 286 treeBoundaryCrossingRules().reset(scopingNode); |
301 | 287 |
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
404 } | 390 } |
405 | 391 |
406 void StyleResolver::popParentShadowRoot(const ShadowRoot& shadowRoot) | 392 void StyleResolver::popParentShadowRoot(const ShadowRoot& shadowRoot) |
407 { | 393 { |
408 ASSERT(shadowRoot.host()); | 394 ASSERT(shadowRoot.host()); |
409 m_styleTree.popStyleCache(shadowRoot); | 395 m_styleTree.popStyleCache(shadowRoot); |
410 } | 396 } |
411 | 397 |
412 StyleResolver::~StyleResolver() | 398 StyleResolver::~StyleResolver() |
413 { | 399 { |
414 m_fontSelector->unregisterForInvalidationCallbacks(this); | |
415 m_fontSelector->clearDocument(); | |
416 m_viewportStyleResolver->clearDocument(); | 400 m_viewportStyleResolver->clearDocument(); |
417 } | 401 } |
418 | 402 |
419 inline void StyleResolver::collectTreeBoundaryCrossingRules(Element* element, El
ementRuleCollector& collector, bool includeEmptyRules) | 403 inline void StyleResolver::collectTreeBoundaryCrossingRules(Element* element, El
ementRuleCollector& collector, bool includeEmptyRules) |
420 { | 404 { |
421 if (m_treeBoundaryCrossingRules.isEmpty()) | 405 if (m_treeBoundaryCrossingRules.isEmpty()) |
422 return; | 406 return; |
423 | 407 |
424 RuleRange ruleRange = collector.matchedResult().ranges.authorRuleRange(); | 408 RuleRange ruleRange = collector.matchedResult().ranges.authorRuleRange(); |
425 | 409 |
(...skipping 225 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
651 ASSERT(documentSettings()); | 635 ASSERT(documentSettings()); |
652 ASSERT(!hasPendingAuthorStyleSheets()); | 636 ASSERT(!hasPendingAuthorStyleSheets()); |
653 ASSERT(!m_needCollectFeatures); | 637 ASSERT(!m_needCollectFeatures); |
654 | 638 |
655 // Once an element has a renderer, we don't try to destroy it, since otherwi
se the renderer | 639 // Once an element has a renderer, we don't try to destroy it, since otherwi
se the renderer |
656 // will vanish if a style recalc happens during loading. | 640 // will vanish if a style recalc happens during loading. |
657 if (sharingBehavior == AllowStyleSharing && !element->document().haveStylesh
eetsLoaded() && !element->renderer()) { | 641 if (sharingBehavior == AllowStyleSharing && !element->document().haveStylesh
eetsLoaded() && !element->renderer()) { |
658 if (!s_styleNotYetAvailable) { | 642 if (!s_styleNotYetAvailable) { |
659 s_styleNotYetAvailable = RenderStyle::create().leakRef(); | 643 s_styleNotYetAvailable = RenderStyle::create().leakRef(); |
660 s_styleNotYetAvailable->setDisplay(NONE); | 644 s_styleNotYetAvailable->setDisplay(NONE); |
661 s_styleNotYetAvailable->font().update(m_fontSelector); | 645 s_styleNotYetAvailable->font().update(document().fontSelector()); |
662 } | 646 } |
663 element->document().setHasNodesWithPlaceholderStyle(); | 647 element->document().setHasNodesWithPlaceholderStyle(); |
664 return s_styleNotYetAvailable; | 648 return s_styleNotYetAvailable; |
665 } | 649 } |
666 | 650 |
667 didAccess(); | 651 didAccess(); |
668 | 652 |
669 if (element == document().documentElement()) | 653 if (element == document().documentElement()) |
670 resetDirectionAndWritingModeOnDocument(document()); | 654 resetDirectionAndWritingModeOnDocument(document()); |
671 StyleResolverState state(document(), element, defaultParent, regionForStylin
g); | 655 StyleResolverState state(document(), element, defaultParent, regionForStylin
g); |
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
793 // Now do rest of the properties. | 777 // Now do rest of the properties. |
794 if (keyframe->properties()) | 778 if (keyframe->properties()) |
795 applyMatchedProperties<LowPriorityProperties>(state, result, false, 0, r
esult.matchedProperties.size() - 1, inheritedOnly); | 779 applyMatchedProperties<LowPriorityProperties>(state, result, false, 0, r
esult.matchedProperties.size() - 1, inheritedOnly); |
796 | 780 |
797 // If our font got dirtied by one of the non-essential font props, | 781 // If our font got dirtied by one of the non-essential font props, |
798 // go ahead and update it a second time. | 782 // go ahead and update it a second time. |
799 updateFont(state); | 783 updateFont(state); |
800 | 784 |
801 // Start loading resources referenced by this style. | 785 // Start loading resources referenced by this style. |
802 m_styleResourceLoader.loadPendingResources(state.style(), state.elementStyle
Resources()); | 786 m_styleResourceLoader.loadPendingResources(state.style(), state.elementStyle
Resources()); |
803 m_fontSelector->loadPendingFonts(); | 787 document().fontSelector()->loadPendingFonts(); |
804 | 788 |
805 didAccess(); | 789 didAccess(); |
806 | 790 |
807 return state.takeStyle(); | 791 return state.takeStyle(); |
808 } | 792 } |
809 | 793 |
810 void StyleResolver::keyframeStylesForAnimation(Element* e, const RenderStyle& el
ementStyle, KeyframeList& list) | 794 void StyleResolver::keyframeStylesForAnimation(Element* e, const RenderStyle& el
ementStyle, KeyframeList& list) |
811 { | 795 { |
812 ASSERT(!RuntimeEnabledFeatures::webAnimationsCSSEnabled()); | 796 ASSERT(!RuntimeEnabledFeatures::webAnimationsCSSEnabled()); |
813 list.clear(); | 797 list.clear(); |
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
957 // Line-height is set when we are sure we decided on the font-size. | 941 // Line-height is set when we are sure we decided on the font-size. |
958 if (state.lineHeightValue()) | 942 if (state.lineHeightValue()) |
959 StyleBuilder::applyProperty(CSSPropertyLineHeight, state, state.lineHeig
htValue()); | 943 StyleBuilder::applyProperty(CSSPropertyLineHeight, state, state.lineHeig
htValue()); |
960 | 944 |
961 applyMatchedProperties<LowPriorityProperties>(state, result, false, 0, resul
t.matchedProperties.size() - 1, inheritedOnly); | 945 applyMatchedProperties<LowPriorityProperties>(state, result, false, 0, resul
t.matchedProperties.size() - 1, inheritedOnly); |
962 | 946 |
963 addContentAttrValuesToFeatures(state.contentAttrValues(), m_features); | 947 addContentAttrValuesToFeatures(state.contentAttrValues(), m_features); |
964 | 948 |
965 // Start loading resources referenced by this style. | 949 // Start loading resources referenced by this style. |
966 m_styleResourceLoader.loadPendingResources(state.style(), state.elementStyle
Resources()); | 950 m_styleResourceLoader.loadPendingResources(state.style(), state.elementStyle
Resources()); |
967 m_fontSelector->loadPendingFonts(); | 951 document().fontSelector()->loadPendingFonts(); |
968 | 952 |
969 didAccess(); | 953 didAccess(); |
970 | 954 |
971 // Now return the style. | 955 // Now return the style. |
972 return state.takeStyle(); | 956 return state.takeStyle(); |
973 } | 957 } |
974 | 958 |
975 void StyleResolver::collectViewportRules() | 959 void StyleResolver::collectViewportRules() |
976 { | 960 { |
977 viewportStyleResolver()->collectViewportRules(CSSDefaultStyleSheets::default
Style, ViewportStyleResolver::UserAgentOrigin); | 961 viewportStyleResolver()->collectViewportRules(CSSDefaultStyleSheets::default
Style, ViewportStyleResolver::UserAgentOrigin); |
978 | 962 |
979 if (document().isMobileDocument()) | 963 if (document().isMobileDocument()) |
980 viewportStyleResolver()->collectViewportRules(CSSDefaultStyleSheets::xht
mlMobileProfileStyle(), ViewportStyleResolver::UserAgentOrigin); | 964 viewportStyleResolver()->collectViewportRules(CSSDefaultStyleSheets::xht
mlMobileProfileStyle(), ViewportStyleResolver::UserAgentOrigin); |
981 | 965 |
982 if (ScopedStyleResolver* scopedResolver = m_styleTree.scopedStyleResolverFor
Document()) | 966 if (ScopedStyleResolver* scopedResolver = m_styleTree.scopedStyleResolverFor
Document()) |
983 scopedResolver->collectViewportRulesTo(this); | 967 scopedResolver->collectViewportRulesTo(this); |
984 | 968 |
985 viewportStyleResolver()->resolve(); | 969 viewportStyleResolver()->resolve(); |
986 } | 970 } |
987 | 971 |
988 PassRefPtr<RenderStyle> StyleResolver::defaultStyleForElement() | 972 PassRefPtr<RenderStyle> StyleResolver::defaultStyleForElement() |
989 { | 973 { |
990 StyleResolverState state(document(), 0); | 974 StyleResolverState state(document(), 0); |
991 state.setStyle(RenderStyle::create()); | 975 state.setStyle(RenderStyle::create()); |
992 state.fontBuilder().initForStyleResolve(document(), state.style(), state.use
SVGZoomRules()); | 976 state.fontBuilder().initForStyleResolve(document(), state.style(), state.use
SVGZoomRules()); |
993 state.style()->setLineHeight(RenderStyle::initialLineHeight()); | 977 state.style()->setLineHeight(RenderStyle::initialLineHeight()); |
994 state.setLineHeightValue(0); | 978 state.setLineHeightValue(0); |
995 state.fontBuilder().setInitial(state.style()->effectiveZoom()); | 979 state.fontBuilder().setInitial(state.style()->effectiveZoom()); |
996 state.style()->font().update(fontSelector()); | 980 state.style()->font().update(document().fontSelector()); |
997 return state.takeStyle(); | 981 return state.takeStyle(); |
998 } | 982 } |
999 | 983 |
1000 PassRefPtr<RenderStyle> StyleResolver::styleForText(Text* textNode) | 984 PassRefPtr<RenderStyle> StyleResolver::styleForText(Text* textNode) |
1001 { | 985 { |
1002 ASSERT(textNode); | 986 ASSERT(textNode); |
1003 | 987 |
1004 NodeRenderingTraversal::ParentDetails parentDetails; | 988 NodeRenderingTraversal::ParentDetails parentDetails; |
1005 Node* parentNode = NodeRenderingTraversal::parent(textNode, &parentDetails); | 989 Node* parentNode = NodeRenderingTraversal::parent(textNode, &parentDetails); |
1006 if (!parentNode || !parentNode->renderStyle() || parentDetails.resetStyleInh
eritance()) | 990 if (!parentNode || !parentNode->renderStyle() || parentDetails.resetStyleInh
eritance()) |
1007 return defaultStyleForElement(); | 991 return defaultStyleForElement(); |
1008 return parentNode->renderStyle(); | 992 return parentNode->renderStyle(); |
1009 } | 993 } |
1010 | 994 |
1011 bool StyleResolver::checkRegionStyle(Element* regionElement) | 995 bool StyleResolver::checkRegionStyle(Element* regionElement) |
1012 { | 996 { |
1013 // FIXME (BUG 72472): We don't add @-webkit-region rules of scoped style she
ets for the moment, | 997 // FIXME (BUG 72472): We don't add @-webkit-region rules of scoped style she
ets for the moment, |
1014 // so all region rules are global by default. Verify whether that can stand
or needs changing. | 998 // so all region rules are global by default. Verify whether that can stand
or needs changing. |
1015 if (ScopedStyleResolver* scopedResolver = m_styleTree.scopedStyleResolverFor
Document()) { | 999 if (ScopedStyleResolver* scopedResolver = m_styleTree.scopedStyleResolverFor
Document()) { |
1016 if (scopedResolver->checkRegionStyle(regionElement)) | 1000 if (scopedResolver->checkRegionStyle(regionElement)) |
1017 return true; | 1001 return true; |
1018 } | 1002 } |
1019 return false; | 1003 return false; |
1020 } | 1004 } |
1021 | 1005 |
1022 void StyleResolver::updateFont(StyleResolverState& state) | 1006 void StyleResolver::updateFont(StyleResolverState& state) |
1023 { | 1007 { |
1024 state.fontBuilder().createFont(m_fontSelector, state.parentStyle(), state.st
yle()); | 1008 state.fontBuilder().createFont(document().fontSelector(), state.parentStyle(
), state.style()); |
1025 } | 1009 } |
1026 | 1010 |
1027 PassRefPtr<StyleRuleList> StyleResolver::styleRulesForElement(Element* element,
unsigned rulesToInclude) | 1011 PassRefPtr<StyleRuleList> StyleResolver::styleRulesForElement(Element* element,
unsigned rulesToInclude) |
1028 { | 1012 { |
1029 ASSERT(element); | 1013 ASSERT(element); |
1030 StyleResolverState state(document(), element); | 1014 StyleResolverState state(document(), element); |
1031 ElementRuleCollector collector(state.elementContext(), m_selectorFilter, sta
te.style()); | 1015 ElementRuleCollector collector(state.elementContext(), m_selectorFilter, sta
te.style()); |
1032 collector.setMode(SelectorChecker::CollectingStyleRules); | 1016 collector.setMode(SelectorChecker::CollectingStyleRules); |
1033 collectPseudoRulesForElement(element, collector, NOPSEUDO, rulesToInclude); | 1017 collectPseudoRulesForElement(element, collector, NOPSEUDO, rulesToInclude); |
1034 return collector.matchedStyleRuleList(); | 1018 return collector.matchedStyleRuleList(); |
(...skipping 312 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1347 state.cacheUserAgentBorderAndBackground(); | 1331 state.cacheUserAgentBorderAndBackground(); |
1348 | 1332 |
1349 // Now do the author and user normal priority properties and all the !import
ant properties. | 1333 // Now do the author and user normal priority properties and all the !import
ant properties. |
1350 applyMatchedProperties<LowPriorityProperties>(state, matchResult, false, mat
chResult.ranges.lastUARule + 1, matchResult.matchedProperties.size() - 1, applyI
nheritedOnly); | 1334 applyMatchedProperties<LowPriorityProperties>(state, matchResult, false, mat
chResult.ranges.lastUARule + 1, matchResult.matchedProperties.size() - 1, applyI
nheritedOnly); |
1351 applyMatchedProperties<LowPriorityProperties>(state, matchResult, true, matc
hResult.ranges.firstAuthorRule, matchResult.ranges.lastAuthorRule, applyInherite
dOnly); | 1335 applyMatchedProperties<LowPriorityProperties>(state, matchResult, true, matc
hResult.ranges.firstAuthorRule, matchResult.ranges.lastAuthorRule, applyInherite
dOnly); |
1352 applyMatchedProperties<LowPriorityProperties>(state, matchResult, true, matc
hResult.ranges.firstUserRule, matchResult.ranges.lastUserRule, applyInheritedOnl
y); | 1336 applyMatchedProperties<LowPriorityProperties>(state, matchResult, true, matc
hResult.ranges.firstUserRule, matchResult.ranges.lastUserRule, applyInheritedOnl
y); |
1353 applyMatchedProperties<LowPriorityProperties>(state, matchResult, true, matc
hResult.ranges.firstUARule, matchResult.ranges.lastUARule, applyInheritedOnly); | 1337 applyMatchedProperties<LowPriorityProperties>(state, matchResult, true, matc
hResult.ranges.firstUARule, matchResult.ranges.lastUARule, applyInheritedOnly); |
1354 | 1338 |
1355 // Start loading resources referenced by this style. | 1339 // Start loading resources referenced by this style. |
1356 m_styleResourceLoader.loadPendingResources(state.style(), state.elementStyle
Resources()); | 1340 m_styleResourceLoader.loadPendingResources(state.style(), state.elementStyle
Resources()); |
1357 m_fontSelector->loadPendingFonts(); | 1341 document().fontSelector()->loadPendingFonts(); |
1358 | 1342 |
1359 if (!cachedMatchedProperties && cacheHash && MatchedPropertiesCache::isCache
able(element, state.style(), state.parentStyle())) { | 1343 if (!cachedMatchedProperties && cacheHash && MatchedPropertiesCache::isCache
able(element, state.style(), state.parentStyle())) { |
1360 INCREMENT_STYLE_STATS_COUNTER(*this, matchedPropertyCacheAdded); | 1344 INCREMENT_STYLE_STATS_COUNTER(*this, matchedPropertyCacheAdded); |
1361 m_matchedPropertiesCache.add(state.style(), state.parentStyle(), cacheHa
sh, matchResult); | 1345 m_matchedPropertiesCache.add(state.style(), state.parentStyle(), cacheHa
sh, matchResult); |
1362 } | 1346 } |
1363 | 1347 |
1364 applyAnimatedProperties(state, animatingElement); | 1348 applyAnimatedProperties(state, animatingElement); |
1365 | 1349 |
1366 ASSERT(!state.fontBuilder().fontDirty()); | 1350 ASSERT(!state.fontBuilder().fontDirty()); |
1367 } | 1351 } |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1433 bool StyleResolver::affectedByViewportChange() const | 1417 bool StyleResolver::affectedByViewportChange() const |
1434 { | 1418 { |
1435 for (unsigned i = 0; i < m_viewportDependentMediaQueryResults.size(); ++i) { | 1419 for (unsigned i = 0; i < m_viewportDependentMediaQueryResults.size(); ++i) { |
1436 if (m_medium->eval(&m_viewportDependentMediaQueryResults[i]->m_expressio
n) != m_viewportDependentMediaQueryResults[i]->m_result) | 1420 if (m_medium->eval(&m_viewportDependentMediaQueryResults[i]->m_expressio
n) != m_viewportDependentMediaQueryResults[i]->m_result) |
1437 return true; | 1421 return true; |
1438 } | 1422 } |
1439 return false; | 1423 return false; |
1440 } | 1424 } |
1441 | 1425 |
1442 } // namespace WebCore | 1426 } // namespace WebCore |
OLD | NEW |