| 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 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 129 // If this context isn't scoped, skip checking. | 129 // If this context isn't scoped, skip checking. |
| 130 if (!context.scope) | 130 if (!context.scope) |
| 131 return true; | 131 return true; |
| 132 | 132 |
| 133 if (context.scope->treeScope() == context.element->treeScope()) | 133 if (context.scope->treeScope() == context.element->treeScope()) |
| 134 return true; | 134 return true; |
| 135 | 135 |
| 136 // Because Blink treats a shadow host's TreeScope as a separate one from its
descendent shadow roots, | 136 // Because Blink treats a shadow host's TreeScope as a separate one from its
descendent shadow roots, |
| 137 // if the last matched element is a shadow host, the condition above isn't m
et, even though it | 137 // if the last matched element is a shadow host, the condition above isn't m
et, even though it |
| 138 // should be. | 138 // should be. |
| 139 return context.element == context.scope->shadowHost() && (!context.previousE
lement || context.previousElement->isInDescendantTreeOf(context.element)); | 139 return context.element == context.scope->ownerShadowHost() && (!context.prev
iousElement || context.previousElement->isInDescendantTreeOf(context.element)); |
| 140 } | 140 } |
| 141 | 141 |
| 142 static inline bool nextSelectorExceedsScope(const SelectorChecker::SelectorCheck
ingContext& context) | 142 static inline bool nextSelectorExceedsScope(const SelectorChecker::SelectorCheck
ingContext& context) |
| 143 { | 143 { |
| 144 if (context.scope && context.scope->isInShadowTree()) | 144 if (context.scope && context.scope->isInShadowTree()) |
| 145 return context.element == context.scope->shadowHost(); | 145 return context.element == context.scope->ownerShadowHost(); |
| 146 | 146 |
| 147 return false; | 147 return false; |
| 148 } | 148 } |
| 149 | 149 |
| 150 static bool shouldMatchHoverOrActive(const SelectorChecker::SelectorCheckingCont
ext& context) | 150 static bool shouldMatchHoverOrActive(const SelectorChecker::SelectorCheckingCont
ext& context) |
| 151 { | 151 { |
| 152 // If we're in quirks mode, then :hover and :active should never match ancho
rs with no | 152 // If we're in quirks mode, then :hover and :active should never match ancho
rs with no |
| 153 // href and *:hover and *:active should not match anything. This is specifie
d in | 153 // href and *:hover and *:active should not match anything. This is specifie
d in |
| 154 // https://quirks.spec.whatwg.org/#the-:active-and-:hover-quirk | 154 // https://quirks.spec.whatwg.org/#the-:active-and-:hover-quirk |
| 155 if (!context.element->document().inQuirksMode()) | 155 if (!context.element->document().inQuirksMode()) |
| (...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 350 if (match == SelectorMatches || match == SelectorFailsAllSiblings ||
match == SelectorFailsCompletely) | 350 if (match == SelectorMatches || match == SelectorFailsAllSiblings ||
match == SelectorFailsCompletely) |
| 351 return match; | 351 return match; |
| 352 } | 352 } |
| 353 return SelectorFailsAllSiblings; | 353 return SelectorFailsAllSiblings; |
| 354 | 354 |
| 355 case CSSSelector::ShadowPseudo: | 355 case CSSSelector::ShadowPseudo: |
| 356 { | 356 { |
| 357 if (!m_isUARule && !m_isQuerySelector && context.selector->getPseudo
Type() == CSSSelector::PseudoShadow) | 357 if (!m_isUARule && !m_isQuerySelector && context.selector->getPseudo
Type() == CSSSelector::PseudoShadow) |
| 358 Deprecation::countDeprecation(context.element->document(), UseCo
unter::CSSSelectorPseudoShadow); | 358 Deprecation::countDeprecation(context.element->document(), UseCo
unter::CSSSelectorPseudoShadow); |
| 359 // 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. | 359 // 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. |
| 360 if (context.scope && context.scope->shadowHost() && context.scope->s
hadowHost()->treeScope() == context.element->treeScope()) | 360 if (context.scope && context.scope->ownerShadowHost() && context.sco
pe->ownerShadowHost()->treeScope() == context.element->treeScope()) |
| 361 return SelectorFailsCompletely; | 361 return SelectorFailsCompletely; |
| 362 | 362 |
| 363 Element* shadowHost = context.element->shadowHost(); | 363 Element* shadowHost = context.element->ownerShadowHost(); |
| 364 if (!shadowHost) | 364 if (!shadowHost) |
| 365 return SelectorFailsCompletely; | 365 return SelectorFailsCompletely; |
| 366 nextContext.element = shadowHost; | 366 nextContext.element = shadowHost; |
| 367 return matchSelector(nextContext, result); | 367 return matchSelector(nextContext, result); |
| 368 } | 368 } |
| 369 | 369 |
| 370 case CSSSelector::ShadowDeep: | 370 case CSSSelector::ShadowDeep: |
| 371 { | 371 { |
| 372 if (!m_isUARule && !m_isQuerySelector) | 372 if (!m_isUARule && !m_isQuerySelector) |
| 373 Deprecation::countDeprecation(context.element->document(), UseCo
unter::CSSDeepCombinator); | 373 Deprecation::countDeprecation(context.element->document(), UseCo
unter::CSSDeepCombinator); |
| (...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 578 } | 578 } |
| 579 | 579 |
| 580 bool SelectorChecker::checkOne(const SelectorCheckingContext& context, MatchResu
lt& result) const | 580 bool SelectorChecker::checkOne(const SelectorCheckingContext& context, MatchResu
lt& result) const |
| 581 { | 581 { |
| 582 ASSERT(context.element); | 582 ASSERT(context.element); |
| 583 Element& element = *context.element; | 583 Element& element = *context.element; |
| 584 ASSERT(context.selector); | 584 ASSERT(context.selector); |
| 585 const CSSSelector& selector = *context.selector; | 585 const CSSSelector& selector = *context.selector; |
| 586 | 586 |
| 587 // Only :host and :host-context() should match the host: http://drafts.csswg
.org/css-scoping/#host-element | 587 // Only :host and :host-context() should match the host: http://drafts.csswg
.org/css-scoping/#host-element |
| 588 if (context.scope && context.scope->shadowHost() == element && (!selector.is
HostPseudoClass() | 588 if (context.scope && context.scope->ownerShadowHost() == element && (!select
or.isHostPseudoClass() |
| 589 && !context.treatShadowHostAsNormalScope | 589 && !context.treatShadowHostAsNormalScope |
| 590 && selector.match() != CSSSelector::PseudoElement)) | 590 && selector.match() != CSSSelector::PseudoElement)) |
| 591 return false; | 591 return false; |
| 592 | 592 |
| 593 switch (selector.match()) { | 593 switch (selector.match()) { |
| 594 case CSSSelector::Tag: | 594 case CSSSelector::Tag: |
| 595 return matchesTagName(element, selector.tagQName()); | 595 return matchesTagName(element, selector.tagQName()); |
| 596 case CSSSelector::Class: | 596 case CSSSelector::Class: |
| 597 return element.hasClass() && element.classNames().contains(selector.valu
e()); | 597 return element.hasClass() && element.classNames().contains(selector.valu
e()); |
| 598 case CSSSelector::Id: | 598 case CSSSelector::Id: |
| (...skipping 459 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1058 bool SelectorChecker::checkPseudoHost(const SelectorCheckingContext& context, Ma
tchResult& result) const | 1058 bool SelectorChecker::checkPseudoHost(const SelectorCheckingContext& context, Ma
tchResult& result) const |
| 1059 { | 1059 { |
| 1060 const CSSSelector& selector = *context.selector; | 1060 const CSSSelector& selector = *context.selector; |
| 1061 Element& element = *context.element; | 1061 Element& element = *context.element; |
| 1062 | 1062 |
| 1063 if (m_mode == SharingRules) | 1063 if (m_mode == SharingRules) |
| 1064 return true; | 1064 return true; |
| 1065 // :host only matches a shadow host when :host is in a shadow tree of the sh
adow host. | 1065 // :host only matches a shadow host when :host is in a shadow tree of the sh
adow host. |
| 1066 if (!context.scope) | 1066 if (!context.scope) |
| 1067 return false; | 1067 return false; |
| 1068 const ContainerNode* shadowHost = context.scope->shadowHost(); | 1068 const ContainerNode* shadowHost = context.scope->ownerShadowHost(); |
| 1069 if (!shadowHost || shadowHost != element) | 1069 if (!shadowHost || shadowHost != element) |
| 1070 return false; | 1070 return false; |
| 1071 ASSERT(element.shadow()); | 1071 ASSERT(element.shadow()); |
| 1072 | 1072 |
| 1073 // For the case with no parameters, i.e. just :host. | 1073 // For the case with no parameters, i.e. just :host. |
| 1074 if (!selector.selectorList()) | 1074 if (!selector.selectorList()) |
| 1075 return true; | 1075 return true; |
| 1076 | 1076 |
| 1077 SelectorCheckingContext subContext(context); | 1077 SelectorCheckingContext subContext(context); |
| 1078 subContext.isSubSelector = true; | 1078 subContext.isSubSelector = true; |
| (...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1198 } | 1198 } |
| 1199 | 1199 |
| 1200 bool SelectorChecker::matchesFocusPseudoClass(const Element& element) | 1200 bool SelectorChecker::matchesFocusPseudoClass(const Element& element) |
| 1201 { | 1201 { |
| 1202 if (InspectorInstrumentation::forcePseudoState(const_cast<Element*>(&element
), CSSSelector::PseudoFocus)) | 1202 if (InspectorInstrumentation::forcePseudoState(const_cast<Element*>(&element
), CSSSelector::PseudoFocus)) |
| 1203 return true; | 1203 return true; |
| 1204 return element.focused() && isFrameFocused(element); | 1204 return element.focused() && isFrameFocused(element); |
| 1205 } | 1205 } |
| 1206 | 1206 |
| 1207 } // namespace blink | 1207 } // namespace blink |
| OLD | NEW |