diff options
author | Tom Sepez <tsepez@chromium.org> | 2018-10-26 21:27:41 +0000 |
---|---|---|
committer | Chromium commit bot <commit-bot@chromium.org> | 2018-10-26 21:27:41 +0000 |
commit | 8fba261fb6584169c5788326dd49e91bc9babda5 (patch) | |
tree | c3a66ab343f20c15427f131c320d1e77afd7aac8 /fpdfsdk/pwl/cpwl_wnd.cpp | |
parent | d0ad4a785dbaf71ab0ccf626c7ef38c692484a60 (diff) | |
download | pdfium-8fba261fb6584169c5788326dd49e91bc9babda5.tar.xz |
Remove pParentWnd field entirely from CreateParams.
Put it into CPWL_Wnd directly, and set/clear it when a child
is added/removed from a parent.
Change-Id: I7a8cd0cf22dbd6173e64bec5d844df56ad373722
Reviewed-on: https://pdfium-review.googlesource.com/c/44692
Reviewed-by: Lei Zhang <thestig@chromium.org>
Commit-Queue: Tom Sepez <tsepez@chromium.org>
Diffstat (limited to 'fpdfsdk/pwl/cpwl_wnd.cpp')
-rw-r--r-- | fpdfsdk/pwl/cpwl_wnd.cpp | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/fpdfsdk/pwl/cpwl_wnd.cpp b/fpdfsdk/pwl/cpwl_wnd.cpp index d5d2102997..66e5cfa0b6 100644 --- a/fpdfsdk/pwl/cpwl_wnd.cpp +++ b/fpdfsdk/pwl/cpwl_wnd.cpp @@ -173,9 +173,8 @@ void CPWL_Wnd::Destroy() { delete pChild; } } - if (m_CreationParams.pParentWnd) - m_CreationParams.pParentWnd->RemoveChild(this); - + if (m_pParent) + m_pParent->RemoveChild(this); m_bCreated = false; } DestroyMsgControl(); @@ -379,10 +378,14 @@ bool CPWL_Wnd::OnMouseWheel(short zDelta, } void CPWL_Wnd::AddChild(CPWL_Wnd* pWnd) { + ASSERT(!pWnd->m_pParent); + pWnd->m_pParent = this; m_Children.push_back(pWnd); } void CPWL_Wnd::RemoveChild(CPWL_Wnd* pWnd) { + ASSERT(pWnd->m_pParent == this); + pWnd->m_pParent = nullptr; for (auto it = m_Children.rbegin(); it != m_Children.rend(); ++it) { if (*it && *it == pWnd) { m_Children.erase(std::next(it).base()); @@ -492,7 +495,6 @@ void CPWL_Wnd::CreateVScrollBar(const CreateParams& cp) { scp.dwFlags = PWS_CHILD | PWS_BACKGROUND | PWS_AUTOTRANSPARENT | PWS_NOREFRESHCLIP; - scp.pParentWnd = this; scp.sBackgroundColor = PWL_DEFAULT_WHITECOLOR; scp.eCursorType = FXCT_ARROW; scp.nTransparency = PWL_SCROLLBAR_TRANSPARENCY; |