From 77221d4b4288ada80e34464ef4a402ea232b402b Mon Sep 17 00:00:00 2001 From: Tom Sepez Date: Tue, 8 Dec 2015 11:20:08 -0800 Subject: FWL refcounts never incremented (part 1) BUG=pdfium:282 R=thestig@chromium.org Review URL: https://codereview.chromium.org/1509203002 . --- xfa/src/fwl/src/basewidget/fwl_barcodeimp.cpp | 3 - xfa/src/fwl/src/basewidget/fwl_caretimp.cpp | 3 - xfa/src/fwl/src/basewidget/fwl_checkboximp.cpp | 6 -- xfa/src/fwl/src/basewidget/fwl_comboboximp.cpp | 66 ++++++++-------------- .../fwl/src/basewidget/fwl_datetimepickerimp.cpp | 51 ++++++----------- xfa/src/fwl/src/basewidget/fwl_editimp.cpp | 44 ++++----------- xfa/src/fwl/src/basewidget/fwl_listboximp.cpp | 29 +++------- .../fwl/src/basewidget/fwl_monthcalendarimp.cpp | 3 - xfa/src/fwl/src/basewidget/fwl_pictureboximp.cpp | 3 - xfa/src/fwl/src/basewidget/fwl_pushbuttonimp.cpp | 3 - xfa/src/fwl/src/basewidget/fwl_scrollbarimp.cpp | 3 - xfa/src/fwl/src/basewidget/fwl_spinbuttonimp.cpp | 3 - xfa/src/fwl/src/basewidget/fwl_tooltipctrlimp.cpp | 3 - .../fwl/src/basewidget/include/fwl_comboboximp.h | 10 ++-- .../src/basewidget/include/fwl_datetimepickerimp.h | 9 ++- xfa/src/fwl/src/basewidget/include/fwl_editimp.h | 10 ++-- .../fwl/src/basewidget/include/fwl_listboximp.h | 7 ++- xfa/src/fwl/src/core/fwl_contentimp.cpp | 3 - xfa/src/fwl/src/core/fwl_formimp.cpp | 3 - xfa/src/fwl/src/core/fwl_gridimp.cpp | 3 - xfa/src/fwl/src/core/fwl_noteimp.cpp | 10 +--- xfa/src/fwl/src/core/fwl_panelimp.cpp | 6 -- xfa/src/fwl/src/core/fwl_targetimp.cpp | 32 +---------- xfa/src/fwl/src/core/fwl_widgetimp.cpp | 3 - xfa/src/fwl/src/core/include/fwl_targetimp.h | 4 -- xfa/src/fwl/src/lightwidget/barcode.cpp | 2 +- xfa/src/fwl/src/lightwidget/caret.cpp | 2 +- xfa/src/fwl/src/lightwidget/checkbox.cpp | 2 +- xfa/src/fwl/src/lightwidget/combobox.cpp | 2 +- xfa/src/fwl/src/lightwidget/datetimepicker.cpp | 2 +- xfa/src/fwl/src/lightwidget/edit.cpp | 2 +- xfa/src/fwl/src/lightwidget/listbox.cpp | 2 +- xfa/src/fwl/src/lightwidget/picturebox.cpp | 2 +- xfa/src/fwl/src/lightwidget/pushbutton.cpp | 2 +- xfa/src/fwl/src/lightwidget/scrollbar.cpp | 2 +- xfa/src/fwl/src/lightwidget/tooltipctrl.cpp | 2 +- xfa/src/fwl/src/lightwidget/widget.cpp | 33 +---------- 37 files changed, 100 insertions(+), 275 deletions(-) (limited to 'xfa/src/fwl') diff --git a/xfa/src/fwl/src/basewidget/fwl_barcodeimp.cpp b/xfa/src/fwl/src/basewidget/fwl_barcodeimp.cpp index e6d8d164b8..37cc945947 100644 --- a/xfa/src/fwl/src/basewidget/fwl_barcodeimp.cpp +++ b/xfa/src/fwl/src/basewidget/fwl_barcodeimp.cpp @@ -10,9 +10,6 @@ #include "../core/include/fwl_widgetimp.h" #include "include/fwl_editimp.h" #include "include/fwl_barcodeimp.h" -IFWL_Barcode* IFWL_Barcode::Create() { - return new IFWL_Barcode; -} IFWL_Barcode::IFWL_Barcode() { } FWL_ERR IFWL_Barcode::Initialize(const CFWL_WidgetImpProperties& properties, diff --git a/xfa/src/fwl/src/basewidget/fwl_caretimp.cpp b/xfa/src/fwl/src/basewidget/fwl_caretimp.cpp index 98bcbb59e2..24104e19b5 100644 --- a/xfa/src/fwl/src/basewidget/fwl_caretimp.cpp +++ b/xfa/src/fwl/src/basewidget/fwl_caretimp.cpp @@ -9,9 +9,6 @@ #include "../core/include/fwl_noteimp.h" #include "../core/include/fwl_widgetimp.h" #include "include/fwl_caretimp.h" -IFWL_Caret* IFWL_Caret::Create() { - return new IFWL_Caret; -} IFWL_Caret::IFWL_Caret() { } FWL_ERR IFWL_Caret::Initialize(IFWL_Widget* pOuter) { diff --git a/xfa/src/fwl/src/basewidget/fwl_checkboximp.cpp b/xfa/src/fwl/src/basewidget/fwl_checkboximp.cpp index 4fe0c0a149..c68dd7512b 100644 --- a/xfa/src/fwl/src/basewidget/fwl_checkboximp.cpp +++ b/xfa/src/fwl/src/basewidget/fwl_checkboximp.cpp @@ -11,9 +11,6 @@ #include "../core/include/fwl_widgetmgrimp.h" #include "include/fwl_checkboximp.h" #define FWL_CKB_CaptionMargin 5 -IFWL_CheckBox* IFWL_CheckBox::Create() { - return new IFWL_CheckBox; -} IFWL_CheckBox::IFWL_CheckBox() { } FWL_ERR IFWL_CheckBox::Initialize(const CFWL_WidgetImpProperties& properties, @@ -29,9 +26,6 @@ int32_t IFWL_CheckBox::GetCheckState() { FWL_ERR IFWL_CheckBox::SetCheckState(int32_t iCheck) { return static_cast(GetImpl())->SetCheckState(iCheck); } -IFWL_RadioButton* IFWL_RadioButton::Create() { - return new IFWL_RadioButton; -} IFWL_RadioButton::IFWL_RadioButton() { } FWL_ERR IFWL_RadioButton::Initialize(const CFWL_WidgetImpProperties& properties, diff --git a/xfa/src/fwl/src/basewidget/fwl_comboboximp.cpp b/xfa/src/fwl/src/basewidget/fwl_comboboximp.cpp index c35ae75de6..265337616b 100644 --- a/xfa/src/fwl/src/basewidget/fwl_comboboximp.cpp +++ b/xfa/src/fwl/src/basewidget/fwl_comboboximp.cpp @@ -18,9 +18,6 @@ #include "include/fwl_listboximp.h" #include "include/fwl_formproxyimp.h" #include "include/fwl_comboboximp.h" -IFWL_ComboBox* IFWL_ComboBox::Create() { - return new IFWL_ComboBox; -} IFWL_ComboBox::IFWL_ComboBox() { } FWL_ERR IFWL_ComboBox::Initialize(const CFWL_WidgetImpProperties& properties, @@ -342,7 +339,7 @@ void CFWL_ComboListImpDelegate::OnDropListFocusChanged(CFWL_Message* pMsg, CFWL_ComboBoxImp* pOuter = static_cast(m_pOwner->m_pOuter->GetImpl()); if (pKill->m_pSetFocus == m_pOwner->m_pOuter || - pKill->m_pSetFocus == pOuter->m_pEdit) { + pKill->m_pSetFocus == pOuter->m_pEdit.get()) { pOuter->ShowDropList(FALSE); } } @@ -472,8 +469,6 @@ void CFWL_ComboListImpDelegate::OnDropListKeyDown(CFWL_MsgKey* pKey) { } CFWL_ComboBoxImp::CFWL_ComboBoxImp(IFWL_Widget* pOuter) : CFWL_WidgetImp(pOuter), - m_pEdit(NULL), - m_pListBox(NULL), m_pForm(NULL), m_bLButtonDown(FALSE), m_iCurSel(-1), @@ -487,8 +482,6 @@ CFWL_ComboBoxImp::CFWL_ComboBoxImp(IFWL_Widget* pOuter) CFWL_ComboBoxImp::CFWL_ComboBoxImp(const CFWL_WidgetImpProperties& properties, IFWL_Widget* pOuter) : CFWL_WidgetImp(properties, pOuter), - m_pEdit(NULL), - m_pListBox(NULL), m_pForm(NULL), m_bLButtonDown(FALSE), m_iCurSel(-1), @@ -500,14 +493,6 @@ CFWL_ComboBoxImp::CFWL_ComboBoxImp(const CFWL_WidgetImpProperties& properties, m_rtHandler.Reset(); } CFWL_ComboBoxImp::~CFWL_ComboBoxImp() { - if (m_pEdit) { - m_pEdit->Release(); - m_pEdit = NULL; - } - if (m_pListBox) { - m_pListBox->Release(); - m_pListBox = NULL; - } } FWL_ERR CFWL_ComboBoxImp::GetClassName(CFX_WideString& wsClass) const { wsClass = FWL_CLASS_ComboBox; @@ -531,14 +516,14 @@ FWL_ERR CFWL_ComboBoxImp::Initialize() { } prop.m_pDataProvider = m_pProperties->m_pDataProvider; CFWL_ComboListImp* pList = new CFWL_ComboListImp(prop, m_pInterface); - m_pListBox = IFWL_ListBox::Create(); - pList->SetInterface(m_pListBox); + m_pListBox.reset(new IFWL_ListBox); + pList->SetInterface(m_pListBox.get()); m_pListBox->SetImpl(pList); pList->Initialize(); if ((m_pProperties->m_dwStyleExes & FWL_STYLEEXT_CMB_DropDown) && !m_pEdit) { CFWL_ComboEditImp* pEdit = new CFWL_ComboEditImp(m_pInterface); - m_pEdit = IFWL_Edit::Create(); - pEdit->SetInterface(m_pEdit); + m_pEdit.reset(new IFWL_Edit); + pEdit->SetInterface(m_pEdit.get()); m_pEdit->SetImpl(pEdit); pEdit->Initialize(); pEdit->SetOuter(m_pInterface); @@ -591,8 +576,8 @@ FWL_ERR CFWL_ComboBoxImp::ModifyStylesEx(FX_DWORD dwStylesExAdded, FX_BOOL bRemoveDropDown = dwStylesExRemoved & FWL_STYLEEXT_CMB_DropDown; if (bAddDropDown && !m_pEdit) { CFWL_ComboEditImp* pEdit = new CFWL_ComboEditImp(m_pInterface); - m_pEdit = IFWL_Edit::Create(); - pEdit->SetInterface(m_pEdit); + m_pEdit.reset(new IFWL_Edit); + pEdit->SetInterface(m_pEdit.get()); m_pEdit->SetImpl(pEdit); pEdit->Initialize(); pEdit->SetOuter(m_pInterface); @@ -663,8 +648,8 @@ FWL_ERR CFWL_ComboBoxImp::DrawWidget(CFX_Graphics* pGraphics, IFWL_ListBoxDP* pData = static_cast( static_cast(m_pListBox->GetImpl()) ->m_pProperties->m_pDataProvider); - void* p = - pData->GetItemData(m_pListBox, pData->GetItem(m_pListBox, m_iCurSel)); + void* p = pData->GetItemData(m_pListBox.get(), + pData->GetItem(m_pListBox.get(), m_iCurSel)); if (p != NULL) { param.m_pData = p; } @@ -721,10 +706,10 @@ FWL_ERR CFWL_ComboBoxImp::SetThemeProvider(IFWL_ThemeProvider* pThemeProvider) { if (!pThemeProvider) return FWL_ERR_Indefinite; m_pProperties->m_pThemeProvider = pThemeProvider; - if (m_pListBox && pThemeProvider->IsValidWidget(m_pListBox)) { + if (m_pListBox && pThemeProvider->IsValidWidget(m_pListBox.get())) { m_pListBox->SetThemeProvider(pThemeProvider); } - if (m_pEdit && pThemeProvider->IsValidWidget(m_pEdit)) { + if (m_pEdit && pThemeProvider->IsValidWidget(m_pEdit.get())) { m_pEdit->SetThemeProvider(pThemeProvider); } return FWL_ERR_Succeeded; @@ -826,9 +811,7 @@ FX_BOOL CFWL_ComboBoxImp::EditUndo(const CFX_ByteStringC& bsRecord) { return m_pEdit->Undo(bsRecord); } IFWL_ListBox* CFWL_ComboBoxImp::GetListBoxt() { - if (!m_pListBox) - return FALSE; - return m_pListBox; + return m_pListBox.get(); } FX_BOOL CFWL_ComboBoxImp::AfterFocusShowDropList() { if (!m_bNeedShowList) { @@ -1072,12 +1055,13 @@ void CFWL_ComboBoxImp::ReSetTheme() { m_pProperties->m_pThemeProvider = pTheme; } if (m_pListBox) { - if (!m_pListBox->GetThemeProvider() && pTheme->IsValidWidget(m_pListBox)) { + if (!m_pListBox->GetThemeProvider() && + pTheme->IsValidWidget(m_pListBox.get())) { m_pListBox->SetThemeProvider(pTheme); } } if (m_pEdit) { - if (!m_pEdit->GetThemeProvider() && pTheme->IsValidWidget(m_pEdit)) { + if (!m_pEdit->GetThemeProvider() && pTheme->IsValidWidget(m_pEdit.get())) { m_pEdit->SetThemeProvider(pTheme); } } @@ -1171,8 +1155,8 @@ void CFWL_ComboBoxImp::InitProxyForm() { propForm.m_pOwner = m_pInterface; propForm.m_dwStyles = FWL_WGTSTYLE_Popup; propForm.m_dwStates = FWL_WGTSTATE_Invisible; - m_pProxy = new CFWL_FormProxyImp(propForm, m_pListBox); - m_pForm = IFWL_Form::Create(); + m_pProxy = new CFWL_FormProxyImp(propForm, m_pListBox.get()); + m_pForm = new IFWL_Form; m_pProxy->SetInterface(m_pForm); m_pForm->SetImpl(m_pProxy); m_pProxy->Initialize(); @@ -1199,8 +1183,8 @@ void CFWL_ComboBoxImp::DisForm_InitComboList() { prop.m_pDataProvider = m_pProperties->m_pDataProvider; prop.m_pThemeProvider = m_pProperties->m_pThemeProvider; CFWL_ComboListImp* pList = new CFWL_ComboListImp(prop, m_pInterface); - m_pListBox = IFWL_ListBox::Create(); - pList->SetInterface(m_pListBox); + m_pListBox.reset(new IFWL_ListBox); + pList->SetInterface(m_pListBox.get()); m_pListBox->SetImpl(pList); pList->Initialize(); } @@ -1214,8 +1198,8 @@ void CFWL_ComboBoxImp::DisForm_InitComboEdit() { if ((m_pProperties->m_dwStyleExes & FWL_STYLEEXT_CMB_DropDown) == 0) { } CFWL_ComboEditImp* pEdit = new CFWL_ComboEditImp(prop, m_pInterface); - m_pEdit = IFWL_Edit::Create(); - pEdit->SetInterface(m_pEdit); + m_pEdit.reset(new IFWL_Edit); + pEdit->SetInterface(m_pEdit.get()); m_pEdit->SetImpl(pEdit); pEdit->Initialize(); pEdit->SetOuter(m_pInterface); @@ -1493,7 +1477,7 @@ void CFWL_ComboBoxImpDelegate::OnFocusChanged(CFWL_Message* pMsg, FX_BOOL bDropDown = m_pOwner->IsDropDownStyle(); if (bSet) { m_pOwner->m_pProperties->m_dwStates |= FWL_WGTSTATE_Focused; - if (bDropDown && pSrcTarget != m_pOwner->m_pListBox) { + if (bDropDown && pSrcTarget != m_pOwner->m_pListBox.get()) { if (!m_pOwner->m_pEdit) return; static_cast(m_pOwner->m_pEdit->GetImpl()) @@ -1503,7 +1487,7 @@ void CFWL_ComboBoxImpDelegate::OnFocusChanged(CFWL_Message* pMsg, } } else { m_pOwner->m_pProperties->m_dwStates &= ~FWL_WGTSTATE_Focused; - if (bDropDown && pDstTarget != m_pOwner->m_pListBox) { + if (bDropDown && pDstTarget != m_pOwner->m_pListBox.get()) { if (!m_pOwner->m_pEdit) return; static_cast(m_pOwner->m_pEdit->GetImpl()) @@ -1713,7 +1697,7 @@ void CFWL_ComboBoxImpDelegate::DisForm_OnFocusChanged(CFWL_Message* pMsg, m_pOwner->m_pProperties->m_dwStates |= FWL_WGTSTATE_Focused; if ((m_pOwner->m_pEdit->GetStates() & FWL_WGTSTATE_Focused) == 0) { CFWL_MsgSetFocus msg; - msg.m_pDstTarget = m_pOwner->m_pEdit; + msg.m_pDstTarget = m_pOwner->m_pEdit.get(); msg.m_pSrcTarget = NULL; IFWL_WidgetDelegate* pDelegate = m_pOwner->m_pEdit->SetDelegate(NULL); pDelegate->OnProcessMessage(&msg); @@ -1723,7 +1707,7 @@ void CFWL_ComboBoxImpDelegate::DisForm_OnFocusChanged(CFWL_Message* pMsg, m_pOwner->DisForm_ShowDropList(FALSE); CFWL_MsgKillFocus msg; msg.m_pDstTarget = NULL; - msg.m_pSrcTarget = m_pOwner->m_pEdit; + msg.m_pSrcTarget = m_pOwner->m_pEdit.get(); IFWL_WidgetDelegate* pDelegate = m_pOwner->m_pEdit->SetDelegate(NULL); pDelegate->OnProcessMessage(&msg); } diff --git a/xfa/src/fwl/src/basewidget/fwl_datetimepickerimp.cpp b/xfa/src/fwl/src/basewidget/fwl_datetimepickerimp.cpp index 12b0f2d7e8..5208ca880e 100644 --- a/xfa/src/fwl/src/basewidget/fwl_datetimepickerimp.cpp +++ b/xfa/src/fwl/src/basewidget/fwl_datetimepickerimp.cpp @@ -17,9 +17,6 @@ #include "include/fwl_datetimepickerimp.h" #define FWL_DTP_WIDTH 100 #define FWL_DTP_HEIGHT 20 -IFWL_DateTimePicker* IFWL_DateTimePicker::Create() { - return new IFWL_DateTimePicker; -} FWL_ERR IFWL_DateTimeForm::Initialize( const CFWL_WidgetImpProperties& properties, IFWL_Widget* pOuter) { @@ -426,18 +423,6 @@ CFWL_DateTimePickerImp::CFWL_DateTimePickerImp( m_rtBtn.Set(0, 0, 0, 0); } CFWL_DateTimePickerImp::~CFWL_DateTimePickerImp() { - if (m_pEdit) { - m_pEdit->Release(); - m_pEdit = NULL; - } - if (m_pMonthCal) { - m_pMonthCal->Release(); - m_pMonthCal = NULL; - } - if (m_pForm) { - m_pForm->Release(); - m_pForm = NULL; - } } FWL_ERR CFWL_DateTimePickerImp::GetClassName(CFX_WideString& wsClass) const { wsClass = FWL_CLASS_DateTimePicker; @@ -457,7 +442,7 @@ FWL_ERR CFWL_DateTimePickerImp::Initialize() { propMonth.m_pDataProvider = &m_MonthCalendarDP; propMonth.m_pParent = m_pInterface; propMonth.m_pThemeProvider = m_pProperties->m_pThemeProvider; - m_pMonthCal = new IFWL_DateTimeCalender(); + m_pMonthCal.reset(new IFWL_DateTimeCalender()); m_pMonthCal->Initialize(propMonth, m_pInterface); CFX_RectF rtMonthCal; m_pMonthCal->GetWidgetRect(rtMonthCal, TRUE); @@ -466,10 +451,10 @@ FWL_ERR CFWL_DateTimePickerImp::Initialize() { CFWL_WidgetImpProperties propEdit; propEdit.m_pParent = m_pInterface; propEdit.m_pThemeProvider = m_pProperties->m_pThemeProvider; - m_pEdit = new IFWL_DateTimeEdit(); + m_pEdit.reset(new IFWL_DateTimeEdit()); m_pEdit->Initialize(propEdit, m_pInterface); - RegisterEventTarget(m_pMonthCal); - RegisterEventTarget(m_pEdit); + RegisterEventTarget(m_pMonthCal.get()); + RegisterEventTarget(m_pEdit.get()); return FWL_ERR_Succeeded; } FWL_ERR CFWL_DateTimePickerImp::Finalize() { @@ -700,7 +685,7 @@ void CFWL_DateTimePickerImp::DrawDropDownButton(CFX_Graphics* pGraphics, prop.m_dwStyleExes |= FWL_STYLEEXE_SPB_Vert; prop.m_pParent = m_pInterface; prop.m_rtWidget = m_rtBtn; - IFWL_SpinButton* pSpin = IFWL_SpinButton::Create(); + IFWL_SpinButton* pSpin = new IFWL_SpinButton; pSpin->Initialize(prop, m_pInterface); } else { CFWL_ThemeBackground param; @@ -828,19 +813,19 @@ void CFWL_DateTimePickerImp::InitProxyForm() { propForm.m_dwStyles = FWL_WGTSTYLE_Popup; propForm.m_dwStates = FWL_WGTSTATE_Invisible; propForm.m_pOwner = m_pInterface; - m_pForm = new IFWL_DateTimeForm(); - m_pForm->Initialize(propForm, m_pMonthCal); - m_pMonthCal->SetParent(m_pForm); + m_pForm.reset(new IFWL_DateTimeForm()); + m_pForm->Initialize(propForm, m_pMonthCal.get()); + m_pMonthCal->SetParent(m_pForm.get()); } IFWL_DateTimeEdit* CFWL_DateTimePickerImp::GetDataTimeEdit() { - return m_pEdit; + return m_pEdit.get(); } FWL_ERR CFWL_DateTimePickerImp::DisForm_Initialize() { m_pProperties->m_dwStyleExes = FWL_STYLEEXT_DTP_ShortDateFormat; DisForm_InitDateTimeCalendar(); DisForm_InitDateTimeEdit(); - RegisterEventTarget(m_pMonthCal); - RegisterEventTarget(m_pEdit); + RegisterEventTarget(m_pMonthCal.get()); + RegisterEventTarget(m_pEdit.get()); return FWL_ERR_Succeeded; } void CFWL_DateTimePickerImp::DisForm_InitDateTimeCalendar() { @@ -854,7 +839,7 @@ void CFWL_DateTimePickerImp::DisForm_InitDateTimeCalendar() { propMonth.m_pParent = m_pInterface; propMonth.m_pDataProvider = &m_MonthCalendarDP; propMonth.m_pThemeProvider = m_pProperties->m_pThemeProvider; - m_pMonthCal = new IFWL_DateTimeCalender(); + m_pMonthCal.reset(new IFWL_DateTimeCalender()); m_pMonthCal->Initialize(propMonth, m_pInterface); CFX_RectF rtMonthCal; m_pMonthCal->GetWidgetRect(rtMonthCal, TRUE); @@ -868,7 +853,7 @@ void CFWL_DateTimePickerImp::DisForm_InitDateTimeEdit() { CFWL_WidgetImpProperties propEdit; propEdit.m_pParent = m_pInterface; propEdit.m_pThemeProvider = m_pProperties->m_pThemeProvider; - m_pEdit = new IFWL_DateTimeEdit(); + m_pEdit.reset(new IFWL_DateTimeEdit()); m_pEdit->Initialize(propEdit, m_pInterface); } FX_BOOL CFWL_DateTimePickerImp::DisForm_IsMonthCalendarShowed() { @@ -900,8 +885,8 @@ void CFWL_DateTimePickerImp::DisForm_ShowMonthCalendar(FX_BOOL bActivate) { m_pMonthCal->SetStates(FWL_WGTSTATE_Invisible, !bActivate); if (bActivate) { CFWL_MsgSetFocus msg; - msg.m_pDstTarget = m_pMonthCal; - msg.m_pSrcTarget = m_pEdit; + msg.m_pDstTarget = m_pMonthCal.get(); + msg.m_pSrcTarget = m_pEdit.get(); IFWL_WidgetDelegate* pDelegate = m_pEdit->SetDelegate(NULL); pDelegate->OnProcessMessage(&msg); } @@ -1090,7 +1075,7 @@ void CFWL_DateTimePickerImpDelegate::OnFocusChanged(CFWL_Message* pMsg, m_pOwner->m_pProperties->m_dwStates &= ~(FWL_WGTSTATE_Focused); m_pOwner->Repaint(&m_pOwner->m_rtClient); } - if (pMsg->m_pSrcTarget == m_pOwner->m_pMonthCal && + if (pMsg->m_pSrcTarget == m_pOwner->m_pMonthCal.get() && m_pOwner->IsMonthCalendarShowed()) { m_pOwner->ShowMonthCalendar(FALSE); } @@ -1156,7 +1141,7 @@ void CFWL_DateTimePickerImpDelegate::DisForm_OnFocusChanged(CFWL_Message* pMsg, m_pOwner->m_pProperties->m_rtWidget.height - 1); } rtInvalidate = m_pOwner->m_rtBtn; - pMsg->m_pDstTarget = m_pOwner->m_pEdit; + pMsg->m_pDstTarget = m_pOwner->m_pEdit.get(); IFWL_WidgetDelegate* pDelegate = m_pOwner->m_pEdit->SetDelegate(NULL); pDelegate->OnProcessMessage(pMsg); } else { @@ -1166,7 +1151,7 @@ void CFWL_DateTimePickerImpDelegate::DisForm_OnFocusChanged(CFWL_Message* pMsg, m_pOwner->ShowMonthCalendar(FALSE); } if (m_pOwner->m_pEdit->GetStates() & FWL_WGTSTATE_Focused) { - pMsg->m_pSrcTarget = m_pOwner->m_pEdit; + pMsg->m_pSrcTarget = m_pOwner->m_pEdit.get(); IFWL_WidgetDelegate* pDelegate = m_pOwner->m_pEdit->SetDelegate(NULL); pDelegate->OnProcessMessage(pMsg); } diff --git a/xfa/src/fwl/src/basewidget/fwl_editimp.cpp b/xfa/src/fwl/src/basewidget/fwl_editimp.cpp index 00a24dd9f5..8f6611884a 100644 --- a/xfa/src/fwl/src/basewidget/fwl_editimp.cpp +++ b/xfa/src/fwl/src/basewidget/fwl_editimp.cpp @@ -14,9 +14,6 @@ #include "include/fwl_scrollbarimp.h" #include "include/fwl_editimp.h" #include "include/fwl_caretimp.h" -IFWL_Edit* IFWL_Edit::Create() { - return new IFWL_Edit; -} IFWL_Edit::IFWL_Edit() { } FWL_ERR IFWL_Edit::Initialize(const CFWL_WidgetImpProperties& properties, @@ -168,10 +165,6 @@ CFWL_EditImp::CFWL_EditImp(IFWL_Widget* pOuter) m_bSetRange(FALSE), m_iMin(-1), m_iMax(0xFFFFFFF), - m_pVertScrollBar(NULL), - m_pHorzScrollBar(NULL), - m_pCaret(NULL), - m_pTextField(NULL), m_backColor(0), m_updateBackColor(FALSE), m_iCurRecord(-1), @@ -196,10 +189,6 @@ CFWL_EditImp::CFWL_EditImp(const CFWL_WidgetImpProperties& properties, m_bSetRange(FALSE), m_iMin(-1), m_iMax(0xFFFFFFF), - m_pVertScrollBar(NULL), - m_pHorzScrollBar(NULL), - m_pCaret(NULL), - m_pTextField(NULL), m_backColor(0), m_updateBackColor(FALSE), m_iCurRecord(-1), @@ -213,18 +202,6 @@ CFWL_EditImp::~CFWL_EditImp() { m_pEdtEngine->Release(); m_pEdtEngine = NULL; } - if (m_pHorzScrollBar) { - m_pHorzScrollBar->Release(); - m_pHorzScrollBar = NULL; - } - if (m_pVertScrollBar) { - m_pVertScrollBar->Release(); - m_pVertScrollBar = NULL; - } - if (m_pCaret) { - m_pCaret->Release(); - m_pCaret = NULL; - } ClearRecord(); } FWL_ERR CFWL_EditImp::GetClassName(CFX_WideString& wsClass) const { @@ -1465,14 +1442,14 @@ IFWL_ScrollBar* CFWL_EditImp::UpdateScroll() { m_pHorzScrollBar->SetStates(FWL_WGTSTATE_Disabled, FALSE); m_pHorzScrollBar->UnlockUpdate(); m_pHorzScrollBar->Update(); - pRepaint = m_pHorzScrollBar; + pRepaint = m_pHorzScrollBar.get(); } else if ((m_pHorzScrollBar->GetStates() & FWL_WGTSTATE_Disabled) == 0) { m_pHorzScrollBar->LockUpdate(); m_pHorzScrollBar->SetRange(0, -1); m_pHorzScrollBar->SetStates(FWL_WGTSTATE_Disabled, TRUE); m_pHorzScrollBar->UnlockUpdate(); m_pHorzScrollBar->Update(); - pRepaint = m_pHorzScrollBar; + pRepaint = m_pHorzScrollBar.get(); } } if (bShowVert) { @@ -1500,14 +1477,14 @@ IFWL_ScrollBar* CFWL_EditImp::UpdateScroll() { m_pVertScrollBar->SetStates(FWL_WGTSTATE_Disabled, FALSE); m_pVertScrollBar->UnlockUpdate(); m_pVertScrollBar->Update(); - pRepaint = m_pVertScrollBar; + pRepaint = m_pVertScrollBar.get(); } else if ((m_pVertScrollBar->GetStates() & FWL_WGTSTATE_Disabled) == 0) { m_pVertScrollBar->LockUpdate(); m_pVertScrollBar->SetRange(0, -1); m_pVertScrollBar->SetStates(FWL_WGTSTATE_Disabled, TRUE); m_pVertScrollBar->UnlockUpdate(); m_pVertScrollBar->Update(); - pRepaint = m_pVertScrollBar; + pRepaint = m_pVertScrollBar.get(); } } return pRepaint; @@ -1693,9 +1670,9 @@ void CFWL_EditImp::InitScrollBar(FX_BOOL bVert) { prop.m_dwStates = FWL_WGTSTATE_Disabled | FWL_WGTSTATE_Invisible; prop.m_pParent = m_pInterface; prop.m_pThemeProvider = m_pProperties->m_pThemeProvider; - IFWL_ScrollBar* pScrollBar = IFWL_ScrollBar::Create(); + IFWL_ScrollBar* pScrollBar = new IFWL_ScrollBar; pScrollBar->Initialize(prop, m_pInterface); - bVert ? (m_pVertScrollBar = pScrollBar) : (m_pHorzScrollBar = pScrollBar); + (bVert ? &m_pVertScrollBar : &m_pHorzScrollBar)->reset(pScrollBar); } void CFWL_EditImp::InitEngine() { if (m_pEdtEngine) { @@ -1768,15 +1745,14 @@ FX_BOOL CFWL_EditImp::ValidateNumberChar(FX_WCHAR cNum) { void CFWL_EditImp::InitCaret() { if (!m_pCaret) { if ((m_pProperties->m_dwStyleExes & FWL_STYLEEXT_EDT_InnerCaret)) { - m_pCaret = IFWL_Caret::Create(); + m_pCaret.reset(new IFWL_Caret); m_pCaret->Initialize(m_pInterface); m_pCaret->SetParent(m_pInterface); m_pCaret->SetStates(m_pProperties->m_dwStates); } } else if ((m_pProperties->m_dwStyleExes & FWL_STYLEEXT_EDT_InnerCaret) == 0) { - m_pCaret->Release(); - m_pCaret = NULL; + m_pCaret.reset(); } } void CFWL_EditImp::ClearRecord() { @@ -1866,9 +1842,9 @@ FWL_ERR CFWL_EditImpDelegate::OnProcessEvent(CFWL_Event* pEvent) { return FWL_ERR_Succeeded; } IFWL_Widget* pSrcTarget = pEvent->m_pSrcTarget; - if ((pSrcTarget == m_pOwner->m_pVertScrollBar && + if ((pSrcTarget == m_pOwner->m_pVertScrollBar.get() && m_pOwner->m_pVertScrollBar) || - (pSrcTarget == m_pOwner->m_pHorzScrollBar && + (pSrcTarget == m_pOwner->m_pHorzScrollBar.get() && m_pOwner->m_pHorzScrollBar)) { CFWL_EvtScroll* pScrollEvent = static_cast(pEvent); OnScroll(static_cast(pSrcTarget), diff --git a/xfa/src/fwl/src/basewidget/fwl_listboximp.cpp b/xfa/src/fwl/src/basewidget/fwl_listboximp.cpp index 73c3a9ce44..24ec699d10 100644 --- a/xfa/src/fwl/src/basewidget/fwl_listboximp.cpp +++ b/xfa/src/fwl/src/basewidget/fwl_listboximp.cpp @@ -11,9 +11,6 @@ #include "include/fwl_scrollbarimp.h" #include "include/fwl_listboximp.h" #define FWL_LISTBOX_ItemTextMargin 2 -IFWL_ListBox* IFWL_ListBox::Create() { - return new IFWL_ListBox; -} IFWL_ListBox::IFWL_ListBox() { } FWL_ERR IFWL_ListBox::Initialize(const CFWL_WidgetImpProperties& properties, @@ -46,8 +43,6 @@ FWL_ERR* IFWL_ListBox::Sort(IFWL_ListBoxCompare* pCom) { } CFWL_ListBoxImp::CFWL_ListBoxImp(IFWL_Widget* pOuter) : CFWL_WidgetImp(pOuter), - m_pHorzScrollBar(NULL), - m_pVertScrollBar(NULL), m_dwTTOStyles(0), m_iTTOAligns(0), m_hAnchor(NULL), @@ -61,8 +56,6 @@ CFWL_ListBoxImp::CFWL_ListBoxImp(IFWL_Widget* pOuter) CFWL_ListBoxImp::CFWL_ListBoxImp(const CFWL_WidgetImpProperties& properties, IFWL_Widget* pOuter) : CFWL_WidgetImp(properties, pOuter), - m_pHorzScrollBar(NULL), - m_pVertScrollBar(NULL), m_dwTTOStyles(0), m_iTTOAligns(0), m_hAnchor(NULL), @@ -74,14 +67,6 @@ CFWL_ListBoxImp::CFWL_ListBoxImp(const CFWL_WidgetImpProperties& properties, m_rtStatic.Reset(); } CFWL_ListBoxImp::~CFWL_ListBoxImp() { - if (m_pVertScrollBar) { - m_pVertScrollBar->Release(); - m_pVertScrollBar = NULL; - } - if (m_pHorzScrollBar) { - m_pHorzScrollBar->Release(); - m_pHorzScrollBar = NULL; - } } FWL_ERR CFWL_ListBoxImp::GetClassName(CFX_WideString& wsClass) const { wsClass = FWL_CLASS_ListBox; @@ -309,7 +294,8 @@ FWL_ERR CFWL_ListBoxImp::GetItemText(FWL_HLISTITEM hItem, } FWL_ERR CFWL_ListBoxImp::GetScrollPos(FX_FLOAT& fPos, FX_BOOL bVert) { if ((bVert && IsShowScrollBar(TRUE)) || (!bVert && IsShowScrollBar(FALSE))) { - IFWL_ScrollBar* pScrollBar = bVert ? m_pVertScrollBar : m_pHorzScrollBar; + IFWL_ScrollBar* pScrollBar = + bVert ? m_pVertScrollBar.get() : m_pHorzScrollBar.get(); fPos = pScrollBar->GetPos(); return FWL_ERR_Succeeded; } @@ -959,13 +945,14 @@ void CFWL_ListBoxImp::InitScrollBar(FX_BOOL bVert) { prop.m_dwStates = FWL_WGTSTATE_Invisible; prop.m_pParent = m_pInterface; prop.m_pThemeProvider = m_pScrollBarTP; - IFWL_ScrollBar* pScrollBar = IFWL_ScrollBar::Create(); + IFWL_ScrollBar* pScrollBar = new IFWL_ScrollBar; pScrollBar->Initialize(prop, m_pInterface); - bVert ? (m_pVertScrollBar = pScrollBar) : (m_pHorzScrollBar = pScrollBar); + (bVert ? &m_pVertScrollBar : &m_pHorzScrollBar)->reset(pScrollBar); } void CFWL_ListBoxImp::SortItem() {} FX_BOOL CFWL_ListBoxImp::IsShowScrollBar(FX_BOOL bVert) { - IFWL_ScrollBar* pScrollbar = bVert ? m_pVertScrollBar : m_pHorzScrollBar; + IFWL_ScrollBar* pScrollbar = + bVert ? m_pVertScrollBar.get() : m_pHorzScrollBar.get(); if (!pScrollbar || (pScrollbar->GetStates() & FWL_WGTSTATE_Invisible)) { return FALSE; } @@ -1041,9 +1028,9 @@ FWL_ERR CFWL_ListBoxImpDelegate::OnProcessEvent(CFWL_Event* pEvent) { return FWL_ERR_Succeeded; } IFWL_Widget* pSrcTarget = pEvent->m_pSrcTarget; - if ((pSrcTarget == m_pOwner->m_pVertScrollBar && + if ((pSrcTarget == m_pOwner->m_pVertScrollBar.get() && m_pOwner->m_pVertScrollBar) || - (pSrcTarget == m_pOwner->m_pHorzScrollBar && + (pSrcTarget == m_pOwner->m_pHorzScrollBar.get() && m_pOwner->m_pHorzScrollBar)) { CFWL_EvtScroll* pScrollEvent = static_cast(pEvent); OnScroll(static_cast(pSrcTarget), diff --git a/xfa/src/fwl/src/basewidget/fwl_monthcalendarimp.cpp b/xfa/src/fwl/src/basewidget/fwl_monthcalendarimp.cpp index e7f773e4ca..624ce45bde 100644 --- a/xfa/src/fwl/src/basewidget/fwl_monthcalendarimp.cpp +++ b/xfa/src/fwl/src/basewidget/fwl_monthcalendarimp.cpp @@ -17,9 +17,6 @@ #define MONTHCAL_COLUMNS 7 #define MONTHCAL_HEADER_BTN_VMARGIN 7 #define MONTHCAL_HEADER_BTN_HMARGIN 5 -IFWL_MonthCalendar* IFWL_MonthCalendar::Create() { - return new IFWL_MonthCalendar; -} IFWL_MonthCalendar::IFWL_MonthCalendar() { } FWL_ERR IFWL_MonthCalendar::Initialize( diff --git a/xfa/src/fwl/src/basewidget/fwl_pictureboximp.cpp b/xfa/src/fwl/src/basewidget/fwl_pictureboximp.cpp index c0b2f67e49..7c02052f74 100644 --- a/xfa/src/fwl/src/basewidget/fwl_pictureboximp.cpp +++ b/xfa/src/fwl/src/basewidget/fwl_pictureboximp.cpp @@ -9,9 +9,6 @@ #include "../core/include/fwl_noteimp.h" #include "../core/include/fwl_widgetimp.h" #include "include/fwl_pictureboximp.h" -IFWL_PictureBox* IFWL_PictureBox::Create() { - return new IFWL_PictureBox; -} IFWL_PictureBox::IFWL_PictureBox() { } FWL_ERR IFWL_PictureBox::Initialize(const CFWL_WidgetImpProperties& properties, diff --git a/xfa/src/fwl/src/basewidget/fwl_pushbuttonimp.cpp b/xfa/src/fwl/src/basewidget/fwl_pushbuttonimp.cpp index 6df34d9d61..8ddd93d272 100644 --- a/xfa/src/fwl/src/basewidget/fwl_pushbuttonimp.cpp +++ b/xfa/src/fwl/src/basewidget/fwl_pushbuttonimp.cpp @@ -9,9 +9,6 @@ #include "../core/include/fwl_noteimp.h" #include "../core/include/fwl_widgetimp.h" #include "include/fwl_pushbuttonimp.h" -IFWL_PushButton* IFWL_PushButton::Create() { - return new IFWL_PushButton; -} FWL_ERR IFWL_PushButton::Initialize(const CFWL_WidgetImpProperties& properties, IFWL_Widget* pOuter) { CFWL_PushButtonImp* pPushButtonImpl = diff --git a/xfa/src/fwl/src/basewidget/fwl_scrollbarimp.cpp b/xfa/src/fwl/src/basewidget/fwl_scrollbarimp.cpp index db84a56a9f..9a6521179c 100644 --- a/xfa/src/fwl/src/basewidget/fwl_scrollbarimp.cpp +++ b/xfa/src/fwl/src/basewidget/fwl_scrollbarimp.cpp @@ -11,9 +11,6 @@ #include "include/fwl_scrollbarimp.h" #define FWL_SCROLLBAR_Elapse 500 #define FWL_SCROLLBAR_MinThumb 5 -IFWL_ScrollBar* IFWL_ScrollBar::Create() { - return new IFWL_ScrollBar; -} IFWL_ScrollBar::IFWL_ScrollBar() { } FWL_ERR IFWL_ScrollBar::Initialize(const CFWL_WidgetImpProperties& properties, diff --git a/xfa/src/fwl/src/basewidget/fwl_spinbuttonimp.cpp b/xfa/src/fwl/src/basewidget/fwl_spinbuttonimp.cpp index 25bb6a14b6..7b1bf6aa44 100644 --- a/xfa/src/fwl/src/basewidget/fwl_spinbuttonimp.cpp +++ b/xfa/src/fwl/src/basewidget/fwl_spinbuttonimp.cpp @@ -12,9 +12,6 @@ #define FWL_SPN_MinWidth 18 #define FWL_SPN_MinHeight 32 #define FWL_SPIN_Elapse 200 -IFWL_SpinButton* IFWL_SpinButton::Create() { - return new IFWL_SpinButton; -} IFWL_SpinButton::IFWL_SpinButton() { } FWL_ERR IFWL_SpinButton::Initialize(const CFWL_WidgetImpProperties& properties, diff --git a/xfa/src/fwl/src/basewidget/fwl_tooltipctrlimp.cpp b/xfa/src/fwl/src/basewidget/fwl_tooltipctrlimp.cpp index 3c470a872d..f2079375dc 100644 --- a/xfa/src/fwl/src/basewidget/fwl_tooltipctrlimp.cpp +++ b/xfa/src/fwl/src/basewidget/fwl_tooltipctrlimp.cpp @@ -11,9 +11,6 @@ #include "../core/include/fwl_panelimp.h" #include "../core/include/fwl_formimp.h" #include "include/fwl_tooltipctrlimp.h" -IFWL_ToolTip* IFWL_ToolTip::Create() { - return new IFWL_ToolTip; -} FWL_ERR IFWL_ToolTip::Initialize(const CFWL_WidgetImpProperties& properties, IFWL_Widget* pOuter) { CFWL_ToolTipImp* pToolTipImpl = new CFWL_ToolTipImp(properties, pOuter); diff --git a/xfa/src/fwl/src/basewidget/include/fwl_comboboximp.h b/xfa/src/fwl/src/basewidget/include/fwl_comboboximp.h index f824fa1c2f..356276829e 100644 --- a/xfa/src/fwl/src/basewidget/include/fwl_comboboximp.h +++ b/xfa/src/fwl/src/basewidget/include/fwl_comboboximp.h @@ -6,6 +6,9 @@ #ifndef _FWL_COMBOBOX_IMP_H #define _FWL_COMBOBOX_IMP_H + +#include "third_party/base/nonstd_unique_ptr.h" + class CFWL_WidgetImp; class CFWL_WidgetImpProperties; class CFWL_WidgetImpDelegate; @@ -144,8 +147,6 @@ class CFWL_ComboBoxImp : public CFWL_WidgetImp { void ReSetListItemAlignment(); void ProcessSelChanged(FX_BOOL bLButtonUp); void InitProxyForm(); - - protected: FWL_ERR DisForm_Initialize(); void DisForm_InitComboList(); void DisForm_InitComboEdit(); @@ -160,15 +161,14 @@ class CFWL_ComboBoxImp : public CFWL_WidgetImp { FWL_ERR DisForm_GetBBox(CFX_RectF& rect); void DisForm_Layout(); - protected: CFX_RectF m_rtClient; CFX_RectF m_rtContent; CFX_RectF m_rtBtn; CFX_RectF m_rtList; CFX_RectF m_rtProxy; CFX_RectF m_rtHandler; - IFWL_Edit* m_pEdit; - IFWL_ListBox* m_pListBox; + nonstd::unique_ptr m_pEdit; + nonstd::unique_ptr m_pListBox; IFWL_Form* m_pForm; FX_BOOL m_bLButtonDown; FX_BOOL m_bUpFormHandler; diff --git a/xfa/src/fwl/src/basewidget/include/fwl_datetimepickerimp.h b/xfa/src/fwl/src/basewidget/include/fwl_datetimepickerimp.h index 5048601d0e..68eb898a63 100644 --- a/xfa/src/fwl/src/basewidget/include/fwl_datetimepickerimp.h +++ b/xfa/src/fwl/src/basewidget/include/fwl_datetimepickerimp.h @@ -6,6 +6,9 @@ #ifndef _FWL_DATETIMEPICKER_IMP_H #define _FWL_DATETIMEPICKER_IMP_H + +#include "third_party/base/nonstd_unique_ptr.h" + class CFWL_WidgetImp; class CFWL_WidgetImpProperties; class CFWL_WidgetImpDelegate; @@ -164,9 +167,9 @@ class CFWL_DateTimePickerImp : public CFWL_WidgetImp { int32_t m_iMonth; int32_t m_iDay; FX_BOOL m_bLBtnDown; - IFWL_DateTimeEdit* m_pEdit; - IFWL_DateTimeCalender* m_pMonthCal; - IFWL_DateTimeForm* m_pForm; + nonstd::unique_ptr m_pEdit; + nonstd::unique_ptr m_pMonthCal; + nonstd::unique_ptr m_pForm; FX_FLOAT m_fBtn; class CFWL_MonthCalendarImpDP : public IFWL_MonthCalendarDP { public: diff --git a/xfa/src/fwl/src/basewidget/include/fwl_editimp.h b/xfa/src/fwl/src/basewidget/include/fwl_editimp.h index 0000856963..486e47c3fd 100644 --- a/xfa/src/fwl/src/basewidget/include/fwl_editimp.h +++ b/xfa/src/fwl/src/basewidget/include/fwl_editimp.h @@ -6,6 +6,9 @@ #ifndef _FWL_EDIT_IMP_H #define _FWL_EDIT_IMP_H + +#include "third_party/base/nonstd_unique_ptr.h" + class CFWL_WidgetImp; class CFWL_WidgetImpProperties; class CFWL_WidgetImpDelegate; @@ -163,10 +166,9 @@ class CFWL_EditImp : public CFWL_WidgetImp, public IFDE_TxtEdtEventSink { FX_BOOL m_bSetRange; int32_t m_iMin; int32_t m_iMax; - IFWL_ScrollBar* m_pVertScrollBar; - IFWL_ScrollBar* m_pHorzScrollBar; - IFWL_Caret* m_pCaret; - IFWL_AdapterTextField* m_pTextField; + nonstd::unique_ptr m_pVertScrollBar; + nonstd::unique_ptr m_pHorzScrollBar; + nonstd::unique_ptr m_pCaret; CFX_WideString m_wsCache; friend class CFWL_TxtEdtEventSink; friend class CFWL_EditImpDelegate; diff --git a/xfa/src/fwl/src/basewidget/include/fwl_listboximp.h b/xfa/src/fwl/src/basewidget/include/fwl_listboximp.h index 4695a2caec..d441e5e6a5 100644 --- a/xfa/src/fwl/src/basewidget/include/fwl_listboximp.h +++ b/xfa/src/fwl/src/basewidget/include/fwl_listboximp.h @@ -6,6 +6,9 @@ #ifndef _FWL_LISTBOX_IMP_H #define _FWL_LISTBOX_IMP_H + +#include "third_party/base/nonstd_unique_ptr.h" + class CFWL_WidgetImp; class CFWL_WidgetImpProperties; class CFWL_WidgetImpDelegate; @@ -84,8 +87,8 @@ class CFWL_ListBoxImp : public CFWL_WidgetImp { CFX_RectF m_rtClient; CFX_RectF m_rtStatic; CFX_RectF m_rtConent; - IFWL_ScrollBar* m_pHorzScrollBar; - IFWL_ScrollBar* m_pVertScrollBar; + nonstd::unique_ptr m_pHorzScrollBar; + nonstd::unique_ptr m_pVertScrollBar; FX_DWORD m_dwTTOStyles; int32_t m_iTTOAligns; FWL_HLISTITEM m_hAnchor; diff --git a/xfa/src/fwl/src/core/fwl_contentimp.cpp b/xfa/src/fwl/src/core/fwl_contentimp.cpp index 130b4cb1a1..32235de65b 100644 --- a/xfa/src/fwl/src/core/fwl_contentimp.cpp +++ b/xfa/src/fwl/src/core/fwl_contentimp.cpp @@ -11,9 +11,6 @@ #include "include/fwl_widgetimp.h" #include "include/fwl_contentimp.h" #include "include/fwl_widgetmgrimp.h" -IFWL_Content* IFWL_Content::Create() { - return new IFWL_Content; -} FWL_ERR IFWL_Content::InsertWidget(IFWL_Widget* pChild, int32_t nIndex) { return static_cast(GetImpl())->InsertWidget(pChild, nIndex); } diff --git a/xfa/src/fwl/src/core/fwl_formimp.cpp b/xfa/src/fwl/src/core/fwl_formimp.cpp index 7a532ec887..1e236567e8 100644 --- a/xfa/src/fwl/src/core/fwl_formimp.cpp +++ b/xfa/src/fwl/src/core/fwl_formimp.cpp @@ -17,9 +17,6 @@ #define FWL_SYSBTNMARGIN 5 #define FWL_SYSBTNSPAN 2 #define FWL_CornerEnlarge 10 -IFWL_Form* IFWL_Form::Create() { - return new IFWL_Form; -} FWL_ERR IFWL_Form::Initialize(CFWL_WidgetImpProperties& properties, CFX_WideString* classname, IFWL_Widget* pOuter) { diff --git a/xfa/src/fwl/src/core/fwl_gridimp.cpp b/xfa/src/fwl/src/core/fwl_gridimp.cpp index d647fe5a99..1d9c5d68a8 100644 --- a/xfa/src/fwl/src/core/fwl_gridimp.cpp +++ b/xfa/src/fwl/src/core/fwl_gridimp.cpp @@ -11,9 +11,6 @@ #include "include/fwl_widgetimp.h" #include "include/fwl_contentimp.h" #include "include/fwl_gridimp.h" -IFWL_Grid* IFWL_Grid::Create() { - return new IFWL_Grid; -} FWL_ERR IFWL_Grid::Initialize(CFWL_WidgetImpProperties& properties) { CFWL_GridImp* pGridImpl = new CFWL_GridImp(properties); SetImpl(pGridImpl); diff --git a/xfa/src/fwl/src/core/fwl_noteimp.cpp b/xfa/src/fwl/src/core/fwl_noteimp.cpp index 149b80f26c..4bc28b87dd 100644 --- a/xfa/src/fwl/src/core/fwl_noteimp.cpp +++ b/xfa/src/fwl/src/core/fwl_noteimp.cpp @@ -937,13 +937,9 @@ CFWL_ToolTipContainer::~CFWL_ToolTipContainer() { if (m_pToolTipImp) { IFWL_ToolTip* pToolTip = (IFWL_ToolTip*)m_pToolTipImp->GetInterface(); pToolTip->Finalize(); - pToolTip->Release(); - m_pToolTipImp = NULL; - } - if (m_ToolTipDp) { - delete m_ToolTipDp; - m_ToolTipDp = NULL; + delete pToolTip; } + delete m_ToolTipDp; } // static CFWL_ToolTipContainer* CFWL_ToolTipContainer::getInstance() { @@ -996,7 +992,7 @@ FX_BOOL CFWL_ToolTipContainer::ProcessEnter(CFWL_EvtMouse* pEvt, rtTooltip.Set(150, 150, 100, 50); prop.m_rtWidget = rtTooltip; m_pToolTipImp = new CFWL_ToolTipImp(prop); - IFWL_ToolTip* pToolTip = IFWL_ToolTip::Create(); + IFWL_ToolTip* pToolTip = new IFWL_ToolTip; m_pToolTipImp->SetInterface(pToolTip); pToolTip->SetImpl(m_pToolTipImp); m_pToolTipImp->Initialize(); diff --git a/xfa/src/fwl/src/core/fwl_panelimp.cpp b/xfa/src/fwl/src/core/fwl_panelimp.cpp index 991ce226ab..70cb5882d0 100644 --- a/xfa/src/fwl/src/core/fwl_panelimp.cpp +++ b/xfa/src/fwl/src/core/fwl_panelimp.cpp @@ -9,9 +9,6 @@ #include "include/fwl_noteimp.h" #include "include/fwl_widgetimp.h" #include "include/fwl_panelimp.h" -IFWL_Panel* IFWL_Panel::Create() { - return new IFWL_Panel; -} FWL_ERR IFWL_Panel::Initialize(CFWL_WidgetImpProperties& properties, IFWL_Widget* pOuter) { CFWL_PanelImp* pPanelImpl = new CFWL_PanelImp(properties, pOuter); @@ -130,9 +127,6 @@ FWL_ERR CFWL_CustomPanelImp::SetProxy(IFWL_Proxy* pProxy) { m_pProxy = pProxy; return FWL_ERR_Succeeded; } -IFWL_CustomPanel* IFWL_CustomPanel::Create() { - return new IFWL_CustomPanel; -} FWL_ERR IFWL_CustomPanel::Initialize(CFWL_WidgetImpProperties& properties, IFWL_Widget* pOuter) { CFWL_CustomPanelImp* pCustomPanelImpl = diff --git a/xfa/src/fwl/src/core/fwl_targetimp.cpp b/xfa/src/fwl/src/core/fwl_targetimp.cpp index 0ae40d11f4..dde102159b 100644 --- a/xfa/src/fwl/src/core/fwl_targetimp.cpp +++ b/xfa/src/fwl/src/core/fwl_targetimp.cpp @@ -6,20 +6,6 @@ #include "../../../foxitlib.h" #include "include/fwl_targetimp.h" -FX_DWORD IFWL_Target::Release() { - FX_DWORD dwRef = m_pImpl->Release(); - if (!dwRef) { - m_pImpl = nullptr; - delete this; - } - return dwRef; -} -IFWL_Target* IFWL_Target::Retain() { - return m_pImpl->Retain(); -} -FX_DWORD IFWL_Target::GetRefCount() const { - return m_pImpl->GetRefCount(); -} FWL_ERR IFWL_Target::GetClassName(CFX_WideString& wsClass) const { return m_pImpl->GetClassName(wsClass); } @@ -38,25 +24,9 @@ FWL_ERR IFWL_Target::Finalize() { IFWL_Target::~IFWL_Target() { delete m_pImpl; } -CFWL_TargetImp::CFWL_TargetImp() : m_dwRefCount(1) { -} +CFWL_TargetImp::CFWL_TargetImp() {} CFWL_TargetImp::~CFWL_TargetImp() { } -FX_DWORD CFWL_TargetImp::Release() { - m_dwRefCount--; - FX_DWORD dwRet = m_dwRefCount; - if (!m_dwRefCount) { - delete this; - } - return dwRet; -} -IFWL_Target* CFWL_TargetImp::Retain() { - m_dwRefCount++; - return (IFWL_Target*)this; -} -FX_DWORD CFWL_TargetImp::GetRefCount() const { - return m_dwRefCount; -} FWL_ERR CFWL_TargetImp::GetClassName(CFX_WideString& wsClass) const { return FWL_ERR_Succeeded; } diff --git a/xfa/src/fwl/src/core/fwl_widgetimp.cpp b/xfa/src/fwl/src/core/fwl_widgetimp.cpp index 2e6d5b30ed..92725ae3ff 100644 --- a/xfa/src/fwl/src/core/fwl_widgetimp.cpp +++ b/xfa/src/fwl/src/core/fwl_widgetimp.cpp @@ -1071,9 +1071,6 @@ FWL_ERR CFWL_CustomImp::SetProxy(IFWL_Proxy* pProxy) { m_pProxy = pProxy; return FWL_ERR_Succeeded; } -IFWL_Custom* IFWL_Custom::Create() { - return new IFWL_Custom; -} IFWL_Custom::IFWL_Custom() { } FWL_ERR IFWL_Custom::Initialize(const CFWL_WidgetImpProperties& properties, diff --git a/xfa/src/fwl/src/core/include/fwl_targetimp.h b/xfa/src/fwl/src/core/include/fwl_targetimp.h index 5f494a78e2..d0a6caa308 100644 --- a/xfa/src/fwl/src/core/include/fwl_targetimp.h +++ b/xfa/src/fwl/src/core/include/fwl_targetimp.h @@ -14,9 +14,6 @@ class CFWL_TargetImp { public: virtual ~CFWL_TargetImp(); - virtual FX_DWORD Release(); - virtual IFWL_Target* Retain(); - virtual FX_DWORD GetRefCount() const; virtual FWL_ERR GetClassName(CFX_WideString& wsClass) const; virtual FX_DWORD GetClassID() const; virtual FX_BOOL IsInstance(const CFX_WideStringC& wsClass) const; @@ -25,7 +22,6 @@ class CFWL_TargetImp { protected: CFWL_TargetImp(); - FX_DWORD m_dwRefCount; }; #endif // FWL_TARGETIMP_H_ diff --git a/xfa/src/fwl/src/lightwidget/barcode.cpp b/xfa/src/fwl/src/lightwidget/barcode.cpp index 5426cb5eb6..d0f3be46f3 100644 --- a/xfa/src/fwl/src/lightwidget/barcode.cpp +++ b/xfa/src/fwl/src/lightwidget/barcode.cpp @@ -14,7 +14,7 @@ FWL_ERR CFWL_Barcode::Initialize(const CFWL_WidgetProperties* pProperties) { if (pProperties) { *m_pProperties = *pProperties; } - m_pIface = IFWL_Barcode::Create(); + m_pIface = new IFWL_Barcode; FWL_ERR ret = ((IFWL_Barcode*)m_pIface) ->Initialize(m_pProperties->MakeWidgetImpProperties(&m_barcodeData), diff --git a/xfa/src/fwl/src/lightwidget/caret.cpp b/xfa/src/fwl/src/lightwidget/caret.cpp index 48bc18a82d..cb318d9a58 100644 --- a/xfa/src/fwl/src/lightwidget/caret.cpp +++ b/xfa/src/fwl/src/lightwidget/caret.cpp @@ -14,7 +14,7 @@ FWL_ERR CFWL_Caret::Initialize(const CFWL_WidgetProperties* pProperties) { if (pProperties) { *m_pProperties = *pProperties; } - m_pIface = IFWL_Caret::Create(); + m_pIface = new IFWL_Caret; FWL_ERR ret = ((IFWL_Caret*)m_pIface) ->Initialize(m_pProperties->MakeWidgetImpProperties(nullptr), diff --git a/xfa/src/fwl/src/lightwidget/checkbox.cpp b/xfa/src/fwl/src/lightwidget/checkbox.cpp index 7ec0c515bd..296a2635ea 100644 --- a/xfa/src/fwl/src/lightwidget/checkbox.cpp +++ b/xfa/src/fwl/src/lightwidget/checkbox.cpp @@ -27,7 +27,7 @@ FWL_ERR CFWL_CheckBox::Initialize(const CFWL_WidgetProperties* pProperties) { if (m_pProperties->m_pOwner) { prop.m_pOwner = m_pProperties->m_pOwner->GetWidget(); } - m_pIface = IFWL_CheckBox::Create(); + m_pIface = new IFWL_CheckBox; FWL_ERR ret = ((IFWL_CheckBox*)m_pIface)->Initialize(prop, nullptr); if (ret == FWL_ERR_Succeeded) { CFWL_Widget::Initialize(); diff --git a/xfa/src/fwl/src/lightwidget/combobox.cpp b/xfa/src/fwl/src/lightwidget/combobox.cpp index 6335df58a3..b758883321 100644 --- a/xfa/src/fwl/src/lightwidget/combobox.cpp +++ b/xfa/src/fwl/src/lightwidget/combobox.cpp @@ -14,7 +14,7 @@ FWL_ERR CFWL_ComboBox::Initialize(const CFWL_WidgetProperties* pProperties) { if (pProperties) { *m_pProperties = *pProperties; } - m_pIface = IFWL_ComboBox::Create(); + m_pIface = new IFWL_ComboBox; FWL_ERR ret = ((IFWL_ComboBox*)m_pIface) ->Initialize(m_pProperties->MakeWidgetImpProperties(&m_comboBoxData), diff --git a/xfa/src/fwl/src/lightwidget/datetimepicker.cpp b/xfa/src/fwl/src/lightwidget/datetimepicker.cpp index a1f5493049..60e0e30b4e 100644 --- a/xfa/src/fwl/src/lightwidget/datetimepicker.cpp +++ b/xfa/src/fwl/src/lightwidget/datetimepicker.cpp @@ -15,7 +15,7 @@ FWL_ERR CFWL_DateTimePicker::Initialize( if (pProperties) { *m_pProperties = *pProperties; } - m_pIface = IFWL_DateTimePicker::Create(); + m_pIface = new IFWL_DateTimePicker; FWL_ERR ret = ((IFWL_DateTimePicker*)m_pIface) ->Initialize( diff --git a/xfa/src/fwl/src/lightwidget/edit.cpp b/xfa/src/fwl/src/lightwidget/edit.cpp index 6fb3429725..8e89e6474b 100644 --- a/xfa/src/fwl/src/lightwidget/edit.cpp +++ b/xfa/src/fwl/src/lightwidget/edit.cpp @@ -14,7 +14,7 @@ FWL_ERR CFWL_Edit::Initialize(const CFWL_WidgetProperties* pProperties) { if (pProperties) { *m_pProperties = *pProperties; } - m_pIface = IFWL_Edit::Create(); + m_pIface = new IFWL_Edit; FWL_ERR ret = ((IFWL_Edit*)m_pIface) ->Initialize(m_pProperties->MakeWidgetImpProperties(nullptr), diff --git a/xfa/src/fwl/src/lightwidget/listbox.cpp b/xfa/src/fwl/src/lightwidget/listbox.cpp index 1507d50ea2..cd8c3305e9 100644 --- a/xfa/src/fwl/src/lightwidget/listbox.cpp +++ b/xfa/src/fwl/src/lightwidget/listbox.cpp @@ -14,7 +14,7 @@ FWL_ERR CFWL_ListBox::Initialize(const CFWL_WidgetProperties* pProperties) { if (pProperties) { *m_pProperties = *pProperties; } - m_pIface = IFWL_ListBox::Create(); + m_pIface = new IFWL_ListBox; FWL_ERR ret = ((IFWL_ListBox*)m_pIface) ->Initialize(m_pProperties->MakeWidgetImpProperties(&m_ListBoxDP), diff --git a/xfa/src/fwl/src/lightwidget/picturebox.cpp b/xfa/src/fwl/src/lightwidget/picturebox.cpp index 5ccefa9076..7d8e201d85 100644 --- a/xfa/src/fwl/src/lightwidget/picturebox.cpp +++ b/xfa/src/fwl/src/lightwidget/picturebox.cpp @@ -14,7 +14,7 @@ FWL_ERR CFWL_PictureBox::Initialize(const CFWL_WidgetProperties* pProperties) { if (pProperties) { *m_pProperties = *pProperties; } - m_pIface = IFWL_PictureBox::Create(); + m_pIface = new IFWL_PictureBox; FWL_ERR ret = ((IFWL_PictureBox*)m_pIface) ->Initialize(m_pProperties->MakeWidgetImpProperties(&m_PictureBoxDP), diff --git a/xfa/src/fwl/src/lightwidget/pushbutton.cpp b/xfa/src/fwl/src/lightwidget/pushbutton.cpp index 28a7fa5d33..24050c8666 100644 --- a/xfa/src/fwl/src/lightwidget/pushbutton.cpp +++ b/xfa/src/fwl/src/lightwidget/pushbutton.cpp @@ -14,7 +14,7 @@ FWL_ERR CFWL_PushButton::Initialize(const CFWL_WidgetProperties* pProperties) { if (pProperties) { *m_pProperties = *pProperties; } - m_pIface = IFWL_PushButton::Create(); + m_pIface = new IFWL_PushButton; FWL_ERR ret = ((IFWL_PushButton*)m_pIface) ->Initialize(m_pProperties->MakeWidgetImpProperties(&m_buttonData), diff --git a/xfa/src/fwl/src/lightwidget/scrollbar.cpp b/xfa/src/fwl/src/lightwidget/scrollbar.cpp index bb346a4728..eaf9b575ef 100644 --- a/xfa/src/fwl/src/lightwidget/scrollbar.cpp +++ b/xfa/src/fwl/src/lightwidget/scrollbar.cpp @@ -14,7 +14,7 @@ FWL_ERR CFWL_ScrollBar::Initialize(const CFWL_WidgetProperties* pProperties) { if (pProperties) { *m_pProperties = *pProperties; } - m_pIface = IFWL_ScrollBar::Create(); + m_pIface = new IFWL_ScrollBar; FWL_ERR ret = ((IFWL_ScrollBar*)m_pIface) ->Initialize(m_pProperties->MakeWidgetImpProperties(nullptr), diff --git a/xfa/src/fwl/src/lightwidget/tooltipctrl.cpp b/xfa/src/fwl/src/lightwidget/tooltipctrl.cpp index f51ec221a0..19ca2cb94f 100644 --- a/xfa/src/fwl/src/lightwidget/tooltipctrl.cpp +++ b/xfa/src/fwl/src/lightwidget/tooltipctrl.cpp @@ -20,7 +20,7 @@ FWL_ERR CFWL_ToolTip::Initialize(const CFWL_WidgetProperties* pProperties) { if (pProperties) { *m_pProperties = *pProperties; } - m_pIface = IFWL_ToolTip::Create(); + m_pIface = new IFWL_ToolTip; FWL_ERR ret = ((IFWL_ToolTip*)m_pIface) ->Initialize(m_pProperties->MakeWidgetImpProperties(&m_tooltipData), diff --git a/xfa/src/fwl/src/lightwidget/widget.cpp b/xfa/src/fwl/src/lightwidget/widget.cpp index 6aeafcef74..b3e5953a2c 100644 --- a/xfa/src/fwl/src/lightwidget/widget.cpp +++ b/xfa/src/fwl/src/lightwidget/widget.cpp @@ -29,31 +29,6 @@ CFWL_WidgetImpProperties CFWL_WidgetProperties::MakeWidgetImpProperties( IFWL_Widget* CFWL_Widget::GetWidget() { return m_pIface; } -FX_DWORD CFWL_Widget::Release() { - if (!m_pIface) - return 0; - FX_DWORD dwRef = m_pIface->GetRefCount(); - if (dwRef == 1) { - m_pIface->Finalize(); - } - m_pIface->Release(); - if (dwRef == 1) { - m_pIface = NULL; - delete this; - } - return dwRef - 1; -} -CFWL_Widget* CFWL_Widget::Retain() { - if (!m_pIface) - return NULL; - m_pIface->Retain(); - return this; -} -FX_DWORD CFWL_Widget::GetRefCount() const { - if (!m_pIface) - return 1; - return m_pIface->GetRefCount(); -} FWL_ERR CFWL_Widget::GetClassName(CFX_WideString& wsClass) const { if (!m_pIface) return FWL_ERR_Indefinite; @@ -222,14 +197,10 @@ CFWL_Widget::CFWL_Widget() FXSYS_assert(m_pWidgetMgr != NULL); } CFWL_Widget::~CFWL_Widget() { - if (m_pProperties) { - delete m_pProperties; - m_pProperties = NULL; - } + delete m_pProperties; if (m_pIface) { m_pIface->Finalize(); - m_pIface->Release(); - m_pIface = NULL; + delete m_pIface; } } FWL_ERR CFWL_Widget::Repaint(const CFX_RectF* pRect) { -- cgit v1.2.3