Remove page view arguments from IPDFSDK_AnnotHandler methods

The annot itself is already tightly bound to the pageview it
should be using. Having two sources could only lead to
inconsistency.

Change-Id: I2047b9abf5f549d809bca129a3ebbac8522091c7
Reviewed-on: https://pdfium-review.googlesource.com/c/pdfium/+/85191
Commit-Queue: Tom Sepez <tsepez@chromium.org>
Reviewed-by: Lei Zhang <thestig@chromium.org>
diff --git a/fpdfsdk/cpdfsdk_annothandlermgr.cpp b/fpdfsdk/cpdfsdk_annothandlermgr.cpp
index abf22c1..49c2d0c 100644
--- a/fpdfsdk/cpdfsdk_annothandlermgr.cpp
+++ b/fpdfsdk/cpdfsdk_annothandlermgr.cpp
@@ -10,10 +10,6 @@
 
 #include "core/fpdfdoc/cpdf_annot.h"
 #include "fpdfsdk/cpdfsdk_annot.h"
-#include "fpdfsdk/cpdfsdk_baannot.h"
-#include "fpdfsdk/cpdfsdk_formfillenvironment.h"
-#include "fpdfsdk/cpdfsdk_pageview.h"
-#include "fpdfsdk/cpdfsdk_widget.h"
 #include "fpdfsdk/ipdfsdk_annothandler.h"
 #include "third_party/base/check.h"
 
@@ -123,101 +119,84 @@
   return m_pBAAnnotHandler.get();
 }
 
-void CPDFSDK_AnnotHandlerMgr::Annot_OnDraw(CPDFSDK_PageView* pPageView,
-                                           CPDFSDK_Annot* pAnnot,
+void CPDFSDK_AnnotHandlerMgr::Annot_OnDraw(CPDFSDK_Annot* pAnnot,
                                            CFX_RenderDevice* pDevice,
                                            const CFX_Matrix& mtUser2Device,
                                            bool bDrawAnnots) {
   DCHECK(pAnnot);
-  GetAnnotHandler(pAnnot)->OnDraw(pPageView, pAnnot, pDevice, mtUser2Device,
-                                  bDrawAnnots);
+  GetAnnotHandler(pAnnot)->OnDraw(pAnnot, pDevice, mtUser2Device, bDrawAnnots);
 }
 
 bool CPDFSDK_AnnotHandlerMgr::Annot_OnLButtonDown(
-    CPDFSDK_PageView* pPageView,
     ObservedPtr<CPDFSDK_Annot>* pAnnot,
     Mask<FWL_EVENTFLAG> nFlags,
     const CFX_PointF& point) {
   DCHECK(pAnnot->HasObservable());
-  return GetAnnotHandler(pAnnot->Get())
-      ->OnLButtonDown(pPageView, pAnnot, nFlags, point);
+  return GetAnnotHandler(pAnnot->Get())->OnLButtonDown(pAnnot, nFlags, point);
 }
 
 bool CPDFSDK_AnnotHandlerMgr::Annot_OnLButtonUp(
-    CPDFSDK_PageView* pPageView,
     ObservedPtr<CPDFSDK_Annot>* pAnnot,
     Mask<FWL_EVENTFLAG> nFlags,
     const CFX_PointF& point) {
   DCHECK(pAnnot->HasObservable());
-  return GetAnnotHandler(pAnnot->Get())
-      ->OnLButtonUp(pPageView, pAnnot, nFlags, point);
+  return GetAnnotHandler(pAnnot->Get())->OnLButtonUp(pAnnot, nFlags, point);
 }
 
 bool CPDFSDK_AnnotHandlerMgr::Annot_OnLButtonDblClk(
-    CPDFSDK_PageView* pPageView,
     ObservedPtr<CPDFSDK_Annot>* pAnnot,
     Mask<FWL_EVENTFLAG> nFlags,
     const CFX_PointF& point) {
   DCHECK(pAnnot->HasObservable());
-  return GetAnnotHandler(pAnnot->Get())
-      ->OnLButtonDblClk(pPageView, pAnnot, nFlags, point);
+  return GetAnnotHandler(pAnnot->Get())->OnLButtonDblClk(pAnnot, nFlags, point);
 }
 
 bool CPDFSDK_AnnotHandlerMgr::Annot_OnMouseMove(
-    CPDFSDK_PageView* pPageView,
     ObservedPtr<CPDFSDK_Annot>* pAnnot,
     Mask<FWL_EVENTFLAG> nFlags,
     const CFX_PointF& point) {
   DCHECK(pAnnot->HasObservable());
-  return GetAnnotHandler(pAnnot->Get())
-      ->OnMouseMove(pPageView, pAnnot, nFlags, point);
+  return GetAnnotHandler(pAnnot->Get())->OnMouseMove(pAnnot, nFlags, point);
 }
 
 bool CPDFSDK_AnnotHandlerMgr::Annot_OnMouseWheel(
-    CPDFSDK_PageView* pPageView,
     ObservedPtr<CPDFSDK_Annot>* pAnnot,
     Mask<FWL_EVENTFLAG> nFlags,
     const CFX_PointF& point,
     const CFX_Vector& delta) {
   DCHECK(pAnnot->HasObservable());
-  auto* handler = GetAnnotHandler(pAnnot->Get());
-  return handler->OnMouseWheel(pPageView, pAnnot, nFlags, point, delta);
+  return GetAnnotHandler(pAnnot->Get())
+      ->OnMouseWheel(pAnnot, nFlags, point, delta);
 }
 
 bool CPDFSDK_AnnotHandlerMgr::Annot_OnRButtonDown(
-    CPDFSDK_PageView* pPageView,
     ObservedPtr<CPDFSDK_Annot>* pAnnot,
     Mask<FWL_EVENTFLAG> nFlags,
     const CFX_PointF& point) {
   DCHECK(pAnnot->HasObservable());
-  return GetAnnotHandler(pAnnot->Get())
-      ->OnRButtonDown(pPageView, pAnnot, nFlags, point);
+  return GetAnnotHandler(pAnnot->Get())->OnRButtonDown(pAnnot, nFlags, point);
 }
 
 bool CPDFSDK_AnnotHandlerMgr::Annot_OnRButtonUp(
-    CPDFSDK_PageView* pPageView,
     ObservedPtr<CPDFSDK_Annot>* pAnnot,
     Mask<FWL_EVENTFLAG> nFlags,
     const CFX_PointF& point) {
   DCHECK(pAnnot->HasObservable());
-  return GetAnnotHandler(pAnnot->Get())
-      ->OnRButtonUp(pPageView, pAnnot, nFlags, point);
+  return GetAnnotHandler(pAnnot->Get())->OnRButtonUp(pAnnot, nFlags, point);
 }
 
 void CPDFSDK_AnnotHandlerMgr::Annot_OnMouseEnter(
-    CPDFSDK_PageView* pPageView,
     ObservedPtr<CPDFSDK_Annot>* pAnnot,
     Mask<FWL_EVENTFLAG> nFlag) {
   DCHECK(pAnnot->HasObservable());
-  GetAnnotHandler(pAnnot->Get())->OnMouseEnter(pPageView, pAnnot, nFlag);
+  GetAnnotHandler(pAnnot->Get())->OnMouseEnter(pAnnot, nFlag);
 }
 
 void CPDFSDK_AnnotHandlerMgr::Annot_OnMouseExit(
-    CPDFSDK_PageView* pPageView,
     ObservedPtr<CPDFSDK_Annot>* pAnnot,
     Mask<FWL_EVENTFLAG> nFlag) {
   DCHECK(pAnnot->HasObservable());
-  GetAnnotHandler(pAnnot->Get())->OnMouseExit(pPageView, pAnnot, nFlag);
+  GetAnnotHandler(pAnnot->Get())->OnMouseExit(pAnnot, nFlag);
 }
 
 bool CPDFSDK_AnnotHandlerMgr::Annot_OnChar(CPDFSDK_Annot* pAnnot,
@@ -226,11 +205,9 @@
   return GetAnnotHandler(pAnnot)->OnChar(pAnnot, nChar, nFlags);
 }
 
-bool CPDFSDK_AnnotHandlerMgr::Annot_OnKeyDown(CPDFSDK_PageView* pPageView,
-                                              CPDFSDK_Annot* pAnnot,
+bool CPDFSDK_AnnotHandlerMgr::Annot_OnKeyDown(CPDFSDK_Annot* pAnnot,
                                               FWL_VKEYCODE nKeyCode,
                                               Mask<FWL_EVENTFLAG> nFlag) {
-
   return GetAnnotHandler(pAnnot)->OnKeyDown(pAnnot, nKeyCode, nFlag);
 }
 
@@ -278,19 +255,17 @@
 #endif  // PDF_ENABLE_XFA
 
 CFX_FloatRect CPDFSDK_AnnotHandlerMgr::Annot_OnGetViewBBox(
-    CPDFSDK_PageView* pPageView,
     CPDFSDK_Annot* pAnnot) {
   DCHECK(pAnnot);
-  return GetAnnotHandler(pAnnot)->GetViewBBox(pPageView, pAnnot);
+  return GetAnnotHandler(pAnnot)->GetViewBBox(pAnnot);
 }
 
-bool CPDFSDK_AnnotHandlerMgr::Annot_OnHitTest(CPDFSDK_PageView* pPageView,
-                                              CPDFSDK_Annot* pAnnot,
+bool CPDFSDK_AnnotHandlerMgr::Annot_OnHitTest(CPDFSDK_Annot* pAnnot,
                                               const CFX_PointF& point) {
   DCHECK(pAnnot);
   IPDFSDK_AnnotHandler* pAnnotHandler = GetAnnotHandler(pAnnot);
   if (pAnnotHandler->CanAnswer(pAnnot))
-    return pAnnotHandler->HitTest(pPageView, pAnnot, point);
+    return pAnnotHandler->HitTest(pAnnot, point);
 
   return false;
 }
diff --git a/fpdfsdk/cpdfsdk_annothandlermgr.h b/fpdfsdk/cpdfsdk_annothandlermgr.h
index 2e8d1ce..630e4f8 100644
--- a/fpdfsdk/cpdfsdk_annothandlermgr.h
+++ b/fpdfsdk/cpdfsdk_annothandlermgr.h
@@ -56,52 +56,41 @@
   bool Annot_Undo(CPDFSDK_Annot* pAnnot);
   bool Annot_Redo(CPDFSDK_Annot* pAnnot);
 
-  void Annot_OnDraw(CPDFSDK_PageView* pPageView,
-                    CPDFSDK_Annot* pAnnot,
+  void Annot_OnDraw(CPDFSDK_Annot* pAnnot,
                     CFX_RenderDevice* pDevice,
                     const CFX_Matrix& mtUser2Device,
                     bool bDrawAnnots);
 
-  void Annot_OnMouseEnter(CPDFSDK_PageView* pPageView,
-                          ObservedPtr<CPDFSDK_Annot>* pAnnot,
+  void Annot_OnMouseEnter(ObservedPtr<CPDFSDK_Annot>* pAnnot,
                           Mask<FWL_EVENTFLAG> nFlags);
-  void Annot_OnMouseExit(CPDFSDK_PageView* pPageView,
-                         ObservedPtr<CPDFSDK_Annot>* pAnnot,
+  void Annot_OnMouseExit(ObservedPtr<CPDFSDK_Annot>* pAnnot,
                          Mask<FWL_EVENTFLAG> nFlags);
-  bool Annot_OnLButtonDown(CPDFSDK_PageView* pPageView,
-                           ObservedPtr<CPDFSDK_Annot>* pAnnot,
+  bool Annot_OnLButtonDown(ObservedPtr<CPDFSDK_Annot>* pAnnot,
                            Mask<FWL_EVENTFLAG> nFlags,
                            const CFX_PointF& point);
-  bool Annot_OnLButtonUp(CPDFSDK_PageView* pPageView,
-                         ObservedPtr<CPDFSDK_Annot>* pAnnot,
+  bool Annot_OnLButtonUp(ObservedPtr<CPDFSDK_Annot>* pAnnot,
                          Mask<FWL_EVENTFLAG> nFlags,
                          const CFX_PointF& point);
-  bool Annot_OnLButtonDblClk(CPDFSDK_PageView* pPageView,
-                             ObservedPtr<CPDFSDK_Annot>* pAnnot,
+  bool Annot_OnLButtonDblClk(ObservedPtr<CPDFSDK_Annot>* pAnnot,
                              Mask<FWL_EVENTFLAG> nFlags,
                              const CFX_PointF& point);
-  bool Annot_OnMouseMove(CPDFSDK_PageView* pPageView,
-                         ObservedPtr<CPDFSDK_Annot>* pAnnot,
+  bool Annot_OnMouseMove(ObservedPtr<CPDFSDK_Annot>* pAnnot,
                          Mask<FWL_EVENTFLAG> nFlags,
                          const CFX_PointF& point);
-  bool Annot_OnMouseWheel(CPDFSDK_PageView* pPageView,
-                          ObservedPtr<CPDFSDK_Annot>* pAnnot,
+  bool Annot_OnMouseWheel(ObservedPtr<CPDFSDK_Annot>* pAnnot,
                           Mask<FWL_EVENTFLAG> nFlags,
                           const CFX_PointF& point,
                           const CFX_Vector& delta);
-  bool Annot_OnRButtonDown(CPDFSDK_PageView* pPageView,
-                           ObservedPtr<CPDFSDK_Annot>* pAnnot,
+  bool Annot_OnRButtonDown(ObservedPtr<CPDFSDK_Annot>* pAnnot,
                            Mask<FWL_EVENTFLAG> nFlags,
                            const CFX_PointF& point);
-  bool Annot_OnRButtonUp(CPDFSDK_PageView* pPageView,
-                         ObservedPtr<CPDFSDK_Annot>* pAnnot,
+  bool Annot_OnRButtonUp(ObservedPtr<CPDFSDK_Annot>* pAnnot,
                          Mask<FWL_EVENTFLAG> nFlags,
                          const CFX_PointF& point);
   bool Annot_OnChar(CPDFSDK_Annot* pAnnot,
                     uint32_t nChar,
                     Mask<FWL_EVENTFLAG> nFlags);
-  bool Annot_OnKeyDown(CPDFSDK_PageView* pPageView,
-                       CPDFSDK_Annot* pAnnot,
+  bool Annot_OnKeyDown(CPDFSDK_Annot* pAnnot,
                        FWL_VKEYCODE nKeyCode,
                        Mask<FWL_EVENTFLAG> nFlag);
   bool Annot_OnSetFocus(ObservedPtr<CPDFSDK_Annot>* pAnnot,
@@ -118,11 +107,8 @@
                            ObservedPtr<CPDFSDK_Annot>* pKillAnnot);
 #endif  // PDF_ENABLE_XFA
 
-  CFX_FloatRect Annot_OnGetViewBBox(CPDFSDK_PageView* pPageView,
-                                    CPDFSDK_Annot* pAnnot);
-  bool Annot_OnHitTest(CPDFSDK_PageView* pPageView,
-                       CPDFSDK_Annot* pAnnot,
-                       const CFX_PointF& point);
+  CFX_FloatRect Annot_OnGetViewBBox(CPDFSDK_Annot* pAnnot);
+  bool Annot_OnHitTest(CPDFSDK_Annot* pAnnot, const CFX_PointF& point);
 
  private:
   friend class CPDFSDK_BAAnnotHandlerTest;
diff --git a/fpdfsdk/cpdfsdk_baannothandler.cpp b/fpdfsdk/cpdfsdk_baannothandler.cpp
index f810881..b1fd7a6 100644
--- a/fpdfsdk/cpdfsdk_baannothandler.cpp
+++ b/fpdfsdk/cpdfsdk_baannothandler.cpp
@@ -21,12 +21,12 @@
 #include "fpdfsdk/formfiller/cffl_formfield.h"
 #include "public/fpdf_fwlevent.h"
 #include "third_party/base/check.h"
-#include "third_party/base/check_op.h"
 #include "third_party/base/containers/contains.h"
+#include "third_party/base/notreached.h"
 
 namespace {
 
-void UpdateAnnotRects(CPDFSDK_PageView* pPageView, CPDFSDK_BAAnnot* pBAAnnot) {
+void UpdateAnnotRects(CPDFSDK_BAAnnot* pBAAnnot) {
   std::vector<CFX_FloatRect> rects;
   rects.push_back(pBAAnnot->GetRect());
   if (CPDF_Annot* pPopupAnnot = pBAAnnot->GetPDFPopupAnnot())
@@ -36,7 +36,7 @@
   for (CFX_FloatRect& rect : rects)
     rect.Inflate(1, 1);
 
-  pPageView->UpdateRects(rects);
+  pBAAnnot->GetPageView()->UpdateRects(rects);
 }
 
 }  // namespace
@@ -61,12 +61,10 @@
   // pAnnot deleted by unique_ptr going out of scope.
 }
 
-void CPDFSDK_BAAnnotHandler::OnDraw(CPDFSDK_PageView* pPageView,
-                                    CPDFSDK_Annot* pAnnot,
+void CPDFSDK_BAAnnotHandler::OnDraw(CPDFSDK_Annot* pAnnot,
                                     CFX_RenderDevice* pDevice,
                                     const CFX_Matrix& mtUser2Device,
                                     bool bDrawAnnots) {
-  CHECK_EQ(pPageView, pAnnot->GetPageView());
   if (pAnnot->AsXFAWidget())
     return;
 
@@ -82,8 +80,7 @@
 
   if (is_annotation_focused_ && IsFocusableAnnot(annot_type) &&
       pAnnot == GetFormFillEnvironment()->GetFocusAnnot()) {
-    CFX_FloatRect view_bounding_box =
-        GetViewBBox(pPageView, pAnnot->AsBAAnnot());
+    CFX_FloatRect view_bounding_box = GetViewBBox(pAnnot->AsBAAnnot());
     if (view_bounding_box.IsEmpty())
       return;
 
@@ -93,86 +90,66 @@
   }
 }
 
-void CPDFSDK_BAAnnotHandler::OnMouseEnter(CPDFSDK_PageView* pPageView,
-                                          ObservedPtr<CPDFSDK_Annot>* pAnnot,
+void CPDFSDK_BAAnnotHandler::OnMouseEnter(ObservedPtr<CPDFSDK_Annot>* pAnnot,
                                           Mask<FWL_EVENTFLAG> nFlag) {
-  CHECK_EQ(pPageView, (*pAnnot)->GetPageView());
   CPDFSDK_BAAnnot* pBAAnnot = (*pAnnot)->AsBAAnnot();
   pBAAnnot->SetOpenState(true);
-  UpdateAnnotRects(pPageView, pBAAnnot);
+  UpdateAnnotRects(pBAAnnot);
 }
 
-void CPDFSDK_BAAnnotHandler::OnMouseExit(CPDFSDK_PageView* pPageView,
-                                         ObservedPtr<CPDFSDK_Annot>* pAnnot,
+void CPDFSDK_BAAnnotHandler::OnMouseExit(ObservedPtr<CPDFSDK_Annot>* pAnnot,
                                          Mask<FWL_EVENTFLAG> nFlag) {
-  CHECK_EQ(pPageView, (*pAnnot)->GetPageView());
   CPDFSDK_BAAnnot* pBAAnnot = (*pAnnot)->AsBAAnnot();
   pBAAnnot->SetOpenState(false);
-  UpdateAnnotRects(pPageView, pBAAnnot);
+  UpdateAnnotRects(pBAAnnot);
 }
 
-bool CPDFSDK_BAAnnotHandler::OnLButtonDown(CPDFSDK_PageView* pPageView,
-                                           ObservedPtr<CPDFSDK_Annot>* pAnnot,
+bool CPDFSDK_BAAnnotHandler::OnLButtonDown(ObservedPtr<CPDFSDK_Annot>* pAnnot,
                                            Mask<FWL_EVENTFLAG> nFlags,
                                            const CFX_PointF& point) {
-  CHECK_EQ(pPageView, (*pAnnot)->GetPageView());
   return false;
 }
 
-bool CPDFSDK_BAAnnotHandler::OnLButtonUp(CPDFSDK_PageView* pPageView,
-                                         ObservedPtr<CPDFSDK_Annot>* pAnnot,
+bool CPDFSDK_BAAnnotHandler::OnLButtonUp(ObservedPtr<CPDFSDK_Annot>* pAnnot,
                                          Mask<FWL_EVENTFLAG> nFlags,
                                          const CFX_PointF& point) {
-  CHECK_EQ(pPageView, (*pAnnot)->GetPageView());
   return false;
 }
 
-bool CPDFSDK_BAAnnotHandler::OnLButtonDblClk(CPDFSDK_PageView* pPageView,
-                                             ObservedPtr<CPDFSDK_Annot>* pAnnot,
+bool CPDFSDK_BAAnnotHandler::OnLButtonDblClk(ObservedPtr<CPDFSDK_Annot>* pAnnot,
                                              Mask<FWL_EVENTFLAG> nFlags,
                                              const CFX_PointF& point) {
-  CHECK_EQ(pPageView, (*pAnnot)->GetPageView());
   return false;
 }
 
-bool CPDFSDK_BAAnnotHandler::OnMouseMove(CPDFSDK_PageView* pPageView,
-                                         ObservedPtr<CPDFSDK_Annot>* pAnnot,
+bool CPDFSDK_BAAnnotHandler::OnMouseMove(ObservedPtr<CPDFSDK_Annot>* pAnnot,
                                          Mask<FWL_EVENTFLAG> nFlags,
                                          const CFX_PointF& point) {
-  CHECK_EQ(pPageView, (*pAnnot)->GetPageView());
   return false;
 }
 
-bool CPDFSDK_BAAnnotHandler::OnMouseWheel(CPDFSDK_PageView* pPageView,
-                                          ObservedPtr<CPDFSDK_Annot>* pAnnot,
+bool CPDFSDK_BAAnnotHandler::OnMouseWheel(ObservedPtr<CPDFSDK_Annot>* pAnnot,
                                           Mask<FWL_EVENTFLAG> nFlags,
                                           const CFX_PointF& point,
                                           const CFX_Vector& delta) {
-  CHECK_EQ(pPageView, (*pAnnot)->GetPageView());
   return false;
 }
 
-bool CPDFSDK_BAAnnotHandler::OnRButtonDown(CPDFSDK_PageView* pPageView,
-                                           ObservedPtr<CPDFSDK_Annot>* pAnnot,
+bool CPDFSDK_BAAnnotHandler::OnRButtonDown(ObservedPtr<CPDFSDK_Annot>* pAnnot,
                                            Mask<FWL_EVENTFLAG> nFlags,
                                            const CFX_PointF& point) {
-  CHECK_EQ(pPageView, (*pAnnot)->GetPageView());
   return false;
 }
 
-bool CPDFSDK_BAAnnotHandler::OnRButtonUp(CPDFSDK_PageView* pPageView,
-                                         ObservedPtr<CPDFSDK_Annot>* pAnnot,
+bool CPDFSDK_BAAnnotHandler::OnRButtonUp(ObservedPtr<CPDFSDK_Annot>* pAnnot,
                                          Mask<FWL_EVENTFLAG> nFlags,
                                          const CFX_PointF& point) {
-  CHECK_EQ(pPageView, (*pAnnot)->GetPageView());
   return false;
 }
 
-bool CPDFSDK_BAAnnotHandler::OnRButtonDblClk(CPDFSDK_PageView* pPageView,
-                                             ObservedPtr<CPDFSDK_Annot>* pAnnot,
+bool CPDFSDK_BAAnnotHandler::OnRButtonDblClk(ObservedPtr<CPDFSDK_Annot>* pAnnot,
                                              Mask<FWL_EVENTFLAG> nFlags,
                                              const CFX_PointF& point) {
-  CHECK_EQ(pPageView, (*pAnnot)->GetPageView());
   return false;
 }
 
@@ -225,8 +202,7 @@
 
 void CPDFSDK_BAAnnotHandler::InvalidateRect(CPDFSDK_Annot* annot) {
   CPDFSDK_BAAnnot* ba_annot = annot->AsBAAnnot();
-  CPDFSDK_PageView* page_view = ba_annot->GetPageView();
-  CFX_FloatRect view_bounding_box = GetViewBBox(page_view, ba_annot);
+  CFX_FloatRect view_bounding_box = GetViewBBox(ba_annot);
   if (!view_bounding_box.IsEmpty()) {
     view_bounding_box.Inflate(1, 1);
     view_bounding_box.Normalize();
@@ -267,9 +243,7 @@
   return false;
 }
 
-CFX_FloatRect CPDFSDK_BAAnnotHandler::GetViewBBox(CPDFSDK_PageView* pPageView,
-                                                  CPDFSDK_Annot* pAnnot) {
-  CHECK_EQ(pPageView, pAnnot->GetPageView());
+CFX_FloatRect CPDFSDK_BAAnnotHandler::GetViewBBox(CPDFSDK_Annot* pAnnot) {
   return pAnnot->GetRect();
 }
 
@@ -304,11 +278,24 @@
   return false;
 }
 
-bool CPDFSDK_BAAnnotHandler::HitTest(CPDFSDK_PageView* pPageView,
-                                     CPDFSDK_Annot* pAnnot,
+bool CPDFSDK_BAAnnotHandler::HitTest(CPDFSDK_Annot* pAnnot,
                                      const CFX_PointF& point) {
-  DCHECK(pPageView);
   DCHECK(pAnnot);
-  CHECK_EQ(pPageView, pAnnot->GetPageView());
-  return GetViewBBox(pPageView, pAnnot).Contains(point);
+  return GetViewBBox(pAnnot).Contains(point);
 }
+
+#ifdef PDF_ENABLE_XFA
+std::unique_ptr<CPDFSDK_Annot> CPDFSDK_BAAnnotHandler::NewAnnotForXFA(
+    CXFA_FFWidget* pWidget,
+    CPDFSDK_PageView* pPageView) {
+  NOTREACHED();
+  return nullptr;
+}
+
+bool CPDFSDK_BAAnnotHandler::OnXFAChangedFocus(
+    ObservedPtr<CPDFSDK_Annot>* pOldAnnot,
+    ObservedPtr<CPDFSDK_Annot>* pNewAnnot) {
+  NOTREACHED();
+  return false;
+}
+#endif
diff --git a/fpdfsdk/cpdfsdk_baannothandler.h b/fpdfsdk/cpdfsdk_baannothandler.h
index 8013632..02980d3 100644
--- a/fpdfsdk/cpdfsdk_baannothandler.h
+++ b/fpdfsdk/cpdfsdk_baannothandler.h
@@ -27,9 +27,9 @@
   bool CanAnswer(CPDFSDK_Annot* pAnnot) override;
   std::unique_ptr<CPDFSDK_Annot> NewAnnot(CPDF_Annot* pAnnot,
                                           CPDFSDK_PageView* pPageView) override;
+
   void ReleaseAnnot(std::unique_ptr<CPDFSDK_Annot> pAnnot) override;
-  CFX_FloatRect GetViewBBox(CPDFSDK_PageView* pPageView,
-                            CPDFSDK_Annot* pAnnot) override;
+  CFX_FloatRect GetViewBBox(CPDFSDK_Annot* pAnnot) override;
   WideString GetText(CPDFSDK_Annot* pAnnot) override;
   WideString GetSelectedText(CPDFSDK_Annot* pAnnot) override;
   void ReplaceSelection(CPDFSDK_Annot* pAnnot, const WideString& text) override;
@@ -38,53 +38,40 @@
   bool CanRedo(CPDFSDK_Annot* pAnnot) override;
   bool Undo(CPDFSDK_Annot* pAnnot) override;
   bool Redo(CPDFSDK_Annot* pAnnot) override;
-  bool HitTest(CPDFSDK_PageView* pPageView,
-               CPDFSDK_Annot* pAnnot,
-               const CFX_PointF& point) override;
-  void OnDraw(CPDFSDK_PageView* pPageView,
-              CPDFSDK_Annot* pAnnot,
+  bool HitTest(CPDFSDK_Annot* pAnnot, const CFX_PointF& point) override;
+  void OnDraw(CPDFSDK_Annot* pAnnot,
               CFX_RenderDevice* pDevice,
               const CFX_Matrix& mtUser2Device,
               bool bDrawAnnots) override;
   void OnLoad(CPDFSDK_Annot* pAnnot) override;
 
-  void OnMouseEnter(CPDFSDK_PageView* pPageView,
-                    ObservedPtr<CPDFSDK_Annot>* pAnnot,
+  void OnMouseEnter(ObservedPtr<CPDFSDK_Annot>* pAnnot,
                     Mask<FWL_EVENTFLAG> nFlag) override;
-  void OnMouseExit(CPDFSDK_PageView* pPageView,
-                   ObservedPtr<CPDFSDK_Annot>* pAnnot,
+  void OnMouseExit(ObservedPtr<CPDFSDK_Annot>* pAnnot,
                    Mask<FWL_EVENTFLAG> nFlag) override;
-  bool OnLButtonDown(CPDFSDK_PageView* pPageView,
-                     ObservedPtr<CPDFSDK_Annot>* pAnnot,
+  bool OnLButtonDown(ObservedPtr<CPDFSDK_Annot>* pAnnot,
                      Mask<FWL_EVENTFLAG> nFlags,
                      const CFX_PointF& point) override;
-  bool OnLButtonUp(CPDFSDK_PageView* pPageView,
-                   ObservedPtr<CPDFSDK_Annot>* pAnnot,
+  bool OnLButtonUp(ObservedPtr<CPDFSDK_Annot>* pAnnot,
                    Mask<FWL_EVENTFLAG> nFlags,
                    const CFX_PointF& point) override;
-  bool OnLButtonDblClk(CPDFSDK_PageView* pPageView,
-                       ObservedPtr<CPDFSDK_Annot>* pAnnot,
+  bool OnLButtonDblClk(ObservedPtr<CPDFSDK_Annot>* pAnnot,
                        Mask<FWL_EVENTFLAG> nFlags,
                        const CFX_PointF& point) override;
-  bool OnMouseMove(CPDFSDK_PageView* pPageView,
-                   ObservedPtr<CPDFSDK_Annot>* pAnnot,
+  bool OnMouseMove(ObservedPtr<CPDFSDK_Annot>* pAnnot,
                    Mask<FWL_EVENTFLAG> nFlags,
                    const CFX_PointF& point) override;
-  bool OnMouseWheel(CPDFSDK_PageView* pPageView,
-                    ObservedPtr<CPDFSDK_Annot>* pAnnot,
+  bool OnMouseWheel(ObservedPtr<CPDFSDK_Annot>* pAnnot,
                     Mask<FWL_EVENTFLAG> nFlags,
                     const CFX_PointF& point,
                     const CFX_Vector& delta) override;
-  bool OnRButtonDown(CPDFSDK_PageView* pPageView,
-                     ObservedPtr<CPDFSDK_Annot>* pAnnot,
+  bool OnRButtonDown(ObservedPtr<CPDFSDK_Annot>* pAnnot,
                      Mask<FWL_EVENTFLAG> nFlags,
                      const CFX_PointF& point) override;
-  bool OnRButtonUp(CPDFSDK_PageView* pPageView,
-                   ObservedPtr<CPDFSDK_Annot>* pAnnot,
+  bool OnRButtonUp(ObservedPtr<CPDFSDK_Annot>* pAnnot,
                    Mask<FWL_EVENTFLAG> nFlags,
                    const CFX_PointF& point) override;
-  bool OnRButtonDblClk(CPDFSDK_PageView* pPageView,
-                       ObservedPtr<CPDFSDK_Annot>* pAnnot,
+  bool OnRButtonDblClk(ObservedPtr<CPDFSDK_Annot>* pAnnot,
                        Mask<FWL_EVENTFLAG> nFlags,
                        const CFX_PointF& point) override;
   bool OnChar(CPDFSDK_Annot* pAnnot,
@@ -105,6 +92,15 @@
                         bool selected) override;
   bool IsIndexSelected(ObservedPtr<CPDFSDK_Annot>* pAnnot, int index) override;
 
+#ifdef PDF_ENABLE_XFA
+  std::unique_ptr<CPDFSDK_Annot> NewAnnotForXFA(
+      CXFA_FFWidget* pAnnot,
+      CPDFSDK_PageView* pPageView) override;
+
+  bool OnXFAChangedFocus(ObservedPtr<CPDFSDK_Annot>* pOldAnnot,
+                         ObservedPtr<CPDFSDK_Annot>* pNewAnnot) override;
+#endif  // PDF_ENABLE_XFA
+
  private:
   void InvalidateRect(CPDFSDK_Annot* annot);
   bool IsFocusableAnnot(const CPDF_Annot::Subtype& annot_type) const;
diff --git a/fpdfsdk/cpdfsdk_pageview.cpp b/fpdfsdk/cpdfsdk_pageview.cpp
index da3500e..5740add 100644
--- a/fpdfsdk/cpdfsdk_pageview.cpp
+++ b/fpdfsdk/cpdfsdk_pageview.cpp
@@ -84,8 +84,7 @@
   CPDFSDK_AnnotIteration annotIteration(this, true);
   for (const auto& pSDKAnnot : annotIteration) {
     m_pFormFillEnv->GetAnnotHandlerMgr()->Annot_OnDraw(
-        this, pSDKAnnot.Get(), pDevice, mtUser2Device,
-        pOptions->GetDrawAnnots());
+        pSDKAnnot.Get(), pDevice, mtUser2Device, pOptions->GetDrawAnnots());
   }
 }
 
@@ -93,7 +92,7 @@
   CPDFSDK_AnnotHandlerMgr* pAnnotMgr = m_pFormFillEnv->GetAnnotHandlerMgr();
   CPDFSDK_AnnotIteration annotIteration(this, false);
   for (const auto& pSDKAnnot : annotIteration) {
-    CFX_FloatRect rc = pAnnotMgr->Annot_OnGetViewBBox(this, pSDKAnnot.Get());
+    CFX_FloatRect rc = pAnnotMgr->Annot_OnGetViewBBox(pSDKAnnot.Get());
     if (pSDKAnnot->GetAnnotSubtype() == CPDF_Annot::Subtype::POPUP)
       continue;
     if (rc.Contains(point))
@@ -112,8 +111,8 @@
                pSDKAnnot->GetAnnotSubtype() == CPDF_Annot::Subtype::XFAWIDGET;
 #endif  // PDF_ENABLE_XFA
     if (bHitTest) {
-      pAnnotMgr->Annot_OnGetViewBBox(this, pSDKAnnot.Get());
-      if (pAnnotMgr->Annot_OnHitTest(this, pSDKAnnot.Get(), point))
+      pAnnotMgr->Annot_OnGetViewBBox(pSDKAnnot.Get());
+      if (pAnnotMgr->Annot_OnHitTest(pSDKAnnot.Get(), point))
         return pSDKAnnot.Get();
     }
   }
@@ -346,7 +345,7 @@
 
   CPDFSDK_AnnotHandlerMgr* pAnnotHandlerMgr =
       m_pFormFillEnv->GetAnnotHandlerMgr();
-  if (!pAnnotHandlerMgr->Annot_OnLButtonDown(this, &pAnnot, nFlag, point))
+  if (!pAnnotHandlerMgr->Annot_OnLButtonDown(&pAnnot, nFlag, point))
     return false;
 
   if (!pAnnot)
@@ -364,11 +363,11 @@
   ObservedPtr<CPDFSDK_Annot> pFocusAnnot(GetFocusAnnot());
   if (pFocusAnnot && pFocusAnnot != pFXAnnot) {
     // Last focus Annot gets a chance to handle the event.
-    if (pAnnotHandlerMgr->Annot_OnLButtonUp(this, &pFocusAnnot, nFlag, point))
+    if (pAnnotHandlerMgr->Annot_OnLButtonUp(&pFocusAnnot, nFlag, point))
       return true;
   }
   return pFXAnnot &&
-         pAnnotHandlerMgr->Annot_OnLButtonUp(this, &pFXAnnot, nFlag, point);
+         pAnnotHandlerMgr->Annot_OnLButtonUp(&pFXAnnot, nFlag, point);
 }
 
 bool CPDFSDK_PageView::OnLButtonDblClk(Mask<FWL_EVENTFLAG> nFlag,
@@ -381,7 +380,7 @@
 
   CPDFSDK_AnnotHandlerMgr* pAnnotHandlerMgr =
       m_pFormFillEnv->GetAnnotHandlerMgr();
-  if (!pAnnotHandlerMgr->Annot_OnLButtonDblClk(this, &pAnnot, nFlag, point))
+  if (!pAnnotHandlerMgr->Annot_OnLButtonDblClk(&pAnnot, nFlag, point))
     return false;
 
   if (!pAnnot)
@@ -399,7 +398,7 @@
 
   CPDFSDK_AnnotHandlerMgr* pAnnotHandlerMgr =
       m_pFormFillEnv->GetAnnotHandlerMgr();
-  bool ok = pAnnotHandlerMgr->Annot_OnRButtonDown(this, &pAnnot, nFlag, point);
+  bool ok = pAnnotHandlerMgr->Annot_OnRButtonDown(&pAnnot, nFlag, point);
   if (!pAnnot)
     return false;
 
@@ -417,7 +416,7 @@
 
   CPDFSDK_AnnotHandlerMgr* pAnnotHandlerMgr =
       m_pFormFillEnv->GetAnnotHandlerMgr();
-  bool ok = pAnnotHandlerMgr->Annot_OnRButtonUp(this, &pAnnot, nFlag, point);
+  bool ok = pAnnotHandlerMgr->Annot_OnRButtonUp(&pAnnot, nFlag, point);
   if (!pAnnot)
     return false;
 
@@ -454,7 +453,7 @@
       return true;
     }
   }
-  pAnnotHandlerMgr->Annot_OnMouseMove(this, &pFXAnnot, nFlag, point);
+  pAnnotHandlerMgr->Annot_OnMouseMove(&pFXAnnot, nFlag, point);
   return true;
 }
 
@@ -463,7 +462,7 @@
                                    Mask<FWL_EVENTFLAG> nFlag) {
   m_bOnWidget = true;
   m_pCaptureWidget.Reset(pAnnot->Get());
-  pAnnotHandlerMgr->Annot_OnMouseEnter(this, pAnnot, nFlag);
+  pAnnotHandlerMgr->Annot_OnMouseEnter(pAnnot, nFlag);
 }
 
 void CPDFSDK_PageView::ExitWidget(CPDFSDK_AnnotHandlerMgr* pAnnotHandlerMgr,
@@ -475,7 +474,7 @@
 
   if (callExitCallback) {
     ObservedPtr<CPDFSDK_PageView> pThis(this);
-    pAnnotHandlerMgr->Annot_OnMouseExit(this, &m_pCaptureWidget, nFlag);
+    pAnnotHandlerMgr->Annot_OnMouseExit(&m_pCaptureWidget, nFlag);
 
     // Annot_OnMouseExit() may have invalidated |this|.
     if (!pThis)
@@ -494,8 +493,7 @@
 
   CPDFSDK_AnnotHandlerMgr* pAnnotHandlerMgr =
       m_pFormFillEnv->GetAnnotHandlerMgr();
-  return pAnnotHandlerMgr->Annot_OnMouseWheel(this, &pAnnot, nFlag, point,
-                                              delta);
+  return pAnnotHandlerMgr->Annot_OnMouseWheel(&pAnnot, nFlag, point, delta);
 }
 
 bool CPDFSDK_PageView::SetIndexSelected(int index, bool selected) {
@@ -553,7 +551,7 @@
   }
 
   if (CPWL_Wnd::IsCTRLKeyDown(nFlag) || CPWL_Wnd::IsALTKeyDown(nFlag))
-    return pAnnotHandlerMgr->Annot_OnKeyDown(this, pAnnot, nKeyCode, nFlag);
+    return pAnnotHandlerMgr->Annot_OnKeyDown(pAnnot, nKeyCode, nFlag);
 
   ObservedPtr<CPDFSDK_Annot> pObservedAnnot(pAnnot);
   CPDFSDK_Annot* pFocusAnnot = GetFocusAnnot();
@@ -573,7 +571,7 @@
   if (!pObservedAnnot)
     return false;
 
-  return pAnnotHandlerMgr->Annot_OnKeyDown(this, pAnnot, nKeyCode, nFlag);
+  return pAnnotHandlerMgr->Annot_OnKeyDown(pAnnot, nKeyCode, nFlag);
 }
 
 bool CPDFSDK_PageView::OnKeyUp(FWL_VKEYCODE nKeyCode,
diff --git a/fpdfsdk/cpdfsdk_widgethandler.cpp b/fpdfsdk/cpdfsdk_widgethandler.cpp
index b01d3a1..8905e67 100644
--- a/fpdfsdk/cpdfsdk_widgethandler.cpp
+++ b/fpdfsdk/cpdfsdk_widgethandler.cpp
@@ -23,6 +23,7 @@
 #include "third_party/base/check.h"
 #include "third_party/base/check_op.h"
 #include "third_party/base/containers/contains.h"
+#include "third_party/base/notreached.h"
 
 CPDFSDK_WidgetHandler::CPDFSDK_WidgetHandler() = default;
 
@@ -78,117 +79,95 @@
   pForm->RemoveMap(pControl);
 }
 
-void CPDFSDK_WidgetHandler::OnDraw(CPDFSDK_PageView* pPageView,
-                                   CPDFSDK_Annot* pAnnot,
+void CPDFSDK_WidgetHandler::OnDraw(CPDFSDK_Annot* pAnnot,
                                    CFX_RenderDevice* pDevice,
                                    const CFX_Matrix& mtUser2Device,
                                    bool bDrawAnnots) {
-  CHECK_EQ(pPageView, pAnnot->GetPageView());
   if (pAnnot->IsSignatureWidget()) {
     pAnnot->AsBAAnnot()->DrawAppearance(
         pDevice, mtUser2Device, CPDF_Annot::AppearanceMode::kNormal, nullptr);
   } else {
     GetFormFillEnvironment()->GetInteractiveFormFiller()->OnDraw(
-        pPageView, pAnnot, pDevice, mtUser2Device);
+        pAnnot->GetPageView(), pAnnot, pDevice, mtUser2Device);
   }
 }
 
-void CPDFSDK_WidgetHandler::OnMouseEnter(CPDFSDK_PageView* pPageView,
-                                         ObservedPtr<CPDFSDK_Annot>* pAnnot,
+void CPDFSDK_WidgetHandler::OnMouseEnter(ObservedPtr<CPDFSDK_Annot>* pAnnot,
                                          Mask<FWL_EVENTFLAG> nFlag) {
-  CHECK_EQ(pPageView, (*pAnnot)->GetPageView());
   if (!(*pAnnot)->IsSignatureWidget()) {
     GetFormFillEnvironment()->GetInteractiveFormFiller()->OnMouseEnter(
-        pPageView, pAnnot, nFlag);
+        (*pAnnot)->GetPageView(), pAnnot, nFlag);
   }
 }
 
-void CPDFSDK_WidgetHandler::OnMouseExit(CPDFSDK_PageView* pPageView,
-                                        ObservedPtr<CPDFSDK_Annot>* pAnnot,
+void CPDFSDK_WidgetHandler::OnMouseExit(ObservedPtr<CPDFSDK_Annot>* pAnnot,
                                         Mask<FWL_EVENTFLAG> nFlag) {
-  CHECK_EQ(pPageView, (*pAnnot)->GetPageView());
   if (!(*pAnnot)->IsSignatureWidget()) {
     GetFormFillEnvironment()->GetInteractiveFormFiller()->OnMouseExit(
-        pPageView, pAnnot, nFlag);
+        (*pAnnot)->GetPageView(), pAnnot, nFlag);
   }
 }
 
-bool CPDFSDK_WidgetHandler::OnLButtonDown(CPDFSDK_PageView* pPageView,
-                                          ObservedPtr<CPDFSDK_Annot>* pAnnot,
+bool CPDFSDK_WidgetHandler::OnLButtonDown(ObservedPtr<CPDFSDK_Annot>* pAnnot,
                                           Mask<FWL_EVENTFLAG> nFlags,
                                           const CFX_PointF& point) {
-  CHECK_EQ(pPageView, (*pAnnot)->GetPageView());
   return !(*pAnnot)->IsSignatureWidget() &&
          GetFormFillEnvironment()->GetInteractiveFormFiller()->OnLButtonDown(
-             pPageView, pAnnot, nFlags, point);
+             (*pAnnot)->GetPageView(), pAnnot, nFlags, point);
 }
 
-bool CPDFSDK_WidgetHandler::OnLButtonUp(CPDFSDK_PageView* pPageView,
-                                        ObservedPtr<CPDFSDK_Annot>* pAnnot,
+bool CPDFSDK_WidgetHandler::OnLButtonUp(ObservedPtr<CPDFSDK_Annot>* pAnnot,
                                         Mask<FWL_EVENTFLAG> nFlags,
                                         const CFX_PointF& point) {
-  CHECK_EQ(pPageView, (*pAnnot)->GetPageView());
   return !(*pAnnot)->IsSignatureWidget() &&
          GetFormFillEnvironment()->GetInteractiveFormFiller()->OnLButtonUp(
-             pPageView, pAnnot, nFlags, point);
+             (*pAnnot)->GetPageView(), pAnnot, nFlags, point);
 }
 
-bool CPDFSDK_WidgetHandler::OnLButtonDblClk(CPDFSDK_PageView* pPageView,
-                                            ObservedPtr<CPDFSDK_Annot>* pAnnot,
+bool CPDFSDK_WidgetHandler::OnLButtonDblClk(ObservedPtr<CPDFSDK_Annot>* pAnnot,
                                             Mask<FWL_EVENTFLAG> nFlags,
                                             const CFX_PointF& point) {
-  CHECK_EQ(pPageView, (*pAnnot)->GetPageView());
   return !(*pAnnot)->IsSignatureWidget() &&
          GetFormFillEnvironment()->GetInteractiveFormFiller()->OnLButtonDblClk(
-             pPageView, pAnnot, nFlags, point);
+             (*pAnnot)->GetPageView(), pAnnot, nFlags, point);
 }
 
-bool CPDFSDK_WidgetHandler::OnMouseMove(CPDFSDK_PageView* pPageView,
-                                        ObservedPtr<CPDFSDK_Annot>* pAnnot,
+bool CPDFSDK_WidgetHandler::OnMouseMove(ObservedPtr<CPDFSDK_Annot>* pAnnot,
                                         Mask<FWL_EVENTFLAG> nFlags,
                                         const CFX_PointF& point) {
-  CHECK_EQ(pPageView, (*pAnnot)->GetPageView());
   return !(*pAnnot)->IsSignatureWidget() &&
          GetFormFillEnvironment()->GetInteractiveFormFiller()->OnMouseMove(
-             pPageView, pAnnot, nFlags, point);
+             (*pAnnot)->GetPageView(), pAnnot, nFlags, point);
 }
 
-bool CPDFSDK_WidgetHandler::OnMouseWheel(CPDFSDK_PageView* pPageView,
-                                         ObservedPtr<CPDFSDK_Annot>* pAnnot,
+bool CPDFSDK_WidgetHandler::OnMouseWheel(ObservedPtr<CPDFSDK_Annot>* pAnnot,
                                          Mask<FWL_EVENTFLAG> nFlags,
                                          const CFX_PointF& point,
                                          const CFX_Vector& delta) {
-  CHECK_EQ(pPageView, (*pAnnot)->GetPageView());
   return !(*pAnnot)->IsSignatureWidget() &&
          GetFormFillEnvironment()->GetInteractiveFormFiller()->OnMouseWheel(
-             pPageView, pAnnot, nFlags, point, delta);
+             (*pAnnot)->GetPageView(), pAnnot, nFlags, point, delta);
 }
 
-bool CPDFSDK_WidgetHandler::OnRButtonDown(CPDFSDK_PageView* pPageView,
-                                          ObservedPtr<CPDFSDK_Annot>* pAnnot,
+bool CPDFSDK_WidgetHandler::OnRButtonDown(ObservedPtr<CPDFSDK_Annot>* pAnnot,
                                           Mask<FWL_EVENTFLAG> nFlags,
                                           const CFX_PointF& point) {
-  CHECK_EQ(pPageView, (*pAnnot)->GetPageView());
   return !(*pAnnot)->IsSignatureWidget() &&
          GetFormFillEnvironment()->GetInteractiveFormFiller()->OnRButtonDown(
-             pPageView, pAnnot, nFlags, point);
+             (*pAnnot)->GetPageView(), pAnnot, nFlags, point);
 }
 
-bool CPDFSDK_WidgetHandler::OnRButtonUp(CPDFSDK_PageView* pPageView,
-                                        ObservedPtr<CPDFSDK_Annot>* pAnnot,
+bool CPDFSDK_WidgetHandler::OnRButtonUp(ObservedPtr<CPDFSDK_Annot>* pAnnot,
                                         Mask<FWL_EVENTFLAG> nFlags,
                                         const CFX_PointF& point) {
-  CHECK_EQ(pPageView, (*pAnnot)->GetPageView());
   return !(*pAnnot)->IsSignatureWidget() &&
          GetFormFillEnvironment()->GetInteractiveFormFiller()->OnRButtonUp(
-             pPageView, pAnnot, nFlags, point);
+             (*pAnnot)->GetPageView(), pAnnot, nFlags, point);
 }
 
-bool CPDFSDK_WidgetHandler::OnRButtonDblClk(CPDFSDK_PageView* pPageView,
-                                            ObservedPtr<CPDFSDK_Annot>* pAnnot,
+bool CPDFSDK_WidgetHandler::OnRButtonDblClk(ObservedPtr<CPDFSDK_Annot>* pAnnot,
                                             Mask<FWL_EVENTFLAG> nFlags,
                                             const CFX_PointF& point) {
-  CHECK_EQ(pPageView, (*pAnnot)->GetPageView());
   return false;
 }
 
@@ -278,13 +257,11 @@
              pAnnot, index);
 }
 
-CFX_FloatRect CPDFSDK_WidgetHandler::GetViewBBox(CPDFSDK_PageView* pPageView,
-                                                 CPDFSDK_Annot* pAnnot) {
-  CHECK_EQ(pPageView, pAnnot->GetPageView());
+CFX_FloatRect CPDFSDK_WidgetHandler::GetViewBBox(CPDFSDK_Annot* pAnnot) {
   if (!pAnnot->IsSignatureWidget()) {
     return CFX_FloatRect(
         GetFormFillEnvironment()->GetInteractiveFormFiller()->GetViewBBox(
-            pPageView, pAnnot));
+            pAnnot->GetPageView(), pAnnot));
   }
   return CFX_FloatRect();
 }
@@ -340,13 +317,10 @@
          GetFormFillEnvironment()->GetInteractiveFormFiller()->Redo(pAnnot);
 }
 
-bool CPDFSDK_WidgetHandler::HitTest(CPDFSDK_PageView* pPageView,
-                                    CPDFSDK_Annot* pAnnot,
+bool CPDFSDK_WidgetHandler::HitTest(CPDFSDK_Annot* pAnnot,
                                     const CFX_PointF& point) {
-  DCHECK(pPageView);
   DCHECK(pAnnot);
-  CHECK_EQ(pPageView, pAnnot->GetPageView());
-  return GetViewBBox(pPageView, pAnnot).Contains(point);
+  return GetViewBBox(pAnnot).Contains(point);
 }
 
 bool CPDFSDK_WidgetHandler::IsFocusableAnnot(
@@ -355,3 +329,19 @@
   return pdfium::Contains(GetFormFillEnvironment()->GetFocusableAnnotSubtypes(),
                           annot_type);
 }
+
+#ifdef PDF_ENABLE_XFA
+std::unique_ptr<CPDFSDK_Annot> CPDFSDK_WidgetHandler::NewAnnotForXFA(
+    CXFA_FFWidget* pWidget,
+    CPDFSDK_PageView* pPageView) {
+  NOTREACHED();
+  return nullptr;
+}
+
+bool CPDFSDK_WidgetHandler::OnXFAChangedFocus(
+    ObservedPtr<CPDFSDK_Annot>* pOldAnnot,
+    ObservedPtr<CPDFSDK_Annot>* pNewAnnot) {
+  NOTREACHED();
+  return false;
+}
+#endif
diff --git a/fpdfsdk/cpdfsdk_widgethandler.h b/fpdfsdk/cpdfsdk_widgethandler.h
index 519f462..e1953501 100644
--- a/fpdfsdk/cpdfsdk_widgethandler.h
+++ b/fpdfsdk/cpdfsdk_widgethandler.h
@@ -27,9 +27,9 @@
   bool CanAnswer(CPDFSDK_Annot* pAnnot) override;
   std::unique_ptr<CPDFSDK_Annot> NewAnnot(CPDF_Annot* pAnnot,
                                           CPDFSDK_PageView* pPageView) override;
+
   void ReleaseAnnot(std::unique_ptr<CPDFSDK_Annot> pAnnot) override;
-  CFX_FloatRect GetViewBBox(CPDFSDK_PageView* pPageView,
-                            CPDFSDK_Annot* pAnnot) override;
+  CFX_FloatRect GetViewBBox(CPDFSDK_Annot* pAnnot) override;
   WideString GetText(CPDFSDK_Annot* pAnnot) override;
   WideString GetSelectedText(CPDFSDK_Annot* pAnnot) override;
   void ReplaceSelection(CPDFSDK_Annot* pAnnot, const WideString& text) override;
@@ -38,52 +38,39 @@
   bool CanRedo(CPDFSDK_Annot* pAnnot) override;
   bool Undo(CPDFSDK_Annot* pAnnot) override;
   bool Redo(CPDFSDK_Annot* pAnnot) override;
-  bool HitTest(CPDFSDK_PageView* pPageView,
-               CPDFSDK_Annot* pAnnot,
-               const CFX_PointF& point) override;
-  void OnDraw(CPDFSDK_PageView* pPageView,
-              CPDFSDK_Annot* pAnnot,
+  bool HitTest(CPDFSDK_Annot* pAnnot, const CFX_PointF& point) override;
+  void OnDraw(CPDFSDK_Annot* pAnnot,
               CFX_RenderDevice* pDevice,
               const CFX_Matrix& mtUser2Device,
               bool bDrawAnnots) override;
   void OnLoad(CPDFSDK_Annot* pAnnot) override;
-  void OnMouseEnter(CPDFSDK_PageView* pPageView,
-                    ObservedPtr<CPDFSDK_Annot>* pAnnot,
+  void OnMouseEnter(ObservedPtr<CPDFSDK_Annot>* pAnnot,
                     Mask<FWL_EVENTFLAG> nFlag) override;
-  void OnMouseExit(CPDFSDK_PageView* pPageView,
-                   ObservedPtr<CPDFSDK_Annot>* pAnnot,
+  void OnMouseExit(ObservedPtr<CPDFSDK_Annot>* pAnnot,
                    Mask<FWL_EVENTFLAG> nFlag) override;
-  bool OnLButtonDown(CPDFSDK_PageView* pPageView,
-                     ObservedPtr<CPDFSDK_Annot>* pAnnot,
+  bool OnLButtonDown(ObservedPtr<CPDFSDK_Annot>* pAnnot,
                      Mask<FWL_EVENTFLAG> nFlags,
                      const CFX_PointF& point) override;
-  bool OnLButtonUp(CPDFSDK_PageView* pPageView,
-                   ObservedPtr<CPDFSDK_Annot>* pAnnot,
+  bool OnLButtonUp(ObservedPtr<CPDFSDK_Annot>* pAnnot,
                    Mask<FWL_EVENTFLAG> nFlags,
                    const CFX_PointF& point) override;
-  bool OnLButtonDblClk(CPDFSDK_PageView* pPageView,
-                       ObservedPtr<CPDFSDK_Annot>* pAnnot,
+  bool OnLButtonDblClk(ObservedPtr<CPDFSDK_Annot>* pAnnot,
                        Mask<FWL_EVENTFLAG> nFlags,
                        const CFX_PointF& point) override;
-  bool OnMouseMove(CPDFSDK_PageView* pPageView,
-                   ObservedPtr<CPDFSDK_Annot>* pAnnot,
+  bool OnMouseMove(ObservedPtr<CPDFSDK_Annot>* pAnnot,
                    Mask<FWL_EVENTFLAG> nFlags,
                    const CFX_PointF& point) override;
-  bool OnMouseWheel(CPDFSDK_PageView* pPageView,
-                    ObservedPtr<CPDFSDK_Annot>* pAnnot,
+  bool OnMouseWheel(ObservedPtr<CPDFSDK_Annot>* pAnnot,
                     Mask<FWL_EVENTFLAG> nFlags,
                     const CFX_PointF& point,
                     const CFX_Vector& delta) override;
-  bool OnRButtonDown(CPDFSDK_PageView* pPageView,
-                     ObservedPtr<CPDFSDK_Annot>* pAnnot,
+  bool OnRButtonDown(ObservedPtr<CPDFSDK_Annot>* pAnnot,
                      Mask<FWL_EVENTFLAG> nFlags,
                      const CFX_PointF& point) override;
-  bool OnRButtonUp(CPDFSDK_PageView* pPageView,
-                   ObservedPtr<CPDFSDK_Annot>* pAnnot,
+  bool OnRButtonUp(ObservedPtr<CPDFSDK_Annot>* pAnnot,
                    Mask<FWL_EVENTFLAG> nFlags,
                    const CFX_PointF& point) override;
-  bool OnRButtonDblClk(CPDFSDK_PageView* pPageView,
-                       ObservedPtr<CPDFSDK_Annot>* pAnnot,
+  bool OnRButtonDblClk(ObservedPtr<CPDFSDK_Annot>* pAnnot,
                        Mask<FWL_EVENTFLAG> nFlags,
                        const CFX_PointF& point) override;
   bool OnChar(CPDFSDK_Annot* pAnnot,
@@ -104,6 +91,15 @@
                         bool selected) override;
   bool IsIndexSelected(ObservedPtr<CPDFSDK_Annot>* pAnnot, int index) override;
 
+#ifdef PDF_ENABLE_XFA
+  std::unique_ptr<CPDFSDK_Annot> NewAnnotForXFA(
+      CXFA_FFWidget* pWiget,
+      CPDFSDK_PageView* pPageView) override;
+
+  bool OnXFAChangedFocus(ObservedPtr<CPDFSDK_Annot>* pOldAnnot,
+                         ObservedPtr<CPDFSDK_Annot>* pNewAnnot) override;
+#endif
+
  private:
   bool IsFocusableAnnot(const CPDF_Annot::Subtype& annot_type) const;
 };
diff --git a/fpdfsdk/fpdfxfa/cpdfxfa_widgethandler.cpp b/fpdfsdk/fpdfxfa/cpdfxfa_widgethandler.cpp
index 9c46c8c..61c66ff 100644
--- a/fpdfsdk/fpdfxfa/cpdfxfa_widgethandler.cpp
+++ b/fpdfsdk/fpdfxfa/cpdfxfa_widgethandler.cpp
@@ -13,7 +13,6 @@
 #include "fpdfsdk/fpdfxfa/cpdfxfa_context.h"
 #include "fpdfsdk/fpdfxfa/cpdfxfa_widget.h"
 #include "third_party/base/check.h"
-#include "third_party/base/check_op.h"
 #include "xfa/fgas/graphics/cfgas_gegraphics.h"
 #include "xfa/fwl/cfwl_app.h"
 #include "xfa/fwl/fwl_widgetdef.h"
@@ -223,12 +222,10 @@
   return std::make_unique<CPDFXFA_Widget>(pFFWidget, pPageView);
 }
 
-void CPDFXFA_WidgetHandler::OnDraw(CPDFSDK_PageView* pPageView,
-                                   CPDFSDK_Annot* pAnnot,
+void CPDFXFA_WidgetHandler::OnDraw(CPDFSDK_Annot* pAnnot,
                                    CFX_RenderDevice* pDevice,
                                    const CFX_Matrix& mtUser2Device,
                                    bool bDrawAnnots) {
-  CHECK_EQ(pPageView, pAnnot->GetPageView());
   CPDFXFA_Widget* pXFAWidget = ToXFAWidget(pAnnot);
   DCHECK(pXFAWidget);
 
@@ -249,9 +246,7 @@
 void CPDFXFA_WidgetHandler::ReleaseAnnot(
     std::unique_ptr<CPDFSDK_Annot> pAnnot) {}
 
-CFX_FloatRect CPDFXFA_WidgetHandler::GetViewBBox(CPDFSDK_PageView* pPageView,
-                                                 CPDFSDK_Annot* pAnnot) {
-  CHECK_EQ(pPageView, pAnnot->GetPageView());
+CFX_FloatRect CPDFXFA_WidgetHandler::GetViewBBox(CPDFSDK_Annot* pAnnot) {
   CPDFXFA_Widget* pXFAWidget = ToXFAWidget(pAnnot);
   CXFA_Node* node = pXFAWidget->GetXFAFFWidget()->GetNode();
   DCHECK(node->IsWidgetReady());
@@ -339,13 +334,8 @@
   return pWidgetHandler->Redo(pXFAWidget->GetXFAFFWidget());
 }
 
-bool CPDFXFA_WidgetHandler::HitTest(CPDFSDK_PageView* pPageView,
-                                    CPDFSDK_Annot* pAnnot,
+bool CPDFXFA_WidgetHandler::HitTest(CPDFSDK_Annot* pAnnot,
                                     const CFX_PointF& point) {
-  CHECK_EQ(pPageView, pAnnot->GetPageView());
-  if (!pPageView)
-    return false;
-
   CPDFXFA_Widget* pXFAWidget = ToXFAWidget(pAnnot);
   if (!pXFAWidget)
     return false;
@@ -365,13 +355,8 @@
              FWL_WidgetHit::Unknown;
 }
 
-void CPDFXFA_WidgetHandler::OnMouseEnter(CPDFSDK_PageView* pPageView,
-                                         ObservedPtr<CPDFSDK_Annot>* pAnnot,
+void CPDFXFA_WidgetHandler::OnMouseEnter(ObservedPtr<CPDFSDK_Annot>* pAnnot,
                                          Mask<FWL_EVENTFLAG> nFlag) {
-  CHECK_EQ(pPageView, (*pAnnot)->GetPageView());
-  if (!pPageView)
-    return;
-
   CPDFXFA_Widget* pXFAWidget = ToXFAWidget(pAnnot->Get());
   if (!pXFAWidget)
     return;
@@ -380,13 +365,8 @@
   pWidgetHandler->OnMouseEnter(pXFAWidget->GetXFAFFWidget());
 }
 
-void CPDFXFA_WidgetHandler::OnMouseExit(CPDFSDK_PageView* pPageView,
-                                        ObservedPtr<CPDFSDK_Annot>* pAnnot,
+void CPDFXFA_WidgetHandler::OnMouseExit(ObservedPtr<CPDFSDK_Annot>* pAnnot,
                                         Mask<FWL_EVENTFLAG> nFlag) {
-  CHECK_EQ(pPageView, (*pAnnot)->GetPageView());
-  if (!pPageView)
-    return;
-
   CPDFXFA_Widget* pXFAWidget = ToXFAWidget(pAnnot->Get());
   if (!pXFAWidget)
     return;
@@ -395,14 +375,9 @@
   pWidgetHandler->OnMouseExit(pXFAWidget->GetXFAFFWidget());
 }
 
-bool CPDFXFA_WidgetHandler::OnLButtonDown(CPDFSDK_PageView* pPageView,
-                                          ObservedPtr<CPDFSDK_Annot>* pAnnot,
+bool CPDFXFA_WidgetHandler::OnLButtonDown(ObservedPtr<CPDFSDK_Annot>* pAnnot,
                                           Mask<FWL_EVENTFLAG> nFlags,
                                           const CFX_PointF& point) {
-  CHECK_EQ(pPageView, (*pAnnot)->GetPageView());
-  if (!pPageView)
-    return false;
-
   CPDFXFA_Widget* pXFAWidget = ToXFAWidget(pAnnot->Get());
   if (!pXFAWidget)
     return false;
@@ -412,14 +387,9 @@
                                        GetKeyFlags(nFlags), point);
 }
 
-bool CPDFXFA_WidgetHandler::OnLButtonUp(CPDFSDK_PageView* pPageView,
-                                        ObservedPtr<CPDFSDK_Annot>* pAnnot,
+bool CPDFXFA_WidgetHandler::OnLButtonUp(ObservedPtr<CPDFSDK_Annot>* pAnnot,
                                         Mask<FWL_EVENTFLAG> nFlags,
                                         const CFX_PointF& point) {
-  CHECK_EQ(pPageView, (*pAnnot)->GetPageView());
-  if (!pPageView)
-    return false;
-
   CPDFXFA_Widget* pXFAWidget = ToXFAWidget(pAnnot->Get());
   if (!pXFAWidget)
     return false;
@@ -429,14 +399,9 @@
                                      GetKeyFlags(nFlags), point);
 }
 
-bool CPDFXFA_WidgetHandler::OnLButtonDblClk(CPDFSDK_PageView* pPageView,
-                                            ObservedPtr<CPDFSDK_Annot>* pAnnot,
+bool CPDFXFA_WidgetHandler::OnLButtonDblClk(ObservedPtr<CPDFSDK_Annot>* pAnnot,
                                             Mask<FWL_EVENTFLAG> nFlags,
                                             const CFX_PointF& point) {
-  CHECK_EQ(pPageView, (*pAnnot)->GetPageView());
-  if (!pPageView)
-    return false;
-
   CPDFXFA_Widget* pXFAWidget = ToXFAWidget(pAnnot->Get());
   if (!pXFAWidget)
     return false;
@@ -446,14 +411,9 @@
                                          GetKeyFlags(nFlags), point);
 }
 
-bool CPDFXFA_WidgetHandler::OnMouseMove(CPDFSDK_PageView* pPageView,
-                                        ObservedPtr<CPDFSDK_Annot>* pAnnot,
+bool CPDFXFA_WidgetHandler::OnMouseMove(ObservedPtr<CPDFSDK_Annot>* pAnnot,
                                         Mask<FWL_EVENTFLAG> nFlags,
                                         const CFX_PointF& point) {
-  CHECK_EQ(pPageView, (*pAnnot)->GetPageView());
-  if (!pPageView)
-    return false;
-
   CPDFXFA_Widget* pXFAWidget = ToXFAWidget(pAnnot->Get());
   if (!pXFAWidget)
     return false;
@@ -463,15 +423,10 @@
                                      GetKeyFlags(nFlags), point);
 }
 
-bool CPDFXFA_WidgetHandler::OnMouseWheel(CPDFSDK_PageView* pPageView,
-                                         ObservedPtr<CPDFSDK_Annot>* pAnnot,
+bool CPDFXFA_WidgetHandler::OnMouseWheel(ObservedPtr<CPDFSDK_Annot>* pAnnot,
                                          Mask<FWL_EVENTFLAG> nFlags,
                                          const CFX_PointF& point,
                                          const CFX_Vector& delta) {
-  CHECK_EQ(pPageView, (*pAnnot)->GetPageView());
-  if (!pPageView)
-    return false;
-
   CPDFXFA_Widget* pXFAWidget = ToXFAWidget(pAnnot->Get());
   if (!pXFAWidget)
     return false;
@@ -481,14 +436,9 @@
                                       GetKeyFlags(nFlags), point, delta);
 }
 
-bool CPDFXFA_WidgetHandler::OnRButtonDown(CPDFSDK_PageView* pPageView,
-                                          ObservedPtr<CPDFSDK_Annot>* pAnnot,
+bool CPDFXFA_WidgetHandler::OnRButtonDown(ObservedPtr<CPDFSDK_Annot>* pAnnot,
                                           Mask<FWL_EVENTFLAG> nFlags,
                                           const CFX_PointF& point) {
-  CHECK_EQ(pPageView, (*pAnnot)->GetPageView());
-  if (!pPageView)
-    return false;
-
   CPDFXFA_Widget* pXFAWidget = ToXFAWidget(pAnnot->Get());
   if (!pXFAWidget)
     return false;
@@ -498,14 +448,9 @@
                                        GetKeyFlags(nFlags), point);
 }
 
-bool CPDFXFA_WidgetHandler::OnRButtonUp(CPDFSDK_PageView* pPageView,
-                                        ObservedPtr<CPDFSDK_Annot>* pAnnot,
+bool CPDFXFA_WidgetHandler::OnRButtonUp(ObservedPtr<CPDFSDK_Annot>* pAnnot,
                                         Mask<FWL_EVENTFLAG> nFlags,
                                         const CFX_PointF& point) {
-  CHECK_EQ(pPageView, (*pAnnot)->GetPageView());
-  if (!pPageView)
-    return false;
-
   CPDFXFA_Widget* pXFAWidget = ToXFAWidget(pAnnot->Get());
   if (!pXFAWidget)
     return false;
@@ -515,14 +460,9 @@
                                      GetKeyFlags(nFlags), point);
 }
 
-bool CPDFXFA_WidgetHandler::OnRButtonDblClk(CPDFSDK_PageView* pPageView,
-                                            ObservedPtr<CPDFSDK_Annot>* pAnnot,
+bool CPDFXFA_WidgetHandler::OnRButtonDblClk(ObservedPtr<CPDFSDK_Annot>* pAnnot,
                                             Mask<FWL_EVENTFLAG> nFlags,
                                             const CFX_PointF& point) {
-  CHECK_EQ(pPageView, (*pAnnot)->GetPageView());
-  if (!pPageView)
-    return false;
-
   CPDFXFA_Widget* pXFAWidget = ToXFAWidget(pAnnot->Get());
   if (!pXFAWidget)
     return false;
diff --git a/fpdfsdk/fpdfxfa/cpdfxfa_widgethandler.h b/fpdfsdk/fpdfxfa/cpdfxfa_widgethandler.h
index 58a3e09..1267ec8 100644
--- a/fpdfsdk/fpdfxfa/cpdfxfa_widgethandler.h
+++ b/fpdfsdk/fpdfxfa/cpdfxfa_widgethandler.h
@@ -31,9 +31,9 @@
   bool CanAnswer(CPDFSDK_Annot* pAnnot) override;
   std::unique_ptr<CPDFSDK_Annot> NewAnnot(CPDF_Annot* pAnnot,
                                           CPDFSDK_PageView* pPageView) override;
+
   void ReleaseAnnot(std::unique_ptr<CPDFSDK_Annot> pAnnot) override;
-  CFX_FloatRect GetViewBBox(CPDFSDK_PageView* pPageView,
-                            CPDFSDK_Annot* pAnnot) override;
+  CFX_FloatRect GetViewBBox(CPDFSDK_Annot* pAnnot) override;
   WideString GetText(CPDFSDK_Annot* pAnnot) override;
   WideString GetSelectedText(CPDFSDK_Annot* pAnnot) override;
   void ReplaceSelection(CPDFSDK_Annot* pAnnot, const WideString& text) override;
@@ -42,52 +42,39 @@
   bool CanRedo(CPDFSDK_Annot* pAnnot) override;
   bool Undo(CPDFSDK_Annot* pAnnot) override;
   bool Redo(CPDFSDK_Annot* pAnnot) override;
-  bool HitTest(CPDFSDK_PageView* pPageView,
-               CPDFSDK_Annot* pAnnot,
-               const CFX_PointF& point) override;
-  void OnDraw(CPDFSDK_PageView* pPageView,
-              CPDFSDK_Annot* pAnnot,
+  bool HitTest(CPDFSDK_Annot* pAnnot, const CFX_PointF& point) override;
+  void OnDraw(CPDFSDK_Annot* pAnnot,
               CFX_RenderDevice* pDevice,
               const CFX_Matrix& mtUser2Device,
               bool bDrawAnnots) override;
   void OnLoad(CPDFSDK_Annot* pAnnot) override;
-  void OnMouseEnter(CPDFSDK_PageView* pPageView,
-                    ObservedPtr<CPDFSDK_Annot>* pAnnot,
+  void OnMouseEnter(ObservedPtr<CPDFSDK_Annot>* pAnnot,
                     Mask<FWL_EVENTFLAG> nFlag) override;
-  void OnMouseExit(CPDFSDK_PageView* pPageView,
-                   ObservedPtr<CPDFSDK_Annot>* pAnnot,
+  void OnMouseExit(ObservedPtr<CPDFSDK_Annot>* pAnnot,
                    Mask<FWL_EVENTFLAG> nFlag) override;
-  bool OnLButtonDown(CPDFSDK_PageView* pPageView,
-                     ObservedPtr<CPDFSDK_Annot>* pAnnot,
+  bool OnLButtonDown(ObservedPtr<CPDFSDK_Annot>* pAnnot,
                      Mask<FWL_EVENTFLAG> nFlags,
                      const CFX_PointF& point) override;
-  bool OnLButtonUp(CPDFSDK_PageView* pPageView,
-                   ObservedPtr<CPDFSDK_Annot>* pAnnot,
+  bool OnLButtonUp(ObservedPtr<CPDFSDK_Annot>* pAnnot,
                    Mask<FWL_EVENTFLAG> nFlags,
                    const CFX_PointF& point) override;
-  bool OnLButtonDblClk(CPDFSDK_PageView* pPageView,
-                       ObservedPtr<CPDFSDK_Annot>* pAnnot,
+  bool OnLButtonDblClk(ObservedPtr<CPDFSDK_Annot>* pAnnot,
                        Mask<FWL_EVENTFLAG> nFlags,
                        const CFX_PointF& point) override;
-  bool OnMouseMove(CPDFSDK_PageView* pPageView,
-                   ObservedPtr<CPDFSDK_Annot>* pAnnot,
+  bool OnMouseMove(ObservedPtr<CPDFSDK_Annot>* pAnnot,
                    Mask<FWL_EVENTFLAG> nFlags,
                    const CFX_PointF& point) override;
-  bool OnMouseWheel(CPDFSDK_PageView* pPageView,
-                    ObservedPtr<CPDFSDK_Annot>* pAnnot,
+  bool OnMouseWheel(ObservedPtr<CPDFSDK_Annot>* pAnnot,
                     Mask<FWL_EVENTFLAG> nFlags,
                     const CFX_PointF& point,
                     const CFX_Vector& delta) override;
-  bool OnRButtonDown(CPDFSDK_PageView* pPageView,
-                     ObservedPtr<CPDFSDK_Annot>* pAnnot,
+  bool OnRButtonDown(ObservedPtr<CPDFSDK_Annot>* pAnnot,
                      Mask<FWL_EVENTFLAG> nFlags,
                      const CFX_PointF& point) override;
-  bool OnRButtonUp(CPDFSDK_PageView* pPageView,
-                   ObservedPtr<CPDFSDK_Annot>* pAnnot,
+  bool OnRButtonUp(ObservedPtr<CPDFSDK_Annot>* pAnnot,
                    Mask<FWL_EVENTFLAG> nFlags,
                    const CFX_PointF& point) override;
-  bool OnRButtonDblClk(CPDFSDK_PageView* pPageView,
-                       ObservedPtr<CPDFSDK_Annot>* pAnnot,
+  bool OnRButtonDblClk(ObservedPtr<CPDFSDK_Annot>* pAnnot,
                        Mask<FWL_EVENTFLAG> nFlags,
                        const CFX_PointF& point) override;
   bool OnChar(CPDFSDK_Annot* pAnnot,
diff --git a/fpdfsdk/ipdfsdk_annothandler.h b/fpdfsdk/ipdfsdk_annothandler.h
index 1ea79e0..b40973e 100644
--- a/fpdfsdk/ipdfsdk_annothandler.h
+++ b/fpdfsdk/ipdfsdk_annothandler.h
@@ -43,9 +43,9 @@
   virtual std::unique_ptr<CPDFSDK_Annot> NewAnnot(
       CPDF_Annot* pAnnot,
       CPDFSDK_PageView* pPageView) = 0;
+
   virtual void ReleaseAnnot(std::unique_ptr<CPDFSDK_Annot> pAnnot) = 0;
-  virtual CFX_FloatRect GetViewBBox(CPDFSDK_PageView* pPageView,
-                                    CPDFSDK_Annot* pAnnot) = 0;
+  virtual CFX_FloatRect GetViewBBox(CPDFSDK_Annot* pAnnot) = 0;
   virtual WideString GetText(CPDFSDK_Annot* pAnnot) = 0;
   virtual WideString GetSelectedText(CPDFSDK_Annot* pAnnot) = 0;
   virtual void ReplaceSelection(CPDFSDK_Annot* pAnnot,
@@ -55,52 +55,39 @@
   virtual bool CanRedo(CPDFSDK_Annot* pAnnot) = 0;
   virtual bool Undo(CPDFSDK_Annot* pAnnot) = 0;
   virtual bool Redo(CPDFSDK_Annot* pAnnot) = 0;
-  virtual bool HitTest(CPDFSDK_PageView* pPageView,
-                       CPDFSDK_Annot* pAnnot,
-                       const CFX_PointF& point) = 0;
-  virtual void OnDraw(CPDFSDK_PageView* pPageView,
-                      CPDFSDK_Annot* pAnnot,
+  virtual bool HitTest(CPDFSDK_Annot* pAnnot, const CFX_PointF& point) = 0;
+  virtual void OnDraw(CPDFSDK_Annot* pAnnot,
                       CFX_RenderDevice* pDevice,
                       const CFX_Matrix& mtUser2Device,
                       bool bDrawAnnots) = 0;
   virtual void OnLoad(CPDFSDK_Annot* pAnnot) = 0;
-  virtual void OnMouseEnter(CPDFSDK_PageView* pPageView,
-                            ObservedPtr<CPDFSDK_Annot>* pAnnot,
+  virtual void OnMouseEnter(ObservedPtr<CPDFSDK_Annot>* pAnnot,
                             Mask<FWL_EVENTFLAG> nFlag) = 0;
-  virtual void OnMouseExit(CPDFSDK_PageView* pPageView,
-                           ObservedPtr<CPDFSDK_Annot>* pAnnot,
+  virtual void OnMouseExit(ObservedPtr<CPDFSDK_Annot>* pAnnot,
                            Mask<FWL_EVENTFLAG> nFlag) = 0;
-  virtual bool OnLButtonDown(CPDFSDK_PageView* pPageView,
-                             ObservedPtr<CPDFSDK_Annot>* pAnnot,
+  virtual bool OnLButtonDown(ObservedPtr<CPDFSDK_Annot>* pAnnot,
                              Mask<FWL_EVENTFLAG> nFlags,
                              const CFX_PointF& point) = 0;
-  virtual bool OnLButtonUp(CPDFSDK_PageView* pPageView,
-                           ObservedPtr<CPDFSDK_Annot>* pAnnot,
+  virtual bool OnLButtonUp(ObservedPtr<CPDFSDK_Annot>* pAnnot,
                            Mask<FWL_EVENTFLAG> nFlags,
                            const CFX_PointF& point) = 0;
-  virtual bool OnLButtonDblClk(CPDFSDK_PageView* pPageView,
-                               ObservedPtr<CPDFSDK_Annot>* pAnnot,
+  virtual bool OnLButtonDblClk(ObservedPtr<CPDFSDK_Annot>* pAnnot,
                                Mask<FWL_EVENTFLAG> nFlags,
                                const CFX_PointF& point) = 0;
-  virtual bool OnMouseMove(CPDFSDK_PageView* pPageView,
-                           ObservedPtr<CPDFSDK_Annot>* pAnnot,
+  virtual bool OnMouseMove(ObservedPtr<CPDFSDK_Annot>* pAnnot,
                            Mask<FWL_EVENTFLAG> nFlags,
                            const CFX_PointF& point) = 0;
-  virtual bool OnMouseWheel(CPDFSDK_PageView* pPageView,
-                            ObservedPtr<CPDFSDK_Annot>* pAnnot,
+  virtual bool OnMouseWheel(ObservedPtr<CPDFSDK_Annot>* pAnnot,
                             Mask<FWL_EVENTFLAG> nFlags,
                             const CFX_PointF& point,
                             const CFX_Vector& delta) = 0;
-  virtual bool OnRButtonDown(CPDFSDK_PageView* pPageView,
-                             ObservedPtr<CPDFSDK_Annot>* pAnnot,
+  virtual bool OnRButtonDown(ObservedPtr<CPDFSDK_Annot>* pAnnot,
                              Mask<FWL_EVENTFLAG> nFlags,
                              const CFX_PointF& point) = 0;
-  virtual bool OnRButtonUp(CPDFSDK_PageView* pPageView,
-                           ObservedPtr<CPDFSDK_Annot>* pAnnot,
+  virtual bool OnRButtonUp(ObservedPtr<CPDFSDK_Annot>* pAnnot,
                            Mask<FWL_EVENTFLAG> nFlags,
                            const CFX_PointF& point) = 0;
-  virtual bool OnRButtonDblClk(CPDFSDK_PageView* pPageView,
-                               ObservedPtr<CPDFSDK_Annot>* pAnnot,
+  virtual bool OnRButtonDblClk(ObservedPtr<CPDFSDK_Annot>* pAnnot,
                                Mask<FWL_EVENTFLAG> nFlags,
                                const CFX_PointF& point) = 0;
   virtual bool OnChar(CPDFSDK_Annot* pAnnot,