| 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 291 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 302 | 302 |
| 303 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 |
| 304 { | 304 { |
| 305 if (!isOpenShadowRoot(node)) | 305 if (!isOpenShadowRoot(node)) |
| 306 return SelectorFailsCompletely; | 306 return SelectorFailsCompletely; |
| 307 if (!context.previousElement) | 307 if (!context.previousElement) |
| 308 return SelectorFailsCompletely; | 308 return SelectorFailsCompletely; |
| 309 return matchSelector(context, result); | 309 return matchSelector(context, result); |
| 310 } | 310 } |
| 311 | 311 |
| 312 static inline Element* parentOrShadowHostElementButDisallowClosedShadowTree(cons
t Element& element) |
| 313 { |
| 314 if (element.parentNode() && element.parentNode()->isShadowRoot()) { |
| 315 if (!toShadowRoot(element.parentNode())->isOpen()) |
| 316 return nullptr; |
| 317 } |
| 318 return element.parentOrShadowHostElement(); |
| 319 } |
| 320 |
| 312 SelectorChecker::Match SelectorChecker::matchForRelation(const SelectorCheckingC
ontext& context, MatchResult& result) const | 321 SelectorChecker::Match SelectorChecker::matchForRelation(const SelectorCheckingC
ontext& context, MatchResult& result) const |
| 313 { | 322 { |
| 314 SelectorCheckingContext nextContext = prepareNextContextForRelation(context)
; | 323 SelectorCheckingContext nextContext = prepareNextContextForRelation(context)
; |
| 315 nextContext.previousElement = context.element; | 324 nextContext.previousElement = context.element; |
| 316 | 325 |
| 317 CSSSelector::Relation relation = context.selector->relation(); | 326 CSSSelector::Relation relation = context.selector->relation(); |
| 318 | 327 |
| 319 // Disable :visited matching when we see the first link or try to match anyt
hing else than an ancestors. | 328 // Disable :visited matching when we see the first link or try to match anyt
hing else than an ancestors. |
| 320 if (!context.isSubSelector && (context.element->isLink() || (relation != CSS
Selector::Descendant && relation != CSSSelector::Child))) | 329 if (!context.isSubSelector && (context.element->isLink() || (relation != CSS
Selector::Descendant && relation != CSSSelector::Child))) |
| 321 nextContext.visitedMatchType = VisitedMatchDisabled; | 330 nextContext.visitedMatchType = VisitedMatchDisabled; |
| (...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 416 case CSSSelector::ShadowDeep: | 425 case CSSSelector::ShadowDeep: |
| 417 { | 426 { |
| 418 if (!context.isUARule) | 427 if (!context.isUARule) |
| 419 UseCounter::countDeprecation(context.element->document(), UseCou
nter::CSSDeepCombinator); | 428 UseCounter::countDeprecation(context.element->document(), UseCou
nter::CSSDeepCombinator); |
| 420 if (ShadowRoot* root = context.element->containingShadowRoot()) { | 429 if (ShadowRoot* root = context.element->containingShadowRoot()) { |
| 421 if (root->type() == ShadowRootType::UserAgent) | 430 if (root->type() == ShadowRootType::UserAgent) |
| 422 return SelectorFailsCompletely; | 431 return SelectorFailsCompletely; |
| 423 } | 432 } |
| 424 | 433 |
| 425 if (context.selector->relationIsAffectedByPseudoContent()) { | 434 if (context.selector->relationIsAffectedByPseudoContent()) { |
| 435 // TODO(kochi): closed mode tree should be handled as well for :
:content. |
| 426 for (Element* element = context.element; element; element = elem
ent->parentOrShadowHostElement()) { | 436 for (Element* element = context.element; element; element = elem
ent->parentOrShadowHostElement()) { |
| 427 if (matchForShadowDistributed(nextContext, *element, result)
== SelectorMatches) | 437 if (matchForShadowDistributed(nextContext, *element, result)
== SelectorMatches) |
| 428 return SelectorMatches; | 438 return SelectorMatches; |
| 429 } | 439 } |
| 430 return SelectorFailsCompletely; | 440 return SelectorFailsCompletely; |
| 431 } | 441 } |
| 432 | 442 |
| 433 nextContext.isSubSelector = false; | 443 nextContext.isSubSelector = false; |
| 434 nextContext.inRightmostCompound = false; | 444 nextContext.inRightmostCompound = false; |
| 435 for (nextContext.element = context.element->parentOrShadowHostElemen
t(); nextContext.element; nextContext.element = nextContext.element->parentOrSha
dowHostElement()) { | 445 |
| 446 for (nextContext.element = parentOrShadowHostElementButDisallowClose
dShadowTree(*context.element); nextContext.element; nextContext.element = parent
OrShadowHostElementButDisallowClosedShadowTree(*nextContext.element)) { |
| 436 Match match = matchSelector(nextContext, result); | 447 Match match = matchSelector(nextContext, result); |
| 437 if (match == SelectorMatches || match == SelectorFailsCompletely
) | 448 if (match == SelectorMatches || match == SelectorFailsCompletely
) |
| 438 return match; | 449 return match; |
| 439 if (nextSelectorExceedsScope(nextContext)) | 450 if (nextSelectorExceedsScope(nextContext)) |
| 440 return SelectorFailsCompletely; | 451 return SelectorFailsCompletely; |
| 441 } | 452 } |
| 442 return SelectorFailsCompletely; | 453 return SelectorFailsCompletely; |
| 443 } | 454 } |
| 444 | 455 |
| 445 case CSSSelector::SubSelector: | 456 case CSSSelector::SubSelector: |
| (...skipping 731 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1177 } | 1188 } |
| 1178 | 1189 |
| 1179 bool SelectorChecker::matchesFocusPseudoClass(const Element& element) | 1190 bool SelectorChecker::matchesFocusPseudoClass(const Element& element) |
| 1180 { | 1191 { |
| 1181 if (InspectorInstrumentation::forcePseudoState(const_cast<Element*>(&element
), CSSSelector::PseudoFocus)) | 1192 if (InspectorInstrumentation::forcePseudoState(const_cast<Element*>(&element
), CSSSelector::PseudoFocus)) |
| 1182 return true; | 1193 return true; |
| 1183 return element.focused() && isFrameFocused(element); | 1194 return element.focused() && isFrameFocused(element); |
| 1184 } | 1195 } |
| 1185 | 1196 |
| 1186 } | 1197 } |
| OLD | NEW |