1 // Copyright 2020 The PDFium Authors 2 // Use of this source code is governed by a BSD-style license that can be 3 // found in the LICENSE file. 4 5 #ifndef FXJS_GC_GCED_TREE_NODE_H_ 6 #define FXJS_GC_GCED_TREE_NODE_H_ 7 8 #include "core/fxcrt/tree_node.h" 9 #include "v8/include/cppgc/garbage-collected.h" 10 #include "v8/include/cppgc/member.h" 11 #include "v8/include/cppgc/visitor.h" 12 13 namespace fxjs { 14 15 // For DOM/XML-ish trees, where references outside the tree are Persistent<>. 16 template <typename T> 17 class GCedTreeNode : public cppgc::GarbageCollected<GCedTreeNode<T>>, 18 public fxcrt::TreeNodeBase<T> { 19 public: Trace(cppgc::Visitor * visitor)20 virtual void Trace(cppgc::Visitor* visitor) const { 21 visitor->Trace(m_pParent); 22 visitor->Trace(m_pFirstChild); 23 visitor->Trace(m_pLastChild); 24 visitor->Trace(m_pNextSibling); 25 visitor->Trace(m_pPrevSibling); 26 } 27 28 protected: 29 GCedTreeNode() = default; 30 GCedTreeNode(const GCedTreeNode& that) = delete; 31 GCedTreeNode& operator=(const GCedTreeNode& that) = delete; 32 33 private: 34 friend class fxcrt::TreeNodeBase<T>; 35 36 cppgc::Member<T> m_pParent; 37 cppgc::Member<T> m_pFirstChild; 38 cppgc::Member<T> m_pLastChild; 39 cppgc::Member<T> m_pNextSibling; 40 cppgc::Member<T> m_pPrevSibling; 41 }; 42 43 } // namespace fxjs 44 45 using fxjs::GCedTreeNode; 46 47 #endif // FXJS_GC_GCED_TREE_NODE_H_ 48