Add CXFA_Document::GetHeap(). Since CXFA_Document creates the various CXFA_Nodes, this will be a big help in allowing them to be GC'd down the road. The heap is reachable, but is a couple of hops away, so add the function here rather than making callers do these steps over and over. -- Move some forward declarations even more forward. Change-Id: Ic589bf7d4a4c47cc69344226ffd1c48def3585be Reviewed-on: https://pdfium-review.googlesource.com/c/pdfium/+/71390 Reviewed-by: Lei Zhang <thestig@chromium.org> Commit-Queue: Tom Sepez <tsepez@chromium.org>
diff --git a/xfa/fxfa/cxfa_ffdoc.h b/xfa/fxfa/cxfa_ffdoc.h index 67852e4..461ffaa 100644 --- a/xfa/fxfa/cxfa_ffdoc.h +++ b/xfa/fxfa/cxfa_ffdoc.h
@@ -58,6 +58,7 @@ return m_pDocEnvironment.Get(); } FormType GetFormType() const { return m_FormType; } + cppgc::Heap* GetHeap() const { return m_pHeap.Get(); } CFX_XMLDocument* GetXMLDocument() const { return m_pXMLDoc.get(); } CXFA_FFDocView* CreateDocView();
diff --git a/xfa/fxfa/parser/cxfa_document.cpp b/xfa/fxfa/parser/cxfa_document.cpp index b62d94c..98d65c0 100644 --- a/xfa/fxfa/parser/cxfa_document.cpp +++ b/xfa/fxfa/parser/cxfa_document.cpp
@@ -1412,6 +1412,10 @@ return m_pLocaleMgr.get(); } +cppgc::Heap* CXFA_Document::GetHeap() const { + return notify_->GetFFDoc()->GetHeap(); +} + CFXJSE_Engine* CXFA_Document::InitScriptContext(CJS_Runtime* fxjs_runtime) { ASSERT(!m_pScriptContext); m_pScriptContext = std::make_unique<CFXJSE_Engine>(this, fxjs_runtime);
diff --git a/xfa/fxfa/parser/cxfa_document.h b/xfa/fxfa/parser/cxfa_document.h index 8509d19..c9fa4bf 100644 --- a/xfa/fxfa/parser/cxfa_document.h +++ b/xfa/fxfa/parser/cxfa_document.h
@@ -17,6 +17,22 @@ #include "xfa/fxfa/parser/cxfa_localemgr.h" #include "xfa/fxfa/parser/cxfa_nodeowner.h" +class CFXJSE_Engine; +class CJS_Runtime; +class CScript_DataWindow; +class CScript_EventPseudoModel; +class CScript_HostPseudoModel; +class CScript_LayoutPseudoModel; +class CScript_LogPseudoModel; +class CScript_SignaturePseudoModel; +class CXFA_FFNotify; +class CXFA_Node; +class CXFA_Object; + +namespace cppgc { +class Heap; +} // namespace cppgc + enum XFA_VERSION { XFA_VERSION_UNKNOWN = 0, XFA_VERSION_200 = 200, @@ -35,18 +51,6 @@ XFA_VERSION_MAX = 400, }; -class CFXJSE_Engine; -class CJS_Runtime; -class CScript_DataWindow; -class CScript_EventPseudoModel; -class CScript_HostPseudoModel; -class CScript_LayoutPseudoModel; -class CScript_LogPseudoModel; -class CScript_SignaturePseudoModel; -class CXFA_FFNotify; -class CXFA_Node; -class CXFA_Object; - class CXFA_Document final : public CXFA_NodeOwner { public: class LayoutProcessorIface { @@ -77,6 +81,7 @@ CFXJSE_Engine* GetScriptContext() const; CXFA_FFNotify* GetNotify() const { return notify_.Get(); } + cppgc::Heap* GetHeap() const; CXFA_LocaleMgr* GetLocaleMgr(); CXFA_Object* GetXFAObject(XFA_HashCode wsNodeNameHash); CXFA_Node* GetNodeByID(CXFA_Node* pRoot, WideStringView wsID) const;