From 6fe8795d9022105a0061a0a81be9a49d49fda345 Mon Sep 17 00:00:00 2001 From: dsinclair Date: Tue, 1 Nov 2016 18:48:19 -0700 Subject: 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 --- xfa/fwl/core/ifwl_edit.cpp | 32 ++++++++++---------------------- 1 file changed, 10 insertions(+), 22 deletions(-) (limited to 'xfa/fwl/core/ifwl_edit.cpp') 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 #include +#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(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); } -- cgit v1.2.3