Index: Source/core/dom/ContainerNode.cpp |
diff --git a/Source/core/dom/ContainerNode.cpp b/Source/core/dom/ContainerNode.cpp |
index 4256a5986c0edf602b926724a543e38404e899b9..52b0a0244163a50830014a9fda54da8760c0ce27 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/html/shadow/InsertionPoint.h" |
#include "core/inspector/InspectorInstrumentation.h" |
#include "core/loader/cache/MemoryCache.h" |
@@ -825,6 +827,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; |