Remove IPDFSDK_AnnotHandler::CanUndo() and friends.

Add CPDFSDK_Annot::CanUndo() and make the IPDFSDK_AnnotHandler overrides
CPDFSDK_Annot overrides. Then remove the pass-through via
CPDFSDK_AnnotHandlerMgr. Also update CanRedo(), Undo() and Redo().

Change-Id: I9c299ec1c988700fd6cab9d1ac3142a63d431a4a
Reviewed-on: https://pdfium-review.googlesource.com/c/pdfium/+/92330
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 22e5515..b476014 100644
--- a/fpdfsdk/cpdfsdk_annot.h
+++ b/fpdfsdk/cpdfsdk_annot.h
@@ -32,6 +32,10 @@
   virtual CFX_FloatRect GetRect() const = 0;
   virtual bool DoHitTest(const CFX_PointF& point) = 0;
   virtual CFX_FloatRect GetViewBBox() = 0;
+  virtual bool CanUndo() = 0;
+  virtual bool CanRedo() = 0;
+  virtual bool Undo() = 0;
+  virtual bool Redo() = 0;
 
   // 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.
diff --git a/fpdfsdk/cpdfsdk_annothandlermgr.cpp b/fpdfsdk/cpdfsdk_annothandlermgr.cpp
index 7bf3578..d39c4eb 100644
--- a/fpdfsdk/cpdfsdk_annothandlermgr.cpp
+++ b/fpdfsdk/cpdfsdk_annothandlermgr.cpp
@@ -64,22 +64,6 @@
   return GetAnnotHandler(pAnnot)->SelectAllText(pAnnot);
 }
 
-bool CPDFSDK_AnnotHandlerMgr::Annot_CanUndo(CPDFSDK_Annot* pAnnot) {
-  return GetAnnotHandler(pAnnot)->CanUndo(pAnnot);
-}
-
-bool CPDFSDK_AnnotHandlerMgr::Annot_CanRedo(CPDFSDK_Annot* pAnnot) {
-  return GetAnnotHandler(pAnnot)->CanRedo(pAnnot);
-}
-
-bool CPDFSDK_AnnotHandlerMgr::Annot_Undo(CPDFSDK_Annot* pAnnot) {
-  return GetAnnotHandler(pAnnot)->Undo(pAnnot);
-}
-
-bool CPDFSDK_AnnotHandlerMgr::Annot_Redo(CPDFSDK_Annot* pAnnot) {
-  return GetAnnotHandler(pAnnot)->Redo(pAnnot);
-}
-
 IPDFSDK_AnnotHandler* CPDFSDK_AnnotHandlerMgr::GetAnnotHandler(
     CPDFSDK_Annot* pAnnot) const {
   return GetAnnotHandlerOfType(pAnnot->GetAnnotSubtype());
diff --git a/fpdfsdk/cpdfsdk_annothandlermgr.h b/fpdfsdk/cpdfsdk_annothandlermgr.h
index 9056c93..c219849 100644
--- a/fpdfsdk/cpdfsdk_annothandlermgr.h
+++ b/fpdfsdk/cpdfsdk_annothandlermgr.h
@@ -41,11 +41,6 @@
   void Annot_ReplaceSelection(CPDFSDK_Annot* pAnnot, const WideString& text);
   bool Annot_SelectAllText(CPDFSDK_Annot* pAnnot);
 
-  bool Annot_CanUndo(CPDFSDK_Annot* pAnnot);
-  bool Annot_CanRedo(CPDFSDK_Annot* pAnnot);
-  bool Annot_Undo(CPDFSDK_Annot* pAnnot);
-  bool Annot_Redo(CPDFSDK_Annot* pAnnot);
-
   void Annot_OnDraw(CPDFSDK_Annot* pAnnot,
                     CFX_RenderDevice* pDevice,
                     const CFX_Matrix& mtUser2Device,
diff --git a/fpdfsdk/cpdfsdk_baannot.cpp b/fpdfsdk/cpdfsdk_baannot.cpp
index e1bc222..a6864a7 100644
--- a/fpdfsdk/cpdfsdk_baannot.cpp
+++ b/fpdfsdk/cpdfsdk_baannot.cpp
@@ -220,6 +220,22 @@
   return GetRect();
 }
 
+bool CPDFSDK_BAAnnot::CanUndo() {
+  return false;
+}
+
+bool CPDFSDK_BAAnnot::CanRedo() {
+  return false;
+}
+
+bool CPDFSDK_BAAnnot::Undo() {
+  return false;
+}
+
+bool CPDFSDK_BAAnnot::Redo() {
+  return false;
+}
+
 CPDF_Dest CPDFSDK_BAAnnot::GetDestination() const {
   if (m_pAnnot->GetSubtype() != CPDF_Annot::Subtype::LINK)
     return CPDF_Dest(nullptr);
diff --git a/fpdfsdk/cpdfsdk_baannot.h b/fpdfsdk/cpdfsdk_baannot.h
index cd2b36f..5a828e2 100644
--- a/fpdfsdk/cpdfsdk_baannot.h
+++ b/fpdfsdk/cpdfsdk_baannot.h
@@ -33,6 +33,10 @@
   int GetLayoutOrder() const override;
   bool DoHitTest(const CFX_PointF& point) override;
   CFX_FloatRect GetViewBBox() override;
+  bool CanUndo() override;
+  bool CanRedo() override;
+  bool Undo() override;
+  bool Redo() override;
 
   virtual CPDF_Action GetAAction(CPDF_AAction::AActionType eAAT);
   virtual bool IsAppearanceValid();
diff --git a/fpdfsdk/cpdfsdk_baannothandler.cpp b/fpdfsdk/cpdfsdk_baannothandler.cpp
index 189c6a3..6077f08 100644
--- a/fpdfsdk/cpdfsdk_baannothandler.cpp
+++ b/fpdfsdk/cpdfsdk_baannothandler.cpp
@@ -245,19 +245,3 @@
 bool CPDFSDK_BAAnnotHandler::SelectAllText(CPDFSDK_Annot* pAnnot) {
   return false;
 }
-
-bool CPDFSDK_BAAnnotHandler::CanUndo(CPDFSDK_Annot* pAnnot) {
-  return false;
-}
-
-bool CPDFSDK_BAAnnotHandler::CanRedo(CPDFSDK_Annot* pAnnot) {
-  return false;
-}
-
-bool CPDFSDK_BAAnnotHandler::Undo(CPDFSDK_Annot* pAnnot) {
-  return false;
-}
-
-bool CPDFSDK_BAAnnotHandler::Redo(CPDFSDK_Annot* pAnnot) {
-  return false;
-}
diff --git a/fpdfsdk/cpdfsdk_baannothandler.h b/fpdfsdk/cpdfsdk_baannothandler.h
index 579be4b..7798d43 100644
--- a/fpdfsdk/cpdfsdk_baannothandler.h
+++ b/fpdfsdk/cpdfsdk_baannothandler.h
@@ -31,10 +31,6 @@
   WideString GetSelectedText(CPDFSDK_Annot* pAnnot) override;
   void ReplaceSelection(CPDFSDK_Annot* pAnnot, const WideString& text) override;
   bool SelectAllText(CPDFSDK_Annot* pAnnot) override;
-  bool CanUndo(CPDFSDK_Annot* pAnnot) override;
-  bool CanRedo(CPDFSDK_Annot* pAnnot) override;
-  bool Undo(CPDFSDK_Annot* pAnnot) override;
-  bool Redo(CPDFSDK_Annot* pAnnot) override;
   void OnDraw(CPDFSDK_Annot* pAnnot,
               CFX_RenderDevice* pDevice,
               const CFX_Matrix& mtUser2Device,
diff --git a/fpdfsdk/cpdfsdk_pageview.cpp b/fpdfsdk/cpdfsdk_pageview.cpp
index 60f6ddb..b83f70f 100644
--- a/fpdfsdk/cpdfsdk_pageview.cpp
+++ b/fpdfsdk/cpdfsdk_pageview.cpp
@@ -284,39 +284,23 @@
 }
 
 bool CPDFSDK_PageView::CanUndo() {
-  if (CPDFSDK_Annot* pAnnot = GetFocusAnnot()) {
-    CPDFSDK_AnnotHandlerMgr* pAnnotHandlerMgr =
-        m_pFormFillEnv->GetAnnotHandlerMgr();
-    return pAnnotHandlerMgr->Annot_CanUndo(pAnnot);
-  }
-  return false;
+  CPDFSDK_Annot* annot = GetFocusAnnot();
+  return annot && annot->CanUndo();
 }
 
 bool CPDFSDK_PageView::CanRedo() {
-  if (CPDFSDK_Annot* pAnnot = GetFocusAnnot()) {
-    CPDFSDK_AnnotHandlerMgr* pAnnotHandlerMgr =
-        m_pFormFillEnv->GetAnnotHandlerMgr();
-    return pAnnotHandlerMgr->Annot_CanRedo(pAnnot);
-  }
-  return false;
+  CPDFSDK_Annot* annot = GetFocusAnnot();
+  return annot && annot->CanRedo();
 }
 
 bool CPDFSDK_PageView::Undo() {
-  if (CPDFSDK_Annot* pAnnot = GetFocusAnnot()) {
-    CPDFSDK_AnnotHandlerMgr* pAnnotHandlerMgr =
-        m_pFormFillEnv->GetAnnotHandlerMgr();
-    return pAnnotHandlerMgr->Annot_Undo(pAnnot);
-  }
-  return false;
+  CPDFSDK_Annot* annot = GetFocusAnnot();
+  return annot && annot->Undo();
 }
 
 bool CPDFSDK_PageView::Redo() {
-  if (CPDFSDK_Annot* pAnnot = GetFocusAnnot()) {
-    CPDFSDK_AnnotHandlerMgr* pAnnotHandlerMgr =
-        m_pFormFillEnv->GetAnnotHandlerMgr();
-    return pAnnotHandlerMgr->Annot_Redo(pAnnot);
-  }
-  return false;
+  CPDFSDK_Annot* annot = GetFocusAnnot();
+  return annot && annot->Redo();
 }
 
 bool CPDFSDK_PageView::OnFocus(Mask<FWL_EVENTFLAG> nFlag,
diff --git a/fpdfsdk/cpdfsdk_widget.cpp b/fpdfsdk/cpdfsdk_widget.cpp
index 2c2e7a4..8952509 100644
--- a/fpdfsdk/cpdfsdk_widget.cpp
+++ b/fpdfsdk/cpdfsdk_widget.cpp
@@ -52,7 +52,7 @@
       m_pInteractiveForm(pInteractiveForm) {}
 
 CPDFSDK_Widget::~CPDFSDK_Widget() {
-  m_pPageView->GetFormFillEnv()->GetInteractiveFormFiller()->OnDelete(this);
+  GetInteractiveFormFiller()->OnDelete(this);
   m_pInteractiveForm->RemoveMap(GetFormControl());
 }
 
@@ -694,10 +694,26 @@
   if (IsSignatureWidget())
     return CFX_FloatRect();
 
-  auto* form_filler = m_pPageView->GetFormFillEnv()->GetInteractiveFormFiller();
+  auto* form_filler = GetInteractiveFormFiller();
   return CFX_FloatRect(form_filler->GetViewBBox(GetPageView(), this));
 }
 
+bool CPDFSDK_Widget::CanUndo() {
+  return !IsSignatureWidget() && GetInteractiveFormFiller()->CanUndo(this);
+}
+
+bool CPDFSDK_Widget::CanRedo() {
+  return !IsSignatureWidget() && GetInteractiveFormFiller()->CanRedo(this);
+}
+
+bool CPDFSDK_Widget::Undo() {
+  return !IsSignatureWidget() && GetInteractiveFormFiller()->Undo(this);
+}
+
+bool CPDFSDK_Widget::Redo() {
+  return !IsSignatureWidget() && GetInteractiveFormFiller()->Redo(this);
+}
+
 void CPDFSDK_Widget::DrawAppearance(CFX_RenderDevice* pDevice,
                                     const CFX_Matrix& mtUser2Device,
                                     CPDF_Annot::AppearanceMode mode) {
@@ -903,3 +919,7 @@
 
   return CPDF_Action(nullptr);
 }
+
+CFFL_InteractiveFormFiller* CPDFSDK_Widget::GetInteractiveFormFiller() {
+  return m_pPageView->GetFormFillEnv()->GetInteractiveFormFiller();
+}
diff --git a/fpdfsdk/cpdfsdk_widget.h b/fpdfsdk/cpdfsdk_widget.h
index aa9edd2..a1d1ffb 100644
--- a/fpdfsdk/cpdfsdk_widget.h
+++ b/fpdfsdk/cpdfsdk_widget.h
@@ -18,6 +18,7 @@
 #include "fpdfsdk/cpdfsdk_baannot.h"
 #include "third_party/abseil-cpp/absl/types/optional.h"
 
+class CFFL_InteractiveFormFiller;
 class CFX_RenderDevice;
 class CPDF_Annot;
 class CPDF_FormControl;
@@ -55,6 +56,10 @@
   int GetLayoutOrder() const override;
   bool DoHitTest(const CFX_PointF& point) override;
   CFX_FloatRect GetViewBBox() override;
+  bool CanUndo() override;
+  bool CanRedo() override;
+  bool Undo() override;
+  bool Redo() override;
   void DrawAppearance(CFX_RenderDevice* pDevice,
                       const CFX_Matrix& mtUser2Device,
                       CPDF_Annot::AppearanceMode mode) override;
@@ -132,6 +137,8 @@
   CFX_Color GetFillPWLColor() const;
 
  private:
+  CFFL_InteractiveFormFiller* GetInteractiveFormFiller();
+
 #ifdef PDF_ENABLE_XFA
   CXFA_FFWidgetHandler* GetXFAWidgetHandler() const;
   CXFA_FFWidget* GetGroupMixXFAWidget() const;
diff --git a/fpdfsdk/cpdfsdk_widgethandler.cpp b/fpdfsdk/cpdfsdk_widgethandler.cpp
index 45bed1c..fdbf255 100644
--- a/fpdfsdk/cpdfsdk_widgethandler.cpp
+++ b/fpdfsdk/cpdfsdk_widgethandler.cpp
@@ -245,30 +245,6 @@
              pWidget);
 }
 
-bool CPDFSDK_WidgetHandler::CanUndo(CPDFSDK_Annot* pAnnot) {
-  CPDFSDK_Widget* pWidget = ToCPDFSDKWidget(pAnnot);
-  return !pWidget->IsSignatureWidget() &&
-         GetFormFillEnvironment()->GetInteractiveFormFiller()->CanUndo(pWidget);
-}
-
-bool CPDFSDK_WidgetHandler::CanRedo(CPDFSDK_Annot* pAnnot) {
-  CPDFSDK_Widget* pWidget = ToCPDFSDKWidget(pAnnot);
-  return !pWidget->IsSignatureWidget() &&
-         GetFormFillEnvironment()->GetInteractiveFormFiller()->CanRedo(pWidget);
-}
-
-bool CPDFSDK_WidgetHandler::Undo(CPDFSDK_Annot* pAnnot) {
-  CPDFSDK_Widget* pWidget = ToCPDFSDKWidget(pAnnot);
-  return !pWidget->IsSignatureWidget() &&
-         GetFormFillEnvironment()->GetInteractiveFormFiller()->Undo(pWidget);
-}
-
-bool CPDFSDK_WidgetHandler::Redo(CPDFSDK_Annot* pAnnot) {
-  CPDFSDK_Widget* pWidget = ToCPDFSDKWidget(pAnnot);
-  return !pWidget->IsSignatureWidget() &&
-         GetFormFillEnvironment()->GetInteractiveFormFiller()->Redo(pWidget);
-}
-
 bool CPDFSDK_WidgetHandler::IsFocusableAnnot(
     const CPDF_Annot::Subtype& annot_type) const {
   DCHECK_EQ(annot_type, CPDF_Annot::Subtype::WIDGET);
diff --git a/fpdfsdk/cpdfsdk_widgethandler.h b/fpdfsdk/cpdfsdk_widgethandler.h
index 1a30728..a793dbc 100644
--- a/fpdfsdk/cpdfsdk_widgethandler.h
+++ b/fpdfsdk/cpdfsdk_widgethandler.h
@@ -31,10 +31,6 @@
   WideString GetSelectedText(CPDFSDK_Annot* pAnnot) override;
   void ReplaceSelection(CPDFSDK_Annot* pAnnot, const WideString& text) override;
   bool SelectAllText(CPDFSDK_Annot* pAnnot) override;
-  bool CanUndo(CPDFSDK_Annot* pAnnot) override;
-  bool CanRedo(CPDFSDK_Annot* pAnnot) override;
-  bool Undo(CPDFSDK_Annot* pAnnot) override;
-  bool Redo(CPDFSDK_Annot* pAnnot) override;
   void OnDraw(CPDFSDK_Annot* pAnnot,
               CFX_RenderDevice* pDevice,
               const CFX_Matrix& mtUser2Device,
diff --git a/fpdfsdk/fpdfxfa/cpdfxfa_widget.cpp b/fpdfsdk/fpdfxfa/cpdfxfa_widget.cpp
index f44e918..4e84ca6 100644
--- a/fpdfsdk/fpdfxfa/cpdfxfa_widget.cpp
+++ b/fpdfsdk/fpdfxfa/cpdfxfa_widget.cpp
@@ -33,32 +33,20 @@
 }
 
 bool CPDFXFA_Widget::DoHitTest(const CFX_PointF& point) {
-  CXFA_FFWidget* widget = GetXFAFFWidget();
-  CXFA_FFPageView* page_view = widget->GetPageView();
-  if (!page_view)
-    return false;
-
-  CXFA_FFDocView* doc_view = page_view->GetDocView();
-  if (!doc_view)
-    return false;
-
-  CXFA_FFWidgetHandler* widget_handler = doc_view->GetWidgetHandler();
+  CXFA_FFWidgetHandler* widget_handler = GetWidgetHandler();
   if (!widget_handler)
     return false;
 
-  return widget_handler->HitTest(widget, point) != FWL_WidgetHit::Unknown;
+  return widget_handler->HitTest(GetXFAFFWidget(), point) !=
+         FWL_WidgetHit::Unknown;
 }
 
 bool CPDFXFA_Widget::OnChangedFocus() {
-  CXFA_FFWidget* widget = GetXFAFFWidget();
-  CXFA_FFPageView* page_view = widget->GetPageView();
-  if (!page_view)
-    return false;
-
-  CXFA_FFDocView* doc_view = page_view->GetDocView();
+  CXFA_FFDocView* doc_view = GetDocView();
   if (!doc_view)
     return false;
 
+  CXFA_FFWidget* widget = GetXFAFFWidget();
   if (doc_view->SetFocus(widget))
     return false;
 
@@ -79,3 +67,33 @@
   result.Inflate(1.0f, 1.0f);
   return result;
 }
+
+bool CPDFXFA_Widget::CanUndo() {
+  CXFA_FFWidgetHandler* widget_handler = GetWidgetHandler();
+  return widget_handler && widget_handler->CanUndo(GetXFAFFWidget());
+}
+
+bool CPDFXFA_Widget::CanRedo() {
+  CXFA_FFWidgetHandler* widget_handler = GetWidgetHandler();
+  return widget_handler && widget_handler->CanRedo(GetXFAFFWidget());
+}
+
+bool CPDFXFA_Widget::Undo() {
+  CXFA_FFWidgetHandler* widget_handler = GetWidgetHandler();
+  return widget_handler && widget_handler->Undo(GetXFAFFWidget());
+}
+
+bool CPDFXFA_Widget::Redo() {
+  CXFA_FFWidgetHandler* widget_handler = GetWidgetHandler();
+  return widget_handler && widget_handler->Redo(GetXFAFFWidget());
+}
+
+CXFA_FFDocView* CPDFXFA_Widget::GetDocView() {
+  CXFA_FFPageView* page_view = GetXFAFFWidget()->GetPageView();
+  return page_view ? page_view->GetDocView() : nullptr;
+}
+
+CXFA_FFWidgetHandler* CPDFXFA_Widget::GetWidgetHandler() {
+  CXFA_FFDocView* doc_view = GetDocView();
+  return doc_view ? doc_view->GetWidgetHandler() : nullptr;
+}
diff --git a/fpdfsdk/fpdfxfa/cpdfxfa_widget.h b/fpdfsdk/fpdfxfa/cpdfxfa_widget.h
index b6dafec..237dc10 100644
--- a/fpdfsdk/fpdfxfa/cpdfxfa_widget.h
+++ b/fpdfsdk/fpdfxfa/cpdfxfa_widget.h
@@ -13,6 +13,8 @@
 #include "xfa/fxfa/cxfa_ffwidget.h"
 
 class CPDFSDK_PageView;
+class CXFA_FFDocView;
+class CXFA_FFWidgetHandler;
 
 class CPDFXFA_Widget final : public CPDFSDK_Annot {
  public:
@@ -25,12 +27,19 @@
   CFX_FloatRect GetRect() const override;
   bool DoHitTest(const CFX_PointF& point) override;
   CFX_FloatRect GetViewBBox() override;
+  bool CanUndo() override;
+  bool CanRedo() override;
+  bool Undo() override;
+  bool Redo() override;
 
   CXFA_FFWidget* GetXFAFFWidget() const { return m_pXFAFFWidget.Get(); }
 
   bool OnChangedFocus();
 
  private:
+  CXFA_FFDocView* GetDocView();
+  CXFA_FFWidgetHandler* GetWidgetHandler();
+
   cppgc::Persistent<CXFA_FFWidget> const m_pXFAFFWidget;
 };
 
diff --git a/fpdfsdk/fpdfxfa/cpdfxfa_widgethandler.cpp b/fpdfsdk/fpdfxfa/cpdfxfa_widgethandler.cpp
index bcaeb63..9be1b01 100644
--- a/fpdfsdk/fpdfxfa/cpdfxfa_widgethandler.cpp
+++ b/fpdfsdk/fpdfxfa/cpdfxfa_widgethandler.cpp
@@ -251,30 +251,6 @@
   return pWidgetHandler->SelectAllText(pXFAWidget->GetXFAFFWidget());
 }
 
-bool CPDFXFA_WidgetHandler::CanUndo(CPDFSDK_Annot* pAnnot) {
-  CPDFXFA_Widget* pXFAWidget = ToXFAWidget(pAnnot);
-  CXFA_FFWidgetHandler* pWidgetHandler = GetXFAFFWidgetHandler();
-  return pWidgetHandler->CanUndo(pXFAWidget->GetXFAFFWidget());
-}
-
-bool CPDFXFA_WidgetHandler::CanRedo(CPDFSDK_Annot* pAnnot) {
-  CPDFXFA_Widget* pXFAWidget = ToXFAWidget(pAnnot);
-  CXFA_FFWidgetHandler* pWidgetHandler = GetXFAFFWidgetHandler();
-  return pWidgetHandler->CanRedo(pXFAWidget->GetXFAFFWidget());
-}
-
-bool CPDFXFA_WidgetHandler::Undo(CPDFSDK_Annot* pAnnot) {
-  CPDFXFA_Widget* pXFAWidget = ToXFAWidget(pAnnot);
-  CXFA_FFWidgetHandler* pWidgetHandler = GetXFAFFWidgetHandler();
-  return pWidgetHandler->Undo(pXFAWidget->GetXFAFFWidget());
-}
-
-bool CPDFXFA_WidgetHandler::Redo(CPDFSDK_Annot* pAnnot) {
-  CPDFXFA_Widget* pXFAWidget = ToXFAWidget(pAnnot);
-  CXFA_FFWidgetHandler* pWidgetHandler = GetXFAFFWidgetHandler();
-  return pWidgetHandler->Redo(pXFAWidget->GetXFAFFWidget());
-}
-
 void CPDFXFA_WidgetHandler::OnMouseEnter(ObservedPtr<CPDFSDK_Annot>& pAnnot,
                                          Mask<FWL_EVENTFLAG> nFlag) {
   CPDFXFA_Widget* pXFAWidget = ToXFAWidget(pAnnot.Get());
diff --git a/fpdfsdk/fpdfxfa/cpdfxfa_widgethandler.h b/fpdfsdk/fpdfxfa/cpdfxfa_widgethandler.h
index a25d9d8..5821f2a 100644
--- a/fpdfsdk/fpdfxfa/cpdfxfa_widgethandler.h
+++ b/fpdfsdk/fpdfxfa/cpdfxfa_widgethandler.h
@@ -34,10 +34,6 @@
   WideString GetSelectedText(CPDFSDK_Annot* pAnnot) override;
   void ReplaceSelection(CPDFSDK_Annot* pAnnot, const WideString& text) override;
   bool SelectAllText(CPDFSDK_Annot* pAnnot) override;
-  bool CanUndo(CPDFSDK_Annot* pAnnot) override;
-  bool CanRedo(CPDFSDK_Annot* pAnnot) override;
-  bool Undo(CPDFSDK_Annot* pAnnot) override;
-  bool Redo(CPDFSDK_Annot* pAnnot) override;
   void OnDraw(CPDFSDK_Annot* pAnnot,
               CFX_RenderDevice* pDevice,
               const CFX_Matrix& mtUser2Device,
diff --git a/fpdfsdk/ipdfsdk_annothandler.h b/fpdfsdk/ipdfsdk_annothandler.h
index eb8326b..0e1aca9 100644
--- a/fpdfsdk/ipdfsdk_annothandler.h
+++ b/fpdfsdk/ipdfsdk_annothandler.h
@@ -44,10 +44,6 @@
   virtual void ReplaceSelection(CPDFSDK_Annot* pAnnot,
                                 const WideString& text) = 0;
   virtual bool SelectAllText(CPDFSDK_Annot* pAnnot) = 0;
-  virtual bool CanUndo(CPDFSDK_Annot* pAnnot) = 0;
-  virtual bool CanRedo(CPDFSDK_Annot* pAnnot) = 0;
-  virtual bool Undo(CPDFSDK_Annot* pAnnot) = 0;
-  virtual bool Redo(CPDFSDK_Annot* pAnnot) = 0;
   virtual void OnDraw(CPDFSDK_Annot* pAnnot,
                       CFX_RenderDevice* pDevice,
                       const CFX_Matrix& mtUser2Device,