summaryrefslogtreecommitdiff
path: root/Source/WebCore/dom/ChildNodeList.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'Source/WebCore/dom/ChildNodeList.cpp')
-rw-r--r--Source/WebCore/dom/ChildNodeList.cpp40
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 = &current;
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 = &current;
- 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