#pragma once
#include <wtf/Forward.h>
#include <wtf/Noncopyable.h>
#include <wtf/RefCounted.h>
namespace WebCore {
class RenderCounter;
class RenderElement;
class CounterNode : public RefCounted<CounterNode> {
public:
static Ref<CounterNode> create(RenderElement&, 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; }
RenderElement& 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 = nullptr) const;
CounterNode* nextInPreOrderAfterChildren(const CounterNode* stayWithin = nullptr) const;
void insertAfter(CounterNode& newChild, CounterNode* beforeChild, const AtomicString& identifier);
void removeChild(CounterNode&);
private:
CounterNode(RenderElement&, bool isReset, int value);
int computeCountInParent() const;
void resetThisAndDescendantsRenderers();
void recount();
bool m_hasResetType;
int m_value;
int m_countInParent;
RenderElement& m_owner;
RenderCounter* m_rootRenderer { nullptr };
CounterNode* m_parent { nullptr };
CounterNode* m_previousSibling { nullptr };
CounterNode* m_nextSibling { nullptr };
CounterNode* m_firstChild { nullptr };
CounterNode* m_lastChild { nullptr };
};
}
#if ENABLE(TREE_DEBUGGING)
void showCounterTree(const WebCore::CounterNode*);
#endif