| 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 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 97 return namespaceURI == starAtom || namespaceURI == element.namespaceURI(); | 97 return namespaceURI == starAtom || namespaceURI == element.namespaceURI(); |
| 98 } | 98 } |
| 99 | 99 |
| 100 static Element* parentElement(const SelectorChecker::SelectorCheckingContext& co
ntext) | 100 static Element* parentElement(const SelectorChecker::SelectorCheckingContext& co
ntext) |
| 101 { | 101 { |
| 102 // - If context.scope is a shadow root, we should walk up to its shadow host
. | 102 // - If context.scope is a shadow root, we should walk up to its shadow host
. |
| 103 // - If context.scope is some element in some shadow tree and querySelector
initialized the context, | 103 // - If context.scope is some element in some shadow tree and querySelector
initialized the context, |
| 104 // e.g. shadowRoot.querySelector(':host *'), | 104 // e.g. shadowRoot.querySelector(':host *'), |
| 105 // (a) context.element has the same treescope as context.scope, need to wa
lk up to its shadow host. | 105 // (a) context.element has the same treescope as context.scope, need to wa
lk up to its shadow host. |
| 106 // (b) Otherwise, should not walk up from a shadow root to a shadow host. | 106 // (b) Otherwise, should not walk up from a shadow root to a shadow host. |
| 107 if (context.scope && (context.scope == context.element->containingShadowRoot
() || context.scope->treeScope() == context.element->treeScope())) | 107 if (context.scope && (context.scope == context.element->containingShadowRoot
() || context.scope->treeScopeOrDocument() == context.element->treeScopeOrDocume
nt())) |
| 108 return context.element->parentOrShadowHostElement(); | 108 return context.element->parentOrShadowHostElement(); |
| 109 return context.element->parentElement(); | 109 return context.element->parentElement(); |
| 110 } | 110 } |
| 111 | 111 |
| 112 static const HTMLSlotElement* findSlotElementInScope(const SelectorChecker::Sele
ctorCheckingContext& context) | 112 static const HTMLSlotElement* findSlotElementInScope(const SelectorChecker::Sele
ctorCheckingContext& context) |
| 113 { | 113 { |
| 114 if (!context.scope) | 114 if (!context.scope) |
| 115 return nullptr; | 115 return nullptr; |
| 116 | 116 |
| 117 const HTMLSlotElement* slot = context.element->assignedSlot(); | 117 const HTMLSlotElement* slot = context.element->assignedSlot(); |
| 118 while (slot) { | 118 while (slot) { |
| 119 if (slot->treeScope() == context.scope->treeScope()) | 119 if (slot->treeScopeOrDocument() == context.scope->treeScopeOrDocument()) |
| 120 return slot; | 120 return slot; |
| 121 slot = slot->assignedSlot(); | 121 slot = slot->assignedSlot(); |
| 122 } | 122 } |
| 123 return nullptr; | 123 return nullptr; |
| 124 } | 124 } |
| 125 | 125 |
| 126 static bool scopeContainsLastMatchedElement(const SelectorChecker::SelectorCheck
ingContext& context) | 126 static bool scopeContainsLastMatchedElement(const SelectorChecker::SelectorCheck
ingContext& context) |
| 127 { | 127 { |
| 128 // If this context isn't scoped, skip checking. | 128 // If this context isn't scoped, skip checking. |
| 129 if (!context.scope) | 129 if (!context.scope) |
| 130 return true; | 130 return true; |
| 131 | 131 |
| 132 if (context.scope->treeScope() == context.element->treeScope()) | 132 if (context.scope->treeScopeOrDocument() == context.element->treeScopeOrDocu
ment()) |
| 133 return true; | 133 return true; |
| 134 | 134 |
| 135 // Because Blink treats a shadow host's TreeScope as a separate one from its
descendent shadow roots, | 135 // Because Blink treats a shadow host's TreeScope as a separate one from its
descendent shadow roots, |
| 136 // if the last matched element is a shadow host, the condition above isn't m
et, even though it | 136 // if the last matched element is a shadow host, the condition above isn't m
et, even though it |
| 137 // should be. | 137 // should be. |
| 138 return context.element == context.scope->shadowHost() && (!context.previousE
lement || context.previousElement->isInDescendantTreeOf(context.element)); | 138 return context.element == context.scope->shadowHost() && (!context.previousE
lement || context.previousElement->isInDescendantTreeOf(context.element)); |
| 139 } | 139 } |
| 140 | 140 |
| 141 static inline bool nextSelectorExceedsScope(const SelectorChecker::SelectorCheck
ingContext& context) | 141 static inline bool nextSelectorExceedsScope(const SelectorChecker::SelectorCheck
ingContext& context) |
| 142 { | 142 { |
| (...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 341 if (match == SelectorMatches || match == SelectorFailsAllSiblings ||
match == SelectorFailsCompletely) | 341 if (match == SelectorMatches || match == SelectorFailsAllSiblings ||
match == SelectorFailsCompletely) |
| 342 return match; | 342 return match; |
| 343 } | 343 } |
| 344 return SelectorFailsAllSiblings; | 344 return SelectorFailsAllSiblings; |
| 345 | 345 |
| 346 case CSSSelector::ShadowPseudo: | 346 case CSSSelector::ShadowPseudo: |
| 347 { | 347 { |
| 348 if (!m_isUARule && !m_isQuerySelector && context.selector->getPseudo
Type() == CSSSelector::PseudoShadow) | 348 if (!m_isUARule && !m_isQuerySelector && context.selector->getPseudo
Type() == CSSSelector::PseudoShadow) |
| 349 Deprecation::countDeprecation(context.element->document(), UseCo
unter::CSSSelectorPseudoShadow); | 349 Deprecation::countDeprecation(context.element->document(), UseCo
unter::CSSSelectorPseudoShadow); |
| 350 // If we're in the same tree-scope as the scoping element, then foll
owing a shadow descendant combinator would escape that and thus the scope. | 350 // If we're in the same tree-scope as the scoping element, then foll
owing a shadow descendant combinator would escape that and thus the scope. |
| 351 if (context.scope && context.scope->shadowHost() && context.scope->s
hadowHost()->treeScope() == context.element->treeScope()) | 351 if (context.scope && context.scope->shadowHost() && context.scope->s
hadowHost()->treeScopeOrDocument() == context.element->treeScopeOrDocument()) |
| 352 return SelectorFailsCompletely; | 352 return SelectorFailsCompletely; |
| 353 | 353 |
| 354 Element* shadowHost = context.element->shadowHost(); | 354 Element* shadowHost = context.element->shadowHost(); |
| 355 if (!shadowHost) | 355 if (!shadowHost) |
| 356 return SelectorFailsCompletely; | 356 return SelectorFailsCompletely; |
| 357 nextContext.element = shadowHost; | 357 nextContext.element = shadowHost; |
| 358 return matchSelector(nextContext, result); | 358 return matchSelector(nextContext, result); |
| 359 } | 359 } |
| 360 | 360 |
| 361 case CSSSelector::ShadowDeep: | 361 case CSSSelector::ShadowDeep: |
| (...skipping 781 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1143 } | 1143 } |
| 1144 | 1144 |
| 1145 bool SelectorChecker::matchesFocusPseudoClass(const Element& element) | 1145 bool SelectorChecker::matchesFocusPseudoClass(const Element& element) |
| 1146 { | 1146 { |
| 1147 if (InspectorInstrumentation::forcePseudoState(const_cast<Element*>(&element
), CSSSelector::PseudoFocus)) | 1147 if (InspectorInstrumentation::forcePseudoState(const_cast<Element*>(&element
), CSSSelector::PseudoFocus)) |
| 1148 return true; | 1148 return true; |
| 1149 return element.focused() && isFrameFocused(element); | 1149 return element.focused() && isFrameFocused(element); |
| 1150 } | 1150 } |
| 1151 | 1151 |
| 1152 } // namespace blink | 1152 } // namespace blink |
| OLD | NEW |