Remove FX_STRSIZE and replace with size_t

BUG=pdfium:828

Change-Id: I5c40237433ebabaeabdb43aec9cdf783e41dfe16
Reviewed-on: https://pdfium-review.googlesource.com/13230
Reviewed-by: dsinclair <dsinclair@chromium.org>
Commit-Queue: Ryan Harrison <rharrison@chromium.org>
diff --git a/fpdfsdk/cpdfsdk_interform.cpp b/fpdfsdk/cpdfsdk_interform.cpp
index fd0dffa..635655c 100644
--- a/fpdfsdk/cpdfsdk_interform.cpp
+++ b/fpdfsdk/cpdfsdk_interform.cpp
@@ -442,7 +442,7 @@
                                      bool bUrlEncoded) {
   ByteString textBuf = ExportFieldsToFDFTextBuf(fields, bIncludeOrExclude);
 
-  FX_STRSIZE nBufSize = textBuf.GetLength();
+  size_t nBufSize = textBuf.GetLength();
   if (nBufSize == 0)
     return false;
 
@@ -465,8 +465,7 @@
   return true;
 }
 
-bool CPDFSDK_InterForm::FDFToURLEncodedData(uint8_t*& pBuf,
-                                            FX_STRSIZE& nBufSize) {
+bool CPDFSDK_InterForm::FDFToURLEncodedData(uint8_t*& pBuf, size_t& nBufSize) {
   std::unique_ptr<CFDF_Document> pFDF =
       CFDF_Document::ParseMemory(pBuf, nBufSize);
   if (!pFDF)
@@ -538,14 +537,14 @@
 
   ByteString fdfBuffer = pFDFDoc->WriteToString();
 
-  FX_STRSIZE nBufSize = fdfBuffer.GetLength();
-  if (nBufSize == 0)
+  if (fdfBuffer.IsEmpty())
     return false;
 
-  uint8_t* pLocalBuffer = FX_Alloc(uint8_t, nBufSize);
-  memcpy(pLocalBuffer, fdfBuffer.c_str(), nBufSize);
+  uint8_t* pLocalBuffer = FX_Alloc(uint8_t, fdfBuffer.GetLength());
+  memcpy(pLocalBuffer, fdfBuffer.c_str(), fdfBuffer.GetLength());
   uint8_t* pBuffer = pLocalBuffer;
 
+  size_t nBufSize = fdfBuffer.GetLength();
   if (bUrlEncoded && !FDFToURLEncodedData(pBuffer, nBufSize)) {
     FX_Free(pLocalBuffer);
     return false;
diff --git a/fpdfsdk/cpdfsdk_interform.h b/fpdfsdk/cpdfsdk_interform.h
index 76acaf9..ae39913 100644
--- a/fpdfsdk/cpdfsdk_interform.h
+++ b/fpdfsdk/cpdfsdk_interform.h
@@ -115,7 +115,7 @@
   int BeforeFormImportData(CPDF_InterForm* pForm) override;
   void AfterFormImportData(CPDF_InterForm* pForm) override;
 
-  bool FDFToURLEncodedData(uint8_t*& pBuf, FX_STRSIZE& nBufSize);
+  bool FDFToURLEncodedData(uint8_t*& pBuf, size_t& nBufSize);
   int GetPageIndexByAnnotDict(CPDF_Document* pDocument,
                               CPDF_Dictionary* pAnnotDict) const;
 
diff --git a/fpdfsdk/fpdf_sysfontinfo.cpp b/fpdfsdk/fpdf_sysfontinfo.cpp
index 67b9a08..f1f165a 100644
--- a/fpdfsdk/fpdf_sysfontinfo.cpp
+++ b/fpdfsdk/fpdf_sysfontinfo.cpp
@@ -171,7 +171,7 @@
   auto* pDefault = static_cast<FPDF_SYSFONTINFO_DEFAULT*>(pThis);
   if (!pDefault->m_pFontInfo->GetFaceName(hFont, &name))
     return 0;
-  if (name.GetLength() >= static_cast<FX_STRSIZE>(buf_size))
+  if (name.GetLength() >= static_cast<size_t>(buf_size))
     return name.GetLength() + 1;
 
   strncpy(buffer, name.c_str(),
diff --git a/fpdfsdk/fpdfdoc.cpp b/fpdfsdk/fpdfdoc.cpp
index c3910b2..c536c73 100644
--- a/fpdfsdk/fpdfdoc.cpp
+++ b/fpdfsdk/fpdfdoc.cpp
@@ -103,7 +103,7 @@
   if (!pDoc)
     return nullptr;
   CPDF_BookmarkTree tree(pDoc);
-  FX_STRSIZE len = WideString::WStringLength(title);
+  size_t len = WideString::WStringLength(title);
   WideString encodedTitle = WideString::FromUTF16LE(title, len);
   std::set<CPDF_Dictionary*> visited;
   return FindBookmark(tree, CPDF_Bookmark(), encodedTitle, &visited).GetDict();
diff --git a/fpdfsdk/fpdfedittext.cpp b/fpdfsdk/fpdfedittext.cpp
index 2ac32b8..2a9ef53 100644
--- a/fpdfsdk/fpdfedittext.cpp
+++ b/fpdfsdk/fpdfedittext.cpp
@@ -420,7 +420,7 @@
   if (!pTextObj)
     return false;
 
-  FX_STRSIZE len = WideString::WStringLength(text);
+  size_t len = WideString::WStringLength(text);
   WideString encodedText = WideString::FromUTF16LE(text, len);
   ByteString byteText;
   for (wchar_t wc : encodedText) {
diff --git a/fpdfsdk/fpdfformfill.cpp b/fpdfsdk/fpdfformfill.cpp
index 65b0ae9..3d821b6 100644
--- a/fpdfsdk/fpdfformfill.cpp
+++ b/fpdfsdk/fpdfformfill.cpp
@@ -404,7 +404,7 @@
   if (!pPageView)
     return;
 
-  FX_STRSIZE len = WideString::WStringLength(wsText);
+  size_t len = WideString::WStringLength(wsText);
   WideString wide_str_text = WideString::FromUTF16LE(wsText, len);
 
   pPageView->ReplaceSelection(wide_str_text);
diff --git a/fpdfsdk/fpdfppo.cpp b/fpdfsdk/fpdfppo.cpp
index 153ae2e..3caba0e 100644
--- a/fpdfsdk/fpdfppo.cpp
+++ b/fpdfsdk/fpdfppo.cpp
@@ -77,16 +77,16 @@
     return true;
 
   rangstring.Remove(' ');
-  FX_STRSIZE nLength = rangstring.GetLength();
+  size_t nLength = rangstring.GetLength();
   ByteString cbCompareString("0123456789-,");
-  for (FX_STRSIZE i = 0; i < nLength; ++i) {
+  for (size_t i = 0; i < nLength; ++i) {
     if (!cbCompareString.Contains(rangstring[i]))
       return false;
   }
 
   ByteString cbMidRange;
-  FX_STRSIZE nStringFrom = 0;
-  pdfium::Optional<FX_STRSIZE> nStringTo = 0;
+  size_t nStringFrom = 0;
+  pdfium::Optional<size_t> nStringTo = 0;
   while (nStringTo < nLength) {
     nStringTo = rangstring.Find(',', nStringFrom);
     if (!nStringTo.has_value())
@@ -106,7 +106,7 @@
         return false;
 
       nMid = nMid.value() + 1;
-      FX_STRSIZE nEnd = cbMidRange.GetLength() - nMid.value();
+      size_t nEnd = cbMidRange.GetLength() - nMid.value();
       if (nEnd == 0)
         return false;
 
diff --git a/fpdfsdk/fpdftext.cpp b/fpdfsdk/fpdftext.cpp
index 9742974..ae6841f 100644
--- a/fpdfsdk/fpdftext.cpp
+++ b/fpdfsdk/fpdftext.cpp
@@ -175,8 +175,8 @@
   if (str.GetLength() <= 0)
     return 0;
 
-  if (str.GetLength() > static_cast<FX_STRSIZE>(count))
-    str = str.Left(static_cast<FX_STRSIZE>(count));
+  if (str.GetLength() > static_cast<size_t>(count))
+    str = str.Left(static_cast<size_t>(count));
 
   // UFT16LE_Encode doesn't handle surrogate pairs properly, so it is expected
   // the number of items to stay the same.
@@ -256,11 +256,11 @@
 
   CPDF_TextPageFind* textpageFind =
       new CPDF_TextPageFind(CPDFTextPageFromFPDFTextPage(text_page));
-  FX_STRSIZE len = WideString::WStringLength(findwhat);
+  size_t len = WideString::WStringLength(findwhat);
   textpageFind->FindFirst(WideString::FromUTF16LE(findwhat, len), flags,
                           start_index >= 0
-                              ? pdfium::Optional<FX_STRSIZE>(start_index)
-                              : pdfium::Optional<FX_STRSIZE>());
+                              ? pdfium::Optional<size_t>(start_index)
+                              : pdfium::Optional<size_t>());
   return textpageFind;
 }
 
diff --git a/fpdfsdk/fpdfview.cpp b/fpdfsdk/fpdfview.cpp
index cb5edcf..bbd60bd 100644
--- a/fpdfsdk/fpdfview.cpp
+++ b/fpdfsdk/fpdfview.cpp
@@ -240,7 +240,7 @@
     return 0;
   FX_FILESIZE dwAvail = nSize - m_nCurPos;
   if (dwAvail < (FX_FILESIZE)size)
-    size = (size_t)dwAvail;
+    size = static_cast<size_t>(dwAvail);
   if (m_pFS->ReadBlock(m_pFS->clientData, (FPDF_DWORD)m_nCurPos, buffer,
                        (FPDF_DWORD)size) == 0) {
     m_nCurPos += size;
diff --git a/fpdfsdk/javascript/Document.cpp b/fpdfsdk/javascript/Document.cpp
index 0c611c1..5d0f35c 100644
--- a/fpdfsdk/javascript/Document.cpp
+++ b/fpdfsdk/javascript/Document.cpp
@@ -386,7 +386,7 @@
   if (sTextBuf.GetLength() == 0)
     return false;
 
-  FX_STRSIZE nBufSize = sTextBuf.GetLength();
+  size_t nBufSize = sTextBuf.GetLength();
   char* pMutableBuf = FX_Alloc(char, nBufSize);
   memcpy(pMutableBuf, sTextBuf.c_str(), nBufSize);
 
@@ -1015,7 +1015,7 @@
     return false;
   }
   WideString wsFilePath = m_pFormFillEnv->JS_docGetFilePath();
-  FX_STRSIZE i = wsFilePath.GetLength();
+  size_t i = wsFilePath.GetLength();
   for (; i > 0; i--) {
     if (wsFilePath[i - 1] == L'\\' || wsFilePath[i - 1] == L'/')
       break;
diff --git a/fpdfsdk/javascript/PublicMethods.cpp b/fpdfsdk/javascript/PublicMethods.cpp
index c065bd0..af47159 100644
--- a/fpdfsdk/javascript/PublicMethods.cpp
+++ b/fpdfsdk/javascript/PublicMethods.cpp
@@ -224,12 +224,12 @@
 }
 
 int CJS_PublicMethods::ParseStringInteger(const WideString& str,
-                                          FX_STRSIZE nStart,
-                                          FX_STRSIZE& nSkip,
-                                          FX_STRSIZE nMaxStep) {
+                                          size_t nStart,
+                                          size_t& nSkip,
+                                          size_t nMaxStep) {
   int nRet = 0;
   nSkip = 0;
-  for (FX_STRSIZE i = nStart, sz = str.GetLength(); i < sz; i++) {
+  for (size_t i = nStart, sz = str.GetLength(); i < sz; i++) {
     if (i - nStart > 10)
       break;
 
@@ -247,11 +247,11 @@
 }
 
 WideString CJS_PublicMethods::ParseStringString(const WideString& str,
-                                                FX_STRSIZE nStart,
-                                                FX_STRSIZE& nSkip) {
+                                                size_t nStart,
+                                                size_t& nSkip) {
   WideString swRet;
   nSkip = 0;
-  for (FX_STRSIZE i = nStart, sz = str.GetLength(); i < sz; i++) {
+  for (size_t i = nStart, sz = str.GetLength(); i < sz; i++) {
     wchar_t c = str[i];
     if (!std::iswdigit(c))
       break;
@@ -276,10 +276,10 @@
 
   int number[3];
 
-  FX_STRSIZE nSkip = 0;
-  FX_STRSIZE nLen = value.GetLength();
-  FX_STRSIZE nIndex = 0;
-  FX_STRSIZE i = 0;
+  size_t nSkip = 0;
+  size_t nLen = value.GetLength();
+  size_t nIndex = 0;
+  size_t i = 0;
   while (i < nLen) {
     if (nIndex > 2)
       break;
@@ -364,8 +364,8 @@
   bool bExit = false;
   bool bBadFormat = false;
 
-  FX_STRSIZE i = 0;
-  FX_STRSIZE j = 0;
+  size_t i = 0;
+  size_t j = 0;
 
   while (i < format.GetLength()) {
     if (bExit)
@@ -390,9 +390,9 @@
       case 'M':
       case 's':
       case 't': {
-        FX_STRSIZE oldj = j;
-        FX_STRSIZE nSkip = 0;
-        FX_STRSIZE remaining = format.GetLength() - i - 1;
+        size_t oldj = j;
+        size_t nSkip = 0;
+        size_t remaining = format.GetLength() - i - 1;
 
         if (remaining == 0 || format[i + 1] != c) {
           switch (c) {
@@ -626,10 +626,10 @@
   int nMin = JS_GetMinFromTime(dDate);
   int nSec = JS_GetSecFromTime(dDate);
 
-  FX_STRSIZE i = 0;
+  size_t i = 0;
   while (i < format.GetLength()) {
     wchar_t c = format[i];
-    FX_STRSIZE remaining = format.GetLength() - i - 1;
+    size_t remaining = format.GetLength() - i - 1;
     sPart = L"";
     switch (c) {
       case 'y':
@@ -804,7 +804,7 @@
   }
 
   // Processing separator style
-  if (static_cast<FX_STRSIZE>(iDec2) < strValue.GetLength()) {
+  if (static_cast<size_t>(iDec2) < strValue.GetLength()) {
     if (iSepStyle == 2 || iSepStyle == 3)
       strValue.Replace(".", ",");
 
@@ -946,7 +946,7 @@
   const wchar_t cSep = iSepStyle < 2 ? L'.' : L',';
 
   bool bHasSep = wstrValue.Contains(cSep);
-  for (FX_STRSIZE i = 0; i < wstrChange.GetLength(); ++i) {
+  for (size_t i = 0; i < wstrChange.GetLength(); ++i) {
     if (wstrChange[i] == cSep) {
       if (bHasSep) {
         pEvent->Rc() = false;
@@ -982,9 +982,9 @@
   WideString wprefix = wstrValue.Left(pEvent->SelStart());
   WideString wpostfix;
   if (pEvent->SelEnd() >= 0 &&
-      static_cast<FX_STRSIZE>(pEvent->SelEnd()) < wstrValue.GetLength())
+      static_cast<size_t>(pEvent->SelEnd()) < wstrValue.GetLength())
     wpostfix = wstrValue.Right(wstrValue.GetLength() -
-                               static_cast<FX_STRSIZE>(pEvent->SelEnd()));
+                               static_cast<size_t>(pEvent->SelEnd()));
   val = wprefix + wstrChange + wpostfix;
   return true;
 }
@@ -1410,7 +1410,7 @@
     if (valEvent.IsEmpty())
       return true;
 
-    FX_STRSIZE iIndexMask = 0;
+    size_t iIndexMask = 0;
     for (; iIndexMask < valEvent.GetLength(); ++iIndexMask) {
       if (!maskSatisfied(valEvent[iIndexMask], wstrMask[iIndexMask]))
         break;
@@ -1430,9 +1430,9 @@
     return true;
 
   WideString wChange = wideChange;
-  FX_STRSIZE iIndexMask = pEvent->SelStart();
-  FX_STRSIZE combined_len = valEvent.GetLength() + wChange.GetLength() +
-                            pEvent->SelStart() - pEvent->SelEnd();
+  size_t iIndexMask = pEvent->SelStart();
+  size_t combined_len = valEvent.GetLength() + wChange.GetLength() +
+                        pEvent->SelStart() - pEvent->SelEnd();
   if (combined_len > wstrMask.GetLength()) {
     AlertIfPossible(pContext,
                     JSGetStringFromID(IDS_STRING_JSPARAM_TOOLONG).c_str());
@@ -1447,7 +1447,7 @@
     return true;
   }
 
-  for (FX_STRSIZE i = 0; i < wChange.GetLength(); ++i) {
+  for (size_t i = 0; i < wChange.GetLength(); ++i) {
     if (iIndexMask >= wstrMask.GetLength()) {
       AlertIfPossible(pContext,
                       JSGetStringFromID(IDS_STRING_JSPARAM_TOOLONG).c_str());
@@ -1537,9 +1537,9 @@
     prefix = L"";
 
   if (pEventHandler->SelEnd() >= 0 &&
-      static_cast<FX_STRSIZE>(pEventHandler->SelEnd()) <= swValue.GetLength())
+      static_cast<size_t>(pEventHandler->SelEnd()) <= swValue.GetLength())
     postfix = swValue.Right(swValue.GetLength() -
-                            static_cast<FX_STRSIZE>(pEventHandler->SelEnd()));
+                            static_cast<size_t>(pEventHandler->SelEnd()));
   else
     postfix = L"";
 
diff --git a/fpdfsdk/javascript/PublicMethods.h b/fpdfsdk/javascript/PublicMethods.h
index 365df3e..abce08b 100644
--- a/fpdfsdk/javascript/PublicMethods.h
+++ b/fpdfsdk/javascript/PublicMethods.h
@@ -133,12 +133,12 @@
   JS_STATIC_DECLARE_GLOBAL_FUN();
 
   static int ParseStringInteger(const WideString& string,
-                                FX_STRSIZE nStart,
-                                FX_STRSIZE& nSkip,
-                                FX_STRSIZE nMaxStep);
+                                size_t nStart,
+                                size_t& nSkip,
+                                size_t nMaxStep);
   static WideString ParseStringString(const WideString& string,
-                                      FX_STRSIZE nStart,
-                                      FX_STRSIZE& nSkip);
+                                      size_t nStart,
+                                      size_t& nSkip);
   static double MakeRegularDate(const WideString& value,
                                 const WideString& format,
                                 bool* bWrongFormat);
diff --git a/fpdfsdk/javascript/util.cpp b/fpdfsdk/javascript/util.cpp
index 3fe7a86..c4b1568 100644
--- a/fpdfsdk/javascript/util.cpp
+++ b/fpdfsdk/javascript/util.cpp
@@ -297,8 +297,8 @@
 WideString util::printx(const WideString& wsFormat,
                         const WideString& wsSource) {
   WideString wsResult;
-  FX_STRSIZE iSourceIdx = 0;
-  FX_STRSIZE iFormatIdx = 0;
+  size_t iSourceIdx = 0;
+  size_t iFormatIdx = 0;
   CaseMode eCaseMode = kPreserveCase;
   bool bEscaped = false;
   while (iFormatIdx < wsFormat.GetLength()) {