Merge to XFA: CPDFText_ParseOptions never change from default.

Original Review URL: https://codereview.chromium.org/1618693009 .
(cherry picked from commit c818b5fc6cca9a7e1a2851b30e8a34f652ab0ea9)

TBR=ochang@chromium.org

Review URL: https://codereview.chromium.org/1629593002 .
diff --git a/core/include/fpdftext/fpdf_text.h b/core/include/fpdftext/fpdf_text.h
index 77b0c29..20efb91 100644
--- a/core/include/fpdftext/fpdf_text.h
+++ b/core/include/fpdftext/fpdf_text.h
@@ -67,13 +67,6 @@
 #define FPDFTEXT_WRITINGMODE_LRTB 1
 #define FPDFTEXT_WRITINGMODE_RLTB 2
 #define FPDFTEXT_WRITINGMODE_TBRL 3
-class CPDFText_ParseOptions {
- public:
-  CPDFText_ParseOptions();
-  FX_BOOL m_bGetCharCodeOnly;
-  FX_BOOL m_bNormalizeObjs;
-  FX_BOOL m_bOutputHyphen;
-};
 
 class IPDF_TextPage {
  public:
@@ -82,8 +75,6 @@
 
   virtual ~IPDF_TextPage() {}
 
-  virtual void NormalizeObjects(FX_BOOL bNormalize) = 0;
-
   virtual FX_BOOL ParseTextPage() = 0;
 
   virtual bool IsParsed() const = 0;
diff --git a/core/src/fpdftext/fpdf_text_int.cpp b/core/src/fpdftext/fpdf_text_int.cpp
index 3b633a6..67411e3 100644
--- a/core/src/fpdftext/fpdf_text_int.cpp
+++ b/core/src/fpdftext/fpdf_text_int.cpp
@@ -81,11 +81,6 @@
 
 }  // namespace
 
-CPDFText_ParseOptions::CPDFText_ParseOptions()
-    : m_bGetCharCodeOnly(FALSE),
-      m_bNormalizeObjs(TRUE),
-      m_bOutputHyphen(FALSE) {}
-
 IPDF_TextPage* IPDF_TextPage::CreateTextPage(const CPDF_Page* pPage,
                                              int flags) {
   return new CPDF_TextPage(pPage, flags);
@@ -123,9 +118,6 @@
                           (int)pPage->GetPageHeight(), 0);
 }
 
-void CPDF_TextPage::NormalizeObjects(FX_BOOL bNormalize) {
-  m_ParseOptions.m_bNormalizeObjs = bNormalize;
-}
 bool CPDF_TextPage::IsControlChar(const PAGECHAR_INFO& charInfo) {
   switch (charInfo.m_Unicode) {
     case 0x2:
@@ -151,55 +143,49 @@
   m_pPreTextObj = NULL;
   ProcessObject();
   m_bIsParsed = true;
-  if (!m_ParseOptions.m_bGetCharCodeOnly) {
-    m_CharIndex.RemoveAll();
-    int nCount = m_charList.GetSize();
-    if (nCount) {
-      m_CharIndex.Add(0);
-    }
-    for (int i = 0; i < nCount; i++) {
-      int indexSize = m_CharIndex.GetSize();
-      FX_BOOL bNormal = FALSE;
-      PAGECHAR_INFO charinfo = *(PAGECHAR_INFO*)m_charList.GetAt(i);
-      if (charinfo.m_Flag == FPDFTEXT_CHAR_GENERATED) {
-        bNormal = TRUE;
-      } else if (charinfo.m_Unicode == 0 || IsControlChar(charinfo)) {
-        bNormal = FALSE;
-      } else {
-        bNormal = TRUE;
-      }
-      if (bNormal) {
-        if (indexSize % 2) {
-          m_CharIndex.Add(1);
-        } else {
-          if (indexSize <= 0) {
-            continue;
-          }
-          m_CharIndex.SetAt(indexSize - 1,
-                            m_CharIndex.GetAt(indexSize - 1) + 1);
-        }
-      } else {
-        if (indexSize % 2) {
-          if (indexSize <= 0) {
-            continue;
-          }
-          m_CharIndex.SetAt(indexSize - 1, i + 1);
-        } else {
-          m_CharIndex.Add(i + 1);
-        }
-      }
-    }
+  m_CharIndex.RemoveAll();
+  int nCount = m_charList.GetSize();
+  if (nCount) {
+    m_CharIndex.Add(0);
+  }
+  for (int i = 0; i < nCount; i++) {
     int indexSize = m_CharIndex.GetSize();
-    if (indexSize % 2) {
-      m_CharIndex.RemoveAt(indexSize - 1);
+    FX_BOOL bNormal = FALSE;
+    PAGECHAR_INFO charinfo = *(PAGECHAR_INFO*)m_charList.GetAt(i);
+    if (charinfo.m_Flag == FPDFTEXT_CHAR_GENERATED) {
+      bNormal = TRUE;
+    } else if (charinfo.m_Unicode == 0 || IsControlChar(charinfo)) {
+      bNormal = FALSE;
+    } else {
+      bNormal = TRUE;
     }
+    if (bNormal) {
+      if (indexSize % 2) {
+        m_CharIndex.Add(1);
+      } else {
+        if (indexSize <= 0) {
+          continue;
+        }
+        m_CharIndex.SetAt(indexSize - 1, m_CharIndex.GetAt(indexSize - 1) + 1);
+      }
+    } else {
+      if (indexSize % 2) {
+        if (indexSize <= 0) {
+          continue;
+        }
+        m_CharIndex.SetAt(indexSize - 1, i + 1);
+      } else {
+        m_CharIndex.Add(i + 1);
+      }
+    }
+  }
+  int indexSize = m_CharIndex.GetSize();
+  if (indexSize % 2) {
+    m_CharIndex.RemoveAt(indexSize - 1);
   }
   return TRUE;
 }
 int CPDF_TextPage::CountChars() const {
-  if (m_ParseOptions.m_bGetCharCodeOnly) {
-    return m_TextBuf.GetSize();
-  }
   return m_charList.GetSize();
 }
 int CPDF_TextPage::CharIndexFromTextIndex(int TextIndex) const {
@@ -232,9 +218,6 @@
 void CPDF_TextPage::GetRectArray(int start,
                                  int nCount,
                                  CFX_RectArray& rectArray) const {
-  if (m_ParseOptions.m_bGetCharCodeOnly) {
-    return;
-  }
   if (start < 0 || nCount == 0) {
     return;
   }
@@ -321,7 +304,7 @@
 int CPDF_TextPage::GetIndexAtPos(CPDF_Point point,
                                  FX_FLOAT xTolerance,
                                  FX_FLOAT yTolerance) const {
-  if (m_ParseOptions.m_bGetCharCodeOnly || !m_bIsParsed)
+  if (!m_bIsParsed)
     return -3;
 
   int pos = 0;
@@ -366,7 +349,7 @@
 }
 CFX_WideString CPDF_TextPage::GetTextByRect(const CFX_FloatRect& rect) const {
   CFX_WideString strText;
-  if (m_ParseOptions.m_bGetCharCodeOnly || !m_bIsParsed)
+  if (!m_bIsParsed)
     return strText;
 
   int nCount = m_charList.GetSize();
@@ -404,7 +387,7 @@
 }
 void CPDF_TextPage::GetRectsArrayByRect(const CFX_FloatRect& rect,
                                         CFX_RectArray& resRectArray) const {
-  if (m_ParseOptions.m_bGetCharCodeOnly || !m_bIsParsed)
+  if (!m_bIsParsed)
     return;
 
   CFX_FloatRect curRect;
@@ -454,15 +437,12 @@
                                  FX_FLOAT y,
                                  FX_FLOAT xTolerance,
                                  FX_FLOAT yTolerance) const {
-  if (m_ParseOptions.m_bGetCharCodeOnly) {
-    return -3;
-  }
   CPDF_Point point(x, y);
   return GetIndexAtPos(point, xTolerance, yTolerance);
 }
 
 void CPDF_TextPage::GetCharInfo(int index, FPDF_CHAR_INFO* info) const {
-  if (m_ParseOptions.m_bGetCharCodeOnly || !m_bIsParsed)
+  if (!m_bIsParsed)
     return;
 
   if (index < 0 || index >= m_charList.GetSize())
@@ -573,7 +553,7 @@
   return m_TextBuf.GetWideString().Mid(startindex, nCount);
 }
 int CPDF_TextPage::CountRects(int start, int nCount) {
-  if (m_ParseOptions.m_bGetCharCodeOnly || !m_bIsParsed || start < 0)
+  if (!m_bIsParsed || start < 0)
     return -1;
 
   if (nCount == -1 || nCount + start > m_charList.GetSize()) {
@@ -588,7 +568,7 @@
                             FX_FLOAT& top,
                             FX_FLOAT& right,
                             FX_FLOAT& bottom) const {
-  if (m_ParseOptions.m_bGetCharCodeOnly || !m_bIsParsed)
+  if (!m_bIsParsed)
     return;
 
   if (rectIndex < 0 || rectIndex >= m_SelRects.GetSize())
@@ -601,9 +581,6 @@
 }
 
 FX_BOOL CPDF_TextPage::GetBaselineRotate(int start, int end, int& Rotate) {
-  if (m_ParseOptions.m_bGetCharCodeOnly) {
-    return FALSE;
-  }
   if (end == start) {
     return FALSE;
   }
@@ -641,9 +618,6 @@
 
 FX_BOOL CPDF_TextPage::GetBaselineRotate(const CFX_FloatRect& rect,
                                          int& Rotate) {
-  if (m_ParseOptions.m_bGetCharCodeOnly) {
-    return FALSE;
-  }
   int start, end, count,
       n = CountBoundedSegments(rect.left, rect.top, rect.right, rect.bottom,
                                TRUE);
@@ -661,10 +635,10 @@
   return GetBaselineRotate(start, end, Rotate);
 }
 FX_BOOL CPDF_TextPage::GetBaselineRotate(int rectIndex, int& Rotate) {
-  if (m_ParseOptions.m_bGetCharCodeOnly || !m_bIsParsed)
+  if (!m_bIsParsed)
     return FALSE;
 
-  if (rectIndex < 0 || rectIndex > m_SelRects.GetSize())
+  if (rectIndex < 0 || rectIndex >= m_SelRects.GetSize())
     return FALSE;
 
   CFX_FloatRect rect = m_SelRects.GetAt(rectIndex);
@@ -675,9 +649,6 @@
                                         FX_FLOAT right,
                                         FX_FLOAT bottom,
                                         FX_BOOL bContains) {
-  if (m_ParseOptions.m_bGetCharCodeOnly)
-    return -1;
-
   m_Segment.RemoveAll();
   if (!m_bIsParsed)
     return -1;
@@ -751,9 +722,6 @@
   return m_Segment.GetSize();
 }
 void CPDF_TextPage::GetBoundedSegment(int index, int& start, int& count) const {
-  if (m_ParseOptions.m_bGetCharCodeOnly) {
-    return;
-  }
   if (index < 0 || index >= m_Segment.GetSize()) {
     return;
   }
@@ -761,7 +729,7 @@
   count = m_Segment.GetAt(index).m_nCount;
 }
 int CPDF_TextPage::GetWordBreak(int index, int direction) const {
-  if (m_ParseOptions.m_bGetCharCodeOnly || !m_bIsParsed)
+  if (!m_bIsParsed)
     return -1;
 
   if (direction != FPDFTEXT_LEFT && direction != FPDFTEXT_RIGHT)
@@ -1007,9 +975,7 @@
           Info2.m_Unicode = pDst[nIndex];
           Info2.m_Flag = FPDFTEXT_CHAR_PIECE;
           m_TextBuf.AppendChar(Info2.m_Unicode);
-          if (!m_ParseOptions.m_bGetCharCodeOnly) {
-            m_charList.Add(Info2);
-          }
+          m_charList.Add(Info2);
         }
         FX_Free(pDst);
         return;
@@ -1019,9 +985,7 @@
   } else {
     Info.m_Index = -1;
   }
-  if (!m_ParseOptions.m_bGetCharCodeOnly) {
-    m_charList.Add(Info);
-  }
+  m_charList.Add(Info);
 }
 void CPDF_TextPage::AddCharInfoByRLDirection(CFX_WideString& str, int i) {
   PAGECHAR_INFO Info = *(PAGECHAR_INFO*)m_TempCharList.GetAt(i);
@@ -1038,9 +1002,7 @@
         Info2.m_Unicode = pDst[nIndex];
         Info2.m_Flag = FPDFTEXT_CHAR_PIECE;
         m_TextBuf.AppendChar(Info2.m_Unicode);
-        if (!m_ParseOptions.m_bGetCharCodeOnly) {
-          m_charList.Add(Info2);
-        }
+        m_charList.Add(Info2);
       }
       FX_Free(pDst);
       return;
@@ -1050,9 +1012,7 @@
   } else {
     Info.m_Index = -1;
   }
-  if (!m_ParseOptions.m_bGetCharCodeOnly) {
-    m_charList.Add(Info);
-  }
+  m_charList.Add(Info);
 }
 void CPDF_TextPage::CloseTempLine() {
   int count1 = m_TempCharList.GetSize();
@@ -1251,31 +1211,28 @@
     return;
   }
   int i = 0;
-  if (m_ParseOptions.m_bNormalizeObjs) {
-    for (i = count - 1; i >= 0; i--) {
-      PDFTEXT_Obj prev_Obj = m_LineObj.GetAt(i);
-      CFX_Matrix prev_matrix;
-      prev_Obj.m_pTextObj->GetTextMatrix(&prev_matrix);
-      FX_FLOAT Prev_x = prev_Obj.m_pTextObj->GetPosX(),
-               Prev_y = prev_Obj.m_pTextObj->GetPosY();
-      prev_Obj.m_formMatrix.Transform(Prev_x, Prev_y);
-      m_DisplayMatrix.Transform(Prev_x, Prev_y);
-      if (this_x >= Prev_x) {
-        if (i == count - 1) {
-          m_LineObj.Add(Obj);
-        } else {
-          m_LineObj.InsertAt(i + 1, Obj);
-        }
-        break;
+  for (i = count - 1; i >= 0; i--) {
+    PDFTEXT_Obj prev_Obj = m_LineObj.GetAt(i);
+    CFX_Matrix prev_matrix;
+    prev_Obj.m_pTextObj->GetTextMatrix(&prev_matrix);
+    FX_FLOAT Prev_x = prev_Obj.m_pTextObj->GetPosX(),
+             Prev_y = prev_Obj.m_pTextObj->GetPosY();
+    prev_Obj.m_formMatrix.Transform(Prev_x, Prev_y);
+    m_DisplayMatrix.Transform(Prev_x, Prev_y);
+    if (this_x >= Prev_x) {
+      if (i == count - 1) {
+        m_LineObj.Add(Obj);
+      } else {
+        m_LineObj.InsertAt(i + 1, Obj);
       }
+      break;
     }
-    if (i < 0) {
-      m_LineObj.InsertAt(0, Obj);
-    }
-  } else {
-    m_LineObj.Add(Obj);
+  }
+  if (i < 0) {
+    m_LineObj.InsertAt(0, Obj);
   }
 }
+
 int32_t CPDF_TextPage::PreMarkedContent(PDFTEXT_Obj Obj) {
   CPDF_TextObject* pTextObj = Obj.m_pTextObj;
   CPDF_ContentMarkData* pMarkData =
@@ -1524,27 +1481,22 @@
     } else if (result == 2) {
       CloseTempLine();
       if (m_TextBuf.GetSize()) {
-        if (m_ParseOptions.m_bGetCharCodeOnly) {
+        if (GenerateCharInfo(TEXT_RETURN_CHAR, generateChar)) {
           m_TextBuf.AppendChar(TEXT_RETURN_CHAR);
+          if (!formMatrix.IsIdentity()) {
+            generateChar.m_Matrix.Copy(formMatrix);
+          }
+          m_charList.Add(generateChar);
+        }
+        if (GenerateCharInfo(TEXT_LINEFEED_CHAR, generateChar)) {
           m_TextBuf.AppendChar(TEXT_LINEFEED_CHAR);
-        } else {
-          if (GenerateCharInfo(TEXT_RETURN_CHAR, generateChar)) {
-            m_TextBuf.AppendChar(TEXT_RETURN_CHAR);
-            if (!formMatrix.IsIdentity()) {
-              generateChar.m_Matrix.Copy(formMatrix);
-            }
-            m_charList.Add(generateChar);
+          if (!formMatrix.IsIdentity()) {
+            generateChar.m_Matrix.Copy(formMatrix);
           }
-          if (GenerateCharInfo(TEXT_LINEFEED_CHAR, generateChar)) {
-            m_TextBuf.AppendChar(TEXT_LINEFEED_CHAR);
-            if (!formMatrix.IsIdentity()) {
-              generateChar.m_Matrix.Copy(formMatrix);
-            }
-            m_charList.Add(generateChar);
-          }
+          m_charList.Add(generateChar);
         }
       }
-    } else if (result == 3 && !m_ParseOptions.m_bOutputHyphen) {
+    } else if (result == 3) {
       int32_t nChars = pTextObj->CountChars();
       if (nChars == 1) {
         CPDF_TextObjectItem item;
@@ -1985,8 +1937,7 @@
                          pTextObj2->m_Right, pTextObj2->m_Top);
   CFX_FloatRect rcCurObj(pTextObj1->m_Left, pTextObj1->m_Bottom,
                          pTextObj1->m_Right, pTextObj1->m_Top);
-  if (rcPreObj.IsEmpty() && rcCurObj.IsEmpty() &&
-      !m_ParseOptions.m_bGetCharCodeOnly) {
+  if (rcPreObj.IsEmpty() && rcCurObj.IsEmpty()) {
     FX_FLOAT dbXdif = FXSYS_fabs(rcPreObj.left - rcCurObj.left);
     int nCount = m_charList.GetSize();
     if (nCount >= 2) {
diff --git a/core/src/fpdftext/text_int.h b/core/src/fpdftext/text_int.h
index acc9bfa..f5d1f98 100644
--- a/core/src/fpdftext/text_int.h
+++ b/core/src/fpdftext/text_int.h
@@ -54,9 +54,8 @@
   CPDF_TextPage(const CPDF_Page* pPage, int flags);
   ~CPDF_TextPage() override {}
 
-  // IPDF_TextPage
+  // IPDF_TextPage:
   FX_BOOL ParseTextPage() override;
-  void NormalizeObjects(FX_BOOL bNormalize) override;
   bool IsParsed() const override { return m_bIsParsed; }
   int CharIndexFromTextIndex(int TextIndex) const override;
   int TextIndexFromCharIndex(int CharIndex) const override;
@@ -131,7 +130,6 @@
                         const CPDF_Font* pFont,
                         int nItems) const;
 
-  CPDFText_ParseOptions m_ParseOptions;
   CFX_WordArray m_CharIndex;
   const CPDF_PageObjectList* const m_pPage;
   PAGECHAR_InfoArray m_charList;