Remove CFWL_WidgetProperties::m_pFWLThemeProvider.

The IFWL_ThemeProvider, as implemented by CXFA_FWLThemeProvider is
essentially a singleton living in the CXFA_FFApp. Instead of storing
a theoretically changing pointer to it inside each of the FWL widget's
properties, retrieve the one and only instance as needed. Then remove
code to set it into widgets, which mainly involved propagating the
values to sub-widgets to keep them in sync.

Change-Id: Ia645a338bdc600cb9199d439c09aabdbe959bfe8
Reviewed-on: https://pdfium-review.googlesource.com/c/pdfium/+/72750
Commit-Queue: Tom Sepez <tsepez@chromium.org>
Reviewed-by: Lei Zhang <thestig@chromium.org>
diff --git a/xfa/fxfa/cxfa_ffapp.cpp b/xfa/fxfa/cxfa_ffapp.cpp
index d6f06a4..3686402 100644
--- a/xfa/fxfa/cxfa_ffapp.cpp
+++ b/xfa/fxfa/cxfa_ffapp.cpp
@@ -48,13 +48,13 @@
   return m_pFDEFontMgr.get();
 }
 
-CXFA_FWLTheme* CXFA_FFApp::GetFWLTheme(CXFA_FFDoc* doc) {
-  if (!m_pFWLTheme) {
-    auto fwl_theme = std::make_unique<CXFA_FWLTheme>(this);
-    if (fwl_theme->LoadCalendarFont(doc))
-      m_pFWLTheme = std::move(fwl_theme);
-  }
-  return m_pFWLTheme.get();
+bool CXFA_FFApp::LoadFWLTheme(CXFA_FFDoc* doc) {
+  auto fwl_theme = std::make_unique<CXFA_FWLTheme>(this);
+  if (!fwl_theme->LoadCalendarFont(doc))
+    return false;
+
+  m_pFWLTheme = std::move(fwl_theme);
+  return true;
 }
 
 CFWL_WidgetMgr::AdapterIface* CXFA_FFApp::GetWidgetMgrAdapter() {
@@ -66,3 +66,7 @@
 TimerHandlerIface* CXFA_FFApp::GetTimerHandler() {
   return m_pProvider->GetTimerHandler();
 }
+
+IFWL_ThemeProvider* CXFA_FFApp::GetThemeProvider() {
+  return m_pFWLTheme.get();
+}
diff --git a/xfa/fxfa/cxfa_ffapp.h b/xfa/fxfa/cxfa_ffapp.h
index e3bac30..2c513fd 100644
--- a/xfa/fxfa/cxfa_ffapp.h
+++ b/xfa/fxfa/cxfa_ffapp.h
@@ -29,10 +29,11 @@
   // CFWL_App::AdapterIface:
   CFWL_WidgetMgr::AdapterIface* GetWidgetMgrAdapter() override;
   TimerHandlerIface* GetTimerHandler() override;
+  IFWL_ThemeProvider* GetThemeProvider() override;
 
+  bool LoadFWLTheme(CXFA_FFDoc* doc);
   CFWL_WidgetMgr* GetFWLWidgetMgr() const { return m_pFWLApp->GetWidgetMgr(); }
   CFGAS_FontMgr* GetFDEFontMgr();
-  CXFA_FWLTheme* GetFWLTheme(CXFA_FFDoc* doc);
 
   IXFA_AppProvider* GetAppProvider() const { return m_pProvider.Get(); }
   const CFWL_App* GetFWLApp() const { return m_pFWLApp.get(); }
diff --git a/xfa/fxfa/cxfa_fffield.cpp b/xfa/fxfa/cxfa_fffield.cpp
index f4cd6dc..046f401 100644
--- a/xfa/fxfa/cxfa_fffield.cpp
+++ b/xfa/fxfa/cxfa_fffield.cpp
@@ -124,11 +124,6 @@
   pGS->StrokePath(&path, pMatrix);
 }
 
-void CXFA_FFField::SetFWLThemeProvider() {
-  if (GetNormalWidget())
-    GetNormalWidget()->SetThemeProvider(GetApp()->GetFWLTheme(GetDoc()));
-}
-
 CFWL_Widget* CXFA_FFField::GetNormalWidget() {
   return m_pNormalWidget.get();
 }
@@ -148,8 +143,6 @@
 bool CXFA_FFField::LoadWidget() {
   // Prevents destruction of the CXFA_ContentLayoutItem that owns |this|.
   RetainPtr<CXFA_ContentLayoutItem> retain_layout(m_pLayoutItem.Get());
-
-  SetFWLThemeProvider();
   m_pNode->LoadCaption(GetDoc());
   PerformLayout();
   return true;
diff --git a/xfa/fxfa/cxfa_fffield.h b/xfa/fxfa/cxfa_fffield.h
index dbfd2ac..565df66 100644
--- a/xfa/fxfa/cxfa_fffield.h
+++ b/xfa/fxfa/cxfa_fffield.h
@@ -73,7 +73,6 @@
   bool PtInActiveRect(const CFX_PointF& point) override;
 
   virtual void SetFWLRect();
-  void SetFWLThemeProvider();
   CFWL_Widget* GetNormalWidget();
   const CFWL_Widget* GetNormalWidget() const;
   void SetNormalWidget(std::unique_ptr<CFWL_Widget> widget);