summaryrefslogtreecommitdiff
path: root/xfa/fwl
diff options
context:
space:
mode:
authorweili <weili@chromium.org>2016-08-04 16:37:48 -0700
committerCommit bot <commit-bot@chromium.org>2016-08-04 16:37:48 -0700
commit1b4f6b36b3ed8d1f6cea96bc32c1b376f4a499bc (patch)
treeaa3ba6730495096411f2a3555c74e83f5d1fca11 /xfa/fwl
parent52a5005c453a9e08384e375ae51c5f1ad628fe86 (diff)
downloadpdfium-1b4f6b36b3ed8d1f6cea96bc32c1b376f4a499bc.tar.xz
Use smart pointers for class owned pointers
For classes under xfa/fgas, xfa/fwl/basewidget, and xfa/fwl/core, use smart pointers instead of raw pointer to make memory management easier. BUG=pdfium:518 Review-Url: https://codereview.chromium.org/2207093005
Diffstat (limited to 'xfa/fwl')
-rw-r--r--xfa/fwl/basewidget/cfx_barcode.cpp71
-rw-r--r--xfa/fwl/basewidget/cfx_barcode.h4
-rw-r--r--xfa/fwl/basewidget/fwl_caretimp.cpp6
-rw-r--r--xfa/fwl/basewidget/fwl_caretimp.h6
-rw-r--r--xfa/fwl/basewidget/fwl_editimp.cpp13
-rw-r--r--xfa/fwl/basewidget/fwl_editimp.h2
-rw-r--r--xfa/fwl/basewidget/fwl_monthcalendarimp.cpp9
-rw-r--r--xfa/fwl/basewidget/fwl_monthcalendarimp.h4
-rw-r--r--xfa/fwl/basewidget/fwl_tooltipctrlimp.cpp8
-rw-r--r--xfa/fwl/basewidget/fwl_tooltipctrlimp.h1
-rw-r--r--xfa/fwl/core/fwl_formimp.cpp15
-rw-r--r--xfa/fwl/core/fwl_formimp.h4
-rw-r--r--xfa/fwl/core/fwl_noteimp.cpp21
-rw-r--r--xfa/fwl/core/fwl_noteimp.h5
-rw-r--r--xfa/fwl/core/fwl_widgetimp.cpp9
-rw-r--r--xfa/fwl/core/fwl_widgetimp.h6
16 files changed, 87 insertions, 97 deletions
diff --git a/xfa/fwl/basewidget/cfx_barcode.cpp b/xfa/fwl/basewidget/cfx_barcode.cpp
index 723619fc5f..cb554f5c5b 100644
--- a/xfa/fwl/basewidget/cfx_barcode.cpp
+++ b/xfa/fwl/basewidget/cfx_barcode.cpp
@@ -54,12 +54,10 @@ CBC_CodeBase* CreateBarCodeEngineObject(BC_TYPE type) {
CFX_Barcode::CFX_Barcode() {}
-CFX_Barcode::~CFX_Barcode() {
- delete m_pBCEngine;
-}
+CFX_Barcode::~CFX_Barcode() {}
FX_BOOL CFX_Barcode::Create(BC_TYPE type) {
- m_pBCEngine = CreateBarCodeEngineObject(type);
+ m_pBCEngine.reset(CreateBarCodeEngineObject(type));
return !!m_pBCEngine;
}
BC_TYPE CFX_Barcode::GetType() {
@@ -91,7 +89,7 @@ FX_BOOL CFX_Barcode::CheckContentValidity(const CFX_WideStringC& contents) {
case BC_EAN13:
case BC_UPCA:
return m_pBCEngine
- ? static_cast<CBC_OneCode*>(m_pBCEngine)
+ ? static_cast<CBC_OneCode*>(m_pBCEngine.get())
->CheckContentValidity(contents)
: TRUE;
default:
@@ -108,7 +106,7 @@ FX_BOOL CFX_Barcode::SetPrintChecksum(FX_BOOL checksum) {
case BC_EAN8:
case BC_EAN13:
case BC_UPCA:
- return m_pBCEngine ? (static_cast<CBC_OneCode*>(m_pBCEngine)
+ return m_pBCEngine ? (static_cast<CBC_OneCode*>(m_pBCEngine.get())
->SetPrintChecksum(checksum),
TRUE)
: FALSE;
@@ -126,7 +124,7 @@ FX_BOOL CFX_Barcode::SetDataLength(int32_t length) {
case BC_EAN8:
case BC_EAN13:
case BC_UPCA:
- return m_pBCEngine ? (static_cast<CBC_OneCode*>(m_pBCEngine)
+ return m_pBCEngine ? (static_cast<CBC_OneCode*>(m_pBCEngine.get())
->SetDataLength(length),
TRUE)
: FALSE;
@@ -144,7 +142,7 @@ FX_BOOL CFX_Barcode::SetCalChecksum(int32_t state) {
case BC_EAN8:
case BC_EAN13:
case BC_UPCA:
- return m_pBCEngine ? (static_cast<CBC_OneCode*>(m_pBCEngine)
+ return m_pBCEngine ? (static_cast<CBC_OneCode*>(m_pBCEngine.get())
->SetCalChecksum(state),
TRUE)
: FALSE;
@@ -163,7 +161,7 @@ FX_BOOL CFX_Barcode::SetFont(CFX_Font* pFont) {
case BC_EAN13:
case BC_UPCA:
return m_pBCEngine
- ? static_cast<CBC_OneCode*>(m_pBCEngine)->SetFont(pFont)
+ ? static_cast<CBC_OneCode*>(m_pBCEngine.get())->SetFont(pFont)
: FALSE;
default:
return FALSE;
@@ -179,10 +177,10 @@ FX_BOOL CFX_Barcode::SetFontSize(FX_FLOAT size) {
case BC_EAN8:
case BC_EAN13:
case BC_UPCA:
- return m_pBCEngine
- ? (static_cast<CBC_OneCode*>(m_pBCEngine)->SetFontSize(size),
- TRUE)
- : FALSE;
+ return m_pBCEngine ? (static_cast<CBC_OneCode*>(m_pBCEngine.get())
+ ->SetFontSize(size),
+ TRUE)
+ : FALSE;
default:
return FALSE;
}
@@ -197,10 +195,10 @@ FX_BOOL CFX_Barcode::SetFontStyle(int32_t style) {
case BC_EAN8:
case BC_EAN13:
case BC_UPCA:
- return m_pBCEngine
- ? (static_cast<CBC_OneCode*>(m_pBCEngine)->SetFontStyle(style),
- TRUE)
- : FALSE;
+ return m_pBCEngine ? (static_cast<CBC_OneCode*>(m_pBCEngine.get())
+ ->SetFontStyle(style),
+ TRUE)
+ : FALSE;
default:
return FALSE;
}
@@ -215,10 +213,10 @@ FX_BOOL CFX_Barcode::SetFontColor(FX_ARGB color) {
case BC_EAN8:
case BC_EAN13:
case BC_UPCA:
- return m_pBCEngine
- ? (static_cast<CBC_OneCode*>(m_pBCEngine)->SetFontColor(color),
- TRUE)
- : FALSE;
+ return m_pBCEngine ? (static_cast<CBC_OneCode*>(m_pBCEngine.get())
+ ->SetFontColor(color),
+ TRUE)
+ : FALSE;
default:
return FALSE;
}
@@ -241,7 +239,7 @@ FX_BOOL CFX_Barcode::SetTextLocation(BC_TEXT_LOC location) {
default:
break;
}
- return m_pBCEngine && memptr ? (m_pBCEngine->*memptr)(location) : FALSE;
+ return m_pBCEngine && memptr ? (m_pBCEngine.get()->*memptr)(location) : FALSE;
}
FX_BOOL CFX_Barcode::SetWideNarrowRatio(int32_t ratio) {
typedef FX_BOOL (CBC_CodeBase::*memptrtype)(int32_t);
@@ -256,7 +254,7 @@ FX_BOOL CFX_Barcode::SetWideNarrowRatio(int32_t ratio) {
default:
break;
}
- return m_pBCEngine && memptr ? (m_pBCEngine->*memptr)(ratio) : FALSE;
+ return m_pBCEngine && memptr ? (m_pBCEngine.get()->*memptr)(ratio) : FALSE;
}
FX_BOOL CFX_Barcode::SetStartChar(FX_CHAR start) {
typedef FX_BOOL (CBC_CodeBase::*memptrtype)(FX_CHAR);
@@ -268,7 +266,7 @@ FX_BOOL CFX_Barcode::SetStartChar(FX_CHAR start) {
default:
break;
}
- return m_pBCEngine && memptr ? (m_pBCEngine->*memptr)(start) : FALSE;
+ return m_pBCEngine && memptr ? (m_pBCEngine.get()->*memptr)(start) : FALSE;
}
FX_BOOL CFX_Barcode::SetEndChar(FX_CHAR end) {
typedef FX_BOOL (CBC_CodeBase::*memptrtype)(FX_CHAR);
@@ -280,7 +278,7 @@ FX_BOOL CFX_Barcode::SetEndChar(FX_CHAR end) {
default:
break;
}
- return m_pBCEngine && memptr ? (m_pBCEngine->*memptr)(end) : FALSE;
+ return m_pBCEngine && memptr ? (m_pBCEngine.get()->*memptr)(end) : FALSE;
}
FX_BOOL CFX_Barcode::SetVersion(int32_t version) {
typedef FX_BOOL (CBC_CodeBase::*memptrtype)(int32_t);
@@ -292,7 +290,7 @@ FX_BOOL CFX_Barcode::SetVersion(int32_t version) {
default:
break;
}
- return m_pBCEngine && memptr ? (m_pBCEngine->*memptr)(version) : FALSE;
+ return m_pBCEngine && memptr ? (m_pBCEngine.get()->*memptr)(version) : FALSE;
}
FX_BOOL CFX_Barcode::SetErrorCorrectionLevel(int32_t level) {
typedef FX_BOOL (CBC_CodeBase::*memptrtype)(int32_t);
@@ -307,7 +305,7 @@ FX_BOOL CFX_Barcode::SetErrorCorrectionLevel(int32_t level) {
default:
return FALSE;
}
- return m_pBCEngine && memptr ? (m_pBCEngine->*memptr)(level) : FALSE;
+ return m_pBCEngine && memptr ? (m_pBCEngine.get()->*memptr)(level) : FALSE;
}
FX_BOOL CFX_Barcode::SetTruncated(FX_BOOL truncated) {
typedef void (CBC_CodeBase::*memptrtype)(FX_BOOL);
@@ -319,29 +317,22 @@ FX_BOOL CFX_Barcode::SetTruncated(FX_BOOL truncated) {
default:
break;
}
- return m_pBCEngine && memptr ? ((m_pBCEngine->*memptr)(truncated), TRUE)
+ return m_pBCEngine && memptr ? ((m_pBCEngine.get()->*memptr)(truncated), TRUE)
: FALSE;
}
FX_BOOL CFX_Barcode::Encode(const CFX_WideStringC& contents,
FX_BOOL isDevice,
int32_t& e) {
- if (!m_pBCEngine) {
- return FALSE;
- }
- return m_pBCEngine->Encode(contents, isDevice, e);
+ return m_pBCEngine && m_pBCEngine->Encode(contents, isDevice, e);
}
+
FX_BOOL CFX_Barcode::RenderDevice(CFX_RenderDevice* device,
const CFX_Matrix* matrix,
int32_t& e) {
- if (!m_pBCEngine) {
- return FALSE;
- }
- return m_pBCEngine->RenderDevice(device, matrix, e);
+ return m_pBCEngine && m_pBCEngine->RenderDevice(device, matrix, e);
}
+
FX_BOOL CFX_Barcode::RenderBitmap(CFX_DIBitmap*& pOutBitmap, int32_t& e) {
- if (!m_pBCEngine) {
- return FALSE;
- }
- return m_pBCEngine->RenderBitmap(pOutBitmap, e);
+ return m_pBCEngine && m_pBCEngine->RenderBitmap(pOutBitmap, e);
}
diff --git a/xfa/fwl/basewidget/cfx_barcode.h b/xfa/fwl/basewidget/cfx_barcode.h
index 2ba1f7f77d..758ba20b1a 100644
--- a/xfa/fwl/basewidget/cfx_barcode.h
+++ b/xfa/fwl/basewidget/cfx_barcode.h
@@ -7,6 +7,8 @@
#ifndef XFA_FWL_BASEWIDGET_CFX_BARCODE_H_
#define XFA_FWL_BASEWIDGET_CFX_BARCODE_H_
+#include <memory>
+
#include "core/fxcrt/include/fx_coordinates.h"
#include "core/fxcrt/include/fx_string.h"
#include "core/fxcrt/include/fx_system.h"
@@ -52,7 +54,7 @@ class CFX_Barcode {
FX_BOOL SetTruncated(FX_BOOL truncated);
protected:
- CBC_CodeBase* m_pBCEngine;
+ std::unique_ptr<CBC_CodeBase> m_pBCEngine;
};
#endif // XFA_FWL_BASEWIDGET_CFX_BARCODE_H_
diff --git a/xfa/fwl/basewidget/fwl_caretimp.cpp b/xfa/fwl/basewidget/fwl_caretimp.cpp
index dbe8e50bc2..cd51bd7430 100644
--- a/xfa/fwl/basewidget/fwl_caretimp.cpp
+++ b/xfa/fwl/basewidget/fwl_caretimp.cpp
@@ -38,16 +38,14 @@ FWL_Error IFWL_Caret::SetColor(CFX_Color crFill) {
CFWL_CaretImp::CFWL_CaretImp(const CFWL_WidgetImpProperties& properties,
IFWL_Widget* pOuter)
: CFWL_WidgetImp(properties, pOuter),
+ m_pTimer(new CFWL_CaretTimer(this)),
m_pTimerInfo(nullptr),
m_dwElapse(400),
m_bSetColor(FALSE) {
- m_pTimer = new CFWL_CaretTimer(this);
SetStates(FWL_STATE_CAT_HightLight);
}
-CFWL_CaretImp::~CFWL_CaretImp() {
- delete m_pTimer;
-}
+CFWL_CaretImp::~CFWL_CaretImp() {}
FWL_Error CFWL_CaretImp::GetClassName(CFX_WideString& wsClass) const {
wsClass = FWL_CLASS_Caret;
diff --git a/xfa/fwl/basewidget/fwl_caretimp.h b/xfa/fwl/basewidget/fwl_caretimp.h
index 4f16715cd1..d8b621b43c 100644
--- a/xfa/fwl/basewidget/fwl_caretimp.h
+++ b/xfa/fwl/basewidget/fwl_caretimp.h
@@ -7,6 +7,8 @@
#ifndef XFA_FWL_BASEWIDGET_FWL_CARETIMP_H_
#define XFA_FWL_BASEWIDGET_FWL_CARETIMP_H_
+#include <memory>
+
#include "xfa/fwl/core/fwl_widgetimp.h"
#include "xfa/fwl/core/ifwl_timer.h"
#include "xfa/fwl/core/ifwl_widget.h"
@@ -51,8 +53,8 @@ class CFWL_CaretImp : public CFWL_WidgetImp {
IFWL_ThemeProvider* pTheme,
const CFX_Matrix* pMatrix);
- CFWL_CaretTimer* m_pTimer;
- IFWL_TimerInfo* m_pTimerInfo;
+ std::unique_ptr<CFWL_CaretTimer> m_pTimer;
+ IFWL_TimerInfo* m_pTimerInfo; // not owned.
uint32_t m_dwElapse;
CFX_Color m_crFill;
FX_BOOL m_bSetColor;
diff --git a/xfa/fwl/basewidget/fwl_editimp.cpp b/xfa/fwl/basewidget/fwl_editimp.cpp
index ae0b7bcc9f..104054f4e1 100644
--- a/xfa/fwl/basewidget/fwl_editimp.cpp
+++ b/xfa/fwl/basewidget/fwl_editimp.cpp
@@ -203,7 +203,6 @@ CFWL_EditImp::CFWL_EditImp(const CFWL_WidgetImpProperties& properties,
m_fVAlignOffset(0.0f),
m_fScrollOffsetX(0.0f),
m_fScrollOffsetY(0.0f),
- m_pEdtEngine(nullptr),
m_bLButtonDown(FALSE),
m_nSelStart(0),
m_nLimit(-1),
@@ -223,7 +222,6 @@ CFWL_EditImp::CFWL_EditImp(const CFWL_WidgetImpProperties& properties,
}
CFWL_EditImp::~CFWL_EditImp() {
- delete m_pEdtEngine;
ClearRecord();
}
@@ -898,26 +896,27 @@ void CFWL_EditImp::On_TextChanged(CFDE_TxtEdtEngine* pEdit,
LayoutScrollBar();
Repaint(&rtTemp);
}
+
void CFWL_EditImp::On_SelChanged(CFDE_TxtEdtEngine* pEdit) {
CFX_RectF rtTemp;
GetClientRect(rtTemp);
Repaint(&rtTemp);
}
+
FX_BOOL CFWL_EditImp::On_PageLoad(CFDE_TxtEdtEngine* pEdit,
int32_t nPageIndex,
int32_t nPurpose) {
- CFDE_TxtEdtEngine* pEdtEngine = m_pEdtEngine;
- IFDE_TxtEdtPage* pPage = pEdtEngine->GetPage(nPageIndex);
+ IFDE_TxtEdtPage* pPage = m_pEdtEngine->GetPage(nPageIndex);
if (!pPage)
return FALSE;
pPage->LoadPage(nullptr, nullptr);
return TRUE;
}
+
FX_BOOL CFWL_EditImp::On_PageUnload(CFDE_TxtEdtEngine* pEdit,
int32_t nPageIndex,
int32_t nPurpose) {
- CFDE_TxtEdtEngine* pEdtEngine = m_pEdtEngine;
- IFDE_TxtEdtPage* pPage = pEdtEngine->GetPage(nPageIndex);
+ IFDE_TxtEdtPage* pPage = m_pEdtEngine->GetPage(nPageIndex);
if (!pPage)
return FALSE;
pPage->UnloadPage(nullptr);
@@ -1630,7 +1629,7 @@ void CFWL_EditImp::InitScrollBar(FX_BOOL bVert) {
void CFWL_EditImp::InitEngine() {
if (!m_pEdtEngine)
- m_pEdtEngine = new CFDE_TxtEdtEngine;
+ m_pEdtEngine.reset(new CFDE_TxtEdtEngine);
}
FX_BOOL FWL_ShowCaret(IFWL_Widget* pWidget,
diff --git a/xfa/fwl/basewidget/fwl_editimp.h b/xfa/fwl/basewidget/fwl_editimp.h
index 3f7a3862dd..e17a4cfc09 100644
--- a/xfa/fwl/basewidget/fwl_editimp.h
+++ b/xfa/fwl/basewidget/fwl_editimp.h
@@ -152,7 +152,7 @@ class CFWL_EditImp : public CFWL_WidgetImp {
FX_FLOAT m_fVAlignOffset;
FX_FLOAT m_fScrollOffsetX;
FX_FLOAT m_fScrollOffsetY;
- CFDE_TxtEdtEngine* m_pEdtEngine;
+ std::unique_ptr<CFDE_TxtEdtEngine> m_pEdtEngine;
FX_BOOL m_bLButtonDown;
int32_t m_nSelStart;
int32_t m_nLimit;
diff --git a/xfa/fwl/basewidget/fwl_monthcalendarimp.cpp b/xfa/fwl/basewidget/fwl_monthcalendarimp.cpp
index ca141a2d7a..7477f04bdc 100644
--- a/xfa/fwl/basewidget/fwl_monthcalendarimp.cpp
+++ b/xfa/fwl/basewidget/fwl_monthcalendarimp.cpp
@@ -151,6 +151,8 @@ CFWL_MonthCalendarImp::CFWL_MonthCalendarImp(
const CFWL_WidgetImpProperties& properties,
IFWL_Widget* pOuter)
: CFWL_WidgetImp(properties, pOuter),
+ m_bInit(FALSE),
+ m_pDateTime(new CFX_DateTime),
m_iCurYear(2011),
m_iCurMonth(1),
m_iYear(2011),
@@ -158,7 +160,8 @@ CFWL_MonthCalendarImp::CFWL_MonthCalendarImp(
m_iDay(1),
m_iHovered(-1),
m_iLBtnPartStates(CFWL_PartState_Normal),
- m_iRBtnPartStates(CFWL_PartState_Normal) {
+ m_iRBtnPartStates(CFWL_PartState_Normal),
+ m_iMaxSel(1) {
m_rtHead.Reset();
m_rtWeek.Reset();
m_rtLBtn.Reset();
@@ -171,14 +174,10 @@ CFWL_MonthCalendarImp::CFWL_MonthCalendarImp(
m_rtClient.Reset();
m_rtWeekNum.Reset();
m_rtWeekNumSep.Reset();
- m_pDateTime = new CFX_DateTime;
- m_bInit = FALSE;
- m_iMaxSel = 1;
}
CFWL_MonthCalendarImp::~CFWL_MonthCalendarImp() {
ClearDateItem();
- delete m_pDateTime;
m_arrSelDays.RemoveAll();
}
diff --git a/xfa/fwl/basewidget/fwl_monthcalendarimp.h b/xfa/fwl/basewidget/fwl_monthcalendarimp.h
index db6ce7801c..2716f59f95 100644
--- a/xfa/fwl/basewidget/fwl_monthcalendarimp.h
+++ b/xfa/fwl/basewidget/fwl_monthcalendarimp.h
@@ -7,6 +7,8 @@
#ifndef XFA_FWL_BASEWIDGET_FWL_MONTHCALENDARIMP_H_
#define XFA_FWL_BASEWIDGET_FWL_MONTHCALENDARIMP_H_
+#include <memory>
+
#include "xfa/fgas/localization/fgas_datetime.h"
#include "xfa/fwl/core/fwl_widgetimp.h"
#include "xfa/fwl/core/ifwl_widget.h"
@@ -164,7 +166,7 @@ class CFWL_MonthCalendarImp : public CFWL_WidgetImp {
CFX_RectF m_rtTemp;
CFX_WideString m_wsHead;
CFX_WideString m_wsToday;
- CFX_DateTime* m_pDateTime;
+ std::unique_ptr<CFX_DateTime> m_pDateTime;
CFX_ArrayTemplate<FWL_DATEINFO*> m_arrDates;
int32_t m_iCurYear;
int32_t m_iCurMonth;
diff --git a/xfa/fwl/basewidget/fwl_tooltipctrlimp.cpp b/xfa/fwl/basewidget/fwl_tooltipctrlimp.cpp
index 85af738555..cf89483a9d 100644
--- a/xfa/fwl/basewidget/fwl_tooltipctrlimp.cpp
+++ b/xfa/fwl/basewidget/fwl_tooltipctrlimp.cpp
@@ -48,8 +48,7 @@ CFWL_ToolTipImp::CFWL_ToolTipImp(const CFWL_WidgetImpProperties& properties,
m_dwTTOStyles(FDE_TTOSTYLE_SingleLine),
m_iTTOAlign(FDE_TTOALIGNMENT_Center),
m_pTimerInfoShow(nullptr),
- m_pTimerInfoHide(nullptr),
- m_pTimer(nullptr) {
+ m_pTimerInfoHide(nullptr) {
m_rtClient.Set(0, 0, 0, 0);
m_rtCaption.Set(0, 0, 0, 0);
m_rtAnchor.Set(0, 0, 0, 0);
@@ -57,10 +56,7 @@ CFWL_ToolTipImp::CFWL_ToolTipImp(const CFWL_WidgetImpProperties& properties,
m_TimerHide.m_pToolTip = this;
}
-CFWL_ToolTipImp::~CFWL_ToolTipImp() {
- delete m_pTimer;
- m_pTimer = nullptr;
-}
+CFWL_ToolTipImp::~CFWL_ToolTipImp() {}
FWL_Error CFWL_ToolTipImp::GetClassName(CFX_WideString& wsClass) const {
wsClass = FWL_CLASS_ToolTip;
diff --git a/xfa/fwl/basewidget/fwl_tooltipctrlimp.h b/xfa/fwl/basewidget/fwl_tooltipctrlimp.h
index 79e3f49f18..f814eea256 100644
--- a/xfa/fwl/basewidget/fwl_tooltipctrlimp.h
+++ b/xfa/fwl/basewidget/fwl_tooltipctrlimp.h
@@ -69,7 +69,6 @@ class CFWL_ToolTipImp : public CFWL_FormImp {
CFX_RectF m_rtAnchor;
IFWL_TimerInfo* m_pTimerInfoShow;
IFWL_TimerInfo* m_pTimerInfoHide;
- CFWL_ToolTipTimer* m_pTimer;
CFWL_ToolTipTimer m_TimerShow;
CFWL_ToolTipTimer m_TimerHide;
};
diff --git a/xfa/fwl/core/fwl_formimp.cpp b/xfa/fwl/core/fwl_formimp.cpp
index a3fc6be816..1b82ff59f8 100644
--- a/xfa/fwl/core/fwl_formimp.cpp
+++ b/xfa/fwl/core/fwl_formimp.cpp
@@ -75,7 +75,6 @@ CFWL_FormImp::CFWL_FormImp(const CFWL_WidgetImpProperties& properties,
m_pMinBox(nullptr),
m_pMaxBox(nullptr),
m_pCaptionBox(nullptr),
- m_pNoteLoop(nullptr),
m_pSubFocus(nullptr),
m_fCXBorder(0),
m_fCYBorder(0),
@@ -100,7 +99,6 @@ CFWL_FormImp::CFWL_FormImp(const CFWL_WidgetImpProperties& properties,
CFWL_FormImp::~CFWL_FormImp() {
RemoveSysButtons();
- delete m_pNoteLoop;
}
FWL_Error CFWL_FormImp::GetClassName(CFX_WideString& wsClass) const {
@@ -371,13 +369,16 @@ FWL_Error CFWL_FormImp::DrawWidget(CFX_Graphics* pGraphics,
#endif
return FWL_Error::Succeeded;
}
+
FWL_FORMSIZE CFWL_FormImp::GetFormSize() {
return m_eFormSize;
}
+
FWL_Error CFWL_FormImp::SetFormSize(FWL_FORMSIZE eFormSize) {
m_eFormSize = eFormSize;
return FWL_Error::Succeeded;
}
+
IFWL_Widget* CFWL_FormImp::DoModal() {
IFWL_App* pApp = GetOwnerApp();
if (!pApp)
@@ -387,8 +388,8 @@ IFWL_Widget* CFWL_FormImp::DoModal() {
if (!pDriver)
return nullptr;
- m_pNoteLoop = new CFWL_NoteLoop(this);
- pDriver->PushNoteLoop(m_pNoteLoop);
+ m_pNoteLoop.reset(new CFWL_NoteLoop(this));
+ pDriver->PushNoteLoop(m_pNoteLoop.get());
m_bDoModalFlag = TRUE;
SetStates(FWL_WGTSTATE_Invisible, FALSE);
pDriver->Run();
@@ -396,13 +397,14 @@ IFWL_Widget* CFWL_FormImp::DoModal() {
#else
pDriver->PopNoteLoop();
#endif
- delete m_pNoteLoop;
- m_pNoteLoop = nullptr;
+ m_pNoteLoop.reset();
return nullptr;
}
+
IFWL_Widget* CFWL_FormImp::DoModal(uint32_t& dwCommandID) {
return DoModal();
}
+
FWL_Error CFWL_FormImp::EndDoModal() {
if (!m_pNoteLoop)
return FWL_Error::Indefinite;
@@ -426,6 +428,7 @@ FWL_Error CFWL_FormImp::EndDoModal() {
return m_pNoteLoop->EndModalLoop();
#endif
}
+
FWL_Error CFWL_FormImp::SetBorderRegion(CFX_Path* pPath) {
return FWL_Error::Succeeded;
}
diff --git a/xfa/fwl/core/fwl_formimp.h b/xfa/fwl/core/fwl_formimp.h
index ee1507d17e..c88b5e683b 100644
--- a/xfa/fwl/core/fwl_formimp.h
+++ b/xfa/fwl/core/fwl_formimp.h
@@ -7,6 +7,8 @@
#ifndef XFA_FWL_CORE_FWL_FORMIMP_H_
#define XFA_FWL_CORE_FWL_FORMIMP_H_
+#include <memory>
+
#include "xfa/fwl/core/fwl_widgetimp.h"
#include "xfa/fwl/core/ifwl_form.h"
@@ -134,7 +136,7 @@ class CFWL_FormImp : public CFWL_WidgetImp {
CFWL_SysBtn* m_pMinBox;
CFWL_SysBtn* m_pMaxBox;
CFWL_SysBtn* m_pCaptionBox;
- CFWL_NoteLoop* m_pNoteLoop;
+ std::unique_ptr<CFWL_NoteLoop> m_pNoteLoop;
CFWL_WidgetImp* m_pSubFocus;
RestoreInfo m_InfoStart;
FX_FLOAT m_fCXBorder;
diff --git a/xfa/fwl/core/fwl_noteimp.cpp b/xfa/fwl/core/fwl_noteimp.cpp
index f115e2fd1b..8ecec2df65 100644
--- a/xfa/fwl/core/fwl_noteimp.cpp
+++ b/xfa/fwl/core/fwl_noteimp.cpp
@@ -70,10 +70,9 @@ CFWL_NoteDriver::CFWL_NoteDriver()
m_pFocus(nullptr),
m_pGrab(nullptr),
m_pNoteLoop(new CFWL_NoteLoop) {
- PushNoteLoop(m_pNoteLoop);
+ PushNoteLoop(m_pNoteLoop.get());
}
CFWL_NoteDriver::~CFWL_NoteDriver() {
- delete m_pNoteLoop;
ClearInvalidEventTargets(TRUE);
}
@@ -655,6 +654,8 @@ void CFWL_NoteDriver::ClearInvalidEventTargets(FX_BOOL bRemoveAll) {
class CFWL_CoreToolTipDP : public IFWL_ToolTipDP {
public:
+ CFWL_CoreToolTipDP(int32_t iInitDelayTime, int32_t iAutoDelayTime);
+
// IFWL_ToolTipDP
FWL_Error GetCaption(IFWL_Widget* pWidget,
CFX_WideString& wsCaption) override;
@@ -664,7 +665,6 @@ class CFWL_CoreToolTipDP : public IFWL_ToolTipDP {
CFX_SizeF GetToolTipIconSize(IFWL_Widget* pWidget) override;
CFX_RectF GetAnchor();
- CFWL_CoreToolTipDP();
CFX_WideString m_wsCaption;
int32_t m_nInitDelayTime;
@@ -672,9 +672,9 @@ class CFWL_CoreToolTipDP : public IFWL_ToolTipDP {
CFX_RectF m_fAnchor;
};
-CFWL_CoreToolTipDP::CFWL_CoreToolTipDP() {
- m_nInitDelayTime = 500;
- m_nAutoPopDelayTime = 50000;
+CFWL_CoreToolTipDP::CFWL_CoreToolTipDP(int32_t iInitDelayTime,
+ int32_t iAutoDelayTime)
+ : m_nInitDelayTime(iInitDelayTime), m_nAutoPopDelayTime(iAutoDelayTime) {
m_fAnchor.Set(0.0, 0.0, 0.0, 0.0);
}
@@ -773,11 +773,9 @@ FX_BOOL CFWL_EventTarget::IsFilterEvent(CFWL_Event* pEvent, uint32_t dwFilter) {
CFWL_ToolTipContainer* CFWL_ToolTipContainer::s_pInstance = nullptr;
-CFWL_ToolTipContainer::CFWL_ToolTipContainer() : m_pToolTipImp(nullptr) {
- m_ToolTipDp = new CFWL_CoreToolTipDP;
- m_ToolTipDp->m_nInitDelayTime = 0;
- m_ToolTipDp->m_nAutoPopDelayTime = 2000;
-}
+CFWL_ToolTipContainer::CFWL_ToolTipContainer()
+ : m_pToolTipImp(nullptr), m_pToolTipDp(new CFWL_CoreToolTipDP(0, 2000)) {}
+
CFWL_ToolTipContainer::~CFWL_ToolTipContainer() {
if (m_pToolTipImp) {
IFWL_ToolTip* pToolTip =
@@ -785,7 +783,6 @@ CFWL_ToolTipContainer::~CFWL_ToolTipContainer() {
pToolTip->Finalize();
delete pToolTip;
}
- delete m_ToolTipDp;
}
// static
diff --git a/xfa/fwl/core/fwl_noteimp.h b/xfa/fwl/core/fwl_noteimp.h
index c92395a13a..f923c395d5 100644
--- a/xfa/fwl/core/fwl_noteimp.h
+++ b/xfa/fwl/core/fwl_noteimp.h
@@ -7,6 +7,7 @@
#ifndef XFA_FWL_CORE_FWL_NOTEIMP_H_
#define XFA_FWL_CORE_FWL_NOTEIMP_H_
+#include <memory>
#include <unordered_map>
#include "xfa/fwl/core/cfwl_event.h"
@@ -115,7 +116,7 @@ class CFWL_NoteDriver {
IFWL_Widget* m_pHover;
IFWL_Widget* m_pFocus;
IFWL_Widget* m_pGrab;
- CFWL_NoteLoop* m_pNoteLoop;
+ std::unique_ptr<CFWL_NoteLoop> m_pNoteLoop;
};
class CFWL_EventTarget {
@@ -147,7 +148,7 @@ class CFWL_ToolTipContainer final {
~CFWL_ToolTipContainer();
CFWL_ToolTipImp* m_pToolTipImp;
- CFWL_CoreToolTipDP* m_ToolTipDp;
+ std::unique_ptr<CFWL_CoreToolTipDP> m_pToolTipDp;
private:
static CFWL_ToolTipContainer* s_pInstance;
diff --git a/xfa/fwl/core/fwl_widgetimp.cpp b/xfa/fwl/core/fwl_widgetimp.cpp
index 52a2978908..3aa6233ae5 100644
--- a/xfa/fwl/core/fwl_widgetimp.cpp
+++ b/xfa/fwl/core/fwl_widgetimp.cpp
@@ -531,7 +531,8 @@ void CFWL_WidgetImp::SetAssociateWidget(void* pAssociate) {
CFWL_WidgetImp::CFWL_WidgetImp(const CFWL_WidgetImpProperties& properties,
IFWL_Widget* pOuter)
- : m_pProperties(new CFWL_WidgetImpProperties),
+ : m_pWidgetMgr(CFWL_WidgetMgr::GetInstance()),
+ m_pProperties(new CFWL_WidgetImpProperties(properties)),
m_pDelegate(nullptr),
m_pCurDelegate(nullptr),
m_pOuter(pOuter),
@@ -540,14 +541,10 @@ CFWL_WidgetImp::CFWL_WidgetImp(const CFWL_WidgetImpProperties& properties,
m_pAssociate(nullptr),
m_iLock(0),
m_nEventKey(0) {
- *m_pProperties = properties;
- m_pWidgetMgr = CFWL_WidgetMgr::GetInstance();
ASSERT(m_pWidgetMgr);
}
-CFWL_WidgetImp::~CFWL_WidgetImp() {
- delete m_pProperties;
-}
+CFWL_WidgetImp::~CFWL_WidgetImp() {}
FX_BOOL CFWL_WidgetImp::IsEnabled() const {
return (m_pProperties->m_dwStates & FWL_WGTSTATE_Disabled) == 0;
diff --git a/xfa/fwl/core/fwl_widgetimp.h b/xfa/fwl/core/fwl_widgetimp.h
index d8c4fe6eb6..cbc89b9a8b 100644
--- a/xfa/fwl/core/fwl_widgetimp.h
+++ b/xfa/fwl/core/fwl_widgetimp.h
@@ -7,6 +7,8 @@
#ifndef XFA_FWL_CORE_FWL_WIDGETIMP_H_
#define XFA_FWL_CORE_FWL_WIDGETIMP_H_
+#include <memory>
+
#include "core/fxcrt/include/fx_coordinates.h"
#include "core/fxcrt/include/fx_system.h"
#include "xfa/fwl/core/cfwl_event.h"
@@ -154,9 +156,9 @@ class CFWL_WidgetImp {
FX_BOOL IsParent(IFWL_Widget* pParent);
- CFWL_WidgetMgr* m_pWidgetMgr;
+ CFWL_WidgetMgr* const m_pWidgetMgr;
CFWL_AppImp* m_pOwnerApp;
- CFWL_WidgetImpProperties* m_pProperties;
+ std::unique_ptr<CFWL_WidgetImpProperties> m_pProperties;
IFWL_WidgetDelegate* m_pDelegate;
IFWL_WidgetDelegate* m_pCurDelegate;
IFWL_Widget* m_pOuter;