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

Side by Side Diff: Source/core/dom/SelectorQuery.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
« no previous file with comments | « Source/core/css/SelectorChecker.cpp ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2011, 2013 Apple Inc. All rights reserved. 2 * Copyright (C) 2011, 2013 Apple Inc. All rights reserved.
3 * Copyright (C) 2014 Samsung Electronics. All rights reserved. 3 * Copyright (C) 2014 Samsung Electronics. All rights reserved.
4 * 4 *
5 * Redistribution and use in source and binary forms, with or without 5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions 6 * modification, are permitted provided that the following conditions
7 * are met: 7 * are met:
8 * 8 *
9 * 1. Redistributions of source code must retain the above copyright 9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer. 10 * notice, this list of conditions and the following disclaimer.
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
115 m_crossesTreeBoundary |= selectorList.selectorCrossesTreeScopes(index); 115 m_crossesTreeBoundary |= selectorList.selectorCrossesTreeScopes(index);
116 m_needsUpdatedDistribution |= selectorList.selectorNeedsUpdatedDistribut ion(index); 116 m_needsUpdatedDistribution |= selectorList.selectorNeedsUpdatedDistribut ion(index);
117 } 117 }
118 } 118 }
119 119
120 inline bool SelectorDataList::selectorMatches(const CSSSelector& selector, Eleme nt& element, const ContainerNode& rootNode) const 120 inline bool SelectorDataList::selectorMatches(const CSSSelector& selector, Eleme nt& element, const ContainerNode& rootNode) const
121 { 121 {
122 SelectorChecker selectorChecker(SelectorChecker::QueryingRules); 122 SelectorChecker selectorChecker(SelectorChecker::QueryingRules);
123 SelectorChecker::SelectorCheckingContext selectorCheckingContext(&element, S electorChecker::VisitedMatchDisabled); 123 SelectorChecker::SelectorCheckingContext selectorCheckingContext(&element, S electorChecker::VisitedMatchDisabled);
124 selectorCheckingContext.selector = &selector; 124 selectorCheckingContext.selector = &selector;
125 selectorCheckingContext.scope = &rootNode; 125 selectorCheckingContext.scope = !rootNode.isDocumentNode() ? &rootNode : nul lptr;
126 selectorCheckingContext.scopeContainsLastMatchedElement = true; 126 if (selectorCheckingContext.scope)
127 selectorCheckingContext.scopeContainsLastMatchedElement = true;
127 return selectorChecker.match(selectorCheckingContext); 128 return selectorChecker.match(selectorCheckingContext);
128 } 129 }
129 130
130 bool SelectorDataList::matches(Element& targetElement) const 131 bool SelectorDataList::matches(Element& targetElement) const
131 { 132 {
132 if (m_needsUpdatedDistribution) 133 if (m_needsUpdatedDistribution)
133 targetElement.updateDistribution(); 134 targetElement.updateDistribution();
134 135
135 unsigned selectorCount = m_selectors.size(); 136 unsigned selectorCount = m_selectors.size();
136 for (unsigned i = 0; i < selectorCount; ++i) { 137 for (unsigned i = 0; i < selectorCount; ++i) {
(...skipping 432 matching lines...) Expand 10 before | Expand all | Expand 10 after
569 570
570 return m_entries.add(selectors, SelectorQuery::adopt(selectorList)).storedVa lue->value.get(); 571 return m_entries.add(selectors, SelectorQuery::adopt(selectorList)).storedVa lue->value.get();
571 } 572 }
572 573
573 void SelectorQueryCache::invalidate() 574 void SelectorQueryCache::invalidate()
574 { 575 {
575 m_entries.clear(); 576 m_entries.clear();
576 } 577 }
577 578
578 } 579 }
OLDNEW
« no previous file with comments | « Source/core/css/SelectorChecker.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698