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

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

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
Index: Source/core/dom/ChildNodeList.cpp
diff --git a/Source/core/dom/ChildNodeList.cpp b/Source/core/dom/ChildNodeList.cpp
index b391298bf0ad2d3b7dfe3c4e07993e7feb6178ad..9576cc57f236b8409860d9274013bafc264c5d54 100644
--- a/Source/core/dom/ChildNodeList.cpp
+++ b/Source/core/dom/ChildNodeList.cpp
@@ -1,8 +1,9 @@
-/**
+/*
* Copyright (C) 1999 Lars Knoll (knoll@kde.org)
* (C) 1999 Antti Koivisto (koivisto@kde.org)
* (C) 2001 Dirk Mueller (mueller@kde.org)
* Copyright (C) 2004, 2007, 2008 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
@@ -28,21 +29,31 @@
namespace WebCore {
-ChildNodeList::ChildNodeList(PassRefPtr<ContainerNode> node)
- : LiveNodeList(node, ChildNodeListType, DoNotInvalidateOnAttributeChanges)
+ChildNodeList::ChildNodeList(PassRefPtr<ContainerNode> parent)
+ : m_parent(parent)
{
+ ASSERT(m_parent);
}
ChildNodeList::~ChildNodeList()
{
- ownerNode()->nodeLists()->removeChildNodeList(this);
+ m_parent->nodeLists()->removeChildNodeList(this);
}
-bool ChildNodeList::nodeMatches(const Element& testNode) const
+Node* ChildNodeList::itemBefore(const Node* previous) const
{
- // This function will be called only by LiveNodeList::namedItem,
- // for an element that was located with getElementById.
- return testNode.parentNode() == rootNode();
+ return LIKELY(!!previous) ? previous->previousSibling() : rootNode().lastChild();
+}
+
+Node* ChildNodeList::traverseForwardToOffset(unsigned offset, Node& currentNode, unsigned& currentOffset, const ContainerNode&) const
+{
+ ASSERT(currentOffset < offset);
+ Node* next = &currentNode;
+ while ((next = next->nextSibling())) {
+ if (++currentOffset == offset)
+ return next;
+ }
+ return 0;
}
} // namespace WebCore

Powered by Google App Engine
This is Rietveld 408576698