summaryrefslogtreecommitdiff
path: root/xfa/fwl/core/ifwl_edit.cpp
diff options
context:
space:
mode:
authordsinclair <dsinclair@chromium.org>2016-11-01 18:48:19 -0700
committerCommit bot <commit-bot@chromium.org>2016-11-01 18:48:20 -0700
commit6fe8795d9022105a0061a0a81be9a49d49fda345 (patch)
treeb1fc8d51560fbf0a9e4a163f887e763f565d5234 /xfa/fwl/core/ifwl_edit.cpp
parent919e48d877e503f1ca250bc37324c9f7dc96d7a9 (diff)
downloadpdfium-6fe8795d9022105a0061a0a81be9a49d49fda345.tar.xz
Fold IFWL*::{Initialize|Finalize} into constructor/destructor
This Cl moves the ::Initialize method into the constructors and the ::Finalize method into the destructors. The |m_pDelegate| is made private and a unique_ptr. A |SetDelegate| and |GetDelegate| method are added. Review-Url: https://codereview.chromium.org/2464703006
Diffstat (limited to 'xfa/fwl/core/ifwl_edit.cpp')
-rw-r--r--xfa/fwl/core/ifwl_edit.cpp32
1 files changed, 10 insertions, 22 deletions
diff --git a/xfa/fwl/core/ifwl_edit.cpp b/xfa/fwl/core/ifwl_edit.cpp
index b826bd2f02..8edc69d578 100644
--- a/xfa/fwl/core/ifwl_edit.cpp
+++ b/xfa/fwl/core/ifwl_edit.cpp
@@ -10,6 +10,7 @@
#include <memory>
#include <vector>
+#include "third_party/base/ptr_util.h"
#include "third_party/base/stl_util.h"
#include "xfa/fde/cfde_txtedtengine.h"
#include "xfa/fde/fde_gedevice.h"
@@ -74,33 +75,18 @@ IFWL_Edit::IFWL_Edit(const IFWL_App* app,
m_rtClient.Reset();
m_rtEngine.Reset();
m_rtStatic.Reset();
-}
-
-IFWL_Edit::~IFWL_Edit() {
- ClearRecord();
-}
-
-void IFWL_Edit::Initialize() {
- IFWL_Widget::Initialize();
- if (!m_pDelegate)
- m_pDelegate = new CFWL_EditImpDelegate(this);
+ SetDelegate(pdfium::MakeUnique<CFWL_EditImpDelegate>(this));
InitCaret();
if (!m_pEdtEngine)
InitEngine();
}
-void IFWL_Edit::Finalize() {
+IFWL_Edit::~IFWL_Edit() {
if (m_pProperties->m_dwStates & FWL_WGTSTATE_Focused)
ShowCaret(FALSE);
- if (m_pHorzScrollBar)
- m_pHorzScrollBar->Finalize();
- if (m_pVertScrollBar)
- m_pVertScrollBar->Finalize();
- delete m_pDelegate;
- m_pDelegate = nullptr;
- IFWL_Widget::Finalize();
+ ClearRecord();
}
FWL_Type IFWL_Edit::GetClassID() const {
@@ -1472,9 +1458,12 @@ void IFWL_Edit::InitScrollBar(FX_BOOL bVert) {
prop.m_dwStates = FWL_WGTSTATE_Disabled | FWL_WGTSTATE_Invisible;
prop.m_pParent = this;
prop.m_pThemeProvider = m_pProperties->m_pThemeProvider;
- IFWL_ScrollBar* pScrollBar = new IFWL_ScrollBar(m_pOwnerApp, prop, this);
- pScrollBar->Initialize();
- (bVert ? &m_pVertScrollBar : &m_pHorzScrollBar)->reset(pScrollBar);
+
+ IFWL_ScrollBar* sb = new IFWL_ScrollBar(m_pOwnerApp, prop, this);
+ if (bVert)
+ m_pVertScrollBar.reset(sb);
+ else
+ m_pHorzScrollBar.reset(sb);
}
void IFWL_Edit::InitEngine() {
@@ -1571,7 +1560,6 @@ void IFWL_Edit::InitCaret() {
if ((m_pProperties->m_dwStyleExes & FWL_STYLEEXT_EDT_InnerCaret)) {
CFWL_WidgetImpProperties prop;
m_pCaret.reset(new IFWL_Caret(m_pOwnerApp, prop, this));
- m_pCaret->Initialize();
m_pCaret->SetParent(this);
m_pCaret->SetStates(m_pProperties->m_dwStates);
}