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

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

Issue 2786493003: Inline SelectorQuery::executeForTraverseRoots into findTraverseRootsAndExecute. (Closed)
Patch Set: Created 3 years, 9 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
« no previous file with comments | « third_party/WebKit/Source/core/dom/SelectorQuery.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 491660ce42756269e7ee9eb4630669f89f858713..ac733e76dd62f969c43d9ace284bfba432c4bc2a 100644
--- a/third_party/WebKit/Source/core/dom/SelectorQuery.cpp
+++ b/third_party/WebKit/Source/core/dom/SelectorQuery.cpp
@@ -278,20 +278,26 @@ void SelectorQuery::findTraverseRootsAndExecute(
if (isRightmostSelector) {
ClassElementList<AllElements> traverseRoots(rootNode,
selector->value());
- executeForTraverseRoots<SelectorQueryTrait>(
- traverseRoots, MatchesTraverseRoots, rootNode, output);
+ while (!traverseRoots.isEmpty()) {
+ Element& element = *traverseRoots.next();
+ if (selectorMatches(*m_selectors[0], element, rootNode))
+ SelectorQueryTrait::appendElement(output, element);
+ }
return;
}
// Since there exists some ancestor element which has the class name, we
// need to see all children of rootNode.
- if (ancestorHasClassName(rootNode, selector->value())) {
- executeForTraverseRoot<SelectorQueryTrait>(&rootNode, rootNode, output);
- return;
- }
+ if (ancestorHasClassName(rootNode, selector->value()))
+ break;
esprehn 2017/03/29 05:00:43 This was just executing the code below if we had n
ClassElementList<OnlyRoots> traverseRoots(rootNode, selector->value());
- executeForTraverseRoots<SelectorQueryTrait>(
- traverseRoots, DoesNotMatchTraverseRoots, rootNode, output);
+ while (!traverseRoots.isEmpty()) {
+ for (Element& element :
+ ElementTraversal::descendantsOf(*traverseRoots.next())) {
+ if (selectorMatches(*m_selectors[0], element, rootNode))
+ SelectorQueryTrait::appendElement(output, element);
+ }
+ }
return;
}
@@ -328,43 +334,6 @@ void SelectorQuery::executeForTraverseRoot(
}
}
-template <typename SelectorQueryTrait, typename SimpleElementListType>
-void SelectorQuery::executeForTraverseRoots(
- SimpleElementListType& traverseRoots,
- MatchTraverseRootState matchTraverseRoots,
- ContainerNode& rootNode,
- typename SelectorQueryTrait::OutputType& output) const {
- DCHECK_EQ(m_selectors.size(), 1u);
-
- if (traverseRoots.isEmpty())
- return;
-
- const CSSSelector& selector = *m_selectors[0];
-
- if (matchTraverseRoots) {
- while (!traverseRoots.isEmpty()) {
- Element& element = *traverseRoots.next();
- if (selectorMatches(selector, element, rootNode)) {
- SelectorQueryTrait::appendElement(output, element);
- if (SelectorQueryTrait::shouldOnlyMatchFirstElement)
- return;
- }
- }
- return;
- }
-
- while (!traverseRoots.isEmpty()) {
- for (Element& element :
- ElementTraversal::descendantsOf(*traverseRoots.next())) {
- if (selectorMatches(selector, element, rootNode)) {
- SelectorQueryTrait::appendElement(output, element);
- if (SelectorQueryTrait::shouldOnlyMatchFirstElement)
- return;
- }
- }
- }
-}
-
template <typename SelectorQueryTrait>
bool SelectorQuery::selectorListMatches(
ContainerNode& rootNode,
« no previous file with comments | « third_party/WebKit/Source/core/dom/SelectorQuery.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698