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_caret.cpp | 22 +++++++--------------- 1 file changed, 7 insertions(+), 15 deletions(-) (limited to 'xfa/fwl/core/ifwl_caret.cpp') diff --git a/xfa/fwl/core/ifwl_caret.cpp b/xfa/fwl/core/ifwl_caret.cpp index b6f799633b..2dd1866642 100644 --- a/xfa/fwl/core/ifwl_caret.cpp +++ b/xfa/fwl/core/ifwl_caret.cpp @@ -6,6 +6,7 @@ #include "xfa/fwl/core/ifwl_caret.h" +#include "third_party/base/ptr_util.h" #include "xfa/fwl/core/cfwl_themebackground.h" #include "xfa/fwl/core/cfwl_widgetimpproperties.h" #include "xfa/fwl/core/fwl_noteimp.h" @@ -21,27 +22,18 @@ IFWL_Caret::IFWL_Caret(const IFWL_App* app, m_dwElapse(400), m_bSetColor(FALSE) { SetStates(FWL_STATE_CAT_HightLight); + SetDelegate(pdfium::MakeUnique(this)); } -IFWL_Caret::~IFWL_Caret() {} - -FWL_Type IFWL_Caret::GetClassID() const { - return FWL_Type::Caret; -} - -void IFWL_Caret::Initialize() { - IFWL_Widget::Initialize(); - m_pDelegate = new CFWL_CaretImpDelegate(this); -} - -void IFWL_Caret::Finalize() { +IFWL_Caret::~IFWL_Caret() { if (m_pTimerInfo) { m_pTimerInfo->StopTimer(); m_pTimerInfo = nullptr; } - delete m_pDelegate; - m_pDelegate = nullptr; - IFWL_Widget::Finalize(); +} + +FWL_Type IFWL_Caret::GetClassID() const { + return FWL_Type::Caret; } FWL_Error IFWL_Caret::DrawWidget(CFX_Graphics* pGraphics, -- cgit v1.2.3