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