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

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

Issue 153073002: Use stricter typing for traverse roots in SelectorQuery (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 6 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
« no previous file with comments | « 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: Source/core/dom/SelectorQuery.cpp
diff --git a/Source/core/dom/SelectorQuery.cpp b/Source/core/dom/SelectorQuery.cpp
index 460efd20200721da4d96a0dbe947fd5fcc7dabfd..32c1867265480cf613f8f9cff456c1236017c34b 100644
--- a/Source/core/dom/SelectorQuery.cpp
+++ b/Source/core/dom/SelectorQuery.cpp
@@ -70,9 +70,9 @@ public:
bool isEmpty() const { return !m_currentElement; }
- Node* next()
+ Element* next()
{
- Node* current = m_currentElement;
+ Element* current = m_currentElement;
ASSERT(current);
if (onlyRoots)
m_currentElement = nextInternal(ElementTraversal::nextSkippingChildren(*m_currentElement, &m_rootNode));
@@ -261,7 +261,7 @@ void SelectorDataList::findTraverseRootsAndExecute(ContainerNode& rootNode, type
}
template <typename SelectorQueryTrait>
-void SelectorDataList::executeForTraverseRoot(const SelectorData& selector, Node* traverseRoot, MatchTraverseRootState matchTraverseRoot, ContainerNode& rootNode, typename SelectorQueryTrait::OutputType& output) const
+void SelectorDataList::executeForTraverseRoot(const SelectorData& selector, ContainerNode* traverseRoot, MatchTraverseRootState matchTraverseRoot, ContainerNode& rootNode, typename SelectorQueryTrait::OutputType& output) const
{
if (!traverseRoot)
return;
@@ -281,16 +281,15 @@ void SelectorDataList::executeForTraverseRoot(const SelectorData& selector, Node
}
}
-template <typename SelectorQueryTrait, typename SimpleNodeListType>
-void SelectorDataList::executeForTraverseRoots(const SelectorData& selector, SimpleNodeListType& traverseRoots, MatchTraverseRootState matchTraverseRoots, ContainerNode& rootNode, typename SelectorQueryTrait::OutputType& output) const
+template <typename SelectorQueryTrait, typename SimpleElementListType>
+void SelectorDataList::executeForTraverseRoots(const SelectorData& selector, SimpleElementListType& traverseRoots, MatchTraverseRootState matchTraverseRoots, ContainerNode& rootNode, typename SelectorQueryTrait::OutputType& output) const
{
if (traverseRoots.isEmpty())
return;
if (matchTraverseRoots) {
while (!traverseRoots.isEmpty()) {
- Node& node = *traverseRoots.next();
- Element& element = toElement(node);
+ Element& element = *traverseRoots.next();
if (selectorMatches(selector, element, rootNode)) {
SelectorQueryTrait::appendElement(output, element);
if (SelectorQueryTrait::shouldOnlyMatchFirstElement)
@@ -301,9 +300,8 @@ void SelectorDataList::executeForTraverseRoots(const SelectorData& selector, Sim
}
while (!traverseRoots.isEmpty()) {
- Node* traverseRoot = traverseRoots.next();
- ASSERT(traverseRoot);
- for (Element* element = ElementTraversal::firstWithin(*traverseRoot); element; element = ElementTraversal::next(*element, traverseRoot)) {
+ Element& traverseRoot = *traverseRoots.next();
+ for (Element* element = ElementTraversal::firstWithin(traverseRoot); element; element = ElementTraversal::next(*element, &traverseRoot)) {
if (selectorMatches(selector, *element, rootNode)) {
SelectorQueryTrait::appendElement(output, *element);
if (SelectorQueryTrait::shouldOnlyMatchFirstElement)
« no previous file with comments | « Source/core/dom/SelectorQuery.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698