Avoid holding raw pointer to GCed sub-class through virtual interface.

Make the interface a gc-mixin, and trace it like any other member. This
is strictly more correct, though it shouldn't matter because of other
traced pointers back to the widget thru the widget mgr.

Change-Id: Ia496102534c5141a5be33091f6804f48ffa4dc5d
Reviewed-on: https://pdfium-review.googlesource.com/c/pdfium/+/79370
Commit-Queue: Tom Sepez <tsepez@chromium.org>
Reviewed-by: Lei Zhang <thestig@chromium.org>
diff --git a/xfa/fwl/cfwl_widget.cpp b/xfa/fwl/cfwl_widget.cpp
index 63ad532..ff783ae 100644
--- a/xfa/fwl/cfwl_widget.cpp
+++ b/xfa/fwl/cfwl_widget.cpp
@@ -53,6 +53,7 @@
 }
 
 void CFWL_Widget::Trace(cppgc::Visitor* visitor) const {
+  visitor->Trace(m_pAdapterIface);
   visitor->Trace(m_pFWLApp);
   visitor->Trace(m_pWidgetMgr);
   visitor->Trace(m_pDelegate);
diff --git a/xfa/fwl/cfwl_widget.h b/xfa/fwl/cfwl_widget.h
index 60939a0..28ff8e7 100644
--- a/xfa/fwl/cfwl_widget.h
+++ b/xfa/fwl/cfwl_widget.h
@@ -54,7 +54,7 @@
   CPPGC_USING_PRE_FINALIZER(CFWL_Widget, PreFinalize);
 
  public:
-  class AdapterIface {
+  class AdapterIface : public cppgc::GarbageCollectedMixin {
    public:
     virtual ~AdapterIface() = default;
     virtual CFX_Matrix GetRotateMatrix() = 0;
@@ -184,7 +184,7 @@
 
   int32_t m_iLock = 0;
   uint64_t m_nEventKey = 0;
-  AdapterIface* m_pAdapterIface = nullptr;
+  cppgc::Member<AdapterIface> m_pAdapterIface;
   cppgc::Member<CFWL_App> const m_pFWLApp;
   cppgc::Member<CFWL_WidgetMgr> const m_pWidgetMgr;
   cppgc::Member<IFWL_WidgetDelegate> m_pDelegate;
diff --git a/xfa/fxfa/cxfa_ffwidget.h b/xfa/fxfa/cxfa_ffwidget.h
index ddf29fb..04afd14 100644
--- a/xfa/fxfa/cxfa_ffwidget.h
+++ b/xfa/fxfa/cxfa_ffwidget.h
@@ -72,7 +72,7 @@
   ~CXFA_FFWidget() override;
 
   virtual void PreFinalize();
-  virtual void Trace(cppgc::Visitor* visitor) const;
+  void Trace(cppgc::Visitor* visitor) const override;
 
   // CFWL_Widget::AdapterIface:
   CFX_Matrix GetRotateMatrix() override;