#ifndef NodeIterator_h
#define NodeIterator_h
#include "bindings/v8/ScriptWrappable.h"
#include "core/dom/NodeFilter.h"
#include "core/dom/NodeIteratorBase.h"
#include "wtf/PassRefPtr.h"
#include "wtf/RefCounted.h"
namespace WebCore {
class ExceptionState;
class NodeIterator : public ScriptWrappable, public RefCounted<NodeIterator>, public NodeIteratorBase {
public:
static PassRefPtr<NodeIterator> create(PassRefPtr<Node> rootNode, unsigned whatToShow, PassRefPtr<NodeFilter> filter)
{
return adoptRef(new NodeIterator(rootNode, whatToShow, filter));
}
~NodeIterator();
PassRefPtr<Node> nextNode(ExceptionState&);
PassRefPtr<Node> previousNode(ExceptionState&);
void detach();
Node* referenceNode() const { return m_referenceNode.node.get(); }
bool pointerBeforeReferenceNode() const { return m_referenceNode.isPointerBeforeNode; }
void nodeWillBeRemoved(Node&);
private:
NodeIterator(PassRefPtr<Node>, unsigned whatToShow, PassRefPtr<NodeFilter>);
struct NodePointer {
RefPtr<Node> node;
bool isPointerBeforeNode;
NodePointer();
NodePointer(PassRefPtr<Node>, bool);
void clear();
bool moveToNext(Node* root);
bool moveToPrevious(Node* root);
};
void updateForNodeRemoval(Node& nodeToBeRemoved, NodePointer&) const;
NodePointer m_referenceNode;
NodePointer m_candidateNode;
bool m_detached;
};
}
#endif