summaryrefslogtreecommitdiff
path: root/xfa/fwl
diff options
context:
space:
mode:
authordsinclair <dsinclair@chromium.org>2016-10-18 16:48:16 -0700
committerCommit bot <commit-bot@chromium.org>2016-10-18 16:48:16 -0700
commit4e903136cf0f02578c0e47c6738b633c96814b62 (patch)
treef6c85bfe408c728b9b2dbfcaf60316912945643d /xfa/fwl
parentf328d0d378b8df8a3416988d96c34f1d3f9d26d1 (diff)
downloadpdfium-4e903136cf0f02578c0e47c6738b633c96814b62.tar.xz
Merge IFWL_App and FWL_AppImp together
The IFWL_App class just acts as a proxy to the FWL_AppImp code. This Cl removes FWL_AppImp and merges the code back up to IFWL_App, simplifying the object hierarchy. Review-Url: https://codereview.chromium.org/2430563003
Diffstat (limited to 'xfa/fwl')
-rw-r--r--xfa/fwl/basewidget/fwl_comboboximp.cpp1
-rw-r--r--xfa/fwl/basewidget/fwl_editimp.cpp1
-rw-r--r--xfa/fwl/core/cfwl_widgetmgr.cpp1
-rw-r--r--xfa/fwl/core/fwl_appimp.cpp117
-rw-r--r--xfa/fwl/core/fwl_appimp.h44
-rw-r--r--xfa/fwl/core/fwl_formimp.cpp1
-rw-r--r--xfa/fwl/core/fwl_noteimp.cpp1
-rw-r--r--xfa/fwl/core/fwl_timerimp.cpp1
-rw-r--r--xfa/fwl/core/fwl_widgetimp.cpp9
-rw-r--r--xfa/fwl/core/fwl_widgetimp.h4
-rw-r--r--xfa/fwl/core/ifwl_app.cpp50
-rw-r--r--xfa/fwl/core/ifwl_app.h38
12 files changed, 62 insertions, 206 deletions
diff --git a/xfa/fwl/basewidget/fwl_comboboximp.cpp b/xfa/fwl/basewidget/fwl_comboboximp.cpp
index 17c5bf80d4..e586055c3b 100644
--- a/xfa/fwl/basewidget/fwl_comboboximp.cpp
+++ b/xfa/fwl/basewidget/fwl_comboboximp.cpp
@@ -17,7 +17,6 @@
#include "xfa/fwl/core/cfwl_themepart.h"
#include "xfa/fwl/core/cfwl_themetext.h"
#include "xfa/fwl/core/cfwl_widgetmgr.h"
-#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_widgetimp.h"
diff --git a/xfa/fwl/basewidget/fwl_editimp.cpp b/xfa/fwl/basewidget/fwl_editimp.cpp
index 8377daf628..0f939f1145 100644
--- a/xfa/fwl/basewidget/fwl_editimp.cpp
+++ b/xfa/fwl/basewidget/fwl_editimp.cpp
@@ -24,7 +24,6 @@
#include "xfa/fwl/core/cfwl_themebackground.h"
#include "xfa/fwl/core/cfwl_themepart.h"
#include "xfa/fwl/core/cfwl_widgetmgr.h"
-#include "xfa/fwl/core/fwl_appimp.h"
#include "xfa/fwl/core/fwl_widgetimp.h"
#include "xfa/fwl/core/ifwl_app.h"
#include "xfa/fwl/core/ifwl_themeprovider.h"
diff --git a/xfa/fwl/core/cfwl_widgetmgr.cpp b/xfa/fwl/core/cfwl_widgetmgr.cpp
index db1035005f..30571c9aed 100644
--- a/xfa/fwl/core/cfwl_widgetmgr.cpp
+++ b/xfa/fwl/core/cfwl_widgetmgr.cpp
@@ -7,7 +7,6 @@
#include "xfa/fwl/core/cfwl_widgetmgr.h"
#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_widgetimp.h"
#include "xfa/fwl/core/ifwl_app.h"
diff --git a/xfa/fwl/core/fwl_appimp.cpp b/xfa/fwl/core/fwl_appimp.cpp
deleted file mode 100644
index 2df579ca38..0000000000
--- a/xfa/fwl/core/fwl_appimp.cpp
+++ /dev/null
@@ -1,117 +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_appimp.h"
-
-#include "xfa/fwl/core/cfwl_widgetmgr.h"
-#include "xfa/fwl/core/fwl_noteimp.h"
-#include "xfa/fwl/core/ifwl_app.h"
-#include "xfa/fwl/core/ifwl_widget.h"
-#include "xfa/fxfa/app/xfa_fwladapter.h"
-
-IFWL_App* IFWL_App::Create(CXFA_FFApp* pAdapter) {
- IFWL_App* pApp = new IFWL_App;
- pApp->SetImpl(new CFWL_AppImp(pApp, pAdapter));
- return pApp;
-}
-
-IFWL_App::IFWL_App() {}
-
-IFWL_App::~IFWL_App() {}
-
-void IFWL_App::Release() {}
-
-FWL_Error IFWL_App::Initialize() {
- return static_cast<CFWL_AppImp*>(GetImpl())->Initialize();
-}
-
-FWL_Error IFWL_App::Finalize() {
- return static_cast<CFWL_AppImp*>(GetImpl())->Finalize();
-}
-
-CXFA_FFApp* IFWL_App::GetAdapterNative() {
- return static_cast<CFWL_AppImp*>(GetImpl())->GetAdapterNative();
-}
-
-CFWL_WidgetMgr* IFWL_App::GetWidgetMgr() {
- return static_cast<CFWL_AppImp*>(GetImpl())->GetWidgetMgr();
-}
-
-IFWL_ThemeProvider* IFWL_App::GetThemeProvider() {
- return static_cast<CFWL_AppImp*>(GetImpl())->GetThemeProvider();
-}
-
-void IFWL_App::SetThemeProvider(IFWL_ThemeProvider* pThemeProvider) {
- static_cast<CFWL_AppImp*>(GetImpl())->SetThemeProvider(pThemeProvider);
-}
-
-void IFWL_App::Exit(int32_t iExitCode) {
- 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, CXFA_FFApp* pAdapter)
- : m_pAdapterNative(pAdapter),
- m_pThemeProvider(nullptr),
- m_pNoteDriver(new CFWL_NoteDriver),
- m_pIface(pIface) {}
-
-CFWL_AppImp::~CFWL_AppImp() {
- CFWL_ToolTipContainer::DeleteInstance();
-}
-
-FWL_Error CFWL_AppImp::Initialize() {
- if (!m_pWidgetMgr) {
- m_pWidgetMgr.reset(new CFWL_WidgetMgr(m_pAdapterNative));
- }
- return FWL_Error::Succeeded;
-}
-FWL_Error CFWL_AppImp::Finalize() {
- m_pWidgetMgr.reset();
- return FWL_Error::Succeeded;
-}
-CXFA_FFApp* CFWL_AppImp::GetAdapterNative() const {
- return m_pAdapterNative;
-}
-CXFA_FWLAdapterWidgetMgr* FWL_GetAdapterWidgetMgr() {
- return CFWL_WidgetMgr::GetInstance()->GetAdapterWidgetMgr();
-}
-CFWL_WidgetMgr* CFWL_AppImp::GetWidgetMgr() const {
- return m_pWidgetMgr.get();
-}
-
-void CFWL_AppImp::SetThemeProvider(IFWL_ThemeProvider* pThemeProvider) {
- m_pThemeProvider = pThemeProvider;
-}
-
-void CFWL_AppImp::Exit(int32_t iExitCode) {
- while (m_pNoteDriver->PopNoteLoop()) {
- continue;
- }
-}
-
-IFWL_ThemeProvider* CFWL_AppImp::GetThemeProvider() const {
- return m_pThemeProvider;
-}
-
-CXFA_FFApp* FWL_GetAdapterNative() {
- IFWL_App* pApp = FWL_GetApp();
- if (!pApp)
- return nullptr;
- return pApp->GetAdapterNative();
-}
-
-static IFWL_App* g_theApp = nullptr;
-IFWL_App* FWL_GetApp() {
- return g_theApp;
-}
-
-void FWL_SetApp(IFWL_App* pApp) {
- g_theApp = pApp;
-}
diff --git a/xfa/fwl/core/fwl_appimp.h b/xfa/fwl/core/fwl_appimp.h
deleted file mode 100644
index f3377048fc..0000000000
--- a/xfa/fwl/core/fwl_appimp.h
+++ /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
-
-#ifndef XFA_FWL_CORE_FWL_APPIMP_H_
-#define XFA_FWL_CORE_FWL_APPIMP_H_
-
-#include <memory>
-
-#include "xfa/fwl/core/fwl_noteimp.h"
-
-class CFWL_WidgetMgr;
-class CXFA_FFApp;
-class IFWL_App;
-class IFWL_NoteThread;
-class IFWL_ThemeProvider;
-
-class CFWL_AppImp {
- public:
- CFWL_AppImp(IFWL_App* pIface, CXFA_FFApp* pAdapter);
- ~CFWL_AppImp();
-
- IFWL_App* GetInterface() const { return m_pIface; }
- CFWL_NoteDriver* GetNoteDriver() const { return m_pNoteDriver.get(); }
-
- FWL_Error Initialize();
- FWL_Error Finalize();
- CXFA_FFApp* GetAdapterNative() const;
- CFWL_WidgetMgr* GetWidgetMgr() const;
- IFWL_ThemeProvider* GetThemeProvider() const;
- void SetThemeProvider(IFWL_ThemeProvider* pThemeProvider);
- void Exit(int32_t iExitCode);
-
- private:
- CXFA_FFApp* const m_pAdapterNative;
- std::unique_ptr<CFWL_WidgetMgr> m_pWidgetMgr;
- IFWL_ThemeProvider* m_pThemeProvider;
- std::unique_ptr<CFWL_NoteDriver> m_pNoteDriver;
- 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 4dcedf67f9..747e5e83dc 100644
--- a/xfa/fwl/core/fwl_formimp.cpp
+++ b/xfa/fwl/core/fwl_formimp.cpp
@@ -13,7 +13,6 @@
#include "xfa/fwl/core/cfwl_themepart.h"
#include "xfa/fwl/core/cfwl_themetext.h"
#include "xfa/fwl/core/cfwl_widgetmgr.h"
-#include "xfa/fwl/core/fwl_appimp.h"
#include "xfa/fwl/core/fwl_noteimp.h"
#include "xfa/fwl/core/fwl_widgetimp.h"
#include "xfa/fwl/core/ifwl_app.h"
diff --git a/xfa/fwl/core/fwl_noteimp.cpp b/xfa/fwl/core/fwl_noteimp.cpp
index 3173f3e4db..848cb772ba 100644
--- a/xfa/fwl/core/fwl_noteimp.cpp
+++ b/xfa/fwl/core/fwl_noteimp.cpp
@@ -12,7 +12,6 @@
#include "xfa/fwl/basewidget/ifwl_tooltip.h"
#include "xfa/fwl/core/cfwl_message.h"
#include "xfa/fwl/core/cfwl_widgetmgr.h"
-#include "xfa/fwl/core/fwl_appimp.h"
#include "xfa/fwl/core/fwl_formimp.h"
#include "xfa/fwl/core/fwl_widgetimp.h"
#include "xfa/fwl/core/ifwl_app.h"
diff --git a/xfa/fwl/core/fwl_timerimp.cpp b/xfa/fwl/core/fwl_timerimp.cpp
index a46469391d..941113e7ca 100644
--- a/xfa/fwl/core/fwl_timerimp.cpp
+++ b/xfa/fwl/core/fwl_timerimp.cpp
@@ -4,7 +4,6 @@
// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
-#include "xfa/fwl/core/fwl_appimp.h"
#include "xfa/fwl/core/ifwl_adaptertimermgr.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 6e8ec09243..b59fd27713 100644
--- a/xfa/fwl/core/fwl_widgetimp.cpp
+++ b/xfa/fwl/core/fwl_widgetimp.cpp
@@ -15,7 +15,6 @@
#include "xfa/fwl/core/cfwl_themepart.h"
#include "xfa/fwl/core/cfwl_themetext.h"
#include "xfa/fwl/core/cfwl_widgetmgr.h"
-#include "xfa/fwl/core/fwl_appimp.h"
#include "xfa/fwl/core/fwl_noteimp.h"
#include "xfa/fwl/core/ifwl_app.h"
#include "xfa/fwl/core/ifwl_form.h"
@@ -179,7 +178,7 @@ FWL_Error CFWL_WidgetImp::Initialize() {
if (!pAdapter)
return FWL_Error::Indefinite;
- SetOwnerApp(static_cast<CFWL_AppImp*>(FWL_GetApp()->GetImpl()));
+ SetOwnerApp(FWL_GetApp());
IFWL_Widget* pParent = m_pProperties->m_pParent;
m_pWidgetMgr->InsertWidget(pParent, m_pInterface);
@@ -492,9 +491,9 @@ IFWL_WidgetDelegate* CFWL_WidgetImp::SetDelegate(
return pOldDelegate;
}
IFWL_App* CFWL_WidgetImp::GetOwnerApp() const {
- return static_cast<IFWL_App*>(m_pOwnerApp->GetInterface());
+ return m_pOwnerApp;
}
-FWL_Error CFWL_WidgetImp::SetOwnerApp(CFWL_AppImp* pOwnerApp) {
+FWL_Error CFWL_WidgetImp::SetOwnerApp(IFWL_App* pOwnerApp) {
m_pOwnerApp = pOwnerApp;
return FWL_Error::Succeeded;
}
@@ -642,7 +641,7 @@ IFWL_ThemeProvider* CFWL_WidgetImp::GetAvailableTheme() {
return pRet;
}
} while (pUp);
- return FWL_GetApp()->GetThemeProvider();
+ return nullptr;
}
CFWL_WidgetImp* CFWL_WidgetImp::GetRootOuter() {
IFWL_Widget* pRet = m_pOuter;
diff --git a/xfa/fwl/core/fwl_widgetimp.h b/xfa/fwl/core/fwl_widgetimp.h
index 57970a87eb..dfbfc5bf4b 100644
--- a/xfa/fwl/core/fwl_widgetimp.h
+++ b/xfa/fwl/core/fwl_widgetimp.h
@@ -72,7 +72,7 @@ class CFWL_WidgetImp {
virtual IFWL_WidgetDelegate* SetDelegate(IFWL_WidgetDelegate* pDelegate);
virtual IFWL_App* GetOwnerApp() const;
- FWL_Error SetOwnerApp(CFWL_AppImp* pOwnerApp);
+ FWL_Error SetOwnerApp(IFWL_App* pOwnerApp);
IFWL_Widget* GetInterface() const;
void SetInterface(IFWL_Widget* pInterface);
CFX_SizeF GetOffsetFromParent(IFWL_Widget* pParent);
@@ -157,7 +157,7 @@ class CFWL_WidgetImp {
FX_BOOL IsParent(IFWL_Widget* pParent);
CFWL_WidgetMgr* const m_pWidgetMgr;
- CFWL_AppImp* m_pOwnerApp;
+ IFWL_App* m_pOwnerApp;
std::unique_ptr<CFWL_WidgetImpProperties> m_pProperties;
IFWL_WidgetDelegate* m_pDelegate;
IFWL_WidgetDelegate* m_pCurDelegate;
diff --git a/xfa/fwl/core/ifwl_app.cpp b/xfa/fwl/core/ifwl_app.cpp
new file mode 100644
index 0000000000..a47a76e4c0
--- /dev/null
+++ b/xfa/fwl/core/ifwl_app.cpp
@@ -0,0 +1,50 @@
+// 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/ifwl_app.h"
+
+#include "third_party/base/ptr_util.h"
+#include "xfa/fwl/core/cfwl_widgetmgr.h"
+#include "xfa/fwl/core/fwl_noteimp.h"
+#include "xfa/fwl/core/ifwl_widget.h"
+#include "xfa/fxfa/app/xfa_fwladapter.h"
+
+CXFA_FWLAdapterWidgetMgr* FWL_GetAdapterWidgetMgr() {
+ return CFWL_WidgetMgr::GetInstance()->GetAdapterWidgetMgr();
+}
+
+CXFA_FFApp* FWL_GetAdapterNative() {
+ IFWL_App* pApp = FWL_GetApp();
+ if (!pApp)
+ return nullptr;
+ return pApp->GetAdapterNative();
+}
+
+static IFWL_App* g_theApp = nullptr;
+IFWL_App* FWL_GetApp() {
+ return g_theApp;
+}
+
+void FWL_SetApp(IFWL_App* pApp) {
+ g_theApp = pApp;
+}
+
+IFWL_App::IFWL_App(CXFA_FFApp* pAdapter)
+ : m_pAdapterNative(pAdapter),
+ m_pWidgetMgr(pdfium::MakeUnique<CFWL_WidgetMgr>(pAdapter)),
+ m_pNoteDriver(pdfium::MakeUnique<CFWL_NoteDriver>()) {}
+
+IFWL_App::~IFWL_App() {
+ CFWL_ToolTipContainer::DeleteInstance();
+}
+
+CXFA_FFApp* IFWL_App::GetAdapterNative() {
+ return m_pAdapterNative;
+}
+
+CFWL_WidgetMgr* IFWL_App::GetWidgetMgr() {
+ return m_pWidgetMgr.get();
+}
diff --git a/xfa/fwl/core/ifwl_app.h b/xfa/fwl/core/ifwl_app.h
index c030e26b2e..35cbbe2ff9 100644
--- a/xfa/fwl/core/ifwl_app.h
+++ b/xfa/fwl/core/ifwl_app.h
@@ -7,25 +7,14 @@
#ifndef XFA_FWL_CORE_IFWL_APP_H_
#define XFA_FWL_CORE_IFWL_APP_H_
-// The FWL 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/fx_string.h"
-#include "xfa/fwl/core/fwl_appimp.h"
-#include "xfa/fwl/core/fwl_error.h"
class CFWL_NoteDriver;
class CFWL_WidgetMgr;
class CXFA_FFApp;
class CXFA_FWLAdapterWidgetMgr;
-class IFWL_ThemeProvider;
class IFWL_Widget;
enum FWL_KeyFlag {
@@ -40,32 +29,17 @@ enum FWL_KeyFlag {
class IFWL_App {
public:
- static IFWL_App* Create(CXFA_FFApp* pAdapter);
-
- virtual ~IFWL_App();
+ explicit IFWL_App(CXFA_FFApp* pAdapter);
+ ~IFWL_App();
- FWL_Error Initialize();
- FWL_Error Finalize();
CXFA_FFApp* GetAdapterNative();
CFWL_WidgetMgr* GetWidgetMgr();
- IFWL_ThemeProvider* GetThemeProvider();
- void SetThemeProvider(IFWL_ThemeProvider* pThemeProvider);
- void 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;
+ CFWL_NoteDriver* GetNoteDriver() const { return m_pNoteDriver.get(); }
private:
- IFWL_App();
-
- std::unique_ptr<CFWL_AppImp> m_pImpl;
+ CXFA_FFApp* const m_pAdapterNative;
+ std::unique_ptr<CFWL_WidgetMgr> m_pWidgetMgr;
+ std::unique_ptr<CFWL_NoteDriver> m_pNoteDriver;
};
IFWL_App* FWL_GetApp();