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 379 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
390 { | 390 { |
391 const HTMLSlotElement* slot = findSlotElementInScope(context); | 391 const HTMLSlotElement* slot = findSlotElementInScope(context); |
392 if (!slot) | 392 if (!slot) |
393 return SelectorFailsCompletely; | 393 return SelectorFailsCompletely; |
394 | 394 |
395 nextContext.element = const_cast<HTMLSlotElement*>(slot); | 395 nextContext.element = const_cast<HTMLSlotElement*>(slot); |
396 return matchSelector(nextContext, result); | 396 return matchSelector(nextContext, result); |
397 } | 397 } |
398 | 398 |
399 case CSSSelector::SubSelector: | 399 case CSSSelector::SubSelector: |
400 ASSERT_NOT_REACHED(); | 400 break; |
401 } | 401 } |
402 | |
403 ASSERT_NOT_REACHED(); | 402 ASSERT_NOT_REACHED(); |
404 return SelectorFailsCompletely; | 403 return SelectorFailsCompletely; |
405 } | 404 } |
406 | 405 |
407 SelectorChecker::Match SelectorChecker::matchForPseudoContent(const SelectorChec
kingContext& context, const Element& element, MatchResult& result) const | 406 SelectorChecker::Match SelectorChecker::matchForPseudoContent(const SelectorChec
kingContext& context, const Element& element, MatchResult& result) const |
408 { | 407 { |
409 HeapVector<Member<InsertionPoint>, 8> insertionPoints; | 408 HeapVector<Member<InsertionPoint>, 8> insertionPoints; |
410 collectDestinationInsertionPoints(element, insertionPoints); | 409 collectDestinationInsertionPoints(element, insertionPoints); |
411 SelectorCheckingContext nextContext(context); | 410 SelectorCheckingContext nextContext(context); |
412 for (const auto& insertionPoint : insertionPoints) { | 411 for (const auto& insertionPoint : insertionPoints) { |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
488 case CSSSelector::AttributeHyphen: | 487 case CSSSelector::AttributeHyphen: |
489 if (value.length() < selectorValue.length()) | 488 if (value.length() < selectorValue.length()) |
490 return false; | 489 return false; |
491 if (!value.startsWith(selectorValue, caseSensitivity)) | 490 if (!value.startsWith(selectorValue, caseSensitivity)) |
492 return false; | 491 return false; |
493 // It they start the same, check for exact match or following '-': | 492 // It they start the same, check for exact match or following '-': |
494 if (value.length() != selectorValue.length() && value[selectorValue.leng
th()] != '-') | 493 if (value.length() != selectorValue.length() && value[selectorValue.leng
th()] != '-') |
495 return false; | 494 return false; |
496 return true; | 495 return true; |
497 default: | 496 default: |
498 break; | 497 ASSERT_NOT_REACHED(); |
| 498 return false; |
499 } | 499 } |
500 | |
501 ASSERT_NOT_REACHED(); | |
502 return true; | |
503 } | 500 } |
504 | 501 |
505 static bool anyAttributeMatches(Element& element, CSSSelector::MatchType match,
const CSSSelector& selector) | 502 static bool anyAttributeMatches(Element& element, CSSSelector::MatchType match,
const CSSSelector& selector) |
506 { | 503 { |
507 const QualifiedName& selectorAttr = selector.attribute(); | 504 const QualifiedName& selectorAttr = selector.attribute(); |
508 ASSERT(selectorAttr.localName() != starAtom); // Should not be possible from
the CSS grammar. | 505 ASSERT(selectorAttr.localName() != starAtom); // Should not be possible from
the CSS grammar. |
509 | 506 |
510 // Synchronize the attribute in case it is lazy-computed. | 507 // Synchronize the attribute in case it is lazy-computed. |
511 // Currently all lazy properties have a null namespace, so only pass localNa
me(). | 508 // Currently all lazy properties have a null namespace, so only pass localNa
me(). |
512 element.synchronizeAttribute(selectorAttr.localName()); | 509 element.synchronizeAttribute(selectorAttr.localName()); |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
575 case CSSSelector::AttributeContain: | 572 case CSSSelector::AttributeContain: |
576 case CSSSelector::AttributeBegin: | 573 case CSSSelector::AttributeBegin: |
577 case CSSSelector::AttributeEnd: | 574 case CSSSelector::AttributeEnd: |
578 return anyAttributeMatches(element, selector.match(), selector); | 575 return anyAttributeMatches(element, selector.match(), selector); |
579 | 576 |
580 case CSSSelector::PseudoClass: | 577 case CSSSelector::PseudoClass: |
581 return checkPseudoClass(context, result); | 578 return checkPseudoClass(context, result); |
582 case CSSSelector::PseudoElement: | 579 case CSSSelector::PseudoElement: |
583 return checkPseudoElement(context, result); | 580 return checkPseudoElement(context, result); |
584 | 581 |
585 case CSSSelector::PagePseudoClass: | 582 default: |
586 // FIXME: what? | 583 ASSERT_NOT_REACHED(); |
587 return true; | 584 return false; |
588 case CSSSelector::Unknown: | |
589 // FIXME: what? | |
590 return true; | |
591 } | 585 } |
592 ASSERT_NOT_REACHED(); | |
593 return true; | |
594 } | 586 } |
595 | 587 |
596 bool SelectorChecker::checkPseudoNot(const SelectorCheckingContext& context, Mat
chResult& result) const | 588 bool SelectorChecker::checkPseudoNot(const SelectorCheckingContext& context, Mat
chResult& result) const |
597 { | 589 { |
598 const CSSSelector& selector = *context.selector; | 590 const CSSSelector& selector = *context.selector; |
599 | 591 |
600 SelectorCheckingContext subContext(context); | 592 SelectorCheckingContext subContext(context); |
601 subContext.isSubSelector = true; | 593 subContext.isSubSelector = true; |
602 ASSERT(selector.selectorList()); | 594 ASSERT(selector.selectorList()); |
603 for (subContext.selector = selector.selectorList()->first(); subContext.sele
ctor; subContext.selector = subContext.selector->tagHistory()) { | 595 for (subContext.selector = selector.selectorList()->first(); subContext.sele
ctor; subContext.selector = subContext.selector->tagHistory()) { |
(...skipping 531 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1135 } | 1127 } |
1136 | 1128 |
1137 bool SelectorChecker::matchesFocusPseudoClass(const Element& element) | 1129 bool SelectorChecker::matchesFocusPseudoClass(const Element& element) |
1138 { | 1130 { |
1139 if (InspectorInstrumentation::forcePseudoState(const_cast<Element*>(&element
), CSSSelector::PseudoFocus)) | 1131 if (InspectorInstrumentation::forcePseudoState(const_cast<Element*>(&element
), CSSSelector::PseudoFocus)) |
1140 return true; | 1132 return true; |
1141 return element.focused() && isFrameFocused(element); | 1133 return element.focused() && isFrameFocused(element); |
1142 } | 1134 } |
1143 | 1135 |
1144 } // namespace blink | 1136 } // namespace blink |
OLD | NEW |