Encapsulate CPDF_AnnotList::m_AnnotList.

Hide implementation from callers.

Change-Id: I33ad49324e6d256dbbd6507b681f1d33e1841f4f
Reviewed-on: https://pdfium-review.googlesource.com/c/pdfium/+/95990
Reviewed-by: Lei Zhang <thestig@chromium.org>
Commit-Queue: Tom Sepez <tsepez@chromium.org>
diff --git a/core/fpdfdoc/cpdf_annotlist.cpp b/core/fpdfdoc/cpdf_annotlist.cpp
index 5a2912f..2c90d0f 100644
--- a/core/fpdfdoc/cpdf_annotlist.cpp
+++ b/core/fpdfdoc/cpdf_annotlist.cpp
@@ -222,6 +222,14 @@
   m_AnnotList.clear();
 }
 
+bool CPDF_AnnotList::Contains(const CPDF_Annot* pAnnot) const {
+  auto it = std::find_if(m_AnnotList.begin(), m_AnnotList.end(),
+                         [pAnnot](const std::unique_ptr<CPDF_Annot>& annot) {
+                           return annot.get() == pAnnot;
+                         });
+  return it != m_AnnotList.end();
+}
+
 void CPDF_AnnotList::DisplayPass(CPDF_Page* pPage,
                                  CFX_RenderDevice* pDevice,
                                  CPDF_RenderContext* pContext,
diff --git a/core/fpdfdoc/cpdf_annotlist.h b/core/fpdfdoc/cpdf_annotlist.h
index 2664407..68898dc 100644
--- a/core/fpdfdoc/cpdf_annotlist.h
+++ b/core/fpdfdoc/cpdf_annotlist.h
@@ -37,9 +37,7 @@
 
   size_t Count() const { return m_AnnotList.size(); }
   CPDF_Annot* GetAt(size_t index) const { return m_AnnotList[index].get(); }
-  const std::vector<std::unique_ptr<CPDF_Annot>>& All() const {
-    return m_AnnotList;
-  }
+  bool Contains(const CPDF_Annot* pAnnot) const;
 
  private:
   void DisplayPass(CPDF_Page* pPage,
diff --git a/fpdfsdk/cpdfsdk_pageview.cpp b/fpdfsdk/cpdfsdk_pageview.cpp
index a69c8b6..d16df90 100644
--- a/fpdfsdk/cpdfsdk_pageview.cpp
+++ b/fpdfsdk/cpdfsdk_pageview.cpp
@@ -588,15 +588,7 @@
 }
 
 bool CPDFSDK_PageView::IsValidAnnot(const CPDF_Annot* p) const {
-  if (!p)
-    return false;
-
-  const auto& annots = m_pAnnotList->All();
-  auto it = std::find_if(annots.begin(), annots.end(),
-                         [p](const std::unique_ptr<CPDF_Annot>& annot) {
-                           return annot.get() == p;
-                         });
-  return it != annots.end();
+  return p && m_pAnnotList->Contains(p);
 }
 
 bool CPDFSDK_PageView::IsValidSDKAnnot(const CPDFSDK_Annot* p) const {