#ifndef CounterNode_h
#define CounterNode_h
#include "wtf/Forward.h"
#include "wtf/Noncopyable.h"
#include "wtf/RefCounted.h"
namespace WebCore {
class RenderObject;
class RenderCounter;
class CounterNode : public RefCounted<CounterNode> {
public:
static PassRefPtr<CounterNode> create(RenderObject&, bool isReset, int value);
~CounterNode();
bool actsAsReset() const { return m_hasResetType || !m_parent; }
bool hasResetType() const { return m_hasResetType; }
int value() const { return m_value; }
int countInParent() const { return m_countInParent; }
RenderObject& owner() const { return m_owner; }
void addRenderer(RenderCounter*);
void removeRenderer(RenderCounter*);
void resetRenderers();
CounterNode* parent() const { return m_parent; }
CounterNode* previousSibling() const { return m_previousSibling; }
CounterNode* nextSibling() const { return m_nextSibling; }
CounterNode* firstChild() const { return m_firstChild; }
CounterNode* lastChild() const { return m_lastChild; }
CounterNode* lastDescendant() const;
CounterNode* previousInPreOrder() const;
CounterNode* nextInPreOrder(const CounterNode* stayWithin = 0) const;
CounterNode* nextInPreOrderAfterChildren(const CounterNode* stayWithin = 0) const;
void insertAfter(CounterNode* newChild, CounterNode* beforeChild, const AtomicString& identifier);
void removeChild(CounterNode*);
private:
CounterNode(RenderObject&, bool isReset, int value);
int computeCountInParent() const;
void resetThisAndDescendantsRenderers();
void recount();
bool m_hasResetType;
int m_value;
int m_countInParent;
RenderObject& m_owner;
RenderCounter* m_rootRenderer;
CounterNode* m_parent;
CounterNode* m_previousSibling;
CounterNode* m_nextSibling;
CounterNode* m_firstChild;
CounterNode* m_lastChild;
};
}
#ifndef NDEBUG
void showCounterTree(const WebCore::CounterNode*);
#endif
#endif