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 338 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
349 | 349 |
350 const ContainerNode* scope = nextContext.scope; | 350 const ContainerNode* scope = nextContext.scope; |
351 BehaviorAtBoundary behaviorAtBoundary = nextContext.behaviorAtBoundary; | 351 BehaviorAtBoundary behaviorAtBoundary = nextContext.behaviorAtBoundary; |
352 | 352 |
353 collectDestinationInsertionPoints(*element, insertionPoints); | 353 collectDestinationInsertionPoints(*element, insertionPoints); |
354 for (size_t i = 0; i < insertionPoints.size(); ++i) { | 354 for (size_t i = 0; i < insertionPoints.size(); ++i) { |
355 nextContext.element = insertionPoints[i]; | 355 nextContext.element = insertionPoints[i]; |
356 | 356 |
357 // If a given scope is a shadow host of an insertion point but behaviorA
tBoundary doesn't have ScopeIsShadowHost, | 357 // If a given scope is a shadow host of an insertion point but behaviorA
tBoundary doesn't have ScopeIsShadowHost, |
358 // we need to update behaviorAtBoundary to make selectors like ":host >
::content" work correctly. | 358 // we need to update behaviorAtBoundary to make selectors like ":host >
::content" work correctly. |
359 if (scope == insertionPoints[i]->containingShadowRoot()->shadowHost() &&
!(behaviorAtBoundary & ScopeIsShadowHost)) | 359 if (m_mode == SharingRules) { |
| 360 nextContext.behaviorAtBoundary = static_cast<BehaviorAtBoundary>(beh
aviorAtBoundary | ScopeIsShadowHost); |
| 361 nextContext.scope = insertionPoints[i]->containingShadowRoot()->shad
owHost(); |
| 362 } else if (scope == insertionPoints[i]->containingShadowRoot()->shadowHo
st() && !(behaviorAtBoundary & ScopeIsShadowHost)) |
360 nextContext.behaviorAtBoundary = static_cast<BehaviorAtBoundary>(beh
aviorAtBoundary | ScopeIsShadowHost); | 363 nextContext.behaviorAtBoundary = static_cast<BehaviorAtBoundary>(beh
aviorAtBoundary | ScopeIsShadowHost); |
361 else | 364 else |
362 nextContext.behaviorAtBoundary = behaviorAtBoundary; | 365 nextContext.behaviorAtBoundary = behaviorAtBoundary; |
363 | 366 |
364 nextContext.isSubSelector = false; | 367 nextContext.isSubSelector = false; |
365 nextContext.elementStyle = 0; | 368 nextContext.elementStyle = 0; |
366 if (match(nextContext, siblingTraversalStrategy, result) == SelectorMatc
hes) | 369 if (match(nextContext, siblingTraversalStrategy, result) == SelectorMatc
hes) |
367 return SelectorMatches; | 370 return SelectorMatches; |
368 } | 371 } |
369 return SelectorFailsCompletely; | 372 return SelectorFailsLocally; |
370 } | 373 } |
371 | 374 |
372 static inline bool containsHTMLSpace(const AtomicString& string) | 375 static inline bool containsHTMLSpace(const AtomicString& string) |
373 { | 376 { |
374 for (unsigned i = 0; i < string.length(); i++) | 377 for (unsigned i = 0; i < string.length(); i++) |
375 if (isHTMLSpace<UChar>(string[i])) | 378 if (isHTMLSpace<UChar>(string[i])) |
376 return true; | 379 return true; |
377 return false; | 380 return false; |
378 } | 381 } |
379 | 382 |
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
514 subContext.isSubSelector = true; | 517 subContext.isSubSelector = true; |
515 ASSERT(selector.selectorList()); | 518 ASSERT(selector.selectorList()); |
516 for (subContext.selector = selector.selectorList()->first(); subCont
ext.selector; subContext.selector = subContext.selector->tagHistory()) { | 519 for (subContext.selector = selector.selectorList()->first(); subCont
ext.selector; subContext.selector = subContext.selector->tagHistory()) { |
517 // :not cannot nest. I don't really know why this is a | 520 // :not cannot nest. I don't really know why this is a |
518 // restriction in CSS3, but it is, so let's honor it. | 521 // restriction in CSS3, but it is, so let's honor it. |
519 // the parser enforces that this never occurs | 522 // the parser enforces that this never occurs |
520 ASSERT(subContext.selector->pseudoType() != CSSSelector::PseudoN
ot); | 523 ASSERT(subContext.selector->pseudoType() != CSSSelector::PseudoN
ot); |
521 // We select between :visited and :link when applying. We don't
know which one applied (or not) yet. | 524 // We select between :visited and :link when applying. We don't
know which one applied (or not) yet. |
522 if (subContext.selector->pseudoType() == CSSSelector::PseudoVisi
ted || (subContext.selector->pseudoType() == CSSSelector::PseudoLink && subConte
xt.visitedMatchType == VisitedMatchEnabled)) | 525 if (subContext.selector->pseudoType() == CSSSelector::PseudoVisi
ted || (subContext.selector->pseudoType() == CSSSelector::PseudoLink && subConte
xt.visitedMatchType == VisitedMatchEnabled)) |
523 return true; | 526 return true; |
| 527 // context.scope is not available if m_mode == SharingRules. |
| 528 // We cannot determine whether :host or :scope matches a given e
lement or not. |
| 529 if (m_mode == SharingRules && (subContext.selector->isHostPseudo
Class() || subContext.selector->pseudoType() == CSSSelector::PseudoScope)) |
| 530 return true; |
524 if (!checkOne(subContext, DOMSiblingTraversalStrategy())) | 531 if (!checkOne(subContext, DOMSiblingTraversalStrategy())) |
525 return true; | 532 return true; |
526 } | 533 } |
527 } else if (context.hasScrollbarPseudo) { | 534 } else if (context.hasScrollbarPseudo) { |
528 // CSS scrollbars match a specific subset of pseudo classes, and the
y have specialized rules for each | 535 // CSS scrollbars match a specific subset of pseudo classes, and the
y have specialized rules for each |
529 // (since there are no elements involved). | 536 // (since there are no elements involved). |
530 return checkScrollbarPseudoClass(context, &element.document(), selec
tor); | 537 return checkScrollbarPseudoClass(context, &element.document(), selec
tor); |
531 } else if (context.hasSelectionPseudo) { | 538 } else if (context.hasSelectionPseudo) { |
532 if (selector.pseudoType() == CSSSelector::PseudoWindowInactive) | 539 if (selector.pseudoType() == CSSSelector::PseudoWindowInactive) |
533 return !element.document().page()->focusController().isActive(); | 540 return !element.document().page()->focusController().isActive(); |
(...skipping 319 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
853 case CSSSelector::PseudoOutOfRange: | 860 case CSSSelector::PseudoOutOfRange: |
854 element.document().setContainsValidityStyleRules(); | 861 element.document().setContainsValidityStyleRules(); |
855 return element.isOutOfRange(); | 862 return element.isOutOfRange(); |
856 case CSSSelector::PseudoFutureCue: | 863 case CSSSelector::PseudoFutureCue: |
857 return (element.isVTTElement() && !toVTTElement(element).isPastNode(
)); | 864 return (element.isVTTElement() && !toVTTElement(element).isPastNode(
)); |
858 case CSSSelector::PseudoPastCue: | 865 case CSSSelector::PseudoPastCue: |
859 return (element.isVTTElement() && toVTTElement(element).isPastNode()
); | 866 return (element.isVTTElement() && toVTTElement(element).isPastNode()
); |
860 | 867 |
861 case CSSSelector::PseudoScope: | 868 case CSSSelector::PseudoScope: |
862 { | 869 { |
| 870 if (m_mode == SharingRules) |
| 871 return true; |
863 const Node* contextualReferenceNode = !context.scope ? element.d
ocument().documentElement() : context.scope; | 872 const Node* contextualReferenceNode = !context.scope ? element.d
ocument().documentElement() : context.scope; |
864 if (element == contextualReferenceNode) | 873 if (element == contextualReferenceNode) |
865 return true; | 874 return true; |
866 break; | 875 break; |
867 } | 876 } |
868 | 877 |
869 case CSSSelector::PseudoUnresolved: | 878 case CSSSelector::PseudoUnresolved: |
870 if (element.isUnresolvedCustomElement()) | 879 if (element.isUnresolvedCustomElement()) |
871 return true; | 880 return true; |
872 break; | 881 break; |
873 | 882 |
874 case CSSSelector::PseudoHost: | 883 case CSSSelector::PseudoHost: |
875 case CSSSelector::PseudoAncestor: | 884 case CSSSelector::PseudoAncestor: |
876 { | 885 { |
| 886 if (m_mode == SharingRules) |
| 887 return true; |
877 // :host only matches a shadow host when :host is in a shadow tr
ee of the shadow host. | 888 // :host only matches a shadow host when :host is in a shadow tr
ee of the shadow host. |
878 if (!context.scope) | 889 if (!context.scope) |
879 return false; | 890 return false; |
880 const ContainerNode* shadowHost = (context.behaviorAtBoundary &
ScopeIsShadowHost) ? context.scope : (context.scope->isInShadowTree() ? context.
scope->shadowHost() : 0); | 891 const ContainerNode* shadowHost = (context.behaviorAtBoundary &
ScopeIsShadowHost) ? context.scope : (context.scope->isInShadowTree() ? context.
scope->shadowHost() : 0); |
881 if (!shadowHost || shadowHost != element) | 892 if (!shadowHost || shadowHost != element) |
882 return false; | 893 return false; |
883 ASSERT(element.shadow()); | 894 ASSERT(element.shadow()); |
884 | 895 |
885 // For empty parameter case, i.e. just :host or :host(). | 896 // For empty parameter case, i.e. just :host or :host(). |
886 if (!selector.selectorList()) // Use *'s specificity. So just 0. | 897 if (!selector.selectorList()) // Use *'s specificity. So just 0. |
(...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1097 return element.focused() && isFrameFocused(element); | 1108 return element.focused() && isFrameFocused(element); |
1098 } | 1109 } |
1099 | 1110 |
1100 template | 1111 template |
1101 SelectorChecker::Match SelectorChecker::match(const SelectorCheckingContext&, co
nst DOMSiblingTraversalStrategy&, MatchResult*) const; | 1112 SelectorChecker::Match SelectorChecker::match(const SelectorCheckingContext&, co
nst DOMSiblingTraversalStrategy&, MatchResult*) const; |
1102 | 1113 |
1103 template | 1114 template |
1104 SelectorChecker::Match SelectorChecker::match(const SelectorCheckingContext&, co
nst ShadowDOMSiblingTraversalStrategy&, MatchResult*) const; | 1115 SelectorChecker::Match SelectorChecker::match(const SelectorCheckingContext&, co
nst ShadowDOMSiblingTraversalStrategy&, MatchResult*) const; |
1105 | 1116 |
1106 } | 1117 } |
OLD | NEW |