| 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 174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 185 // * SelectorMatches - the selector matches the element e | 185 // * SelectorMatches - the selector matches the element e |
| 186 // * SelectorFailsLocally - the selector fails for the element e | 186 // * SelectorFailsLocally - the selector fails for the element e |
| 187 // * SelectorFailsAllSiblings - the selector fails for e and any sibling of e | 187 // * SelectorFailsAllSiblings - the selector fails for e and any sibling of e |
| 188 // * SelectorFailsCompletely - the selector fails for e and any sibling or ance
stor of e | 188 // * SelectorFailsCompletely - the selector fails for e and any sibling or ance
stor of e |
| 189 SelectorChecker::Match SelectorChecker::matchSelector(const SelectorCheckingCont
ext& context, MatchResult& result) const | 189 SelectorChecker::Match SelectorChecker::matchSelector(const SelectorCheckingCont
ext& context, MatchResult& result) const |
| 190 { | 190 { |
| 191 MatchResult subResult; | 191 MatchResult subResult; |
| 192 if (!checkOne(context, subResult)) | 192 if (!checkOne(context, subResult)) |
| 193 return SelectorFailsLocally; | 193 return SelectorFailsLocally; |
| 194 | 194 |
| 195 if (subResult.dynamicPseudo != NOPSEUDO) | 195 if (subResult.dynamicPseudo != PseudoIdNone) |
| 196 result.dynamicPseudo = subResult.dynamicPseudo; | 196 result.dynamicPseudo = subResult.dynamicPseudo; |
| 197 | 197 |
| 198 if (context.selector->isLastInTagHistory()) { | 198 if (context.selector->isLastInTagHistory()) { |
| 199 if (scopeContainsLastMatchedElement(context)) { | 199 if (scopeContainsLastMatchedElement(context)) { |
| 200 result.specificity += subResult.specificity; | 200 result.specificity += subResult.specificity; |
| 201 return SelectorMatches; | 201 return SelectorMatches; |
| 202 } | 202 } |
| 203 return SelectorFailsLocally; | 203 return SelectorFailsLocally; |
| 204 } | 204 } |
| 205 | 205 |
| 206 Match match; | 206 Match match; |
| 207 if (context.selector->relation() != CSSSelector::SubSelector) { | 207 if (context.selector->relation() != CSSSelector::SubSelector) { |
| 208 if (nextSelectorExceedsScope(context)) | 208 if (nextSelectorExceedsScope(context)) |
| 209 return SelectorFailsCompletely; | 209 return SelectorFailsCompletely; |
| 210 | 210 |
| 211 if (context.pseudoId != NOPSEUDO && context.pseudoId != result.dynamicPs
eudo) | 211 if (context.pseudoId != PseudoIdNone && context.pseudoId != result.dynam
icPseudo) |
| 212 return SelectorFailsCompletely; | 212 return SelectorFailsCompletely; |
| 213 | 213 |
| 214 TemporaryChange<PseudoId> dynamicPseudoScope(result.dynamicPseudo, NOPSE
UDO); | 214 TemporaryChange<PseudoId> dynamicPseudoScope(result.dynamicPseudo, Pseud
oIdNone); |
| 215 match = matchForRelation(context, result); | 215 match = matchForRelation(context, result); |
| 216 } else { | 216 } else { |
| 217 match = matchForSubSelector(context, result); | 217 match = matchForSubSelector(context, result); |
| 218 } | 218 } |
| 219 if (match == SelectorMatches) | 219 if (match == SelectorMatches) |
| 220 result.specificity += subResult.specificity; | 220 result.specificity += subResult.specificity; |
| 221 return match; | 221 return match; |
| 222 } | 222 } |
| 223 | 223 |
| 224 static inline SelectorChecker::SelectorCheckingContext prepareNextContextForRela
tion(const SelectorChecker::SelectorCheckingContext& context) | 224 static inline SelectorChecker::SelectorCheckingContext prepareNextContextForRela
tion(const SelectorChecker::SelectorCheckingContext& context) |
| 225 { | 225 { |
| 226 SelectorChecker::SelectorCheckingContext nextContext(context); | 226 SelectorChecker::SelectorCheckingContext nextContext(context); |
| 227 ASSERT(context.selector->tagHistory()); | 227 ASSERT(context.selector->tagHistory()); |
| 228 nextContext.selector = context.selector->tagHistory(); | 228 nextContext.selector = context.selector->tagHistory(); |
| 229 return nextContext; | 229 return nextContext; |
| 230 } | 230 } |
| 231 | 231 |
| 232 SelectorChecker::Match SelectorChecker::matchForSubSelector(const SelectorChecki
ngContext& context, MatchResult& result) const | 232 SelectorChecker::Match SelectorChecker::matchForSubSelector(const SelectorChecki
ngContext& context, MatchResult& result) const |
| 233 { | 233 { |
| 234 SelectorCheckingContext nextContext = prepareNextContextForRelation(context)
; | 234 SelectorCheckingContext nextContext = prepareNextContextForRelation(context)
; |
| 235 | 235 |
| 236 PseudoId dynamicPseudo = result.dynamicPseudo; | 236 PseudoId dynamicPseudo = result.dynamicPseudo; |
| 237 nextContext.hasScrollbarPseudo = dynamicPseudo != NOPSEUDO && (m_scrollbar |
| dynamicPseudo == SCROLLBAR_CORNER || dynamicPseudo == RESIZER); | 237 nextContext.hasScrollbarPseudo = dynamicPseudo != PseudoIdNone && (m_scrollb
ar || dynamicPseudo == PseudoIdScrollbarCorner || dynamicPseudo == PseudoIdResiz
er); |
| 238 nextContext.hasSelectionPseudo = dynamicPseudo == SELECTION; | 238 nextContext.hasSelectionPseudo = dynamicPseudo == PseudoIdSelection; |
| 239 nextContext.isSubSelector = true; | 239 nextContext.isSubSelector = true; |
| 240 return matchSelector(nextContext, result); | 240 return matchSelector(nextContext, result); |
| 241 } | 241 } |
| 242 | 242 |
| 243 static inline bool isV0ShadowRoot(const Node* node) | 243 static inline bool isV0ShadowRoot(const Node* node) |
| 244 { | 244 { |
| 245 return node && node->isShadowRoot() && toShadowRoot(node)->type() == ShadowR
ootType::V0; | 245 return node && node->isShadowRoot() && toShadowRoot(node)->type() == ShadowR
ootType::V0; |
| 246 } | 246 } |
| 247 | 247 |
| 248 SelectorChecker::Match SelectorChecker::matchForPseudoShadow(const SelectorCheck
ingContext& context, const ContainerNode* node, MatchResult& result) const | 248 SelectorChecker::Match SelectorChecker::matchForPseudoShadow(const SelectorCheck
ingContext& context, const ContainerNode* node, MatchResult& result) const |
| (...skipping 20 matching lines...) Expand all Loading... |
| 269 | 269 |
| 270 CSSSelector::RelationType relation = context.selector->relation(); | 270 CSSSelector::RelationType relation = context.selector->relation(); |
| 271 | 271 |
| 272 // Disable :visited matching when we see the first link or try to match anyt
hing else than an ancestors. | 272 // Disable :visited matching when we see the first link or try to match anyt
hing else than an ancestors. |
| 273 if (!context.isSubSelector && (context.element->isLink() || (relation != CSS
Selector::Descendant && relation != CSSSelector::Child))) | 273 if (!context.isSubSelector && (context.element->isLink() || (relation != CSS
Selector::Descendant && relation != CSSSelector::Child))) |
| 274 nextContext.visitedMatchType = VisitedMatchDisabled; | 274 nextContext.visitedMatchType = VisitedMatchDisabled; |
| 275 | 275 |
| 276 nextContext.inRightmostCompound = false; | 276 nextContext.inRightmostCompound = false; |
| 277 nextContext.isSubSelector = false; | 277 nextContext.isSubSelector = false; |
| 278 nextContext.previousElement = context.element; | 278 nextContext.previousElement = context.element; |
| 279 nextContext.pseudoId = NOPSEUDO; | 279 nextContext.pseudoId = PseudoIdNone; |
| 280 | 280 |
| 281 switch (relation) { | 281 switch (relation) { |
| 282 case CSSSelector::Descendant: | 282 case CSSSelector::Descendant: |
| 283 if (context.selector->relationIsAffectedByPseudoContent()) { | 283 if (context.selector->relationIsAffectedByPseudoContent()) { |
| 284 for (Element* element = context.element; element; element = element-
>parentElement()) { | 284 for (Element* element = context.element; element; element = element-
>parentElement()) { |
| 285 if (matchForPseudoContent(nextContext, *element, result) == Sele
ctorMatches) | 285 if (matchForPseudoContent(nextContext, *element, result) == Sele
ctorMatches) |
| 286 return SelectorMatches; | 286 return SelectorMatches; |
| 287 } | 287 } |
| 288 return SelectorFailsCompletely; | 288 return SelectorFailsCompletely; |
| 289 } | 289 } |
| (...skipping 698 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 988 } | 988 } |
| 989 case CSSSelector::PseudoContent: | 989 case CSSSelector::PseudoContent: |
| 990 return element.isInShadowTree() && element.isInsertionPoint(); | 990 return element.isInShadowTree() && element.isInsertionPoint(); |
| 991 case CSSSelector::PseudoShadow: | 991 case CSSSelector::PseudoShadow: |
| 992 return element.isInShadowTree() && context.previousElement; | 992 return element.isInShadowTree() && context.previousElement; |
| 993 default: | 993 default: |
| 994 if (m_mode == SharingRules) | 994 if (m_mode == SharingRules) |
| 995 return true; | 995 return true; |
| 996 ASSERT(m_mode != QueryingRules); | 996 ASSERT(m_mode != QueryingRules); |
| 997 result.dynamicPseudo = CSSSelector::pseudoId(selector.getPseudoType()); | 997 result.dynamicPseudo = CSSSelector::pseudoId(selector.getPseudoType()); |
| 998 ASSERT(result.dynamicPseudo != NOPSEUDO); | 998 ASSERT(result.dynamicPseudo != PseudoIdNone); |
| 999 return true; | 999 return true; |
| 1000 } | 1000 } |
| 1001 } | 1001 } |
| 1002 | 1002 |
| 1003 bool SelectorChecker::checkPseudoHost(const SelectorCheckingContext& context, Ma
tchResult& result) const | 1003 bool SelectorChecker::checkPseudoHost(const SelectorCheckingContext& context, Ma
tchResult& result) const |
| 1004 { | 1004 { |
| 1005 const CSSSelector& selector = *context.selector; | 1005 const CSSSelector& selector = *context.selector; |
| 1006 Element& element = *context.element; | 1006 Element& element = *context.element; |
| 1007 | 1007 |
| 1008 if (m_mode == SharingRules) | 1008 if (m_mode == SharingRules) |
| (...skipping 134 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 |