| 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 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 147 } | 147 } |
| 148 | 148 |
| 149 static StylePropertySet* rightToLeftDeclaration() | 149 static StylePropertySet* rightToLeftDeclaration() |
| 150 { | 150 { |
| 151 DEFINE_STATIC_REF_WILL_BE_PERSISTENT(MutableStylePropertySet, rightToLeftDec
l, (MutableStylePropertySet::create(HTMLQuirksMode))); | 151 DEFINE_STATIC_REF_WILL_BE_PERSISTENT(MutableStylePropertySet, rightToLeftDec
l, (MutableStylePropertySet::create(HTMLQuirksMode))); |
| 152 if (rightToLeftDecl->isEmpty()) | 152 if (rightToLeftDecl->isEmpty()) |
| 153 rightToLeftDecl->setProperty(CSSPropertyDirection, CSSValueRtl); | 153 rightToLeftDecl->setProperty(CSSPropertyDirection, CSSValueRtl); |
| 154 return rightToLeftDecl; | 154 return rightToLeftDecl; |
| 155 } | 155 } |
| 156 | 156 |
| 157 static void collectScopedResolversForHostedShadowTrees(const Element& element, W
illBeHeapVector<RawPtrWillBeMember<ScopedStyleResolver>, 8>& resolvers) | 157 static void collectScopedResolversForHostedShadowTrees(const Element& element, H
eapVector<Member<ScopedStyleResolver>, 8>& resolvers) |
| 158 { | 158 { |
| 159 ElementShadow* shadow = element.shadow(); | 159 ElementShadow* shadow = element.shadow(); |
| 160 if (!shadow) | 160 if (!shadow) |
| 161 return; | 161 return; |
| 162 | 162 |
| 163 // Adding scoped resolver for active shadow roots for shadow host styling. | 163 // Adding scoped resolver for active shadow roots for shadow host styling. |
| 164 for (ShadowRoot* shadowRoot = &shadow->youngestShadowRoot(); shadowRoot; sha
dowRoot = shadowRoot->olderShadowRoot()) { | 164 for (ShadowRoot* shadowRoot = &shadow->youngestShadowRoot(); shadowRoot; sha
dowRoot = shadowRoot->olderShadowRoot()) { |
| 165 if (shadowRoot->numberOfStyles() > 0) { | 165 if (shadowRoot->numberOfStyles() > 0) { |
| 166 if (ScopedStyleResolver* resolver = shadowRoot->scopedStyleResolver(
)) | 166 if (ScopedStyleResolver* resolver = shadowRoot->scopedStyleResolver(
)) |
| 167 resolvers.append(resolver); | 167 resolvers.append(resolver); |
| 168 } | 168 } |
| 169 } | 169 } |
| 170 } | 170 } |
| 171 | 171 |
| 172 StyleResolver::StyleResolver(Document& document) | 172 StyleResolver::StyleResolver(Document& document) |
| 173 : m_document(document) | 173 : m_document(document) |
| 174 , m_viewportStyleResolver(ViewportStyleResolver::create(&document)) | 174 , m_viewportStyleResolver(ViewportStyleResolver::create(&document)) |
| 175 , m_needCollectFeatures(false) | 175 , m_needCollectFeatures(false) |
| 176 , m_printMediaType(false) | 176 , m_printMediaType(false) |
| 177 , m_styleSharingDepth(0) | 177 , m_styleSharingDepth(0) |
| 178 { | 178 { |
| 179 FrameView* view = document.view(); | 179 FrameView* view = document.view(); |
| 180 if (view) { | 180 if (view) { |
| 181 m_medium = adoptPtrWillBeNoop(new MediaQueryEvaluator(&view->frame())); | 181 m_medium = new MediaQueryEvaluator(&view->frame()); |
| 182 m_printMediaType = equalIgnoringCase(view->mediaType(), MediaTypeNames::
print); | 182 m_printMediaType = equalIgnoringCase(view->mediaType(), MediaTypeNames::
print); |
| 183 } else { | 183 } else { |
| 184 m_medium = adoptPtrWillBeNoop(new MediaQueryEvaluator("all")); | 184 m_medium = new MediaQueryEvaluator("all"); |
| 185 } | 185 } |
| 186 | 186 |
| 187 initWatchedSelectorRules(); | 187 initWatchedSelectorRules(); |
| 188 } | 188 } |
| 189 | 189 |
| 190 StyleResolver::~StyleResolver() | 190 StyleResolver::~StyleResolver() |
| 191 { | 191 { |
| 192 } | 192 } |
| 193 | 193 |
| 194 void StyleResolver::dispose() | 194 void StyleResolver::dispose() |
| 195 { | 195 { |
| 196 m_matchedPropertiesCache.clear(); | 196 m_matchedPropertiesCache.clear(); |
| 197 } | 197 } |
| 198 | 198 |
| 199 void StyleResolver::initWatchedSelectorRules() | 199 void StyleResolver::initWatchedSelectorRules() |
| 200 { | 200 { |
| 201 m_watchedSelectorsRules = nullptr; | 201 m_watchedSelectorsRules = nullptr; |
| 202 CSSSelectorWatch* watch = CSSSelectorWatch::fromIfExists(*m_document); | 202 CSSSelectorWatch* watch = CSSSelectorWatch::fromIfExists(*m_document); |
| 203 if (!watch) | 203 if (!watch) |
| 204 return; | 204 return; |
| 205 const WillBeHeapVector<RefPtrWillBeMember<StyleRule>>& watchedSelectors = wa
tch->watchedCallbackSelectors(); | 205 const HeapVector<Member<StyleRule>>& watchedSelectors = watch->watchedCallba
ckSelectors(); |
| 206 if (!watchedSelectors.size()) | 206 if (!watchedSelectors.size()) |
| 207 return; | 207 return; |
| 208 m_watchedSelectorsRules = RuleSet::create(); | 208 m_watchedSelectorsRules = RuleSet::create(); |
| 209 for (unsigned i = 0; i < watchedSelectors.size(); ++i) | 209 for (unsigned i = 0; i < watchedSelectors.size(); ++i) |
| 210 m_watchedSelectorsRules->addStyleRule(watchedSelectors[i].get(), RuleHas
NoSpecialState); | 210 m_watchedSelectorsRules->addStyleRule(watchedSelectors[i].get(), RuleHas
NoSpecialState); |
| 211 } | 211 } |
| 212 | 212 |
| 213 void StyleResolver::lazyAppendAuthorStyleSheets(unsigned firstNew, const WillBeH
eapVector<RefPtrWillBeMember<CSSStyleSheet>>& styleSheets) | 213 void StyleResolver::lazyAppendAuthorStyleSheets(unsigned firstNew, const HeapVec
tor<Member<CSSStyleSheet>>& styleSheets) |
| 214 { | 214 { |
| 215 unsigned size = styleSheets.size(); | 215 unsigned size = styleSheets.size(); |
| 216 for (unsigned i = firstNew; i < size; ++i) | 216 for (unsigned i = firstNew; i < size; ++i) |
| 217 m_pendingStyleSheets.add(styleSheets[i].get()); | 217 m_pendingStyleSheets.add(styleSheets[i].get()); |
| 218 } | 218 } |
| 219 | 219 |
| 220 void StyleResolver::removePendingAuthorStyleSheets(const WillBeHeapVector<RefPtr
WillBeMember<CSSStyleSheet>>& styleSheets) | 220 void StyleResolver::removePendingAuthorStyleSheets(const HeapVector<Member<CSSSt
yleSheet>>& styleSheets) |
| 221 { | 221 { |
| 222 for (unsigned i = 0; i < styleSheets.size(); ++i) | 222 for (unsigned i = 0; i < styleSheets.size(); ++i) |
| 223 m_pendingStyleSheets.remove(styleSheets[i].get()); | 223 m_pendingStyleSheets.remove(styleSheets[i].get()); |
| 224 } | 224 } |
| 225 | 225 |
| 226 void StyleResolver::appendCSSStyleSheet(CSSStyleSheet& cssSheet) | 226 void StyleResolver::appendCSSStyleSheet(CSSStyleSheet& cssSheet) |
| 227 { | 227 { |
| 228 ASSERT(!cssSheet.disabled()); | 228 ASSERT(!cssSheet.disabled()); |
| 229 ASSERT(cssSheet.ownerDocument()); | 229 ASSERT(cssSheet.ownerDocument()); |
| 230 ASSERT(cssSheet.ownerNode()); | 230 ASSERT(cssSheet.ownerNode()); |
| (...skipping 21 matching lines...) Expand all Loading... |
| 252 | 252 |
| 253 void StyleResolver::appendPendingAuthorStyleSheets() | 253 void StyleResolver::appendPendingAuthorStyleSheets() |
| 254 { | 254 { |
| 255 for (const auto& styleSheet : m_pendingStyleSheets) | 255 for (const auto& styleSheet : m_pendingStyleSheets) |
| 256 appendCSSStyleSheet(*styleSheet); | 256 appendCSSStyleSheet(*styleSheet); |
| 257 | 257 |
| 258 m_pendingStyleSheets.clear(); | 258 m_pendingStyleSheets.clear(); |
| 259 finishAppendAuthorStyleSheets(); | 259 finishAppendAuthorStyleSheets(); |
| 260 } | 260 } |
| 261 | 261 |
| 262 void StyleResolver::appendAuthorStyleSheets(const WillBeHeapVector<RefPtrWillBeM
ember<CSSStyleSheet>>& styleSheets) | 262 void StyleResolver::appendAuthorStyleSheets(const HeapVector<Member<CSSStyleShee
t>>& styleSheets) |
| 263 { | 263 { |
| 264 // This handles sheets added to the end of the stylesheet list only. In othe
r cases the style resolver | 264 // This handles sheets added to the end of the stylesheet list only. In othe
r cases the style resolver |
| 265 // needs to be reconstructed. To handle insertions too the rule order number
s would need to be updated. | 265 // needs to be reconstructed. To handle insertions too the rule order number
s would need to be updated. |
| 266 for (const auto& styleSheet : styleSheets) | 266 for (const auto& styleSheet : styleSheets) |
| 267 appendCSSStyleSheet(*styleSheet); | 267 appendCSSStyleSheet(*styleSheet); |
| 268 } | 268 } |
| 269 | 269 |
| 270 void StyleResolver::finishAppendAuthorStyleSheets() | 270 void StyleResolver::finishAppendAuthorStyleSheets() |
| 271 { | 271 { |
| 272 collectFeatures(); | 272 collectFeatures(); |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 305 | 305 |
| 306 if (treeScope.rootNode().isDocumentNode()) { | 306 if (treeScope.rootNode().isDocumentNode()) { |
| 307 resolver->resetAuthorStyle(); | 307 resolver->resetAuthorStyle(); |
| 308 return; | 308 return; |
| 309 } | 309 } |
| 310 | 310 |
| 311 // resolver is going to be freed below. | 311 // resolver is going to be freed below. |
| 312 treeScope.clearScopedStyleResolver(); | 312 treeScope.clearScopedStyleResolver(); |
| 313 } | 313 } |
| 314 | 314 |
| 315 static PassOwnPtrWillBeRawPtr<RuleSet> makeRuleSet(const WillBeHeapVector<RuleFe
ature>& rules) | 315 static RawPtr<RuleSet> makeRuleSet(const HeapVector<RuleFeature>& rules) |
| 316 { | 316 { |
| 317 size_t size = rules.size(); | 317 size_t size = rules.size(); |
| 318 if (!size) | 318 if (!size) |
| 319 return nullptr; | 319 return nullptr; |
| 320 OwnPtrWillBeRawPtr<RuleSet> ruleSet = RuleSet::create(); | 320 RawPtr<RuleSet> ruleSet = RuleSet::create(); |
| 321 for (size_t i = 0; i < size; ++i) | 321 for (size_t i = 0; i < size; ++i) |
| 322 ruleSet->addRule(rules[i].rule, rules[i].selectorIndex, rules[i].hasDocu
mentSecurityOrigin ? RuleHasDocumentSecurityOrigin : RuleHasNoSpecialState); | 322 ruleSet->addRule(rules[i].rule, rules[i].selectorIndex, rules[i].hasDocu
mentSecurityOrigin ? RuleHasDocumentSecurityOrigin : RuleHasNoSpecialState); |
| 323 return ruleSet.release(); | 323 return ruleSet.release(); |
| 324 } | 324 } |
| 325 | 325 |
| 326 void StyleResolver::collectFeatures() | 326 void StyleResolver::collectFeatures() |
| 327 { | 327 { |
| 328 m_features.clear(); | 328 m_features.clear(); |
| 329 // Collect all ids and rules using sibling selectors (:first-child and simil
ar) | 329 // Collect all ids and rules using sibling selectors (:first-child and simil
ar) |
| 330 // in the current set of stylesheets. Style sharing code uses this informati
on to reject | 330 // in the current set of stylesheets. Style sharing code uses this informati
on to reject |
| (...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 532 ASSERT(RuntimeEnabledFeatures::shadowDOMV1Enabled()); | 532 ASSERT(RuntimeEnabledFeatures::shadowDOMV1Enabled()); |
| 533 matchHostRules(element, collector); | 533 matchHostRules(element, collector); |
| 534 matchScopedRules(element, collector); | 534 matchScopedRules(element, collector); |
| 535 } | 535 } |
| 536 | 536 |
| 537 void StyleResolver::matchAuthorRulesV0(const Element& element, ElementRuleCollec
tor& collector) | 537 void StyleResolver::matchAuthorRulesV0(const Element& element, ElementRuleCollec
tor& collector) |
| 538 { | 538 { |
| 539 collector.clearMatchedRules(); | 539 collector.clearMatchedRules(); |
| 540 | 540 |
| 541 CascadeOrder cascadeOrder = 0; | 541 CascadeOrder cascadeOrder = 0; |
| 542 WillBeHeapVector<RawPtrWillBeMember<ScopedStyleResolver>, 8> resolversInShad
owTree; | 542 HeapVector<Member<ScopedStyleResolver>, 8> resolversInShadowTree; |
| 543 collectScopedResolversForHostedShadowTrees(element, resolversInShadowTree); | 543 collectScopedResolversForHostedShadowTrees(element, resolversInShadowTree); |
| 544 | 544 |
| 545 // Apply :host and :host-context rules from inner scopes. | 545 // Apply :host and :host-context rules from inner scopes. |
| 546 for (int j = resolversInShadowTree.size() - 1; j >= 0; --j) | 546 for (int j = resolversInShadowTree.size() - 1; j >= 0; --j) |
| 547 resolversInShadowTree.at(j)->collectMatchingShadowHostRules(collector, +
+cascadeOrder); | 547 resolversInShadowTree.at(j)->collectMatchingShadowHostRules(collector, +
+cascadeOrder); |
| 548 | 548 |
| 549 // Apply normal rules from element scope. | 549 // Apply normal rules from element scope. |
| 550 if (ScopedStyleResolver* resolver = scopedResolverFor(element)) | 550 if (ScopedStyleResolver* resolver = scopedResolverFor(element)) |
| 551 resolver->collectMatchingAuthorRules(collector, ++cascadeOrder); | 551 resolver->collectMatchingAuthorRules(collector, ++cascadeOrder); |
| 552 | 552 |
| (...skipping 274 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 827 | 827 |
| 828 PassRefPtr<AnimatableValue> StyleResolver::createAnimatableValueSnapshot(StyleRe
solverState& state, CSSPropertyID property, CSSValue* value) | 828 PassRefPtr<AnimatableValue> StyleResolver::createAnimatableValueSnapshot(StyleRe
solverState& state, CSSPropertyID property, CSSValue* value) |
| 829 { | 829 { |
| 830 if (value) { | 830 if (value) { |
| 831 StyleBuilder::applyProperty(property, state, value); | 831 StyleBuilder::applyProperty(property, state, value); |
| 832 state.fontBuilder().createFont(state.document().styleEngine().fontSelect
or(), state.mutableStyleRef()); | 832 state.fontBuilder().createFont(state.document().styleEngine().fontSelect
or(), state.mutableStyleRef()); |
| 833 } | 833 } |
| 834 return CSSAnimatableValueFactory::create(property, *state.style()); | 834 return CSSAnimatableValueFactory::create(property, *state.style()); |
| 835 } | 835 } |
| 836 | 836 |
| 837 PassRefPtrWillBeRawPtr<PseudoElement> StyleResolver::createPseudoElement(Element
* parent, PseudoId pseudoId) | 837 RawPtr<PseudoElement> StyleResolver::createPseudoElement(Element* parent, Pseudo
Id pseudoId) |
| 838 { | 838 { |
| 839 if (pseudoId == PseudoIdFirstLetter) | 839 if (pseudoId == PseudoIdFirstLetter) |
| 840 return FirstLetterPseudoElement::create(parent); | 840 return FirstLetterPseudoElement::create(parent); |
| 841 return PseudoElement::create(parent, pseudoId); | 841 return PseudoElement::create(parent, pseudoId); |
| 842 } | 842 } |
| 843 | 843 |
| 844 PassRefPtrWillBeRawPtr<PseudoElement> StyleResolver::createPseudoElementIfNeeded
(Element& parent, PseudoId pseudoId) | 844 RawPtr<PseudoElement> StyleResolver::createPseudoElementIfNeeded(Element& parent
, PseudoId pseudoId) |
| 845 { | 845 { |
| 846 LayoutObject* parentLayoutObject = parent.layoutObject(); | 846 LayoutObject* parentLayoutObject = parent.layoutObject(); |
| 847 if (!parentLayoutObject) | 847 if (!parentLayoutObject) |
| 848 return nullptr; | 848 return nullptr; |
| 849 | 849 |
| 850 // The first letter pseudo element has to look up the tree and see if any | 850 // The first letter pseudo element has to look up the tree and see if any |
| 851 // of the ancestors are first letter. | 851 // of the ancestors are first letter. |
| 852 if (pseudoId < FirstInternalPseudoId && pseudoId != PseudoIdFirstLetter && !
parentLayoutObject->style()->hasPseudoStyle(pseudoId)) | 852 if (pseudoId < FirstInternalPseudoId && pseudoId != PseudoIdFirstLetter && !
parentLayoutObject->style()->hasPseudoStyle(pseudoId)) |
| 853 return nullptr; | 853 return nullptr; |
| 854 | 854 |
| (...skipping 16 matching lines...) Expand all Loading... |
| 871 StyleResolverState state(document(), &parent, parentStyle); | 871 StyleResolverState state(document(), &parent, parentStyle); |
| 872 if (!pseudoStyleForElementInternal(parent, pseudoId, parentStyle, state)) | 872 if (!pseudoStyleForElementInternal(parent, pseudoId, parentStyle, state)) |
| 873 return nullptr; | 873 return nullptr; |
| 874 RefPtr<ComputedStyle> style = state.takeStyle(); | 874 RefPtr<ComputedStyle> style = state.takeStyle(); |
| 875 ASSERT(style); | 875 ASSERT(style); |
| 876 parentStyle->addCachedPseudoStyle(style); | 876 parentStyle->addCachedPseudoStyle(style); |
| 877 | 877 |
| 878 if (!pseudoElementLayoutObjectIsNeeded(style.get())) | 878 if (!pseudoElementLayoutObjectIsNeeded(style.get())) |
| 879 return nullptr; | 879 return nullptr; |
| 880 | 880 |
| 881 RefPtrWillBeRawPtr<PseudoElement> pseudo = createPseudoElement(&parent, pseu
doId); | 881 RawPtr<PseudoElement> pseudo = createPseudoElement(&parent, pseudoId); |
| 882 | 882 |
| 883 setAnimationUpdateIfNeeded(state, *pseudo); | 883 setAnimationUpdateIfNeeded(state, *pseudo); |
| 884 if (ElementAnimations* elementAnimations = pseudo->elementAnimations()) | 884 if (ElementAnimations* elementAnimations = pseudo->elementAnimations()) |
| 885 elementAnimations->cssAnimations().maybeApplyPendingUpdate(pseudo.get())
; | 885 elementAnimations->cssAnimations().maybeApplyPendingUpdate(pseudo.get())
; |
| 886 return pseudo.release(); | 886 return pseudo.release(); |
| 887 } | 887 } |
| 888 | 888 |
| 889 bool StyleResolver::pseudoStyleForElementInternal(Element& element, const Pseudo
StyleRequest& pseudoStyleRequest, const ComputedStyle* parentStyle, StyleResolve
rState& state) | 889 bool StyleResolver::pseudoStyleForElementInternal(Element& element, const Pseudo
StyleRequest& pseudoStyleRequest, const ComputedStyle* parentStyle, StyleResolve
rState& state) |
| 890 { | 890 { |
| 891 ASSERT(document().frame()); | 891 ASSERT(document().frame()); |
| (...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1030 return parentNode->mutableComputedStyle(); | 1030 return parentNode->mutableComputedStyle(); |
| 1031 } | 1031 } |
| 1032 | 1032 |
| 1033 void StyleResolver::updateFont(StyleResolverState& state) | 1033 void StyleResolver::updateFont(StyleResolverState& state) |
| 1034 { | 1034 { |
| 1035 state.fontBuilder().createFont(document().styleEngine().fontSelector(), stat
e.mutableStyleRef()); | 1035 state.fontBuilder().createFont(document().styleEngine().fontSelector(), stat
e.mutableStyleRef()); |
| 1036 state.setConversionFontSizes(CSSToLengthConversionData::FontSizes(state.styl
e(), state.rootElementStyle())); | 1036 state.setConversionFontSizes(CSSToLengthConversionData::FontSizes(state.styl
e(), state.rootElementStyle())); |
| 1037 state.setConversionZoom(state.style()->effectiveZoom()); | 1037 state.setConversionZoom(state.style()->effectiveZoom()); |
| 1038 } | 1038 } |
| 1039 | 1039 |
| 1040 PassRefPtrWillBeRawPtr<StyleRuleList> StyleResolver::styleRulesForElement(Elemen
t* element, unsigned rulesToInclude) | 1040 RawPtr<StyleRuleList> StyleResolver::styleRulesForElement(Element* element, unsi
gned rulesToInclude) |
| 1041 { | 1041 { |
| 1042 ASSERT(element); | 1042 ASSERT(element); |
| 1043 StyleResolverState state(document(), element); | 1043 StyleResolverState state(document(), element); |
| 1044 ElementRuleCollector collector(state.elementContext(), m_selectorFilter, sta
te.style()); | 1044 ElementRuleCollector collector(state.elementContext(), m_selectorFilter, sta
te.style()); |
| 1045 collector.setMode(SelectorChecker::CollectingStyleRules); | 1045 collector.setMode(SelectorChecker::CollectingStyleRules); |
| 1046 collectPseudoRulesForElement(*element, collector, PseudoIdNone, rulesToInclu
de); | 1046 collectPseudoRulesForElement(*element, collector, PseudoIdNone, rulesToInclu
de); |
| 1047 return collector.matchedStyleRuleList(); | 1047 return collector.matchedStyleRuleList(); |
| 1048 } | 1048 } |
| 1049 | 1049 |
| 1050 PassRefPtrWillBeRawPtr<CSSRuleList> StyleResolver::pseudoCSSRulesForElement(Elem
ent* element, PseudoId pseudoId, unsigned rulesToInclude) | 1050 RawPtr<CSSRuleList> StyleResolver::pseudoCSSRulesForElement(Element* element, Ps
eudoId pseudoId, unsigned rulesToInclude) |
| 1051 { | 1051 { |
| 1052 ASSERT(element); | 1052 ASSERT(element); |
| 1053 StyleResolverState state(document(), element); | 1053 StyleResolverState state(document(), element); |
| 1054 ElementRuleCollector collector(state.elementContext(), m_selectorFilter, sta
te.style()); | 1054 ElementRuleCollector collector(state.elementContext(), m_selectorFilter, sta
te.style()); |
| 1055 collector.setMode(SelectorChecker::CollectingCSSRules); | 1055 collector.setMode(SelectorChecker::CollectingCSSRules); |
| 1056 collectPseudoRulesForElement(*element, collector, pseudoId, rulesToInclude); | 1056 collectPseudoRulesForElement(*element, collector, pseudoId, rulesToInclude); |
| 1057 return collector.matchedCSSRuleList(); | 1057 return collector.matchedCSSRuleList(); |
| 1058 } | 1058 } |
| 1059 | 1059 |
| 1060 PassRefPtrWillBeRawPtr<CSSRuleList> StyleResolver::cssRulesForElement(Element* e
lement, unsigned rulesToInclude) | 1060 RawPtr<CSSRuleList> StyleResolver::cssRulesForElement(Element* element, unsigned
rulesToInclude) |
| 1061 { | 1061 { |
| 1062 return pseudoCSSRulesForElement(element, PseudoIdNone, rulesToInclude); | 1062 return pseudoCSSRulesForElement(element, PseudoIdNone, rulesToInclude); |
| 1063 } | 1063 } |
| 1064 | 1064 |
| 1065 void StyleResolver::collectPseudoRulesForElement(const Element& element, Element
RuleCollector& collector, PseudoId pseudoId, unsigned rulesToInclude) | 1065 void StyleResolver::collectPseudoRulesForElement(const Element& element, Element
RuleCollector& collector, PseudoId pseudoId, unsigned rulesToInclude) |
| 1066 { | 1066 { |
| 1067 collector.setPseudoStyleRequest(PseudoStyleRequest(pseudoId)); | 1067 collector.setPseudoStyleRequest(PseudoStyleRequest(pseudoId)); |
| 1068 | 1068 |
| 1069 if (rulesToInclude & UAAndUserCSSRules) | 1069 if (rulesToInclude & UAAndUserCSSRules) |
| 1070 matchUARules(collector); | 1070 matchUARules(collector); |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1117 | 1117 |
| 1118 ASSERT(!state.fontBuilder().fontDirty()); | 1118 ASSERT(!state.fontBuilder().fontDirty()); |
| 1119 | 1119 |
| 1120 state.setApplyPropertyToVisitedLinkStyle(false); | 1120 state.setApplyPropertyToVisitedLinkStyle(false); |
| 1121 | 1121 |
| 1122 return true; | 1122 return true; |
| 1123 } | 1123 } |
| 1124 | 1124 |
| 1125 StyleRuleKeyframes* StyleResolver::findKeyframesRule(const Element* element, con
st AtomicString& animationName) | 1125 StyleRuleKeyframes* StyleResolver::findKeyframesRule(const Element* element, con
st AtomicString& animationName) |
| 1126 { | 1126 { |
| 1127 WillBeHeapVector<RawPtrWillBeMember<ScopedStyleResolver>, 8> resolvers; | 1127 HeapVector<Member<ScopedStyleResolver>, 8> resolvers; |
| 1128 collectScopedResolversForHostedShadowTrees(*element, resolvers); | 1128 collectScopedResolversForHostedShadowTrees(*element, resolvers); |
| 1129 if (ScopedStyleResolver* scopedResolver = element->treeScope().scopedStyleRe
solver()) | 1129 if (ScopedStyleResolver* scopedResolver = element->treeScope().scopedStyleRe
solver()) |
| 1130 resolvers.append(scopedResolver); | 1130 resolvers.append(scopedResolver); |
| 1131 | 1131 |
| 1132 for (size_t i = 0; i < resolvers.size(); ++i) { | 1132 for (size_t i = 0; i < resolvers.size(); ++i) { |
| 1133 if (StyleRuleKeyframes* keyframesRule = resolvers[i]->keyframeStylesForA
nimation(animationName.impl())) | 1133 if (StyleRuleKeyframes* keyframesRule = resolvers[i]->keyframeStylesForA
nimation(animationName.impl())) |
| 1134 return keyframesRule; | 1134 return keyframesRule; |
| 1135 } | 1135 } |
| 1136 return nullptr; | 1136 return nullptr; |
| 1137 } | 1137 } |
| (...skipping 493 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1631 return; | 1631 return; |
| 1632 | 1632 |
| 1633 ElementRuleCollector collector(state.elementContext(), m_selectorFilter, sta
te.style()); | 1633 ElementRuleCollector collector(state.elementContext(), m_selectorFilter, sta
te.style()); |
| 1634 collector.setMode(SelectorChecker::CollectingStyleRules); | 1634 collector.setMode(SelectorChecker::CollectingStyleRules); |
| 1635 collector.setIncludeEmptyRules(true); | 1635 collector.setIncludeEmptyRules(true); |
| 1636 | 1636 |
| 1637 MatchRequest matchRequest(m_watchedSelectorsRules.get()); | 1637 MatchRequest matchRequest(m_watchedSelectorsRules.get()); |
| 1638 collector.collectMatchingRules(matchRequest); | 1638 collector.collectMatchingRules(matchRequest); |
| 1639 collector.sortAndTransferMatchedRules(); | 1639 collector.sortAndTransferMatchedRules(); |
| 1640 | 1640 |
| 1641 RefPtrWillBeRawPtr<StyleRuleList> rules = collector.matchedStyleRuleList(); | 1641 RawPtr<StyleRuleList> rules = collector.matchedStyleRuleList(); |
| 1642 if (!rules) | 1642 if (!rules) |
| 1643 return; | 1643 return; |
| 1644 for (size_t i = 0; i < rules->size(); i++) | 1644 for (size_t i = 0; i < rules->size(); i++) |
| 1645 state.style()->addCallbackSelector(rules->at(i)->selectorList().selector
sText()); | 1645 state.style()->addCallbackSelector(rules->at(i)->selectorList().selector
sText()); |
| 1646 } | 1646 } |
| 1647 | 1647 |
| 1648 void StyleResolver::computeFont(ComputedStyle* style, const StylePropertySet& pr
opertySet) | 1648 void StyleResolver::computeFont(ComputedStyle* style, const StylePropertySet& pr
opertySet) |
| 1649 { | 1649 { |
| 1650 CSSPropertyID properties[] = { | 1650 CSSPropertyID properties[] = { |
| 1651 CSSPropertyFontSize, | 1651 CSSPropertyFontSize, |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1712 visitor->trace(m_uncommonAttributeRuleSet); | 1712 visitor->trace(m_uncommonAttributeRuleSet); |
| 1713 visitor->trace(m_watchedSelectorsRules); | 1713 visitor->trace(m_watchedSelectorsRules); |
| 1714 visitor->trace(m_treeBoundaryCrossingScopes); | 1714 visitor->trace(m_treeBoundaryCrossingScopes); |
| 1715 visitor->trace(m_styleSharingLists); | 1715 visitor->trace(m_styleSharingLists); |
| 1716 visitor->trace(m_pendingStyleSheets); | 1716 visitor->trace(m_pendingStyleSheets); |
| 1717 visitor->trace(m_document); | 1717 visitor->trace(m_document); |
| 1718 #endif | 1718 #endif |
| 1719 } | 1719 } |
| 1720 | 1720 |
| 1721 } // namespace blink | 1721 } // namespace blink |
| OLD | NEW |