Add prefinalizers for other CXFA_FF* classes

Similar to previous patch, but these weren't hit yet by testing
of subsequent patches. But they can't be good.

Bug: pdfium:1563
Change-Id: I2e49b811ea9f1295bd375149ad08abf3302df45b
Reviewed-on: https://pdfium-review.googlesource.com/c/pdfium/+/72915
Commit-Queue: Tom Sepez <tsepez@chromium.org>
Reviewed-by: Lei Zhang <thestig@chromium.org>
diff --git a/xfa/fxfa/cxfa_ffimage.cpp b/xfa/fxfa/cxfa_ffimage.cpp
index eeb0e24..c7c09f6 100644
--- a/xfa/fxfa/cxfa_ffimage.cpp
+++ b/xfa/fxfa/cxfa_ffimage.cpp
@@ -17,8 +17,11 @@
 
 CXFA_FFImage::CXFA_FFImage(CXFA_Node* pNode) : CXFA_FFWidget(pNode) {}
 
-CXFA_FFImage::~CXFA_FFImage() {
+CXFA_FFImage::~CXFA_FFImage() = default;
+
+void CXFA_FFImage::PreFinalize() {
   GetNode()->SetImageImage(nullptr);
+  CXFA_FFWidget::PreFinalize();
 }
 
 bool CXFA_FFImage::IsLoaded() {
diff --git a/xfa/fxfa/cxfa_ffimage.h b/xfa/fxfa/cxfa_ffimage.h
index 73fe546..d75e5b5 100644
--- a/xfa/fxfa/cxfa_ffimage.h
+++ b/xfa/fxfa/cxfa_ffimage.h
@@ -14,7 +14,8 @@
   CONSTRUCT_VIA_MAKE_GARBAGE_COLLECTED;
   ~CXFA_FFImage() override;
 
-  // CXFA_FFWidget
+  // CXFA_FFWidget:
+  void PreFinalize() override;
   void RenderWidget(CXFA_Graphics* pGS,
                     const CFX_Matrix& matrix,
                     HighlightOption highlight) override;
diff --git a/xfa/fxfa/cxfa_ffimageedit.cpp b/xfa/fxfa/cxfa_ffimageedit.cpp
index 55fd3d3..c8e1961 100644
--- a/xfa/fxfa/cxfa_ffimageedit.cpp
+++ b/xfa/fxfa/cxfa_ffimageedit.cpp
@@ -26,8 +26,11 @@
 
 CXFA_FFImageEdit::CXFA_FFImageEdit(CXFA_Node* pNode) : CXFA_FFField(pNode) {}
 
-CXFA_FFImageEdit::~CXFA_FFImageEdit() {
+CXFA_FFImageEdit::~CXFA_FFImageEdit() = default;
+
+void CXFA_FFImageEdit::PreFinalize() {
   m_pNode->SetImageEditImage(nullptr);
+  CXFA_FFField::PreFinalize();
 }
 
 bool CXFA_FFImageEdit::LoadWidget() {
diff --git a/xfa/fxfa/cxfa_ffimageedit.h b/xfa/fxfa/cxfa_ffimageedit.h
index 1dd27d8..dd3376c 100644
--- a/xfa/fxfa/cxfa_ffimageedit.h
+++ b/xfa/fxfa/cxfa_ffimageedit.h
@@ -15,7 +15,8 @@
   CONSTRUCT_VIA_MAKE_GARBAGE_COLLECTED;
   ~CXFA_FFImageEdit() override;
 
-  // CXFA_FFField
+  // CXFA_FFField:
+  void PreFinalize() override;
   void RenderWidget(CXFA_Graphics* pGS,
                     const CFX_Matrix& matrix,
                     HighlightOption highlight) override;
diff --git a/xfa/fxfa/cxfa_fflistbox.cpp b/xfa/fxfa/cxfa_fflistbox.cpp
index 15960d4..819f7ba 100644
--- a/xfa/fxfa/cxfa_fflistbox.cpp
+++ b/xfa/fxfa/cxfa_fflistbox.cpp
@@ -28,13 +28,15 @@
 
 CXFA_FFListBox::CXFA_FFListBox(CXFA_Node* pNode) : CXFA_FFDropDown(pNode) {}
 
-CXFA_FFListBox::~CXFA_FFListBox() {
-  if (!GetNormalWidget())
-    return;
+CXFA_FFListBox::~CXFA_FFListBox() = default;
 
-  CFWL_NoteDriver* pNoteDriver =
-      GetNormalWidget()->GetFWLApp()->GetNoteDriver();
-  pNoteDriver->UnregisterEventTarget(GetNormalWidget());
+void CXFA_FFListBox::PreFinalize() {
+  if (GetNormalWidget()) {
+    CFWL_NoteDriver* pNoteDriver =
+        GetNormalWidget()->GetFWLApp()->GetNoteDriver();
+    pNoteDriver->UnregisterEventTarget(GetNormalWidget());
+  }
+  CXFA_FFDropDown::PreFinalize();
 }
 
 bool CXFA_FFListBox::LoadWidget() {
diff --git a/xfa/fxfa/cxfa_fflistbox.h b/xfa/fxfa/cxfa_fflistbox.h
index 11074ef..581bbd8 100644
--- a/xfa/fxfa/cxfa_fflistbox.h
+++ b/xfa/fxfa/cxfa_fflistbox.h
@@ -16,6 +16,7 @@
   ~CXFA_FFListBox() override;
 
   // CXFA_FFField:
+  void PreFinalize() override;
   bool LoadWidget() override;
   bool OnKillFocus(CXFA_FFWidget* pNewWidget) override WARN_UNUSED_RESULT;
   void OnProcessMessage(CFWL_Message* pMessage) override;