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

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

Issue 15077006: Implement ParentNode IDL interface (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: rebase Created 7 years, 7 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/ContainerNode.h ('k') | Source/core/dom/Document.idl » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/dom/ContainerNode.cpp
diff --git a/Source/core/dom/ContainerNode.cpp b/Source/core/dom/ContainerNode.cpp
index 5aba112a03ccce68d4757f1a98f6175d3feaf88a..7c3ff411bb04f3a280ae56979b42a39afac390bc 100644
--- a/Source/core/dom/ContainerNode.cpp
+++ b/Source/core/dom/ContainerNode.cpp
@@ -30,9 +30,11 @@
#include "core/dom/EventNames.h"
#include "core/dom/ExceptionCode.h"
#include "core/dom/MutationEvent.h"
+#include "core/dom/NodeRareData.h"
#include "core/dom/NodeRenderStyle.h"
#include "core/dom/NodeTraversal.h"
#include "core/dom/TemplateContentDocumentFragment.h"
+#include "core/html/HTMLCollection.h"
#include "core/inspector/InspectorInstrumentation.h"
#include "core/loader/cache/MemoryCache.h"
#include "core/page/Chrome.h"
@@ -824,6 +826,35 @@ void ContainerNode::setHovered(bool over)
}
}
+PassRefPtr<HTMLCollection> ContainerNode::children()
+{
+ return ensureRareData()->ensureNodeLists()->addCacheWithAtomicName<HTMLCollection>(this, NodeChildren);
+}
+
+Element* ContainerNode::firstElementChild() const
+{
+ return ElementTraversal::firstWithin(this);
+}
+
+Element* ContainerNode::lastElementChild() const
+{
+ Node* n = lastChild();
+ while (n && !n->isElementNode())
+ n = n->previousSibling();
+ return toElement(n);
+}
+
+unsigned ContainerNode::childElementCount() const
+{
+ unsigned count = 0;
+ Node* n = firstChild();
+ while (n) {
+ count += n->isElementNode();
+ n = n->nextSibling();
+ }
+ return count;
+}
+
unsigned ContainerNode::childNodeCount() const
{
unsigned count = 0;
« no previous file with comments | « Source/core/dom/ContainerNode.h ('k') | Source/core/dom/Document.idl » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698