| 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. | 5 * Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013 Apple Inc. |
| 6 * All rights reserved. | 6 * All rights reserved. |
| 7 * Copyright (C) 2007 Alexey Proskuryakov <ap@webkit.org> | 7 * Copyright (C) 2007 Alexey Proskuryakov <ap@webkit.org> |
| 8 * Copyright (C) 2007, 2008 Eric Seidel <eric@webkit.org> | 8 * Copyright (C) 2007, 2008 Eric Seidel <eric@webkit.org> |
| 9 * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. | 9 * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. |
| 10 * (http://www.torchmobile.com/) | 10 * (http://www.torchmobile.com/) |
| (...skipping 267 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 278 } | 278 } |
| 279 | 279 |
| 280 static inline Element* parentOrV0ShadowHostElement(const Element& element) { | 280 static inline Element* parentOrV0ShadowHostElement(const Element& element) { |
| 281 if (element.parentNode() && element.parentNode()->isShadowRoot()) { | 281 if (element.parentNode() && element.parentNode()->isShadowRoot()) { |
| 282 if (toShadowRoot(element.parentNode())->type() != ShadowRootType::V0) | 282 if (toShadowRoot(element.parentNode())->type() != ShadowRootType::V0) |
| 283 return nullptr; | 283 return nullptr; |
| 284 } | 284 } |
| 285 return element.parentOrShadowHostElement(); | 285 return element.parentOrShadowHostElement(); |
| 286 } | 286 } |
| 287 | 287 |
| 288 static inline Element* parentOrOpenShadowHostElement(const Element& element) { |
| 289 if (element.parentNode() && element.parentNode()->isShadowRoot()) { |
| 290 if (toShadowRoot(element.parentNode())->type() != ShadowRootType::Open) |
| 291 return nullptr; |
| 292 } |
| 293 return element.parentOrShadowHostElement(); |
| 294 } |
| 295 |
| 288 SelectorChecker::Match SelectorChecker::matchForRelation( | 296 SelectorChecker::Match SelectorChecker::matchForRelation( |
| 289 const SelectorCheckingContext& context, | 297 const SelectorCheckingContext& context, |
| 290 MatchResult& result) const { | 298 MatchResult& result) const { |
| 291 SelectorCheckingContext nextContext = prepareNextContextForRelation(context); | 299 SelectorCheckingContext nextContext = prepareNextContextForRelation(context); |
| 292 | 300 |
| 293 CSSSelector::RelationType relation = context.selector->relation(); | 301 CSSSelector::RelationType relation = context.selector->relation(); |
| 294 | 302 |
| 295 // Disable :visited matching when we see the first link or try to match | 303 // Disable :visited matching when we see the first link or try to match |
| 296 // anything else than an ancestors. | 304 // anything else than an ancestors. |
| 297 if (!context.isSubSelector && | 305 if (!context.isSubSelector && |
| (...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 431 UseCounter::count(context.element->document(), | 439 UseCounter::count(context.element->document(), |
| 432 UseCounter::CSSDeepCombinatorAndShadow); | 440 UseCounter::CSSDeepCombinatorAndShadow); |
| 433 if (match == SelectorMatches || match == SelectorFailsCompletely) | 441 if (match == SelectorMatches || match == SelectorFailsCompletely) |
| 434 return match; | 442 return match; |
| 435 if (nextSelectorExceedsScope(nextContext)) | 443 if (nextSelectorExceedsScope(nextContext)) |
| 436 return SelectorFailsCompletely; | 444 return SelectorFailsCompletely; |
| 437 } | 445 } |
| 438 return SelectorFailsCompletely; | 446 return SelectorFailsCompletely; |
| 439 } | 447 } |
| 440 | 448 |
| 449 case CSSSelector::ShadowPiercingDescendant: { |
| 450 DCHECK(m_isQuerySelector); |
| 451 // TODO(kochi): parentOrOpenShadowHostElement() is necessary because |
| 452 // SelectorQuery can pass V0 shadow roots. All closed shadow roots are |
| 453 // already filtered out, thus once V0 is removed this logic can use |
| 454 // parentOrShadowHostElement() instead. |
| 455 for (nextContext.element = |
| 456 parentOrOpenShadowHostElement(*context.element); |
| 457 nextContext.element; |
| 458 nextContext.element = |
| 459 parentOrOpenShadowHostElement(*nextContext.element)) { |
| 460 Match match = matchSelector(nextContext, result); |
| 461 if (match == SelectorMatches || match == SelectorFailsCompletely) |
| 462 return match; |
| 463 if (nextSelectorExceedsScope(nextContext)) |
| 464 break; |
| 465 } |
| 466 return SelectorFailsCompletely; |
| 467 } |
| 468 |
| 441 case CSSSelector::ShadowSlot: { | 469 case CSSSelector::ShadowSlot: { |
| 442 const HTMLSlotElement* slot = findSlotElementInScope(context); | 470 const HTMLSlotElement* slot = findSlotElementInScope(context); |
| 443 if (!slot) | 471 if (!slot) |
| 444 return SelectorFailsCompletely; | 472 return SelectorFailsCompletely; |
| 445 | 473 |
| 446 nextContext.element = const_cast<HTMLSlotElement*>(slot); | 474 nextContext.element = const_cast<HTMLSlotElement*>(slot); |
| 447 return matchSelector(nextContext, result); | 475 return matchSelector(nextContext, result); |
| 448 } | 476 } |
| 449 | 477 |
| 450 case CSSSelector::SubSelector: | 478 case CSSSelector::SubSelector: |
| (...skipping 826 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1277 } | 1305 } |
| 1278 | 1306 |
| 1279 bool SelectorChecker::matchesFocusPseudoClass(const Element& element) { | 1307 bool SelectorChecker::matchesFocusPseudoClass(const Element& element) { |
| 1280 if (InspectorInstrumentation::forcePseudoState(const_cast<Element*>(&element), | 1308 if (InspectorInstrumentation::forcePseudoState(const_cast<Element*>(&element), |
| 1281 CSSSelector::PseudoFocus)) | 1309 CSSSelector::PseudoFocus)) |
| 1282 return true; | 1310 return true; |
| 1283 return element.isFocused() && isFrameFocused(element); | 1311 return element.isFocused() && isFrameFocused(element); |
| 1284 } | 1312 } |
| 1285 | 1313 |
| 1286 } // namespace blink | 1314 } // namespace blink |
| OLD | NEW |