Clean up misc nits found while fixing bugs.

Some bits regressed in commit 338805f.

R=tsepez@chromium.org

Review URL: https://codereview.chromium.org/1544963002 .
diff --git a/core/src/fpdfapi/fpdf_edit/fpdf_edit_create.cpp b/core/src/fpdfapi/fpdf_edit/fpdf_edit_create.cpp
index 2dc9854..183baa2 100644
--- a/core/src/fpdfapi/fpdf_edit/fpdf_edit_create.cpp
+++ b/core/src/fpdfapi/fpdf_edit/fpdf_edit_create.cpp
@@ -4,7 +4,7 @@
 
 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
 
-#include "editint.h"
+#include "core/src/fpdfapi/fpdf_edit/editint.h"
 
 #include "core/include/fxcrt/fx_ext.h"
 #include "core/include/fpdfapi/fpdf_serial.h"
@@ -13,6 +13,8 @@
 #define PDF_OBJECTSTREAM_MAXLENGTH (256 * 1024)
 #define PDF_XREFSTREAM_MAXSIZE 10000
 
+namespace {
+
 int32_t PDF_CreatorAppendObject(const CPDF_Object* pObj,
                                 CFX_FileBufferArchive* pFile,
                                 FX_FILESIZE& offset) {
@@ -169,6 +171,7 @@
   }
   return 1;
 }
+
 int32_t PDF_CreatorWriteTrailer(CPDF_Document* pDocument,
                                 CFX_FileBufferArchive* pFile,
                                 CPDF_Array* pIDArray,
@@ -259,6 +262,7 @@
   }
   return offset;
 }
+
 int32_t PDF_CreatorWriteEncrypt(const CPDF_Dictionary* pEncryptDict,
                                 FX_DWORD dwObjNum,
                                 CFX_FileBufferArchive* pFile) {
@@ -284,25 +288,89 @@
   offset += len + 6;
   return offset;
 }
-FX_BOOL PDF_GenerateFileID(FX_DWORD dwSeed1,
-                           FX_DWORD dwSeed2,
-                           FX_DWORD* pBuffer) {
-  if (!pBuffer) {
-    return FALSE;
-  }
+
+std::vector<uint8_t> PDF_GenerateFileID(FX_DWORD dwSeed1, FX_DWORD dwSeed2) {
+  std::vector<uint8_t> buffer(sizeof(FX_DWORD) * 4);
+  FX_DWORD* pBuffer = reinterpret_cast<FX_DWORD*>(buffer.data());
   void* pContext = FX_Random_MT_Start(dwSeed1);
-  int32_t i = 0;
-  for (i = 0; i < 2; i++) {
+  for (int i = 0; i < 2; ++i)
     *pBuffer++ = FX_Random_MT_Generate(pContext);
-  }
   FX_Random_MT_Close(pContext);
   pContext = FX_Random_MT_Start(dwSeed2);
-  for (i = 0; i < 2; i++) {
+  for (int i = 0; i < 2; ++i)
     *pBuffer++ = FX_Random_MT_Generate(pContext);
-  }
   FX_Random_MT_Close(pContext);
-  return TRUE;
+  return buffer;
 }
+
+void AppendIndex0(CFX_ByteTextBuf& buffer, bool bFirstObject) {
+  buffer.AppendByte(0);
+  buffer.AppendByte(0);
+  buffer.AppendByte(0);
+  buffer.AppendByte(0);
+  buffer.AppendByte(0);
+  const uint8_t byte = bFirstObject ? 0xFF : 0;
+  buffer.AppendByte(byte);
+  buffer.AppendByte(byte);
+}
+
+void AppendIndex1(CFX_ByteTextBuf& buffer, FX_FILESIZE offset) {
+  buffer.AppendByte(1);
+  buffer.AppendByte(FX_GETBYTEOFFSET24(offset));
+  buffer.AppendByte(FX_GETBYTEOFFSET16(offset));
+  buffer.AppendByte(FX_GETBYTEOFFSET8(offset));
+  buffer.AppendByte(FX_GETBYTEOFFSET0(offset));
+  buffer.AppendByte(0);
+  buffer.AppendByte(0);
+}
+
+void AppendIndex2(CFX_ByteTextBuf& buffer, FX_DWORD objnum, int32_t index) {
+  buffer.AppendByte(2);
+  buffer.AppendByte(FX_GETBYTEOFFSET24(objnum));
+  buffer.AppendByte(FX_GETBYTEOFFSET16(objnum));
+  buffer.AppendByte(FX_GETBYTEOFFSET8(objnum));
+  buffer.AppendByte(FX_GETBYTEOFFSET0(objnum));
+  buffer.AppendByte(FX_GETBYTEOFFSET8(index));
+  buffer.AppendByte(FX_GETBYTEOFFSET0(index));
+}
+
+bool IsXRefNeedEnd(CPDF_XRefStream* pXRef, FX_DWORD flag) {
+  if (!(flag & FPDFCREATE_INCREMENTAL))
+    return false;
+
+  int32_t iSize = pXRef->m_IndexArray.GetSize() / 2;
+  int32_t iCount = 0;
+  for (int32_t i = 0; i < iSize; ++i)
+    iCount += pXRef->m_IndexArray.ElementAt(i * 2 + 1);
+  return iCount >= PDF_XREFSTREAM_MAXSIZE;
+}
+
+int32_t OutputIndex(CFX_FileBufferArchive* pFile, FX_FILESIZE offset) {
+  if (sizeof(offset) > 4) {
+    if (FX_GETBYTEOFFSET32(offset)) {
+      if (pFile->AppendByte(FX_GETBYTEOFFSET56(offset)) < 0)
+        return -1;
+      if (pFile->AppendByte(FX_GETBYTEOFFSET48(offset)) < 0)
+        return -1;
+      if (pFile->AppendByte(FX_GETBYTEOFFSET40(offset)) < 0)
+        return -1;
+      if (pFile->AppendByte(FX_GETBYTEOFFSET32(offset)) < 0)
+        return -1;
+    }
+  }
+  if (pFile->AppendByte(FX_GETBYTEOFFSET24(offset)) < 0)
+    return -1;
+  if (pFile->AppendByte(FX_GETBYTEOFFSET16(offset)) < 0)
+    return -1;
+  if (pFile->AppendByte(FX_GETBYTEOFFSET8(offset)) < 0)
+    return -1;
+  if (pFile->AppendByte(FX_GETBYTEOFFSET0(offset)) < 0)
+    return -1;
+  if (pFile->AppendByte(0) < 0)
+    return -1;
+  return 0;
+}
+
 class CPDF_FlateEncoder {
  public:
   CPDF_FlateEncoder();
@@ -433,6 +501,9 @@
     FX_Free(m_pData);
   }
 }
+
+}  // namespace
+
 CPDF_ObjectStream::CPDF_ObjectStream() : m_dwObjNum(0), m_index(0) {}
 FX_BOOL CPDF_ObjectStream::Start() {
   m_ObjNumArray.RemoveAll();
@@ -582,41 +653,7 @@
   }
   return EndObjectStream(pCreator);
 }
-static void _AppendIndex0(CFX_ByteTextBuf& buffer,
-                          FX_BOOL bFirstObject = TRUE) {
-  buffer.AppendByte(0);
-  buffer.AppendByte(0);
-  buffer.AppendByte(0);
-  buffer.AppendByte(0);
-  buffer.AppendByte(0);
-  if (bFirstObject) {
-    buffer.AppendByte(0xFF);
-    buffer.AppendByte(0xFF);
-  } else {
-    buffer.AppendByte(0);
-    buffer.AppendByte(0);
-  }
-}
-static void _AppendIndex1(CFX_ByteTextBuf& buffer, FX_FILESIZE offset) {
-  buffer.AppendByte(1);
-  buffer.AppendByte(FX_GETBYTEOFFSET24(offset));
-  buffer.AppendByte(FX_GETBYTEOFFSET16(offset));
-  buffer.AppendByte(FX_GETBYTEOFFSET8(offset));
-  buffer.AppendByte(FX_GETBYTEOFFSET0(offset));
-  buffer.AppendByte(0);
-  buffer.AppendByte(0);
-}
-static void _AppendIndex2(CFX_ByteTextBuf& buffer,
-                          FX_DWORD objnum,
-                          int32_t index) {
-  buffer.AppendByte(2);
-  buffer.AppendByte(FX_GETBYTEOFFSET24(objnum));
-  buffer.AppendByte(FX_GETBYTEOFFSET16(objnum));
-  buffer.AppendByte(FX_GETBYTEOFFSET8(objnum));
-  buffer.AppendByte(FX_GETBYTEOFFSET0(objnum));
-  buffer.AppendByte(FX_GETBYTEOFFSET8(index));
-  buffer.AppendByte(FX_GETBYTEOFFSET0(index));
-}
+
 int32_t CPDF_XRefStream::EndObjectStream(CPDF_Creator* pCreator, FX_BOOL bEOF) {
   FX_FILESIZE objOffset = 0;
   if (bEOF) {
@@ -633,7 +670,7 @@
   int32_t iSeg = m_IndexArray.GetSize() / 2;
   if (!(pCreator->m_dwFlags & FPDFCREATE_INCREMENTAL)) {
     if (m_dwTempObjNum == 0) {
-      _AppendIndex0(m_Buffer);
+      AppendIndex0(m_Buffer, true);
       m_dwTempObjNum++;
     }
     FX_DWORD end_num = m_IndexArray.GetAt((iSeg - 1) * 2) +
@@ -644,12 +681,12 @@
       if (offset) {
         if (index >= iSize ||
             m_dwTempObjNum != m_ObjStream.m_ObjNumArray[index]) {
-          _AppendIndex1(m_Buffer, *offset);
+          AppendIndex1(m_Buffer, *offset);
         } else {
-          _AppendIndex2(m_Buffer, dwObjStmNum, index++);
+          AppendIndex2(m_Buffer, dwObjStmNum, index++);
         }
       } else {
-        _AppendIndex0(m_Buffer, FALSE);
+        AppendIndex0(m_Buffer, false);
       }
     }
     if (iSize > 0 && bEOF) {
@@ -668,14 +705,14 @@
     FX_DWORD end = m_IndexArray.ElementAt(i * 2 + 1) + start;
     for (FX_DWORD m = start; m < end; m++) {
       if (j >= iSize || m != m_ObjStream.m_ObjNumArray.ElementAt(j)) {
-        _AppendIndex1(m_Buffer, pCreator->m_ObjectOffset[m]);
+        AppendIndex1(m_Buffer, pCreator->m_ObjectOffset[m]);
       } else {
-        _AppendIndex2(m_Buffer, dwObjStmNum, j++);
+        AppendIndex2(m_Buffer, dwObjStmNum, j++);
       }
     }
   }
   if (iSize > 0 && bEOF) {
-    _AppendIndex1(m_Buffer, objOffset);
+    AppendIndex1(m_Buffer, objOffset);
     m_IndexArray.Add(dwObjStmNum);
     m_IndexArray.Add(1);
     iSeg += 1;
@@ -698,13 +735,13 @@
     for (; m_dwTempObjNum < pCreator->m_dwLastObjNum; m_dwTempObjNum++) {
       FX_FILESIZE* offset = pCreator->m_ObjectOffset.GetPtrAt(m_dwTempObjNum);
       if (offset) {
-        _AppendIndex1(m_Buffer, *offset);
+        AppendIndex1(m_Buffer, *offset);
       } else {
-        _AppendIndex0(m_Buffer, FALSE);
+        AppendIndex0(m_Buffer, false);
       }
     }
   }
-  _AppendIndex1(m_Buffer, offset_tmp);
+  AppendIndex1(m_Buffer, offset_tmp);
   FX_FILESIZE& offset = pCreator->m_Offset;
   int32_t len = pFile->AppendDWord(objnum);
   if (len < 0) {
@@ -832,13 +869,13 @@
 }
 FX_BOOL CPDF_XRefStream::EndXRefStream(CPDF_Creator* pCreator) {
   if (!(pCreator->m_dwFlags & FPDFCREATE_INCREMENTAL)) {
-    _AppendIndex0(m_Buffer);
+    AppendIndex0(m_Buffer, true);
     for (FX_DWORD i = 1; i < pCreator->m_dwLastObjNum + 1; i++) {
       FX_FILESIZE* offset = pCreator->m_ObjectOffset.GetPtrAt(i);
       if (offset) {
-        _AppendIndex1(m_Buffer, *offset);
+        AppendIndex1(m_Buffer, *offset);
       } else {
-        _AppendIndex0(m_Buffer, FALSE);
+        AppendIndex0(m_Buffer, false);
       }
     }
   } else {
@@ -847,7 +884,7 @@
       FX_DWORD start = m_IndexArray.ElementAt(i * 2);
       FX_DWORD end = m_IndexArray.ElementAt(i * 2 + 1) + start;
       for (FX_DWORD j = start; j < end; j++) {
-        _AppendIndex1(m_Buffer, pCreator->m_ObjectOffset[j]);
+        AppendIndex1(m_Buffer, pCreator->m_ObjectOffset[j]);
       }
     }
   }
@@ -908,17 +945,7 @@
   }
   Clear();
 }
-static FX_BOOL _IsXRefNeedEnd(CPDF_XRefStream* pXRef, FX_DWORD flag) {
-  if (!(flag & FPDFCREATE_INCREMENTAL)) {
-    return FALSE;
-  }
-  int32_t iSize = pXRef->m_IndexArray.GetSize() / 2;
-  int32_t iCount = 0;
-  for (int32_t i = 0; i < iSize; i++) {
-    iCount += pXRef->m_IndexArray.ElementAt(i * 2 + 1);
-  }
-  return (iCount >= PDF_XREFSTREAM_MAXSIZE);
-}
+
 int32_t CPDF_Creator::WriteIndirectObjectToStream(const CPDF_Object* pObj) {
   if (!m_pXRefStream)
     return 1;
@@ -933,10 +960,11 @@
     return 1;
 
   CPDF_Dictionary* pDict = pObj->GetDict();
-  if (pObj->IsStream())
+  if (pObj->IsStream()) {
     if (pDict && pDict->GetString("Type") == "XRef")
       return 0;
     return 1;
+  }
 
   if (pDict) {
     if (pDict == m_pDocument->m_pRootDict || pDict == m_pEncryptDict)
@@ -950,7 +978,7 @@
   m_pXRefStream->AddObjectNumberToIndexArray(objnum);
   if (m_pXRefStream->CompressIndirectObject(objnum, pObj, this) < 0)
     return -1;
-  if (!_IsXRefNeedEnd(m_pXRefStream, m_dwFlags))
+  if (!IsXRefNeedEnd(m_pXRefStream, m_dwFlags))
     return 0;
   if (!m_pXRefStream->End(this))
     return -1;
@@ -970,7 +998,7 @@
   if (iRet < 1) {
     return iRet;
   }
-  if (!_IsXRefNeedEnd(m_pXRefStream, m_dwFlags)) {
+  if (!IsXRefNeedEnd(m_pXRefStream, m_dwFlags)) {
     return 0;
   }
   if (!m_pXRefStream->End(this)) {
@@ -986,7 +1014,7 @@
     return 1;
   }
   m_pXRefStream->AddObjectNumberToIndexArray(objnum);
-  if (!_IsXRefNeedEnd(m_pXRefStream, m_dwFlags)) {
+  if (!IsXRefNeedEnd(m_pXRefStream, m_dwFlags)) {
     return 0;
   }
   if (!m_pXRefStream->End(this)) {
@@ -1723,41 +1751,7 @@
   }
   return m_iStage;
 }
-static int32_t _OutPutIndex(CFX_FileBufferArchive* pFile, FX_FILESIZE offset) {
-  FXSYS_assert(pFile);
-  if (sizeof(offset) > 4) {
-    if (FX_GETBYTEOFFSET32(offset)) {
-      if (pFile->AppendByte(FX_GETBYTEOFFSET56(offset)) < 0) {
-        return -1;
-      }
-      if (pFile->AppendByte(FX_GETBYTEOFFSET48(offset)) < 0) {
-        return -1;
-      }
-      if (pFile->AppendByte(FX_GETBYTEOFFSET40(offset)) < 0) {
-        return -1;
-      }
-      if (pFile->AppendByte(FX_GETBYTEOFFSET32(offset)) < 0) {
-        return -1;
-      }
-    }
-  }
-  if (pFile->AppendByte(FX_GETBYTEOFFSET24(offset)) < 0) {
-    return -1;
-  }
-  if (pFile->AppendByte(FX_GETBYTEOFFSET16(offset)) < 0) {
-    return -1;
-  }
-  if (pFile->AppendByte(FX_GETBYTEOFFSET8(offset)) < 0) {
-    return -1;
-  }
-  if (pFile->AppendByte(FX_GETBYTEOFFSET0(offset)) < 0) {
-    return -1;
-  }
-  if (pFile->AppendByte(0) < 0) {
-    return -1;
-  }
-  return 0;
-}
+
 int32_t CPDF_Creator::WriteDoc_Stage4(IFX_Pause* pPause) {
   FXSYS_assert(m_iStage >= 90);
   if ((m_dwFlags & FPDFCREATE_OBJECTSTREAM) == 0) {
@@ -1914,7 +1908,7 @@
           if (!offset) {
             continue;
           }
-          _OutPutIndex(&m_File, *offset);
+          OutputIndex(&m_File, *offset);
         }
       } else {
         int count = m_NewObjNumArray.GetSize();
@@ -1940,7 +1934,7 @@
         for (i = 0; i < count; i++) {
           FX_DWORD objnum = m_NewObjNumArray.ElementAt(i);
           FX_FILESIZE offset = m_ObjectOffset[objnum];
-          _OutPutIndex(&m_File, offset);
+          OutputIndex(&m_File, offset);
         }
       }
       if (m_File.AppendString("\r\nendstream") < 0) {
@@ -1999,18 +1993,16 @@
   CPDF_Array* pOldIDArray = m_pParser ? m_pParser->GetIDArray() : NULL;
   FX_BOOL bNewId = !m_pIDArray;
   if (!m_pIDArray) {
-    FX_DWORD* pBuffer = NULL;
     m_pIDArray = new CPDF_Array;
     CPDF_Object* pID1 = pOldIDArray ? pOldIDArray->GetElement(0) : NULL;
     if (pID1) {
       m_pIDArray->Add(pID1->Clone());
     } else {
-      pBuffer = FX_Alloc(FX_DWORD, 4);
-      PDF_GenerateFileID((FX_DWORD)(uintptr_t) this, m_dwLastObjNum, pBuffer);
-      CFX_ByteStringC bsBuffer((const uint8_t*)pBuffer, 4 * sizeof(FX_DWORD));
+      std::vector<uint8_t> buffer =
+          PDF_GenerateFileID((FX_DWORD)(uintptr_t) this, m_dwLastObjNum);
+      CFX_ByteStringC bsBuffer(buffer.data(), buffer.size());
       m_pIDArray->Add(new CPDF_String(bsBuffer, TRUE), m_pDocument);
     }
-    FX_Free(pBuffer);
   }
   if (!bDefault) {
     return;
@@ -2021,11 +2013,10 @@
       m_pIDArray->Add(pID2->Clone());
       return;
     }
-    FX_DWORD* pBuffer = FX_Alloc(FX_DWORD, 4);
-    PDF_GenerateFileID((FX_DWORD)(uintptr_t) this, m_dwLastObjNum, pBuffer);
-    CFX_ByteStringC bsBuffer((const uint8_t*)pBuffer, 4 * sizeof(FX_DWORD));
+    std::vector<uint8_t> buffer =
+        PDF_GenerateFileID((FX_DWORD)(uintptr_t) this, m_dwLastObjNum);
+    CFX_ByteStringC bsBuffer(buffer.data(), buffer.size());
     m_pIDArray->Add(new CPDF_String(bsBuffer, TRUE), m_pDocument);
-    FX_Free(pBuffer);
     return;
   }
   m_pIDArray->Add(m_pIDArray->GetElement(0)->Clone());
diff --git a/core/src/fpdfapi/fpdf_page/fpdf_page_parser.cpp b/core/src/fpdfapi/fpdf_page/fpdf_page_parser.cpp
index 264b6fb..dee63d4 100644
--- a/core/src/fpdfapi/fpdf_page/fpdf_page_parser.cpp
+++ b/core/src/fpdfapi/fpdf_page/fpdf_page_parser.cpp
@@ -4,16 +4,79 @@
 
 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
 
-#include "pageint.h"
+#include "core/src/fpdfapi/fpdf_page/pageint.h"
 
 #include "core/include/fpdfapi/fpdf_module.h"
 #include "core/include/fpdfapi/fpdf_page.h"
 #include "core/include/fpdfapi/fpdf_serial.h"
 
-#define REQUIRE_PARAMS(count)  \
-  if (m_ParamCount != count) { \
-    return;                    \
+namespace {
+
+struct _FX_BSTR {
+  const FX_CHAR* m_Ptr;
+  int m_Size;
+};
+#define _FX_BSTRC(str) \
+  { str, sizeof(str) - 1 }
+
+struct PDF_AbbrPairs {
+  _FX_BSTR full_name;
+  _FX_BSTR abbr;
+};
+
+const PDF_AbbrPairs PDF_InlineKeyAbbr[] = {
+    {_FX_BSTRC("BitsPerComponent"), _FX_BSTRC("BPC")},
+    {_FX_BSTRC("ColorSpace"), _FX_BSTRC("CS")},
+    {_FX_BSTRC("Decode"), _FX_BSTRC("D")},
+    {_FX_BSTRC("DecodeParms"), _FX_BSTRC("DP")},
+    {_FX_BSTRC("Filter"), _FX_BSTRC("F")},
+    {_FX_BSTRC("Height"), _FX_BSTRC("H")},
+    {_FX_BSTRC("ImageMask"), _FX_BSTRC("IM")},
+    {_FX_BSTRC("Interpolate"), _FX_BSTRC("I")},
+    {_FX_BSTRC("Width"), _FX_BSTRC("W")},
+};
+
+const PDF_AbbrPairs PDF_InlineValueAbbr[] = {
+    {_FX_BSTRC("DeviceGray"), _FX_BSTRC("G")},
+    {_FX_BSTRC("DeviceRGB"), _FX_BSTRC("RGB")},
+    {_FX_BSTRC("DeviceCMYK"), _FX_BSTRC("CMYK")},
+    {_FX_BSTRC("Indexed"), _FX_BSTRC("I")},
+    {_FX_BSTRC("ASCIIHexDecode"), _FX_BSTRC("AHx")},
+    {_FX_BSTRC("ASCII85Decode"), _FX_BSTRC("A85")},
+    {_FX_BSTRC("LZWDecode"), _FX_BSTRC("LZW")},
+    {_FX_BSTRC("FlateDecode"), _FX_BSTRC("Fl")},
+    {_FX_BSTRC("RunLengthDecode"), _FX_BSTRC("RL")},
+    {_FX_BSTRC("CCITTFaxDecode"), _FX_BSTRC("CCF")},
+    {_FX_BSTRC("DCTDecode"), _FX_BSTRC("DCT")},
+};
+
+CFX_ByteStringC PDF_FindFullName(const PDF_AbbrPairs* table,
+                                 size_t count,
+                                 const CFX_ByteStringC& abbr) {
+  for (size_t i = 0; i < count; ++i) {
+    if (abbr.GetLength() != table[i].abbr.m_Size)
+      continue;
+    if (memcmp(abbr.GetPtr(), table[i].abbr.m_Ptr, abbr.GetLength()))
+      continue;
+    return CFX_ByteStringC(table[i].full_name.m_Ptr, table[i].full_name.m_Size);
   }
+  return CFX_ByteStringC();
+}
+
+CFX_ByteStringC PDF_FindAbbrName(const PDF_AbbrPairs* table,
+                                 size_t count,
+                                 const CFX_ByteStringC& name) {
+  for (size_t i = 0; i < count; ++i) {
+    if (name.GetLength() != table[i].full_name.m_Size)
+      continue;
+    if (memcmp(name.GetPtr(), table[i].full_name.m_Ptr, name.GetLength()))
+      continue;
+    return CFX_ByteStringC(table[i].abbr.m_Ptr, table[i].abbr.m_Size);
+  }
+  return CFX_ByteStringC();
+}
+
+}  // namespace
 
 CPDF_StreamContentParser::CPDF_StreamContentParser(
     CPDF_Document* pDocument,
@@ -361,7 +424,7 @@
   while (i < 4) {
     opid <<= 8;
     i++;
-  };
+  }
   int low = 0, high = sizeof g_OpCodes / sizeof(OpCode) - 1;
   while (low <= high) {
     int middle = (low + high) / 2;
@@ -431,60 +494,8 @@
   CFX_ByteString tag = GetString(0);
   m_CurContentMark.GetModify()->AddMark(tag, NULL, FALSE);
 }
-struct _FX_BSTR {
-  const FX_CHAR* m_Ptr;
-  int m_Size;
-};
-#define _FX_BSTRC(str) \
-  { str, sizeof(str) - 1 }
-const _FX_BSTR _PDF_InlineKeyAbbr[] = {
-    _FX_BSTRC("BitsPerComponent"),
-    _FX_BSTRC("BPC"),
-    _FX_BSTRC("ColorSpace"),
-    _FX_BSTRC("CS"),
-    _FX_BSTRC("Decode"),
-    _FX_BSTRC("D"),
-    _FX_BSTRC("DecodeParms"),
-    _FX_BSTRC("DP"),
-    _FX_BSTRC("Filter"),
-    _FX_BSTRC("F"),
-    _FX_BSTRC("Height"),
-    _FX_BSTRC("H"),
-    _FX_BSTRC("ImageMask"),
-    _FX_BSTRC("IM"),
-    _FX_BSTRC("Interpolate"),
-    _FX_BSTRC("I"),
-    _FX_BSTRC("Width"),
-    _FX_BSTRC("W"),
-};
-const _FX_BSTR _PDF_InlineValueAbbr[] = {
-    _FX_BSTRC("DeviceGray"),      _FX_BSTRC("G"),
-    _FX_BSTRC("DeviceRGB"),       _FX_BSTRC("RGB"),
-    _FX_BSTRC("DeviceCMYK"),      _FX_BSTRC("CMYK"),
-    _FX_BSTRC("Indexed"),         _FX_BSTRC("I"),
-    _FX_BSTRC("ASCIIHexDecode"),  _FX_BSTRC("AHx"),
-    _FX_BSTRC("ASCII85Decode"),   _FX_BSTRC("A85"),
-    _FX_BSTRC("LZWDecode"),       _FX_BSTRC("LZW"),
-    _FX_BSTRC("FlateDecode"),     _FX_BSTRC("Fl"),
-    _FX_BSTRC("RunLengthDecode"), _FX_BSTRC("RL"),
-    _FX_BSTRC("CCITTFaxDecode"),  _FX_BSTRC("CCF"),
-    _FX_BSTRC("DCTDecode"),       _FX_BSTRC("DCT"),
-};
-static CFX_ByteStringC _PDF_FindFullName(const _FX_BSTR* table,
-                                         int count,
-                                         const CFX_ByteStringC& abbr) {
-  int i = 0;
-  while (i < count) {
-    if (abbr.GetLength() == table[i + 1].m_Size &&
-        FXSYS_memcmp(abbr.GetPtr(), table[i + 1].m_Ptr, abbr.GetLength()) ==
-            0) {
-      return CFX_ByteStringC(table[i].m_Ptr, table[i].m_Size);
-    }
-    i += 2;
-  }
-  return CFX_ByteStringC();
-}
-void _PDF_ReplaceAbbr(CPDF_Object* pObj) {
+
+void PDF_ReplaceAbbr(CPDF_Object* pObj) {
   switch (pObj->GetType()) {
     case PDFOBJ_DICTIONARY: {
       CPDF_Dictionary* pDict = pObj->AsDictionary();
@@ -492,9 +503,8 @@
       while (pos) {
         CFX_ByteString key;
         CPDF_Object* value = pDict->GetNextElement(pos, key);
-        CFX_ByteStringC fullname = _PDF_FindFullName(
-            _PDF_InlineKeyAbbr, sizeof _PDF_InlineKeyAbbr / sizeof(_FX_BSTR),
-            key);
+        CFX_ByteStringC fullname = PDF_FindFullName(
+            PDF_InlineKeyAbbr, FX_ArraySize(PDF_InlineKeyAbbr), key);
         if (!fullname.IsEmpty()) {
           pDict->ReplaceKey(key, fullname);
           key = fullname;
@@ -502,14 +512,13 @@
 
         if (value->IsName()) {
           CFX_ByteString name = value->GetString();
-          fullname = _PDF_FindFullName(
-              _PDF_InlineValueAbbr,
-              sizeof _PDF_InlineValueAbbr / sizeof(_FX_BSTR), name);
+          fullname = PDF_FindFullName(PDF_InlineValueAbbr,
+                                      FX_ArraySize(PDF_InlineValueAbbr), name);
           if (!fullname.IsEmpty()) {
             pDict->SetAtName(key, fullname);
           }
         } else {
-          _PDF_ReplaceAbbr(value);
+          PDF_ReplaceAbbr(value);
         }
       }
       break;
@@ -520,35 +529,21 @@
         CPDF_Object* pElement = pArray->GetElement(i);
         if (pElement->IsName()) {
           CFX_ByteString name = pElement->GetString();
-          CFX_ByteStringC fullname = _PDF_FindFullName(
-              _PDF_InlineValueAbbr,
-              sizeof _PDF_InlineValueAbbr / sizeof(_FX_BSTR), name);
+          CFX_ByteStringC fullname = PDF_FindFullName(
+              PDF_InlineValueAbbr, FX_ArraySize(PDF_InlineValueAbbr), name);
           if (!fullname.IsEmpty()) {
             pArray->SetAt(i, new CPDF_Name(fullname));
           }
         } else {
-          _PDF_ReplaceAbbr(pElement);
+          PDF_ReplaceAbbr(pElement);
         }
       }
       break;
     }
   }
 }
-static CFX_ByteStringC _PDF_FindAbbrName(const _FX_BSTR* table,
-                                         int count,
-                                         const CFX_ByteStringC& fullName) {
-  int i = 0;
-  while (i < count) {
-    if (fullName.GetLength() == table[i].m_Size &&
-        FXSYS_memcmp(fullName.GetPtr(), table[i].m_Ptr, fullName.GetLength()) ==
-            0) {
-      return CFX_ByteStringC(table[i + 1].m_Ptr, table[i + 1].m_Size);
-    }
-    i += 2;
-  }
-  return CFX_ByteStringC();
-}
-void _PDF_ReplaceFull(CPDF_Object* pObj) {
+
+void PDF_ReplaceFull(CPDF_Object* pObj) {
   switch (pObj->GetType()) {
     case PDFOBJ_DICTIONARY: {
       CPDF_Dictionary* pDict = pObj->AsDictionary();
@@ -556,23 +551,21 @@
       while (pos) {
         CFX_ByteString key;
         CPDF_Object* value = pDict->GetNextElement(pos, key);
-        CFX_ByteStringC abbrName = _PDF_FindAbbrName(
-            _PDF_InlineKeyAbbr, sizeof(_PDF_InlineKeyAbbr) / sizeof(_FX_BSTR),
-            key);
+        CFX_ByteStringC abbrName = PDF_FindAbbrName(
+            PDF_InlineKeyAbbr, FX_ArraySize(PDF_InlineKeyAbbr), key);
         if (!abbrName.IsEmpty()) {
           pDict->ReplaceKey(key, abbrName);
           key = abbrName;
         }
         if (value->IsName()) {
           CFX_ByteString name = value->GetString();
-          abbrName = _PDF_FindAbbrName(
-              _PDF_InlineValueAbbr,
-              sizeof(_PDF_InlineValueAbbr) / sizeof(_FX_BSTR), name);
+          abbrName = PDF_FindAbbrName(PDF_InlineValueAbbr,
+                                      FX_ArraySize(PDF_InlineValueAbbr), name);
           if (!abbrName.IsEmpty()) {
             pDict->SetAtName(key, abbrName);
           }
         } else {
-          _PDF_ReplaceFull(value);
+          PDF_ReplaceFull(value);
         }
       }
       break;
@@ -583,14 +576,13 @@
         CPDF_Object* pElement = pArray->GetElement(i);
         if (pElement->IsName()) {
           CFX_ByteString name = pElement->GetString();
-          CFX_ByteStringC abbrName = _PDF_FindAbbrName(
-              _PDF_InlineValueAbbr,
-              sizeof _PDF_InlineValueAbbr / sizeof(_FX_BSTR), name);
+          CFX_ByteStringC abbrName = PDF_FindAbbrName(
+              PDF_InlineValueAbbr, FX_ArraySize(PDF_InlineValueAbbr), name);
           if (!abbrName.IsEmpty()) {
             pArray->SetAt(i, new CPDF_Name(abbrName));
           }
         } else {
-          _PDF_ReplaceFull(pElement);
+          PDF_ReplaceFull(pElement);
         }
       }
       break;
@@ -893,7 +885,9 @@
       (CFX_GraphStateData::LineCap)GetInteger(0);
 }
 void CPDF_StreamContentParser::Handle_SetCMYKColor_Fill() {
-  REQUIRE_PARAMS(4);
+  if (m_ParamCount != 4)
+    return;
+
   FX_FLOAT values[4];
   for (int i = 0; i < 4; i++) {
     values[i] = GetNumber(3 - i);
@@ -902,7 +896,9 @@
   m_pCurStates->m_ColorState.SetFillColor(pCS, values, 4);
 }
 void CPDF_StreamContentParser::Handle_SetCMYKColor_Stroke() {
-  REQUIRE_PARAMS(4);
+  if (m_ParamCount != 4)
+    return;
+
   FX_FLOAT values[4];
   for (int i = 0; i < 4; i++) {
     values[i] = GetNumber(3 - i);
@@ -911,14 +907,18 @@
   m_pCurStates->m_ColorState.SetStrokeColor(pCS, values, 4);
 }
 void CPDF_StreamContentParser::Handle_LineTo() {
-  REQUIRE_PARAMS(2);
+  if (m_ParamCount != 2)
+    return;
+
   if (m_Options.m_bTextOnly) {
     return;
   }
   AddPathPoint(GetNumber(1), GetNumber(0), FXPT_LINETO);
 }
 void CPDF_StreamContentParser::Handle_MoveTo() {
-  REQUIRE_PARAMS(2);
+  if (m_ParamCount != 2)
+    return;
+
   if (m_Options.m_bTextOnly) {
     m_pSyntax->SkipPathObject();
     return;
@@ -970,7 +970,9 @@
   AddPathPoint(x, y, FXPT_LINETO | FXPT_CLOSEFIGURE);
 }
 void CPDF_StreamContentParser::Handle_SetRGBColor_Fill() {
-  REQUIRE_PARAMS(3);
+  if (m_ParamCount != 3)
+    return;
+
   FX_FLOAT values[3];
   for (int i = 0; i < 3; i++) {
     values[i] = GetNumber(2 - i);
@@ -979,7 +981,9 @@
   m_pCurStates->m_ColorState.SetFillColor(pCS, values, 3);
 }
 void CPDF_StreamContentParser::Handle_SetRGBColor_Stroke() {
-  REQUIRE_PARAMS(3);
+  if (m_ParamCount != 3)
+    return;
+
   FX_FLOAT values[3];
   for (int i = 0; i < 3; i++) {
     values[i] = GetNumber(2 - i);
@@ -1341,7 +1345,7 @@
           FXSYS_Mul(pArray->GetNumber(i),
                     m_pCurStates->m_TextState.GetFontSize()) /
           1000;
-    };
+    }
     return;
   }
   CFX_ByteString* pStrs = new CFX_ByteString[nsegs];
diff --git a/core/src/fpdfapi/fpdf_page/fpdf_page_parser_old.cpp b/core/src/fpdfapi/fpdf_page/fpdf_page_parser_old.cpp
index 1c4cc24..8846c02 100644
--- a/core/src/fpdfapi/fpdf_page/fpdf_page_parser_old.cpp
+++ b/core/src/fpdfapi/fpdf_page/fpdf_page_parser_old.cpp
@@ -4,7 +4,7 @@
 
 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
 
-#include "pageint.h"
+#include "core/src/fpdfapi/fpdf_page/pageint.h"
 
 #include <limits.h>
 
@@ -72,7 +72,7 @@
   }
   return m_pSyntax->GetPos();
 }
-void _PDF_ReplaceAbbr(CPDF_Object* pObj);
+
 void CPDF_StreamContentParser::Handle_BeginImage() {
   FX_FILESIZE savePos = m_pSyntax->GetPos();
   CPDF_Dictionary* pDict = new CPDF_Dictionary;
@@ -102,7 +102,7 @@
         pDict->SetAt(key, pObj.release());
     }
   }
-  _PDF_ReplaceAbbr(pDict);
+  PDF_ReplaceAbbr(pDict);
   CPDF_Object* pCSObj = NULL;
   if (pDict->KeyExist("ColorSpace")) {
     pCSObj = pDict->GetElementValue("ColorSpace");
@@ -933,6 +933,7 @@
   m_Status = ToBeContinued;
   m_InternalStage = PAGEPARSE_STAGE_GETCONTENT;
   m_CurrentOffset = 0;
+
   CPDF_Object* pContent = pPage->m_pFormDict->GetElementValue("Contents");
   if (!pContent) {
     m_Status = Done;
@@ -951,7 +952,6 @@
     m_pStreamArray = FX_Alloc(CPDF_StreamAcc*, m_nStreams);
   } else {
     m_Status = Done;
-    return;
   }
 }
 void CPDF_ContentParser::Start(CPDF_Form* pForm,
@@ -1006,11 +1006,7 @@
   }
   m_nStreams = 0;
   m_pSingleStream = new CPDF_StreamAcc;
-  if (pForm->m_pDocument) {
-    m_pSingleStream->LoadAllData(pForm->m_pFormStream, FALSE);
-  } else {
-    m_pSingleStream->LoadAllData(pForm->m_pFormStream, FALSE);
-  }
+  m_pSingleStream->LoadAllData(pForm->m_pFormStream, FALSE);
   m_pData = (uint8_t*)m_pSingleStream->GetData();
   m_Size = m_pSingleStream->GetSize();
   m_Status = ToBeContinued;
diff --git a/core/src/fpdfapi/fpdf_page/pageint.h b/core/src/fpdfapi/fpdf_page/pageint.h
index f41a987..76ddaeb 100644
--- a/core/src/fpdfapi/fpdf_page/pageint.h
+++ b/core/src/fpdfapi/fpdf_page/pageint.h
@@ -525,4 +525,6 @@
   CPDF_CountedColorSpace* m_pCountedBaseCS;
 };
 
+void PDF_ReplaceAbbr(CPDF_Object* pObj);
+
 #endif  // CORE_SRC_FPDFAPI_FPDF_PAGE_PAGEINT_H_
diff --git a/core/src/fpdfapi/fpdf_parser/fpdf_parser_decode.cpp b/core/src/fpdfapi/fpdf_parser/fpdf_parser_decode.cpp
index c855a7c..d7783e4 100644
--- a/core/src/fpdfapi/fpdf_parser/fpdf_parser_decode.cpp
+++ b/core/src/fpdfapi/fpdf_parser/fpdf_parser_decode.cpp
@@ -324,9 +324,7 @@
                        CFX_ByteString& ImageEncoding,
                        CPDF_Dictionary*& pImageParms,
                        FX_DWORD last_estimated_size,
-                       FX_BOOL bImageAcc)
-
-{
+                       FX_BOOL bImageAcc) {
   CPDF_Object* pDecoder = pDict ? pDict->GetElementValue("Filter") : nullptr;
   if (!pDecoder || (!pDecoder->IsArray() && !pDecoder->IsName()))
     return FALSE;
diff --git a/core/src/fpdfapi/fpdf_parser/fpdf_parser_parser.cpp b/core/src/fpdfapi/fpdf_parser/fpdf_parser_parser.cpp
index 010b9b7..ad97d1f 100644
--- a/core/src/fpdfapi/fpdf_parser/fpdf_parser_parser.cpp
+++ b/core/src/fpdfapi/fpdf_parser/fpdf_parser_parser.cpp
@@ -360,13 +360,15 @@
   if (!m_pTrailer) {
     return FALSE;
   }
+
   int32_t xrefsize = GetDirectInteger(m_pTrailer, "Size");
   if (xrefsize <= 0 || xrefsize > kMaxXRefSize) {
     return FALSE;
   }
   m_ObjectInfo[0].pos = 0;
   m_V5Type.SetSize(xrefsize);
-  CFX_FileSizeArray CrossRefList, XRefStreamList;
+  CFX_FileSizeArray CrossRefList;
+  CFX_FileSizeArray XRefStreamList;
   CrossRefList.Add(xrefpos);
   XRefStreamList.Add(GetDirectInteger(m_pTrailer, "XRefStm"));
 
@@ -1416,9 +1418,8 @@
   }
   m_Syntax.RestorePos(SavedPos);
   if (pObj) {
-    if (!objnum) {
+    if (!objnum)
       pObj->m_ObjNum = parser_objnum;
-    }
     pObj->m_GenNum = parser_gennum;
   }
   return pObj;
@@ -1582,8 +1583,9 @@
   if (bLoadV4) {
     m_pTrailer = LoadTrailerV4();
     if (!m_pTrailer) {
-      return FALSE;
+      return PDFPARSE_ERROR_SUCCESS;
     }
+
     int32_t xrefsize = GetDirectInteger(m_pTrailer, "Size");
     if (xrefsize > 0) {
       m_ObjectInfo[0].pos = 0;
@@ -2759,7 +2761,6 @@
   FX_BOOL LoadAllXref(IFX_DownloadHints* pHints);
   FX_BOOL LoadAllFile(IFX_DownloadHints* pHints);
   int32_t CheckLinearizedData(IFX_DownloadHints* pHints);
-  FX_BOOL CheckFileResources(IFX_DownloadHints* pHints);
   FX_BOOL CheckPageAnnots(int iPage, IFX_DownloadHints* pHints);
 
   FX_BOOL CheckLinearizedFirstPage(int iPage, IFX_DownloadHints* pHints);
@@ -4296,7 +4297,7 @@
       pHints->AddSegment(m_dwLastXRefOffset, data_size.ValueOrDie());
       return DataNotAvailable;
     }
-    FX_DWORD dwRet = (m_pDocument->GetParser())->LoadLinearizedMainXRefTable();
+    FX_DWORD dwRet = m_pDocument->GetParser()->LoadLinearizedMainXRefTable();
     m_bMainXRefLoadTried = TRUE;
     if (dwRet != PDFPARSE_ERROR_SUCCESS) {
       return DataError;
@@ -4929,6 +4930,7 @@
   }
   return IPDF_DataAvail::DataAvailable;
 }
+
 FX_BOOL CPDF_HintTables::LoadHintStream(CPDF_Stream* pHintStream) {
   if (!pHintStream || !m_pLinearizedDict)
     return FALSE;
@@ -4954,6 +4956,7 @@
          ReadSharedObjHintTable(&bs, pdfium::base::checked_cast<FX_DWORD>(
                                          shared_hint_table_offset));
 }
+
 int CPDF_HintTables::ReadPrimaryHintStreamOffset() const {
   if (!m_pLinearizedDict)
     return -1;
diff --git a/core/src/fpdfapi/fpdf_parser/fpdf_parser_parser_unittest.cpp b/core/src/fpdfapi/fpdf_parser/fpdf_parser_parser_unittest.cpp
index 3014ca2..e091f14 100644
--- a/core/src/fpdfapi/fpdf_parser/fpdf_parser_parser_unittest.cpp
+++ b/core/src/fpdfapi/fpdf_parser/fpdf_parser_parser_unittest.cpp
@@ -20,18 +20,6 @@
       return false;
   return true;
 }
-template bool CompareArray<uint8_t>(const CFX_ByteArray&,
-                                    const uint8_t*,
-                                    size_t);
-template bool CompareArray<FX_WORD>(const CFX_WordArray&,
-                                    const FX_WORD*,
-                                    size_t);
-template bool CompareArray<FX_DWORD>(const CFX_DWordArray&,
-                                     const FX_DWORD*,
-                                     size_t);
-template bool CompareArray<FX_FILESIZE>(const CFX_FileSizeArray&,
-                                        const FX_FILESIZE*,
-                                        size_t);
 
 // Provide a way to read test data from a buffer instead of a file.
 class CFX_TestBufferRead : public IFX_FileRead {
diff --git a/fpdfsdk/include/fsdk_baseform.h b/fpdfsdk/include/fsdk_baseform.h
index 20cb7ce..f553bd8 100644
--- a/fpdfsdk/include/fsdk_baseform.h
+++ b/fpdfsdk/include/fsdk_baseform.h
@@ -196,10 +196,6 @@
   void EnableCalculate(FX_BOOL bEnabled);
   FX_BOOL IsCalculateEnabled() const;
 
-#ifdef _WIN32
-  CPDF_Stream* LoadImageFromFile(const CFX_WideString& sFile);
-#endif
-
   void OnKeyStrokeCommit(CPDF_FormField* pFormField,
                          CFX_WideString& csValue,
                          FX_BOOL& bRC);
diff --git a/fpdfsdk/include/fsdk_define.h b/fpdfsdk/include/fsdk_define.h
index 5d5e6e4..9746bb3 100644
--- a/fpdfsdk/include/fsdk_define.h
+++ b/fpdfsdk/include/fsdk_define.h
@@ -11,7 +11,6 @@
 #include "core/include/fpdfapi/fpdf_pageobj.h"
 #include "core/include/fpdfapi/fpdf_parser.h"
 #include "core/include/fpdfapi/fpdf_render.h"
-#include "core/include/fpdfapi/fpdf_serial.h"
 #include "core/include/fpdfdoc/fpdf_doc.h"
 #include "core/include/fpdfdoc/fpdf_vt.h"
 #include "core/include/fxge/fx_ge.h"
diff --git a/fpdfsdk/src/fpdfsave.cpp b/fpdfsdk/src/fpdfsave.cpp
index 0573e17..f786396 100644
--- a/fpdfsdk/src/fpdfsave.cpp
+++ b/fpdfsdk/src/fpdfsave.cpp
@@ -6,6 +6,7 @@
 
 #include "public/fpdf_save.h"
 
+#include "core/include/fpdfapi/fpdf_serial.h"
 #include "fpdfsdk/include/fsdk_define.h"
 #include "public/fpdf_edit.h"
 
diff --git a/fpdfsdk/src/fsdk_baseform.cpp b/fpdfsdk/src/fsdk_baseform.cpp
index ef821dc..efa6b4f 100644
--- a/fpdfsdk/src/fsdk_baseform.cpp
+++ b/fpdfsdk/src/fsdk_baseform.cpp
@@ -1551,66 +1551,6 @@
   return m_bCalculate;
 }
 
-#ifdef _WIN32
-CPDF_Stream* CPDFSDK_InterForm::LoadImageFromFile(const CFX_WideString& sFile) {
-  CPDF_Document* pDocument = m_pDocument->GetPDFDocument();
-  CPDF_Stream* pRetStream = NULL;
-
-  if (CFX_DIBitmap* pBmp = CFX_WindowsDIB::LoadFromFile(sFile.c_str())) {
-    int nWidth = pBmp->GetWidth();
-    int nHeight = pBmp->GetHeight();
-
-    CPDF_Image Image(pDocument);
-    Image.SetImage(pBmp, FALSE);
-    CPDF_Stream* pImageStream = Image.GetStream();
-    if (pImageStream) {
-      if (pImageStream->GetObjNum() == 0)
-        pDocument->AddIndirectObject(pImageStream);
-
-      CPDF_Dictionary* pStreamDict = new CPDF_Dictionary();
-      pStreamDict->SetAtName("Subtype", "Form");
-      pStreamDict->SetAtName("Name", "IMG");
-      CPDF_Array* pMatrix = new CPDF_Array();
-      pStreamDict->SetAt("Matrix", pMatrix);
-      pMatrix->AddInteger(1);
-      pMatrix->AddInteger(0);
-      pMatrix->AddInteger(0);
-      pMatrix->AddInteger(1);
-      pMatrix->AddInteger(-nWidth / 2);
-      pMatrix->AddInteger(-nHeight / 2);
-      CPDF_Dictionary* pResource = new CPDF_Dictionary();
-      pStreamDict->SetAt("Resources", pResource);
-      CPDF_Dictionary* pXObject = new CPDF_Dictionary();
-      pResource->SetAt("XObject", pXObject);
-      pXObject->SetAtReference("Img", pDocument, pImageStream);
-      CPDF_Array* pProcSet = new CPDF_Array();
-      pResource->SetAt("ProcSet", pProcSet);
-      pProcSet->AddName("PDF");
-      pProcSet->AddName("ImageC");
-      pStreamDict->SetAtName("Type", "XObject");
-      CPDF_Array* pBBox = new CPDF_Array();
-      pStreamDict->SetAt("BBox", pBBox);
-      pBBox->AddInteger(0);
-      pBBox->AddInteger(0);
-      pBBox->AddInteger(nWidth);
-      pBBox->AddInteger(nHeight);
-      pStreamDict->SetAtInteger("FormType", 1);
-
-      pRetStream = new CPDF_Stream(NULL, 0, NULL);
-      CFX_ByteString csStream;
-      csStream.Format("q\n%d 0 0 %d 0 0 cm\n/Img Do\nQ", nWidth, nHeight);
-      pRetStream->InitStream((uint8_t*)csStream.c_str(), csStream.GetLength(),
-                             pStreamDict);
-      pDocument->AddIndirectObject(pRetStream);
-    }
-
-    delete pBmp;
-  }
-
-  return pRetStream;
-}
-#endif
-
 void CPDFSDK_InterForm::OnCalculate(CPDF_FormField* pFormField) {
   CPDFDoc_Environment* pEnv = m_pDocument->GetEnv();
   ASSERT(pEnv);
diff --git a/fpdfsdk/src/pdfwindow/PWL_FontMap.cpp b/fpdfsdk/src/pdfwindow/PWL_FontMap.cpp
index e418e8b..89a75b2 100644
--- a/fpdfsdk/src/pdfwindow/PWL_FontMap.cpp
+++ b/fpdfsdk/src/pdfwindow/PWL_FontMap.cpp
@@ -9,7 +9,26 @@
 #include "core/include/fpdfapi/fpdf_module.h"
 #include "fpdfsdk/include/pdfwindow/PWL_Wnd.h"
 
-#define DEFAULT_FONT_NAME "Helvetica"
+namespace {
+
+const char kDefaultFontName[] = "Helvetica";
+
+const char* const g_sDEStandardFontName[] = {"Courier",
+                                             "Courier-Bold",
+                                             "Courier-BoldOblique",
+                                             "Courier-Oblique",
+                                             "Helvetica",
+                                             "Helvetica-Bold",
+                                             "Helvetica-BoldOblique",
+                                             "Helvetica-Oblique",
+                                             "Times-Roman",
+                                             "Times-Bold",
+                                             "Times-Italic",
+                                             "Times-BoldItalic",
+                                             "Symbol",
+                                             "ZapfDingbats"};
+
+}  // namespace
 
 CPWL_FontMap::CPWL_FontMap(IFX_SystemHandler* pSystemHandler)
     : m_pPDFDoc(NULL), m_pSystemHandler(pSystemHandler) {
@@ -151,34 +170,11 @@
 }
 
 void CPWL_FontMap::Initialize() {
-  GetFontIndex(DEFAULT_FONT_NAME, ANSI_CHARSET, FALSE);
+  GetFontIndex(kDefaultFontName, ANSI_CHARSET, FALSE);
 }
 
-/*
-List of currently supported standard fonts:
-Courier, Courier-Bold, Courier-BoldOblique, Courier-Oblique
-Helvetica, Helvetica-Bold, Helvetica-BoldOblique, Helvetica-Oblique
-Times-Roman, Times-Bold, Times-Italic, Times-BoldItalic
-Symbol, ZapfDingbats
-*/
-
-const char* g_sDEStandardFontName[] = {"Courier",
-                                       "Courier-Bold",
-                                       "Courier-BoldOblique",
-                                       "Courier-Oblique",
-                                       "Helvetica",
-                                       "Helvetica-Bold",
-                                       "Helvetica-BoldOblique",
-                                       "Helvetica-Oblique",
-                                       "Times-Roman",
-                                       "Times-Bold",
-                                       "Times-Italic",
-                                       "Times-BoldItalic",
-                                       "Symbol",
-                                       "ZapfDingbats"};
-
 FX_BOOL CPWL_FontMap::IsStandardFont(const CFX_ByteString& sFontName) {
-  for (int32_t i = 0; i < 14; i++) {
+  for (int32_t i = 0; i < FX_ArraySize(g_sDEStandardFontName); ++i) {
     if (sFontName == g_sDEStandardFontName[i])
       return TRUE;
   }