From c5267c54ea32ade03bf10e6bb203e34e3fcbd77d Mon Sep 17 00:00:00 2001 From: dsinclair Date: Fri, 4 Nov 2016 15:35:12 -0700 Subject: Revert: Only create widgets if really needed This CL reverts ef523dd36aea991084b8b934df846014a5c09c6f which causes issues with syncing of form fields over pages. The initial bug had follow on fixes which seem to have rendered this fix un-needed. BUG=chromium:632709, chromium:661294 Review-Url: https://codereview.chromium.org/2473103003 --- fpdfsdk/cpdfsdk_interform.cpp | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) (limited to 'fpdfsdk/cpdfsdk_interform.cpp') diff --git a/fpdfsdk/cpdfsdk_interform.cpp b/fpdfsdk/cpdfsdk_interform.cpp index 5229f95528..f8fd3b3db5 100644 --- a/fpdfsdk/cpdfsdk_interform.cpp +++ b/fpdfsdk/cpdfsdk_interform.cpp @@ -82,8 +82,7 @@ CPDFSDK_Widget* CPDFSDK_InterForm::GetSibling(CPDFSDK_Widget* pWidget, return static_cast(pIterator->GetPrevAnnot(pWidget)); } -CPDFSDK_Widget* CPDFSDK_InterForm::GetWidget(CPDF_FormControl* pControl, - bool createIfNeeded) const { +CPDFSDK_Widget* CPDFSDK_InterForm::GetWidget(CPDF_FormControl* pControl) const { if (!pControl || !m_pInterForm) return nullptr; @@ -93,8 +92,6 @@ CPDFSDK_Widget* CPDFSDK_InterForm::GetWidget(CPDF_FormControl* pControl, pWidget = it->second; if (pWidget) return pWidget; - if (!createIfNeeded) - return nullptr; CPDF_Dictionary* pControlDict = pControl->GetWidget(); CPDF_Document* pDocument = m_pFormFillEnv->GetPDFDocument(); @@ -134,7 +131,7 @@ void CPDFSDK_InterForm::GetWidgets( for (int i = 0, sz = pField->CountControls(); i < sz; ++i) { CPDF_FormControl* pFormCtrl = pField->GetControl(i); ASSERT(pFormCtrl); - CPDFSDK_Widget* pWidget = GetWidget(pFormCtrl, true); + CPDFSDK_Widget* pWidget = GetWidget(pFormCtrl); if (pWidget) widgets->push_back(pWidget); } @@ -213,7 +210,7 @@ void CPDFSDK_InterForm::SynchronizeField(CPDF_FormField* pFormField, bool bSynchronizeElse) { for (int i = 0, sz = pFormField->CountControls(); i < sz; i++) { CPDF_FormControl* pFormCtrl = pFormField->GetControl(i); - if (CPDFSDK_Widget* pWidget = GetWidget(pFormCtrl, false)) + if (CPDFSDK_Widget* pWidget = GetWidget(pFormCtrl)) pWidget->Synchronize(bSynchronizeElse); } } @@ -322,7 +319,7 @@ void CPDFSDK_InterForm::ResetFieldAppearance(CPDF_FormField* pFormField, for (int i = 0, sz = pFormField->CountControls(); i < sz; i++) { CPDF_FormControl* pFormCtrl = pFormField->GetControl(i); ASSERT(pFormCtrl); - if (CPDFSDK_Widget* pWidget = GetWidget(pFormCtrl, false)) + if (CPDFSDK_Widget* pWidget = GetWidget(pFormCtrl)) pWidget->ResetAppearance(sValue, bValueChanged); } } @@ -332,7 +329,7 @@ void CPDFSDK_InterForm::UpdateField(CPDF_FormField* pFormField) { CPDF_FormControl* pFormCtrl = pFormField->GetControl(i); ASSERT(pFormCtrl); - if (CPDFSDK_Widget* pWidget = GetWidget(pFormCtrl, false)) { + if (CPDFSDK_Widget* pWidget = GetWidget(pFormCtrl)) { UnderlyingPageType* pPage = pWidget->GetUnderlyingPage(); CPDFSDK_PageView* pPageView = m_pFormFillEnv->GetPageView(pPage, false); FX_RECT rcBBox = m_pFormFillEnv->GetInteractiveFormFiller()->GetViewBBox( @@ -399,7 +396,7 @@ bool CPDFSDK_InterForm::DoAction_Hide(const CPDF_Action& action) { CPDF_FormControl* pControl = pField->GetControl(i); ASSERT(pControl); - if (CPDFSDK_Widget* pWidget = GetWidget(pControl, false)) { + if (CPDFSDK_Widget* pWidget = GetWidget(pControl)) { uint32_t nFlags = pWidget->GetFlags(); nFlags &= ~ANNOTFLAG_INVISIBLE; nFlags &= ~ANNOTFLAG_NOVIEW; -- cgit v1.2.3