Chromium Code Reviews| 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 91257de398f7b08db78f4e7ff3ad411846ee4716..b0f36ea5d4b1417190f48b2d2545476ed27695b3 100644 |
| --- a/third_party/WebKit/Source/core/dom/SelectorQuery.cpp |
| +++ b/third_party/WebKit/Source/core/dom/SelectorQuery.cpp |
| @@ -110,6 +110,8 @@ void SelectorDataList::initialize(const CSSSelectorList& selectorList) |
| m_selectors.reserveInitialCapacity(selectorCount); |
| unsigned index = 0; |
| for (const CSSSelector* selector = selectorList.first(); selector; selector = CSSSelectorList::next(*selector), ++index) { |
| + if (selector->matchesPseudoElement()) |
| + continue; |
| m_selectors.uncheckedAppend(selector); |
| m_usesDeepCombinatorOrShadowPseudo |= selectorList.selectorUsesDeepCombinatorOrShadowPseudo(index); |
| m_needsUpdatedDistribution |= selectorList.selectorNeedsUpdatedDistribution(index); |
| @@ -141,10 +143,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 +456,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()) |
|
esprehn
2016/01/29 12:29:56
isEmpty() ?
rune
2016/01/29 12:43:13
Done.
|
| + return; |
| + |
| if (!canUseFastQuery(rootNode)) { |
| if (m_needsUpdatedDistribution) |
| rootNode.updateDistribution(); |