summaryrefslogtreecommitdiffstats
path: root/Source/WebCore
diff options
context:
space:
mode:
Diffstat (limited to 'Source/WebCore')
-rw-r--r--Source/WebCore/dom/ChildNodeList.cpp17
-rw-r--r--Source/WebCore/dom/ChildNodeList.h8
-rw-r--r--Source/WebCore/dom/Node.cpp21
-rw-r--r--Source/WebCore/dom/Node.h1
-rw-r--r--Source/WebCore/dom/NodeRareData.h6
5 files changed, 11 insertions, 42 deletions
diff --git a/Source/WebCore/dom/ChildNodeList.cpp b/Source/WebCore/dom/ChildNodeList.cpp
index 253537c..3328c7c 100644
--- a/Source/WebCore/dom/ChildNodeList.cpp
+++ b/Source/WebCore/dom/ChildNodeList.cpp
@@ -27,27 +27,19 @@
namespace WebCore {
-ChildNodeList::ChildNodeList(PassRefPtr<Node> rootNode)
- : DynamicNodeList(rootNode)
+ChildNodeList::ChildNodeList(PassRefPtr<Node> rootNode, DynamicNodeList::Caches* info)
+ : DynamicNodeList(rootNode, info)
{
}
-ChildNodeList::~ChildNodeList()
-{
- m_rootNode->removeCachedChildNodeList(this);
-}
-
unsigned ChildNodeList::length() const
{
if (m_caches->isLengthCacheValid)
return m_caches->cachedLength;
unsigned len = 0;
- Vector<Node* >& cachedNodes = m_caches->cachedNodes;
- for (Node* n = m_rootNode->firstChild(); n; n = n->nextSibling()) {
- cachedNodes.append(n);
+ for (Node* n = m_rootNode->firstChild(); n; n = n->nextSibling())
len++;
- }
m_caches->cachedLength = len;
m_caches->isLengthCacheValid = true;
@@ -57,9 +49,6 @@ 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();
diff --git a/Source/WebCore/dom/ChildNodeList.h b/Source/WebCore/dom/ChildNodeList.h
index df3d67b..f38106d 100644
--- a/Source/WebCore/dom/ChildNodeList.h
+++ b/Source/WebCore/dom/ChildNodeList.h
@@ -31,18 +31,16 @@ namespace WebCore {
class ChildNodeList : public DynamicNodeList {
public:
- static PassRefPtr<ChildNodeList> create(PassRefPtr<Node> rootNode)
+ static PassRefPtr<ChildNodeList> create(PassRefPtr<Node> rootNode, Caches* caches)
{
- return adoptRef(new ChildNodeList(rootNode));
+ return adoptRef(new ChildNodeList(rootNode, caches));
}
- virtual ~ChildNodeList();
-
virtual unsigned length() const;
virtual Node* item(unsigned index) const;
protected:
- ChildNodeList(PassRefPtr<Node> rootNode);
+ ChildNodeList(PassRefPtr<Node> rootNode, Caches*);
virtual bool nodeMatches(Element*) const;
};
diff --git a/Source/WebCore/dom/Node.cpp b/Source/WebCore/dom/Node.cpp
index 5b173bf..facb694 100644
--- a/Source/WebCore/dom/Node.cpp
+++ b/Source/WebCore/dom/Node.cpp
@@ -628,12 +628,8 @@ void Node::setNodeValue(const String& /*nodeValue*/, ExceptionCode& ec)
PassRefPtr<NodeList> Node::childNodes()
{
NodeListsNodeData* data = ensureRareData()->ensureNodeLists(this);
- if (data->m_childNodeListCache)
- return PassRefPtr<ChildNodeList>(data->m_childNodeListCache);
- RefPtr<ChildNodeList> childNodeList = ChildNodeList::create(this);
- data->m_childNodeListCache = childNodeList.get();
- return childNodeList.release();
+ return ChildNodeList::create(this, data->m_childNodeListCaches.get());
}
Node *Node::lastDescendant() const
@@ -1149,16 +1145,6 @@ void Node::removeCachedLabelsNodeList(DynamicNodeList* list)
data->m_labelsNodeListCache = 0;
}
-void Node::removeCachedChildNodeList(DynamicNodeList* list)
-{
- ASSERT(rareData());
- ASSERT(rareData()->nodeLists());
- ASSERT_UNUSED(list, list->hasOwnCaches());
-
- NodeListsNodeData* data = rareData()->nodeLists();
- data->m_childNodeListCache = 0;
-}
-
Node* Node::traverseNextNode(const Node* stayWithin) const
{
prefetchTarget();
@@ -2504,8 +2490,7 @@ void Node::formatForDebugger(char* buffer, unsigned length) const
void NodeListsNodeData::invalidateCaches()
{
- if (m_childNodeListCache)
- m_childNodeListCache->invalidateCache();
+ m_childNodeListCaches->reset();
if (m_labelsNodeListCache)
m_labelsNodeListCache->invalidateCache();
@@ -2536,7 +2521,7 @@ bool NodeListsNodeData::isEmpty() const
if (!m_listsWithCaches.isEmpty())
return false;
- if (m_childNodeListCache)
+ if (m_childNodeListCaches->refCount())
return false;
TagNodeListCacheNS::const_iterator tagCacheEndNS = m_tagNodeListCacheNS.end();
diff --git a/Source/WebCore/dom/Node.h b/Source/WebCore/dom/Node.h
index ad5ee9d..d75d064 100644
--- a/Source/WebCore/dom/Node.h
+++ b/Source/WebCore/dom/Node.h
@@ -563,7 +563,6 @@ public:
void removeCachedTagNodeList(TagNodeList*, const AtomicString&);
void removeCachedTagNodeListNS(TagNodeListNS*, const QualifiedName&);
void removeCachedLabelsNodeList(DynamicNodeList*);
- void removeCachedChildNodeList(DynamicNodeList*);
PassRefPtr<NodeList> getElementsByTagName(const AtomicString&);
PassRefPtr<NodeList> getElementsByTagNameNS(const AtomicString& namespaceURI, const AtomicString& localName);
diff --git a/Source/WebCore/dom/NodeRareData.h b/Source/WebCore/dom/NodeRareData.h
index b81dd3f..7bbd0c1 100644
--- a/Source/WebCore/dom/NodeRareData.h
+++ b/Source/WebCore/dom/NodeRareData.h
@@ -22,7 +22,6 @@
#ifndef NodeRareData_h
#define NodeRareData_h
-#include "ChildNodeList.h"
#include "ClassNodeList.h"
#include "DynamicNodeList.h"
#include "NameNodeList.h"
@@ -43,7 +42,7 @@ public:
typedef HashSet<DynamicNodeList*> NodeListSet;
NodeListSet m_listsWithCaches;
- RefPtr<ChildNodeList> m_childNodeListCache;
+ RefPtr<DynamicNodeList::Caches> m_childNodeListCaches;
typedef HashMap<String, ClassNodeList*> ClassNodeListCache;
ClassNodeListCache m_classNodeListCache;
@@ -70,8 +69,7 @@ public:
private:
NodeListsNodeData()
- : m_childNodeListCache(0)
- , m_labelsNodeListCache(0)
+ : m_childNodeListCaches(DynamicNodeList::Caches::create()), m_labelsNodeListCache(0)
{
}
};