| 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 356 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 367 // Note that we may get invoked for some random elements in some wacky cases
during style resolve. | 367 // Note that we may get invoked for some random elements in some wacky cases
during style resolve. |
| 368 // Pause maintaining the stack in this case. | 368 // Pause maintaining the stack in this case. |
| 369 if (m_selectorFilter.parentStackIsConsistent(&parent)) | 369 if (m_selectorFilter.parentStackIsConsistent(&parent)) |
| 370 m_selectorFilter.popParent(); | 370 m_selectorFilter.popParent(); |
| 371 } | 371 } |
| 372 | 372 |
| 373 StyleResolver::~StyleResolver() | 373 StyleResolver::~StyleResolver() |
| 374 { | 374 { |
| 375 } | 375 } |
| 376 | 376 |
| 377 void StyleResolver::matchAuthorRulesForShadowHost(Element* element, ElementRuleC
ollector& collector, bool includeEmptyRules, WillBeHeapVector<RawPtrWillBeMember
<ScopedStyleResolver>, 8>& resolvers, WillBeHeapVector<RawPtrWillBeMember<Scoped
StyleResolver>, 8>& resolversInShadowTree) | |
| 378 { | |
| 379 collector.clearMatchedRules(); | |
| 380 collector.matchedResult().ranges.lastAuthorRule = collector.matchedResult().
matchedProperties.size() - 1; | |
| 381 | |
| 382 CascadeScope cascadeScope = 0; | |
| 383 CascadeOrder cascadeOrder = 0; | |
| 384 | |
| 385 for (int j = resolversInShadowTree.size() - 1; j >= 0; --j) | |
| 386 resolversInShadowTree.at(j)->collectMatchingAuthorRules(collector, inclu
deEmptyRules, cascadeScope, cascadeOrder++); | |
| 387 | |
| 388 if (resolvers.isEmpty() || resolvers.first()->treeScope() != element->treeSc
ope()) | |
| 389 ++cascadeScope; | |
| 390 cascadeOrder += resolvers.size(); | |
| 391 for (unsigned i = 0; i < resolvers.size(); ++i) | |
| 392 resolvers.at(i)->collectMatchingAuthorRules(collector, includeEmptyRules
, cascadeScope++, --cascadeOrder); | |
| 393 | |
| 394 m_treeBoundaryCrossingRules.collectTreeBoundaryCrossingRules(element, collec
tor, includeEmptyRules); | |
| 395 collector.sortAndTransferMatchedRules(); | |
| 396 } | |
| 397 | |
| 398 void StyleResolver::matchAuthorRules(Element* element, ElementRuleCollector& col
lector, bool includeEmptyRules) | 377 void StyleResolver::matchAuthorRules(Element* element, ElementRuleCollector& col
lector, bool includeEmptyRules) |
| 399 { | 378 { |
| 400 collector.clearMatchedRules(); | 379 collector.clearMatchedRules(); |
| 401 collector.matchedResult().ranges.lastAuthorRule = collector.matchedResult().
matchedProperties.size() - 1; | 380 collector.matchedResult().ranges.lastAuthorRule = collector.matchedResult().
matchedProperties.size() - 1; |
| 402 | 381 |
| 403 if (document().styleEngine()->hasOnlyScopedResolverForDocument()) { | 382 CascadeOrder cascadeOrder = 0; |
| 404 document().scopedStyleResolver()->collectMatchingAuthorRules(collector,
includeEmptyRules, ignoreCascadeScope); | |
| 405 m_treeBoundaryCrossingRules.collectTreeBoundaryCrossingRules(element, co
llector, includeEmptyRules); | |
| 406 collector.sortAndTransferMatchedRules(); | |
| 407 return; | |
| 408 } | |
| 409 | 383 |
| 410 WillBeHeapVector<RawPtrWillBeMember<ScopedStyleResolver>, 8> resolvers; | 384 // FIXME: We should track host rules separately right now the SelectorChecke
r |
| 411 resolveScopedStyles(element, resolvers); | 385 // is doing lots of checking to compensate for entering with rules that |
| 386 // shouldn't match in the :host/:host-context step below. |
| 412 | 387 |
| 388 // Match :host and :host-context rules. |
| 413 WillBeHeapVector<RawPtrWillBeMember<ScopedStyleResolver>, 8> resolversInShad
owTree; | 389 WillBeHeapVector<RawPtrWillBeMember<ScopedStyleResolver>, 8> resolversInShad
owTree; |
| 414 collectScopedResolversForHostedShadowTrees(element, resolversInShadowTree); | 390 collectScopedResolversForHostedShadowTrees(element, resolversInShadowTree); |
| 415 if (!resolversInShadowTree.isEmpty()) { | 391 for (int j = resolversInShadowTree.size() - 1; j >= 0; --j) |
| 416 matchAuthorRulesForShadowHost(element, collector, includeEmptyRules, res
olvers, resolversInShadowTree); | 392 resolversInShadowTree[j]->collectMatchingAuthorRules(collector, includeE
mptyRules, ignoreCascadeScope, ++cascadeOrder); |
| 417 return; | |
| 418 } | |
| 419 | 393 |
| 420 if (resolvers.isEmpty()) | 394 // Match rules in your own scope (ShadowRoot or Document). |
| 421 return; | 395 if (ScopedStyleResolver* resolver = element->treeScope().scopedStyleResolver
()) |
| 396 resolver->collectMatchingAuthorRules(collector, includeEmptyRules, ignor
eCascadeScope, ++cascadeOrder); |
| 422 | 397 |
| 423 CascadeScope cascadeScope = 0; | 398 // Match /deep/, ::shadow and ::content rules. |
| 424 CascadeOrder cascadeOrder = resolvers.size(); | 399 m_treeBoundaryCrossingRules.collectTreeBoundaryCrossingRules(element, collec
tor, includeEmptyRules); |
| 425 for (unsigned i = 0; i < resolvers.size(); ++i, --cascadeOrder) { | |
| 426 ScopedStyleResolver* resolver = resolvers.at(i); | |
| 427 // FIXME: Need to clarify how to treat style scoped. | |
| 428 resolver->collectMatchingAuthorRules(collector, includeEmptyRules, casca
deScope++, resolver->treeScope() == element->treeScope() && resolver->treeScope(
).rootNode().isShadowRoot() ? 0 : cascadeOrder); | |
| 429 } | |
| 430 | 400 |
| 431 m_treeBoundaryCrossingRules.collectTreeBoundaryCrossingRules(element, collec
tor, includeEmptyRules); | |
| 432 collector.sortAndTransferMatchedRules(); | 401 collector.sortAndTransferMatchedRules(); |
| 433 } | 402 } |
| 434 | 403 |
| 435 void StyleResolver::matchUARules(ElementRuleCollector& collector) | 404 void StyleResolver::matchUARules(ElementRuleCollector& collector) |
| 436 { | 405 { |
| 437 collector.setMatchingUARules(true); | 406 collector.setMatchingUARules(true); |
| 438 | 407 |
| 439 CSSDefaultStyleSheets& defaultStyleSheets = CSSDefaultStyleSheets::instance(
); | 408 CSSDefaultStyleSheets& defaultStyleSheets = CSSDefaultStyleSheets::instance(
); |
| 440 RuleSet* userAgentStyleSheet = m_printMediaType ? defaultStyleSheets.default
PrintStyle() : defaultStyleSheets.defaultStyle(); | 409 RuleSet* userAgentStyleSheet = m_printMediaType ? defaultStyleSheets.default
PrintStyle() : defaultStyleSheets.defaultStyle(); |
| 441 matchUARules(collector, userAgentStyleSheet); | 410 matchUARules(collector, userAgentStyleSheet); |
| (...skipping 550 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 992 applyAnimatedProperties<LowPriorityProperties>(state, activeInterpolationsFo
rTransitions); | 961 applyAnimatedProperties<LowPriorityProperties>(state, activeInterpolationsFo
rTransitions); |
| 993 | 962 |
| 994 // Start loading resources used by animations. | 963 // Start loading resources used by animations. |
| 995 loadPendingResources(state); | 964 loadPendingResources(state); |
| 996 | 965 |
| 997 ASSERT(!state.fontBuilder().fontDirty()); | 966 ASSERT(!state.fontBuilder().fontDirty()); |
| 998 | 967 |
| 999 return true; | 968 return true; |
| 1000 } | 969 } |
| 1001 | 970 |
| 1002 static inline ScopedStyleResolver* scopedResolverFor(const Element* element) | |
| 1003 { | |
| 1004 for (TreeScope* treeScope = &element->treeScope(); treeScope; treeScope = tr
eeScope->parentTreeScope()) { | |
| 1005 if (ScopedStyleResolver* scopedStyleResolver = treeScope->scopedStyleRes
olver()) | |
| 1006 return scopedStyleResolver; | |
| 1007 } | |
| 1008 return 0; | |
| 1009 } | |
| 1010 | |
| 1011 void StyleResolver::resolveScopedStyles(const Element* element, WillBeHeapVector
<RawPtrWillBeMember<ScopedStyleResolver>, 8>& resolvers) | |
| 1012 { | |
| 1013 for (ScopedStyleResolver* scopedResolver = scopedResolverFor(element); scope
dResolver; scopedResolver = scopedResolver->parent()) | |
| 1014 resolvers.append(scopedResolver); | |
| 1015 } | |
| 1016 | |
| 1017 void StyleResolver::collectScopedResolversForHostedShadowTrees(const Element* el
ement, WillBeHeapVector<RawPtrWillBeMember<ScopedStyleResolver>, 8>& resolvers) | 971 void StyleResolver::collectScopedResolversForHostedShadowTrees(const Element* el
ement, WillBeHeapVector<RawPtrWillBeMember<ScopedStyleResolver>, 8>& resolvers) |
| 1018 { | 972 { |
| 1019 ElementShadow* shadow = element->shadow(); | 973 ElementShadow* shadow = element->shadow(); |
| 1020 if (!shadow) | 974 if (!shadow) |
| 1021 return; | 975 return; |
| 1022 | 976 |
| 1023 // Adding scoped resolver for active shadow roots for shadow host styling. | 977 // Adding scoped resolver for active shadow roots for shadow host styling. |
| 1024 for (ShadowRoot* shadowRoot = shadow->youngestShadowRoot(); shadowRoot; shad
owRoot = shadowRoot->olderShadowRoot()) { | 978 for (ShadowRoot* shadowRoot = shadow->youngestShadowRoot(); shadowRoot; shad
owRoot = shadowRoot->olderShadowRoot()) { |
| 1025 if (shadowRoot->numberOfStyles() > 0) { | 979 if (shadowRoot->numberOfStyles() > 0) { |
| 1026 if (ScopedStyleResolver* resolver = shadowRoot->scopedStyleResolver(
)) | 980 if (ScopedStyleResolver* resolver = shadowRoot->scopedStyleResolver(
)) |
| 1027 resolvers.append(resolver); | 981 resolvers.append(resolver); |
| 1028 } | 982 } |
| 1029 } | 983 } |
| 1030 } | 984 } |
| 1031 | 985 |
| 1032 void StyleResolver::styleTreeResolveScopedKeyframesRules(const Element* element,
WillBeHeapVector<RawPtrWillBeMember<ScopedStyleResolver>, 8>& resolvers) | 986 void StyleResolver::styleTreeResolveScopedKeyframesRules(const Element* element,
WillBeHeapVector<RawPtrWillBeMember<ScopedStyleResolver>, 8>& resolvers) |
| 1033 { | 987 { |
| 1034 TreeScope& treeScope = element->treeScope(); | |
| 1035 | |
| 1036 // Add resolvers for shadow roots hosted by the given element. | |
| 1037 collectScopedResolversForHostedShadowTrees(element, resolvers); | 988 collectScopedResolversForHostedShadowTrees(element, resolvers); |
| 1038 | 989 |
| 1039 // Add resolvers while walking up DOM tree from the given element. | 990 if (ScopedStyleResolver* scopedResolver = element->treeScope().scopedStyleRe
solver()) |
| 1040 for (ScopedStyleResolver* scopedResolver = scopedResolverFor(element); scope
dResolver; scopedResolver = scopedResolver->parent()) { | 991 resolvers.append(scopedResolver); |
| 1041 if (scopedResolver->treeScope() == treeScope) | |
| 1042 resolvers.append(scopedResolver); | |
| 1043 } | |
| 1044 } | 992 } |
| 1045 | 993 |
| 1046 template <StyleResolver::StyleApplicationPass pass> | 994 template <StyleResolver::StyleApplicationPass pass> |
| 1047 void StyleResolver::applyAnimatedProperties(StyleResolverState& state, const Wil
lBeHeapHashMap<CSSPropertyID, RefPtrWillBeMember<Interpolation> >& activeInterpo
lations) | 995 void StyleResolver::applyAnimatedProperties(StyleResolverState& state, const Wil
lBeHeapHashMap<CSSPropertyID, RefPtrWillBeMember<Interpolation> >& activeInterpo
lations) |
| 1048 { | 996 { |
| 1049 for (WillBeHeapHashMap<CSSPropertyID, RefPtrWillBeMember<Interpolation> >::c
onst_iterator iter = activeInterpolations.begin(); iter != activeInterpolations.
end(); ++iter) { | 997 for (WillBeHeapHashMap<CSSPropertyID, RefPtrWillBeMember<Interpolation> >::c
onst_iterator iter = activeInterpolations.begin(); iter != activeInterpolations.
end(); ++iter) { |
| 1050 CSSPropertyID property = iter->key; | 998 CSSPropertyID property = iter->key; |
| 1051 if (!isPropertyForPass<pass>(property)) | 999 if (!isPropertyForPass<pass>(property)) |
| 1052 continue; | 1000 continue; |
| 1053 const StyleInterpolation* interpolation = toStyleInterpolation(iter->val
ue.get()); | 1001 const StyleInterpolation* interpolation = toStyleInterpolation(iter->val
ue.get()); |
| (...skipping 529 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1583 visitor->trace(m_uncommonAttributeRuleSet); | 1531 visitor->trace(m_uncommonAttributeRuleSet); |
| 1584 visitor->trace(m_watchedSelectorsRules); | 1532 visitor->trace(m_watchedSelectorsRules); |
| 1585 visitor->trace(m_treeBoundaryCrossingRules); | 1533 visitor->trace(m_treeBoundaryCrossingRules); |
| 1586 visitor->trace(m_styleSharingLists); | 1534 visitor->trace(m_styleSharingLists); |
| 1587 visitor->trace(m_pendingStyleSheets); | 1535 visitor->trace(m_pendingStyleSheets); |
| 1588 visitor->trace(m_document); | 1536 visitor->trace(m_document); |
| 1589 #endif | 1537 #endif |
| 1590 } | 1538 } |
| 1591 | 1539 |
| 1592 } // namespace blink | 1540 } // namespace blink |
| OLD | NEW |