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 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
74 #include "core/dom/FirstLetterPseudoElement.h" | 74 #include "core/dom/FirstLetterPseudoElement.h" |
75 #include "core/dom/NodeComputedStyle.h" | 75 #include "core/dom/NodeComputedStyle.h" |
76 #include "core/dom/StyleEngine.h" | 76 #include "core/dom/StyleEngine.h" |
77 #include "core/dom/Text.h" | 77 #include "core/dom/Text.h" |
78 #include "core/dom/shadow/ElementShadow.h" | 78 #include "core/dom/shadow/ElementShadow.h" |
79 #include "core/dom/shadow/ShadowRoot.h" | 79 #include "core/dom/shadow/ShadowRoot.h" |
80 #include "core/frame/FrameView.h" | 80 #include "core/frame/FrameView.h" |
81 #include "core/frame/LocalFrame.h" | 81 #include "core/frame/LocalFrame.h" |
82 #include "core/frame/Settings.h" | 82 #include "core/frame/Settings.h" |
83 #include "core/html/HTMLIFrameElement.h" | 83 #include "core/html/HTMLIFrameElement.h" |
| 84 #include "core/html/HTMLSlotElement.h" |
84 #include "core/inspector/InspectorInstrumentation.h" | 85 #include "core/inspector/InspectorInstrumentation.h" |
85 #include "core/layout/GeneratedChildren.h" | 86 #include "core/layout/GeneratedChildren.h" |
86 #include "core/layout/LayoutView.h" | 87 #include "core/layout/LayoutView.h" |
87 #include "core/style/StyleVariableData.h" | 88 #include "core/style/StyleVariableData.h" |
88 #include "core/svg/SVGDocumentExtensions.h" | 89 #include "core/svg/SVGDocumentExtensions.h" |
89 #include "core/svg/SVGElement.h" | 90 #include "core/svg/SVGElement.h" |
90 #include "platform/RuntimeEnabledFeatures.h" | 91 #include "platform/RuntimeEnabledFeatures.h" |
91 #include "wtf/StdLibExtras.h" | 92 #include "wtf/StdLibExtras.h" |
92 | 93 |
93 namespace { | 94 namespace { |
(...skipping 330 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
424 continue; | 425 continue; |
425 if (ScopedStyleResolver* resolver = shadowRoot->scopedStyleResolver()) { | 426 if (ScopedStyleResolver* resolver = shadowRoot->scopedStyleResolver()) { |
426 collector.clearMatchedRules(); | 427 collector.clearMatchedRules(); |
427 resolver->collectMatchingShadowHostRules(collector); | 428 resolver->collectMatchingShadowHostRules(collector); |
428 collector.sortAndTransferMatchedRules(); | 429 collector.sortAndTransferMatchedRules(); |
429 collector.finishAddingAuthorRulesForTreeScope(); | 430 collector.finishAddingAuthorRulesForTreeScope(); |
430 } | 431 } |
431 } | 432 } |
432 } | 433 } |
433 | 434 |
| 435 static void matchSlottedRules(const Element& element, ElementRuleCollector& coll
ector) |
| 436 { |
| 437 HTMLSlotElement* slot = element.assignedSlot(); |
| 438 if (!slot) |
| 439 return; |
| 440 |
| 441 HeapVector<Member<ScopedStyleResolver>> resolvers; |
| 442 for (; slot; slot = slot->assignedSlot()) { |
| 443 if (ScopedStyleResolver* resolver = slot->treeScope().scopedStyleResolve
r()) |
| 444 resolvers.append(resolver); |
| 445 } |
| 446 for (auto it = resolvers.rbegin(); it != resolvers.rend(); ++it) { |
| 447 collector.clearMatchedRules(); |
| 448 (*it)->collectMatchingTreeBoundaryCrossingRules(collector); |
| 449 collector.sortAndTransferMatchedRules(); |
| 450 collector.finishAddingAuthorRulesForTreeScope(); |
| 451 } |
| 452 } |
| 453 |
434 static void matchElementScopeRules(const Element& element, ScopedStyleResolver*
elementScopeResolver, ElementRuleCollector& collector) | 454 static void matchElementScopeRules(const Element& element, ScopedStyleResolver*
elementScopeResolver, ElementRuleCollector& collector) |
435 { | 455 { |
436 if (elementScopeResolver) { | 456 if (elementScopeResolver) { |
437 collector.clearMatchedRules(); | 457 collector.clearMatchedRules(); |
438 elementScopeResolver->collectMatchingAuthorRules(collector); | 458 elementScopeResolver->collectMatchingAuthorRules(collector); |
439 elementScopeResolver->collectMatchingTreeBoundaryCrossingRules(collector
); | 459 elementScopeResolver->collectMatchingTreeBoundaryCrossingRules(collector
); |
440 collector.sortAndTransferMatchedRules(); | 460 collector.sortAndTransferMatchedRules(); |
441 } | 461 } |
442 | 462 |
443 if (element.isStyledElement() && element.inlineStyle() && !collector.isColle
ctingForPseudoElement()) { | 463 if (element.isStyledElement() && element.inlineStyle() && !collector.isColle
ctingForPseudoElement()) { |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
475 | 495 |
476 void StyleResolver::matchScopedRules(const Element& element, ElementRuleCollecto
r& collector) | 496 void StyleResolver::matchScopedRules(const Element& element, ElementRuleCollecto
r& collector) |
477 { | 497 { |
478 // Match rules from treeScopes in the reverse tree-of-trees order, since the | 498 // Match rules from treeScopes in the reverse tree-of-trees order, since the |
479 // cascading order for normal rules is such that when comparing rules from | 499 // cascading order for normal rules is such that when comparing rules from |
480 // different shadow trees, the rule from the tree which comes first in the | 500 // different shadow trees, the rule from the tree which comes first in the |
481 // tree-of-trees order wins. From other treeScopes than the element's own | 501 // tree-of-trees order wins. From other treeScopes than the element's own |
482 // scope, only tree-boundary-crossing rules may match. | 502 // scope, only tree-boundary-crossing rules may match. |
483 | 503 |
484 ScopedStyleResolver* elementScopeResolver = scopedResolverFor(element); | 504 ScopedStyleResolver* elementScopeResolver = scopedResolverFor(element); |
| 505 |
| 506 if (!document().styleEngine().mayContainV0Shadow()) { |
| 507 matchSlottedRules(element, collector); |
| 508 matchElementScopeRules(element, elementScopeResolver, collector); |
| 509 return; |
| 510 } |
| 511 |
485 bool matchElementScopeDone = !elementScopeResolver && !element.inlineStyle()
; | 512 bool matchElementScopeDone = !elementScopeResolver && !element.inlineStyle()
; |
486 | 513 |
487 // TODO(kochi): This loops through m_treeBoundaryCrossingScopes because to h
andle | |
488 // Shadow DOM V0 documents as well. In pure V1 document only have to go thro
ugh | |
489 // the chain of scopes for assigned slots. Add fast path for pure V1 documen
t. | |
490 for (auto it = m_treeBoundaryCrossingScopes.rbegin(); it != m_treeBoundaryCr
ossingScopes.rend(); ++it) { | 514 for (auto it = m_treeBoundaryCrossingScopes.rbegin(); it != m_treeBoundaryCr
ossingScopes.rend(); ++it) { |
491 const TreeScope& scope = (*it)->treeScope(); | 515 const TreeScope& scope = (*it)->treeScope(); |
492 ScopedStyleResolver* resolver = scope.scopedStyleResolver(); | 516 ScopedStyleResolver* resolver = scope.scopedStyleResolver(); |
493 ASSERT(resolver); | 517 ASSERT(resolver); |
494 | 518 |
495 bool isInnerTreeScope = element.treeScope().isInclusiveAncestorOf(scope)
; | 519 bool isInnerTreeScope = element.treeScope().isInclusiveAncestorOf(scope)
; |
496 if (!shouldCheckScope(element, **it, isInnerTreeScope)) | 520 if (!shouldCheckScope(element, **it, isInnerTreeScope)) |
497 continue; | 521 continue; |
498 | 522 |
499 if (!matchElementScopeDone && scope.isInclusiveAncestorOf(element.treeSc
ope())) { | 523 if (!matchElementScopeDone && scope.isInclusiveAncestorOf(element.treeSc
ope())) { |
(...skipping 1212 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1712 visitor->trace(m_uncommonAttributeRuleSet); | 1736 visitor->trace(m_uncommonAttributeRuleSet); |
1713 visitor->trace(m_watchedSelectorsRules); | 1737 visitor->trace(m_watchedSelectorsRules); |
1714 visitor->trace(m_treeBoundaryCrossingScopes); | 1738 visitor->trace(m_treeBoundaryCrossingScopes); |
1715 visitor->trace(m_styleSharingLists); | 1739 visitor->trace(m_styleSharingLists); |
1716 visitor->trace(m_pendingStyleSheets); | 1740 visitor->trace(m_pendingStyleSheets); |
1717 visitor->trace(m_document); | 1741 visitor->trace(m_document); |
1718 #endif | 1742 #endif |
1719 } | 1743 } |
1720 | 1744 |
1721 } // namespace blink | 1745 } // namespace blink |
OLD | NEW |