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

Unified Diff: Source/core/dom/ParentNode.h

Issue 166573003: Port ParentNode API to ElementTraversal (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: 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/ElementTraversal.h ('k') | Source/core/editing/TypingCommand.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/dom/ParentNode.h
diff --git a/Source/core/dom/ParentNode.h b/Source/core/dom/ParentNode.h
index 9fb949a35b0aefb308f11af7253806ad7167cbe8..45f146c0e8581b68958d572121397ba8421c0248 100644
--- a/Source/core/dom/ParentNode.h
+++ b/Source/core/dom/ParentNode.h
@@ -32,6 +32,7 @@
#define ParentNode_h
#include "core/dom/ContainerNode.h"
+#include "core/dom/ElementTraversal.h"
namespace WebCore {
@@ -44,17 +45,23 @@ public:
static Element* firstElementChild(ContainerNode* node)
{
- return node->firstElementChild();
+ ASSERT(node);
+ return ElementTraversal::firstWithin(*node);
}
static Element* lastElementChild(ContainerNode* node)
{
- return node->lastElementChild();
+ ASSERT(node);
+ return ElementTraversal::lastWithin(*node);
}
static unsigned childElementCount(ContainerNode* node)
{
- return node->childElementCount();
+ ASSERT(node);
+ unsigned count = 0;
+ for (Element* child = ElementTraversal::firstWithin(*node); child; child = ElementTraversal::nextSibling(*child))
+ ++count;
+ return count;
}
};
« no previous file with comments | « Source/core/dom/ElementTraversal.h ('k') | Source/core/editing/TypingCommand.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698