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 580 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
591 subContext.isSubSelector = true; | 591 subContext.isSubSelector = true; |
592 ASSERT(selector.selectorList()); | 592 ASSERT(selector.selectorList()); |
593 for (subContext.selector = selector.selectorList()->first(); subContext.sele
ctor; subContext.selector = subContext.selector->tagHistory()) { | 593 for (subContext.selector = selector.selectorList()->first(); subContext.sele
ctor; subContext.selector = subContext.selector->tagHistory()) { |
594 // :not cannot nest. I don't really know why this is a | 594 // :not cannot nest. I don't really know why this is a |
595 // restriction in CSS3, but it is, so let's honor it. | 595 // restriction in CSS3, but it is, so let's honor it. |
596 // the parser enforces that this never occurs | 596 // the parser enforces that this never occurs |
597 ASSERT(subContext.selector->getPseudoType() != CSSSelector::PseudoNot); | 597 ASSERT(subContext.selector->getPseudoType() != CSSSelector::PseudoNot); |
598 // We select between :visited and :link when applying. We don't know whi
ch one applied (or not) yet. | 598 // We select between :visited and :link when applying. We don't know whi
ch one applied (or not) yet. |
599 if (subContext.selector->getPseudoType() == CSSSelector::PseudoVisited |
| (subContext.selector->getPseudoType() == CSSSelector::PseudoLink && subContext
.visitedMatchType == VisitedMatchEnabled)) | 599 if (subContext.selector->getPseudoType() == CSSSelector::PseudoVisited |
| (subContext.selector->getPseudoType() == CSSSelector::PseudoLink && subContext
.visitedMatchType == VisitedMatchEnabled)) |
600 return true; | 600 return true; |
601 // context.scope is not available if m_mode == SharingRules. | 601 if (m_mode == SharingRules) { |
602 // We cannot determine whether :host or :scope matches a given element o
r not. | 602 // context.scope is not available if m_mode == SharingRules. |
603 if (m_mode == SharingRules && (subContext.selector->isHostPseudoClass()
|| subContext.selector->getPseudoType() == CSSSelector::PseudoScope)) | 603 // We cannot determine whether :host or :scope matches a given eleme
nt or not. |
604 return true; | 604 if (subContext.selector->isHostPseudoClass() || subContext.selector-
>getPseudoType() == CSSSelector::PseudoScope) |
| 605 return true; |
| 606 // :hover, :active, :focus, :-webkit-drag relies on setting flags on |
| 607 // ComputedStyle even if the whole selector may not match. That |
| 608 // means we cannot share style between elements which may fail |
| 609 // matching the same selector for different reasons. An example is |
| 610 // [attr]:hover which both fail for :hover, but an element without |
| 611 // attr won't reach the :hover selector, hence not setting the bit. |
| 612 if (subContext.selector->isUserActionPseudoClass()) |
| 613 return true; |
| 614 } |
605 if (!checkOne(subContext, result)) | 615 if (!checkOne(subContext, result)) |
606 return true; | 616 return true; |
607 } | 617 } |
608 return false; | 618 return false; |
609 } | 619 } |
610 | 620 |
611 bool SelectorChecker::checkPseudoClass(const SelectorCheckingContext& context, M
atchResult& result) const | 621 bool SelectorChecker::checkPseudoClass(const SelectorCheckingContext& context, M
atchResult& result) const |
612 { | 622 { |
613 Element& element = *context.element; | 623 Element& element = *context.element; |
614 const CSSSelector& selector = *context.selector; | 624 const CSSSelector& selector = *context.selector; |
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
758 } | 768 } |
759 break; | 769 break; |
760 case CSSSelector::PseudoAutofill: | 770 case CSSSelector::PseudoAutofill: |
761 return element.isFormControlElement() && toHTMLFormControlElement(elemen
t).isAutofilled(); | 771 return element.isFormControlElement() && toHTMLFormControlElement(elemen
t).isAutofilled(); |
762 case CSSSelector::PseudoAnyLink: | 772 case CSSSelector::PseudoAnyLink: |
763 case CSSSelector::PseudoLink: | 773 case CSSSelector::PseudoLink: |
764 return element.isLink(); | 774 return element.isLink(); |
765 case CSSSelector::PseudoVisited: | 775 case CSSSelector::PseudoVisited: |
766 return element.isLink() && context.visitedMatchType == VisitedMatchEnabl
ed; | 776 return element.isLink() && context.visitedMatchType == VisitedMatchEnabl
ed; |
767 case CSSSelector::PseudoDrag: | 777 case CSSSelector::PseudoDrag: |
| 778 if (m_mode == SharingRules) |
| 779 return true; |
768 if (m_mode == ResolvingStyle) { | 780 if (m_mode == ResolvingStyle) { |
769 if (context.inRightmostCompound) { | 781 if (context.inRightmostCompound) { |
770 m_elementStyle->setAffectedByDrag(); | 782 m_elementStyle->setAffectedByDrag(); |
771 } else { | 783 } else { |
772 m_elementStyle->setUnique(); | 784 m_elementStyle->setUnique(); |
773 element.setChildrenOrSiblingsAffectedByDrag(); | 785 element.setChildrenOrSiblingsAffectedByDrag(); |
774 } | 786 } |
775 } | 787 } |
776 return element.isDragged(); | 788 return element.isDragged(); |
777 case CSSSelector::PseudoFocus: | 789 case CSSSelector::PseudoFocus: |
| 790 if (m_mode == SharingRules) |
| 791 return true; |
778 if (m_mode == ResolvingStyle) { | 792 if (m_mode == ResolvingStyle) { |
779 if (context.inRightmostCompound) { | 793 if (context.inRightmostCompound) { |
780 m_elementStyle->setAffectedByFocus(); | 794 m_elementStyle->setAffectedByFocus(); |
781 } else { | 795 } else { |
782 m_elementStyle->setUnique(); | 796 m_elementStyle->setUnique(); |
783 element.setChildrenOrSiblingsAffectedByFocus(); | 797 element.setChildrenOrSiblingsAffectedByFocus(); |
784 } | 798 } |
785 } | 799 } |
786 return matchesFocusPseudoClass(element); | 800 return matchesFocusPseudoClass(element); |
787 case CSSSelector::PseudoHover: | 801 case CSSSelector::PseudoHover: |
| 802 if (m_mode == SharingRules) |
| 803 return true; |
788 if (m_mode == ResolvingStyle) { | 804 if (m_mode == ResolvingStyle) { |
789 if (context.inRightmostCompound) { | 805 if (context.inRightmostCompound) { |
790 m_elementStyle->setAffectedByHover(); | 806 m_elementStyle->setAffectedByHover(); |
791 } else { | 807 } else { |
792 m_elementStyle->setUnique(); | 808 m_elementStyle->setUnique(); |
793 element.setChildrenOrSiblingsAffectedByHover(); | 809 element.setChildrenOrSiblingsAffectedByHover(); |
794 } | 810 } |
795 } | 811 } |
796 if (!shouldMatchHoverOrActive(context)) | 812 if (!shouldMatchHoverOrActive(context)) |
797 return false; | 813 return false; |
798 if (InspectorInstrumentation::forcePseudoState(&element, CSSSelector::Ps
eudoHover)) | 814 if (InspectorInstrumentation::forcePseudoState(&element, CSSSelector::Ps
eudoHover)) |
799 return true; | 815 return true; |
800 return element.hovered(); | 816 return element.hovered(); |
801 case CSSSelector::PseudoActive: | 817 case CSSSelector::PseudoActive: |
| 818 if (m_mode == SharingRules) |
| 819 return true; |
802 if (m_mode == ResolvingStyle) { | 820 if (m_mode == ResolvingStyle) { |
803 if (context.inRightmostCompound) { | 821 if (context.inRightmostCompound) { |
804 m_elementStyle->setAffectedByActive(); | 822 m_elementStyle->setAffectedByActive(); |
805 } else { | 823 } else { |
806 m_elementStyle->setUnique(); | 824 m_elementStyle->setUnique(); |
807 element.setChildrenOrSiblingsAffectedByActive(); | 825 element.setChildrenOrSiblingsAffectedByActive(); |
808 } | 826 } |
809 } | 827 } |
810 if (!shouldMatchHoverOrActive(context)) | 828 if (!shouldMatchHoverOrActive(context)) |
811 return false; | 829 return false; |
(...skipping 332 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1144 } | 1162 } |
1145 | 1163 |
1146 bool SelectorChecker::matchesFocusPseudoClass(const Element& element) | 1164 bool SelectorChecker::matchesFocusPseudoClass(const Element& element) |
1147 { | 1165 { |
1148 if (InspectorInstrumentation::forcePseudoState(const_cast<Element*>(&element
), CSSSelector::PseudoFocus)) | 1166 if (InspectorInstrumentation::forcePseudoState(const_cast<Element*>(&element
), CSSSelector::PseudoFocus)) |
1149 return true; | 1167 return true; |
1150 return element.focused() && isFrameFocused(element); | 1168 return element.focused() && isFrameFocused(element); |
1151 } | 1169 } |
1152 | 1170 |
1153 } // namespace blink | 1171 } // namespace blink |
OLD | NEW |