diff options
author | Tom Sepez <tsepez@chromium.org> | 2018-10-25 23:25:58 +0000 |
---|---|---|
committer | Chromium commit bot <commit-bot@chromium.org> | 2018-10-25 23:25:58 +0000 |
commit | 6fe32f898af3eea875fd01a6d18f719d17dd72f3 (patch) | |
tree | f63a1a03d3fffc3e4e765442df9805b526660765 /fpdfsdk/pwl/cpwl_combo_box.cpp | |
parent | ed7da31f67e93c8923669ad496126aa005a8d3a2 (diff) | |
download | pdfium-6fe32f898af3eea875fd01a6d18f719d17dd72f3.tar.xz |
Make CPWL_Wnd own its pAttachedData.
This requires moving it out of CreateParams, since that must be
a copyable struct, and implies that currently there is some
questionable sharing going on. To resolve this, introduce a
Clone() method so that each window gets its own copy.
Make GetAttachedData() return a const pointer, so that callers
can't free it behind our back.
Tidy initializations along the way.
Change-Id: Iadc97688b4692bf4fafefe8cff88af88672f7110
Reviewed-on: https://pdfium-review.googlesource.com/c/44590
Commit-Queue: Tom Sepez <tsepez@chromium.org>
Reviewed-by: Lei Zhang <thestig@chromium.org>
Diffstat (limited to 'fpdfsdk/pwl/cpwl_combo_box.cpp')
-rw-r--r-- | fpdfsdk/pwl/cpwl_combo_box.cpp | 24 |
1 files changed, 17 insertions, 7 deletions
diff --git a/fpdfsdk/pwl/cpwl_combo_box.cpp b/fpdfsdk/pwl/cpwl_combo_box.cpp index 341bd93e41..bb5890b519 100644 --- a/fpdfsdk/pwl/cpwl_combo_box.cpp +++ b/fpdfsdk/pwl/cpwl_combo_box.cpp @@ -8,6 +8,7 @@ #include <algorithm> #include <sstream> +#include <utility> #include "core/fxge/cfx_pathdata.h" #include "core/fxge/cfx_renderdevice.h" @@ -26,6 +27,11 @@ constexpr int kDefaultButtonWidth = 13; } // namespace +CPWL_CBListBox::CPWL_CBListBox(std::unique_ptr<PrivateData> pAttachedData) + : CPWL_ListBox(std::move(pAttachedData)) {} + +CPWL_CBListBox::~CPWL_CBListBox() = default; + bool CPWL_CBListBox::OnLButtonUp(const CFX_PointF& point, uint32_t nFlag) { CPWL_Wnd::OnLButtonUp(point, nFlag); @@ -94,6 +100,11 @@ bool CPWL_CBListBox::OnCharNotify(uint16_t nChar, uint32_t nFlag) { return OnNotifySelectionChanged(true, nFlag); } +CPWL_CBButton::CPWL_CBButton(std::unique_ptr<PrivateData> pAttachedData) + : CPWL_Wnd(std::move(pAttachedData)) {} + +CPWL_CBButton::~CPWL_CBButton() = default; + void CPWL_CBButton::DrawThisAppearance(CFX_RenderDevice* pDevice, const CFX_Matrix& mtUser2Device) { CPWL_Wnd::DrawThisAppearance(pDevice, mtUser2Device); @@ -132,7 +143,6 @@ bool CPWL_CBButton::OnLButtonDown(const CFX_PointF& point, uint32_t nFlag) { CPWL_Wnd::OnLButtonDown(point, nFlag); SetCapture(); - if (CPWL_Wnd* pParent = GetParentWindow()) pParent->NotifyLButtonDown(this, point); @@ -143,13 +153,13 @@ bool CPWL_CBButton::OnLButtonUp(const CFX_PointF& point, uint32_t nFlag) { CPWL_Wnd::OnLButtonUp(point, nFlag); ReleaseCapture(); - return true; } -CPWL_ComboBox::CPWL_ComboBox() {} +CPWL_ComboBox::CPWL_ComboBox(std::unique_ptr<PrivateData> pAttachedData) + : CPWL_Wnd(std::move(pAttachedData)) {} -CPWL_ComboBox::~CPWL_ComboBox() {} +CPWL_ComboBox::~CPWL_ComboBox() = default; void CPWL_ComboBox::OnCreate(CreateParams* pParamsToAdjust) { pParamsToAdjust->dwFlags &= ~PWS_HSCROLL; @@ -262,7 +272,7 @@ void CPWL_ComboBox::CreateEdit(const CreateParams& cp) { if (m_pEdit) return; - m_pEdit = new CPWL_Edit(); + m_pEdit = new CPWL_Edit(CloneAttachedData()); m_pEdit->AttachFFLData(m_pFormFiller.Get()); CreateParams ecp = cp; @@ -286,7 +296,7 @@ void CPWL_ComboBox::CreateButton(const CreateParams& cp) { if (m_pButton) return; - m_pButton = new CPWL_CBButton; + m_pButton = new CPWL_CBButton(CloneAttachedData()); CreateParams bcp = cp; bcp.pParentWnd = this; @@ -304,7 +314,7 @@ void CPWL_ComboBox::CreateListBox(const CreateParams& cp) { if (m_pList) return; - m_pList = new CPWL_CBListBox(); + m_pList = new CPWL_CBListBox(CloneAttachedData()); m_pList->AttachFFLData(m_pFormFiller.Get()); CreateParams lcp = cp; |