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

Unified Diff: Source/core/css/SelectorChecker.cpp

Issue 1245933002: document.querySelector[All]() should check selector context (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: . Created 5 years, 4 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 side-by-side diff with in-line comments
Download patch
Index: Source/core/css/SelectorChecker.cpp
diff --git a/Source/core/css/SelectorChecker.cpp b/Source/core/css/SelectorChecker.cpp
index 3dff0a3c6d52688f3f4a8310b1ce0c1dbf2cc49a..026f4f9f9a40b923e146a551342791cecf866859 100644
--- a/Source/core/css/SelectorChecker.cpp
+++ b/Source/core/css/SelectorChecker.cpp
@@ -960,9 +960,9 @@ bool SelectorChecker::checkPseudoClass(const SelectorCheckingContext& context, M
case CSSSelector::PseudoScope:
if (m_mode == SharingRules)
return true;
- if (context.scope)
- return context.scope == element;
- return element == element.document().documentElement();
+ if (context.scope == element.document())
+ return element == element.document().documentElement();
+ return context.scope == element;
case CSSSelector::PseudoUnresolved:
return element.isUnresolvedCustomElement();
case CSSSelector::PseudoHost:
@@ -1050,8 +1050,6 @@ bool SelectorChecker::checkPseudoHost(const SelectorCheckingContext& context, Ma
if (m_mode == SharingRules)
return true;
// :host only matches a shadow host when :host is in a shadow tree of the shadow host.
- if (!context.scope)
- return false;
const ContainerNode* shadowHost = context.scope->shadowHost();
if (!shadowHost || shadowHost != element)
return false;

Powered by Google App Engine
This is Rietveld 408576698