#ifndef LiveNodeList_h
#define LiveNodeList_h
#include "core/dom/LiveNodeListBase.h"
#include "core/dom/NodeList.h"
#include "core/html/CollectionIndexCache.h"
#include "core/html/CollectionType.h"
#include "wtf/PassRefPtr.h"
namespace WebCore {
class Element;
class LiveNodeList : public NodeList, public LiveNodeListBase {
public:
LiveNodeList(ContainerNode& ownerNode, CollectionType collectionType, NodeListInvalidationType invalidationType, NodeListRootType rootType = NodeListIsRootedAtNode)
: LiveNodeListBase(ownerNode, rootType, invalidationType,
collectionType)
{ }
virtual unsigned length() const OVERRIDE FINAL { return m_collectionIndexCache.nodeCount(*this); }
virtual Node* item(unsigned offset) const OVERRIDE FINAL { return m_collectionIndexCache.nodeAt(*this, offset); }
virtual bool elementMatches(const Element&) const = 0;
virtual void invalidateCache(Document* oldDocument) const OVERRIDE FINAL;
bool shouldOnlyIncludeDirectChildren() const { return false; }
bool canTraverseBackward() const { return true; }
Element* itemBefore(const Element* previousItem) const;
Element* traverseToFirstElement() const;
Element* traverseForwardToOffset(unsigned offset, Element& currentNode, unsigned& currentOffset) const;
private:
virtual Node* virtualOwnerNode() const OVERRIDE FINAL;
mutable CollectionIndexCache<LiveNodeList, Element> m_collectionIndexCache;
};
}
#endif