More FWL interface cleanup.

This CL merges the IFWL_Target class into IFWL_Widget and IFWL_Thread into
IFWL_App. The IFWL_WidgetMgrDelegate, IFWL_NoteDriver and IFWL_NotThread are
removed in favour of their concrete classes.

Review-Url: https://codereview.chromium.org/1921853006
diff --git a/BUILD.gn b/BUILD.gn
index 133fee8..86e0da3 100644
--- a/BUILD.gn
+++ b/BUILD.gn
@@ -1029,10 +1029,6 @@
       "xfa/fwl/core/fwl_noteimp.h",
       "xfa/fwl/core/fwl_sdadapterimp.cpp",
       "xfa/fwl/core/fwl_sdadapterimp.h",
-      "xfa/fwl/core/fwl_targetimp.cpp",
-      "xfa/fwl/core/fwl_targetimp.h",
-      "xfa/fwl/core/fwl_threadimp.cpp",
-      "xfa/fwl/core/fwl_threadimp.h",
       "xfa/fwl/core/fwl_timerimp.cpp",
       "xfa/fwl/core/fwl_widgetdef.h",
       "xfa/fwl/core/fwl_widgetimp.cpp",
@@ -1045,17 +1041,12 @@
       "xfa/fwl/core/ifwl_app.h",
       "xfa/fwl/core/ifwl_dataprovider.h",
       "xfa/fwl/core/ifwl_form.h",
-      "xfa/fwl/core/ifwl_notedriver.h",
-      "xfa/fwl/core/ifwl_noteloop.h",
-      "xfa/fwl/core/ifwl_target.h",
       "xfa/fwl/core/ifwl_themeprovider.h",
-      "xfa/fwl/core/ifwl_thread.h",
       "xfa/fwl/core/ifwl_timer.h",
       "xfa/fwl/core/ifwl_tooltiptarget.h",
       "xfa/fwl/core/ifwl_widget.h",
       "xfa/fwl/core/ifwl_widgetdelegate.h",
       "xfa/fwl/core/ifwl_widgetmgr.h",
-      "xfa/fwl/core/ifwl_widgetmgrdelegate.h",
       "xfa/fwl/core/include/ifwl_adaptertimermgr.h",
       "xfa/fwl/lightwidget/cfwl_barcode.cpp",
       "xfa/fwl/lightwidget/cfwl_barcode.h",
diff --git a/xfa.gyp b/xfa.gyp
index 72d2c8f..25b0646 100644
--- a/xfa.gyp
+++ b/xfa.gyp
@@ -186,10 +186,6 @@
         "xfa/fwl/core/fwl_noteimp.h",
         "xfa/fwl/core/fwl_sdadapterimp.cpp",
         "xfa/fwl/core/fwl_sdadapterimp.h",
-        "xfa/fwl/core/fwl_targetimp.cpp",
-        "xfa/fwl/core/fwl_targetimp.h",
-        "xfa/fwl/core/fwl_threadimp.cpp",
-        "xfa/fwl/core/fwl_threadimp.h",
         "xfa/fwl/core/fwl_timerimp.cpp",
         "xfa/fwl/core/fwl_widgetdef.h",
         "xfa/fwl/core/fwl_widgetimp.cpp",
@@ -202,17 +198,12 @@
         "xfa/fwl/core/ifwl_app.h",
         "xfa/fwl/core/ifwl_dataprovider.h",
         "xfa/fwl/core/ifwl_form.h",
-        "xfa/fwl/core/ifwl_notedriver.h",
-        "xfa/fwl/core/ifwl_noteloop.h",
-        "xfa/fwl/core/ifwl_target.h",
         "xfa/fwl/core/ifwl_themeprovider.h",
-        "xfa/fwl/core/ifwl_thread.h",
         "xfa/fwl/core/ifwl_timer.h",
         "xfa/fwl/core/ifwl_tooltiptarget.h",
         "xfa/fwl/core/ifwl_widget.h",
         "xfa/fwl/core/ifwl_widgetdelegate.h",
         "xfa/fwl/core/ifwl_widgetmgr.h",
-        "xfa/fwl/core/ifwl_widgetmgrdelegate.h",
         "xfa/fwl/core/include/ifwl_adaptertimermgr.h",
         "xfa/fwl/lightwidget/cfwl_barcode.cpp",
         "xfa/fwl/lightwidget/cfwl_barcode.h",
diff --git a/xfa/fwl/basewidget/fwl_barcodeimp.cpp b/xfa/fwl/basewidget/fwl_barcodeimp.cpp
index cc0bd62..d4589e3 100644
--- a/xfa/fwl/basewidget/fwl_barcodeimp.cpp
+++ b/xfa/fwl/basewidget/fwl_barcodeimp.cpp
@@ -10,7 +10,6 @@
 #include "xfa/fwl/basewidget/fxmath_barcodeimp.h"
 #include "xfa/fwl/core/cfwl_themepart.h"
 #include "xfa/fwl/core/fwl_noteimp.h"
-#include "xfa/fwl/core/fwl_targetimp.h"
 #include "xfa/fwl/core/fwl_widgetimp.h"
 #include "xfa/fwl/core/ifwl_themeprovider.h"
 
diff --git a/xfa/fwl/basewidget/fwl_caretimp.cpp b/xfa/fwl/basewidget/fwl_caretimp.cpp
index 959398c..3cb2ed6 100644
--- a/xfa/fwl/basewidget/fwl_caretimp.cpp
+++ b/xfa/fwl/basewidget/fwl_caretimp.cpp
@@ -9,7 +9,6 @@
 #include "xfa/fwl/basewidget/ifwl_caret.h"
 #include "xfa/fwl/core/cfwl_themebackground.h"
 #include "xfa/fwl/core/fwl_noteimp.h"
-#include "xfa/fwl/core/fwl_targetimp.h"
 #include "xfa/fwl/core/fwl_widgetimp.h"
 #include "xfa/fwl/core/ifwl_themeprovider.h"
 
diff --git a/xfa/fwl/basewidget/fwl_checkboximp.cpp b/xfa/fwl/basewidget/fwl_checkboximp.cpp
index e511b8e4..76d5b8f 100644
--- a/xfa/fwl/basewidget/fwl_checkboximp.cpp
+++ b/xfa/fwl/basewidget/fwl_checkboximp.cpp
@@ -14,7 +14,6 @@
 #include "xfa/fwl/core/cfwl_themebackground.h"
 #include "xfa/fwl/core/cfwl_themetext.h"
 #include "xfa/fwl/core/fwl_noteimp.h"
-#include "xfa/fwl/core/fwl_targetimp.h"
 #include "xfa/fwl/core/fwl_widgetimp.h"
 #include "xfa/fwl/core/fwl_widgetmgrimp.h"
 #include "xfa/fwl/core/ifwl_themeprovider.h"
diff --git a/xfa/fwl/basewidget/fwl_comboboximp.cpp b/xfa/fwl/basewidget/fwl_comboboximp.cpp
index d04c641..60794da4 100644
--- a/xfa/fwl/basewidget/fwl_comboboximp.cpp
+++ b/xfa/fwl/basewidget/fwl_comboboximp.cpp
@@ -18,12 +18,10 @@
 #include "xfa/fwl/core/fwl_appimp.h"
 #include "xfa/fwl/core/fwl_formimp.h"
 #include "xfa/fwl/core/fwl_noteimp.h"
-#include "xfa/fwl/core/fwl_targetimp.h"
-#include "xfa/fwl/core/fwl_threadimp.h"
 #include "xfa/fwl/core/fwl_widgetimp.h"
 #include "xfa/fwl/core/fwl_widgetmgrimp.h"
+#include "xfa/fwl/core/ifwl_app.h"
 #include "xfa/fwl/core/ifwl_themeprovider.h"
-#include "xfa/fwl/core/ifwl_thread.h"
 
 // static
 IFWL_ComboBox* IFWL_ComboBox::Create(
@@ -1457,8 +1455,8 @@
 }
 void CFWL_ComboBoxImpDelegate::OnFocusChanged(CFWL_Message* pMsg,
                                               FX_BOOL bSet) {
-  IFWL_Target* pDstTarget = pMsg->m_pDstTarget;
-  IFWL_Target* pSrcTarget = pMsg->m_pSrcTarget;
+  IFWL_Widget* pDstTarget = pMsg->m_pDstTarget;
+  IFWL_Widget* pSrcTarget = pMsg->m_pSrcTarget;
   FX_BOOL bDropDown = m_pOwner->IsDropDownStyle();
   if (bSet) {
     m_pOwner->m_pProperties->m_dwStates |= FWL_WGTSTATE_Focused;
@@ -1803,11 +1801,12 @@
   return FWL_ERR_Succeeded;
 }
 void CFWL_ComboProxyImpDelegate::OnLButtonDown(CFWL_MsgMouse* pMsg) {
-  IFWL_Thread* pThread = m_pForm->GetOwnerThread();
-  if (!pThread)
+  IFWL_App* pApp = m_pForm->GetOwnerApp();
+  if (!pApp)
     return;
+
   CFWL_NoteDriver* pDriver =
-      static_cast<CFWL_NoteDriver*>(pThread->GetNoteDriver());
+      static_cast<CFWL_NoteDriver*>(pApp->GetNoteDriver());
   CFX_RectF rtWidget;
   m_pForm->GetWidgetRect(rtWidget);
   rtWidget.left = rtWidget.top = 0;
@@ -1822,11 +1821,12 @@
 }
 void CFWL_ComboProxyImpDelegate::OnLButtonUp(CFWL_MsgMouse* pMsg) {
   m_bLButtonDown = FALSE;
-  IFWL_Thread* pThread = m_pForm->GetOwnerThread();
-  if (!pThread)
+  IFWL_App* pApp = m_pForm->GetOwnerApp();
+  if (!pApp)
     return;
+
   CFWL_NoteDriver* pDriver =
-      static_cast<CFWL_NoteDriver*>(pThread->GetNoteDriver());
+      static_cast<CFWL_NoteDriver*>(pApp->GetNoteDriver());
   pDriver->SetGrab(m_pForm, FALSE);
   if (m_bLButtonUpSelf) {
     CFX_RectF rect;
diff --git a/xfa/fwl/basewidget/fwl_datetimepickerimp.cpp b/xfa/fwl/basewidget/fwl_datetimepickerimp.cpp
index 94fa549..941b222 100644
--- a/xfa/fwl/basewidget/fwl_datetimepickerimp.cpp
+++ b/xfa/fwl/basewidget/fwl_datetimepickerimp.cpp
@@ -14,7 +14,6 @@
 #include "xfa/fwl/core/cfwl_themebackground.h"
 #include "xfa/fwl/core/fwl_formimp.h"
 #include "xfa/fwl/core/fwl_noteimp.h"
-#include "xfa/fwl/core/fwl_targetimp.h"
 #include "xfa/fwl/core/fwl_widgetimp.h"
 #include "xfa/fwl/core/fwl_widgetmgrimp.h"
 #include "xfa/fwl/core/ifwl_themeprovider.h"
diff --git a/xfa/fwl/basewidget/fwl_editimp.cpp b/xfa/fwl/basewidget/fwl_editimp.cpp
index 74db0c9..86c6fe8 100644
--- a/xfa/fwl/basewidget/fwl_editimp.cpp
+++ b/xfa/fwl/basewidget/fwl_editimp.cpp
@@ -22,8 +22,6 @@
 #include "xfa/fwl/core/cfwl_themepart.h"
 #include "xfa/fwl/core/fwl_appimp.h"
 #include "xfa/fwl/core/fwl_noteimp.h"
-#include "xfa/fwl/core/fwl_targetimp.h"
-#include "xfa/fwl/core/fwl_threadimp.h"
 #include "xfa/fwl/core/fwl_widgetimp.h"
 #include "xfa/fwl/core/fwl_widgetmgrimp.h"
 #include "xfa/fwl/core/ifwl_themeprovider.h"
diff --git a/xfa/fwl/basewidget/fwl_formproxyimp.cpp b/xfa/fwl/basewidget/fwl_formproxyimp.cpp
index b86f287..0a5bb67 100644
--- a/xfa/fwl/basewidget/fwl_formproxyimp.cpp
+++ b/xfa/fwl/basewidget/fwl_formproxyimp.cpp
@@ -8,7 +8,6 @@
 
 #include "xfa/fwl/core/fwl_formimp.h"
 #include "xfa/fwl/core/fwl_noteimp.h"
-#include "xfa/fwl/core/fwl_targetimp.h"
 #include "xfa/fwl/core/fwl_widgetimp.h"
 
 CFWL_FormProxyImp::CFWL_FormProxyImp(const CFWL_WidgetImpProperties& properties,
diff --git a/xfa/fwl/basewidget/fwl_listboximp.cpp b/xfa/fwl/basewidget/fwl_listboximp.cpp
index 49d5d41..9b5d2fc 100644
--- a/xfa/fwl/basewidget/fwl_listboximp.cpp
+++ b/xfa/fwl/basewidget/fwl_listboximp.cpp
@@ -14,7 +14,6 @@
 #include "xfa/fwl/core/cfwl_themepart.h"
 #include "xfa/fwl/core/cfwl_themetext.h"
 #include "xfa/fwl/core/fwl_noteimp.h"
-#include "xfa/fwl/core/fwl_targetimp.h"
 #include "xfa/fwl/core/fwl_widgetimp.h"
 #include "xfa/fwl/core/ifwl_themeprovider.h"
 
diff --git a/xfa/fwl/basewidget/fwl_monthcalendarimp.cpp b/xfa/fwl/basewidget/fwl_monthcalendarimp.cpp
index 32cec6d..4b7f342 100644
--- a/xfa/fwl/basewidget/fwl_monthcalendarimp.cpp
+++ b/xfa/fwl/basewidget/fwl_monthcalendarimp.cpp
@@ -14,7 +14,6 @@
 #include "xfa/fwl/core/cfwl_themebackground.h"
 #include "xfa/fwl/core/cfwl_themetext.h"
 #include "xfa/fwl/core/fwl_noteimp.h"
-#include "xfa/fwl/core/fwl_targetimp.h"
 #include "xfa/fwl/core/fwl_widgetimp.h"
 #include "xfa/fwl/core/ifwl_themeprovider.h"
 
diff --git a/xfa/fwl/basewidget/fwl_pictureboximp.cpp b/xfa/fwl/basewidget/fwl_pictureboximp.cpp
index e61dae3..4495a49 100644
--- a/xfa/fwl/basewidget/fwl_pictureboximp.cpp
+++ b/xfa/fwl/basewidget/fwl_pictureboximp.cpp
@@ -7,7 +7,6 @@
 #include "xfa/fwl/basewidget/fwl_pictureboximp.h"
 
 #include "xfa/fwl/core/fwl_noteimp.h"
-#include "xfa/fwl/core/fwl_targetimp.h"
 #include "xfa/fwl/core/fwl_widgetimp.h"
 #include "xfa/fwl/lightwidget/cfwl_picturebox.h"
 
diff --git a/xfa/fwl/basewidget/fwl_pushbuttonimp.cpp b/xfa/fwl/basewidget/fwl_pushbuttonimp.cpp
index 167d8f3..9d6e3b1 100644
--- a/xfa/fwl/basewidget/fwl_pushbuttonimp.cpp
+++ b/xfa/fwl/basewidget/fwl_pushbuttonimp.cpp
@@ -12,7 +12,6 @@
 #include "xfa/fwl/core/cfwl_themebackground.h"
 #include "xfa/fwl/core/cfwl_themetext.h"
 #include "xfa/fwl/core/fwl_noteimp.h"
-#include "xfa/fwl/core/fwl_targetimp.h"
 #include "xfa/fwl/core/fwl_widgetimp.h"
 #include "xfa/fwl/core/ifwl_themeprovider.h"
 
diff --git a/xfa/fwl/basewidget/fwl_scrollbarimp.cpp b/xfa/fwl/basewidget/fwl_scrollbarimp.cpp
index fed93fb..69c2895 100644
--- a/xfa/fwl/basewidget/fwl_scrollbarimp.cpp
+++ b/xfa/fwl/basewidget/fwl_scrollbarimp.cpp
@@ -11,7 +11,6 @@
 #include "xfa/fwl/core/cfwl_themebackground.h"
 #include "xfa/fwl/core/cfwl_themepart.h"
 #include "xfa/fwl/core/fwl_noteimp.h"
-#include "xfa/fwl/core/fwl_targetimp.h"
 #include "xfa/fwl/core/fwl_widgetimp.h"
 #include "xfa/fwl/core/ifwl_themeprovider.h"
 
diff --git a/xfa/fwl/basewidget/fwl_spinbuttonimp.cpp b/xfa/fwl/basewidget/fwl_spinbuttonimp.cpp
index 6d60d81..434f6dd 100644
--- a/xfa/fwl/basewidget/fwl_spinbuttonimp.cpp
+++ b/xfa/fwl/basewidget/fwl_spinbuttonimp.cpp
@@ -11,7 +11,6 @@
 #include "xfa/fwl/core/cfwl_themebackground.h"
 #include "xfa/fwl/core/cfwl_widgetimpproperties.h"
 #include "xfa/fwl/core/fwl_noteimp.h"
-#include "xfa/fwl/core/fwl_targetimp.h"
 #include "xfa/fwl/core/fwl_widgetimp.h"
 #include "xfa/fwl/core/ifwl_themeprovider.h"
 #include "xfa/fwl/core/ifwl_themeprovider.h"
diff --git a/xfa/fwl/basewidget/fwl_tooltipctrlimp.cpp b/xfa/fwl/basewidget/fwl_tooltipctrlimp.cpp
index 36751b6..2ce52c6 100644
--- a/xfa/fwl/basewidget/fwl_tooltipctrlimp.cpp
+++ b/xfa/fwl/basewidget/fwl_tooltipctrlimp.cpp
@@ -13,7 +13,6 @@
 #include "xfa/fwl/core/cfwl_themetext.h"
 #include "xfa/fwl/core/fwl_formimp.h"
 #include "xfa/fwl/core/fwl_noteimp.h"
-#include "xfa/fwl/core/fwl_targetimp.h"
 #include "xfa/fwl/core/fwl_widgetimp.h"
 #include "xfa/fwl/core/ifwl_themeprovider.h"
 #include "xfa/fwl/core/ifwl_tooltiptarget.h"
diff --git a/xfa/fwl/core/cfwl_themepart.h b/xfa/fwl/core/cfwl_themepart.h
index 5868465..df75a94 100644
--- a/xfa/fwl/core/cfwl_themepart.h
+++ b/xfa/fwl/core/cfwl_themepart.h
@@ -9,7 +9,6 @@
 
 #include "core/fxcrt/include/fx_coordinates.h"
 #include "core/fxcrt/include/fx_system.h"
-#include "xfa/fwl/core/ifwl_widget.h"
 
 enum class CFWL_Part {
   None = 0,
@@ -78,6 +77,8 @@
   CFWL_PartState_Selected = 1 << 14
 };
 
+class IFWL_Widget;
+
 class CFWL_ThemePart {
  public:
   CFWL_ThemePart()
diff --git a/xfa/fwl/core/fwl_appimp.cpp b/xfa/fwl/core/fwl_appimp.cpp
index 95ed0c9..0017aad 100644
--- a/xfa/fwl/core/fwl_appimp.cpp
+++ b/xfa/fwl/core/fwl_appimp.cpp
@@ -7,8 +7,6 @@
 #include "xfa/fwl/core/fwl_appimp.h"
 
 #include "xfa/fwl/core/fwl_noteimp.h"
-#include "xfa/fwl/core/fwl_targetimp.h"
-#include "xfa/fwl/core/fwl_threadimp.h"
 #include "xfa/fwl/core/fwl_widgetmgrimp.h"
 #include "xfa/fwl/core/ifwl_adapterwidgetmgr.h"
 #include "xfa/fwl/core/ifwl_app.h"
@@ -19,32 +17,46 @@
   pApp->SetImpl(new CFWL_AppImp(pApp, pAdapter));
   return pApp;
 }
+
+void IFWL_App::Release() {}
+
 FWL_ERR IFWL_App::Initialize() {
   return static_cast<CFWL_AppImp*>(GetImpl())->Initialize();
 }
+
 FWL_ERR IFWL_App::Finalize() {
   return static_cast<CFWL_AppImp*>(GetImpl())->Finalize();
 }
+
 IFWL_AdapterNative* IFWL_App::GetAdapterNative() {
   return static_cast<CFWL_AppImp*>(GetImpl())->GetAdapterNative();
 }
+
 IFWL_WidgetMgr* IFWL_App::GetWidgetMgr() {
   return static_cast<CFWL_AppImp*>(GetImpl())->GetWidgetMgr();
 }
+
 IFWL_ThemeProvider* IFWL_App::GetThemeProvider() {
   return static_cast<CFWL_AppImp*>(GetImpl())->GetThemeProvider();
 }
+
 FWL_ERR IFWL_App::SetThemeProvider(IFWL_ThemeProvider* pThemeProvider) {
   return static_cast<CFWL_AppImp*>(GetImpl())->SetThemeProvider(pThemeProvider);
 }
+
 FWL_ERR IFWL_App::Exit(int32_t iExitCode) {
   return static_cast<CFWL_AppImp*>(GetImpl())->Exit(iExitCode);
 }
 
+CFWL_NoteDriver* IFWL_App::GetNoteDriver() const {
+  return static_cast<CFWL_AppImp*>(GetImpl())->GetNoteDriver();
+}
+
 CFWL_AppImp::CFWL_AppImp(IFWL_App* pIface, IFWL_AdapterNative* pAdapter)
-    : CFWL_ThreadImp(pIface),
-      m_pAdapterNative(pAdapter),
-      m_pThemeProvider(nullptr) {}
+    : m_pAdapterNative(pAdapter),
+      m_pThemeProvider(nullptr),
+      m_pNoteDriver(new CFWL_NoteDriver),
+      m_pIface(pIface) {}
 
 CFWL_AppImp::~CFWL_AppImp() {
   CFWL_ToolTipContainer::DeleteInstance();
diff --git a/xfa/fwl/core/fwl_appimp.h b/xfa/fwl/core/fwl_appimp.h
index a713060..8743b54 100644
--- a/xfa/fwl/core/fwl_appimp.h
+++ b/xfa/fwl/core/fwl_appimp.h
@@ -9,18 +9,23 @@
 
 #include <memory>
 
-#include "xfa/fwl/core/fwl_threadimp.h"
+#include "xfa/fwl/core/fwl_noteimp.h"
 
 class CFWL_WidgetMgr;
 class IFWL_AdapterNative;
-class IFWL_WidgetMgr;
-class IFWL_ThemeProvider;
 class IFWL_App;
+class IFWL_NoteThread;
+class IFWL_ThemeProvider;
+class IFWL_WidgetMgr;
 
-class CFWL_AppImp : public CFWL_ThreadImp {
+class CFWL_AppImp {
  public:
   CFWL_AppImp(IFWL_App* pIface, IFWL_AdapterNative* pAdapter);
   virtual ~CFWL_AppImp();
+
+  IFWL_App* GetInterface() const { return m_pIface; }
+  CFWL_NoteDriver* GetNoteDriver() const { return m_pNoteDriver.get(); }
+
   virtual FWL_ERR Initialize();
   virtual FWL_ERR Finalize();
   virtual IFWL_AdapterNative* GetAdapterNative() const;
@@ -33,6 +38,10 @@
   IFWL_AdapterNative* const m_pAdapterNative;
   std::unique_ptr<CFWL_WidgetMgr> m_pWidgetMgr;
   IFWL_ThemeProvider* m_pThemeProvider;
+  std::unique_ptr<CFWL_NoteDriver> m_pNoteDriver;
+
+ private:
+  IFWL_App* const m_pIface;
 };
 
 #endif  // XFA_FWL_CORE_FWL_APPIMP_H_
diff --git a/xfa/fwl/core/fwl_formimp.cpp b/xfa/fwl/core/fwl_formimp.cpp
index e31f7e8..815aca9 100644
--- a/xfa/fwl/core/fwl_formimp.cpp
+++ b/xfa/fwl/core/fwl_formimp.cpp
@@ -14,8 +14,6 @@
 #include "xfa/fwl/core/cfwl_themetext.h"
 #include "xfa/fwl/core/fwl_appimp.h"
 #include "xfa/fwl/core/fwl_noteimp.h"
-#include "xfa/fwl/core/fwl_targetimp.h"
-#include "xfa/fwl/core/fwl_threadimp.h"
 #include "xfa/fwl/core/fwl_widgetimp.h"
 #include "xfa/fwl/core/fwl_widgetmgrimp.h"
 #include "xfa/fwl/core/ifwl_adapterwidgetmgr.h"
@@ -389,12 +387,14 @@
   return FWL_ERR_Succeeded;
 }
 IFWL_Widget* CFWL_FormImp::DoModal() {
-  IFWL_Thread* pThread = GetOwnerThread();
-  if (!pThread)
-    return NULL;
-  IFWL_NoteDriver* pDriver = pThread->GetNoteDriver();
+  IFWL_App* pApp = GetOwnerApp();
+  if (!pApp)
+    return nullptr;
+
+  CFWL_NoteDriver* pDriver = pApp->GetNoteDriver();
   if (!pDriver)
-    return NULL;
+    return nullptr;
+
   m_pNoteLoop = new CFWL_NoteLoop(this);
   pDriver->PushNoteLoop(m_pNoteLoop);
   m_bDoModalFlag = TRUE;
@@ -417,13 +417,15 @@
   m_bDoModalFlag = FALSE;
 #if (_FX_OS_ == _FX_MACOSX_)
   m_pNoteLoop->EndModalLoop();
-  IFWL_Thread* pThread = GetOwnerThread();
-  if (!pThread)
+  IFWL_App* pApp = GetOwnerApp();
+  if (!pApp)
     return FWL_ERR_Indefinite;
+
   CFWL_NoteDriver* pDriver =
-      static_cast<CFWL_NoteDriver*>(pThread->GetNoteDriver());
+      static_cast<CFWL_NoteDriver*>(pApp->GetNoteDriver());
   if (!pDriver)
     return FWL_ERR_Indefinite;
+
   pDriver->PopNoteLoop();
   SetStates(FWL_WGTSTATE_Invisible, TRUE);
   return FWL_ERR_Succeeded;
@@ -745,23 +747,27 @@
   }
 }
 void CFWL_FormImp::RegisterForm() {
-  IFWL_Thread* pThread = GetOwnerThread();
-  if (!pThread)
+  IFWL_App* pApp = GetOwnerApp();
+  if (!pApp)
     return;
+
   CFWL_NoteDriver* pDriver =
-      static_cast<CFWL_NoteDriver*>(pThread->GetNoteDriver());
+      static_cast<CFWL_NoteDriver*>(pApp->GetNoteDriver());
   if (!pDriver)
     return;
+
   pDriver->RegisterForm(this);
 }
 void CFWL_FormImp::UnRegisterForm() {
-  IFWL_Thread* pThread = GetOwnerThread();
-  if (!pThread)
+  IFWL_App* pApp = GetOwnerApp();
+  if (!pApp)
     return;
+
   CFWL_NoteDriver* pDriver =
-      static_cast<CFWL_NoteDriver*>(pThread->GetNoteDriver());
+      static_cast<CFWL_NoteDriver*>(pApp->GetNoteDriver());
   if (!pDriver)
     return;
+
   pDriver->UnRegisterForm(this);
 }
 FX_BOOL CFWL_FormImp::IsDoModal() {
@@ -888,9 +894,9 @@
   switch (pMessage->GetClassID()) {
     case CFWL_MessageType::Activate: {
       m_pOwner->m_pProperties->m_dwStates &= ~FWL_WGTSTATE_Deactivated;
-      IFWL_Thread* pThread = m_pOwner->GetOwnerThread();
+      IFWL_App* pApp = m_pOwner->GetOwnerApp();
       CFWL_NoteDriver* pDriver =
-          static_cast<CFWL_NoteDriver*>(pThread->GetNoteDriver());
+          static_cast<CFWL_NoteDriver*>(pApp->GetNoteDriver());
       CFWL_WidgetImp* pSubFocusImp = m_pOwner->GetSubFocus();
       IFWL_Widget* pSubFocus =
           pSubFocusImp ? pSubFocusImp->GetInterface() : nullptr;
@@ -902,9 +908,9 @@
     }
     case CFWL_MessageType::Deactivate: {
       m_pOwner->m_pProperties->m_dwStates |= FWL_WGTSTATE_Deactivated;
-      IFWL_Thread* pThread = m_pOwner->GetOwnerThread();
+      IFWL_App* pApp = m_pOwner->GetOwnerApp();
       CFWL_NoteDriver* pDriver =
-          static_cast<CFWL_NoteDriver*>(pThread->GetNoteDriver());
+          static_cast<CFWL_NoteDriver*>(pApp->GetNoteDriver());
       CFWL_WidgetImp* pSubFocusImp = m_pOwner->GetSubFocus();
       IFWL_Widget* pSubFocus =
           pSubFocusImp ? pSubFocusImp->GetInterface() : nullptr;
diff --git a/xfa/fwl/core/fwl_noteimp.cpp b/xfa/fwl/core/fwl_noteimp.cpp
index cc548a5..267b2ca 100644
--- a/xfa/fwl/core/fwl_noteimp.cpp
+++ b/xfa/fwl/core/fwl_noteimp.cpp
@@ -12,8 +12,6 @@
 #include "xfa/fwl/core/cfwl_message.h"
 #include "xfa/fwl/core/fwl_appimp.h"
 #include "xfa/fwl/core/fwl_formimp.h"
-#include "xfa/fwl/core/fwl_targetimp.h"
-#include "xfa/fwl/core/fwl_threadimp.h"
 #include "xfa/fwl/core/fwl_widgetimp.h"
 #include "xfa/fwl/core/fwl_widgetmgrimp.h"
 #include "xfa/fwl/core/ifwl_adapterwidgetmgr.h"
@@ -31,7 +29,7 @@
     IFWL_App* pApp = FWL_GetApp();
     if (!pApp)
       return FWL_ERR_Indefinite;
-    IFWL_NoteDriver* pDriver = pApp->GetNoteDriver();
+    CFWL_NoteDriver* pDriver = pApp->GetNoteDriver();
     if (!pDriver)
       return FWL_ERR_Indefinite;
     pDriver->SendEvent(&ev);
@@ -63,12 +61,14 @@
 void CFWL_NoteLoop::GenerateCommondEvent(uint32_t dwCommand) {
   CFWL_EvtMenuCommand ev;
   ev.m_iCommand = dwCommand;
-  IFWL_Thread* pThread = m_pForm->GetOwnerThread();
-  if (!pThread)
+  IFWL_App* pApp = m_pForm->GetOwnerApp();
+  if (!pApp)
     return;
-  IFWL_NoteDriver* pDriver = pThread->GetNoteDriver();
+
+  CFWL_NoteDriver* pDriver = pApp->GetNoteDriver();
   if (!pDriver)
     return;
+
   pDriver->SendEvent(&ev);
 }
 CFWL_NoteDriver::CFWL_NoteDriver()
@@ -153,18 +153,19 @@
 void CFWL_NoteDriver::ClearEventTargets(FX_BOOL bRemoveAll) {
   ClearInvalidEventTargets(bRemoveAll);
 }
-IFWL_Thread* CFWL_NoteDriver::GetOwnerThread() const {
+IFWL_App* CFWL_NoteDriver::GetOwnerApp() const {
   return FWL_GetApp();
 }
-FWL_ERR CFWL_NoteDriver::PushNoteLoop(IFWL_NoteLoop* pNoteLoop) {
+FWL_ERR CFWL_NoteDriver::PushNoteLoop(CFWL_NoteLoop* pNoteLoop) {
   m_noteLoopQueue.Add(pNoteLoop);
   return FWL_ERR_Succeeded;
 }
-IFWL_NoteLoop* CFWL_NoteDriver::PopNoteLoop() {
+CFWL_NoteLoop* CFWL_NoteDriver::PopNoteLoop() {
   int32_t pos = m_noteLoopQueue.GetSize();
   if (pos <= 0)
-    return NULL;
-  IFWL_NoteLoop* p = m_noteLoopQueue.GetAt(pos - 1);
+    return nullptr;
+
+  CFWL_NoteLoop* p = m_noteLoopQueue.GetAt(pos - 1);
   m_noteLoopQueue.RemoveAt(pos - 1);
   return p;
 }
diff --git a/xfa/fwl/core/fwl_noteimp.h b/xfa/fwl/core/fwl_noteimp.h
index f51f09c..8607a33 100644
--- a/xfa/fwl/core/fwl_noteimp.h
+++ b/xfa/fwl/core/fwl_noteimp.h
@@ -7,10 +7,20 @@
 #ifndef XFA_FWL_CORE_FWL_NOTEIMP_H_
 #define XFA_FWL_CORE_FWL_NOTEIMP_H_
 
-#include "xfa/fwl/core/ifwl_notedriver.h"
-#include "xfa/fwl/core/ifwl_noteloop.h"
+#include "xfa/fwl/core/cfwl_event.h"
+#include "xfa/fwl/core/cfwl_message.h"
+#include "xfa/fwl/core/fwl_error.h"
+#include "xfa/fwl/core/ifwl_widget.h"
 #include "xfa/fxgraphics/include/cfx_graphics.h"
 
+#define FWL_KEYFLAG_Ctrl (1 << 0)
+#define FWL_KEYFLAG_Alt (1 << 1)
+#define FWL_KEYFLAG_Shift (1 << 2)
+#define FWL_KEYFLAG_Command (1 << 3)
+#define FWL_KEYFLAG_LButton (1 << 4)
+#define FWL_KEYFLAG_RButton (1 << 5)
+#define FWL_KEYFLAG_MButton (1 << 6)
+
 class CFWL_CoreToolTipDP;
 class CFWL_MsgActivate;
 class CFWL_MsgDeactivate;
@@ -27,14 +37,12 @@
 class CFWL_WidgetImp;
 class IFWL_ToolTipTarget;
 
-class CFWL_NoteLoop : public IFWL_NoteLoop {
+class CFWL_NoteLoop {
  public:
   CFWL_NoteLoop(CFWL_WidgetImp* pForm = nullptr);
-  ~CFWL_NoteLoop() override {}
+  ~CFWL_NoteLoop() {}
 
-  // IFWL_NoteLoop:
-  FWL_ERR Idle(int32_t count) override;
-
+  FWL_ERR Idle(int32_t count);
   CFWL_WidgetImp* GetForm();
   FX_BOOL ContinueModal();
   FWL_ERR EndModalLoop();
@@ -47,25 +55,24 @@
   FX_BOOL m_bContinueModal;
 };
 
-class CFWL_NoteDriver : public IFWL_NoteDriver {
+class CFWL_NoteDriver {
  public:
   CFWL_NoteDriver();
-  ~CFWL_NoteDriver() override;
+  ~CFWL_NoteDriver();
 
-  // IFWL_NoteDriver:
-  FX_BOOL SendEvent(CFWL_Event* pNote) override;
+  FX_BOOL SendEvent(CFWL_Event* pNote);
   FWL_ERR RegisterEventTarget(IFWL_Widget* pListener,
                               IFWL_Widget* pEventSource = nullptr,
-                              uint32_t dwFilter = FWL_EVENT_ALL_MASK) override;
-  FWL_ERR UnregisterEventTarget(IFWL_Widget* pListener) override;
-  void ClearEventTargets(FX_BOOL bRemoveAll) override;
-  IFWL_Thread* GetOwnerThread() const override;
-  FWL_ERR PushNoteLoop(IFWL_NoteLoop* pNoteLoop) override;
-  IFWL_NoteLoop* PopNoteLoop() override;
-  IFWL_Widget* GetFocus() override;
-  FX_BOOL SetFocus(IFWL_Widget* pFocus, FX_BOOL bNotify = FALSE) override;
-  void SetGrab(IFWL_Widget* pGrab, FX_BOOL bSet) override;
-  FWL_ERR Run() override;
+                              uint32_t dwFilter = FWL_EVENT_ALL_MASK);
+  FWL_ERR UnregisterEventTarget(IFWL_Widget* pListener);
+  void ClearEventTargets(FX_BOOL bRemoveAll);
+  IFWL_App* GetOwnerApp() const;
+  FWL_ERR PushNoteLoop(CFWL_NoteLoop* pNoteLoop);
+  CFWL_NoteLoop* PopNoteLoop();
+  IFWL_Widget* GetFocus();
+  FX_BOOL SetFocus(IFWL_Widget* pFocus, FX_BOOL bNotify = FALSE);
+  void SetGrab(IFWL_Widget* pGrab, FX_BOOL bSet);
+  FWL_ERR Run();
 
   IFWL_Widget* GetHover();
   void SetHover(IFWL_Widget* pHover);
@@ -96,9 +103,10 @@
   FX_BOOL IsValidMessage(CFWL_Message* pMessage);
   IFWL_Widget* GetMessageForm(IFWL_Widget* pDstTarget);
   void ClearInvalidEventTargets(FX_BOOL bRemoveAll);
-  CFX_ArrayTemplate<CFWL_TargetImp*> m_forms;
+
+  CFX_ArrayTemplate<CFWL_WidgetImp*> m_forms;
   CFX_ArrayTemplate<CFWL_Message*> m_noteQueue;
-  CFX_ArrayTemplate<IFWL_NoteLoop*> m_noteLoopQueue;
+  CFX_ArrayTemplate<CFWL_NoteLoop*> m_noteLoopQueue;
   CFX_MapPtrToPtr m_eventTargets;
   int32_t m_sendEventCalled;
   IFWL_Widget* m_pHover;
diff --git a/xfa/fwl/core/fwl_sdadapterimp.cpp b/xfa/fwl/core/fwl_sdadapterimp.cpp
index 76cbad6..c4dc61a 100644
--- a/xfa/fwl/core/fwl_sdadapterimp.cpp
+++ b/xfa/fwl/core/fwl_sdadapterimp.cpp
@@ -8,8 +8,6 @@
 
 #include "core/fxcrt/include/fx_system.h"
 #include "xfa/fwl/core/fwl_noteimp.h"
-#include "xfa/fwl/core/fwl_targetimp.h"
-#include "xfa/fwl/core/fwl_threadimp.h"
 #include "xfa/fwl/core/fwl_widgetmgrimp.h"
 #include "xfa/fwl/core/ifwl_adapterthreadmgr.h"
 #include "xfa/fwl/core/ifwl_adapterwidgetmgr.h"
@@ -148,6 +146,6 @@
 
 CFWL_SDAdapterThreadMgr::~CFWL_SDAdapterThreadMgr() {}
 
-IFWL_Thread* CFWL_SDAdapterThreadMgr::GetCurrentThread() {
+IFWL_App* CFWL_SDAdapterThreadMgr::GetCurrentThread() {
   return FWL_GetApp();
 }
diff --git a/xfa/fwl/core/fwl_sdadapterimp.h b/xfa/fwl/core/fwl_sdadapterimp.h
index 3bd176a..cd2ac8d 100644
--- a/xfa/fwl/core/fwl_sdadapterimp.h
+++ b/xfa/fwl/core/fwl_sdadapterimp.h
@@ -74,7 +74,7 @@
   ~CFWL_SDAdapterThreadMgr();
 
  public:
-  virtual IFWL_Thread* GetCurrentThread();
+  virtual IFWL_App* GetCurrentThread();
 };
 
 #endif  // XFA_FWL_CORE_FWL_SDADAPTERIMP_H_
diff --git a/xfa/fwl/core/fwl_targetimp.cpp b/xfa/fwl/core/fwl_targetimp.cpp
deleted file mode 100644
index 1e63efe..0000000
--- a/xfa/fwl/core/fwl_targetimp.cpp
+++ /dev/null
@@ -1,44 +0,0 @@
-// Copyright 2014 PDFium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
-
-#include "xfa/fwl/core/fwl_targetimp.h"
-
-FWL_ERR IFWL_Target::GetClassName(CFX_WideString& wsClass) const {
-  return m_pImpl->GetClassName(wsClass);
-}
-uint32_t IFWL_Target::GetClassID() const {
-  return m_pImpl->GetClassID();
-}
-FX_BOOL IFWL_Target::IsInstance(const CFX_WideStringC& wsClass) const {
-  return m_pImpl->IsInstance(wsClass);
-}
-FWL_ERR IFWL_Target::Initialize() {
-  return m_pImpl->Initialize();
-}
-FWL_ERR IFWL_Target::Finalize() {
-  return m_pImpl->Finalize();
-}
-IFWL_Target::~IFWL_Target() {
-  delete m_pImpl;
-}
-CFWL_TargetImp::CFWL_TargetImp() {}
-CFWL_TargetImp::~CFWL_TargetImp() {}
-FWL_ERR CFWL_TargetImp::GetClassName(CFX_WideString& wsClass) const {
-  wsClass.clear();
-  return FWL_ERR_Succeeded;
-}
-uint32_t CFWL_TargetImp::GetClassID() const {
-  return 0;
-}
-FX_BOOL CFWL_TargetImp::IsInstance(const CFX_WideStringC& wsClass) const {
-  return FALSE;
-}
-FWL_ERR CFWL_TargetImp::Initialize() {
-  return FWL_ERR_Succeeded;
-}
-FWL_ERR CFWL_TargetImp::Finalize() {
-  return FWL_ERR_Succeeded;
-}
diff --git a/xfa/fwl/core/fwl_targetimp.h b/xfa/fwl/core/fwl_targetimp.h
deleted file mode 100644
index c1a5e56..0000000
--- a/xfa/fwl/core/fwl_targetimp.h
+++ /dev/null
@@ -1,27 +0,0 @@
-// Copyright 2014 PDFium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
-
-#ifndef XFA_FWL_CORE_FWL_TARGETIMP_H_
-#define XFA_FWL_CORE_FWL_TARGETIMP_H_
-
-#include "core/fxcrt/include/fx_basic.h"
-#include "xfa/fwl/core/ifwl_target.h"
-
-class CFWL_TargetImp {
- public:
-  virtual ~CFWL_TargetImp();
-
-  virtual FWL_ERR GetClassName(CFX_WideString& wsClass) const;
-  virtual uint32_t GetClassID() const;
-  virtual FX_BOOL IsInstance(const CFX_WideStringC& wsClass) const;
-  virtual FWL_ERR Initialize();
-  virtual FWL_ERR Finalize();
-
- protected:
-  CFWL_TargetImp();
-};
-
-#endif  // XFA_FWL_CORE_FWL_TARGETIMP_H_
diff --git a/xfa/fwl/core/fwl_threadimp.cpp b/xfa/fwl/core/fwl_threadimp.cpp
deleted file mode 100644
index d6036b7..0000000
--- a/xfa/fwl/core/fwl_threadimp.cpp
+++ /dev/null
@@ -1,20 +0,0 @@
-// Copyright 2014 PDFium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
-
-#include "xfa/fwl/core/fwl_threadimp.h"
-
-#include "xfa/fwl/core/fwl_appimp.h"
-#include "xfa/fwl/core/fwl_noteimp.h"
-#include "xfa/fwl/core/fwl_targetimp.h"
-#include "xfa/fwl/core/ifwl_thread.h"
-
-void IFWL_Thread::Release() {
-  delete m_pImpl;
-}
-
-IFWL_NoteDriver* IFWL_Thread::GetNoteDriver() const {
-  return static_cast<CFWL_ThreadImp*>(GetImpl())->GetNoteDriver();
-}
diff --git a/xfa/fwl/core/fwl_threadimp.h b/xfa/fwl/core/fwl_threadimp.h
deleted file mode 100644
index d10d493..0000000
--- a/xfa/fwl/core/fwl_threadimp.h
+++ /dev/null
@@ -1,33 +0,0 @@
-// Copyright 2014 PDFium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
-
-#ifndef XFA_FWL_CORE_FWL_THREADIMP_H_
-#define XFA_FWL_CORE_FWL_THREADIMP_H_
-
-#include "xfa/fwl/core/fwl_noteimp.h"
-#include "xfa/fwl/core/ifwl_thread.h"
-
-class IFWL_NoteDriver;
-class IFWL_NoteThread;
-
-class CFWL_ThreadImp {
- public:
-  CFWL_ThreadImp(IFWL_Thread* pIface)
-      : m_pNoteDriver(new CFWL_NoteDriver), m_pIface(pIface) {}
-
-  virtual ~CFWL_ThreadImp() { delete m_pNoteDriver; }
-
-  IFWL_Thread* GetInterface() const { return m_pIface; }
-  IFWL_NoteDriver* GetNoteDriver() const { return m_pNoteDriver; }
-
- protected:
-  CFWL_NoteDriver* const m_pNoteDriver;
-
- private:
-  IFWL_Thread* const m_pIface;
-};
-
-#endif  // XFA_FWL_CORE_FWL_THREADIMP_H_
diff --git a/xfa/fwl/core/fwl_timerimp.cpp b/xfa/fwl/core/fwl_timerimp.cpp
index 1dfed0c..8a5f889 100644
--- a/xfa/fwl/core/fwl_timerimp.cpp
+++ b/xfa/fwl/core/fwl_timerimp.cpp
@@ -5,8 +5,6 @@
 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
 
 #include "xfa/fwl/core/fwl_appimp.h"
-#include "xfa/fwl/core/fwl_targetimp.h"
-#include "xfa/fwl/core/fwl_threadimp.h"
 #include "xfa/fwl/core/ifwl_adapternative.h"
 #include "xfa/fwl/core/ifwl_app.h"
 #include "xfa/fwl/core/ifwl_timer.h"
diff --git a/xfa/fwl/core/fwl_widgetimp.cpp b/xfa/fwl/core/fwl_widgetimp.cpp
index df3228c..c9d91c4 100644
--- a/xfa/fwl/core/fwl_widgetimp.cpp
+++ b/xfa/fwl/core/fwl_widgetimp.cpp
@@ -17,8 +17,6 @@
 #include "xfa/fwl/core/cfwl_themetext.h"
 #include "xfa/fwl/core/fwl_appimp.h"
 #include "xfa/fwl/core/fwl_noteimp.h"
-#include "xfa/fwl/core/fwl_targetimp.h"
-#include "xfa/fwl/core/fwl_threadimp.h"
 #include "xfa/fwl/core/fwl_widgetmgrimp.h"
 #include "xfa/fwl/core/ifwl_adapternative.h"
 #include "xfa/fwl/core/ifwl_adapterthreadmgr.h"
@@ -30,6 +28,28 @@
 #define FWL_CLASSHASH_Menu 3957949655
 #define FWL_STYLEEXT_MNU_Vert (1L << 0)
 
+IFWL_Widget::~IFWL_Widget() {}
+
+FWL_ERR IFWL_Widget::GetClassName(CFX_WideString& wsClass) const {
+  return m_pImpl->GetClassName(wsClass);
+}
+
+uint32_t IFWL_Widget::GetClassID() const {
+  return m_pImpl->GetClassID();
+}
+
+FX_BOOL IFWL_Widget::IsInstance(const CFX_WideStringC& wsClass) const {
+  return m_pImpl->IsInstance(wsClass);
+}
+
+FWL_ERR IFWL_Widget::Initialize() {
+  return m_pImpl->Initialize();
+}
+
+FWL_ERR IFWL_Widget::Finalize() {
+  return m_pImpl->Finalize();
+}
+
 FWL_ERR IFWL_Widget::GetWidgetRect(CFX_RectF& rect, FX_BOOL bAutoSize) {
   return static_cast<CFWL_WidgetImp*>(GetImpl())
       ->GetWidgetRect(rect, bAutoSize);
@@ -134,12 +154,13 @@
 IFWL_WidgetDelegate* IFWL_Widget::SetDelegate(IFWL_WidgetDelegate* pDelegate) {
   return static_cast<CFWL_WidgetImp*>(GetImpl())->SetDelegate(pDelegate);
 }
-IFWL_Thread* IFWL_Widget::GetOwnerThread() const {
-  return static_cast<CFWL_WidgetImp*>(GetImpl())->GetOwnerThread();
+IFWL_App* IFWL_Widget::GetOwnerApp() const {
+  return static_cast<CFWL_WidgetImp*>(GetImpl())->GetOwnerApp();
 }
 CFX_SizeF IFWL_Widget::GetOffsetFromParent(IFWL_Widget* pParent) {
   return static_cast<CFWL_WidgetImp*>(GetImpl())->GetOffsetFromParent(pParent);
 }
+
 FWL_ERR CFWL_WidgetImp::Initialize() {
   IFWL_App* pApp = FWL_GetApp();
   if (!pApp)
@@ -150,8 +171,8 @@
   IFWL_AdapterThreadMgr* pAdapterThread = pAdapter->GetThreadMgr();
   if (!pAdapterThread)
     return FWL_ERR_Indefinite;
-  SetOwnerThread(static_cast<CFWL_ThreadImp*>(
-      pAdapterThread->GetCurrentThread()->GetImpl()));
+  SetOwnerApp(
+      static_cast<CFWL_AppImp*>(pAdapterThread->GetCurrentThread()->GetImpl()));
   IFWL_Widget* pParent = m_pProperties->m_pParent;
   m_pWidgetMgr->InsertWidget(pParent, m_pInterface);
   if (!IsChild()) {
@@ -165,6 +186,7 @@
   }
   return FWL_ERR_Succeeded;
 }
+
 FWL_ERR CFWL_WidgetImp::Finalize() {
   NotifyDriver();
   if (!IsChild())
@@ -173,6 +195,20 @@
   m_pWidgetMgr->RemoveWidget(m_pInterface);
   return FWL_ERR_Succeeded;
 }
+
+FWL_ERR CFWL_WidgetImp::GetClassName(CFX_WideString& wsClass) const {
+  wsClass.clear();
+  return FWL_ERR_Succeeded;
+}
+
+uint32_t CFWL_WidgetImp::GetClassID() const {
+  return 0;
+}
+
+FX_BOOL CFWL_WidgetImp::IsInstance(const CFX_WideStringC& wsClass) const {
+  return FALSE;
+}
+
 FWL_ERR CFWL_WidgetImp::GetWidgetRect(CFX_RectF& rect, FX_BOOL bAutoSize) {
   if (bAutoSize) {
     if (HasEdge()) {
@@ -286,7 +322,7 @@
     if (bSet) {
       ret = m_pWidgetMgr->HideWidget_Native(m_pInterface);
       CFWL_NoteDriver* noteDriver =
-          static_cast<CFWL_NoteDriver*>(GetOwnerThread()->GetNoteDriver());
+          static_cast<CFWL_NoteDriver*>(GetOwnerApp()->GetNoteDriver());
       IFWL_WidgetMgr* widgetMgr = FWL_GetWidgetMgr();
       noteDriver->NotifyTargetHide(m_pInterface);
       IFWL_Widget* child =
@@ -497,11 +533,11 @@
   m_pCurDelegate = pDelegate;
   return pOldDelegate;
 }
-IFWL_Thread* CFWL_WidgetImp::GetOwnerThread() const {
-  return static_cast<IFWL_Thread*>(m_pOwnerThread->GetInterface());
+IFWL_App* CFWL_WidgetImp::GetOwnerApp() const {
+  return static_cast<IFWL_App*>(m_pOwnerApp->GetInterface());
 }
-FWL_ERR CFWL_WidgetImp::SetOwnerThread(CFWL_ThreadImp* pOwnerThread) {
-  m_pOwnerThread = pOwnerThread;
+FWL_ERR CFWL_WidgetImp::SetOwnerApp(CFWL_AppImp* pOwnerApp) {
+  m_pOwnerApp = pOwnerApp;
   return FWL_ERR_Succeeded;
 }
 IFWL_Widget* CFWL_WidgetImp::GetInterface() const {
@@ -682,13 +718,16 @@
 void CFWL_WidgetImp::SetFocus(FX_BOOL bFocus) {
   if (m_pWidgetMgr->IsFormDisabled())
     return;
-  IFWL_Thread* pThread = GetOwnerThread();
-  if (!pThread)
+
+  IFWL_App* pApp = GetOwnerApp();
+  if (!pApp)
     return;
+
   CFWL_NoteDriver* pDriver =
-      static_cast<CFWL_NoteDriver*>(pThread->GetNoteDriver());
+      static_cast<CFWL_NoteDriver*>(pApp->GetNoteDriver());
   if (!pDriver)
     return;
+
   IFWL_Widget* curFocus = pDriver->GetFocus();
   if (bFocus && curFocus != m_pInterface) {
     pDriver->SetFocus(m_pInterface);
@@ -697,11 +736,11 @@
   }
 }
 void CFWL_WidgetImp::SetGrab(FX_BOOL bSet) {
-  IFWL_Thread* pThread = GetOwnerThread();
-  if (!pThread)
+  IFWL_App* pApp = GetOwnerApp();
+  if (!pApp)
     return;
   CFWL_NoteDriver* pDriver =
-      static_cast<CFWL_NoteDriver*>(pThread->GetNoteDriver());
+      static_cast<CFWL_NoteDriver*>(pApp->GetNoteDriver());
   pDriver->SetGrab(m_pInterface, bSet);
 }
 FX_BOOL CFWL_WidgetImp::GetPopupPos(FX_FLOAT fMinHeight,
@@ -813,21 +852,25 @@
 }
 void CFWL_WidgetImp::RegisterEventTarget(IFWL_Widget* pEventSource,
                                          uint32_t dwFilter) {
-  IFWL_Thread* pThread = GetOwnerThread();
-  if (!pThread)
+  IFWL_App* pApp = GetOwnerApp();
+  if (!pApp)
     return;
-  IFWL_NoteDriver* pNoteDriver = pThread->GetNoteDriver();
+
+  CFWL_NoteDriver* pNoteDriver = pApp->GetNoteDriver();
   if (!pNoteDriver)
     return;
+
   pNoteDriver->RegisterEventTarget(m_pInterface, pEventSource, dwFilter);
 }
 void CFWL_WidgetImp::UnregisterEventTarget() {
-  IFWL_Thread* pThread = GetOwnerThread();
-  if (!pThread)
+  IFWL_App* pApp = GetOwnerApp();
+  if (!pApp)
     return;
-  IFWL_NoteDriver* pNoteDriver = pThread->GetNoteDriver();
+
+  CFWL_NoteDriver* pNoteDriver = pApp->GetNoteDriver();
   if (!pNoteDriver)
     return;
+
   pNoteDriver->UnregisterEventTarget(m_pInterface);
 }
 void CFWL_WidgetImp::DispatchKeyEvent(CFWL_MsgKey* pNote) {
@@ -847,10 +890,10 @@
     pDelegate->OnProcessEvent(pEvent);
     return;
   }
-  IFWL_Thread* pThread = GetOwnerThread();
-  if (!pThread)
+  IFWL_App* pApp = GetOwnerApp();
+  if (!pApp)
     return;
-  IFWL_NoteDriver* pNoteDriver = pThread->GetNoteDriver();
+  CFWL_NoteDriver* pNoteDriver = pApp->GetNoteDriver();
   if (!pNoteDriver)
     return;
   pNoteDriver->SendEvent(pEvent);
@@ -914,13 +957,15 @@
   pTheme->DrawBackground(&param);
 }
 void CFWL_WidgetImp::NotifyDriver() {
-  IFWL_Thread* pThread = GetOwnerThread();
-  if (!pThread)
+  IFWL_App* pApp = GetOwnerApp();
+  if (!pApp)
     return;
+
   CFWL_NoteDriver* pDriver =
-      static_cast<CFWL_NoteDriver*>(pThread->GetNoteDriver());
+      static_cast<CFWL_NoteDriver*>(pApp->GetNoteDriver());
   if (!pDriver)
     return;
+
   pDriver->NotifyTargetDestroy(m_pInterface);
 }
 CFX_SizeF CFWL_WidgetImp::GetOffsetFromParent(IFWL_Widget* pParent) {
diff --git a/xfa/fwl/core/fwl_widgetimp.h b/xfa/fwl/core/fwl_widgetimp.h
index 2e5e761..9381a42 100644
--- a/xfa/fwl/core/fwl_widgetimp.h
+++ b/xfa/fwl/core/fwl_widgetimp.h
@@ -11,23 +11,27 @@
 #include "core/fxcrt/include/fx_system.h"
 #include "xfa/fwl/core/cfwl_event.h"
 #include "xfa/fwl/core/cfwl_themepart.h"
-#include "xfa/fwl/core/fwl_targetimp.h"
 #include "xfa/fwl/core/ifwl_widgetdelegate.h"
 #include "xfa/fwl/theme/cfwl_widgettp.h"
 
+class CFWL_AppImp;
 class CFWL_MsgKey;
-class CFWL_ThreadImp;
 class CFWL_WidgetImpProperties;
 class CFWL_WidgetMgr;
+class IFWL_App;
 class IFWL_DataProvider;
-class IFWL_Thread;
 class IFWL_ThemeProvider;
 class IFWL_Widget;
 
-class CFWL_WidgetImp : public CFWL_TargetImp {
+class CFWL_WidgetImp {
  public:
+  virtual ~CFWL_WidgetImp();
+
   virtual FWL_ERR Initialize();
   virtual FWL_ERR Finalize();
+  virtual FWL_ERR GetClassName(CFX_WideString& wsClass) const;
+  virtual uint32_t GetClassID() const;
+  virtual FX_BOOL IsInstance(const CFX_WideStringC& wsClass) const;
 
   virtual FWL_ERR GetWidgetRect(CFX_RectF& rect, FX_BOOL bAutoSize = FALSE);
   virtual FWL_ERR GetGlobalRect(CFX_RectF& rect);
@@ -64,16 +68,18 @@
   virtual FWL_ERR SetThemeProvider(IFWL_ThemeProvider* pThemeProvider);
   virtual FWL_ERR SetDataProvider(IFWL_DataProvider* pDataProvider);
   virtual IFWL_WidgetDelegate* SetDelegate(IFWL_WidgetDelegate* pDelegate);
-  virtual IFWL_Thread* GetOwnerThread() const;
-  FWL_ERR SetOwnerThread(CFWL_ThreadImp* pOwnerThread);
+  virtual IFWL_App* GetOwnerApp() const;
+  FWL_ERR SetOwnerApp(CFWL_AppImp* pOwnerApp);
   IFWL_Widget* GetInterface() const;
   void SetInterface(IFWL_Widget* pInterface);
   CFX_SizeF GetOffsetFromParent(IFWL_Widget* pParent);
 
  protected:
+  friend class CFWL_WidgetImpDelegate;
+
   CFWL_WidgetImp(const CFWL_WidgetImpProperties& properties,
                  IFWL_Widget* pOuter);
-  virtual ~CFWL_WidgetImp();
+
   FX_BOOL IsEnabled() const;
   FX_BOOL IsVisible() const;
   FX_BOOL IsActive() const;
@@ -141,10 +147,8 @@
 
   FX_BOOL IsParent(IFWL_Widget* pParent);
 
-  friend class CFWL_WidgetImpDelegate;
-
   CFWL_WidgetMgr* m_pWidgetMgr;
-  CFWL_ThreadImp* m_pOwnerThread;
+  CFWL_AppImp* m_pOwnerApp;
   CFWL_WidgetImpProperties* m_pProperties;
   CFX_PrivateData* m_pPrivateData;
   IFWL_WidgetDelegate* m_pDelegate;
diff --git a/xfa/fwl/core/fwl_widgetmgrimp.cpp b/xfa/fwl/core/fwl_widgetmgrimp.cpp
index 0bd1acf..b1e0ca8 100644
--- a/xfa/fwl/core/fwl_widgetmgrimp.cpp
+++ b/xfa/fwl/core/fwl_widgetmgrimp.cpp
@@ -9,8 +9,6 @@
 #include "xfa/fwl/core/cfwl_message.h"
 #include "xfa/fwl/core/fwl_appimp.h"
 #include "xfa/fwl/core/fwl_noteimp.h"
-#include "xfa/fwl/core/fwl_targetimp.h"
-#include "xfa/fwl/core/fwl_threadimp.h"
 #include "xfa/fwl/core/fwl_widgetimp.h"
 #include "xfa/fwl/core/ifwl_adapternative.h"
 #include "xfa/fwl/core/ifwl_adapterwidgetmgr.h"
@@ -695,22 +693,24 @@
     return 0;
   if (!pMessage->m_pDstTarget)
     return 0;
+
   IFWL_Widget* pDstWidget = pMessage->m_pDstTarget;
-  IFWL_Thread* pThread = pDstWidget->GetOwnerThread();
-  if (!pThread)
+  IFWL_App* pApp = pDstWidget->GetOwnerApp();
+  if (!pApp)
     return 0;
+
   CFWL_NoteDriver* pNoteDriver =
-      static_cast<CFWL_NoteDriver*>(pThread->GetNoteDriver());
+      static_cast<CFWL_NoteDriver*>(pApp->GetNoteDriver());
   if (!pNoteDriver)
     return 0;
-  if (m_pWidgetMgr->IsThreadEnabled()) {
+
+  if (m_pWidgetMgr->IsThreadEnabled())
     pMessage = static_cast<CFWL_Message*>(pMessage->Clone());
-  }
-  if (m_pWidgetMgr->IsFormDisabled()) {
+  if (m_pWidgetMgr->IsFormDisabled())
     pNoteDriver->ProcessMessage(pMessage);
-  } else {
+  else
     pNoteDriver->QueueMessage(pMessage);
-  }
+
 #if (_FX_OS_ == _FX_MACOSX_)
   CFWL_NoteLoop* pTopLoop = pNoteDriver->GetTopLoop();
   if (pTopLoop) {
diff --git a/xfa/fwl/core/fwl_widgetmgrimp.h b/xfa/fwl/core/fwl_widgetmgrimp.h
index fa48997..528ecdb 100644
--- a/xfa/fwl/core/fwl_widgetmgrimp.h
+++ b/xfa/fwl/core/fwl_widgetmgrimp.h
@@ -7,14 +7,21 @@
 #ifndef XFA_FWL_CORE_FWL_WIDGETMGRIMP_H_
 #define XFA_FWL_CORE_FWL_WIDGETMGRIMP_H_
 
+#include "core/fxcrt/include/fx_system.h"
+#include "xfa/fwl/core/fwl_error.h"
 #include "xfa/fwl/core/ifwl_widgetmgr.h"
-#include "xfa/fwl/core/ifwl_widgetmgrdelegate.h"
 #include "xfa/fxgraphics/include/cfx_graphics.h"
 
-class IFWL_Widget;
-class IFWL_AdapterWidgetMgr;
+#define FWL_WGTMGR_DisableThread 0x00000001
+#define FWL_WGTMGR_DisableForm 0x00000002
+
+class CFWL_Message;
 class CFWL_WidgetMgrDelegate;
+class CFX_Graphics;
+class CFX_Matrix;
+class IFWL_AdapterWidgetMgr;
 class IFWL_AdapterNative;
+class IFWL_Widget;
 
 class CFWL_WidgetMgrItem {
  public:
@@ -136,18 +143,16 @@
 #endif
 };
 
-class CFWL_WidgetMgrDelegate : public IFWL_WidgetMgrDelegate {
+class CFWL_WidgetMgrDelegate {
  public:
   CFWL_WidgetMgrDelegate(CFWL_WidgetMgr* pWidgetMgr);
-  ~CFWL_WidgetMgrDelegate() override {}
+  ~CFWL_WidgetMgrDelegate() {}
 
-  // IFWL_WidgetMgrDelegate:
-  FWL_ERR OnSetCapability(
-      uint32_t dwCapability = FWL_WGTMGR_DisableThread) override;
-  int32_t OnProcessMessageToForm(CFWL_Message* pMessage) override;
+  FWL_ERR OnSetCapability(uint32_t dwCapability = FWL_WGTMGR_DisableThread);
+  int32_t OnProcessMessageToForm(CFWL_Message* pMessage);
   FWL_ERR OnDrawWidget(IFWL_Widget* pWidget,
                        CFX_Graphics* pGraphics,
-                       const CFX_Matrix* pMatrix) override;
+                       const CFX_Matrix* pMatrix);
 
  protected:
   void DrawChild(IFWL_Widget* pParent,
diff --git a/xfa/fwl/core/ifwl_adapternative.h b/xfa/fwl/core/ifwl_adapternative.h
index 6c6d801..e787658 100644
--- a/xfa/fwl/core/ifwl_adapternative.h
+++ b/xfa/fwl/core/ifwl_adapternative.h
@@ -7,7 +7,7 @@
 #ifndef XFA_FWL_CORE_IFWL_ADAPTERNATIVE_H_
 #define XFA_FWL_CORE_IFWL_ADAPTERNATIVE_H_
 
-class IFWL_WidgetMgrDelegate;
+class CFWL_WidgetMgrDelegate;
 class IFWL_AdapterWidgetMgr;
 class IFWL_AdapterThreadMgr;
 class IFWL_AdapterTimerMgr;
@@ -16,7 +16,7 @@
  public:
   virtual ~IFWL_AdapterNative() {}
   virtual IFWL_AdapterWidgetMgr* GetWidgetMgr(
-      IFWL_WidgetMgrDelegate* pDelegate) = 0;
+      CFWL_WidgetMgrDelegate* pDelegate) = 0;
   virtual IFWL_AdapterThreadMgr* GetThreadMgr() = 0;
   virtual IFWL_AdapterTimerMgr* GetTimerMgr() = 0;
 };
diff --git a/xfa/fwl/core/ifwl_adapterthreadmgr.h b/xfa/fwl/core/ifwl_adapterthreadmgr.h
index dec5010..de2616a 100644
--- a/xfa/fwl/core/ifwl_adapterthreadmgr.h
+++ b/xfa/fwl/core/ifwl_adapterthreadmgr.h
@@ -9,13 +9,14 @@
 
 #include "core/fxcrt/include/fx_system.h"
 #include "xfa/fwl/core/fwl_error.h"
-#include "xfa/fwl/core/ifwl_thread.h"
+
+class IFWL_App;
 
 class IFWL_AdapterThreadMgr {
  public:
   virtual ~IFWL_AdapterThreadMgr() {}
 
-  virtual IFWL_Thread* GetCurrentThread() = 0;
+  virtual IFWL_App* GetCurrentThread() = 0;
 };
 
 #endif  // XFA_FWL_CORE_IFWL_ADAPTERTHREADMGR_H_
diff --git a/xfa/fwl/core/ifwl_app.h b/xfa/fwl/core/ifwl_app.h
index 3fb0940..53dc35d 100644
--- a/xfa/fwl/core/ifwl_app.h
+++ b/xfa/fwl/core/ifwl_app.h
@@ -7,19 +7,33 @@
 #ifndef XFA_FWL_CORE_IFWL_APP_H_
 #define XFA_FWL_CORE_IFWL_APP_H_
 
-#include "core/fxcrt/include/fx_string.h"
-#include "xfa/fwl/core/ifwl_thread.h"
+// The FWL thread/app code contains three parallel classes, which reference each
+// other via pointers as follows:
+//
+//                    m_pIface               m_pImpl
+//      CXFA_FFApp ------------> IFWL_App -----------> CFWL_AppImp
+//                                        <-----------
+//                                           m_pIface
 
+#include <memory>
+
+#include "core/fxcrt/include/fx_string.h"
+#include "xfa/fwl/core/fwl_appimp.h"
+#include "xfa/fwl/core/fwl_error.h"
+
+class CFWL_NoteDriver;
 class IFWL_AdapterNative;
+class IFWL_AdapterWidgetMgr;
+class IFWL_ThemeProvider;
 class IFWL_Widget;
 class IFWL_WidgetMgr;
-class IFWL_ThemeProvider;
-class IFWL_AdapterWidgetMgr;
 
-class IFWL_App : public IFWL_Thread {
+class IFWL_App {
  public:
   static IFWL_App* Create(IFWL_AdapterNative* pAdapter);
 
+  virtual ~IFWL_App() {}
+
   FWL_ERR Initialize();
   FWL_ERR Finalize();
   IFWL_AdapterNative* GetAdapterNative();
@@ -28,8 +42,20 @@
   FWL_ERR SetThemeProvider(IFWL_ThemeProvider* pThemeProvider);
   FWL_ERR Exit(int32_t iExitCode);
 
+  // These call into polymorphic methods in the impl; no need to override.
+  void Release();
+
+  CFWL_AppImp* GetImpl() const { return m_pImpl.get(); }
+
+  // Takes ownership of |pImpl|.
+  void SetImpl(CFWL_AppImp* pImpl) { m_pImpl.reset(pImpl); }
+
+  CFWL_NoteDriver* GetNoteDriver() const;
+
  private:
   IFWL_App() {}
+
+  std::unique_ptr<CFWL_AppImp> m_pImpl;
 };
 
 IFWL_App* FWL_GetApp();
diff --git a/xfa/fwl/core/ifwl_notedriver.h b/xfa/fwl/core/ifwl_notedriver.h
deleted file mode 100644
index 4bf2655..0000000
--- a/xfa/fwl/core/ifwl_notedriver.h
+++ /dev/null
@@ -1,49 +0,0 @@
-// Copyright 2016 PDFium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
-
-#ifndef XFA_FWL_CORE_IFWL_NOTEDRIVER_H_
-#define XFA_FWL_CORE_IFWL_NOTEDRIVER_H_
-
-#include "core/fxcrt/include/fx_system.h"
-#include "xfa/fwl/core/cfwl_event.h"
-#include "xfa/fwl/core/fwl_error.h"
-
-#define FWL_KEYFLAG_Ctrl (1 << 0)
-#define FWL_KEYFLAG_Alt (1 << 1)
-#define FWL_KEYFLAG_Shift (1 << 2)
-#define FWL_KEYFLAG_Command (1 << 3)
-#define FWL_KEYFLAG_LButton (1 << 4)
-#define FWL_KEYFLAG_RButton (1 << 5)
-#define FWL_KEYFLAG_MButton (1 << 6)
-
-class CFWL_Message;
-class CFWL_Note;
-class IFWL_NoteLoop;
-class IFWL_Thread;
-class IFWL_Widget;
-
-class IFWL_NoteDriver {
- public:
-  virtual ~IFWL_NoteDriver() {}
-
-  virtual FX_BOOL SendEvent(CFWL_Event* pNote) = 0;
-
-  virtual FWL_ERR RegisterEventTarget(
-      IFWL_Widget* pListener,
-      IFWL_Widget* pEventSource = NULL,
-      uint32_t dwFilter = FWL_EVENT_ALL_MASK) = 0;
-  virtual FWL_ERR UnregisterEventTarget(IFWL_Widget* pListener) = 0;
-  virtual void ClearEventTargets(FX_BOOL bRemoveAll) = 0;
-  virtual IFWL_Thread* GetOwnerThread() const = 0;
-  virtual FWL_ERR PushNoteLoop(IFWL_NoteLoop* pNoteLoop) = 0;
-  virtual IFWL_NoteLoop* PopNoteLoop() = 0;
-  virtual IFWL_Widget* GetFocus() = 0;
-  virtual FX_BOOL SetFocus(IFWL_Widget* pFocus, FX_BOOL bNotify = FALSE) = 0;
-  virtual void SetGrab(IFWL_Widget* pGrab, FX_BOOL bSet) = 0;
-  virtual FWL_ERR Run() = 0;
-};
-
-#endif  // XFA_FWL_CORE_IFWL_NOTEDRIVER_H_
diff --git a/xfa/fwl/core/ifwl_noteloop.h b/xfa/fwl/core/ifwl_noteloop.h
deleted file mode 100644
index b0b182e..0000000
--- a/xfa/fwl/core/ifwl_noteloop.h
+++ /dev/null
@@ -1,21 +0,0 @@
-// Copyright 2016 PDFium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
-
-#ifndef XFA_FWL_CORE_IFWL_NOTELOOP_H_
-#define XFA_FWL_CORE_IFWL_NOTELOOP_H_
-
-#include "core/fxcrt/include/fx_system.h"
-#include "xfa/fwl/core/fwl_error.h"
-
-class CFWL_Message;
-
-class IFWL_NoteLoop {
- public:
-  virtual ~IFWL_NoteLoop() {}
-  virtual FWL_ERR Idle(int32_t count) = 0;
-};
-
-#endif  // XFA_FWL_CORE_IFWL_NOTELOOP_H_
diff --git a/xfa/fwl/core/ifwl_target.h b/xfa/fwl/core/ifwl_target.h
deleted file mode 100644
index f0de3b1..0000000
--- a/xfa/fwl/core/ifwl_target.h
+++ /dev/null
@@ -1,52 +0,0 @@
-// Copyright 2014 PDFium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
-
-#ifndef XFA_FWL_CORE_IFWL_TARGET_H_
-#define XFA_FWL_CORE_IFWL_TARGET_H_
-
-#include "core/fxcrt/include/fx_basic.h"
-#include "xfa/fwl/core/fwl_error.h"
-
-// FWL contains three parallel inheritance hierarchies, which reference each
-// other via pointers as follows:
-//
-//                                           m_pImpl
-//      (nonesuch)              IFWL_Target ----------> CFWL_TargetImp
-//                                   |                       |
-//                                   A                       A
-//                   m_pIface        |                       |
-//      CFWL_Widget ----------> IFWL_Widget             CFWL_WidgetImp
-//           |                       |                       |
-//           A                       A                       A
-//           |                       |                       |
-//      CFWL_...                IFWL_...                CFWL_...Imp
-//
-
-class CFWL_TargetImp;
-
-class IFWL_Target {
- public:
-  IFWL_Target() : m_pImpl(nullptr) {}
-  virtual ~IFWL_Target();
-
-  // These call into equivalent polymorphic methods of m_pImpl. There
-  // should be no need to override these in subclasses.
-  FWL_ERR GetClassName(CFX_WideString& wsClass) const;
-  uint32_t GetClassID() const;
-  FX_BOOL IsInstance(const CFX_WideStringC& wsClass) const;
-  FWL_ERR Initialize();
-  FWL_ERR Finalize();
-
-  CFWL_TargetImp* GetImpl() const { return m_pImpl; }
-
- protected:
-  void SetImpl(CFWL_TargetImp* pImpl) { m_pImpl = pImpl; }
-
- private:
-  CFWL_TargetImp* m_pImpl;
-};
-
-#endif  // XFA_FWL_CORE_IFWL_TARGET_H_
diff --git a/xfa/fwl/core/ifwl_thread.h b/xfa/fwl/core/ifwl_thread.h
deleted file mode 100644
index b41b988..0000000
--- a/xfa/fwl/core/ifwl_thread.h
+++ /dev/null
@@ -1,43 +0,0 @@
-// Copyright 2014 PDFium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
-
-#ifndef XFA_FWL_CORE_IFWL_THREAD_H_
-#define XFA_FWL_CORE_IFWL_THREAD_H_
-
-// The FWL thread/app code contains three parallel inheritance hierarchies,
-// which reference each other via pointers as follows:
-//
-//                                           m_pImpl
-//      (nonesuch)              IFWL_Thread ----------> CFWL_ThreadImp
-//                                   |      <----------      |
-//                                   A       m_pIface        A
-//                m_pIface           |                       |
-//      CXFA_FFApp ------------> IFWL_App                CFWL_AppImp
-//
-
-#include "xfa/fwl/core/fwl_error.h"
-
-class CFWL_ThreadImp;
-class IFWL_NoteDriver;
-
-class IFWL_Thread {
- public:
-  // These call into polymorphic methods in the impl; no need to override.
-  void Release();
-
-  CFWL_ThreadImp* GetImpl() const { return m_pImpl; }
-  void SetImpl(CFWL_ThreadImp* pImpl) { m_pImpl = pImpl; }
-
-  IFWL_NoteDriver* GetNoteDriver() const;
-
- protected:
-  virtual ~IFWL_Thread() {}
-
- private:
-  CFWL_ThreadImp* m_pImpl;
-};
-
-#endif  // XFA_FWL_CORE_IFWL_THREAD_H_
diff --git a/xfa/fwl/core/ifwl_widget.h b/xfa/fwl/core/ifwl_widget.h
index 3540a3c..ea57c4e 100644
--- a/xfa/fwl/core/ifwl_widget.h
+++ b/xfa/fwl/core/ifwl_widget.h
@@ -7,21 +7,38 @@
 #ifndef XFA_FWL_CORE_IFWL_WIDGET_H_
 #define XFA_FWL_CORE_IFWL_WIDGET_H_
 
+#include <memory>
+
 #include "core/fxcrt/include/fx_basic.h"
 #include "core/fxcrt/include/fx_coordinates.h"
 #include "core/fxcrt/include/fx_system.h"
 #include "xfa/fwl/core/fwl_error.h"
-#include "xfa/fwl/core/ifwl_target.h"
+#include "xfa/fwl/core/fwl_widgetimp.h"
 
+// FWL contains three parallel inheritance hierarchies, which reference each
+// other via pointers as follows:
+//
+//                   m_pIface                m_pImpl
+//      CFWL_Widget ----------> IFWL_Widget ----------> CFWL_WidgetImp
+//           |                       |                       |
+//           A                       A                       A
+//           |                       |                       |
+//      CFWL_...                IFWL_...                CFWL_...Imp
+//
+
+class CFWL_WidgetImp;
 class CFX_Graphics;
+class IFWL_App;
 class IFWL_DataProvider;
 class IFWL_Form;
-class IFWL_Thread;
 class IFWL_ThemeProvider;
 class IFWL_WidgetDelegate;
 
-class IFWL_Widget : public IFWL_Target {
+class IFWL_Widget {
  public:
+  IFWL_Widget() : m_pImpl(nullptr) {}
+  virtual ~IFWL_Widget();
+
   FWL_ERR GetWidgetRect(CFX_RectF& rect, FX_BOOL bAutoSize = FALSE);
   FWL_ERR GetGlobalRect(CFX_RectF& rect);
   FWL_ERR SetWidgetRect(const CFX_RectF& rect);
@@ -54,8 +71,25 @@
   FWL_ERR SetThemeProvider(IFWL_ThemeProvider* pThemeProvider);
   FWL_ERR SetDataProvider(IFWL_DataProvider* pDataProvider);
   IFWL_WidgetDelegate* SetDelegate(IFWL_WidgetDelegate* pDelegate);
-  IFWL_Thread* GetOwnerThread() const;
+  IFWL_App* GetOwnerApp() const;
   CFX_SizeF GetOffsetFromParent(IFWL_Widget* pParent);
+
+  // These call into equivalent polymorphic methods of m_pImpl. There
+  // should be no need to override these in subclasses.
+  FWL_ERR GetClassName(CFX_WideString& wsClass) const;
+  uint32_t GetClassID() const;
+  FX_BOOL IsInstance(const CFX_WideStringC& wsClass) const;
+  FWL_ERR Initialize();
+  FWL_ERR Finalize();
+
+  CFWL_WidgetImp* GetImpl() const { return m_pImpl.get(); }
+
+ protected:
+  // Takes ownership of |pImpl|.
+  void SetImpl(CFWL_WidgetImp* pImpl) { m_pImpl.reset(pImpl); }
+
+ private:
+  std::unique_ptr<CFWL_WidgetImp> m_pImpl;
 };
 
 #endif  // XFA_FWL_CORE_IFWL_WIDGET_H_
diff --git a/xfa/fwl/core/ifwl_widgetmgrdelegate.h b/xfa/fwl/core/ifwl_widgetmgrdelegate.h
deleted file mode 100644
index 2435c0b..0000000
--- a/xfa/fwl/core/ifwl_widgetmgrdelegate.h
+++ /dev/null
@@ -1,33 +0,0 @@
-// Copyright 2016 PDFium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
-
-#ifndef XFA_FWL_CORE_IFWL_WIDGETMGRDELEGATE_H_
-#define XFA_FWL_CORE_IFWL_WIDGETMGRDELEGATE_H_
-
-#include "core/fxcrt/include/fx_system.h"
-#include "xfa/fwl/core/fwl_error.h"
-
-#define FWL_WGTMGR_DisableThread 0x00000001
-#define FWL_WGTMGR_DisableForm 0x00000002
-
-class CFWL_Message;
-class CFX_Graphics;
-class CFX_Matrix;
-class IFWL_Widget;
-
-class IFWL_WidgetMgrDelegate {
- public:
-  virtual ~IFWL_WidgetMgrDelegate() {}
-
-  virtual FWL_ERR OnSetCapability(
-      uint32_t dwCapability = FWL_WGTMGR_DisableThread) = 0;
-  virtual int32_t OnProcessMessageToForm(CFWL_Message* pMessage) = 0;
-  virtual FWL_ERR OnDrawWidget(IFWL_Widget* pWidget,
-                               CFX_Graphics* pGraphics,
-                               const CFX_Matrix* pMatrix = nullptr) = 0;
-};
-
-#endif  // XFA_FWL_CORE_IFWL_WIDGETMGRDELEGATE_H_
diff --git a/xfa/fwl/lightwidget/cfwl_tooltip.cpp b/xfa/fwl/lightwidget/cfwl_tooltip.cpp
index 2c16cfd..efb61ce 100644
--- a/xfa/fwl/lightwidget/cfwl_tooltip.cpp
+++ b/xfa/fwl/lightwidget/cfwl_tooltip.cpp
@@ -10,8 +10,6 @@
 
 #include "xfa/fwl/core/fwl_formimp.h"
 #include "xfa/fwl/core/fwl_noteimp.h"
-#include "xfa/fwl/core/fwl_targetimp.h"
-#include "xfa/fwl/core/fwl_threadimp.h"
 #include "xfa/fwl/core/fwl_widgetimp.h"
 
 CFWL_ToolTip* CFWL_ToolTip::Create() {
diff --git a/xfa/fwl/lightwidget/cfwl_widget.cpp b/xfa/fwl/lightwidget/cfwl_widget.cpp
index 5fbe935..98a5a22 100644
--- a/xfa/fwl/lightwidget/cfwl_widget.cpp
+++ b/xfa/fwl/lightwidget/cfwl_widget.cpp
@@ -10,11 +10,10 @@
 #include "xfa/fwl/core/cfwl_themetext.h"
 #include "xfa/fwl/core/fwl_noteimp.h"
 #include "xfa/fwl/core/fwl_noteimp.h"
-#include "xfa/fwl/core/fwl_targetimp.h"
 #include "xfa/fwl/core/fwl_widgetimp.h"
 #include "xfa/fwl/core/fwl_widgetmgrimp.h"
+#include "xfa/fwl/core/ifwl_app.h"
 #include "xfa/fwl/core/ifwl_themeprovider.h"
-#include "xfa/fwl/core/ifwl_thread.h"
 
 IFWL_Widget* CFWL_Widget::GetWidget() {
   return m_pIface;
@@ -215,7 +214,7 @@
     : m_pIface(NULL), m_pDelegate(NULL), m_pProperties(NULL) {
   m_pProperties = new CFWL_WidgetProperties;
   m_pWidgetMgr = static_cast<CFWL_WidgetMgr*>(FWL_GetWidgetMgr());
-  ASSERT(m_pWidgetMgr != NULL);
+  ASSERT(m_pWidgetMgr);
 }
 
 CFWL_Widget::~CFWL_Widget() {
@@ -242,12 +241,15 @@
 FWL_ERR CFWL_Widget::SetFocus(FX_BOOL bFocus) {
   if (!m_pIface)
     return FWL_ERR_Indefinite;
-  IFWL_Thread* pThread = m_pIface->GetOwnerThread();
-  if (!pThread)
+
+  IFWL_App* pApp = m_pIface->GetOwnerApp();
+  if (!pApp)
     return FWL_ERR_Indefinite;
-  IFWL_NoteDriver* pDriver = pThread->GetNoteDriver();
+
+  CFWL_NoteDriver* pDriver = pApp->GetNoteDriver();
   if (!pDriver)
     return FWL_ERR_Indefinite;
+
   if (bFocus) {
     pDriver->SetFocus(m_pIface);
   } else {
@@ -261,12 +263,15 @@
 FWL_ERR CFWL_Widget::SetGrab(FX_BOOL bSet) {
   if (!m_pIface)
     return FWL_ERR_Indefinite;
-  IFWL_Thread* pThread = m_pIface->GetOwnerThread();
-  if (!pThread)
+
+  IFWL_App* pApp = m_pIface->GetOwnerApp();
+  if (!pApp)
     return FWL_ERR_Indefinite;
-  IFWL_NoteDriver* pDriver = pThread->GetNoteDriver();
+
+  CFWL_NoteDriver* pDriver = pApp->GetNoteDriver();
   if (!pDriver)
     return FWL_ERR_Indefinite;
+
   pDriver->SetGrab(m_pIface, bSet);
   return FWL_ERR_Succeeded;
 }
@@ -275,12 +280,15 @@
                                       uint32_t dwFilter) {
   if (!m_pIface)
     return;
-  IFWL_Thread* pThread = m_pIface->GetOwnerThread();
-  if (!pThread)
+
+  IFWL_App* pApp = m_pIface->GetOwnerApp();
+  if (!pApp)
     return;
-  IFWL_NoteDriver* pNoteDriver = pThread->GetNoteDriver();
+
+  CFWL_NoteDriver* pNoteDriver = pApp->GetNoteDriver();
   if (!pNoteDriver)
     return;
+
   IFWL_Widget* pEventSourceImp =
       !pEventSource ? NULL : pEventSource->GetWidget();
   pNoteDriver->RegisterEventTarget(GetWidget(), pEventSourceImp, dwFilter);
@@ -292,10 +300,10 @@
   if (m_pIface->GetOuter()) {
     return;
   }
-  IFWL_Thread* pThread = m_pIface->GetOwnerThread();
-  if (!pThread)
+  IFWL_App* pApp = m_pIface->GetOwnerApp();
+  if (!pApp)
     return;
-  IFWL_NoteDriver* pNoteDriver = pThread->GetNoteDriver();
+  CFWL_NoteDriver* pNoteDriver = pApp->GetNoteDriver();
   if (!pNoteDriver)
     return;
   pNoteDriver->SendEvent(pEvent);
diff --git a/xfa/fwl/theme/cfwl_widgettp.cpp b/xfa/fwl/theme/cfwl_widgettp.cpp
index 5332b3b..7f4e547 100644
--- a/xfa/fwl/theme/cfwl_widgettp.cpp
+++ b/xfa/fwl/theme/cfwl_widgettp.cpp
@@ -14,6 +14,7 @@
 #include "xfa/fwl/core/cfwl_themepart.h"
 #include "xfa/fwl/core/cfwl_themetext.h"
 #include "xfa/fwl/core/ifwl_themeprovider.h"
+#include "xfa/fwl/core/ifwl_widget.h"
 #include "xfa/fwl/core/ifwl_widgetmgr.h"
 #include "xfa/fxgraphics/cfx_color.h"
 #include "xfa/fxgraphics/cfx_path.h"
diff --git a/xfa/fxfa/app/xfa_ffapp.cpp b/xfa/fxfa/app/xfa_ffapp.cpp
index 987b3e8..de63dc4 100644
--- a/xfa/fxfa/app/xfa_ffapp.cpp
+++ b/xfa/fxfa/app/xfa_ffapp.cpp
@@ -9,7 +9,7 @@
 #include <algorithm>
 
 #include "xfa/fgas/font/fgas_stdfontmgr.h"
-#include "xfa/fwl/core/ifwl_widgetmgrdelegate.h"
+#include "xfa/fwl/core/fwl_widgetmgrimp.h"
 #include "xfa/fxfa/app/xfa_fwladapter.h"
 #include "xfa/fxfa/app/xfa_fwltheme.h"
 #include "xfa/fxfa/include/xfa_ffdoc.h"
@@ -160,7 +160,7 @@
   return m_pFWLTheme;
 }
 IFWL_AdapterWidgetMgr* CXFA_FFApp::GetWidgetMgr(
-    IFWL_WidgetMgrDelegate* pDelegate) {
+    CFWL_WidgetMgrDelegate* pDelegate) {
   if (!m_pAdapterWidgetMgr) {
     m_pAdapterWidgetMgr = new CXFA_FWLAdapterWidgetMgr;
     pDelegate->OnSetCapability(FWL_WGTMGR_DisableThread |
diff --git a/xfa/fxfa/app/xfa_ffbarcode.cpp b/xfa/fxfa/app/xfa_ffbarcode.cpp
index b4608a3..a659e13 100644
--- a/xfa/fxfa/app/xfa_ffbarcode.cpp
+++ b/xfa/fxfa/app/xfa_ffbarcode.cpp
@@ -7,8 +7,8 @@
 #include "xfa/fxfa/app/xfa_ffbarcode.h"
 
 #include "core/fxcrt/include/fx_ext.h"
+#include "xfa/fwl/core/fwl_noteimp.h"
 #include "xfa/fwl/core/ifwl_app.h"
-#include "xfa/fwl/core/ifwl_notedriver.h"
 #include "xfa/fwl/lightwidget/cfwl_barcode.h"
 #include "xfa/fxfa/app/xfa_fffield.h"
 #include "xfa/fxfa/app/xfa_fftextedit.h"
@@ -128,7 +128,7 @@
   m_pNormalWidget = pFWLBarcode;
   IFWL_Widget* pWidget = m_pNormalWidget->GetWidget();
   m_pNormalWidget->SetPrivateData(pWidget, this, NULL);
-  IFWL_NoteDriver* pNoteDriver = FWL_GetApp()->GetNoteDriver();
+  CFWL_NoteDriver* pNoteDriver = FWL_GetApp()->GetNoteDriver();
   pNoteDriver->RegisterEventTarget(pWidget, pWidget);
   m_pOldDelegate = m_pNormalWidget->SetDelegate(this);
   m_pNormalWidget->LockUpdate();
diff --git a/xfa/fxfa/app/xfa_ffcheckbutton.cpp b/xfa/fxfa/app/xfa_ffcheckbutton.cpp
index 4527afe..11deff1 100644
--- a/xfa/fxfa/app/xfa_ffcheckbutton.cpp
+++ b/xfa/fxfa/app/xfa_ffcheckbutton.cpp
@@ -7,8 +7,8 @@
 #include "xfa/fxfa/app/xfa_ffcheckbutton.h"
 
 #include "xfa/fwl/core/cfwl_message.h"
-#include "xfa/fwl/core/ifwl_notedriver.h"
-#include "xfa/fwl/core/ifwl_widgetmgrdelegate.h"
+#include "xfa/fwl/core/fwl_noteimp.h"
+#include "xfa/fwl/core/fwl_widgetmgrimp.h"
 #include "xfa/fwl/lightwidget/cfwl_checkbox.h"
 #include "xfa/fxfa/app/xfa_ffexclgroup.h"
 #include "xfa/fxfa/app/xfa_fffield.h"
@@ -30,7 +30,7 @@
   m_pNormalWidget = pCheckBox;
   IFWL_Widget* pWidget = m_pNormalWidget->GetWidget();
   m_pNormalWidget->SetPrivateData(pWidget, this, NULL);
-  IFWL_NoteDriver* pNoteDriver = FWL_GetApp()->GetNoteDriver();
+  CFWL_NoteDriver* pNoteDriver = FWL_GetApp()->GetNoteDriver();
   pNoteDriver->RegisterEventTarget(pWidget, pWidget);
   m_pOldDelegate = m_pNormalWidget->SetDelegate(this);
   if (m_pDataAcc->IsRadioButton()) {
diff --git a/xfa/fxfa/app/xfa_ffchoicelist.cpp b/xfa/fxfa/app/xfa_ffchoicelist.cpp
index cfd78c2..6bb7c0b 100644
--- a/xfa/fxfa/app/xfa_ffchoicelist.cpp
+++ b/xfa/fxfa/app/xfa_ffchoicelist.cpp
@@ -7,8 +7,8 @@
 #include "xfa/fxfa/app/xfa_ffchoicelist.h"
 
 #include "xfa/fwl/basewidget/ifwl_edit.h"
+#include "xfa/fwl/core/fwl_noteimp.h"
 #include "xfa/fwl/core/ifwl_app.h"
-#include "xfa/fwl/core/ifwl_notedriver.h"
 #include "xfa/fwl/lightwidget/cfwl_combobox.h"
 #include "xfa/fwl/lightwidget/cfwl_listbox.h"
 #include "xfa/fxfa/app/xfa_fffield.h"
@@ -24,7 +24,7 @@
 CXFA_FFListBox::~CXFA_FFListBox() {
   if (m_pNormalWidget) {
     IFWL_Widget* pWidget = m_pNormalWidget->GetWidget();
-    IFWL_NoteDriver* pNoteDriver = FWL_GetApp()->GetNoteDriver();
+    CFWL_NoteDriver* pNoteDriver = FWL_GetApp()->GetNoteDriver();
     pNoteDriver->UnregisterEventTarget(pWidget);
   }
 }
@@ -36,7 +36,7 @@
   m_pNormalWidget = (CFWL_Widget*)pListBox;
   IFWL_Widget* pWidget = m_pNormalWidget->GetWidget();
   m_pNormalWidget->SetPrivateData(pWidget, this, NULL);
-  IFWL_NoteDriver* pNoteDriver = FWL_GetApp()->GetNoteDriver();
+  CFWL_NoteDriver* pNoteDriver = FWL_GetApp()->GetNoteDriver();
   pNoteDriver->RegisterEventTarget(pWidget, pWidget);
   m_pOldDelegate = m_pNormalWidget->SetDelegate(this);
   m_pNormalWidget->LockUpdate();
@@ -232,7 +232,7 @@
   m_pNormalWidget = (CFWL_Widget*)pComboBox;
   IFWL_Widget* pWidget = m_pNormalWidget->GetWidget();
   m_pNormalWidget->SetPrivateData(pWidget, this, NULL);
-  IFWL_NoteDriver* pNoteDriver = FWL_GetApp()->GetNoteDriver();
+  CFWL_NoteDriver* pNoteDriver = FWL_GetApp()->GetNoteDriver();
   pNoteDriver->RegisterEventTarget(pWidget, pWidget);
   m_pOldDelegate = m_pNormalWidget->SetDelegate(this);
   m_pNormalWidget->LockUpdate();
diff --git a/xfa/fxfa/app/xfa_ffdoc.cpp b/xfa/fxfa/app/xfa_ffdoc.cpp
index 12e562c..f33e4e0 100644
--- a/xfa/fxfa/app/xfa_ffdoc.cpp
+++ b/xfa/fxfa/app/xfa_ffdoc.cpp
@@ -15,7 +15,7 @@
 #include "core/fxcrt/include/fx_memory.h"
 #include "xfa/fde/xml/fde_xml_imp.h"
 #include "xfa/fgas/crt/fgas_algorithm.h"
-#include "xfa/fwl/core/ifwl_notedriver.h"
+#include "xfa/fwl/core/fwl_noteimp.h"
 #include "xfa/fxfa/app/xfa_ffnotify.h"
 #include "xfa/fxfa/include/xfa_checksum.h"
 #include "xfa/fxfa/include/xfa_ffapp.h"
diff --git a/xfa/fxfa/app/xfa_fffield.cpp b/xfa/fxfa/app/xfa_fffield.cpp
index b48893a..d19bb4c 100644
--- a/xfa/fxfa/app/xfa_fffield.cpp
+++ b/xfa/fxfa/app/xfa_fffield.cpp
@@ -8,7 +8,7 @@
 
 #include "xfa/fwl/basewidget/ifwl_edit.h"
 #include "xfa/fwl/core/cfwl_message.h"
-#include "xfa/fwl/core/ifwl_widgetmgrdelegate.h"
+#include "xfa/fwl/core/fwl_widgetmgrimp.h"
 #include "xfa/fwl/lightwidget/cfwl_edit.h"
 #include "xfa/fwl/lightwidget/cfwl_picturebox.h"
 #include "xfa/fxfa/app/xfa_fwltheme.h"
@@ -334,10 +334,8 @@
     return;
   }
   CFX_RectF rtUi = m_rtUI;
-  if (rtUi.width < 1.0) {
-    ASSERT(rtUi.width < 1.0);
+  if (rtUi.width < 1.0)
     rtUi.width = 1.0;
-  }
   if (!m_pDataAcc->GetDoc()->GetXFADoc()->IsInteractive()) {
     FX_FLOAT fFontSize = m_pDataAcc->GetFontSize();
     if (rtUi.height < fFontSize) {
diff --git a/xfa/fxfa/app/xfa_ffimageedit.cpp b/xfa/fxfa/app/xfa_ffimageedit.cpp
index 909f7e3..94cafba 100644
--- a/xfa/fxfa/app/xfa_ffimageedit.cpp
+++ b/xfa/fxfa/app/xfa_ffimageedit.cpp
@@ -7,8 +7,8 @@
 #include "xfa/fxfa/app/xfa_ffimageedit.h"
 
 #include "xfa/fwl/core/cfwl_message.h"
+#include "xfa/fwl/core/fwl_noteimp.h"
 #include "xfa/fwl/core/ifwl_app.h"
-#include "xfa/fwl/core/ifwl_notedriver.h"
 #include "xfa/fwl/lightwidget/cfwl_picturebox.h"
 #include "xfa/fxfa/app/xfa_fffield.h"
 #include "xfa/fxfa/include/xfa_ffdoc.h"
@@ -30,7 +30,7 @@
   m_pNormalWidget = (CFWL_Widget*)pPictureBox;
   IFWL_Widget* pWidget = m_pNormalWidget->GetWidget();
   m_pNormalWidget->SetPrivateData(pWidget, this, NULL);
-  IFWL_NoteDriver* pNoteDriver = FWL_GetApp()->GetNoteDriver();
+  CFWL_NoteDriver* pNoteDriver = FWL_GetApp()->GetNoteDriver();
   pNoteDriver->RegisterEventTarget(pWidget, pWidget);
   m_pOldDelegate = pPictureBox->SetDelegate(this);
   CXFA_FFField::LoadWidget();
diff --git a/xfa/fxfa/app/xfa_ffpushbutton.cpp b/xfa/fxfa/app/xfa_ffpushbutton.cpp
index 6136fd3..3893bc2 100644
--- a/xfa/fxfa/app/xfa_ffpushbutton.cpp
+++ b/xfa/fxfa/app/xfa_ffpushbutton.cpp
@@ -6,8 +6,8 @@
 
 #include "xfa/fxfa/app/xfa_ffpushbutton.h"
 
-#include "xfa/fwl/core/ifwl_notedriver.h"
-#include "xfa/fwl/core/ifwl_widgetmgrdelegate.h"
+#include "xfa/fwl/core/fwl_noteimp.h"
+#include "xfa/fwl/core/fwl_widgetmgrimp.h"
 #include "xfa/fwl/lightwidget/cfwl_pushbutton.h"
 #include "xfa/fxfa/app/xfa_fffield.h"
 #include "xfa/fxfa/app/xfa_ffwidgetacc.h"
@@ -52,7 +52,7 @@
                                                  pGS, &mt);
 }
 FX_BOOL CXFA_FFPushButton::LoadWidget() {
-  ASSERT(m_pNormalWidget == NULL);
+  ASSERT(!m_pNormalWidget);
   CFWL_PushButton* pPushButton = CFWL_PushButton::Create();
   if (pPushButton) {
     pPushButton->Initialize();
@@ -61,7 +61,7 @@
   m_pNormalWidget = (CFWL_Widget*)pPushButton;
   IFWL_Widget* pWidget = m_pNormalWidget->GetWidget();
   m_pNormalWidget->SetPrivateData(pWidget, this, NULL);
-  IFWL_NoteDriver* pNoteDriver = FWL_GetApp()->GetNoteDriver();
+  CFWL_NoteDriver* pNoteDriver = FWL_GetApp()->GetNoteDriver();
   pNoteDriver->RegisterEventTarget(pWidget, pWidget);
   m_pNormalWidget->LockUpdate();
   UpdateWidgetProperty();
diff --git a/xfa/fxfa/app/xfa_fftextedit.cpp b/xfa/fxfa/app/xfa_fftextedit.cpp
index baa1d8a..e978e30 100644
--- a/xfa/fxfa/app/xfa_fftextedit.cpp
+++ b/xfa/fxfa/app/xfa_fftextedit.cpp
@@ -11,7 +11,7 @@
 #include "xfa/fwl/basewidget/ifwl_datetimepicker.h"
 #include "xfa/fwl/basewidget/ifwl_edit.h"
 #include "xfa/fwl/core/cfwl_message.h"
-#include "xfa/fwl/core/ifwl_notedriver.h"
+#include "xfa/fwl/core/fwl_noteimp.h"
 #include "xfa/fwl/lightwidget/cfwl_datetimepicker.h"
 #include "xfa/fwl/lightwidget/cfwl_edit.h"
 #include "xfa/fxfa/app/xfa_fffield.h"
@@ -30,7 +30,7 @@
 CXFA_FFTextEdit::~CXFA_FFTextEdit() {
   if (m_pNormalWidget) {
     IFWL_Widget* pWidget = m_pNormalWidget->GetWidget();
-    IFWL_NoteDriver* pNoteDriver = FWL_GetApp()->GetNoteDriver();
+    CFWL_NoteDriver* pNoteDriver = FWL_GetApp()->GetNoteDriver();
     pNoteDriver->UnregisterEventTarget(pWidget);
   }
 }
@@ -40,7 +40,7 @@
   m_pNormalWidget = pFWLEdit;
   IFWL_Widget* pWidget = m_pNormalWidget->GetWidget();
   m_pNormalWidget->SetPrivateData(pWidget, this, NULL);
-  IFWL_NoteDriver* pNoteDriver = FWL_GetApp()->GetNoteDriver();
+  CFWL_NoteDriver* pNoteDriver = FWL_GetApp()->GetNoteDriver();
   pNoteDriver->RegisterEventTarget(pWidget, pWidget);
   m_pOldDelegate = m_pNormalWidget->SetDelegate(this);
   m_pNormalWidget->LockUpdate();
@@ -449,7 +449,7 @@
   m_pNormalWidget = (CFWL_Widget*)pWidget;
   IFWL_Widget* pIWidget = m_pNormalWidget->GetWidget();
   m_pNormalWidget->SetPrivateData(pIWidget, this, NULL);
-  IFWL_NoteDriver* pNoteDriver = FWL_GetApp()->GetNoteDriver();
+  CFWL_NoteDriver* pNoteDriver = FWL_GetApp()->GetNoteDriver();
   pNoteDriver->RegisterEventTarget(pIWidget, pIWidget);
   m_pOldDelegate = m_pNormalWidget->SetDelegate(this);
   m_pNormalWidget->LockUpdate();
@@ -523,7 +523,7 @@
   m_pNormalWidget = (CFWL_Widget*)pWidget;
   IFWL_Widget* pIWidget = m_pNormalWidget->GetWidget();
   m_pNormalWidget->SetPrivateData(pIWidget, this, NULL);
-  IFWL_NoteDriver* pNoteDriver = FWL_GetApp()->GetNoteDriver();
+  CFWL_NoteDriver* pNoteDriver = FWL_GetApp()->GetNoteDriver();
   pNoteDriver->RegisterEventTarget(pIWidget, pIWidget);
   m_pOldDelegate = m_pNormalWidget->SetDelegate(this);
   m_pNormalWidget->LockUpdate();
@@ -589,7 +589,7 @@
   m_pNormalWidget = (CFWL_Widget*)pWidget;
   IFWL_Widget* pIWidget = m_pNormalWidget->GetWidget();
   m_pNormalWidget->SetPrivateData(pIWidget, this, NULL);
-  IFWL_NoteDriver* pNoteDriver = FWL_GetApp()->GetNoteDriver();
+  CFWL_NoteDriver* pNoteDriver = FWL_GetApp()->GetNoteDriver();
   pNoteDriver->RegisterEventTarget(pIWidget, pIWidget);
   m_pOldDelegate = m_pNormalWidget->SetDelegate(this);
   m_pNormalWidget->LockUpdate();
diff --git a/xfa/fxfa/app/xfa_fwltheme.h b/xfa/fxfa/app/xfa_fwltheme.h
index 75885a5..ae95637 100644
--- a/xfa/fxfa/app/xfa_fwltheme.h
+++ b/xfa/fxfa/app/xfa_fwltheme.h
@@ -7,7 +7,6 @@
 #ifndef XFA_FXFA_APP_XFA_FWLTHEME_H_
 #define XFA_FXFA_APP_XFA_FWLTHEME_H_
 
-#include "xfa/fwl/core/ifwl_target.h"
 #include "xfa/fwl/core/ifwl_themeprovider.h"
 #include "xfa/fwl/theme/cfwl_barcodetp.h"
 #include "xfa/fwl/theme/cfwl_carettp.h"
@@ -31,7 +30,7 @@
     delete this;
     return FWL_ERR_Succeeded;
   }
-  virtual IFWL_Target* Retain() { return NULL; }
+  virtual IFWL_Widget* Retain() { return NULL; }
   virtual FWL_ERR GetClassName(CFX_WideString& wsClass) const {
     return FWL_ERR_Succeeded;
   }
diff --git a/xfa/fxfa/include/xfa_ffapp.h b/xfa/fxfa/include/xfa_ffapp.h
index 8ecc89d..774bebb 100644
--- a/xfa/fxfa/include/xfa_ffapp.h
+++ b/xfa/fxfa/include/xfa_ffapp.h
@@ -49,14 +49,14 @@
 
   // IFWL_AdapterNative:
   IFWL_AdapterWidgetMgr* GetWidgetMgr(
-      IFWL_WidgetMgrDelegate* pDelegate) override;
+      CFWL_WidgetMgrDelegate* pDelegate) override;
   IFWL_AdapterThreadMgr* GetThreadMgr() override;
   IFWL_AdapterTimerMgr* GetTimerMgr() override;
 
   CXFA_FontMgr* GetXFAFontMgr();
   IFX_FontMgr* GetFDEFontMgr();
   CXFA_FWLTheme* GetFWLTheme();
-  IFWL_WidgetMgrDelegate* GetWidgetMgrDelegate() {
+  CFWL_WidgetMgrDelegate* GetWidgetMgrDelegate() {
     return m_pWidgetMgrDelegate;
   }
 
@@ -70,7 +70,7 @@
   CFX_FontSourceEnum_File* m_pFontSource;
 #endif
   CXFA_FWLAdapterWidgetMgr* m_pAdapterWidgetMgr;
-  IFWL_WidgetMgrDelegate* m_pWidgetMgrDelegate;
+  CFWL_WidgetMgrDelegate* m_pWidgetMgrDelegate;
   IFX_FontMgr* m_pFDEFontMgr;
   CFWL_SDAdapterThreadMgr* m_pAdapterThreadMgr;
 };