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_listbox.cpp | 24 +++++------------------- 1 file changed, 5 insertions(+), 19 deletions(-) (limited to 'xfa/fwl/core/ifwl_listbox.cpp') diff --git a/xfa/fwl/core/ifwl_listbox.cpp b/xfa/fwl/core/ifwl_listbox.cpp index 7cd4c53ff3..b4b6c25136 100644 --- a/xfa/fwl/core/ifwl_listbox.cpp +++ b/xfa/fwl/core/ifwl_listbox.cpp @@ -6,6 +6,7 @@ #include "xfa/fwl/core/ifwl_listbox.h" +#include "third_party/base/ptr_util.h" #include "xfa/fde/tto/fde_textout.h" #include "xfa/fwl/core/cfwl_message.h" #include "xfa/fwl/core/cfwl_themebackground.h" @@ -33,25 +34,11 @@ IFWL_ListBox::IFWL_ListBox(const IFWL_App* app, m_rtClient.Reset(); m_rtConent.Reset(); m_rtStatic.Reset(); -} - -IFWL_ListBox::~IFWL_ListBox() {} -void IFWL_ListBox::Initialize() { - IFWL_Widget::Initialize(); - m_pDelegate = new CFWL_ListBoxImpDelegate(this); + SetDelegate(pdfium::MakeUnique(this)); } -void IFWL_ListBox::Finalize() { - if (m_pVertScrollBar) - m_pVertScrollBar->Finalize(); - if (m_pHorzScrollBar) - m_pHorzScrollBar->Finalize(); - - delete m_pDelegate; - m_pDelegate = nullptr; - IFWL_Widget::Finalize(); -} +IFWL_ListBox::~IFWL_ListBox() {} FWL_Type IFWL_ListBox::GetClassID() const { return FWL_Type::ListBox; @@ -896,9 +883,8 @@ void IFWL_ListBox::InitScrollBar(FX_BOOL bVert) { prop.m_dwStates = FWL_WGTSTATE_Invisible; prop.m_pParent = this; prop.m_pThemeProvider = m_pScrollBarTP; - IFWL_ScrollBar* pScrollBar = new IFWL_ScrollBar(m_pOwnerApp, prop, this); - pScrollBar->Initialize(); - (bVert ? &m_pVertScrollBar : &m_pHorzScrollBar)->reset(pScrollBar); + (bVert ? &m_pVertScrollBar : &m_pHorzScrollBar) + ->reset(new IFWL_ScrollBar(m_pOwnerApp, prop, this)); } FX_BOOL IFWL_ListBox::IsShowScrollBar(FX_BOOL bVert) { -- cgit v1.2.3