Rename CPDF_Document::GetPage() to GetPageDictionary().

Avoids a conflict should we wish to have the document actually
track pages, with a GetPage() that returns CPDF_Page.

Do the same thing to CPDF_DataAvail along the way.
Add some missing consts as well.

Change-Id: I2cb2213cc4c0649662fceab80407ee4a3f4cf30e
Reviewed-on: https://pdfium-review.googlesource.com/32158
Commit-Queue: dsinclair <dsinclair@chromium.org>
Reviewed-by: dsinclair <dsinclair@chromium.org>
diff --git a/core/fpdfapi/parser/cpdf_data_avail.cpp b/core/fpdfapi/parser/cpdf_data_avail.cpp
index e871e0a..3ffe6f6 100644
--- a/core/fpdfapi/parser/cpdf_data_avail.cpp
+++ b/core/fpdfapi/parser/cpdf_data_avail.cpp
@@ -475,7 +475,7 @@
 std::unique_ptr<CPDF_Object> CPDF_DataAvail::ParseIndirectObjectAt(
     FX_FILESIZE pos,
     uint32_t objnum,
-    CPDF_IndirectObjectHolder* pObjList) {
+    CPDF_IndirectObjectHolder* pObjList) const {
   const FX_FILESIZE SavedPos = GetSyntaxParser()->GetPos();
   GetSyntaxParser()->SetPos(pos);
   std::unique_ptr<CPDF_Object> result = GetSyntaxParser()->GetIndirectObject(
@@ -828,7 +828,7 @@
 
   if (m_pLinearized) {
     if (dwPage == m_pLinearized->GetFirstPageNo()) {
-      CPDF_Dictionary* pPageDict = m_pDocument->GetPage(safePage.ValueOrDie());
+      auto* pPageDict = m_pDocument->GetPageDictionary(safePage.ValueOrDie());
       if (!pPageDict)
         return DataError;
 
@@ -850,7 +850,7 @@
       nResult = m_pHintTables->CheckPage(dwPage);
       if (nResult != DataAvailable)
         return nResult;
-      if (GetPage(dwPage)) {
+      if (GetPageDictionary(dwPage)) {
         m_pagesLoadState.insert(dwPage);
         return DataAvailable;
       }
@@ -879,7 +879,7 @@
   if (CheckAcroForm() == DocFormStatus::FormNotAvailable)
     return DataNotAvailable;
 
-  CPDF_Dictionary* pPageDict = m_pDocument->GetPage(safePage.ValueOrDie());
+  auto* pPageDict = m_pDocument->GetPageDictionary(safePage.ValueOrDie());
   if (!pPageDict)
     return DataError;
 
@@ -943,10 +943,10 @@
   return m_pDocument ? m_pDocument->GetPageCount() : 0;
 }
 
-CPDF_Dictionary* CPDF_DataAvail::GetPage(int index) {
+CPDF_Dictionary* CPDF_DataAvail::GetPageDictionary(int index) const {
   if (!m_pDocument || index < 0 || index >= GetPageCount())
     return nullptr;
-  CPDF_Dictionary* page = m_pDocument->GetPage(index);
+  CPDF_Dictionary* page = m_pDocument->GetPageDictionary(index);
   if (page)
     return page;
   if (!m_pLinearized || !m_pHintTables)
@@ -970,7 +970,7 @@
   }
   if (!ValidatePage(index))
     return nullptr;
-  return m_pDocument->GetPage(index);
+  return m_pDocument->GetPageDictionary(index);
 }
 
 CPDF_DataAvail::DocFormStatus CPDF_DataAvail::IsFormAvail(
@@ -1016,9 +1016,9 @@
   return DocFormStatus::FormError;
 }
 
-bool CPDF_DataAvail::ValidatePage(uint32_t dwPage) {
+bool CPDF_DataAvail::ValidatePage(uint32_t dwPage) const {
   FX_SAFE_INT32 safePage = pdfium::base::checked_cast<int32_t>(dwPage);
-  CPDF_Dictionary* pPageDict = m_pDocument->GetPage(safePage.ValueOrDie());
+  auto* pPageDict = m_pDocument->GetPageDictionary(safePage.ValueOrDie());
   if (!pPageDict)
     return false;
   CPDF_PageObjectAvail obj_avail(GetValidator().Get(), m_pDocument, pPageDict);
diff --git a/core/fpdfapi/parser/cpdf_data_avail.h b/core/fpdfapi/parser/cpdf_data_avail.h
index dfb1f0c..2a0705d 100644
--- a/core/fpdfapi/parser/cpdf_data_avail.h
+++ b/core/fpdfapi/parser/cpdf_data_avail.h
@@ -102,7 +102,7 @@
   DocLinearizationStatus IsLinearizedPDF();
   RetainPtr<IFX_SeekableReadStream> GetFileRead() const;
   int GetPageCount() const;
-  CPDF_Dictionary* GetPage(int index);
+  CPDF_Dictionary* GetPageDictionary(int index) const;
   RetainPtr<CPDF_ReadValidator> GetValidator() const;
 
   std::pair<CPDF_Parser::Error, std::unique_ptr<CPDF_Document>> ParseDocument(
@@ -139,7 +139,7 @@
   std::unique_ptr<CPDF_Object> ParseIndirectObjectAt(
       FX_FILESIZE pos,
       uint32_t objnum,
-      CPDF_IndirectObjectHolder* pObjList = nullptr);
+      CPDF_IndirectObjectHolder* pObjList = nullptr) const;
   std::unique_ptr<CPDF_Object> GetObject(uint32_t objnum,
                                          bool* pExistInFile);
   bool GetPageKids(CPDF_Parser* pParser, CPDF_Object* pPages);
@@ -161,7 +161,7 @@
   bool CheckPageCount();
   bool IsFirstCheck(uint32_t dwPage);
   void ResetFirstCheck(uint32_t dwPage);
-  bool ValidatePage(uint32_t dwPage);
+  bool ValidatePage(uint32_t dwPage) const;
   CPDF_SyntaxParser* GetSyntaxParser() const;
 
   FileAvail* const m_pFileAvail;
diff --git a/core/fpdfapi/parser/cpdf_document.cpp b/core/fpdfapi/parser/cpdf_document.cpp
index 32350b7..13f5db2 100644
--- a/core/fpdfapi/parser/cpdf_document.cpp
+++ b/core/fpdfapi/parser/cpdf_document.cpp
@@ -331,7 +331,7 @@
   return !!m_PageList[iPage];
 }
 
-CPDF_Dictionary* CPDF_Document::GetPage(int iPage) {
+CPDF_Dictionary* CPDF_Document::GetPageDictionary(int iPage) {
   if (!pdfium::IndexInBounds(m_PageList, iPage))
     return nullptr;
 
diff --git a/core/fpdfapi/parser/cpdf_document.h b/core/fpdfapi/parser/cpdf_document.h
index 5ee3c77..8690efe 100644
--- a/core/fpdfapi/parser/cpdf_document.h
+++ b/core/fpdfapi/parser/cpdf_document.h
@@ -65,7 +65,7 @@
   void DeletePage(int iPage);
   int GetPageCount() const;
   bool IsPageLoaded(int iPage) const;
-  CPDF_Dictionary* GetPage(int iPage);
+  CPDF_Dictionary* GetPageDictionary(int iPage);
   int GetPageIndex(uint32_t objnum);
   uint32_t GetUserPermissions() const;
 
diff --git a/core/fpdfapi/parser/cpdf_document_unittest.cpp b/core/fpdfapi/parser/cpdf_document_unittest.cpp
index d1b8dce..f06a7f4 100644
--- a/core/fpdfapi/parser/cpdf_document_unittest.cpp
+++ b/core/fpdfapi/parser/cpdf_document_unittest.cpp
@@ -164,22 +164,22 @@
   std::unique_ptr<CPDF_TestDocumentForPages> document =
       pdfium::MakeUnique<CPDF_TestDocumentForPages>();
   for (int i = 0; i < kNumTestPages; i++) {
-    CPDF_Dictionary* page = document->GetPage(i);
+    CPDF_Dictionary* page = document->GetPageDictionary(i);
     ASSERT_TRUE(page);
     ASSERT_TRUE(page->KeyExist("PageNumbering"));
     EXPECT_EQ(i, page->GetIntegerFor("PageNumbering"));
   }
-  CPDF_Dictionary* page = document->GetPage(kNumTestPages);
+  CPDF_Dictionary* page = document->GetPageDictionary(kNumTestPages);
   EXPECT_FALSE(page);
 }
 
 TEST_F(cpdf_document_test, GetPageWithoutObjNumTwice) {
   auto document = pdfium::MakeUnique<CPDF_TestDocumentWithPageWithoutPageNum>();
-  const CPDF_Dictionary* page = document->GetPage(2);
+  CPDF_Dictionary* page = document->GetPageDictionary(2);
   ASSERT_TRUE(page);
   ASSERT_EQ(document->inlined_page(), page);
 
-  const CPDF_Dictionary* second_call_page = document->GetPage(2);
+  CPDF_Dictionary* second_call_page = document->GetPageDictionary(2);
   EXPECT_TRUE(second_call_page);
   EXPECT_EQ(page, second_call_page);
 }
@@ -188,12 +188,12 @@
   std::unique_ptr<CPDF_TestDocumentForPages> document =
       pdfium::MakeUnique<CPDF_TestDocumentForPages>();
   for (int i = 6; i >= 0; i--) {
-    CPDF_Dictionary* page = document->GetPage(i);
+    CPDF_Dictionary* page = document->GetPageDictionary(i);
     ASSERT_TRUE(page);
     ASSERT_TRUE(page->KeyExist("PageNumbering"));
     EXPECT_EQ(i, page->GetIntegerFor("PageNumbering"));
   }
-  CPDF_Dictionary* page = document->GetPage(kNumTestPages);
+  CPDF_Dictionary* page = document->GetPageDictionary(kNumTestPages);
   EXPECT_FALSE(page);
 }
 
@@ -201,20 +201,20 @@
   std::unique_ptr<CPDF_TestDocumentForPages> document =
       pdfium::MakeUnique<CPDF_TestDocumentForPages>();
 
-  CPDF_Dictionary* page = document->GetPage(1);
+  CPDF_Dictionary* page = document->GetPageDictionary(1);
   ASSERT_TRUE(page);
   ASSERT_TRUE(page->KeyExist("PageNumbering"));
   EXPECT_EQ(1, page->GetIntegerFor("PageNumbering"));
 
-  page = document->GetPage(3);
+  page = document->GetPageDictionary(3);
   ASSERT_TRUE(page);
   ASSERT_TRUE(page->KeyExist("PageNumbering"));
   EXPECT_EQ(3, page->GetIntegerFor("PageNumbering"));
 
-  page = document->GetPage(kNumTestPages);
+  page = document->GetPageDictionary(kNumTestPages);
   EXPECT_FALSE(page);
 
-  page = document->GetPage(6);
+  page = document->GetPageDictionary(6);
   ASSERT_TRUE(page);
   ASSERT_TRUE(page->KeyExist("PageNumbering"));
   EXPECT_EQ(6, page->GetIntegerFor("PageNumbering"));
@@ -237,11 +237,11 @@
   const int test_page_num = 33;
 
   EXPECT_FALSE(document.IsPageLoaded(test_page_num));
-  EXPECT_EQ(nullptr, document.GetPage(test_page_num));
+  EXPECT_EQ(nullptr, document.GetPageDictionary(test_page_num));
 
   document.SetPageObjNum(test_page_num, obj_num);
   EXPECT_TRUE(document.IsPageLoaded(test_page_num));
-  EXPECT_EQ(page_stub, document.GetPage(test_page_num));
+  EXPECT_EQ(page_stub, document.GetPageDictionary(test_page_num));
 }
 
 TEST_F(cpdf_document_test, CountGreaterThanPageTree) {
@@ -249,19 +249,19 @@
       pdfium::MakeUnique<CPDF_TestDocumentForPages>();
   document->SetTreeSize(kNumTestPages + 3);
   for (int i = 0; i < kNumTestPages; i++)
-    EXPECT_TRUE(document->GetPage(i));
+    EXPECT_TRUE(document->GetPageDictionary(i));
   for (int i = kNumTestPages; i < kNumTestPages + 4; i++)
-    EXPECT_FALSE(document->GetPage(i));
-  EXPECT_TRUE(document->GetPage(kNumTestPages - 1));
+    EXPECT_FALSE(document->GetPageDictionary(i));
+  EXPECT_TRUE(document->GetPageDictionary(kNumTestPages - 1));
 }
 
 TEST_F(cpdf_document_test, PagesWithoutKids) {
   // Set up a document with Pages dict without kids, and Count = 3
   auto pDoc = pdfium::MakeUnique<CPDF_TestDocPagesWithoutKids>();
-  EXPECT_TRUE(pDoc->GetPage(0));
+  EXPECT_TRUE(pDoc->GetPageDictionary(0));
   // Test GetPage does not fetch pages out of range
   for (int i = 1; i < 5; i++)
-    EXPECT_FALSE(pDoc->GetPage(i));
+    EXPECT_FALSE(pDoc->GetPageDictionary(i));
 
-  EXPECT_TRUE(pDoc->GetPage(0));
+  EXPECT_TRUE(pDoc->GetPageDictionary(0));
 }
diff --git a/fpdfsdk/cpdfsdk_interform.cpp b/fpdfsdk/cpdfsdk_interform.cpp
index 5ebf683..4f11bab 100644
--- a/fpdfsdk/cpdfsdk_interform.cpp
+++ b/fpdfsdk/cpdfsdk_interform.cpp
@@ -176,7 +176,7 @@
   ASSERT(pAnnotDict);
 
   for (int i = 0, sz = pDocument->GetPageCount(); i < sz; i++) {
-    if (CPDF_Dictionary* pPageDict = pDocument->GetPage(i)) {
+    if (CPDF_Dictionary* pPageDict = pDocument->GetPageDictionary(i)) {
       if (CPDF_Array* pAnnots = pPageDict->GetArrayFor("Annots")) {
         for (int j = 0, jsz = pAnnots->GetCount(); j < jsz; j++) {
           CPDF_Object* pDict = pAnnots->GetDirectObjectAt(j);
diff --git a/fpdfsdk/fpdf_ppo.cpp b/fpdfsdk/fpdf_ppo.cpp
index 0847113..c3b6402 100644
--- a/fpdfsdk/fpdf_ppo.cpp
+++ b/fpdfsdk/fpdf_ppo.cpp
@@ -466,7 +466,7 @@
   auto pObjNumberMap = pdfium::MakeUnique<ObjectNumberMap>();
   for (size_t i = 0; i < pageNums.size(); ++i) {
     CPDF_Dictionary* pDestPageDict = dest()->CreateNewPage(curpage);
-    const CPDF_Dictionary* pSrcPageDict = src()->GetPage(pageNums[i] - 1);
+    auto* pSrcPageDict = src()->GetPageDictionary(pageNums[i] - 1);
     if (!pSrcPageDict || !pDestPageDict)
       return false;
 
@@ -614,7 +614,7 @@
     // Mapping of XObject name and XObject object number of one page.
     XObjectNameNumberMap xObjNameNumberMap;
     for (size_t innerPage = outerPage; innerPage < innerPageMax; ++innerPage) {
-      CPDF_Dictionary* pSrcPageDict = src()->GetPage(pageNums[innerPage] - 1);
+      auto* pSrcPageDict = src()->GetPageDictionary(pageNums[innerPage] - 1);
       if (!pSrcPageDict)
         return false;
 
diff --git a/fpdfsdk/fpdf_view.cpp b/fpdfsdk/fpdf_view.cpp
index 919690f..f5eea66 100644
--- a/fpdfsdk/fpdf_view.cpp
+++ b/fpdfsdk/fpdf_view.cpp
@@ -351,7 +351,7 @@
   // Eventually, fallthrough into non-xfa case once page type made consistent.
   return nullptr;
 #else   // PDF_ENABLE_XFA
-  CPDF_Dictionary* pDict = pDoc->GetPage(page_index);
+  CPDF_Dictionary* pDict = pDoc->GetPageDictionary(page_index);
   if (!pDict)
     return nullptr;
 
@@ -966,7 +966,7 @@
   }
 #endif  // PDF_ENABLE_XFA
 
-  CPDF_Dictionary* pDict = pDoc->GetPage(page_index);
+  CPDF_Dictionary* pDict = pDoc->GetPageDictionary(page_index);
   if (!pDict)
     return false;
 
diff --git a/fpdfsdk/fpdfxfa/cpdfxfa_page.cpp b/fpdfsdk/fpdfxfa/cpdfxfa_page.cpp
index f1d7aa9..9fe63f4 100644
--- a/fpdfsdk/fpdfxfa/cpdfxfa_page.cpp
+++ b/fpdfsdk/fpdfxfa/cpdfxfa_page.cpp
@@ -22,7 +22,7 @@
   CPDF_Document* pPDFDoc = m_pContext->GetPDFDoc();
   CPDF_Dictionary* pDict = nullptr;
   if (pPDFDoc && m_pContext->GetFormType() != FormType::kXFAFull)
-    pDict = pPDFDoc->GetPage(m_iPageIndex);
+    pDict = pPDFDoc->GetPageDictionary(m_iPageIndex);
   m_pPDFPage = pdfium::MakeUnique<CPDF_Page>(pPDFDoc, pDict, true);
   m_pPDFPage->SetPageExtension(this);
 }
diff --git a/fxjs/cjs_document.cpp b/fxjs/cjs_document.cpp
index 0770190..de3c93c 100644
--- a/fxjs/cjs_document.cpp
+++ b/fxjs/cjs_document.cpp
@@ -1251,7 +1251,7 @@
   if (nPageNo < 0 || nPageNo >= pDocument->GetPageCount())
     return CJS_Return(JSGetStringFromID(JSMessage::kValueError));
 
-  CPDF_Dictionary* pPageDict = pDocument->GetPage(nPageNo);
+  CPDF_Dictionary* pPageDict = pDocument->GetPageDictionary(nPageNo);
   if (!pPageDict)
     return CJS_Return(false);
 
@@ -1300,7 +1300,7 @@
   if (nPageNo < 0 || nPageNo >= pDocument->GetPageCount())
     return CJS_Return(JSGetStringFromID(JSMessage::kValueError));
 
-  CPDF_Dictionary* pPageDict = pDocument->GetPage(nPageNo);
+  CPDF_Dictionary* pPageDict = pDocument->GetPageDictionary(nPageNo);
   if (!pPageDict)
     return CJS_Return(false);