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

Unified Diff: Source/core/html/HTMLTableRowsCollection.cpp

Issue 179333004: Add template parameter to ElementTraversal to iterate over Elements of a specific type (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Fix failures and port more code to the new API Created 6 years, 10 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/TreeWalker.cpp ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/html/HTMLTableRowsCollection.cpp
diff --git a/Source/core/html/HTMLTableRowsCollection.cpp b/Source/core/html/HTMLTableRowsCollection.cpp
index 21efc2cb3945bcc7c270e51f37c3832656d863f8..d097f0659dde0d9a99b8d237e71e007e659b0733 100644
--- a/Source/core/html/HTMLTableRowsCollection.cpp
+++ b/Source/core/html/HTMLTableRowsCollection.cpp
@@ -55,11 +55,7 @@ static bool isInFoot(Element* row)
static inline HTMLTableRowElement* findTableRowElementInChildren(Element& current)
{
- for (Element* child = ElementTraversal::firstWithin(current); child; child = ElementTraversal::nextSibling(*child)) {
- if (isHTMLTableRowElement(child))
- return toHTMLTableRowElement(child);
- }
- return 0;
+ return Traversal<HTMLTableRowElement>::firstChild(current);
}
HTMLTableRowElement* HTMLTableRowsCollection::rowAfter(HTMLTableElement& table, HTMLTableRowElement* previous)
@@ -69,10 +65,8 @@ HTMLTableRowElement* HTMLTableRowsCollection::rowAfter(HTMLTableElement& table,
// Start by looking for the next row in this section.
// Continue only if there is none.
if (previous && previous->parentNode() != table) {
- for (child = ElementTraversal::nextSibling(*previous); child; child = ElementTraversal::nextSibling(*child)) {
- if (isHTMLTableRowElement(child))
- return toHTMLTableRowElement(child);
- }
+ if (HTMLTableRowElement* row = Traversal<HTMLTableRowElement>::nextSibling(*previous))
+ return row;
}
// If still looking at head sections, find the first row in the next head section.
@@ -122,10 +116,8 @@ HTMLTableRowElement* HTMLTableRowsCollection::lastRow(HTMLTableElement& table)
{
for (Node* child = table.lastChild(); child; child = child->previousSibling()) {
if (child->hasTagName(tfootTag)) {
- for (Node* grandchild = child->lastChild(); grandchild; grandchild = grandchild->previousSibling()) {
- if (isHTMLTableRowElement(grandchild))
- return toHTMLTableRowElement(grandchild);
- }
+ if (HTMLTableRowElement* lastRow = Traversal<HTMLTableRowElement>::lastChild(*child))
+ return lastRow;
}
}
@@ -133,19 +125,15 @@ HTMLTableRowElement* HTMLTableRowsCollection::lastRow(HTMLTableElement& table)
if (isHTMLTableRowElement(child))
return toHTMLTableRowElement(child);
if (child->hasTagName(tbodyTag)) {
- for (Node* grandchild = child->lastChild(); grandchild; grandchild = grandchild->previousSibling()) {
- if (isHTMLTableRowElement(grandchild))
- return toHTMLTableRowElement(grandchild);
- }
+ if (HTMLTableRowElement* lastRow = Traversal<HTMLTableRowElement>::lastChild(*child))
+ return lastRow;
}
}
for (Node* child = table.lastChild(); child; child = child->previousSibling()) {
if (child->hasTagName(theadTag)) {
- for (Node* grandchild = child->lastChild(); grandchild; grandchild = grandchild->previousSibling()) {
- if (isHTMLTableRowElement(grandchild))
- return toHTMLTableRowElement(grandchild);
- }
+ if (HTMLTableRowElement* lastRow = Traversal<HTMLTableRowElement>::lastChild(*child))
+ return lastRow;
}
}
« no previous file with comments | « Source/core/dom/TreeWalker.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698