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(); |