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

Unified Diff: third_party/WebKit/Source/core/dom/SelectorQuery.cpp

Issue 1602833002: No pseudo elements in SelectorChecker::Mode QueryingRules. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@remove-pseudoelm-check-2-20160118
Patch Set: CORE_EXPORT for unit test in component build Created 4 years, 11 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: third_party/WebKit/Source/core/dom/SelectorQuery.cpp
diff --git a/third_party/WebKit/Source/core/dom/SelectorQuery.cpp b/third_party/WebKit/Source/core/dom/SelectorQuery.cpp
index 37dbb07d7b9f13cb226c907fc9ebaf572d6cd496..5f564799ea05ecb9bf5fcb9b88a5f8f9dbb879b8 100644
--- a/third_party/WebKit/Source/core/dom/SelectorQuery.cpp
+++ b/third_party/WebKit/Source/core/dom/SelectorQuery.cpp
@@ -109,10 +109,13 @@ void SelectorDataList::initialize(const CSSSelectorList& selectorList)
m_needsUpdatedDistribution = false;
m_selectors.reserveInitialCapacity(selectorCount);
unsigned index = 0;
- for (const CSSSelector* selector = selectorList.first(); selector; selector = CSSSelectorList::next(*selector), ++index) {
+ for (const CSSSelector* selector = selectorList.first(); selector; selector = CSSSelectorList::next(*selector)) {
+ if (selector->matchesPseudoElement())
+ continue;
esprehn 2016/01/29 02:42:17 why is it safe not to increment index here? That m
rune 2016/01/29 09:53:20 Ouch, that's not correct. Will fix.
rune 2016/01/29 10:58:43 Done.
m_selectors.uncheckedAppend(selector);
m_usesDeepCombinatorOrShadowPseudo |= selectorList.selectorUsesDeepCombinatorOrShadowPseudo(index);
m_needsUpdatedDistribution |= selectorList.selectorNeedsUpdatedDistribution(index);
+ ++index;
}
}
@@ -141,10 +144,13 @@ bool SelectorDataList::matches(Element& targetElement) const
Element* SelectorDataList::closest(Element& targetElement) const
{
+ unsigned selectorCount = m_selectors.size();
+ if (!selectorCount)
+ return nullptr;
+
if (m_needsUpdatedDistribution)
targetElement.updateDistribution();
- unsigned selectorCount = m_selectors.size();
for (Element* currentElement = &targetElement; currentElement; currentElement = currentElement->parentElement()) {
for (unsigned i = 0; i < selectorCount; ++i) {
if (selectorMatches(*m_selectors[i], *currentElement, targetElement))
@@ -451,6 +457,9 @@ const CSSSelector* SelectorDataList::selectorForIdLookup(const CSSSelector& firs
template <typename SelectorQueryTrait>
void SelectorDataList::execute(ContainerNode& rootNode, typename SelectorQueryTrait::OutputType& output) const
{
+ if (!m_selectors.size())
+ return;
+
if (!canUseFastQuery(rootNode)) {
if (m_needsUpdatedDistribution)
rootNode.updateDistribution();
« no previous file with comments | « third_party/WebKit/Source/core/dom/SelectorQuery.h ('k') | third_party/WebKit/Source/core/dom/SelectorQueryTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698