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 830 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
841 return true; | 841 return true; |
842 break; | 842 break; |
843 } | 843 } |
844 | 844 |
845 case CSSSelector::PseudoUnresolved: | 845 case CSSSelector::PseudoUnresolved: |
846 if (element.isUnresolvedCustomElement()) | 846 if (element.isUnresolvedCustomElement()) |
847 return true; | 847 return true; |
848 break; | 848 break; |
849 | 849 |
850 case CSSSelector::PseudoHost: | 850 case CSSSelector::PseudoHost: |
| 851 case CSSSelector::PseudoAncestor: |
851 { | 852 { |
852 // :host only matches a shadow host when :host is in a shadow tr
ee of the shadow host. | 853 // :host only matches a shadow host when :host is in a shadow tr
ee of the shadow host. |
853 if (!context.scope || !(context.behaviorAtBoundary & ScopeIsShad
owHost) || context.scope != element) | 854 if (!context.scope || !(context.behaviorAtBoundary & ScopeIsShad
owHost) || context.scope != element) |
854 return false; | 855 return false; |
855 ASSERT(element.shadow()); | 856 ASSERT(element.shadow()); |
856 | 857 |
857 // For empty parameter case, i.e. just :host or :host(). | 858 // For empty parameter case, i.e. just :host or :host(). |
858 if (!selector->selectorList()) // Use *'s specificity. So just 0
. | 859 if (!selector->selectorList()) // Use *'s specificity. So just 0
. |
859 return true; | 860 return true; |
860 | 861 |
861 SelectorCheckingContext subContext(context); | 862 SelectorCheckingContext subContext(context); |
862 subContext.isSubSelector = true; | 863 subContext.isSubSelector = true; |
863 | 864 |
864 bool matched = false; | 865 bool matched = false; |
865 unsigned maxSpecificity = 0; | 866 unsigned maxSpecificity = 0; |
866 | 867 |
867 // If one of simple selectors matches an element, returns Select
orMatches. Just "OR". | 868 // If one of simple selectors matches an element, returns Select
orMatches. Just "OR". |
868 for (subContext.selector = selector->selectorList()->first(); su
bContext.selector; subContext.selector = CSSSelectorList::next(subContext.select
or)) { | 869 for (subContext.selector = selector->selectorList()->first(); su
bContext.selector; subContext.selector = CSSSelectorList::next(subContext.select
or)) { |
869 subContext.behaviorAtBoundary = ScopeIsShadowHostInPseudoHos
tParameter; | 870 subContext.behaviorAtBoundary = ScopeIsShadowHostInPseudoHos
tParameter; |
870 subContext.scope = context.scope; | 871 subContext.scope = context.scope; |
871 // Use NodeRenderingTraversal to traverse a composed ancesto
r list of a given element. | 872 // Use NodeRenderingTraversal to traverse a composed ancesto
r list of a given element. |
872 for (Element* nextElement = &element; nextElement; nextEleme
nt = NodeRenderingTraversal::parentElement(nextElement)) { | 873 Element* nextElement = &element; |
| 874 do { |
873 MatchResult subResult; | 875 MatchResult subResult; |
874 subContext.element = nextElement; | 876 subContext.element = nextElement; |
875 if (match(subContext, siblingTraversalStrategy, &subResu
lt) == SelectorMatches) { | 877 if (match(subContext, siblingTraversalStrategy, &subResu
lt) == SelectorMatches) { |
876 matched = true; | 878 matched = true; |
877 // Consider div:host(div:host(div:host(div:host...))
). | 879 // Consider div:host(div:host(div:host(div:host...))
). |
878 maxSpecificity = std::max(maxSpecificity, subContext
.selector->specificity() + subResult.specificity); | 880 maxSpecificity = std::max(maxSpecificity, subContext
.selector->specificity() + subResult.specificity); |
879 break; | 881 break; |
880 } | 882 } |
881 subContext.behaviorAtBoundary = DoesNotCrossBoundary; | 883 subContext.behaviorAtBoundary = DoesNotCrossBoundary; |
882 subContext.scope = 0; | 884 subContext.scope = 0; |
883 } | 885 |
| 886 if (selector->pseudoType() == CSSSelector::PseudoHost) |
| 887 break; |
| 888 |
| 889 nextElement = NodeRenderingTraversal::parentElement(next
Element); |
| 890 } while (nextElement); |
884 } | 891 } |
885 if (matched) { | 892 if (matched) { |
886 if (specificity) | 893 if (specificity) |
887 *specificity = maxSpecificity; | 894 *specificity = maxSpecificity; |
888 return true; | 895 return true; |
889 } | 896 } |
890 } | 897 } |
891 break; | 898 break; |
892 | 899 |
893 case CSSSelector::PseudoHorizontal: | 900 case CSSSelector::PseudoHorizontal: |
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1061 return element.focused() && isFrameFocused(element); | 1068 return element.focused() && isFrameFocused(element); |
1062 } | 1069 } |
1063 | 1070 |
1064 template | 1071 template |
1065 SelectorChecker::Match SelectorChecker::match(const SelectorCheckingContext&, co
nst DOMSiblingTraversalStrategy&, MatchResult*) const; | 1072 SelectorChecker::Match SelectorChecker::match(const SelectorCheckingContext&, co
nst DOMSiblingTraversalStrategy&, MatchResult*) const; |
1066 | 1073 |
1067 template | 1074 template |
1068 SelectorChecker::Match SelectorChecker::match(const SelectorCheckingContext&, co
nst ShadowDOMSiblingTraversalStrategy&, MatchResult*) const; | 1075 SelectorChecker::Match SelectorChecker::match(const SelectorCheckingContext&, co
nst ShadowDOMSiblingTraversalStrategy&, MatchResult*) const; |
1069 | 1076 |
1070 } | 1077 } |
OLD | NEW |