| 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 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 59 ScopeIsShadowHostInPseudoHostParameter = ScopeIsShadowHost | TreatShadow
HostAsNormalScope | 59 ScopeIsShadowHostInPseudoHostParameter = ScopeIsShadowHost | TreatShadow
HostAsNormalScope |
| 60 }; | 60 }; |
| 61 | 61 |
| 62 enum MatchingTagType { | 62 enum MatchingTagType { |
| 63 MatchingElement = 0, | 63 MatchingElement = 0, |
| 64 MatchingHostInItsShadowTree | 64 MatchingHostInItsShadowTree |
| 65 }; | 65 }; |
| 66 | 66 |
| 67 struct SelectorCheckingContext { | 67 struct SelectorCheckingContext { |
| 68 // Initial selector constructor | 68 // Initial selector constructor |
| 69 SelectorCheckingContext(const CSSSelector* selector, Element* element, V
isitedMatchType visitedMatchType) | 69 SelectorCheckingContext(const CSSSelector& selector, Element* element, V
isitedMatchType visitedMatchType) |
| 70 : selector(selector) | 70 : selector(&selector) |
| 71 , element(element) | 71 , element(element) |
| 72 , scope(0) | 72 , scope(0) |
| 73 , visitedMatchType(visitedMatchType) | 73 , visitedMatchType(visitedMatchType) |
| 74 , pseudoId(NOPSEUDO) | 74 , pseudoId(NOPSEUDO) |
| 75 , elementStyle(0) | 75 , elementStyle(0) |
| 76 , scrollbar(0) | 76 , scrollbar(0) |
| 77 , scrollbarPart(NoPart) | 77 , scrollbarPart(NoPart) |
| 78 , isSubSelector(false) | 78 , isSubSelector(false) |
| 79 , hasScrollbarPseudo(false) | 79 , hasScrollbarPseudo(false) |
| 80 , hasSelectionPseudo(false) | 80 , hasSelectionPseudo(false) |
| (...skipping 27 matching lines...) Expand all Loading... |
| 108 Match match(const SelectorCheckingContext&, const SiblingTraversalStrategy&,
MatchResult* = 0) const; | 108 Match match(const SelectorCheckingContext&, const SiblingTraversalStrategy&,
MatchResult* = 0) const; |
| 109 | 109 |
| 110 template<typename SiblingTraversalStrategy> | 110 template<typename SiblingTraversalStrategy> |
| 111 bool checkOne(const SelectorCheckingContext&, const SiblingTraversalStrategy
&, unsigned* specificity = 0) const; | 111 bool checkOne(const SelectorCheckingContext&, const SiblingTraversalStrategy
&, unsigned* specificity = 0) const; |
| 112 | 112 |
| 113 bool strictParsing() const { return m_strictParsing; } | 113 bool strictParsing() const { return m_strictParsing; } |
| 114 | 114 |
| 115 Mode mode() const { return m_mode; } | 115 Mode mode() const { return m_mode; } |
| 116 | 116 |
| 117 static bool tagMatches(const Element&, const QualifiedName&, MatchingTagType
= MatchingElement); | 117 static bool tagMatches(const Element&, const QualifiedName&, MatchingTagType
= MatchingElement); |
| 118 static bool isCommonPseudoClassSelector(const CSSSelector*); | 118 static bool isCommonPseudoClassSelector(const CSSSelector&); |
| 119 static bool matchesFocusPseudoClass(const Element&); | 119 static bool matchesFocusPseudoClass(const Element&); |
| 120 static bool checkExactAttribute(const Element&, const QualifiedName& selecto
rAttributeName, const StringImpl* value); | 120 static bool checkExactAttribute(const Element&, const QualifiedName& selecto
rAttributeName, const StringImpl* value); |
| 121 | 121 |
| 122 enum LinkMatchMask { MatchLink = 1, MatchVisited = 2, MatchAll = MatchLink |
MatchVisited }; | 122 enum LinkMatchMask { MatchLink = 1, MatchVisited = 2, MatchAll = MatchLink |
MatchVisited }; |
| 123 static unsigned determineLinkMatchType(const CSSSelector*); | 123 static unsigned determineLinkMatchType(const CSSSelector&); |
| 124 | 124 |
| 125 static bool isHostInItsShadowTree(const Element&, BehaviorAtBoundary, const
ContainerNode* scope); | 125 static bool isHostInItsShadowTree(const Element&, BehaviorAtBoundary, const
ContainerNode* scope); |
| 126 | 126 |
| 127 private: | 127 private: |
| 128 template<typename SiblingTraversalStrategy> | 128 template<typename SiblingTraversalStrategy> |
| 129 Match matchForSubSelector(const SelectorCheckingContext&, const SiblingTrave
rsalStrategy&, MatchResult*) const; | 129 Match matchForSubSelector(const SelectorCheckingContext&, const SiblingTrave
rsalStrategy&, MatchResult*) const; |
| 130 template<typename SiblingTraversalStrategy> | 130 template<typename SiblingTraversalStrategy> |
| 131 Match matchForRelation(const SelectorCheckingContext&, const SiblingTraversa
lStrategy&, MatchResult*) const; | 131 Match matchForRelation(const SelectorCheckingContext&, const SiblingTraversa
lStrategy&, MatchResult*) const; |
| 132 template<typename SiblingTraversalStrategy> | 132 template<typename SiblingTraversalStrategy> |
| 133 Match matchForShadowDistributed(const Element*, const SiblingTraversalStrate
gy&, SelectorCheckingContext& nextContext, MatchResult* = 0) const; | 133 Match matchForShadowDistributed(const Element*, const SiblingTraversalStrate
gy&, SelectorCheckingContext& nextContext, MatchResult* = 0) const; |
| 134 | 134 |
| 135 bool checkScrollbarPseudoClass(const SelectorCheckingContext&, Document*, co
nst CSSSelector*) const; | 135 bool checkScrollbarPseudoClass(const SelectorCheckingContext&, Document*, co
nst CSSSelector&) const; |
| 136 Element* parentElement(const SelectorCheckingContext&, bool allowToCrossBoun
dary = false) const; | 136 Element* parentElement(const SelectorCheckingContext&, bool allowToCrossBoun
dary = false) const; |
| 137 bool scopeContainsLastMatchedElement(const SelectorCheckingContext&) const; | 137 bool scopeContainsLastMatchedElement(const SelectorCheckingContext&) const; |
| 138 | 138 |
| 139 static bool isFrameFocused(const Element&); | 139 static bool isFrameFocused(const Element&); |
| 140 | 140 |
| 141 bool m_strictParsing; | 141 bool m_strictParsing; |
| 142 bool m_documentIsHTML; | 142 bool m_documentIsHTML; |
| 143 Mode m_mode; | 143 Mode m_mode; |
| 144 }; | 144 }; |
| 145 | 145 |
| 146 inline bool SelectorChecker::isCommonPseudoClassSelector(const CSSSelector* sele
ctor) | 146 inline bool SelectorChecker::isCommonPseudoClassSelector(const CSSSelector& sele
ctor) |
| 147 { | 147 { |
| 148 if (selector->m_match != CSSSelector::PseudoClass) | 148 if (selector.m_match != CSSSelector::PseudoClass) |
| 149 return false; | 149 return false; |
| 150 CSSSelector::PseudoType pseudoType = selector->pseudoType(); | 150 CSSSelector::PseudoType pseudoType = selector.pseudoType(); |
| 151 return pseudoType == CSSSelector::PseudoLink | 151 return pseudoType == CSSSelector::PseudoLink |
| 152 || pseudoType == CSSSelector::PseudoAnyLink | 152 || pseudoType == CSSSelector::PseudoAnyLink |
| 153 || pseudoType == CSSSelector::PseudoVisited | 153 || pseudoType == CSSSelector::PseudoVisited |
| 154 || pseudoType == CSSSelector::PseudoFocus; | 154 || pseudoType == CSSSelector::PseudoFocus; |
| 155 } | 155 } |
| 156 | 156 |
| 157 inline bool SelectorChecker::tagMatches(const Element& element, const QualifiedN
ame& tagQName, MatchingTagType matchingTagType) | 157 inline bool SelectorChecker::tagMatches(const Element& element, const QualifiedN
ame& tagQName, MatchingTagType matchingTagType) |
| 158 { | 158 { |
| 159 if (tagQName == anyQName()) | 159 if (tagQName == anyQName()) |
| 160 return true; | 160 return true; |
| (...skipping 18 matching lines...) Expand all Loading... |
| 179 } | 179 } |
| 180 | 180 |
| 181 inline bool SelectorChecker::isHostInItsShadowTree(const Element& element, Behav
iorAtBoundary behaviorAtBoundary, const ContainerNode* scope) | 181 inline bool SelectorChecker::isHostInItsShadowTree(const Element& element, Behav
iorAtBoundary behaviorAtBoundary, const ContainerNode* scope) |
| 182 { | 182 { |
| 183 return (behaviorAtBoundary & (ScopeIsShadowHost | TreatShadowHostAsNormalSco
pe)) == ScopeIsShadowHost && scope == element; | 183 return (behaviorAtBoundary & (ScopeIsShadowHost | TreatShadowHostAsNormalSco
pe)) == ScopeIsShadowHost && scope == element; |
| 184 } | 184 } |
| 185 | 185 |
| 186 } | 186 } |
| 187 | 187 |
| 188 #endif | 188 #endif |
| OLD | NEW |