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_wnd.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_wnd.cpp')
-rw-r--r-- | fpdfsdk/pwl/cpwl_wnd.cpp | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/fpdfsdk/pwl/cpwl_wnd.cpp b/fpdfsdk/pwl/cpwl_wnd.cpp index 1fc2bd8157..6767164073 100644 --- a/fpdfsdk/pwl/cpwl_wnd.cpp +++ b/fpdfsdk/pwl/cpwl_wnd.cpp @@ -8,6 +8,7 @@ #include <map> #include <sstream> +#include <utility> #include <vector> #include "core/fxge/cfx_renderdevice.h" @@ -110,13 +111,8 @@ class CPWL_MsgControl final : public Observable<CPWL_MsgControl> { UnownedPtr<CPWL_Wnd> m_pMainKeyboardWnd; }; -CPWL_Wnd::CPWL_Wnd() - : m_rcWindow(), - m_rcClip(), - m_bCreated(false), - m_bVisible(false), - m_bNotifying(false), - m_bEnabled(true) {} +CPWL_Wnd::CPWL_Wnd(std::unique_ptr<PrivateData> pAttachedData) + : m_pAttachedData(std::move(pAttachedData)) {} CPWL_Wnd::~CPWL_Wnd() { ASSERT(!m_bCreated); @@ -504,7 +500,7 @@ void CPWL_Wnd::CreateVScrollBar(const CreateParams& cp) { scp.eCursorType = FXCT_ARROW; scp.nTransparency = PWL_SCROLLBAR_TRANSPARENCY; - m_pVScrollBar = new CPWL_ScrollBar(SBT_VSCROLL); + m_pVScrollBar = new CPWL_ScrollBar(CloneAttachedData(), SBT_VSCROLL); m_pVScrollBar->Create(scp); } @@ -541,6 +537,10 @@ void CPWL_Wnd::OnSetFocus() {} void CPWL_Wnd::OnKillFocus() {} +std::unique_ptr<CPWL_Wnd::PrivateData> CPWL_Wnd::CloneAttachedData() const { + return m_pAttachedData ? m_pAttachedData->Clone() : nullptr; +} + bool CPWL_Wnd::WndHitTest(const CFX_PointF& point) const { return IsValid() && IsVisible() && GetWindowRect().Contains(point); } |