Continue splitting pageint.h into per-class files

Add cpdf_streamparser.h and cpdf_contentparser.h since there are
already corresponding .cpp files with the same name.

Review-Url: https://codereview.chromium.org/2521123003
diff --git a/BUILD.gn b/BUILD.gn
index dff6105..81b2c61 100644
--- a/BUILD.gn
+++ b/BUILD.gn
@@ -438,6 +438,7 @@
     "core/fpdfapi/page/cpdf_contentmarkitem.cpp",
     "core/fpdfapi/page/cpdf_contentmarkitem.h",
     "core/fpdfapi/page/cpdf_contentparser.cpp",
+    "core/fpdfapi/page/cpdf_contentparser.h",
     "core/fpdfapi/page/cpdf_countedobject.h",
     "core/fpdfapi/page/cpdf_docpagedata.cpp",
     "core/fpdfapi/page/cpdf_docpagedata.h",
@@ -478,6 +479,7 @@
     "core/fpdfapi/page/cpdf_streamcontentparser.cpp",
     "core/fpdfapi/page/cpdf_streamcontentparser.h",
     "core/fpdfapi/page/cpdf_streamparser.cpp",
+    "core/fpdfapi/page/cpdf_streamparser.h",
     "core/fpdfapi/page/cpdf_textobject.cpp",
     "core/fpdfapi/page/cpdf_textobject.h",
     "core/fpdfapi/page/cpdf_textstate.cpp",
diff --git a/core/fpdfapi/font/cpdf_type3font.cpp b/core/fpdfapi/font/cpdf_type3font.cpp
index e79f16a..8a0a115 100644
--- a/core/fpdfapi/font/cpdf_type3font.cpp
+++ b/core/fpdfapi/font/cpdf_type3font.cpp
@@ -17,6 +17,8 @@
 #include "core/fxcrt/fx_system.h"
 #include "third_party/base/stl_util.h"
 
+#define FPDF_MAX_TYPE3_FORM_LEVEL 4
+
 CPDF_Type3Font::CPDF_Type3Font()
     : m_pCharProcs(nullptr),
       m_pPageResources(nullptr),
@@ -90,7 +92,7 @@
 }
 
 CPDF_Type3Char* CPDF_Type3Font::LoadChar(uint32_t charcode) {
-  if (m_CharLoadingDepth >= _FPDF_MAX_TYPE3_FORM_LEVEL_)
+  if (m_CharLoadingDepth >= FPDF_MAX_TYPE3_FORM_LEVEL)
     return nullptr;
 
   auto it = m_CacheMap.find(charcode);
diff --git a/core/fpdfapi/page/cpdf_allstates.cpp b/core/fpdfapi/page/cpdf_allstates.cpp
index f88342d..94bc7b4 100644
--- a/core/fpdfapi/page/cpdf_allstates.cpp
+++ b/core/fpdfapi/page/cpdf_allstates.cpp
@@ -8,6 +8,8 @@
 
 #include <algorithm>
 
+#include "core/fpdfapi/page/cpdf_pageobjectholder.h"
+#include "core/fpdfapi/page/cpdf_streamcontentparser.h"
 #include "core/fpdfapi/page/pageint.h"
 #include "core/fpdfapi/parser/cpdf_array.h"
 #include "core/fpdfapi/parser/cpdf_dictionary.h"
diff --git a/core/fpdfapi/page/cpdf_contentparser.cpp b/core/fpdfapi/page/cpdf_contentparser.cpp
index f581047..0b8574b 100644
--- a/core/fpdfapi/page/cpdf_contentparser.cpp
+++ b/core/fpdfapi/page/cpdf_contentparser.cpp
@@ -4,7 +4,7 @@
 
 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
 
-#include "core/fpdfapi/page/pageint.h"
+#include "core/fpdfapi/page/cpdf_contentparser.h"
 
 #include "core/fpdfapi/font/cpdf_type3char.h"
 #include "core/fpdfapi/page/cpdf_allstates.h"
@@ -18,6 +18,8 @@
 #include "core/fpdfapi/parser/cpdf_stream_acc.h"
 #include "core/fxcrt/fx_safe_types.h"
 
+#define PARSE_STEP_LIMIT 100
+
 CPDF_ContentParser::CPDF_ContentParser()
     : m_Status(Ready),
       m_InternalStage(STAGE_GETCONTENT),
diff --git a/core/fpdfapi/page/cpdf_contentparser.h b/core/fpdfapi/page/cpdf_contentparser.h
new file mode 100644
index 0000000..5fd11f6
--- /dev/null
+++ b/core/fpdfapi/page/cpdf_contentparser.h
@@ -0,0 +1,59 @@
+// Copyright 2016 PDFium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
+
+#ifndef CORE_FPDFAPI_PAGE_CPDF_CONTENTPARSER_H_
+#define CORE_FPDFAPI_PAGE_CPDF_CONTENTPARSER_H_
+
+#include <memory>
+#include <vector>
+
+#include "core/fpdfapi/page/cpdf_pageobjectholder.h"
+#include "core/fpdfapi/page/cpdf_streamcontentparser.h"
+
+class CPDF_AllStates;
+class CPDF_Form;
+class CPDF_Page;
+class CPDF_StreamAcc;
+class CPDF_Type3Char;
+
+class CPDF_ContentParser {
+ public:
+  enum ParseStatus { Ready, ToBeContinued, Done };
+
+  CPDF_ContentParser();
+  ~CPDF_ContentParser();
+
+  ParseStatus GetStatus() const { return m_Status; }
+  void Start(CPDF_Page* pPage);
+  void Start(CPDF_Form* pForm,
+             CPDF_AllStates* pGraphicStates,
+             const CFX_Matrix* pParentMatrix,
+             CPDF_Type3Char* pType3Char,
+             int level);
+  void Continue(IFX_Pause* pPause);
+
+ private:
+  enum InternalStage {
+    STAGE_GETCONTENT = 1,
+    STAGE_PARSE,
+    STAGE_CHECKCLIP,
+  };
+
+  ParseStatus m_Status;
+  InternalStage m_InternalStage;
+  CPDF_PageObjectHolder* m_pObjectHolder;
+  bool m_bForm;
+  CPDF_Type3Char* m_pType3Char;
+  uint32_t m_nStreams;
+  std::unique_ptr<CPDF_StreamAcc> m_pSingleStream;
+  std::vector<std::unique_ptr<CPDF_StreamAcc>> m_StreamArray;
+  uint8_t* m_pData;
+  uint32_t m_Size;
+  uint32_t m_CurrentOffset;
+  std::unique_ptr<CPDF_StreamContentParser> m_pParser;
+};
+
+#endif  // CORE_FPDFAPI_PAGE_CPDF_CONTENTPARSER_H_
diff --git a/core/fpdfapi/page/cpdf_form.cpp b/core/fpdfapi/page/cpdf_form.cpp
index 7291c88..3a5fa0a 100644
--- a/core/fpdfapi/page/cpdf_form.cpp
+++ b/core/fpdfapi/page/cpdf_form.cpp
@@ -6,6 +6,7 @@
 
 #include "core/fpdfapi/page/cpdf_form.h"
 
+#include "core/fpdfapi/page/cpdf_contentparser.h"
 #include "core/fpdfapi/page/cpdf_pageobject.h"
 #include "core/fpdfapi/page/cpdf_pageobjectholder.h"
 #include "core/fpdfapi/page/pageint.h"
diff --git a/core/fpdfapi/page/cpdf_page.cpp b/core/fpdfapi/page/cpdf_page.cpp
index a29d971..b4e2e67 100644
--- a/core/fpdfapi/page/cpdf_page.cpp
+++ b/core/fpdfapi/page/cpdf_page.cpp
@@ -10,6 +10,7 @@
 #include <utility>
 
 #include "core/fpdfapi/cpdf_pagerendercontext.h"
+#include "core/fpdfapi/page/cpdf_contentparser.h"
 #include "core/fpdfapi/page/cpdf_pageobject.h"
 #include "core/fpdfapi/page/pageint.h"
 #include "core/fpdfapi/parser/cpdf_array.h"
diff --git a/core/fpdfapi/page/cpdf_pageobjectholder.cpp b/core/fpdfapi/page/cpdf_pageobjectholder.cpp
index 9726fa2..3304d4e 100644
--- a/core/fpdfapi/page/cpdf_pageobjectholder.cpp
+++ b/core/fpdfapi/page/cpdf_pageobjectholder.cpp
@@ -8,6 +8,7 @@
 
 #include <algorithm>
 
+#include "core/fpdfapi/page/cpdf_contentparser.h"
 #include "core/fpdfapi/page/cpdf_pageobject.h"
 #include "core/fpdfapi/page/pageint.h"
 #include "core/fpdfapi/parser/cpdf_dictionary.h"
diff --git a/core/fpdfapi/page/cpdf_streamcontentparser.cpp b/core/fpdfapi/page/cpdf_streamcontentparser.cpp
index 2bc80cc..df0d5f1 100644
--- a/core/fpdfapi/page/cpdf_streamcontentparser.cpp
+++ b/core/fpdfapi/page/cpdf_streamcontentparser.cpp
@@ -23,6 +23,7 @@
 #include "core/fpdfapi/page/cpdf_pathobject.h"
 #include "core/fpdfapi/page/cpdf_shadingobject.h"
 #include "core/fpdfapi/page/cpdf_shadingpattern.h"
+#include "core/fpdfapi/page/cpdf_streamparser.h"
 #include "core/fpdfapi/page/cpdf_textobject.h"
 #include "core/fpdfapi/page/pageint.h"
 #include "core/fpdfapi/parser/cpdf_array.h"
diff --git a/core/fpdfapi/page/cpdf_streamparser.cpp b/core/fpdfapi/page/cpdf_streamparser.cpp
index 7b0bf6a..cabf3d3 100644
--- a/core/fpdfapi/page/cpdf_streamparser.cpp
+++ b/core/fpdfapi/page/cpdf_streamparser.cpp
@@ -4,7 +4,7 @@
 
 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
 
-#include "core/fpdfapi/page/pageint.h"
+#include "core/fpdfapi/page/cpdf_streamparser.h"
 
 #include <limits.h>
 
diff --git a/core/fpdfapi/page/cpdf_streamparser.h b/core/fpdfapi/page/cpdf_streamparser.h
new file mode 100644
index 0000000..ce01dd0
--- /dev/null
+++ b/core/fpdfapi/page/cpdf_streamparser.h
@@ -0,0 +1,60 @@
+// Copyright 2016 PDFium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
+
+#ifndef CORE_FPDFAPI_PAGE_CPDF_STREAMPARSER_H_
+#define CORE_FPDFAPI_PAGE_CPDF_STREAMPARSER_H_
+
+#include <memory>
+#include <utility>
+
+#include "core/fpdfapi/parser/cpdf_dictionary.h"
+#include "core/fpdfapi/parser/cpdf_document.h"
+#include "core/fpdfapi/parser/cpdf_object.h"
+#include "core/fpdfapi/parser/cpdf_stream.h"
+#include "core/fxcrt/cfx_string_pool_template.h"
+#include "core/fxcrt/cfx_weak_ptr.h"
+
+class CPDF_StreamParser {
+ public:
+  enum SyntaxType { EndOfData, Number, Keyword, Name, Others };
+
+  CPDF_StreamParser(const uint8_t* pData, uint32_t dwSize);
+  CPDF_StreamParser(const uint8_t* pData,
+                    uint32_t dwSize,
+                    const CFX_WeakPtr<CFX_ByteStringPool>& pPool);
+  ~CPDF_StreamParser();
+
+  SyntaxType ParseNextElement();
+  const uint8_t* GetWordBuf() const { return m_WordBuffer; }
+  uint32_t GetWordSize() const { return m_WordSize; }
+  uint32_t GetPos() const { return m_Pos; }
+  void SetPos(uint32_t pos) { m_Pos = pos; }
+  std::unique_ptr<CPDF_Object> GetObject() { return std::move(m_pLastObj); }
+  std::unique_ptr<CPDF_Object> ReadNextObject(bool bAllowNestedArray,
+                                              uint32_t dwInArrayLevel);
+  std::unique_ptr<CPDF_Stream> ReadInlineStream(
+      CPDF_Document* pDoc,
+      std::unique_ptr<CPDF_Dictionary> pDict,
+      CPDF_Object* pCSObj);
+
+ private:
+  friend class cpdf_streamparser_ReadHexString_Test;
+
+  void GetNextWord(bool& bIsNumber);
+  CFX_ByteString ReadString();
+  CFX_ByteString ReadHexString();
+  bool PositionIsInBounds() const;
+
+  const uint8_t* m_pBuf;
+  uint32_t m_Size;  // Length in bytes of m_pBuf.
+  uint32_t m_Pos;   // Current byte position within m_pBuf.
+  uint8_t m_WordBuffer[256];
+  uint32_t m_WordSize;
+  std::unique_ptr<CPDF_Object> m_pLastObj;
+  CFX_WeakPtr<CFX_ByteStringPool> m_pPool;
+};
+
+#endif  // CORE_FPDFAPI_PAGE_CPDF_STREAMPARSER_H_
diff --git a/core/fpdfapi/page/cpdf_streamparser_unittest.cpp b/core/fpdfapi/page/cpdf_streamparser_unittest.cpp
index f2a5a54..40a41be 100644
--- a/core/fpdfapi/page/cpdf_streamparser_unittest.cpp
+++ b/core/fpdfapi/page/cpdf_streamparser_unittest.cpp
@@ -2,7 +2,7 @@
 // Use of this source code is governed by a BSD-style license that can be
 // found in the LICENSE file.
 
-#include "core/fpdfapi/page/pageint.h"
+#include "core/fpdfapi/page/cpdf_streamparser.h"
 #include "testing/gtest/include/gtest/gtest.h"
 
 TEST(cpdf_streamparser, ReadHexString) {
diff --git a/core/fpdfapi/page/pageint.h b/core/fpdfapi/page/pageint.h
index 49a4845..6700633 100644
--- a/core/fpdfapi/page/pageint.h
+++ b/core/fpdfapi/page/pageint.h
@@ -7,120 +7,17 @@
 #ifndef CORE_FPDFAPI_PAGE_PAGEINT_H_
 #define CORE_FPDFAPI_PAGE_PAGEINT_H_
 
-#include <map>
 #include <memory>
-#include <set>
-#include <unordered_map>
-#include <utility>
 #include <vector>
 
-#include "core/fpdfapi/page/cpdf_contentmark.h"
+#include "core/fpdfapi/page/cpdf_colorspace.h"
 #include "core/fpdfapi/page/cpdf_countedobject.h"
-#include "core/fpdfapi/page/cpdf_pageobjectholder.h"
-#include "core/fpdfapi/page/cpdf_streamcontentparser.h"
-#include "core/fpdfapi/parser/cpdf_stream.h"
-#include "core/fxcrt/cfx_string_pool_template.h"
-#include "core/fxcrt/cfx_weak_ptr.h"
-#include "core/fxge/cfx_pathdata.h"
-#include "core/fxge/cfx_renderdevice.h"
 
-class CPDF_AllStates;
-class CPDF_ColorSpace;
 class CPDF_ExpIntFunc;
-class CPDF_Font;
-class CPDF_FontEncoding;
-class CPDF_Form;
-class CPDF_IccProfile;
-class CPDF_Image;
-class CPDF_ImageObject;
-class CPDF_Page;
 class CPDF_Pattern;
 class CPDF_SampledFunc;
 class CPDF_StitchFunc;
 class CPDF_StreamAcc;
-class CPDF_TextObject;
-class CPDF_Type3Char;
-
-#define PARSE_STEP_LIMIT 100
-
-class CPDF_StreamParser {
- public:
-  enum SyntaxType { EndOfData, Number, Keyword, Name, Others };
-
-  CPDF_StreamParser(const uint8_t* pData, uint32_t dwSize);
-  CPDF_StreamParser(const uint8_t* pData,
-                    uint32_t dwSize,
-                    const CFX_WeakPtr<CFX_ByteStringPool>& pPool);
-  ~CPDF_StreamParser();
-
-  SyntaxType ParseNextElement();
-  uint8_t* GetWordBuf() { return m_WordBuffer; }
-  uint32_t GetWordSize() const { return m_WordSize; }
-  uint32_t GetPos() const { return m_Pos; }
-  void SetPos(uint32_t pos) { m_Pos = pos; }
-  std::unique_ptr<CPDF_Object> GetObject() { return std::move(m_pLastObj); }
-  std::unique_ptr<CPDF_Object> ReadNextObject(bool bAllowNestedArray,
-                                              uint32_t dwInArrayLevel);
-  std::unique_ptr<CPDF_Stream> ReadInlineStream(
-      CPDF_Document* pDoc,
-      std::unique_ptr<CPDF_Dictionary> pDict,
-      CPDF_Object* pCSObj);
-
- private:
-  friend class cpdf_streamparser_ReadHexString_Test;
-
-  void GetNextWord(bool& bIsNumber);
-  CFX_ByteString ReadString();
-  CFX_ByteString ReadHexString();
-  bool PositionIsInBounds() const;
-
-  const uint8_t* m_pBuf;
-  uint32_t m_Size;  // Length in bytes of m_pBuf.
-  uint32_t m_Pos;   // Current byte position within m_pBuf.
-  uint8_t m_WordBuffer[256];
-  uint32_t m_WordSize;
-  std::unique_ptr<CPDF_Object> m_pLastObj;
-  CFX_WeakPtr<CFX_ByteStringPool> m_pPool;
-};
-
-#define _FPDF_MAX_TYPE3_FORM_LEVEL_ 4
-
-class CPDF_ContentParser {
- public:
-  enum ParseStatus { Ready, ToBeContinued, Done };
-
-  CPDF_ContentParser();
-  ~CPDF_ContentParser();
-
-  ParseStatus GetStatus() const { return m_Status; }
-  void Start(CPDF_Page* pPage);
-  void Start(CPDF_Form* pForm,
-             CPDF_AllStates* pGraphicStates,
-             const CFX_Matrix* pParentMatrix,
-             CPDF_Type3Char* pType3Char,
-             int level);
-  void Continue(IFX_Pause* pPause);
-
- private:
-  enum InternalStage {
-    STAGE_GETCONTENT = 1,
-    STAGE_PARSE,
-    STAGE_CHECKCLIP,
-  };
-
-  ParseStatus m_Status;
-  InternalStage m_InternalStage;
-  CPDF_PageObjectHolder* m_pObjectHolder;
-  bool m_bForm;
-  CPDF_Type3Char* m_pType3Char;
-  uint32_t m_nStreams;
-  std::unique_ptr<CPDF_StreamAcc> m_pSingleStream;
-  std::vector<std::unique_ptr<CPDF_StreamAcc>> m_StreamArray;
-  uint8_t* m_pData;
-  uint32_t m_Size;
-  uint32_t m_CurrentOffset;
-  std::unique_ptr<CPDF_StreamContentParser> m_pParser;
-};
 
 class CPDF_Function {
  public:
diff --git a/testing/libfuzzer/pdf_streamparser_fuzzer.cc b/testing/libfuzzer/pdf_streamparser_fuzzer.cc
index 277acc0..5cfa318 100644
--- a/testing/libfuzzer/pdf_streamparser_fuzzer.cc
+++ b/testing/libfuzzer/pdf_streamparser_fuzzer.cc
@@ -5,7 +5,7 @@
 #include <cstdint>
 #include <memory>
 
-#include "core/fpdfapi/page/pageint.h"
+#include "core/fpdfapi/page/cpdf_streamparser.h"
 #include "core/fpdfapi/parser/cpdf_object.h"
 
 extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) {