Index: Source/core/dom/ChildNodeList.h |
diff --git a/Source/core/dom/ChildNodeList.h b/Source/core/dom/ChildNodeList.h |
index b62ea6e7982903a0a35d0e25e7a330a6e9850df1..b356cdfb5616f961da8fb5beae2a5dcca799d121 100644 |
--- a/Source/core/dom/ChildNodeList.h |
+++ b/Source/core/dom/ChildNodeList.h |
@@ -3,6 +3,7 @@ |
* (C) 1999 Antti Koivisto (koivisto@kde.org) |
* (C) 2001 Dirk Mueller (mueller@kde.org) |
* Copyright (C) 2004, 2007 Apple Inc. All rights reserved. |
+ * Copyright (C) 2014 Samsung Electronics. All rights reserved. |
* |
* This library is free software; you can redistribute it and/or |
* modify it under the terms of the GNU Library General Public |
@@ -24,12 +25,13 @@ |
#ifndef ChildNodeList_h |
#define ChildNodeList_h |
-#include "core/dom/LiveNodeList.h" |
+#include "core/dom/NodeList.h" |
+#include "core/html/CollectionIndexCache.h" |
#include "wtf/PassRefPtr.h" |
namespace WebCore { |
-class ChildNodeList FINAL : public LiveNodeList { |
+class ChildNodeList FINAL : public NodeList { |
public: |
static PassRefPtr<ChildNodeList> create(PassRefPtr<ContainerNode> rootNode) |
{ |
@@ -38,11 +40,28 @@ public: |
virtual ~ChildNodeList(); |
-protected: |
+ // DOM API. |
+ virtual unsigned length() const OVERRIDE { return m_collectionIndexCache.nodeCount(*this); } |
+ virtual Node* item(unsigned index) const OVERRIDE { return m_collectionIndexCache.nodeAt(*this, index); } |
+ |
+ // Non-DOM API. |
+ void invalidateCache() { m_collectionIndexCache.invalidate(); } |
+ ContainerNode* ownerNode() const { return m_parent.get(); } |
+ |
+ // CollectionIndexCache API. |
+ ContainerNode& rootNode() const { return *m_parent; } |
+ bool canTraverseBackward() const { return true; } |
+ Node* itemBefore(const Node* previousItem) const; |
+ Node* traverseToFirstElement(const ContainerNode& root) const { return root.firstChild(); } |
+ Node* traverseForwardToOffset(unsigned offset, Node& currentNode, unsigned& currentOffset, const ContainerNode& root) const; |
+ |
+private: |
explicit ChildNodeList(PassRefPtr<ContainerNode> rootNode); |
virtual bool isChildNodeList() const OVERRIDE { return true; } |
- virtual bool nodeMatches(const Element&) const OVERRIDE; |
+ |
+ RefPtr<ContainerNode> m_parent; |
+ mutable CollectionIndexCache<ChildNodeList, Node> m_collectionIndexCache; |
}; |
DEFINE_TYPE_CASTS(ChildNodeList, NodeList, nodeList, nodeList->isChildNodeList(), nodeList.isChildNodeList()); |