| 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 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 118 } | 118 } |
| 119 | 119 |
| 120 static StylePropertySet* rightToLeftDeclaration() | 120 static StylePropertySet* rightToLeftDeclaration() |
| 121 { | 121 { |
| 122 DEFINE_STATIC_REF_WILL_BE_PERSISTENT(MutableStylePropertySet, rightToLeftDec
l, (MutableStylePropertySet::create(HTMLQuirksMode))); | 122 DEFINE_STATIC_REF_WILL_BE_PERSISTENT(MutableStylePropertySet, rightToLeftDec
l, (MutableStylePropertySet::create(HTMLQuirksMode))); |
| 123 if (rightToLeftDecl->isEmpty()) | 123 if (rightToLeftDecl->isEmpty()) |
| 124 rightToLeftDecl->setProperty(CSSPropertyDirection, CSSValueRtl); | 124 rightToLeftDecl->setProperty(CSSPropertyDirection, CSSValueRtl); |
| 125 return rightToLeftDecl; | 125 return rightToLeftDecl; |
| 126 } | 126 } |
| 127 | 127 |
| 128 static void collectScopedResolversForHostedShadowTrees(const Element& element, W
illBeHeapVector<RawPtrWillBeMember<ScopedStyleResolver>, 8>& resolvers) | 128 static void collectScopedResolversForHostedShadowTrees(const Element& element, H
eapVector<Member<ScopedStyleResolver>, 8>& resolvers) |
| 129 { | 129 { |
| 130 ElementShadow* shadow = element.shadow(); | 130 ElementShadow* shadow = element.shadow(); |
| 131 if (!shadow) | 131 if (!shadow) |
| 132 return; | 132 return; |
| 133 | 133 |
| 134 // Adding scoped resolver for active shadow roots for shadow host styling. | 134 // Adding scoped resolver for active shadow roots for shadow host styling. |
| 135 for (ShadowRoot* shadowRoot = &shadow->youngestShadowRoot(); shadowRoot; sha
dowRoot = shadowRoot->olderShadowRoot()) { | 135 for (ShadowRoot* shadowRoot = &shadow->youngestShadowRoot(); shadowRoot; sha
dowRoot = shadowRoot->olderShadowRoot()) { |
| 136 if (shadowRoot->numberOfStyles() > 0) { | 136 if (shadowRoot->numberOfStyles() > 0) { |
| 137 if (ScopedStyleResolver* resolver = shadowRoot->scopedStyleResolver(
)) | 137 if (ScopedStyleResolver* resolver = shadowRoot->scopedStyleResolver(
)) |
| 138 resolvers.append(resolver); | 138 resolvers.append(resolver); |
| 139 } | 139 } |
| 140 } | 140 } |
| 141 } | 141 } |
| 142 | 142 |
| 143 StyleResolver::StyleResolver(Document& document) | 143 StyleResolver::StyleResolver(Document& document) |
| 144 : m_document(document) | 144 : m_document(document) |
| 145 , m_viewportStyleResolver(ViewportStyleResolver::create(&document)) | 145 , m_viewportStyleResolver(ViewportStyleResolver::create(&document)) |
| 146 , m_needCollectFeatures(false) | 146 , m_needCollectFeatures(false) |
| 147 , m_printMediaType(false) | 147 , m_printMediaType(false) |
| 148 , m_styleSharingDepth(0) | 148 , m_styleSharingDepth(0) |
| 149 { | 149 { |
| 150 FrameView* view = document.view(); | 150 FrameView* view = document.view(); |
| 151 if (view) { | 151 if (view) { |
| 152 m_medium = adoptPtrWillBeNoop(new MediaQueryEvaluator(&view->frame())); | 152 m_medium = (new MediaQueryEvaluator(&view->frame())); |
| 153 m_printMediaType = equalIgnoringCase(view->mediaType(), MediaTypeNames::
print); | 153 m_printMediaType = equalIgnoringCase(view->mediaType(), MediaTypeNames::
print); |
| 154 } else { | 154 } else { |
| 155 m_medium = adoptPtrWillBeNoop(new MediaQueryEvaluator("all")); | 155 m_medium = (new MediaQueryEvaluator("all")); |
| 156 } | 156 } |
| 157 | 157 |
| 158 initWatchedSelectorRules(); | 158 initWatchedSelectorRules(); |
| 159 } | 159 } |
| 160 | 160 |
| 161 StyleResolver::~StyleResolver() | 161 StyleResolver::~StyleResolver() |
| 162 { | 162 { |
| 163 } | 163 } |
| 164 | 164 |
| 165 void StyleResolver::dispose() | 165 void StyleResolver::dispose() |
| 166 { | 166 { |
| 167 m_matchedPropertiesCache.clear(); | 167 m_matchedPropertiesCache.clear(); |
| 168 } | 168 } |
| 169 | 169 |
| 170 void StyleResolver::initWatchedSelectorRules() | 170 void StyleResolver::initWatchedSelectorRules() |
| 171 { | 171 { |
| 172 CSSSelectorWatch* watch = CSSSelectorWatch::fromIfExists(*m_document); | 172 CSSSelectorWatch* watch = CSSSelectorWatch::fromIfExists(*m_document); |
| 173 if (!watch) | 173 if (!watch) |
| 174 return; | 174 return; |
| 175 const WillBeHeapVector<RefPtrWillBeMember<StyleRule>>& watchedSelectors = wa
tch->watchedCallbackSelectors(); | 175 const HeapVector<Member<StyleRule>>& watchedSelectors = watch->watchedCallba
ckSelectors(); |
| 176 if (!watchedSelectors.size()) | 176 if (!watchedSelectors.size()) |
| 177 return; | 177 return; |
| 178 m_watchedSelectorsRules = RuleSet::create(); | 178 m_watchedSelectorsRules = RuleSet::create(); |
| 179 for (unsigned i = 0; i < watchedSelectors.size(); ++i) | 179 for (unsigned i = 0; i < watchedSelectors.size(); ++i) |
| 180 m_watchedSelectorsRules->addStyleRule(watchedSelectors[i].get(), RuleHas
NoSpecialState); | 180 m_watchedSelectorsRules->addStyleRule(watchedSelectors[i].get(), RuleHas
NoSpecialState); |
| 181 } | 181 } |
| 182 | 182 |
| 183 void StyleResolver::lazyAppendAuthorStyleSheets(unsigned firstNew, const WillBeH
eapVector<RefPtrWillBeMember<CSSStyleSheet>>& styleSheets) | 183 void StyleResolver::lazyAppendAuthorStyleSheets(unsigned firstNew, const HeapVec
tor<Member<CSSStyleSheet>>& styleSheets) |
| 184 { | 184 { |
| 185 unsigned size = styleSheets.size(); | 185 unsigned size = styleSheets.size(); |
| 186 for (unsigned i = firstNew; i < size; ++i) | 186 for (unsigned i = firstNew; i < size; ++i) |
| 187 m_pendingStyleSheets.add(styleSheets[i].get()); | 187 m_pendingStyleSheets.add(styleSheets[i].get()); |
| 188 } | 188 } |
| 189 | 189 |
| 190 void StyleResolver::removePendingAuthorStyleSheets(const WillBeHeapVector<RefPtr
WillBeMember<CSSStyleSheet>>& styleSheets) | 190 void StyleResolver::removePendingAuthorStyleSheets(const HeapVector<Member<CSSSt
yleSheet>>& styleSheets) |
| 191 { | 191 { |
| 192 for (unsigned i = 0; i < styleSheets.size(); ++i) | 192 for (unsigned i = 0; i < styleSheets.size(); ++i) |
| 193 m_pendingStyleSheets.remove(styleSheets[i].get()); | 193 m_pendingStyleSheets.remove(styleSheets[i].get()); |
| 194 } | 194 } |
| 195 | 195 |
| 196 void StyleResolver::appendCSSStyleSheet(CSSStyleSheet& cssSheet) | 196 void StyleResolver::appendCSSStyleSheet(CSSStyleSheet& cssSheet) |
| 197 { | 197 { |
| 198 ASSERT(!cssSheet.disabled()); | 198 ASSERT(!cssSheet.disabled()); |
| 199 ASSERT(cssSheet.ownerDocument()); | 199 ASSERT(cssSheet.ownerDocument()); |
| 200 ASSERT(cssSheet.ownerNode()); | 200 ASSERT(cssSheet.ownerNode()); |
| (...skipping 21 matching lines...) Expand all Loading... |
| 222 | 222 |
| 223 void StyleResolver::appendPendingAuthorStyleSheets() | 223 void StyleResolver::appendPendingAuthorStyleSheets() |
| 224 { | 224 { |
| 225 for (const auto& styleSheet : m_pendingStyleSheets) | 225 for (const auto& styleSheet : m_pendingStyleSheets) |
| 226 appendCSSStyleSheet(*styleSheet); | 226 appendCSSStyleSheet(*styleSheet); |
| 227 | 227 |
| 228 m_pendingStyleSheets.clear(); | 228 m_pendingStyleSheets.clear(); |
| 229 finishAppendAuthorStyleSheets(); | 229 finishAppendAuthorStyleSheets(); |
| 230 } | 230 } |
| 231 | 231 |
| 232 void StyleResolver::appendAuthorStyleSheets(const WillBeHeapVector<RefPtrWillBeM
ember<CSSStyleSheet>>& styleSheets) | 232 void StyleResolver::appendAuthorStyleSheets(const HeapVector<Member<CSSStyleShee
t>>& styleSheets) |
| 233 { | 233 { |
| 234 // This handles sheets added to the end of the stylesheet list only. In othe
r cases the style resolver | 234 // This handles sheets added to the end of the stylesheet list only. In othe
r cases the style resolver |
| 235 // needs to be reconstructed. To handle insertions too the rule order number
s would need to be updated. | 235 // needs to be reconstructed. To handle insertions too the rule order number
s would need to be updated. |
| 236 for (const auto& styleSheet : styleSheets) | 236 for (const auto& styleSheet : styleSheets) |
| 237 appendCSSStyleSheet(*styleSheet); | 237 appendCSSStyleSheet(*styleSheet); |
| 238 } | 238 } |
| 239 | 239 |
| 240 void StyleResolver::finishAppendAuthorStyleSheets() | 240 void StyleResolver::finishAppendAuthorStyleSheets() |
| 241 { | 241 { |
| 242 collectFeatures(); | 242 collectFeatures(); |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 275 | 275 |
| 276 if (treeScope.rootNode().isDocumentNode()) { | 276 if (treeScope.rootNode().isDocumentNode()) { |
| 277 resolver->resetAuthorStyle(); | 277 resolver->resetAuthorStyle(); |
| 278 return; | 278 return; |
| 279 } | 279 } |
| 280 | 280 |
| 281 // resolver is going to be freed below. | 281 // resolver is going to be freed below. |
| 282 treeScope.clearScopedStyleResolver(); | 282 treeScope.clearScopedStyleResolver(); |
| 283 } | 283 } |
| 284 | 284 |
| 285 static PassOwnPtrWillBeRawPtr<RuleSet> makeRuleSet(const WillBeHeapVector<RuleFe
ature>& rules) | 285 static RawPtr<RuleSet> makeRuleSet(const HeapVector<RuleFeature>& rules) |
| 286 { | 286 { |
| 287 size_t size = rules.size(); | 287 size_t size = rules.size(); |
| 288 if (!size) | 288 if (!size) |
| 289 return nullptr; | 289 return nullptr; |
| 290 OwnPtrWillBeRawPtr<RuleSet> ruleSet = RuleSet::create(); | 290 RawPtr<RuleSet> ruleSet = RuleSet::create(); |
| 291 for (size_t i = 0; i < size; ++i) | 291 for (size_t i = 0; i < size; ++i) |
| 292 ruleSet->addRule(rules[i].rule, rules[i].selectorIndex, rules[i].hasDocu
mentSecurityOrigin ? RuleHasDocumentSecurityOrigin : RuleHasNoSpecialState); | 292 ruleSet->addRule(rules[i].rule, rules[i].selectorIndex, rules[i].hasDocu
mentSecurityOrigin ? RuleHasDocumentSecurityOrigin : RuleHasNoSpecialState); |
| 293 return ruleSet.release(); | 293 return ruleSet.release(); |
| 294 } | 294 } |
| 295 | 295 |
| 296 void StyleResolver::collectFeatures() | 296 void StyleResolver::collectFeatures() |
| 297 { | 297 { |
| 298 m_features.clear(); | 298 m_features.clear(); |
| 299 // Collect all ids and rules using sibling selectors (:first-child and simil
ar) | 299 // Collect all ids and rules using sibling selectors (:first-child and simil
ar) |
| 300 // in the current set of stylesheets. Style sharing code uses this informati
on to reject | 300 // in the current set of stylesheets. Style sharing code uses this informati
on to reject |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 337 | 337 |
| 338 StyleSharingList& StyleResolver::styleSharingList() | 338 StyleSharingList& StyleResolver::styleSharingList() |
| 339 { | 339 { |
| 340 m_styleSharingLists.resize(styleSharingMaxDepth); | 340 m_styleSharingLists.resize(styleSharingMaxDepth); |
| 341 | 341 |
| 342 // We never put things at depth 0 into the list since that's only the <html>
element | 342 // We never put things at depth 0 into the list since that's only the <html>
element |
| 343 // and it has no siblings or cousins to share with. | 343 // and it has no siblings or cousins to share with. |
| 344 unsigned depth = std::max(std::min(m_styleSharingDepth, styleSharingMaxDepth
), 1u) - 1u; | 344 unsigned depth = std::max(std::min(m_styleSharingDepth, styleSharingMaxDepth
), 1u) - 1u; |
| 345 | 345 |
| 346 if (!m_styleSharingLists[depth]) | 346 if (!m_styleSharingLists[depth]) |
| 347 m_styleSharingLists[depth] = adoptPtrWillBeNoop(new StyleSharingList); | 347 m_styleSharingLists[depth] = (new StyleSharingList); |
| 348 return *m_styleSharingLists[depth]; | 348 return *m_styleSharingLists[depth]; |
| 349 } | 349 } |
| 350 | 350 |
| 351 void StyleResolver::clearStyleSharingList() | 351 void StyleResolver::clearStyleSharingList() |
| 352 { | 352 { |
| 353 m_styleSharingLists.resize(0); | 353 m_styleSharingLists.resize(0); |
| 354 } | 354 } |
| 355 | 355 |
| 356 static inline ScopedStyleResolver* scopedResolverFor(const Element& element) | 356 static inline ScopedStyleResolver* scopedResolverFor(const Element& element) |
| 357 { | 357 { |
| (...skipping 21 matching lines...) Expand all Loading... |
| 379 if (element.shadowPseudoId().isEmpty() && !element.isVTTElement()) | 379 if (element.shadowPseudoId().isEmpty() && !element.isVTTElement()) |
| 380 return nullptr; | 380 return nullptr; |
| 381 return treeScope->scopedStyleResolver(); | 381 return treeScope->scopedStyleResolver(); |
| 382 } | 382 } |
| 383 | 383 |
| 384 void StyleResolver::matchAuthorRules(const Element& element, ElementRuleCollecto
r& collector) | 384 void StyleResolver::matchAuthorRules(const Element& element, ElementRuleCollecto
r& collector) |
| 385 { | 385 { |
| 386 collector.clearMatchedRules(); | 386 collector.clearMatchedRules(); |
| 387 | 387 |
| 388 CascadeOrder cascadeOrder = 0; | 388 CascadeOrder cascadeOrder = 0; |
| 389 WillBeHeapVector<RawPtrWillBeMember<ScopedStyleResolver>, 8> resolversInShad
owTree; | 389 HeapVector<Member<ScopedStyleResolver>, 8> resolversInShadowTree; |
| 390 collectScopedResolversForHostedShadowTrees(element, resolversInShadowTree); | 390 collectScopedResolversForHostedShadowTrees(element, resolversInShadowTree); |
| 391 | 391 |
| 392 // Apply :host and :host-context rules from inner scopes. | 392 // Apply :host and :host-context rules from inner scopes. |
| 393 for (int j = resolversInShadowTree.size() - 1; j >= 0; --j) | 393 for (int j = resolversInShadowTree.size() - 1; j >= 0; --j) |
| 394 resolversInShadowTree.at(j)->collectMatchingShadowHostRules(collector, +
+cascadeOrder); | 394 resolversInShadowTree.at(j)->collectMatchingShadowHostRules(collector, +
+cascadeOrder); |
| 395 | 395 |
| 396 // Apply normal rules from element scope. | 396 // Apply normal rules from element scope. |
| 397 if (ScopedStyleResolver* resolver = scopedResolverFor(element)) | 397 if (ScopedStyleResolver* resolver = scopedResolverFor(element)) |
| 398 resolver->collectMatchingAuthorRules(collector, ++cascadeOrder); | 398 resolver->collectMatchingAuthorRules(collector, ++cascadeOrder); |
| 399 | 399 |
| (...skipping 297 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 697 | 697 |
| 698 PassRefPtr<AnimatableValue> StyleResolver::createAnimatableValueSnapshot(StyleRe
solverState& state, CSSPropertyID property, CSSValue* value) | 698 PassRefPtr<AnimatableValue> StyleResolver::createAnimatableValueSnapshot(StyleRe
solverState& state, CSSPropertyID property, CSSValue* value) |
| 699 { | 699 { |
| 700 if (value) { | 700 if (value) { |
| 701 StyleBuilder::applyProperty(property, state, value); | 701 StyleBuilder::applyProperty(property, state, value); |
| 702 state.fontBuilder().createFont(state.document().styleEngine().fontSelect
or(), state.mutableStyleRef()); | 702 state.fontBuilder().createFont(state.document().styleEngine().fontSelect
or(), state.mutableStyleRef()); |
| 703 } | 703 } |
| 704 return CSSAnimatableValueFactory::create(property, *state.style()); | 704 return CSSAnimatableValueFactory::create(property, *state.style()); |
| 705 } | 705 } |
| 706 | 706 |
| 707 PassRefPtrWillBeRawPtr<PseudoElement> StyleResolver::createPseudoElement(Element
* parent, PseudoId pseudoId) | 707 RawPtr<PseudoElement> StyleResolver::createPseudoElement(Element* parent, Pseudo
Id pseudoId) |
| 708 { | 708 { |
| 709 if (pseudoId == FIRST_LETTER) | 709 if (pseudoId == FIRST_LETTER) |
| 710 return FirstLetterPseudoElement::create(parent); | 710 return FirstLetterPseudoElement::create(parent); |
| 711 return PseudoElement::create(parent, pseudoId); | 711 return PseudoElement::create(parent, pseudoId); |
| 712 } | 712 } |
| 713 | 713 |
| 714 PassRefPtrWillBeRawPtr<PseudoElement> StyleResolver::createPseudoElementIfNeeded
(Element& parent, PseudoId pseudoId) | 714 RawPtr<PseudoElement> StyleResolver::createPseudoElementIfNeeded(Element& parent
, PseudoId pseudoId) |
| 715 { | 715 { |
| 716 LayoutObject* parentLayoutObject = parent.layoutObject(); | 716 LayoutObject* parentLayoutObject = parent.layoutObject(); |
| 717 if (!parentLayoutObject) | 717 if (!parentLayoutObject) |
| 718 return nullptr; | 718 return nullptr; |
| 719 | 719 |
| 720 // The first letter pseudo element has to look up the tree and see if any | 720 // The first letter pseudo element has to look up the tree and see if any |
| 721 // of the ancestors are first letter. | 721 // of the ancestors are first letter. |
| 722 if (pseudoId < FIRST_INTERNAL_PSEUDOID && pseudoId != FIRST_LETTER && !paren
tLayoutObject->style()->hasPseudoStyle(pseudoId)) | 722 if (pseudoId < FIRST_INTERNAL_PSEUDOID && pseudoId != FIRST_LETTER && !paren
tLayoutObject->style()->hasPseudoStyle(pseudoId)) |
| 723 return nullptr; | 723 return nullptr; |
| 724 | 724 |
| (...skipping 16 matching lines...) Expand all Loading... |
| 741 StyleResolverState state(document(), &parent, parentStyle); | 741 StyleResolverState state(document(), &parent, parentStyle); |
| 742 if (!pseudoStyleForElementInternal(parent, pseudoId, parentStyle, state)) | 742 if (!pseudoStyleForElementInternal(parent, pseudoId, parentStyle, state)) |
| 743 return nullptr; | 743 return nullptr; |
| 744 RefPtr<ComputedStyle> style = state.takeStyle(); | 744 RefPtr<ComputedStyle> style = state.takeStyle(); |
| 745 ASSERT(style); | 745 ASSERT(style); |
| 746 parentStyle->addCachedPseudoStyle(style); | 746 parentStyle->addCachedPseudoStyle(style); |
| 747 | 747 |
| 748 if (!pseudoElementLayoutObjectIsNeeded(style.get())) | 748 if (!pseudoElementLayoutObjectIsNeeded(style.get())) |
| 749 return nullptr; | 749 return nullptr; |
| 750 | 750 |
| 751 RefPtrWillBeRawPtr<PseudoElement> pseudo = createPseudoElement(&parent, pseu
doId); | 751 RawPtr<PseudoElement> pseudo = createPseudoElement(&parent, pseudoId); |
| 752 | 752 |
| 753 setAnimationUpdateIfNeeded(state, *pseudo); | 753 setAnimationUpdateIfNeeded(state, *pseudo); |
| 754 if (ElementAnimations* elementAnimations = pseudo->elementAnimations()) | 754 if (ElementAnimations* elementAnimations = pseudo->elementAnimations()) |
| 755 elementAnimations->cssAnimations().maybeApplyPendingUpdate(pseudo.get())
; | 755 elementAnimations->cssAnimations().maybeApplyPendingUpdate(pseudo.get())
; |
| 756 return pseudo.release(); | 756 return pseudo.release(); |
| 757 } | 757 } |
| 758 | 758 |
| 759 bool StyleResolver::pseudoStyleForElementInternal(Element& element, const Pseudo
StyleRequest& pseudoStyleRequest, const ComputedStyle* parentStyle, StyleResolve
rState& state) | 759 bool StyleResolver::pseudoStyleForElementInternal(Element& element, const Pseudo
StyleRequest& pseudoStyleRequest, const ComputedStyle* parentStyle, StyleResolve
rState& state) |
| 760 { | 760 { |
| 761 ASSERT(document().frame()); | 761 ASSERT(document().frame()); |
| (...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 900 return parentNode->mutableComputedStyle(); | 900 return parentNode->mutableComputedStyle(); |
| 901 } | 901 } |
| 902 | 902 |
| 903 void StyleResolver::updateFont(StyleResolverState& state) | 903 void StyleResolver::updateFont(StyleResolverState& state) |
| 904 { | 904 { |
| 905 state.fontBuilder().createFont(document().styleEngine().fontSelector(), stat
e.mutableStyleRef()); | 905 state.fontBuilder().createFont(document().styleEngine().fontSelector(), stat
e.mutableStyleRef()); |
| 906 state.setConversionFontSizes(CSSToLengthConversionData::FontSizes(state.styl
e(), state.rootElementStyle())); | 906 state.setConversionFontSizes(CSSToLengthConversionData::FontSizes(state.styl
e(), state.rootElementStyle())); |
| 907 state.setConversionZoom(state.style()->effectiveZoom()); | 907 state.setConversionZoom(state.style()->effectiveZoom()); |
| 908 } | 908 } |
| 909 | 909 |
| 910 PassRefPtrWillBeRawPtr<StyleRuleList> StyleResolver::styleRulesForElement(Elemen
t* element, unsigned rulesToInclude) | 910 RawPtr<StyleRuleList> StyleResolver::styleRulesForElement(Element* element, unsi
gned rulesToInclude) |
| 911 { | 911 { |
| 912 ASSERT(element); | 912 ASSERT(element); |
| 913 StyleResolverState state(document(), element); | 913 StyleResolverState state(document(), element); |
| 914 ElementRuleCollector collector(state.elementContext(), m_selectorFilter, sta
te.style()); | 914 ElementRuleCollector collector(state.elementContext(), m_selectorFilter, sta
te.style()); |
| 915 collector.setMode(SelectorChecker::CollectingStyleRules); | 915 collector.setMode(SelectorChecker::CollectingStyleRules); |
| 916 collectPseudoRulesForElement(*element, collector, NOPSEUDO, rulesToInclude); | 916 collectPseudoRulesForElement(*element, collector, NOPSEUDO, rulesToInclude); |
| 917 return collector.matchedStyleRuleList(); | 917 return collector.matchedStyleRuleList(); |
| 918 } | 918 } |
| 919 | 919 |
| 920 PassRefPtrWillBeRawPtr<CSSRuleList> StyleResolver::pseudoCSSRulesForElement(Elem
ent* element, PseudoId pseudoId, unsigned rulesToInclude) | 920 RawPtr<CSSRuleList> StyleResolver::pseudoCSSRulesForElement(Element* element, Ps
eudoId pseudoId, unsigned rulesToInclude) |
| 921 { | 921 { |
| 922 ASSERT(element); | 922 ASSERT(element); |
| 923 StyleResolverState state(document(), element); | 923 StyleResolverState state(document(), element); |
| 924 ElementRuleCollector collector(state.elementContext(), m_selectorFilter, sta
te.style()); | 924 ElementRuleCollector collector(state.elementContext(), m_selectorFilter, sta
te.style()); |
| 925 collector.setMode(SelectorChecker::CollectingCSSRules); | 925 collector.setMode(SelectorChecker::CollectingCSSRules); |
| 926 collectPseudoRulesForElement(*element, collector, pseudoId, rulesToInclude); | 926 collectPseudoRulesForElement(*element, collector, pseudoId, rulesToInclude); |
| 927 return collector.matchedCSSRuleList(); | 927 return collector.matchedCSSRuleList(); |
| 928 } | 928 } |
| 929 | 929 |
| 930 PassRefPtrWillBeRawPtr<CSSRuleList> StyleResolver::cssRulesForElement(Element* e
lement, unsigned rulesToInclude) | 930 RawPtr<CSSRuleList> StyleResolver::cssRulesForElement(Element* element, unsigned
rulesToInclude) |
| 931 { | 931 { |
| 932 return pseudoCSSRulesForElement(element, NOPSEUDO, rulesToInclude); | 932 return pseudoCSSRulesForElement(element, NOPSEUDO, rulesToInclude); |
| 933 } | 933 } |
| 934 | 934 |
| 935 void StyleResolver::collectPseudoRulesForElement(const Element& element, Element
RuleCollector& collector, PseudoId pseudoId, unsigned rulesToInclude) | 935 void StyleResolver::collectPseudoRulesForElement(const Element& element, Element
RuleCollector& collector, PseudoId pseudoId, unsigned rulesToInclude) |
| 936 { | 936 { |
| 937 collector.setPseudoStyleRequest(PseudoStyleRequest(pseudoId)); | 937 collector.setPseudoStyleRequest(PseudoStyleRequest(pseudoId)); |
| 938 | 938 |
| 939 if (rulesToInclude & UAAndUserCSSRules) | 939 if (rulesToInclude & UAAndUserCSSRules) |
| 940 matchUARules(collector); | 940 matchUARules(collector); |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 987 | 987 |
| 988 ASSERT(!state.fontBuilder().fontDirty()); | 988 ASSERT(!state.fontBuilder().fontDirty()); |
| 989 | 989 |
| 990 state.setApplyPropertyToVisitedLinkStyle(false); | 990 state.setApplyPropertyToVisitedLinkStyle(false); |
| 991 | 991 |
| 992 return true; | 992 return true; |
| 993 } | 993 } |
| 994 | 994 |
| 995 StyleRuleKeyframes* StyleResolver::findKeyframesRule(const Element* element, con
st AtomicString& animationName) | 995 StyleRuleKeyframes* StyleResolver::findKeyframesRule(const Element* element, con
st AtomicString& animationName) |
| 996 { | 996 { |
| 997 WillBeHeapVector<RawPtrWillBeMember<ScopedStyleResolver>, 8> resolvers; | 997 HeapVector<Member<ScopedStyleResolver>, 8> resolvers; |
| 998 collectScopedResolversForHostedShadowTrees(*element, resolvers); | 998 collectScopedResolversForHostedShadowTrees(*element, resolvers); |
| 999 if (ScopedStyleResolver* scopedResolver = element->treeScope().scopedStyleRe
solver()) | 999 if (ScopedStyleResolver* scopedResolver = element->treeScope().scopedStyleRe
solver()) |
| 1000 resolvers.append(scopedResolver); | 1000 resolvers.append(scopedResolver); |
| 1001 | 1001 |
| 1002 for (size_t i = 0; i < resolvers.size(); ++i) { | 1002 for (size_t i = 0; i < resolvers.size(); ++i) { |
| 1003 if (StyleRuleKeyframes* keyframesRule = resolvers[i]->keyframeStylesForA
nimation(animationName.impl())) | 1003 if (StyleRuleKeyframes* keyframesRule = resolvers[i]->keyframeStylesForA
nimation(animationName.impl())) |
| 1004 return keyframesRule; | 1004 return keyframesRule; |
| 1005 } | 1005 } |
| 1006 return nullptr; | 1006 return nullptr; |
| 1007 } | 1007 } |
| (...skipping 469 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1477 return; | 1477 return; |
| 1478 | 1478 |
| 1479 ElementRuleCollector collector(state.elementContext(), m_selectorFilter, sta
te.style()); | 1479 ElementRuleCollector collector(state.elementContext(), m_selectorFilter, sta
te.style()); |
| 1480 collector.setMode(SelectorChecker::CollectingStyleRules); | 1480 collector.setMode(SelectorChecker::CollectingStyleRules); |
| 1481 collector.setIncludeEmptyRules(true); | 1481 collector.setIncludeEmptyRules(true); |
| 1482 | 1482 |
| 1483 MatchRequest matchRequest(m_watchedSelectorsRules.get()); | 1483 MatchRequest matchRequest(m_watchedSelectorsRules.get()); |
| 1484 collector.collectMatchingRules(matchRequest); | 1484 collector.collectMatchingRules(matchRequest); |
| 1485 collector.sortAndTransferMatchedRules(); | 1485 collector.sortAndTransferMatchedRules(); |
| 1486 | 1486 |
| 1487 RefPtrWillBeRawPtr<StyleRuleList> rules = collector.matchedStyleRuleList(); | 1487 RawPtr<StyleRuleList> rules = collector.matchedStyleRuleList(); |
| 1488 if (!rules) | 1488 if (!rules) |
| 1489 return; | 1489 return; |
| 1490 for (size_t i = 0; i < rules->size(); i++) | 1490 for (size_t i = 0; i < rules->size(); i++) |
| 1491 state.style()->addCallbackSelector(rules->at(i)->selectorList().selector
sText()); | 1491 state.style()->addCallbackSelector(rules->at(i)->selectorList().selector
sText()); |
| 1492 } | 1492 } |
| 1493 | 1493 |
| 1494 void StyleResolver::computeFont(ComputedStyle* style, const StylePropertySet& pr
opertySet) | 1494 void StyleResolver::computeFont(ComputedStyle* style, const StylePropertySet& pr
opertySet) |
| 1495 { | 1495 { |
| 1496 CSSPropertyID properties[] = { | 1496 CSSPropertyID properties[] = { |
| 1497 CSSPropertyFontSize, | 1497 CSSPropertyFontSize, |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1558 visitor->trace(m_uncommonAttributeRuleSet); | 1558 visitor->trace(m_uncommonAttributeRuleSet); |
| 1559 visitor->trace(m_watchedSelectorsRules); | 1559 visitor->trace(m_watchedSelectorsRules); |
| 1560 visitor->trace(m_treeBoundaryCrossingScopes); | 1560 visitor->trace(m_treeBoundaryCrossingScopes); |
| 1561 visitor->trace(m_styleSharingLists); | 1561 visitor->trace(m_styleSharingLists); |
| 1562 visitor->trace(m_pendingStyleSheets); | 1562 visitor->trace(m_pendingStyleSheets); |
| 1563 visitor->trace(m_document); | 1563 visitor->trace(m_document); |
| 1564 #endif | 1564 #endif |
| 1565 } | 1565 } |
| 1566 | 1566 |
| 1567 } // namespace blink | 1567 } // namespace blink |
| OLD | NEW |