No need to store CFFL_InteractiveFormFiller in CPFSDK_WidgetHandler.
The CFFL_InteractiveFormFiller is 1:1 with the form fill env, and
owned by the form fill env, so avoid storing an unowned reference.
Change-Id: I04d5837f278fd2734780d4f47ddc66961108fd70
Reviewed-on: https://pdfium-review.googlesource.com/c/pdfium/+/85130
Commit-Queue: Tom Sepez <tsepez@chromium.org>
Reviewed-by: Lei Zhang <thestig@chromium.org>
diff --git a/fpdfsdk/cpdfsdk_widgethandler.cpp b/fpdfsdk/cpdfsdk_widgethandler.cpp
index 62ab33a..1be5b62 100644
--- a/fpdfsdk/cpdfsdk_widgethandler.cpp
+++ b/fpdfsdk/cpdfsdk_widgethandler.cpp
@@ -19,6 +19,7 @@
#include "fpdfsdk/cpdfsdk_pageview.h"
#include "fpdfsdk/cpdfsdk_widget.h"
#include "fpdfsdk/formfiller/cffl_formfield.h"
+#include "fpdfsdk/formfiller/cffl_interactiveformfiller.h"
#include "third_party/base/check.h"
#include "third_party/base/check_op.h"
#include "third_party/base/containers/contains.h"
@@ -30,7 +31,6 @@
void CPDFSDK_WidgetHandler::SetFormFillEnvironment(
CPDFSDK_FormFillEnvironment* pFormFillEnv) {
m_pFormFillEnv = pFormFillEnv;
- m_pInteractiveFormFiller = m_pFormFillEnv->GetInteractiveFormFiller();
}
bool CPDFSDK_WidgetHandler::CanAnswer(CPDFSDK_Annot* pAnnot) {
@@ -73,7 +73,7 @@
void CPDFSDK_WidgetHandler::ReleaseAnnot(
std::unique_ptr<CPDFSDK_Annot> pAnnot) {
DCHECK(pAnnot);
- m_pInteractiveFormFiller->OnDelete(pAnnot.get());
+ m_pFormFillEnv->GetInteractiveFormFiller()->OnDelete(pAnnot.get());
std::unique_ptr<CPDFSDK_Widget> pWidget(ToCPDFSDKWidget(pAnnot.release()));
CPDFSDK_InteractiveForm* pForm = pWidget->GetInteractiveForm();
@@ -90,22 +90,27 @@
pAnnot->AsBAAnnot()->DrawAppearance(
pDevice, mtUser2Device, CPDF_Annot::AppearanceMode::kNormal, nullptr);
} else {
- m_pInteractiveFormFiller->OnDraw(pPageView, pAnnot, pDevice, mtUser2Device);
+ m_pFormFillEnv->GetInteractiveFormFiller()->OnDraw(pPageView, pAnnot,
+ pDevice, mtUser2Device);
}
}
void CPDFSDK_WidgetHandler::OnMouseEnter(CPDFSDK_PageView* pPageView,
ObservedPtr<CPDFSDK_Annot>* pAnnot,
Mask<FWL_EVENTFLAG> nFlag) {
- if (!(*pAnnot)->IsSignatureWidget())
- m_pInteractiveFormFiller->OnMouseEnter(pPageView, pAnnot, nFlag);
+ if (!(*pAnnot)->IsSignatureWidget()) {
+ m_pFormFillEnv->GetInteractiveFormFiller()->OnMouseEnter(pPageView, pAnnot,
+ nFlag);
+ }
}
void CPDFSDK_WidgetHandler::OnMouseExit(CPDFSDK_PageView* pPageView,
ObservedPtr<CPDFSDK_Annot>* pAnnot,
Mask<FWL_EVENTFLAG> nFlag) {
- if (!(*pAnnot)->IsSignatureWidget())
- m_pInteractiveFormFiller->OnMouseExit(pPageView, pAnnot, nFlag);
+ if (!(*pAnnot)->IsSignatureWidget()) {
+ m_pFormFillEnv->GetInteractiveFormFiller()->OnMouseExit(pPageView, pAnnot,
+ nFlag);
+ }
}
bool CPDFSDK_WidgetHandler::OnLButtonDown(CPDFSDK_PageView* pPageView,
@@ -113,8 +118,8 @@
Mask<FWL_EVENTFLAG> nFlags,
const CFX_PointF& point) {
return !(*pAnnot)->IsSignatureWidget() &&
- m_pInteractiveFormFiller->OnLButtonDown(pPageView, pAnnot, nFlags,
- point);
+ m_pFormFillEnv->GetInteractiveFormFiller()->OnLButtonDown(
+ pPageView, pAnnot, nFlags, point);
}
bool CPDFSDK_WidgetHandler::OnLButtonUp(CPDFSDK_PageView* pPageView,
@@ -122,8 +127,8 @@
Mask<FWL_EVENTFLAG> nFlags,
const CFX_PointF& point) {
return !(*pAnnot)->IsSignatureWidget() &&
- m_pInteractiveFormFiller->OnLButtonUp(pPageView, pAnnot, nFlags,
- point);
+ m_pFormFillEnv->GetInteractiveFormFiller()->OnLButtonUp(
+ pPageView, pAnnot, nFlags, point);
}
bool CPDFSDK_WidgetHandler::OnLButtonDblClk(CPDFSDK_PageView* pPageView,
@@ -131,8 +136,8 @@
Mask<FWL_EVENTFLAG> nFlags,
const CFX_PointF& point) {
return !(*pAnnot)->IsSignatureWidget() &&
- m_pInteractiveFormFiller->OnLButtonDblClk(pPageView, pAnnot, nFlags,
- point);
+ m_pFormFillEnv->GetInteractiveFormFiller()->OnLButtonDblClk(
+ pPageView, pAnnot, nFlags, point);
}
bool CPDFSDK_WidgetHandler::OnMouseMove(CPDFSDK_PageView* pPageView,
@@ -140,8 +145,8 @@
Mask<FWL_EVENTFLAG> nFlags,
const CFX_PointF& point) {
return !(*pAnnot)->IsSignatureWidget() &&
- m_pInteractiveFormFiller->OnMouseMove(pPageView, pAnnot, nFlags,
- point);
+ m_pFormFillEnv->GetInteractiveFormFiller()->OnMouseMove(
+ pPageView, pAnnot, nFlags, point);
}
bool CPDFSDK_WidgetHandler::OnMouseWheel(CPDFSDK_PageView* pPageView,
@@ -150,8 +155,8 @@
const CFX_PointF& point,
const CFX_Vector& delta) {
return !(*pAnnot)->IsSignatureWidget() &&
- m_pInteractiveFormFiller->OnMouseWheel(pPageView, pAnnot, nFlags,
- point, delta);
+ m_pFormFillEnv->GetInteractiveFormFiller()->OnMouseWheel(
+ pPageView, pAnnot, nFlags, point, delta);
}
bool CPDFSDK_WidgetHandler::OnRButtonDown(CPDFSDK_PageView* pPageView,
@@ -159,8 +164,8 @@
Mask<FWL_EVENTFLAG> nFlags,
const CFX_PointF& point) {
return !(*pAnnot)->IsSignatureWidget() &&
- m_pInteractiveFormFiller->OnRButtonDown(pPageView, pAnnot, nFlags,
- point);
+ m_pFormFillEnv->GetInteractiveFormFiller()->OnRButtonDown(
+ pPageView, pAnnot, nFlags, point);
}
bool CPDFSDK_WidgetHandler::OnRButtonUp(CPDFSDK_PageView* pPageView,
@@ -168,8 +173,8 @@
Mask<FWL_EVENTFLAG> nFlags,
const CFX_PointF& point) {
return !(*pAnnot)->IsSignatureWidget() &&
- m_pInteractiveFormFiller->OnRButtonUp(pPageView, pAnnot, nFlags,
- point);
+ m_pFormFillEnv->GetInteractiveFormFiller()->OnRButtonUp(
+ pPageView, pAnnot, nFlags, point);
}
bool CPDFSDK_WidgetHandler::OnRButtonDblClk(CPDFSDK_PageView* pPageView,
@@ -183,14 +188,16 @@
uint32_t nChar,
Mask<FWL_EVENTFLAG> nFlags) {
return !pAnnot->IsSignatureWidget() &&
- m_pInteractiveFormFiller->OnChar(pAnnot, nChar, nFlags);
+ m_pFormFillEnv->GetInteractiveFormFiller()->OnChar(pAnnot, nChar,
+ nFlags);
}
bool CPDFSDK_WidgetHandler::OnKeyDown(CPDFSDK_Annot* pAnnot,
FWL_VKEYCODE nKeyCode,
Mask<FWL_EVENTFLAG> nFlag) {
return !pAnnot->IsSignatureWidget() &&
- m_pInteractiveFormFiller->OnKeyDown(pAnnot, nKeyCode, nFlag);
+ m_pFormFillEnv->GetInteractiveFormFiller()->OnKeyDown(pAnnot, nKeyCode,
+ nFlag);
}
bool CPDFSDK_WidgetHandler::OnKeyUp(CPDFSDK_Annot* pAnnot,
@@ -235,7 +242,7 @@
return false;
return (*pAnnot)->IsSignatureWidget() ||
- m_pInteractiveFormFiller->OnSetFocus(pAnnot, nFlag);
+ m_pFormFillEnv->GetInteractiveFormFiller()->OnSetFocus(pAnnot, nFlag);
}
bool CPDFSDK_WidgetHandler::OnKillFocus(ObservedPtr<CPDFSDK_Annot>* pAnnot,
@@ -244,70 +251,75 @@
return false;
return (*pAnnot)->IsSignatureWidget() ||
- m_pInteractiveFormFiller->OnKillFocus(pAnnot, nFlag);
+ m_pFormFillEnv->GetInteractiveFormFiller()->OnKillFocus(pAnnot, nFlag);
}
bool CPDFSDK_WidgetHandler::SetIndexSelected(ObservedPtr<CPDFSDK_Annot>* pAnnot,
int index,
bool selected) {
return !(*pAnnot)->IsSignatureWidget() &&
- m_pInteractiveFormFiller->SetIndexSelected(pAnnot, index, selected);
+ m_pFormFillEnv->GetInteractiveFormFiller()->SetIndexSelected(
+ pAnnot, index, selected);
}
bool CPDFSDK_WidgetHandler::IsIndexSelected(ObservedPtr<CPDFSDK_Annot>* pAnnot,
int index) {
return !(*pAnnot)->IsSignatureWidget() &&
- m_pInteractiveFormFiller->IsIndexSelected(pAnnot, index);
+ m_pFormFillEnv->GetInteractiveFormFiller()->IsIndexSelected(pAnnot,
+ index);
}
CFX_FloatRect CPDFSDK_WidgetHandler::GetViewBBox(CPDFSDK_PageView* pPageView,
CPDFSDK_Annot* pAnnot) {
if (!pAnnot->IsSignatureWidget()) {
return CFX_FloatRect(
- m_pInteractiveFormFiller->GetViewBBox(pPageView, pAnnot));
+ m_pFormFillEnv->GetInteractiveFormFiller()->GetViewBBox(pPageView,
+ pAnnot));
}
return CFX_FloatRect();
}
WideString CPDFSDK_WidgetHandler::GetText(CPDFSDK_Annot* pAnnot) {
if (!pAnnot->IsSignatureWidget())
- return m_pInteractiveFormFiller->GetText(pAnnot);
+ return m_pFormFillEnv->GetInteractiveFormFiller()->GetText(pAnnot);
return WideString();
}
WideString CPDFSDK_WidgetHandler::GetSelectedText(CPDFSDK_Annot* pAnnot) {
if (!pAnnot->IsSignatureWidget())
- return m_pInteractiveFormFiller->GetSelectedText(pAnnot);
+ return m_pFormFillEnv->GetInteractiveFormFiller()->GetSelectedText(pAnnot);
return WideString();
}
void CPDFSDK_WidgetHandler::ReplaceSelection(CPDFSDK_Annot* pAnnot,
const WideString& text) {
if (!pAnnot->IsSignatureWidget())
- m_pInteractiveFormFiller->ReplaceSelection(pAnnot, text);
+ m_pFormFillEnv->GetInteractiveFormFiller()->ReplaceSelection(pAnnot, text);
}
bool CPDFSDK_WidgetHandler::SelectAllText(CPDFSDK_Annot* pAnnot) {
return !pAnnot->IsSignatureWidget() &&
- m_pInteractiveFormFiller->SelectAllText(pAnnot);
+ m_pFormFillEnv->GetInteractiveFormFiller()->SelectAllText(pAnnot);
}
bool CPDFSDK_WidgetHandler::CanUndo(CPDFSDK_Annot* pAnnot) {
return !pAnnot->IsSignatureWidget() &&
- m_pInteractiveFormFiller->CanUndo(pAnnot);
+ m_pFormFillEnv->GetInteractiveFormFiller()->CanUndo(pAnnot);
}
bool CPDFSDK_WidgetHandler::CanRedo(CPDFSDK_Annot* pAnnot) {
return !pAnnot->IsSignatureWidget() &&
- m_pInteractiveFormFiller->CanRedo(pAnnot);
+ m_pFormFillEnv->GetInteractiveFormFiller()->CanRedo(pAnnot);
}
bool CPDFSDK_WidgetHandler::Undo(CPDFSDK_Annot* pAnnot) {
- return !pAnnot->IsSignatureWidget() && m_pInteractiveFormFiller->Undo(pAnnot);
+ return !pAnnot->IsSignatureWidget() &&
+ m_pFormFillEnv->GetInteractiveFormFiller()->Undo(pAnnot);
}
bool CPDFSDK_WidgetHandler::Redo(CPDFSDK_Annot* pAnnot) {
- return !pAnnot->IsSignatureWidget() && m_pInteractiveFormFiller->Redo(pAnnot);
+ return !pAnnot->IsSignatureWidget() &&
+ m_pFormFillEnv->GetInteractiveFormFiller()->Redo(pAnnot);
}
bool CPDFSDK_WidgetHandler::HitTest(CPDFSDK_PageView* pPageView,
diff --git a/fpdfsdk/cpdfsdk_widgethandler.h b/fpdfsdk/cpdfsdk_widgethandler.h
index 7c9d5bc..ee1aa63 100644
--- a/fpdfsdk/cpdfsdk_widgethandler.h
+++ b/fpdfsdk/cpdfsdk_widgethandler.h
@@ -11,7 +11,6 @@
#include "core/fxcrt/fx_coordinates.h"
#include "core/fxcrt/unowned_ptr.h"
-#include "fpdfsdk/formfiller/cffl_interactiveformfiller.h"
#include "fpdfsdk/ipdfsdk_annothandler.h"
class CFX_Matrix;
@@ -113,7 +112,6 @@
bool IsFocusableAnnot(const CPDF_Annot::Subtype& annot_type) const;
UnownedPtr<CPDFSDK_FormFillEnvironment> m_pFormFillEnv;
- UnownedPtr<CFFL_InteractiveFormFiller> m_pInteractiveFormFiller;
};
#endif // FPDFSDK_CPDFSDK_WIDGETHANDLER_H_