summaryrefslogtreecommitdiff
path: root/xfa/fxfa/include
diff options
context:
space:
mode:
authorweili <weili@chromium.org>2016-08-10 14:50:48 -0700
committerCommit bot <commit-bot@chromium.org>2016-08-10 14:50:48 -0700
commitb4d1b576bccb5ca6cebe29288af014bd0f512af1 (patch)
tree2d60839a8323eb6780c782aba4ae1123243c7355 /xfa/fxfa/include
parent1194561d5d83869edecf6a1f402122a59955f0b7 (diff)
downloadpdfium-b4d1b576bccb5ca6cebe29288af014bd0f512af1.tar.xz
Use smart pointers for class owned pointers in xfa/fxfa
Use smart pointers instead of raw pointer to make memory management easier for classes mainly under xfa/fxfa. Also change the return type of IFGAS_FontMgr::Create() to smart pointer type. BUG=pdfium:518 Review-Url: https://codereview.chromium.org/2227883002
Diffstat (limited to 'xfa/fxfa/include')
-rw-r--r--xfa/fxfa/include/xfa_ffapp.h34
-rw-r--r--xfa/fxfa/include/xfa_ffdocview.h32
2 files changed, 35 insertions, 31 deletions
diff --git a/xfa/fxfa/include/xfa_ffapp.h b/xfa/fxfa/include/xfa_ffapp.h
index 5780859a92..bc0d6dfb38 100644
--- a/xfa/fxfa/include/xfa_ffapp.h
+++ b/xfa/fxfa/include/xfa_ffapp.h
@@ -7,6 +7,8 @@
#ifndef XFA_FXFA_INCLUDE_XFA_FFAPP_H_
#define XFA_FXFA_INCLUDE_XFA_FFAPP_H_
+#include <memory>
+
#include "core/fpdfapi/fpdf_parser/include/cpdf_stream.h"
#include "core/fpdfapi/fpdf_parser/include/cpdf_stream_acc.h"
#include "xfa/fgas/font/fgas_font.h"
@@ -40,36 +42,38 @@ class CXFA_FFApp {
explicit CXFA_FFApp(IXFA_AppProvider* pProvider);
~CXFA_FFApp();
- CXFA_FFDocHandler* GetDocHandler();
CXFA_FFDoc* CreateDoc(IXFA_DocProvider* pProvider,
IFX_FileRead* pStream,
FX_BOOL bTakeOverFile);
CXFA_FFDoc* CreateDoc(IXFA_DocProvider* pProvider, CPDF_Document* pPDFDoc);
- IXFA_AppProvider* GetAppProvider() { return m_pProvider; }
void SetDefaultFontMgr(std::unique_ptr<CXFA_DefFontMgr> pFontMgr);
+ CXFA_FFDocHandler* GetDocHandler();
CXFA_FWLAdapterWidgetMgr* GetWidgetMgr(CFWL_WidgetMgrDelegate* pDelegate);
- IFWL_AdapterTimerMgr* GetTimerMgr();
-
- CXFA_FontMgr* GetXFAFontMgr();
IFGAS_FontMgr* GetFDEFontMgr();
CXFA_FWLTheme* GetFWLTheme();
- CFWL_WidgetMgrDelegate* GetWidgetMgrDelegate() {
+
+ IXFA_AppProvider* GetAppProvider() const { return m_pProvider; }
+ IFWL_AdapterTimerMgr* GetTimerMgr() const;
+ CXFA_FontMgr* GetXFAFontMgr() const;
+ CFWL_WidgetMgrDelegate* GetWidgetMgrDelegate() const {
return m_pWidgetMgrDelegate;
}
protected:
- CXFA_FFDocHandler* m_pDocHandler;
- IFWL_App* m_pFWLApp;
- CXFA_FWLTheme* m_pFWLTheme;
- IXFA_AppProvider* m_pProvider;
- CXFA_FontMgr* m_pFontMgr;
+ std::unique_ptr<CXFA_FFDocHandler> m_pDocHandler;
+ IXFA_AppProvider* const m_pProvider;
+ std::unique_ptr<CXFA_FontMgr> m_pFontMgr;
#if _FXM_PLATFORM_ != _FXM_PLATFORM_WINDOWS_
- CFX_FontSourceEnum_File* m_pFontSource;
+ std::unique_ptr<CFX_FontSourceEnum_File> m_pFontSource;
#endif
- CXFA_FWLAdapterWidgetMgr* m_pAdapterWidgetMgr;
- CFWL_WidgetMgrDelegate* m_pWidgetMgrDelegate;
- IFGAS_FontMgr* m_pFDEFontMgr;
+ std::unique_ptr<CXFA_FWLAdapterWidgetMgr> m_pAdapterWidgetMgr;
+ CFWL_WidgetMgrDelegate* m_pWidgetMgrDelegate; // not owned.
+ std::unique_ptr<IFGAS_FontMgr> m_pFDEFontMgr;
+ // |m_pFWLApp| has to be released first, then |m_pFWLTheme| since the former
+ // may refers to theme manager and the latter refers to font manager.
+ std::unique_ptr<CXFA_FWLTheme> m_pFWLTheme;
+ std::unique_ptr<IFWL_App> m_pFWLApp;
};
#endif // XFA_FXFA_INCLUDE_XFA_FFAPP_H_
diff --git a/xfa/fxfa/include/xfa_ffdocview.h b/xfa/fxfa/include/xfa_ffdocview.h
index bc2373d155..8372981cfd 100644
--- a/xfa/fxfa/include/xfa_ffdocview.h
+++ b/xfa/fxfa/include/xfa_ffdocview.h
@@ -42,16 +42,16 @@ class CXFA_FFDocView {
CXFA_FFDoc* GetDoc() { return m_pDoc; }
int32_t StartLayout(int32_t iStartPage = 0);
- int32_t DoLayout(IFX_Pause* pPause = nullptr);
+ int32_t DoLayout(IFX_Pause* pPause);
void StopLayout();
int32_t GetLayoutStatus();
void UpdateDocView();
int32_t CountPageViews();
CXFA_FFPageView* GetPageView(int32_t nIndex);
- void ResetWidgetData(CXFA_WidgetAcc* pWidgetAcc = nullptr);
+ void ResetWidgetData(CXFA_WidgetAcc* pWidgetAcc);
int32_t ProcessWidgetEvent(CXFA_EventParam* pParam,
- CXFA_WidgetAcc* pWidgetAcc = nullptr);
+ CXFA_WidgetAcc* pWidgetAcc);
CXFA_FFWidgetHandler* GetWidgetHandler();
CXFA_WidgetAccIterator* CreateWidgetAccIterator(
XFA_WIDGETORDER eOrder = XFA_WIDGETORDER_PreOrder);
@@ -59,9 +59,9 @@ class CXFA_FFDocView {
void KillFocus();
FX_BOOL SetFocus(CXFA_FFWidget* hWidget);
CXFA_FFWidget* GetWidgetByName(const CFX_WideString& wsName,
- CXFA_FFWidget* pRefWidget = nullptr);
+ CXFA_FFWidget* pRefWidget);
CXFA_WidgetAcc* GetWidgetAccByName(const CFX_WideString& wsName,
- CXFA_WidgetAcc* pRefWidgetAcc = nullptr);
+ CXFA_WidgetAcc* pRefWidgetAcc);
CXFA_LayoutProcessor* GetXFALayout() const;
void OnPageEvent(CXFA_ContainerLayoutItem* pSender, uint32_t dwEvent);
void LockUpdate();
@@ -94,9 +94,9 @@ class CXFA_FFDocView {
void DeleteLayoutItem(CXFA_FFWidget* pWidget);
int32_t ExecEventActivityByDeepFirst(CXFA_Node* pFormNode,
XFA_EVENTTYPE eEventType,
- FX_BOOL bIsFormReady = FALSE,
- FX_BOOL bRecursive = TRUE,
- CXFA_Node* pExclude = nullptr);
+ FX_BOOL bIsFormReady,
+ FX_BOOL bRecursive,
+ CXFA_Node* pExclude);
FX_BOOL m_bLayoutEvent;
CFX_WideStringArray m_arrNullTestMsg;
CXFA_FFWidget* m_pListFocusWidget;
@@ -112,12 +112,12 @@ class CXFA_FFDocView {
FX_BOOL ResetSingleWidgetAccData(CXFA_WidgetAcc* pWidgetAcc);
CXFA_Node* GetRootSubform();
- CXFA_FFDoc* m_pDoc;
- CXFA_FFWidgetHandler* m_pWidgetHandler;
- CXFA_LayoutProcessor* m_pXFADocLayout;
- CXFA_WidgetAcc* m_pFocusAcc;
- CXFA_FFWidget* m_pFocusWidget;
- CXFA_FFWidget* m_pOldFocusWidget;
+ CXFA_FFDoc* const m_pDoc;
+ std::unique_ptr<CXFA_FFWidgetHandler> m_pWidgetHandler;
+ CXFA_LayoutProcessor* m_pXFADocLayout; // not owned.
+ CXFA_WidgetAcc* m_pFocusAcc; // not owned.
+ CXFA_FFWidget* m_pFocusWidget; // not owned.
+ CXFA_FFWidget* m_pOldFocusWidget; // not owned.
std::map<CXFA_FFPageView*, std::unique_ptr<CFX_RectF>> m_mapPageInvalidate;
CFX_ArrayTemplate<CXFA_WidgetAcc*> m_ValidateAccs;
CFX_ArrayTemplate<CXFA_WidgetAcc*> m_CalculateAccs;
@@ -145,8 +145,8 @@ class CXFA_WidgetAccIterator {
protected:
CXFA_ContainerIterator m_ContentIterator;
- CXFA_FFDocView* m_pDocView;
- CXFA_WidgetAcc* m_pCurWidgetAcc;
+ CXFA_FFDocView* const m_pDocView;
+ CXFA_WidgetAcc* m_pCurWidgetAcc; // not owned.
};
#endif // XFA_FXFA_INCLUDE_XFA_FFDOCVIEW_H_