Remove CFWL_ComboBox::InitComboEdit() and InitComboList(). Create these in the constructor and mark the corresponding members as const. In turn, remove all constructors from CFWL_Widget::Properties, so that the brace-initialized forms will work. Change-Id: I4bfd5feb845d5ba048b5b77a9d0b967efdf26393 Reviewed-on: https://pdfium-review.googlesource.com/c/pdfium/+/72890 Reviewed-by: Lei Zhang <thestig@chromium.org> Commit-Queue: Tom Sepez <tsepez@chromium.org>
diff --git a/xfa/fwl/cfwl_combobox.cpp b/xfa/fwl/cfwl_combobox.cpp index d2ce0af..d3e9949 100644 --- a/xfa/fwl/cfwl_combobox.cpp +++ b/xfa/fwl/cfwl_combobox.cpp
@@ -29,10 +29,13 @@ #include "xfa/fwl/ifwl_themeprovider.h" CFWL_ComboBox::CFWL_ComboBox(const CFWL_App* app) - : CFWL_Widget(app, Properties(), nullptr) { - InitComboList(); - InitComboEdit(); -} + : CFWL_Widget(app, Properties(), nullptr), + m_pEdit(std::make_unique<CFWL_ComboEdit>(app, Properties(), this)), + m_pListBox(std::make_unique<CFWL_ComboList>( + app, + Properties{FWL_WGTSTYLE_Border | FWL_WGTSTYLE_VScroll, 0, + FWL_WGTSTATE_Invisible}, + this)) {} CFWL_ComboBox::~CFWL_ComboBox() = default; @@ -54,19 +57,15 @@ void CFWL_ComboBox::ModifyStylesEx(uint32_t dwStylesExAdded, uint32_t dwStylesExRemoved) { - if (!m_pEdit) - InitComboEdit(); - bool bAddDropDown = !!(dwStylesExAdded & FWL_STYLEEXT_CMB_DropDown); bool bDelDropDown = !!(dwStylesExRemoved & FWL_STYLEEXT_CMB_DropDown); - dwStylesExRemoved &= ~FWL_STYLEEXT_CMB_DropDown; m_Properties.m_dwStyleExes |= FWL_STYLEEXT_CMB_DropDown; - if (bAddDropDown) m_pEdit->ModifyStylesEx(0, FWL_STYLEEXT_EDT_ReadOnly); else if (bDelDropDown) m_pEdit->ModifyStylesEx(FWL_STYLEEXT_EDT_ReadOnly, 0); + CFWL_Widget::ModifyStylesEx(dwStylesExAdded, dwStylesExRemoved); } @@ -373,23 +372,6 @@ DispatchEvent(&ev); } -void CFWL_ComboBox::InitComboList() { - if (m_pListBox) - return; - - Properties prop; - prop.m_dwStyles = FWL_WGTSTYLE_Border | FWL_WGTSTYLE_VScroll; - prop.m_dwStates = FWL_WGTSTATE_Invisible; - m_pListBox = std::make_unique<CFWL_ComboList>(GetFWLApp(), prop, this); -} - -void CFWL_ComboBox::InitComboEdit() { - if (m_pEdit) - return; - - m_pEdit = std::make_unique<CFWL_ComboEdit>(GetFWLApp(), Properties(), this); -} - void CFWL_ComboBox::OnProcessMessage(CFWL_Message* pMessage) { bool backDefault = true; switch (pMessage->GetType()) {
diff --git a/xfa/fwl/cfwl_combobox.h b/xfa/fwl/cfwl_combobox.h index 3c7b7ae..6f9293b 100644 --- a/xfa/fwl/cfwl_combobox.h +++ b/xfa/fwl/cfwl_combobox.h
@@ -107,9 +107,6 @@ const CFX_RectF& rtAnchor, CFX_RectF* pPopupRect); void OnLButtonUp(CFWL_MessageMouse* pMsg); - - void InitComboList(); - void InitComboEdit(); bool IsDropListVisible() const { return m_pListBox->IsVisible(); } void OnLButtonDown(CFWL_MessageMouse* pMsg); void OnFocusChanged(CFWL_Message* pMsg, bool bSet); @@ -118,8 +115,8 @@ CFX_RectF m_ClientRect; CFX_RectF m_ContentRect; CFX_RectF m_BtnRect; - std::unique_ptr<CFWL_ComboEdit> m_pEdit; - std::unique_ptr<CFWL_ComboList> m_pListBox; + std::unique_ptr<CFWL_ComboEdit> const m_pEdit; + std::unique_ptr<CFWL_ComboList> const m_pListBox; int32_t m_iCurSel = -1; int32_t m_iBtnState = CFWL_PartState_Normal; };
diff --git a/xfa/fwl/cfwl_widget.cpp b/xfa/fwl/cfwl_widget.cpp index d966921..2d4de85 100644 --- a/xfa/fwl/cfwl_widget.cpp +++ b/xfa/fwl/cfwl_widget.cpp
@@ -347,12 +347,6 @@ void CFWL_Widget::OnDrawWidget(CXFA_Graphics* pGraphics, const CFX_Matrix& matrix) {} -CFWL_Widget::Properties::Properties() = default; - -CFWL_Widget::Properties::Properties(const Properties& that) = default; - -CFWL_Widget::Properties::~Properties() = default; - CFWL_Widget::ScopedUpdateLock::ScopedUpdateLock(CFWL_Widget* widget) : widget_(widget) { widget_->LockUpdate();
diff --git a/xfa/fwl/cfwl_widget.h b/xfa/fwl/cfwl_widget.h index a260734..1c504a6 100644 --- a/xfa/fwl/cfwl_widget.h +++ b/xfa/fwl/cfwl_widget.h
@@ -59,10 +59,6 @@ class Properties { public: - Properties(); - Properties(const Properties& that); - ~Properties(); - uint32_t m_dwStyles = FWL_WGTSTYLE_Child; uint32_t m_dwStyleExes = 0; uint32_t m_dwStates = 0;