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; |