Make CJS_Annot::m_pAnnot point to a BAAnnot subclass.

No need to store the pointer as the parent class, and then
downcast to the subclass since it is only set using a method
that already takes a BAAnnot argument.

Change-Id: I3a36386900ff86b4a835df783137b9d9b338b48f
Reviewed-on: https://pdfium-review.googlesource.com/c/pdfium/+/84273
Commit-Queue: Tom Sepez <tsepez@chromium.org>
Commit-Queue: Lei Zhang <thestig@chromium.org>
Reviewed-by: Lei Zhang <thestig@chromium.org>
diff --git a/fxjs/cjs_annot.cpp b/fxjs/cjs_annot.cpp
index f13479c..3c89b0d 100644
--- a/fxjs/cjs_annot.cpp
+++ b/fxjs/cjs_annot.cpp
@@ -7,7 +7,6 @@
 #include "fxjs/cjs_annot.h"
 
 #include "constants/annotation_flags.h"
-#include "fpdfsdk/cpdfsdk_baannot.h"
 #include "fxjs/cjs_event_context.h"
 #include "fxjs/cjs_object.h"
 #include "fxjs/js_define.h"
@@ -47,7 +46,7 @@
   if (!m_pAnnot)
     return CJS_Result::Failure(JSMessage::kBadObjectError);
 
-  CPDF_Annot* pPDFAnnot = m_pAnnot->AsBAAnnot()->GetPDFAnnot();
+  CPDF_Annot* pPDFAnnot = m_pAnnot->GetPDFAnnot();
   return CJS_Result::Success(pRuntime->NewBoolean(pPDFAnnot->IsHidden()));
 }
 
@@ -56,7 +55,7 @@
   // May invalidate m_pAnnot.
   bool bHidden = pRuntime->ToBoolean(vp);
 
-  CPDFSDK_BAAnnot* pBAAnnot = ToBAAnnot(m_pAnnot.Get());
+  CPDFSDK_BAAnnot* pBAAnnot = m_pAnnot.Get();
   if (!pBAAnnot)
     return CJS_Result::Failure(JSMessage::kBadObjectError);
 
@@ -77,7 +76,7 @@
 }
 
 CJS_Result CJS_Annot::get_name(CJS_Runtime* pRuntime) {
-  CPDFSDK_BAAnnot* pBAAnnot = ToBAAnnot(m_pAnnot.Get());
+  CPDFSDK_BAAnnot* pBAAnnot = m_pAnnot.Get();
   if (!pBAAnnot)
     return CJS_Result::Failure(JSMessage::kBadObjectError);
 
@@ -89,7 +88,7 @@
   // May invalidate m_pAnnot.
   WideString annotName = pRuntime->ToWideString(vp);
 
-  CPDFSDK_BAAnnot* pBAAnnot = ToBAAnnot(m_pAnnot.Get());
+  CPDFSDK_BAAnnot* pBAAnnot = m_pAnnot.Get();
   if (!pBAAnnot)
     return CJS_Result::Failure(JSMessage::kBadObjectError);
 
@@ -98,7 +97,7 @@
 }
 
 CJS_Result CJS_Annot::get_type(CJS_Runtime* pRuntime) {
-  CPDFSDK_BAAnnot* pBAAnnot = ToBAAnnot(m_pAnnot.Get());
+  CPDFSDK_BAAnnot* pBAAnnot = m_pAnnot.Get();
   if (!pBAAnnot)
     return CJS_Result::Failure(JSMessage::kBadObjectError);
 
diff --git a/fxjs/cjs_annot.h b/fxjs/cjs_annot.h
index 4328a90..7c87d23 100644
--- a/fxjs/cjs_annot.h
+++ b/fxjs/cjs_annot.h
@@ -7,11 +7,10 @@
 #ifndef FXJS_CJS_ANNOT_H_
 #define FXJS_CJS_ANNOT_H_
 
+#include "fpdfsdk/cpdfsdk_baannot.h"
 #include "fxjs/cjs_object.h"
 #include "fxjs/js_define.h"
 
-class CPDFSDK_BAAnnot;
-
 class CJS_Annot final : public CJS_Object {
  public:
   static uint32_t GetObjDefnID();
@@ -40,7 +39,7 @@
   CJS_Result get_type(CJS_Runtime* pRuntime);
   CJS_Result set_type(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp);
 
-  ObservedPtr<CPDFSDK_Annot> m_pAnnot;
+  ObservedPtr<CPDFSDK_BAAnnot> m_pAnnot;
 };
 
 #endif  // FXJS_CJS_ANNOT_H_