Simplify CPDF_TextObject::CalcPositionData() for internal callers.

Internal callers within CPDF_TextObject do not care about the parameter
to CalcPositionData() and the corresponding return value. Split
CalcPositionData() so that existing internal callers can call the
internal version which does not have the irrelevant parameter.

Change-Id: I2cce0bcc9ca663322ddd449262b52cbd2b591583
Reviewed-on: https://pdfium-review.googlesource.com/c/pdfium/+/93972
Commit-Queue: Lei Zhang <thestig@chromium.org>
Reviewed-by: Tom Sepez <tsepez@chromium.org>
diff --git a/core/fpdfapi/page/cpdf_textobject.cpp b/core/fpdfapi/page/cpdf_textobject.cpp
index 914de72..33e1b0b 100644
--- a/core/fpdfapi/page/cpdf_textobject.cpp
+++ b/core/fpdfapi/page/cpdf_textobject.cpp
@@ -189,7 +189,7 @@
   pTextMatrix[2] = matrix.b;
   pTextMatrix[3] = matrix.d;
   m_Pos = CFX_PointF(matrix.e, matrix.f);
-  CalcPositionData(0);
+  CalcPositionDataInternal(GetFont());
 }
 
 void CPDF_TextObject::SetSegments(const ByteString* pStrs,
@@ -223,7 +223,7 @@
 
 void CPDF_TextObject::SetText(const ByteString& str) {
   SetSegments(&str, std::vector<float>(), 1);
-  CalcPositionData(/*horz_scale=*/1.0f);
+  CalcPositionDataInternal(GetFont());
   SetDirty(true);
 }
 
@@ -256,12 +256,20 @@
 }
 
 CFX_PointF CPDF_TextObject::CalcPositionData(float horz_scale) {
+  RetainPtr<CPDF_Font> pFont = GetFont();
+  const float curpos = CalcPositionDataInternal(pFont);
+  if (IsVertWritingCIDFont(pFont->AsCIDFont()))
+    return {0, curpos};
+  return {curpos * horz_scale, 0};
+}
+
+float CPDF_TextObject::CalcPositionDataInternal(
+    const RetainPtr<CPDF_Font>& pFont) {
   float curpos = 0;
   float min_x = 10000.0f;
   float max_x = -10000.0f;
   float min_y = 10000.0f;
   float max_y = -10000.0f;
-  RetainPtr<CPDF_Font> pFont = GetFont();
   const CPDF_CIDFont* pCIDFont = pFont->AsCIDFont();
   const bool bVertWriting = IsVertWritingCIDFont(pCIDFont);
   const float fontsize = GetFontSize();
@@ -309,13 +317,10 @@
     curpos += m_TextState.GetCharSpace();
   }
 
-  CFX_PointF ret;
   if (bVertWriting) {
-    ret.y = curpos;
     min_x = min_x * fontsize / 1000;
     max_x = max_x * fontsize / 1000;
   } else {
-    ret.x = curpos * horz_scale;
     min_y = min_y * fontsize / 1000;
     max_y = max_y * fontsize / 1000;
   }
@@ -328,5 +333,5 @@
   }
   SetRect(rect);
 
-  return ret;
+  return curpos;
 }
diff --git a/core/fpdfapi/page/cpdf_textobject.h b/core/fpdfapi/page/cpdf_textobject.h
index 67a42ca..d52aad7 100644
--- a/core/fpdfapi/page/cpdf_textobject.h
+++ b/core/fpdfapi/page/cpdf_textobject.h
@@ -75,6 +75,8 @@
   CFX_PointF CalcPositionData(float horz_scale);
 
  private:
+  float CalcPositionDataInternal(const RetainPtr<CPDF_Font>& pFont);
+
   CFX_PointF m_Pos;
   std::vector<uint32_t> m_CharCodes;
   std::vector<float> m_CharPos;