Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(782)

Unified Diff: Source/core/dom/ChildNodeList.h

Issue 154693002: Have ChildNodeList subclass NodeList instead of LiveNodeList (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Update copyright Created 6 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | Source/core/dom/ChildNodeList.cpp » ('j') | Source/core/dom/NodeList.cpp » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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());
« no previous file with comments | « no previous file | Source/core/dom/ChildNodeList.cpp » ('j') | Source/core/dom/NodeList.cpp » ('J')

Powered by Google App Engine
This is Rietveld 408576698