summaryrefslogtreecommitdiff
path: root/xfa
diff options
context:
space:
mode:
authorTom Sepez <tsepez@chromium.org>2015-11-13 10:14:19 -0800
committerTom Sepez <tsepez@chromium.org>2015-11-13 10:14:19 -0800
commite8131137dabd2e1dcf1bcdf49e81ee6c9ae26413 (patch)
tree77079a63e876439823e1b688be09218a40df4427 /xfa
parent1f39a91b9a2f958fa2cd2e4314060b7dfe5d3bb3 (diff)
downloadpdfium-e8131137dabd2e1dcf1bcdf49e81ee6c9ae26413.tar.xz
Make CFWL_WidgetMgr{Delegate} inherit from IFWL_WidgetMgr{Delegate}.
C-style casting masked a fairly serious botch, where an CFWL_ type would get cast to an IFWL_ type, and later we'd invoke virtual methods against the IFWL_ type. Without the proper inheritance, there's no reason to believe that the vtables for each of these would line up with each other. Fixing the inheritence allows us to remove the c-style casts. I'm guessing these were added to make this compile without having to understand the true nature of the flaw. R=thestig@chromium.org Review URL: https://codereview.chromium.org/1439093003 .
Diffstat (limited to 'xfa')
-rw-r--r--xfa/src/fwl/src/core/fwl_appimp.cpp8
-rw-r--r--xfa/src/fwl/src/core/fwl_widgetmgrimp.cpp3
-rw-r--r--xfa/src/fwl/src/core/include/fwl_widgetmgrimp.h46
3 files changed, 30 insertions, 27 deletions
diff --git a/xfa/src/fwl/src/core/fwl_appimp.cpp b/xfa/src/fwl/src/core/fwl_appimp.cpp
index d9d37e2f9e..948001c21d 100644
--- a/xfa/src/fwl/src/core/fwl_appimp.cpp
+++ b/xfa/src/fwl/src/core/fwl_appimp.cpp
@@ -41,10 +41,8 @@ FWL_ERR CFWL_AppImp::Initialize() {
return FWL_ERR_Succeeded;
}
FWL_ERR CFWL_AppImp::Finalize() {
- if (m_pWidgetMgr) {
- delete m_pWidgetMgr;
- m_pWidgetMgr = NULL;
- }
+ delete m_pWidgetMgr;
+ m_pWidgetMgr = NULL;
return FWL_ERR_Succeeded;
}
IFWL_AdapterNative* CFWL_AppImp::GetAdapterNative() {
@@ -54,7 +52,7 @@ IFWL_AdapterWidgetMgr* FWL_GetAdapterWidgetMgr() {
return ((CFWL_WidgetMgr*)FWL_GetWidgetMgr())->GetAdapterWidgetMgr();
}
IFWL_WidgetMgr* CFWL_AppImp::GetWidgetMgr() {
- return (IFWL_WidgetMgr*)m_pWidgetMgr;
+ return m_pWidgetMgr;
}
FWL_ERR CFWL_AppImp::SetThemeProvider(IFWL_ThemeProvider* pThemeProvider) {
m_pThemeProvider = pThemeProvider;
diff --git a/xfa/src/fwl/src/core/fwl_widgetmgrimp.cpp b/xfa/src/fwl/src/core/fwl_widgetmgrimp.cpp
index 5671ff699a..00bebaed90 100644
--- a/xfa/src/fwl/src/core/fwl_widgetmgrimp.cpp
+++ b/xfa/src/fwl/src/core/fwl_widgetmgrimp.cpp
@@ -26,8 +26,7 @@ IFWL_WidgetMgr* FWL_GetWidgetMgr() {
CFWL_WidgetMgr::CFWL_WidgetMgr(IFWL_AdapterNative* pAdapterNative)
: m_dwCapability(0) {
m_pDelegate = new CFWL_WidgetMgrDelegate(this);
- m_pAdapter =
- pAdapterNative->GetWidgetMgr((IFWL_WidgetMgrDelegate*)m_pDelegate);
+ m_pAdapter = pAdapterNative->GetWidgetMgr(m_pDelegate);
FXSYS_assert(m_pAdapter);
CFWL_WidgetMgrItem* pRoot = new CFWL_WidgetMgrItem;
m_mapWidgetItem.SetAt(NULL, pRoot);
diff --git a/xfa/src/fwl/src/core/include/fwl_widgetmgrimp.h b/xfa/src/fwl/src/core/include/fwl_widgetmgrimp.h
index 5cd8510105..b5d59b9dd2 100644
--- a/xfa/src/fwl/src/core/include/fwl_widgetmgrimp.h
+++ b/xfa/src/fwl/src/core/include/fwl_widgetmgrimp.h
@@ -49,20 +49,23 @@ class CFWL_WidgetMgrItem {
#endif
};
-class CFWL_WidgetMgr {
+class CFWL_WidgetMgr : public IFWL_WidgetMgr {
public:
CFWL_WidgetMgr(IFWL_AdapterNative* pAdapterNative);
- virtual ~CFWL_WidgetMgr();
- virtual int32_t CountWidgets(IFWL_Widget* pParent = NULL);
- virtual IFWL_Widget* GetWidget(int32_t nIndex, IFWL_Widget* pParent = NULL);
- virtual IFWL_Widget* GetWidget(IFWL_Widget* pWidget,
- FWL_WGTRELATION eRelation);
- virtual int32_t GetWidgetIndex(IFWL_Widget* pWidget);
- virtual FX_BOOL SetWidgetIndex(IFWL_Widget* pWidget, int32_t nIndex);
- virtual FX_BOOL IsWidget(void* pObj);
- virtual FWL_ERR RepaintWidget(IFWL_Widget* pWidget,
- const CFX_RectF* pRect = NULL);
- virtual FX_DWORD GetCapability() { return m_dwCapability; }
+ ~CFWL_WidgetMgr() override;
+
+ // IFWL_WidgetMgr:
+ int32_t CountWidgets(IFWL_Widget* pParent = NULL) override;
+ IFWL_Widget* GetWidget(int32_t nIndex, IFWL_Widget* pParent = NULL) override;
+ IFWL_Widget* GetWidget(IFWL_Widget* pWidget,
+ FWL_WGTRELATION eRelation) override;
+ int32_t GetWidgetIndex(IFWL_Widget* pWidget) override;
+ FX_BOOL SetWidgetIndex(IFWL_Widget* pWidget, int32_t nIndex) override;
+ FX_BOOL IsWidget(void* pObj) override;
+ FWL_ERR RepaintWidget(IFWL_Widget* pWidget,
+ const CFX_RectF* pRect = NULL) override;
+ FX_DWORD GetCapability() override { return m_dwCapability; }
+
void AddWidget(IFWL_Widget* pWidget);
void InsertWidget(IFWL_Widget* pParent,
IFWL_Widget* pChild,
@@ -130,16 +133,19 @@ class CFWL_WidgetMgr {
CFX_RectF m_rtScreen;
#endif
};
-class CFWL_WidgetMgrDelegate {
+
+class CFWL_WidgetMgrDelegate : public IFWL_WidgetMgrDelegate {
public:
CFWL_WidgetMgrDelegate(CFWL_WidgetMgr* pWidgetMgr);
- virtual ~CFWL_WidgetMgrDelegate() {}
- virtual FWL_ERR OnSetCapability(
- FX_DWORD dwCapability = FWL_WGTMGR_DisableThread);
- virtual int32_t OnProcessMessageToForm(CFWL_Message* pMessage);
- virtual FWL_ERR OnDrawWidget(IFWL_Widget* pWidget,
- CFX_Graphics* pGraphics,
- const CFX_Matrix* pMatrix);
+ ~CFWL_WidgetMgrDelegate() override {}
+
+ // IFWL_WidgetMgrDelegate:
+ FWL_ERR OnSetCapability(
+ FX_DWORD dwCapability = FWL_WGTMGR_DisableThread) override;
+ int32_t OnProcessMessageToForm(CFWL_Message* pMessage) override;
+ FWL_ERR OnDrawWidget(IFWL_Widget* pWidget,
+ CFX_Graphics* pGraphics,
+ const CFX_Matrix* pMatrix) override;
protected:
void DrawChild(IFWL_Widget* pParent,