5#ifndef CORE_FXCRT_TREE_NODE_H_
6#define CORE_FXCRT_TREE_NODE_H_
10#include "core/fxcrt/unowned_ptr_exclusion.h"
11#include "third_party/base/check.h"
25 inline T*
GetParent()
const {
return static_cast<
const T*>(
this)->m_pParent; }
27 return static_cast<
const T*>(
this)->m_pFirstChild;
30 return static_cast<
const T*>(
this)->m_pLastChild;
33 return static_cast<
const T*>(
this)->m_pNextSibling;
36 return static_cast<
const T*>(
this)->m_pPrevSibling;
40 return child !=
this && child->GetParent() ==
this;
47 while (n-- && result) {
48 result = result->GetNextSibling();
88 child->SetNextSibling(other);
89 child->SetPrevSibling(other->GetPrevSibling());
91 CHECK(!other->GetPrevSibling());
94 other->GetPrevSibling()->SetNextSibling(child);
96 other->m_pPrevSibling = child;
106 child->SetNextSibling(other->GetNextSibling());
107 child->SetPrevSibling(other);
109 CHECK(!other->GetNextSibling());
112 other->GetNextSibling()->SetPrevSibling(child);
114 other->SetNextSibling(child);
120 CHECK(!child->GetNextSibling());
121 SetLastChild(child->GetPrevSibling());
123 child->GetNextSibling()->SetPrevSibling(child->GetPrevSibling());
126 CHECK(!child->GetPrevSibling());
127 SetFirstChild(child->GetNextSibling());
129 child->GetPrevSibling()->SetNextSibling(child->GetNextSibling());
131 child->SetParent(
nullptr);
132 child->SetPrevSibling(
nullptr);
133 child->SetNextSibling(
nullptr);
143 parent->RemoveChild(
static_cast<T*>(
this));
149 inline void SetParent(T* pParent) {
150 static_cast<T*>(
this)->m_pParent = pParent;
152 inline void SetFirstChild(T* pChild) {
153 static_cast<T*>(
this)->m_pFirstChild = pChild;
155 inline void SetLastChild(T* pChild) {
156 static_cast<T*>(
this)->m_pLastChild = pChild;
158 inline void SetNextSibling(T* pSibling) {
159 static_cast<T*>(
this)->m_pNextSibling = pSibling;
161 inline void SetPrevSibling(T* pSibling) {
162 static_cast<T*>(
this)->m_pPrevSibling = pSibling;
166 void BecomeParent(T* child) {
167 CHECK(child !=
this);
168 if (child->m_pParent)
170 child->m_pParent =
static_cast<T*>(
this);
171 CHECK(!child->m_pNextSibling);
172 CHECK(!child->m_pPrevSibling);
195using fxcrt::TreeNode;
CFX_XMLElement * ToXMLElement(CFX_XMLNode *pNode)
const CFX_XMLElement * ToXMLElement(const CFX_XMLNode *pNode)
CFX_XMLElement * GetRoot() const
T * CreateNode(Args &&... args)
void AppendNodesFrom(CFX_XMLDocument *other)
void Save(const RetainPtr< IFX_RetainableWriteStream > &pXMLStream) override
WideString GetNamespacePrefix() const
WideString GetTextData() const
const WideString & GetName() const
CFX_XMLNode * Clone(CFX_XMLDocument *doc) override
~CFX_XMLElement() override
CFX_XMLElement(const WideString &wsTag)
bool HasAttribute(const WideString &name) const
WideString GetLocalTagName() const
Type GetType() const override
WideString GetAttribute(const WideString &name) const
WideString GetNamespaceURI() const
void SetAttribute(const WideString &name, const WideString &value)
CFX_XMLElement * GetFirstChildNamed(WideStringView name) const
void RemoveAttribute(const WideString &name)
const std::map< WideString, WideString > & GetAttributes() const
CFX_XMLElement * GetNthChildNamed(WideStringView name, size_t idx) const
virtual void Save(const RetainPtr< IFX_RetainableWriteStream > &pXMLStream)=0
void InsertChildNode(CFX_XMLNode *pNode, int32_t index)
virtual CFX_XMLNode * Clone(CFX_XMLDocument *doc)=0
virtual Type GetType() const =0
bool HasChild(const T *child) const
void RemoveSelfIfParented()
void AppendLastChild(T *child)
T * GetPrevSibling() const
void RemoveChild(T *child)
virtual ~TreeNodeBase()=default
T * GetNthChild(int32_t n)
T * GetFirstChild() const
void InsertBefore(T *child, T *other)
T * GetNextSibling() const
void InsertAfter(T *child, T *other)
void AppendFirstChild(T *child)
virtual ~TreeNode()=default
static WideString FromASCII(ByteStringView str)
bool EqualsASCII(ByteStringView that) const
#define UNOWNED_PTR_EXCLUSION