Remove mouse event code from IPDFSDK_AnnotHandler.
Add the equivalent methods to CPDFSDK_Annot instead. Then make the
IPDFSDK_AnnotHandler overrides CPDFSDK_Annot overrides, and remove the
pass-through via CPDFSDK_AnnotHandlerMgr.
Also just delete IPDFSDK_AnnotHandler::OnRButtonDblClk(), which has no
callers.
Change-Id: Idffd84296628e34d62b7020535227cf97564380d
Reviewed-on: https://pdfium-review.googlesource.com/c/pdfium/+/92331
Reviewed-by: Tom Sepez <tsepez@chromium.org>
Commit-Queue: Lei Zhang <thestig@chromium.org>
diff --git a/fpdfsdk/cpdfsdk_annot.h b/fpdfsdk/cpdfsdk_annot.h
index b476014..c0e4c5b 100644
--- a/fpdfsdk/cpdfsdk_annot.h
+++ b/fpdfsdk/cpdfsdk_annot.h
@@ -9,8 +9,10 @@
#include "core/fpdfdoc/cpdf_annot.h"
#include "core/fxcrt/fx_coordinates.h"
+#include "core/fxcrt/mask.h"
#include "core/fxcrt/observed_ptr.h"
#include "core/fxcrt/unowned_ptr.h"
+#include "public/fpdf_fwlevent.h"
class CPDF_Page;
class CPDFSDK_BAAnnot;
@@ -20,11 +22,37 @@
class CPDFSDK_Annot : public Observable {
public:
+ // These methods may destroy the class that implements them when called.
+ // Access through the static methods below of the same name.
+ class UnsafeInputHandlers {
+ public:
+ virtual void OnMouseEnter(Mask<FWL_EVENTFLAG> nFlags) = 0;
+ virtual void OnMouseExit(Mask<FWL_EVENTFLAG> nFlags) = 0;
+ virtual bool OnLButtonDown(Mask<FWL_EVENTFLAG> nFlags,
+ const CFX_PointF& point) = 0;
+ virtual bool OnLButtonUp(Mask<FWL_EVENTFLAG> nFlags,
+ const CFX_PointF& point) = 0;
+ virtual bool OnLButtonDblClk(Mask<FWL_EVENTFLAG> nFlags,
+ const CFX_PointF& point) = 0;
+ virtual bool OnMouseMove(Mask<FWL_EVENTFLAG> nFlags,
+ const CFX_PointF& point) = 0;
+ virtual bool OnMouseWheel(Mask<FWL_EVENTFLAG> nFlags,
+ const CFX_PointF& point,
+ const CFX_Vector& delta) = 0;
+ virtual bool OnRButtonDown(Mask<FWL_EVENTFLAG> nFlags,
+ const CFX_PointF& point) = 0;
+ virtual bool OnRButtonUp(Mask<FWL_EVENTFLAG> nFlags,
+ const CFX_PointF& point) = 0;
+ };
+
virtual ~CPDFSDK_Annot();
virtual CPDFSDK_BAAnnot* AsBAAnnot();
virtual CPDFXFA_Widget* AsXFAWidget();
+ // Never returns nullptr.
+ virtual UnsafeInputHandlers* GetUnsafeInputHandlers() = 0;
+
virtual void OnLoad() {}
virtual int GetLayoutOrder() const;
virtual CPDF_Annot* GetPDFAnnot() const;
@@ -37,6 +65,35 @@
virtual bool Undo() = 0;
virtual bool Redo() = 0;
+ // Callers must check if `pAnnot` is still valid after calling these methods,
+ // before accessing them again.
+ static void OnMouseEnter(ObservedPtr<CPDFSDK_Annot>& pAnnot,
+ Mask<FWL_EVENTFLAG> nFlags);
+ static void OnMouseExit(ObservedPtr<CPDFSDK_Annot>& pAnnot,
+ Mask<FWL_EVENTFLAG> nFlags);
+ static bool OnLButtonDown(ObservedPtr<CPDFSDK_Annot>& pAnnot,
+ Mask<FWL_EVENTFLAG> nFlags,
+ const CFX_PointF& point);
+ static bool OnLButtonUp(ObservedPtr<CPDFSDK_Annot>& pAnnot,
+ Mask<FWL_EVENTFLAG> nFlags,
+ const CFX_PointF& point);
+ static bool OnLButtonDblClk(ObservedPtr<CPDFSDK_Annot>& pAnnot,
+ Mask<FWL_EVENTFLAG> nFlags,
+ const CFX_PointF& point);
+ static bool OnMouseMove(ObservedPtr<CPDFSDK_Annot>& pAnnot,
+ Mask<FWL_EVENTFLAG> nFlags,
+ const CFX_PointF& point);
+ static bool OnMouseWheel(ObservedPtr<CPDFSDK_Annot>& pAnnot,
+ Mask<FWL_EVENTFLAG> nFlags,
+ const CFX_PointF& point,
+ const CFX_Vector& delta);
+ static bool OnRButtonDown(ObservedPtr<CPDFSDK_Annot>& pAnnot,
+ Mask<FWL_EVENTFLAG> nFlags,
+ const CFX_PointF& point);
+ static bool OnRButtonUp(ObservedPtr<CPDFSDK_Annot>& pAnnot,
+ Mask<FWL_EVENTFLAG> nFlags,
+ const CFX_PointF& point);
+
// Three cases: PDF page only, XFA page only, or XFA page backed by PDF page.
IPDF_Page* GetPage(); // Returns XFA Page if possible, else PDF page.
CPDF_Page* GetPDFPage(); // Returns PDF page or nullptr.