| 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 277 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 288 nextContext.hasSelectionPseudo = dynamicPseudo == SELECTION; | 288 nextContext.hasSelectionPseudo = dynamicPseudo == SELECTION; |
| 289 if ((context.inRightmostCompound || m_mode == CollectingCSSRules || m_mode =
= CollectingStyleRules || m_mode == QueryingRules) && dynamicPseudo != NOPSEUDO | 289 if ((context.inRightmostCompound || m_mode == CollectingCSSRules || m_mode =
= CollectingStyleRules || m_mode == QueryingRules) && dynamicPseudo != NOPSEUDO |
| 290 && !nextContext.hasSelectionPseudo | 290 && !nextContext.hasSelectionPseudo |
| 291 && !(nextContext.hasScrollbarPseudo && nextContext.selector->match() ==
CSSSelector::PseudoClass)) | 291 && !(nextContext.hasScrollbarPseudo && nextContext.selector->match() ==
CSSSelector::PseudoClass)) |
| 292 return SelectorFailsCompletely; | 292 return SelectorFailsCompletely; |
| 293 | 293 |
| 294 nextContext.isSubSelector = true; | 294 nextContext.isSubSelector = true; |
| 295 return matchSelector(nextContext, result); | 295 return matchSelector(nextContext, result); |
| 296 } | 296 } |
| 297 | 297 |
| 298 static inline Element* parentOrShadowHostButDisallowEscapingUserAgentShadowTree(
const Element& element) | |
| 299 { | |
| 300 ContainerNode* parent = element.parentOrShadowHostNode(); | |
| 301 if (!parent) | |
| 302 return nullptr; | |
| 303 if (parent->isShadowRoot()) | |
| 304 return (toShadowRoot(parent)->type() == ShadowRoot::UserAgentShadowRoot)
? nullptr : toShadowRoot(parent)->host(); | |
| 305 if (!parent->isElementNode()) | |
| 306 return nullptr; | |
| 307 return toElement(parent); | |
| 308 } | |
| 309 | |
| 310 static inline bool isOpenShadowRoot(const Node* node) | 298 static inline bool isOpenShadowRoot(const Node* node) |
| 311 { | 299 { |
| 312 return node && node->isShadowRoot() && toShadowRoot(node)->type() == ShadowR
oot::OpenShadowRoot; | 300 return node && node->isShadowRoot() && toShadowRoot(node)->type() == ShadowR
oot::OpenShadowRoot; |
| 313 } | 301 } |
| 314 | 302 |
| 315 SelectorChecker::Match SelectorChecker::matchForPseudoShadow(const SelectorCheck
ingContext& context, const ContainerNode* node, MatchResult& result) const | 303 SelectorChecker::Match SelectorChecker::matchForPseudoShadow(const SelectorCheck
ingContext& context, const ContainerNode* node, MatchResult& result) const |
| 316 { | 304 { |
| 317 if (!isOpenShadowRoot(node)) | 305 if (!isOpenShadowRoot(node)) |
| 318 return SelectorFailsCompletely; | 306 return SelectorFailsCompletely; |
| 319 if (!context.previousElement) | 307 if (!context.previousElement) |
| (...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 418 if (!shadowHost) | 406 if (!shadowHost) |
| 419 return SelectorFailsCompletely; | 407 return SelectorFailsCompletely; |
| 420 nextContext.element = shadowHost; | 408 nextContext.element = shadowHost; |
| 421 nextContext.isSubSelector = false; | 409 nextContext.isSubSelector = false; |
| 422 nextContext.inRightmostCompound = false; | 410 nextContext.inRightmostCompound = false; |
| 423 return matchSelector(nextContext, result); | 411 return matchSelector(nextContext, result); |
| 424 } | 412 } |
| 425 | 413 |
| 426 case CSSSelector::ShadowDeep: | 414 case CSSSelector::ShadowDeep: |
| 427 { | 415 { |
| 416 if (ShadowRoot* root = context.element->containingShadowRoot()) { |
| 417 if (root->type() == ShadowRoot::UserAgentShadowRoot) |
| 418 return SelectorFailsCompletely; |
| 419 } |
| 420 |
| 428 if (context.selector->relationIsAffectedByPseudoContent()) { | 421 if (context.selector->relationIsAffectedByPseudoContent()) { |
| 429 for (Element* element = context.element; element; element = pare
ntOrShadowHostButDisallowEscapingUserAgentShadowTree(*element)) { | 422 for (Element* element = context.element; element; element = elem
ent->parentOrShadowHostElement()) { |
| 430 if (matchForShadowDistributed(nextContext, *element, result)
== SelectorMatches) | 423 if (matchForShadowDistributed(nextContext, *element, result)
== SelectorMatches) |
| 431 return SelectorMatches; | 424 return SelectorMatches; |
| 432 } | 425 } |
| 433 return SelectorFailsCompletely; | 426 return SelectorFailsCompletely; |
| 434 } | 427 } |
| 435 | 428 |
| 436 nextContext.isSubSelector = false; | 429 nextContext.isSubSelector = false; |
| 437 nextContext.inRightmostCompound = false; | 430 nextContext.inRightmostCompound = false; |
| 438 for (nextContext.element = parentOrShadowHostButDisallowEscapingUser
AgentShadowTree(*context.element); nextContext.element; nextContext.element = pa
rentOrShadowHostButDisallowEscapingUserAgentShadowTree(*nextContext.element)) { | 431 for (nextContext.element = context.element->parentOrShadowHostElemen
t(); nextContext.element; nextContext.element = nextContext.element->parentOrSha
dowHostElement()) { |
| 439 Match match = matchSelector(nextContext, result); | 432 Match match = matchSelector(nextContext, result); |
| 440 if (match == SelectorMatches || match == SelectorFailsCompletely
) | 433 if (match == SelectorMatches || match == SelectorFailsCompletely
) |
| 441 return match; | 434 return match; |
| 442 if (nextSelectorExceedsScope(nextContext)) | 435 if (nextSelectorExceedsScope(nextContext)) |
| 443 return SelectorFailsCompletely; | 436 return SelectorFailsCompletely; |
| 444 } | 437 } |
| 445 return SelectorFailsCompletely; | 438 return SelectorFailsCompletely; |
| 446 } | 439 } |
| 447 | 440 |
| 448 case CSSSelector::SubSelector: | 441 case CSSSelector::SubSelector: |
| (...skipping 733 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1182 } | 1175 } |
| 1183 | 1176 |
| 1184 bool SelectorChecker::matchesFocusPseudoClass(const Element& element) | 1177 bool SelectorChecker::matchesFocusPseudoClass(const Element& element) |
| 1185 { | 1178 { |
| 1186 if (InspectorInstrumentation::forcePseudoState(const_cast<Element*>(&element
), CSSSelector::PseudoFocus)) | 1179 if (InspectorInstrumentation::forcePseudoState(const_cast<Element*>(&element
), CSSSelector::PseudoFocus)) |
| 1187 return true; | 1180 return true; |
| 1188 return element.focused() && isFrameFocused(element); | 1181 return element.focused() && isFrameFocused(element); |
| 1189 } | 1182 } |
| 1190 | 1183 |
| 1191 } | 1184 } |
| OLD | NEW |