Create CFFL_InteractiveFormFiller in CPDFSDK_FormFillEnvironment ctor.
Makes reasoning about the permanent 1:1 relationship between the two
objects much more obvious. Passing a partially-initialized `this` to
the CFFL_InteractiveFormFiller is fine, since all that constructor does
is stash away a pointer.
Change-Id: I8010523016c229e3be03a2b5ba3f39898172279d
Reviewed-on: https://pdfium-review.googlesource.com/c/pdfium/+/85070
Reviewed-by: Lei Zhang <thestig@chromium.org>
Commit-Queue: Tom Sepez <tsepez@chromium.org>
diff --git a/fpdfsdk/cpdfsdk_formfillenvironment.cpp b/fpdfsdk/cpdfsdk_formfillenvironment.cpp
index f299d7f..ad7b349 100644
--- a/fpdfsdk/cpdfsdk_formfillenvironment.cpp
+++ b/fpdfsdk/cpdfsdk_formfillenvironment.cpp
@@ -61,7 +61,9 @@
std::unique_ptr<CPDFSDK_AnnotHandlerMgr> pHandlerMgr)
: m_pInfo(pFFinfo),
m_pCPDFDoc(pDoc),
- m_pAnnotHandlerMgr(std::move(pHandlerMgr)) {
+ m_pAnnotHandlerMgr(std::move(pHandlerMgr)),
+ m_pInteractiveFormFiller(
+ std::make_unique<CFFL_InteractiveFormFiller>(this)) {
DCHECK(m_pCPDFDoc);
m_pAnnotHandlerMgr->SetFormFillEnv(this);
}
@@ -357,15 +359,6 @@
return m_pActionHandler.get();
}
-CFFL_InteractiveFormFiller*
-CPDFSDK_FormFillEnvironment::GetInteractiveFormFiller() {
- if (!m_pInteractiveFormFiller) {
- m_pInteractiveFormFiller =
- std::make_unique<CFFL_InteractiveFormFiller>(this);
- }
- return m_pInteractiveFormFiller.get();
-}
-
void CPDFSDK_FormFillEnvironment::Invalidate(IPDF_Page* page,
const FX_RECT& rect) {
if (m_pInfo && m_pInfo->FFI_Invalidate) {