diff options
author | Lorry Tar Creator <lorry-tar-importer@lorry> | 2017-06-27 06:07:23 +0000 |
---|---|---|
committer | Lorry Tar Creator <lorry-tar-importer@lorry> | 2017-06-27 06:07:23 +0000 |
commit | 1bf1084f2b10c3b47fd1a588d85d21ed0eb41d0c (patch) | |
tree | 46dcd36c86e7fbc6e5df36deb463b33e9967a6f7 /Source/WebCore/dom/ChildNodeList.cpp | |
parent | 32761a6cee1d0dee366b885b7b9c777e67885688 (diff) | |
download | WebKitGtk-tarball-master.tar.gz |
webkitgtk-2.16.5HEADwebkitgtk-2.16.5master
Diffstat (limited to 'Source/WebCore/dom/ChildNodeList.cpp')
-rw-r--r-- | Source/WebCore/dom/ChildNodeList.cpp | 40 |
1 files changed, 10 insertions, 30 deletions
diff --git a/Source/WebCore/dom/ChildNodeList.cpp b/Source/WebCore/dom/ChildNodeList.cpp index c8fff4e03..95baa2f5f 100644 --- a/Source/WebCore/dom/ChildNodeList.cpp +++ b/Source/WebCore/dom/ChildNodeList.cpp @@ -35,6 +35,7 @@ EmptyNodeList::~EmptyNodeList() ChildNodeList::ChildNodeList(ContainerNode& parent) : m_parent(parent) + , m_indexCache(*this) { } @@ -53,7 +54,7 @@ Node* ChildNodeList::item(unsigned index) const return m_indexCache.nodeAt(*this, index); } -Node* ChildNodeList::collectionFirst() const +Node* ChildNodeList::collectionBegin() const { return m_parent->firstChild(); } @@ -63,47 +64,26 @@ Node* ChildNodeList::collectionLast() const return m_parent->lastChild(); } -Node* ChildNodeList::collectionTraverseForward(Node& current, unsigned count, unsigned& traversedCount) const +void ChildNodeList::collectionTraverseForward(Node*& current, unsigned count, unsigned& traversedCount) const { ASSERT(count); - Node* child = ¤t; for (traversedCount = 0; traversedCount < count; ++traversedCount) { - child = child->nextSibling(); - if (!child) - return nullptr; + current = current->nextSibling(); + if (!current) + return; } - return child; } -Node* ChildNodeList::collectionTraverseBackward(Node& current, unsigned count) const +void ChildNodeList::collectionTraverseBackward(Node*& current, unsigned count) const { ASSERT(count); - Node* child = ¤t; - for (; count && child ; --count) - child = child->previousSibling(); - return child; -} - -Node* ChildNodeList::namedItem(const AtomicString& name) const -{ - // FIXME: According to the spec child node list should not have namedItem(). - if (m_parent.get().inDocument()) { - Element* element = m_parent.get().treeScope().getElementById(name); - if (element && element->parentNode() == &m_parent.get()) - return element; - if (!element || !m_parent.get().treeScope().containsMultipleElementsWithId(name)) - return nullptr; - } - for (auto& element : childrenOfType<Element>(m_parent.get())) { - if (element.hasID() && element.idForStyleResolution() == name) - return const_cast<Element*>(&element); - } - return nullptr; + for (; count && current ; --count) + current = current->previousSibling(); } void ChildNodeList::invalidateCache() { - m_indexCache.invalidate(); + m_indexCache.invalidate(*this); } } // namespace WebCore |