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/formfiller/cffl_interactiveformfiller.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/formfiller/cffl_interactiveformfiller.cpp')
-rw-r--r-- | fpdfsdk/formfiller/cffl_interactiveformfiller.cpp | 32 |
1 files changed, 21 insertions, 11 deletions
diff --git a/fpdfsdk/formfiller/cffl_interactiveformfiller.cpp b/fpdfsdk/formfiller/cffl_interactiveformfiller.cpp index c712610dcc..b578a440b7 100644 --- a/fpdfsdk/formfiller/cffl_interactiveformfiller.cpp +++ b/fpdfsdk/formfiller/cffl_interactiveformfiller.cpp @@ -570,12 +570,12 @@ void CFFL_InteractiveFormFiller::UnRegisterFormFiller(CPDFSDK_Annot* pAnnot) { } void CFFL_InteractiveFormFiller::QueryWherePopup( - CPWL_Wnd::PrivateData* pAttached, + const CPWL_Wnd::PrivateData* pAttached, float fPopupMin, float fPopupMax, bool* bBottom, float* fPopupRet) { - auto* pData = static_cast<CFFL_PrivateData*>(pAttached); + auto* pData = static_cast<const CFFL_PrivateData*>(pAttached); CPDFSDK_Widget* pWidget = pData->pWidget; CPDF_Page* pPage = pWidget->GetPDFPage(); @@ -795,10 +795,9 @@ bool CFFL_InteractiveFormFiller::OnFull(CPDFSDK_Annot::ObservedPtr* pAnnot, } bool CFFL_InteractiveFormFiller::OnPopupPreOpen( - CPWL_Wnd::PrivateData* pAttached, + const CPWL_Wnd::PrivateData* pAttached, uint32_t nFlag) { - auto* pData = static_cast<CFFL_PrivateData*>(pAttached); - ASSERT(pData); + auto* pData = static_cast<const CFFL_PrivateData*>(pAttached); ASSERT(pData->pWidget); CPDFSDK_Annot::ObservedPtr pObserved(pData->pWidget); @@ -806,10 +805,9 @@ bool CFFL_InteractiveFormFiller::OnPopupPreOpen( } bool CFFL_InteractiveFormFiller::OnPopupPostOpen( - CPWL_Wnd::PrivateData* pAttached, + const CPWL_Wnd::PrivateData* pAttached, uint32_t nFlag) { - auto* pData = static_cast<CFFL_PrivateData*>(pAttached); - ASSERT(pData); + auto* pData = static_cast<const CFFL_PrivateData*>(pAttached); ASSERT(pData->pWidget); CPDFSDK_Annot::ObservedPtr pObserved(pData->pWidget); @@ -885,7 +883,7 @@ bool CFFL_InteractiveFormFiller::IsValidAnnot(CPDFSDK_PageView* pPageView, } std::pair<bool, bool> CFFL_InteractiveFormFiller::OnBeforeKeyStroke( - CPWL_Wnd::PrivateData* pAttached, + const CPWL_Wnd::PrivateData* pAttached, WideString& strChange, const WideString& strChangeEx, int nSelStart, @@ -893,7 +891,8 @@ std::pair<bool, bool> CFFL_InteractiveFormFiller::OnBeforeKeyStroke( bool bKeyDown, uint32_t nFlag) { // Copy the private data since the window owning it may not survive. - CFFL_PrivateData privateData = *static_cast<CFFL_PrivateData*>(pAttached); + CFFL_PrivateData privateData = + *static_cast<const CFFL_PrivateData*>(pAttached); ASSERT(privateData.pWidget); CFFL_FormFiller* pFormFiller = GetFormFiller(privateData.pWidget, false); @@ -949,7 +948,8 @@ std::pair<bool, bool> CFFL_InteractiveFormFiller::OnBeforeKeyStroke( privateData.pPageView, nValueAge == privateData.pWidget->GetValueAge()); if (!pWnd) return {true, true}; - privateData = *static_cast<CFFL_PrivateData*>(pWnd->GetAttachedData()); + privateData = + *static_cast<const CFFL_PrivateData*>(pWnd->GetAttachedData()); bExit = true; } if (fa.bRC) { @@ -964,3 +964,13 @@ std::pair<bool, bool> CFFL_InteractiveFormFiller::OnBeforeKeyStroke( pFormFiller->CommitData(privateData.pPageView, nFlag); return {false, true}; } + +CFFL_PrivateData::CFFL_PrivateData() = default; + +CFFL_PrivateData::CFFL_PrivateData(const CFFL_PrivateData& that) = default; + +CFFL_PrivateData::~CFFL_PrivateData() = default; + +std::unique_ptr<CPWL_Wnd::PrivateData> CFFL_PrivateData::Clone() const { + return pdfium::MakeUnique<CFFL_PrivateData>(*this); +} |