summaryrefslogtreecommitdiffstats
path: root/Source/WebCore/dom/ChildNodeList.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'Source/WebCore/dom/ChildNodeList.cpp')
-rw-r--r--Source/WebCore/dom/ChildNodeList.cpp17
1 files changed, 14 insertions, 3 deletions
diff --git a/Source/WebCore/dom/ChildNodeList.cpp b/Source/WebCore/dom/ChildNodeList.cpp
index 3328c7c..253537c 100644
--- a/Source/WebCore/dom/ChildNodeList.cpp
+++ b/Source/WebCore/dom/ChildNodeList.cpp
@@ -27,19 +27,27 @@
namespace WebCore {
-ChildNodeList::ChildNodeList(PassRefPtr<Node> rootNode, DynamicNodeList::Caches* info)
- : DynamicNodeList(rootNode, info)
+ChildNodeList::ChildNodeList(PassRefPtr<Node> rootNode)
+ : DynamicNodeList(rootNode)
{
}
+ChildNodeList::~ChildNodeList()
+{
+ m_rootNode->removeCachedChildNodeList(this);
+}
+
unsigned ChildNodeList::length() const
{
if (m_caches->isLengthCacheValid)
return m_caches->cachedLength;
unsigned len = 0;
- for (Node* n = m_rootNode->firstChild(); n; n = n->nextSibling())
+ Vector<Node* >& cachedNodes = m_caches->cachedNodes;
+ for (Node* n = m_rootNode->firstChild(); n; n = n->nextSibling()) {
+ cachedNodes.append(n);
len++;
+ }
m_caches->cachedLength = len;
m_caches->isLengthCacheValid = true;
@@ -49,6 +57,9 @@ unsigned ChildNodeList::length() const
Node* ChildNodeList::item(unsigned index) const
{
+ if (m_caches->isLengthCacheValid && index < m_caches->cachedLength)
+ return m_caches->cachedNodes[index];
+
unsigned int pos = 0;
Node* n = m_rootNode->firstChild();