Make CJX_Object and its subclasses be garbage collected.

Unfortunately, this causes a nearly-identical change to each of the
numerous CFXA_Object subclasses, which was partially automated but
required some IWYU and argument naming adjustments.

Bug: pdfium:1563
Change-Id: Ie107b0b3b9ca628b65bfd14085a08061fbd1014b
Reviewed-on: https://pdfium-review.googlesource.com/c/pdfium/+/73690
Commit-Queue: Tom Sepez <tsepez@chromium.org>
Reviewed-by: Lei Zhang <thestig@chromium.org>
diff --git a/fxjs/xfa/cjx_boolean.h b/fxjs/xfa/cjx_boolean.h
index d2a85ba..6aaff83 100644
--- a/fxjs/xfa/cjx_boolean.h
+++ b/fxjs/xfa/cjx_boolean.h
@@ -14,7 +14,7 @@
 
 class CJX_Boolean final : public CJX_Object {
  public:
-  explicit CJX_Boolean(CXFA_Boolean* node);
+  CONSTRUCT_VIA_MAKE_GARBAGE_COLLECTED;
   ~CJX_Boolean() override;
 
   // CJX_Object:
@@ -24,6 +24,8 @@
   JSE_PROP(value);
 
  private:
+  explicit CJX_Boolean(CXFA_Boolean* node);
+
   using Type__ = CJX_Boolean;
   using ParentType__ = CJX_Object;
 
diff --git a/fxjs/xfa/cjx_container.h b/fxjs/xfa/cjx_container.h
index 51675e5..6fea0a2 100644
--- a/fxjs/xfa/cjx_container.h
+++ b/fxjs/xfa/cjx_container.h
@@ -14,7 +14,7 @@
 
 class CJX_Container : public CJX_Node {
  public:
-  explicit CJX_Container(CXFA_Node* node);
+  CONSTRUCT_VIA_MAKE_GARBAGE_COLLECTED;
   ~CJX_Container() override;
 
   // CJX_Object:
@@ -23,6 +23,9 @@
   JSE_METHOD(getDelta);
   JSE_METHOD(getDeltas);
 
+ protected:
+  explicit CJX_Container(CXFA_Node* node);
+
  private:
   using Type__ = CJX_Container;
   using ParentType__ = CJX_Node;
diff --git a/fxjs/xfa/cjx_datawindow.h b/fxjs/xfa/cjx_datawindow.h
index 6f3ad54..9a87312 100644
--- a/fxjs/xfa/cjx_datawindow.h
+++ b/fxjs/xfa/cjx_datawindow.h
@@ -11,12 +11,11 @@
 #include "fxjs/xfa/jse_define.h"
 #include "xfa/fxfa/fxfa_basic.h"
 
-class CFXJSE_Value;
 class CScript_DataWindow;
 
 class CJX_DataWindow final : public CJX_Object {
  public:
-  explicit CJX_DataWindow(CScript_DataWindow* window);
+  CONSTRUCT_VIA_MAKE_GARBAGE_COLLECTED;
   ~CJX_DataWindow() override;
 
   // CJX_Object:
@@ -33,6 +32,8 @@
   JSE_PROP(recordsBefore);
 
  private:
+  explicit CJX_DataWindow(CScript_DataWindow* window);
+
   using Type__ = CJX_DataWindow;
   using ParentType__ = CJX_Object;
 
diff --git a/fxjs/xfa/cjx_delta.h b/fxjs/xfa/cjx_delta.h
index 716dd1e..f1e4127 100644
--- a/fxjs/xfa/cjx_delta.h
+++ b/fxjs/xfa/cjx_delta.h
@@ -14,7 +14,7 @@
 
 class CJX_Delta final : public CJX_Object {
  public:
-  explicit CJX_Delta(CXFA_Delta* delta);
+  CONSTRUCT_VIA_MAKE_GARBAGE_COLLECTED;
   ~CJX_Delta() override;
 
   // CJX_Object:
@@ -27,6 +27,8 @@
   JSE_PROP(target);
 
  private:
+  explicit CJX_Delta(CXFA_Delta* delta);
+
   using Type__ = CJX_Delta;
   using ParentType__ = CJX_Object;
 
diff --git a/fxjs/xfa/cjx_desc.h b/fxjs/xfa/cjx_desc.h
index 62cdec8..75f9157 100644
--- a/fxjs/xfa/cjx_desc.h
+++ b/fxjs/xfa/cjx_desc.h
@@ -14,7 +14,7 @@
 
 class CJX_Desc final : public CJX_Node {
  public:
-  explicit CJX_Desc(CXFA_Desc* desc);
+  CONSTRUCT_VIA_MAKE_GARBAGE_COLLECTED;
   ~CJX_Desc() override;
 
   // CJX_Object:
@@ -23,6 +23,8 @@
   JSE_METHOD(metadata);
 
  private:
+  explicit CJX_Desc(CXFA_Desc* desc);
+
   using Type__ = CJX_Desc;
   using ParentType__ = CJX_Node;
 
diff --git a/fxjs/xfa/cjx_draw.h b/fxjs/xfa/cjx_draw.h
index bf3c3a7..9a6a332 100644
--- a/fxjs/xfa/cjx_draw.h
+++ b/fxjs/xfa/cjx_draw.h
@@ -14,7 +14,7 @@
 
 class CJX_Draw final : public CJX_Container {
  public:
-  explicit CJX_Draw(CXFA_Draw* node);
+  CONSTRUCT_VIA_MAKE_GARBAGE_COLLECTED;
   ~CJX_Draw() override;
 
   // CJX_Object:
@@ -24,6 +24,8 @@
   JSE_PROP(rawValue);
 
  private:
+  explicit CJX_Draw(CXFA_Draw* node);
+
   using Type__ = CJX_Draw;
   using ParentType__ = CJX_Container;
 
diff --git a/fxjs/xfa/cjx_encrypt.h b/fxjs/xfa/cjx_encrypt.h
index 826bc1f..58989d1 100644
--- a/fxjs/xfa/cjx_encrypt.h
+++ b/fxjs/xfa/cjx_encrypt.h
@@ -14,7 +14,7 @@
 
 class CJX_Encrypt final : public CJX_Node {
  public:
-  explicit CJX_Encrypt(CXFA_Encrypt* node);
+  CONSTRUCT_VIA_MAKE_GARBAGE_COLLECTED;
   ~CJX_Encrypt() override;
 
   // CJX_Object:
@@ -23,6 +23,8 @@
   JSE_PROP(format);
 
  private:
+  explicit CJX_Encrypt(CXFA_Encrypt* node);
+
   using Type__ = CJX_Encrypt;
   using ParentType__ = CJX_Node;
 
diff --git a/fxjs/xfa/cjx_eventpseudomodel.h b/fxjs/xfa/cjx_eventpseudomodel.h
index 6f3cc84..a4e741f 100644
--- a/fxjs/xfa/cjx_eventpseudomodel.h
+++ b/fxjs/xfa/cjx_eventpseudomodel.h
@@ -35,7 +35,7 @@
 
 class CJX_EventPseudoModel final : public CJX_Object {
  public:
-  explicit CJX_EventPseudoModel(CScript_EventPseudoModel* model);
+  CONSTRUCT_VIA_MAKE_GARBAGE_COLLECTED;
   ~CJX_EventPseudoModel() override;
 
   // CJX_Object:
@@ -63,6 +63,8 @@
   JSE_PROP(target);
 
  private:
+  explicit CJX_EventPseudoModel(CScript_EventPseudoModel* model);
+
   using Type__ = CJX_EventPseudoModel;
   using ParentType__ = CJX_Object;
 
diff --git a/fxjs/xfa/cjx_exclgroup.h b/fxjs/xfa/cjx_exclgroup.h
index b459808..a2d911a 100644
--- a/fxjs/xfa/cjx_exclgroup.h
+++ b/fxjs/xfa/cjx_exclgroup.h
@@ -14,7 +14,7 @@
 
 class CJX_ExclGroup final : public CJX_Node {
  public:
-  explicit CJX_ExclGroup(CXFA_ExclGroup* group);
+  CONSTRUCT_VIA_MAKE_GARBAGE_COLLECTED;
   ~CJX_ExclGroup() override;
 
   // CJX_Object:
@@ -32,6 +32,8 @@
   JSE_PROP(transient);
 
  private:
+  explicit CJX_ExclGroup(CXFA_ExclGroup* group);
+
   using Type__ = CJX_ExclGroup;
   using ParentType__ = CJX_Node;
 
diff --git a/fxjs/xfa/cjx_extras.h b/fxjs/xfa/cjx_extras.h
index 0723575..c98d2fb 100644
--- a/fxjs/xfa/cjx_extras.h
+++ b/fxjs/xfa/cjx_extras.h
@@ -14,7 +14,7 @@
 
 class CJX_Extras final : public CJX_Node {
  public:
-  explicit CJX_Extras(CXFA_Extras* node);
+  CONSTRUCT_VIA_MAKE_GARBAGE_COLLECTED;
   ~CJX_Extras() override;
 
   // CJX_Object:
@@ -23,6 +23,8 @@
   JSE_PROP(type);
 
  private:
+  explicit CJX_Extras(CXFA_Extras* node);
+
   using Type__ = CJX_Extras;
   using ParentType__ = CJX_Node;
 
diff --git a/fxjs/xfa/cjx_field.h b/fxjs/xfa/cjx_field.h
index 6e16e7a..750738b 100644
--- a/fxjs/xfa/cjx_field.h
+++ b/fxjs/xfa/cjx_field.h
@@ -14,7 +14,7 @@
 
 class CJX_Field final : public CJX_Container {
  public:
-  explicit CJX_Field(CXFA_Field* field);
+  CONSTRUCT_VIA_MAKE_GARBAGE_COLLECTED;
   ~CJX_Field() override;
 
   // CJX_Object:
@@ -43,6 +43,8 @@
   JSE_PROP(selectedIndex);
 
  private:
+  explicit CJX_Field(CXFA_Field* field);
+
   using Type__ = CJX_Field;
   using ParentType__ = CJX_Container;
 
diff --git a/fxjs/xfa/cjx_form.h b/fxjs/xfa/cjx_form.h
index c7b1ce3..9156413 100644
--- a/fxjs/xfa/cjx_form.h
+++ b/fxjs/xfa/cjx_form.h
@@ -14,7 +14,7 @@
 
 class CJX_Form final : public CJX_Model {
  public:
-  explicit CJX_Form(CXFA_Form* form);
+  CONSTRUCT_VIA_MAKE_GARBAGE_COLLECTED;
   ~CJX_Form() override;
 
   // CJX_Object:
@@ -30,6 +30,8 @@
   JSE_PROP(checksumS);
 
  private:
+  explicit CJX_Form(CXFA_Form* form);
+
   using Type__ = CJX_Form;
   using ParentType__ = CJX_Model;
 
diff --git a/fxjs/xfa/cjx_handler.h b/fxjs/xfa/cjx_handler.h
index 348eaf1..25f7d9a 100644
--- a/fxjs/xfa/cjx_handler.h
+++ b/fxjs/xfa/cjx_handler.h
@@ -14,7 +14,7 @@
 
 class CJX_Handler final : public CJX_TextNode {
  public:
-  explicit CJX_Handler(CXFA_Handler* node);
+  CONSTRUCT_VIA_MAKE_GARBAGE_COLLECTED;
   ~CJX_Handler() override;
 
   // CJX_Object:
@@ -23,6 +23,8 @@
   JSE_PROP(version);
 
  private:
+  explicit CJX_Handler(CXFA_Handler* node);
+
   using Type__ = CJX_Handler;
   using ParentType__ = CJX_TextNode;
 
diff --git a/fxjs/xfa/cjx_hostpseudomodel.h b/fxjs/xfa/cjx_hostpseudomodel.h
index cdc293d..21262cc 100644
--- a/fxjs/xfa/cjx_hostpseudomodel.h
+++ b/fxjs/xfa/cjx_hostpseudomodel.h
@@ -11,12 +11,11 @@
 #include "fxjs/xfa/jse_define.h"
 #include "xfa/fxfa/fxfa_basic.h"
 
-class CFXJSE_Value;
 class CScript_HostPseudoModel;
 
 class CJX_HostPseudoModel final : public CJX_Object {
  public:
-  explicit CJX_HostPseudoModel(CScript_HostPseudoModel* model);
+  CONSTRUCT_VIA_MAKE_GARBAGE_COLLECTED;
   ~CJX_HostPseudoModel() override;
 
   // CJX_Object:
@@ -54,6 +53,8 @@
   JSE_PROP(name);
 
  private:
+  explicit CJX_HostPseudoModel(CScript_HostPseudoModel* model);
+
   using Type__ = CJX_HostPseudoModel;
   using ParentType__ = CJX_Object;
 
diff --git a/fxjs/xfa/cjx_instancemanager.h b/fxjs/xfa/cjx_instancemanager.h
index 3fae9ab..0d574f6 100644
--- a/fxjs/xfa/cjx_instancemanager.h
+++ b/fxjs/xfa/cjx_instancemanager.h
@@ -14,7 +14,7 @@
 
 class CJX_InstanceManager final : public CJX_Node {
  public:
-  explicit CJX_InstanceManager(CXFA_InstanceManager* mgr);
+  CONSTRUCT_VIA_MAKE_GARBAGE_COLLECTED;
   ~CJX_InstanceManager() override;
 
   // CJX_Object:
@@ -33,6 +33,8 @@
   int32_t MoveInstance(int32_t iTo, int32_t iFrom);
 
  private:
+  explicit CJX_InstanceManager(CXFA_InstanceManager* mgr);
+
   using Type__ = CJX_InstanceManager;
   using ParentType__ = CJX_Node;
 
diff --git a/fxjs/xfa/cjx_layoutpseudomodel.h b/fxjs/xfa/cjx_layoutpseudomodel.h
index d5f0cba..34e91d0 100644
--- a/fxjs/xfa/cjx_layoutpseudomodel.h
+++ b/fxjs/xfa/cjx_layoutpseudomodel.h
@@ -19,14 +19,13 @@
   XFA_LAYOUTMODEL_Y
 };
 
-class CFXJSE_Value;
 class CScript_LayoutPseudoModel;
 class CXFA_LayoutProcessor;
 class CXFA_Node;
 
 class CJX_LayoutPseudoModel final : public CJX_Object {
  public:
-  explicit CJX_LayoutPseudoModel(CScript_LayoutPseudoModel* model);
+  CONSTRUCT_VIA_MAKE_GARBAGE_COLLECTED;
   ~CJX_LayoutPseudoModel() override;
 
   // CJX_Object:
@@ -55,6 +54,8 @@
   JSE_PROP(ready);
 
  private:
+  explicit CJX_LayoutPseudoModel(CScript_LayoutPseudoModel* model);
+
   using Type__ = CJX_LayoutPseudoModel;
   using ParentType__ = CJX_Object;
 
diff --git a/fxjs/xfa/cjx_list.h b/fxjs/xfa/cjx_list.h
index 842b859..2cbe820 100644
--- a/fxjs/xfa/cjx_list.h
+++ b/fxjs/xfa/cjx_list.h
@@ -14,7 +14,7 @@
 
 class CJX_List : public CJX_Object {
  public:
-  explicit CJX_List(CXFA_List* list);
+  CONSTRUCT_VIA_MAKE_GARBAGE_COLLECTED;
   ~CJX_List() override;
 
   // CJX_Object:
@@ -27,6 +27,9 @@
 
   JSE_PROP(length);
 
+ protected:
+  explicit CJX_List(CXFA_List* list);
+
  private:
   using Type__ = CJX_List;
   using ParentType__ = CJX_Object;
diff --git a/fxjs/xfa/cjx_logpseudomodel.h b/fxjs/xfa/cjx_logpseudomodel.h
index fda3bb9..16e16db 100644
--- a/fxjs/xfa/cjx_logpseudomodel.h
+++ b/fxjs/xfa/cjx_logpseudomodel.h
@@ -16,7 +16,7 @@
 // xfa_basic_data_element_script is removed.
 class CJX_LogPseudoModel final : public CJX_Object {
  public:
-  explicit CJX_LogPseudoModel(CScript_LogPseudoModel* model);
+  CONSTRUCT_VIA_MAKE_GARBAGE_COLLECTED;
   ~CJX_LogPseudoModel() override;
 
   // CJX_Object:
@@ -29,6 +29,8 @@
   JSE_METHOD(trace);
 
  private:
+  explicit CJX_LogPseudoModel(CScript_LogPseudoModel* model);
+
   using Type__ = CJX_LogPseudoModel;
   using ParentType__ = CJX_Object;
 
diff --git a/fxjs/xfa/cjx_manifest.h b/fxjs/xfa/cjx_manifest.h
index 8380ac6..ada7cdd 100644
--- a/fxjs/xfa/cjx_manifest.h
+++ b/fxjs/xfa/cjx_manifest.h
@@ -14,7 +14,7 @@
 
 class CJX_Manifest final : public CJX_Node {
  public:
-  explicit CJX_Manifest(CXFA_Manifest* manifest);
+  CONSTRUCT_VIA_MAKE_GARBAGE_COLLECTED;
   ~CJX_Manifest() override;
 
   // CJX_Object:
@@ -23,6 +23,8 @@
   JSE_METHOD(evaluate);
 
  private:
+  explicit CJX_Manifest(CXFA_Manifest* manifest);
+
   using Type__ = CJX_Manifest;
   using ParentType__ = CJX_Node;
 
diff --git a/fxjs/xfa/cjx_model.h b/fxjs/xfa/cjx_model.h
index 9fd54f5..455fc4c 100644
--- a/fxjs/xfa/cjx_model.h
+++ b/fxjs/xfa/cjx_model.h
@@ -14,7 +14,7 @@
 
 class CJX_Model : public CJX_Node {
  public:
-  explicit CJX_Model(CXFA_Node* obj);
+  CONSTRUCT_VIA_MAKE_GARBAGE_COLLECTED;
   ~CJX_Model() override;
 
   // CJX_Object:
@@ -27,6 +27,9 @@
   JSE_PROP(aliasNode);
   JSE_PROP(context);
 
+ protected:
+  explicit CJX_Model(CXFA_Node* obj);
+
  private:
   using Type__ = CJX_Model;
   using ParentType__ = CJX_Node;
diff --git a/fxjs/xfa/cjx_node.h b/fxjs/xfa/cjx_node.h
index 6d30351..bd1e13c 100644
--- a/fxjs/xfa/cjx_node.h
+++ b/fxjs/xfa/cjx_node.h
@@ -16,7 +16,7 @@
 
 class CJX_Node : public CJX_Tree {
  public:
-  explicit CJX_Node(CXFA_Node* node);
+  CONSTRUCT_VIA_MAKE_GARBAGE_COLLECTED;
   ~CJX_Node() override;
 
   // CJX_Object:
@@ -41,6 +41,8 @@
   JSE_PROP(oneOfChild);
 
  protected:
+  explicit CJX_Node(CXFA_Node* node);
+
   XFA_EventError execSingleEventByName(WideStringView wsEventName,
                                        XFA_Element eType);
 
diff --git a/fxjs/xfa/cjx_object.cpp b/fxjs/xfa/cjx_object.cpp
index 7b156bc..ba3ebb1 100644
--- a/fxjs/xfa/cjx_object.cpp
+++ b/fxjs/xfa/cjx_object.cpp
@@ -131,6 +131,11 @@
   return this;
 }
 
+void CJX_Object::Trace(cppgc::Visitor* visitor) const {
+  visitor->Trace(object_);
+  visitor->Trace(layout_item_);
+}
+
 bool CJX_Object::DynamicTypeIs(TypeTag eType) const {
   return eType == static_type__;
 }
diff --git a/fxjs/xfa/cjx_object.h b/fxjs/xfa/cjx_object.h
index a34654c..c3cdbf5 100644
--- a/fxjs/xfa/cjx_object.h
+++ b/fxjs/xfa/cjx_object.h
@@ -12,13 +12,14 @@
 #include <utility>
 #include <vector>
 
-#include "core/fxcrt/unowned_ptr.h"
 #include "core/fxcrt/widestring.h"
+#include "fxjs/gc/heap.h"
 #include "fxjs/xfa/fxjse.h"
 #include "fxjs/xfa/jse_define.h"
 #include "third_party/base/optional.h"
 #include "third_party/base/span.h"
-#include "v8/include/cppgc/persistent.h"
+#include "v8/include/cppgc/garbage-collected.h"
+#include "v8/include/cppgc/member.h"
 #include "xfa/fxfa/fxfa_basic.h"
 #include "xfa/fxfa/parser/cxfa_measurement.h"
 
@@ -57,7 +58,8 @@
   XFA_SOM_MandatoryMessage
 };
 
-class CJX_Object : public CFXJSE_HostObject {
+class CJX_Object : public cppgc::GarbageCollected<CJX_Object>,
+                   public CFXJSE_HostObject {
  public:
   // Corresponds 1:1 with CJX_ subclasses.
   enum class TypeTag {
@@ -98,12 +100,13 @@
     Xfa,
   };
 
-  explicit CJX_Object(CXFA_Object* obj);
+  CONSTRUCT_VIA_MAKE_GARBAGE_COLLECTED;
   ~CJX_Object() override;
 
   // CFXJSE_HostObject:
   CJX_Object* AsCJXObject() override;
 
+  virtual void Trace(cppgc::Visitor* visitor) const;
   virtual bool DynamicTypeIs(TypeTag eType) const;
 
   JSE_PROP(className);
@@ -222,6 +225,8 @@
   void ThrowTooManyOccurancesException(const WideString& obj) const;
 
  protected:
+  explicit CJX_Object(CXFA_Object* obj);
+
   void DefineMethods(pdfium::span<const CJX_MethodSpec> methods);
   void MoveBufferMapData(CXFA_Object* pSrcModule, CXFA_Object* pDstModule);
   void SetMapModuleString(void* pKey, WideStringView wsValue);
@@ -261,8 +266,8 @@
   void RemoveMapModuleKey(void* pKey);
   void MoveBufferMapData(CXFA_Object* pDstModule);
 
-  UnownedPtr<CXFA_Object> object_;
-  CXFA_LayoutItem* layout_item_ = nullptr;
+  cppgc::Member<CXFA_Object> object_;
+  cppgc::Member<CXFA_LayoutItem> layout_item_;
   std::unique_ptr<XFA_MAPMODULEDATA> map_module_data_;
   std::unique_ptr<CXFA_CalcData> calc_data_;
   std::map<ByteString, CJX_MethodCall> method_specs_;
diff --git a/fxjs/xfa/cjx_occur.h b/fxjs/xfa/cjx_occur.h
index 8b912b6..253ae92 100644
--- a/fxjs/xfa/cjx_occur.h
+++ b/fxjs/xfa/cjx_occur.h
@@ -14,7 +14,7 @@
 
 class CJX_Occur final : public CJX_Node {
  public:
-  explicit CJX_Occur(CXFA_Occur* node);
+  CONSTRUCT_VIA_MAKE_GARBAGE_COLLECTED;
   ~CJX_Occur() override;
 
   // CJX_Object:
@@ -24,6 +24,8 @@
   JSE_PROP(min);
 
  private:
+  explicit CJX_Occur(CXFA_Occur* node);
+
   using Type__ = CJX_Occur;
   using ParentType__ = CJX_Node;
 
diff --git a/fxjs/xfa/cjx_packet.h b/fxjs/xfa/cjx_packet.h
index df4a987..78af421 100644
--- a/fxjs/xfa/cjx_packet.h
+++ b/fxjs/xfa/cjx_packet.h
@@ -14,7 +14,7 @@
 
 class CJX_Packet final : public CJX_Node {
  public:
-  explicit CJX_Packet(CXFA_Packet* packet);
+  CONSTRUCT_VIA_MAKE_GARBAGE_COLLECTED;
   ~CJX_Packet() override;
 
   // CJX_Object:
@@ -27,6 +27,8 @@
   JSE_PROP(content);
 
  private:
+  explicit CJX_Packet(CXFA_Packet* packet);
+
   using Type__ = CJX_Packet;
   using ParentType__ = CJX_Node;
 
diff --git a/fxjs/xfa/cjx_script.h b/fxjs/xfa/cjx_script.h
index af7c985..f167afc 100644
--- a/fxjs/xfa/cjx_script.h
+++ b/fxjs/xfa/cjx_script.h
@@ -14,7 +14,7 @@
 
 class CJX_Script final : public CJX_Node {
  public:
-  explicit CJX_Script(CXFA_Script* node);
+  CONSTRUCT_VIA_MAKE_GARBAGE_COLLECTED;
   ~CJX_Script() override;
 
   // CJX_Object:
@@ -23,6 +23,8 @@
   JSE_PROP(stateless);
 
  private:
+  explicit CJX_Script(CXFA_Script* node);
+
   using Type__ = CJX_Script;
   using ParentType__ = CJX_Node;
 
diff --git a/fxjs/xfa/cjx_signaturepseudomodel.h b/fxjs/xfa/cjx_signaturepseudomodel.h
index ed77238..b423821 100644
--- a/fxjs/xfa/cjx_signaturepseudomodel.h
+++ b/fxjs/xfa/cjx_signaturepseudomodel.h
@@ -14,7 +14,7 @@
 
 class CJX_SignaturePseudoModel final : public CJX_Object {
  public:
-  explicit CJX_SignaturePseudoModel(CScript_SignaturePseudoModel* model);
+  CONSTRUCT_VIA_MAKE_GARBAGE_COLLECTED;
   ~CJX_SignaturePseudoModel() override;
 
   // CJX_Object:
@@ -26,6 +26,8 @@
   JSE_METHOD(clear);
 
  private:
+  explicit CJX_SignaturePseudoModel(CScript_SignaturePseudoModel* model);
+
   using Type__ = CJX_SignaturePseudoModel;
   using ParentType__ = CJX_Object;
 
diff --git a/fxjs/xfa/cjx_source.h b/fxjs/xfa/cjx_source.h
index cd70601..0d13818 100644
--- a/fxjs/xfa/cjx_source.h
+++ b/fxjs/xfa/cjx_source.h
@@ -14,7 +14,7 @@
 
 class CJX_Source final : public CJX_Node {
  public:
-  explicit CJX_Source(CXFA_Source* src);
+  CONSTRUCT_VIA_MAKE_GARBAGE_COLLECTED;
   ~CJX_Source() override;
 
   // CJX_Object:
@@ -41,6 +41,8 @@
   JSE_PROP(db);
 
  private:
+  explicit CJX_Source(CXFA_Source* src);
+
   using Type__ = CJX_Source;
   using ParentType__ = CJX_Node;
 
diff --git a/fxjs/xfa/cjx_subform.h b/fxjs/xfa/cjx_subform.h
index 83ac66e..f236a76 100644
--- a/fxjs/xfa/cjx_subform.h
+++ b/fxjs/xfa/cjx_subform.h
@@ -10,11 +10,11 @@
 #include "fxjs/xfa/cjx_container.h"
 #include "fxjs/xfa/jse_define.h"
 
-class CXFA_Delta;
+class CXFA_Node;
 
 class CJX_Subform final : public CJX_Container {
  public:
-  explicit CJX_Subform(CXFA_Node* container);
+  CONSTRUCT_VIA_MAKE_GARBAGE_COLLECTED;
   ~CJX_Subform() override;
 
   // CJX_Object:
@@ -29,6 +29,8 @@
   JSE_PROP(locale);
 
  private:
+  explicit CJX_Subform(CXFA_Node* container);
+
   using Type__ = CJX_Subform;
   using ParentType__ = CJX_Container;
 
diff --git a/fxjs/xfa/cjx_template.h b/fxjs/xfa/cjx_template.h
index d396459..3705155 100644
--- a/fxjs/xfa/cjx_template.h
+++ b/fxjs/xfa/cjx_template.h
@@ -14,7 +14,7 @@
 
 class CJX_Template final : public CJX_Model {
  public:
-  explicit CJX_Template(CXFA_Template* tmpl);
+  CONSTRUCT_VIA_MAKE_GARBAGE_COLLECTED;
   ~CJX_Template() override;
 
   // CJX_Object:
@@ -31,6 +31,8 @@
   JSE_METHOD(remerge);
 
  private:
+  explicit CJX_Template(CXFA_Template* tmpl);
+
   using Type__ = CJX_Template;
   using ParentType__ = CJX_Model;
 
diff --git a/fxjs/xfa/cjx_textnode.h b/fxjs/xfa/cjx_textnode.h
index 6d74658..7db8a23 100644
--- a/fxjs/xfa/cjx_textnode.h
+++ b/fxjs/xfa/cjx_textnode.h
@@ -14,7 +14,7 @@
 
 class CJX_TextNode : public CJX_Node {
  public:
-  explicit CJX_TextNode(CXFA_Node* node);
+  CONSTRUCT_VIA_MAKE_GARBAGE_COLLECTED;
   ~CJX_TextNode() override;
 
   // CJX_Object:
@@ -23,6 +23,9 @@
   JSE_PROP(defaultValue); /* {default} */
   JSE_PROP(value);
 
+ protected:
+  explicit CJX_TextNode(CXFA_Node* node);
+
  private:
   using Type__ = CJX_TextNode;
   using ParentType__ = CJX_Node;
diff --git a/fxjs/xfa/cjx_tree.h b/fxjs/xfa/cjx_tree.h
index cbef888..54dd88d 100644
--- a/fxjs/xfa/cjx_tree.h
+++ b/fxjs/xfa/cjx_tree.h
@@ -10,12 +10,13 @@
 #include "fxjs/xfa/cjx_object.h"
 #include "fxjs/xfa/jse_define.h"
 
+class CFXJSE_Value;
 class CXFA_Object;
 class CXFA_Node;
 
 class CJX_Tree : public CJX_Object {
  public:
-  explicit CJX_Tree(CXFA_Object* obj);
+  CONSTRUCT_VIA_MAKE_GARBAGE_COLLECTED;
   ~CJX_Tree() override;
 
   // CJX_Object:
@@ -32,6 +33,9 @@
   JSE_PROP(parent);
   JSE_PROP(somExpression);
 
+ protected:
+  explicit CJX_Tree(CXFA_Object* obj);
+
  private:
   using Type__ = CJX_Tree;
   using ParentType__ = CJX_Object;
diff --git a/fxjs/xfa/cjx_treelist.h b/fxjs/xfa/cjx_treelist.h
index 294ab26..9e5f6cf 100644
--- a/fxjs/xfa/cjx_treelist.h
+++ b/fxjs/xfa/cjx_treelist.h
@@ -14,7 +14,7 @@
 
 class CJX_TreeList final : public CJX_List {
  public:
-  explicit CJX_TreeList(CXFA_TreeList* list);
+  CONSTRUCT_VIA_MAKE_GARBAGE_COLLECTED;
   ~CJX_TreeList() override;
 
   // CJX_Object:
@@ -23,6 +23,8 @@
   JSE_METHOD(namedItem);
 
  private:
+  explicit CJX_TreeList(CXFA_TreeList* list);
+
   using Type__ = CJX_TreeList;
   using ParentType__ = CJX_List;
 
diff --git a/fxjs/xfa/cjx_wsdlconnection.h b/fxjs/xfa/cjx_wsdlconnection.h
index bd5db40..4ed862c 100644
--- a/fxjs/xfa/cjx_wsdlconnection.h
+++ b/fxjs/xfa/cjx_wsdlconnection.h
@@ -14,7 +14,7 @@
 
 class CJX_WsdlConnection final : public CJX_Node {
  public:
-  explicit CJX_WsdlConnection(CXFA_WsdlConnection* connection);
+  CONSTRUCT_VIA_MAKE_GARBAGE_COLLECTED;
   ~CJX_WsdlConnection() override;
 
   // CJX_Object:
@@ -23,6 +23,8 @@
   JSE_METHOD(execute);
 
  private:
+  explicit CJX_WsdlConnection(CXFA_WsdlConnection* connection);
+
   using Type__ = CJX_WsdlConnection;
   using ParentType__ = CJX_Node;
 
diff --git a/fxjs/xfa/cjx_xfa.h b/fxjs/xfa/cjx_xfa.h
index 63b0f5f..1582095 100644
--- a/fxjs/xfa/cjx_xfa.h
+++ b/fxjs/xfa/cjx_xfa.h
@@ -14,7 +14,7 @@
 
 class CJX_Xfa final : public CJX_Model {
  public:
-  explicit CJX_Xfa(CXFA_Xfa* node);
+  CONSTRUCT_VIA_MAKE_GARBAGE_COLLECTED;
   ~CJX_Xfa() override;
 
   // CJX_Object:
@@ -23,6 +23,8 @@
   JSE_PROP(thisValue); /* this */
 
  private:
+  explicit CJX_Xfa(CXFA_Xfa* node);
+
   using Type__ = CJX_Xfa;
   using ParentType__ = CJX_Model;