Rename First() and Last() {Byte,Wide}String{,View} classes

Change to Front() and Back() to have the names be more consistent with
those of STL containers. Prevent an overload when Left() and Right()
are renamed to First() and Last().

Bug: pdfium:1406
Change-Id: I2cb59501c0d48bf8a5c41a32dc5f09431fd142eb
Reviewed-on: https://pdfium-review.googlesource.com/c/pdfium/+/65631
Reviewed-by: Lei Zhang <thestig@chromium.org>
Commit-Queue: Daniel Hosseinian <dhoss@chromium.org>
diff --git a/core/fpdfapi/font/cpdf_cmap.cpp b/core/fpdfapi/font/cpdf_cmap.cpp
index 3b8e250..35cf8bb 100644
--- a/core/fpdfapi/font/cpdf_cmap.cpp
+++ b/core/fpdfapi/font/cpdf_cmap.cpp
@@ -259,7 +259,7 @@
 }  // namespace
 
 CPDF_CMap::CPDF_CMap(const ByteString& bsPredefinedName)
-    : m_bVertical(bsPredefinedName.Last() == 'V') {
+    : m_bVertical(bsPredefinedName.Back() == 'V') {
   if (bsPredefinedName == "Identity-H" || bsPredefinedName == "Identity-V") {
     m_Coding = CIDCODING_CID;
     m_bLoaded = true;
diff --git a/core/fpdfapi/font/cpdf_font.cpp b/core/fpdfapi/font/cpdf_font.cpp
index 813e4b5..106ab6a 100644
--- a/core/fpdfapi/font/cpdf_font.cpp
+++ b/core/fpdfapi/font/cpdf_font.cpp
@@ -345,7 +345,7 @@
     return 0;
 
   size_t& offset = *pOffset;
-  return offset < pString.GetLength() ? pString[offset++] : pString.Last();
+  return offset < pString.GetLength() ? pString[offset++] : pString.Back();
 }
 
 bool CPDF_Font::IsStandardFont() const {
diff --git a/core/fpdftext/cpdf_linkextract.cpp b/core/fpdftext/cpdf_linkextract.cpp
index 3a1e31f..001ff1d 100644
--- a/core/fpdftext/cpdf_linkextract.cpp
+++ b/core/fpdftext/cpdf_linkextract.cpp
@@ -152,7 +152,7 @@
 
     if (strBeCheck.GetLength() > 5) {
       while (strBeCheck.GetLength() > 0) {
-        wchar_t ch = strBeCheck.Last();
+        wchar_t ch = strBeCheck.Back();
         if (ch != L')' && ch != L',' && ch != L'>' && ch != L'.')
           break;
 
diff --git a/core/fpdftext/cpdf_textpage.cpp b/core/fpdftext/cpdf_textpage.cpp
index 7252f91..58a2959 100644
--- a/core/fpdftext/cpdf_textpage.cpp
+++ b/core/fpdftext/cpdf_textpage.cpp
@@ -962,7 +962,7 @@
             return;
         }
         while (m_TempTextBuf.GetSize() > 0 &&
-               m_TempTextBuf.AsStringView().Last() == 0x20) {
+               m_TempTextBuf.AsStringView().Back() == 0x20) {
           m_TempTextBuf.Delete(m_TempTextBuf.GetLength() - 1, 1);
           m_TempCharList.pop_back();
         }
@@ -1004,7 +1004,7 @@
       WideString str = m_TempTextBuf.MakeString();
       if (str.IsEmpty())
         str = m_TextBuf.AsStringView();
-      if (str.IsEmpty() || str.Last() == L' ')
+      if (str.IsEmpty() || str.Back() == L' ')
         continue;
 
       float fontsize_h = pTextObj->m_TextState.GetFontSizeH();
@@ -1118,7 +1118,7 @@
       }
     } else if (i == 0) {
       WideString str = m_TempTextBuf.MakeString();
-      if (!str.IsEmpty() && str.Last() == L' ') {
+      if (!str.IsEmpty() && str.Back() == L' ') {
         m_TempTextBuf.Delete(m_TempTextBuf.GetLength() - 1, 1);
         m_TempCharList.pop_back();
       }
@@ -1290,7 +1290,7 @@
 
   WideString PrevStr =
       m_pPrevTextObj->GetFont()->UnicodeFromCharCode(PrevItem.m_CharCode);
-  wchar_t preChar = PrevStr.Last();
+  wchar_t preChar = PrevStr.Back();
   if (preChar == L' ')
     return GenerateCharacter::kNone;
 
diff --git a/core/fpdftext/cpdf_textpagefind.cpp b/core/fpdftext/cpdf_textpagefind.cpp
index a821de0..d409670 100644
--- a/core/fpdftext/cpdf_textpagefind.cpp
+++ b/core/fpdftext/cpdf_textpagefind.cpp
@@ -248,7 +248,7 @@
       size_t PreResEndPos = nStartPos;
       int curChar = csWord[0];
       WideString lastWord = m_csFindWhatArray[iWord - 1];
-      int lastChar = lastWord.Last();
+      int lastChar = lastWord.Back();
       if (nStartPos == nResultPos.value() &&
           !(IsIgnoreSpaceCharacter(lastChar) ||
             IsIgnoreSpaceCharacter(curChar))) {
diff --git a/core/fxcrt/bytestring.h b/core/fxcrt/bytestring.h
index c7d09aa..c017087 100644
--- a/core/fxcrt/bytestring.h
+++ b/core/fxcrt/bytestring.h
@@ -146,8 +146,8 @@
     return m_pData->m_String[index];
   }
 
-  CharType First() const { return GetLength() ? (*this)[0] : 0; }
-  CharType Last() const { return GetLength() ? (*this)[GetLength() - 1] : 0; }
+  CharType Front() const { return GetLength() ? (*this)[0] : 0; }
+  CharType Back() const { return GetLength() ? (*this)[GetLength() - 1] : 0; }
 
   void SetAt(size_t index, char c);
 
diff --git a/core/fxcrt/string_view_template.h b/core/fxcrt/string_view_template.h
index 135b5a3..f4180f7 100644
--- a/core/fxcrt/string_view_template.h
+++ b/core/fxcrt/string_view_template.h
@@ -179,8 +179,8 @@
     return m_Span[index];
   }
 
-  UnsignedType First() const { return !m_Span.empty() ? m_Span[0] : 0; }
-  UnsignedType Last() const {
+  UnsignedType Front() const { return !m_Span.empty() ? m_Span[0] : 0; }
+  UnsignedType Back() const {
     return !m_Span.empty() ? m_Span[m_Span.size() - 1] : 0;
   }
 
diff --git a/core/fxcrt/widestring.h b/core/fxcrt/widestring.h
index 10a86ba..d240a9d 100644
--- a/core/fxcrt/widestring.h
+++ b/core/fxcrt/widestring.h
@@ -141,8 +141,8 @@
     return m_pData->m_String[index];
   }
 
-  CharType First() const { return GetLength() ? (*this)[0] : 0; }
-  CharType Last() const { return GetLength() ? (*this)[GetLength() - 1] : 0; }
+  CharType Front() const { return GetLength() ? (*this)[0] : 0; }
+  CharType Back() const { return GetLength() ? (*this)[GetLength() - 1] : 0; }
 
   void SetAt(size_t index, wchar_t c);
 
diff --git a/fxbarcode/datamatrix/BC_HighLevelEncoder.cpp b/fxbarcode/datamatrix/BC_HighLevelEncoder.cpp
index 34e1a76..a0c682d 100644
--- a/fxbarcode/datamatrix/BC_HighLevelEncoder.cpp
+++ b/fxbarcode/datamatrix/BC_HighLevelEncoder.cpp
@@ -131,7 +131,7 @@
   if (context.HasCharactersOutsideISO88591Encoding())
     return WideString();
 
-  if (msg.Last() == kMacroTrailer) {
+  if (msg.Back() == kMacroTrailer) {
     WideString left = msg.Left(6);
     if (left == kMacro05Header) {
       context.writeCodeword(kMacro05);
diff --git a/fxbarcode/oned/BC_OnedEAN13Writer.cpp b/fxbarcode/oned/BC_OnedEAN13Writer.cpp
index 7fdab48..2a82a66 100644
--- a/fxbarcode/oned/BC_OnedEAN13Writer.cpp
+++ b/fxbarcode/oned/BC_OnedEAN13Writer.cpp
@@ -100,7 +100,7 @@
     return nullptr;
 
   m_iDataLenth = 13;
-  int32_t firstDigit = FXSYS_DecimalCharToInt(contents.First());
+  int32_t firstDigit = FXSYS_DecimalCharToInt(contents.Front());
   int32_t parities = kFirstDigitEncodings[firstDigit];
   outLength = m_codeWidth;
   std::unique_ptr<uint8_t, FxFreeDeleter> result(
diff --git a/fxjs/xfa/cfxjse_resolveprocessor.cpp b/fxjs/xfa/cfxjse_resolveprocessor.cpp
index 3dc80e7..31d75be 100644
--- a/fxjs/xfa/cfxjse_resolveprocessor.cpp
+++ b/fxjs/xfa/cfxjse_resolveprocessor.cpp
@@ -33,9 +33,9 @@
   ASSERT(iFoundCount == pRnd->m_Objects.size());
   WideString wsExpression;
   CXFA_Script::Type eLangType = CXFA_Script::Type::Unknown;
-  if (wsCondition.Left(2).EqualsASCII(".[") && wsCondition.Last() == L']')
+  if (wsCondition.Left(2).EqualsASCII(".[") && wsCondition.Back() == L']')
     eLangType = CXFA_Script::Type::Formcalc;
-  else if (wsCondition.Left(2).EqualsASCII(".(") && wsCondition.Last() == L')')
+  else if (wsCondition.Left(2).EqualsASCII(".(") && wsCondition.Back() == L')')
     eLangType = CXFA_Script::Type::Javascript;
   else
     return;
diff --git a/xfa/fxfa/cxfa_textlayout.cpp b/xfa/fxfa/cxfa_textlayout.cpp
index cb28541..45f682c 100644
--- a/xfa/fxfa/cxfa_textlayout.cpp
+++ b/xfa/fxfa/cxfa_textlayout.cpp
@@ -798,7 +798,7 @@
           } else if (CFX_CSSDisplay::Inline == eDisplay &&
                      m_pLoader->bFilterSpace) {
             m_pLoader->bFilterSpace = false;
-          } else if (wsText.GetLength() > 0 && wsText.Last() == 0x20) {
+          } else if (wsText.GetLength() > 0 && wsText.Back() == 0x20) {
             m_pLoader->bFilterSpace = true;
           } else if (wsText.GetLength() != 0) {
             m_pLoader->bFilterSpace = false;
diff --git a/xfa/fxfa/layout/cxfa_viewlayoutprocessor.cpp b/xfa/fxfa/layout/cxfa_viewlayoutprocessor.cpp
index bd02dc4..54a9f33 100644
--- a/xfa/fxfa/layout/cxfa_viewlayoutprocessor.cpp
+++ b/xfa/fxfa/layout/cxfa_viewlayoutprocessor.cpp
@@ -204,7 +204,7 @@
         return pNode;
     } else if (bNewExprStyle) {
       WideString wsProcessedTarget = wsExpr;
-      if (wsExpr.Left(4).EqualsASCII("som(") && wsExpr.Last() == L')')
+      if (wsExpr.Left(4).EqualsASCII("som(") && wsExpr.Back() == L')')
         wsProcessedTarget = wsExpr.Substr(4, wsExpr.GetLength() - 5);
 
       XFA_RESOLVENODE_RS rs;
diff --git a/xfa/fxfa/parser/cxfa_document_parser.cpp b/xfa/fxfa/parser/cxfa_document_parser.cpp
index edae8b7..acefd25 100644
--- a/xfa/fxfa/parser/cxfa_document_parser.cpp
+++ b/xfa/fxfa/parser/cxfa_document_parser.cpp
@@ -195,7 +195,7 @@
           wsPlainText += L"\n";
         }
       } else if (uTag == 0xa48ac63) {
-        if (!wsPlainText.IsEmpty() && wsPlainText.Last() != '\n') {
+        if (!wsPlainText.IsEmpty() && wsPlainText.Back() != '\n') {
           wsPlainText += L"\n";
         }
       }
diff --git a/xfa/fxfa/parser/cxfa_node.cpp b/xfa/fxfa/parser/cxfa_node.cpp
index 9c1a2ff..a1b2093 100644
--- a/xfa/fxfa/parser/cxfa_node.cpp
+++ b/xfa/fxfa/parser/cxfa_node.cpp
@@ -3256,7 +3256,7 @@
     return;
   }
 
-  if (wsText.Last() == L'\n')
+  if (wsText.Back() == L'\n')
     wsText += L'\n';
 
   CXFA_FieldLayoutData* layoutData = m_pLayoutData->AsFieldLayoutData();