Better encapsulate CPDFSDK_Annot

Bug: pdfium:1680
Change-Id: Iade783134c174b6db64b575a45328f821731ab39
Reviewed-on: https://pdfium-review.googlesource.com/c/pdfium/+/96514
Reviewed-by: Lei Zhang <thestig@chromium.org>
Commit-Queue: Tom Sepez <tsepez@chromium.org>
diff --git a/fpdfsdk/cpdfsdk_annot.h b/fpdfsdk/cpdfsdk_annot.h
index aafd4c8..d930e62 100644
--- a/fpdfsdk/cpdfsdk_annot.h
+++ b/fpdfsdk/cpdfsdk_annot.h
@@ -130,6 +130,7 @@
  protected:
   explicit CPDFSDK_Annot(CPDFSDK_PageView* pPageView);
 
+ private:
   UnownedPtr<CPDFSDK_PageView> const m_pPageView;
 };
 
diff --git a/fpdfsdk/cpdfsdk_baannot.cpp b/fpdfsdk/cpdfsdk_baannot.cpp
index 26d3ca5..53e5ff2 100644
--- a/fpdfsdk/cpdfsdk_baannot.cpp
+++ b/fpdfsdk/cpdfsdk_baannot.cpp
@@ -67,7 +67,7 @@
 bool CPDFSDK_BAAnnot::IsFocusableAnnot(
     const CPDF_Annot::Subtype& annot_type) const {
   return pdfium::Contains(
-      m_pPageView->GetFormFillEnv()->GetFocusableAnnotSubtypes(), annot_type);
+      GetPageView()->GetFormFillEnv()->GetFocusableAnnotSubtypes(), annot_type);
 }
 
 CFX_FloatRect CPDFSDK_BAAnnot::GetRect() const {
@@ -81,7 +81,7 @@
 void CPDFSDK_BAAnnot::DrawAppearance(CFX_RenderDevice* pDevice,
                                      const CFX_Matrix& mtUser2Device,
                                      CPDF_Annot::AppearanceMode mode) {
-  m_pAnnot->DrawAppearance(m_pPageView->GetPDFPage(), pDevice, mtUser2Device,
+  m_pAnnot->DrawAppearance(GetPageView()->GetPDFPage(), pDevice, mtUser2Device,
                            mode);
 }
 
@@ -252,7 +252,7 @@
   view_bounding_box.Inflate(1, 1);
   view_bounding_box.Normalize();
   FX_RECT rect = view_bounding_box.GetOuterRect();
-  m_pPageView->GetFormFillEnv()->Invalidate(GetPage(), rect);
+  GetPageView()->GetFormFillEnv()->Invalidate(GetPage(), rect);
 }
 
 int CPDFSDK_BAAnnot::GetLayoutOrder() const {
@@ -275,7 +275,7 @@
   }
 
   if (!is_focused_ || !IsFocusableAnnot(annot_type) ||
-      this != m_pPageView->GetFormFillEnv()->GetFocusAnnot()) {
+      this != GetPageView()->GetFormFillEnv()->GetFocusAnnot()) {
     return;
   }
 
@@ -356,7 +356,7 @@
   }
 
   CPDF_Action action = GetAAction(CPDF_AAction::kKeyStroke);
-  CPDFSDK_FormFillEnvironment* env = m_pPageView->GetFormFillEnv();
+  CPDFSDK_FormFillEnvironment* env = GetPageView()->GetFormFillEnv();
   if (action.GetDict()) {
     return env->DoActionLink(action, CPDF_AAction::kKeyStroke, nFlags);
   }
@@ -426,6 +426,6 @@
 
   // Link annotations can have "Dest" entry defined as an explicit array.
   // See ISO 32000-1:2008 spec, section 12.3.2.1.
-  return CPDF_Dest::Create(m_pPageView->GetPDFDocument(),
+  return CPDF_Dest::Create(GetPageView()->GetPDFDocument(),
                            GetAnnotDict()->GetDirectObjectFor("Dest"));
 }
diff --git a/fpdfsdk/cpdfsdk_widget.cpp b/fpdfsdk/cpdfsdk_widget.cpp
index 6812392..de23bd6 100644
--- a/fpdfsdk/cpdfsdk_widget.cpp
+++ b/fpdfsdk/cpdfsdk_widget.cpp
@@ -58,7 +58,7 @@
 #ifdef PDF_ENABLE_XFA
 CXFA_FFWidget* CPDFSDK_Widget::GetMixXFAWidget() const {
   CPDF_Document::Extension* pContext =
-      m_pPageView->GetFormFillEnv()->GetDocExtension();
+      GetPageView()->GetFormFillEnv()->GetDocExtension();
   if (!pContext || !pContext->ContainsExtensionForegroundForm())
     return nullptr;
 
@@ -84,7 +84,7 @@
 
 CXFA_FFWidget* CPDFSDK_Widget::GetGroupMixXFAWidget() const {
   CPDF_Document::Extension* pContext =
-      m_pPageView->GetFormFillEnv()->GetDocExtension();
+      GetPageView()->GetFormFillEnv()->GetDocExtension();
   if (!pContext || !pContext->ContainsExtensionForegroundForm())
     return nullptr;
 
@@ -99,7 +99,7 @@
 
 CXFA_FFWidgetHandler* CPDFSDK_Widget::GetXFAWidgetHandler() const {
   CPDF_Document::Extension* pContext =
-      m_pPageView->GetFormFillEnv()->GetDocExtension();
+      GetPageView()->GetFormFillEnv()->GetDocExtension();
   if (!pContext || !pContext->ContainsExtensionForegroundForm())
     return nullptr;
 
@@ -209,7 +209,7 @@
                                   CFFL_FieldAction* data,
                                   const CPDFSDK_PageView* pPageView) {
   auto* pContext = static_cast<CPDFXFA_Context*>(
-      m_pPageView->GetFormFillEnv()->GetDocExtension());
+      GetPageView()->GetFormFillEnv()->GetDocExtension());
   if (!pContext)
     return false;
 
@@ -295,7 +295,7 @@
 
   if (bSynchronizeElse) {
     auto* context = static_cast<CPDFXFA_Context*>(
-        m_pPageView->GetFormFillEnv()->GetDocExtension());
+        GetPageView()->GetFormFillEnv()->GetDocExtension());
     context->GetXFADocView()->ProcessValueChanged(node);
   }
 }
@@ -394,7 +394,7 @@
 bool CPDFSDK_Widget::IsAppearanceValid() {
 #ifdef PDF_ENABLE_XFA
   CPDF_Document::Extension* pContext =
-      m_pPageView->GetFormFillEnv()->GetDocExtension();
+      GetPageView()->GetFormFillEnv()->GetDocExtension();
   if (pContext && pContext->ContainsExtensionFullForm())
     return true;
 #endif  // PDF_ENABLE_XFA
@@ -1048,7 +1048,7 @@
   }
 
 #ifdef PDF_ENABLE_XFA
-  auto* pContext = m_pPageView->GetFormFillEnv()->GetDocExtension();
+  auto* pContext = GetPageView()->GetFormFillEnv()->GetDocExtension();
   if (pContext && pContext->ContainsExtensionForegroundForm()) {
     if (!IsAppearanceValid() && !GetValue().IsEmpty())
       ResetXFAAppearance(CPDFSDK_Widget::kValueUnchanged);
@@ -1087,5 +1087,5 @@
 }
 
 CFFL_InteractiveFormFiller* CPDFSDK_Widget::GetInteractiveFormFiller() {
-  return m_pPageView->GetFormFillEnv()->GetInteractiveFormFiller();
+  return GetPageView()->GetFormFillEnv()->GetInteractiveFormFiller();
 }
diff --git a/fpdfsdk/fpdfxfa/cpdfxfa_widget.cpp b/fpdfsdk/fpdfxfa/cpdfxfa_widget.cpp
index c4c16a8..bb60ea6 100644
--- a/fpdfsdk/fpdfxfa/cpdfxfa_widget.cpp
+++ b/fpdfsdk/fpdfxfa/cpdfxfa_widget.cpp
@@ -245,7 +245,7 @@
     return;
 
   CFGAS_GEGraphics gs(pDevice);
-  bool is_highlight = m_pPageView->GetFormFillEnv()->GetFocusAnnot() != this;
+  bool is_highlight = GetPageView()->GetFormFillEnv()->GetFocusAnnot() != this;
   widget_handler->RenderWidget(GetXFAFFWidget(), &gs, mtUser2Device,
                                is_highlight);