Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(79)

Side by Side Diff: Source/core/css/SelectorChecker.cpp

Issue 1329523002: Revert of document.querySelector[All]() should check selector context (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 5 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 942 matching lines...) Expand 10 before | Expand all | Expand 10 after
953 if (m_mode == ResolvingStyle) 953 if (m_mode == ResolvingStyle)
954 element.document().setContainsValidityStyleRules(); 954 element.document().setContainsValidityStyleRules();
955 return element.isOutOfRange(); 955 return element.isOutOfRange();
956 case CSSSelector::PseudoFutureCue: 956 case CSSSelector::PseudoFutureCue:
957 return element.isVTTElement() && !toVTTElement(element).isPastNode(); 957 return element.isVTTElement() && !toVTTElement(element).isPastNode();
958 case CSSSelector::PseudoPastCue: 958 case CSSSelector::PseudoPastCue:
959 return element.isVTTElement() && toVTTElement(element).isPastNode(); 959 return element.isVTTElement() && toVTTElement(element).isPastNode();
960 case CSSSelector::PseudoScope: 960 case CSSSelector::PseudoScope:
961 if (m_mode == SharingRules) 961 if (m_mode == SharingRules)
962 return true; 962 return true;
963 if (context.scope == element.document()) 963 if (context.scope)
964 return element == element.document().documentElement(); 964 return context.scope == element;
965 return context.scope == element; 965 return element == element.document().documentElement();
966 case CSSSelector::PseudoUnresolved: 966 case CSSSelector::PseudoUnresolved:
967 return element.isUnresolvedCustomElement(); 967 return element.isUnresolvedCustomElement();
968 case CSSSelector::PseudoHost: 968 case CSSSelector::PseudoHost:
969 case CSSSelector::PseudoHostContext: 969 case CSSSelector::PseudoHostContext:
970 return checkPseudoHost(context, result); 970 return checkPseudoHost(context, result);
971 case CSSSelector::PseudoSpatialNavigationFocus: 971 case CSSSelector::PseudoSpatialNavigationFocus:
972 return context.isUARule && matchesSpatialNavigationFocusPseudoClass(elem ent); 972 return context.isUARule && matchesSpatialNavigationFocusPseudoClass(elem ent);
973 case CSSSelector::PseudoListBox: 973 case CSSSelector::PseudoListBox:
974 return context.isUARule && matchesListBoxPseudoClass(element); 974 return context.isUARule && matchesListBoxPseudoClass(element);
975 case CSSSelector::PseudoWindowInactive: 975 case CSSSelector::PseudoWindowInactive:
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
1043 } 1043 }
1044 1044
1045 bool SelectorChecker::checkPseudoHost(const SelectorCheckingContext& context, Ma tchResult& result) const 1045 bool SelectorChecker::checkPseudoHost(const SelectorCheckingContext& context, Ma tchResult& result) const
1046 { 1046 {
1047 const CSSSelector& selector = *context.selector; 1047 const CSSSelector& selector = *context.selector;
1048 Element& element = *context.element; 1048 Element& element = *context.element;
1049 1049
1050 if (m_mode == SharingRules) 1050 if (m_mode == SharingRules)
1051 return true; 1051 return true;
1052 // :host only matches a shadow host when :host is in a shadow tree of the sh adow host. 1052 // :host only matches a shadow host when :host is in a shadow tree of the sh adow host.
1053 if (!context.scope)
1054 return false;
1053 const ContainerNode* shadowHost = context.scope->shadowHost(); 1055 const ContainerNode* shadowHost = context.scope->shadowHost();
1054 if (!shadowHost || shadowHost != element) 1056 if (!shadowHost || shadowHost != element)
1055 return false; 1057 return false;
1056 ASSERT(element.shadow()); 1058 ASSERT(element.shadow());
1057 1059
1058 // For empty parameter case, i.e. just :host or :host(). 1060 // For empty parameter case, i.e. just :host or :host().
1059 if (!selector.selectorList()) // Use *'s specificity. So just 0. 1061 if (!selector.selectorList()) // Use *'s specificity. So just 0.
1060 return true; 1062 return true;
1061 1063
1062 SelectorCheckingContext subContext(context); 1064 SelectorCheckingContext subContext(context);
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after
1186 } 1188 }
1187 1189
1188 bool SelectorChecker::matchesFocusPseudoClass(const Element& element) 1190 bool SelectorChecker::matchesFocusPseudoClass(const Element& element)
1189 { 1191 {
1190 if (InspectorInstrumentation::forcePseudoState(const_cast<Element*>(&element ), CSSSelector::PseudoFocus)) 1192 if (InspectorInstrumentation::forcePseudoState(const_cast<Element*>(&element ), CSSSelector::PseudoFocus))
1191 return true; 1193 return true;
1192 return element.focused() && isFrameFocused(element); 1194 return element.focused() && isFrameFocused(element);
1193 } 1195 }
1194 1196
1195 } 1197 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698