Make CLine an inner class of CSection.

It's mainly used within that class.

Change-Id: I3d108071a836403d216fe48bd75426fa8a495c20
Reviewed-on: https://pdfium-review.googlesource.com/c/pdfium/+/79031
Commit-Queue: Lei Zhang <thestig@chromium.org>
Reviewed-by: Tom Sepez <tsepez@chromium.org>
diff --git a/core/fpdfdoc/BUILD.gn b/core/fpdfdoc/BUILD.gn
index caf53f9..4d6e96f 100644
--- a/core/fpdfdoc/BUILD.gn
+++ b/core/fpdfdoc/BUILD.gn
@@ -9,8 +9,6 @@
   sources = [
     "cba_fontmap.cpp",
     "cba_fontmap.h",
-    "cline.cpp",
-    "cline.h",
     "cpdf_aaction.cpp",
     "cpdf_aaction.h",
     "cpdf_action.cpp",
diff --git a/core/fpdfdoc/cline.cpp b/core/fpdfdoc/cline.cpp
deleted file mode 100644
index 7940dc8..0000000
--- a/core/fpdfdoc/cline.cpp
+++ /dev/null
@@ -1,38 +0,0 @@
-// Copyright 2016 PDFium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
-
-#include "core/fpdfdoc/cline.h"
-
-CLine::CLine(const CPVT_LineInfo& lineinfo) : m_LineInfo(lineinfo) {}
-
-CLine::~CLine() = default;
-
-CPVT_WordPlace CLine::GetBeginWordPlace() const {
-  return CPVT_WordPlace(LinePlace.nSecIndex, LinePlace.nLineIndex, -1);
-}
-
-CPVT_WordPlace CLine::GetEndWordPlace() const {
-  return CPVT_WordPlace(LinePlace.nSecIndex, LinePlace.nLineIndex,
-                        m_LineInfo.nEndWordIndex);
-}
-
-CPVT_WordPlace CLine::GetPrevWordPlace(const CPVT_WordPlace& place) const {
-  if (place.nWordIndex > m_LineInfo.nEndWordIndex) {
-    return CPVT_WordPlace(place.nSecIndex, place.nLineIndex,
-                          m_LineInfo.nEndWordIndex);
-  }
-  return CPVT_WordPlace(place.nSecIndex, place.nLineIndex,
-                        place.nWordIndex - 1);
-}
-
-CPVT_WordPlace CLine::GetNextWordPlace(const CPVT_WordPlace& place) const {
-  if (place.nWordIndex < m_LineInfo.nBeginWordIndex) {
-    return CPVT_WordPlace(place.nSecIndex, place.nLineIndex,
-                          m_LineInfo.nBeginWordIndex);
-  }
-  return CPVT_WordPlace(place.nSecIndex, place.nLineIndex,
-                        place.nWordIndex + 1);
-}
diff --git a/core/fpdfdoc/cline.h b/core/fpdfdoc/cline.h
deleted file mode 100644
index b7e32d4..0000000
--- a/core/fpdfdoc/cline.h
+++ /dev/null
@@ -1,26 +0,0 @@
-// Copyright 2016 PDFium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
-
-#ifndef CORE_FPDFDOC_CLINE_H_
-#define CORE_FPDFDOC_CLINE_H_
-
-#include "core/fpdfdoc/cpvt_lineinfo.h"
-#include "core/fpdfdoc/cpvt_wordplace.h"
-
-class CLine {
- public:
-  explicit CLine(const CPVT_LineInfo& lineinfo);
-  ~CLine();
-
-  CPVT_WordPlace GetBeginWordPlace() const;
-  CPVT_WordPlace GetEndWordPlace() const;
-  CPVT_WordPlace GetPrevWordPlace(const CPVT_WordPlace& place) const;
-  CPVT_WordPlace GetNextWordPlace(const CPVT_WordPlace& place) const;
-  CPVT_WordPlace LinePlace;
-  CPVT_LineInfo m_LineInfo;
-};
-
-#endif  // CORE_FPDFDOC_CLINE_H_
diff --git a/core/fpdfdoc/cpdf_variabletext.cpp b/core/fpdfdoc/cpdf_variabletext.cpp
index 8ca72fc..26753b0 100644
--- a/core/fpdfdoc/cpdf_variabletext.cpp
+++ b/core/fpdfdoc/cpdf_variabletext.cpp
@@ -10,7 +10,6 @@
 #include <utility>
 
 #include "core/fpdfapi/font/cpdf_font.h"
-#include "core/fpdfdoc/cline.h"
 #include "core/fpdfdoc/cpvt_word.h"
 #include "core/fpdfdoc/cpvt_wordinfo.h"
 #include "core/fpdfdoc/csection.h"
@@ -167,7 +166,7 @@
   if (!pdfium::IndexInBounds(pSection->m_LineArray, m_CurPos.nLineIndex))
     return false;
 
-  CLine* pLine = pSection->m_LineArray[m_CurPos.nLineIndex].get();
+  CSection::Line* pLine = pSection->m_LineArray[m_CurPos.nLineIndex].get();
   line.ptLine = m_pVT->InToOut(
       CFX_PointF(pLine->m_LineInfo.fLineX + pSection->m_Rect.left,
                  pLine->m_LineInfo.fLineY + pSection->m_Rect.top));
diff --git a/core/fpdfdoc/csection.cpp b/core/fpdfdoc/csection.cpp
index c3b8adb..c9ac6f0 100644
--- a/core/fpdfdoc/csection.cpp
+++ b/core/fpdfdoc/csection.cpp
@@ -8,12 +8,44 @@
 
 #include <algorithm>
 
-#include "core/fpdfdoc/cline.h"
 #include "core/fpdfdoc/cpdf_variabletext.h"
 #include "core/fpdfdoc/cpvt_wordinfo.h"
 #include "third_party/base/check.h"
 #include "third_party/base/stl_util.h"
 
+CSection::Line::Line(const CPVT_LineInfo& lineinfo) : m_LineInfo(lineinfo) {}
+
+CSection::Line::~Line() = default;
+
+CPVT_WordPlace CSection::Line::GetBeginWordPlace() const {
+  return CPVT_WordPlace(LinePlace.nSecIndex, LinePlace.nLineIndex, -1);
+}
+
+CPVT_WordPlace CSection::Line::GetEndWordPlace() const {
+  return CPVT_WordPlace(LinePlace.nSecIndex, LinePlace.nLineIndex,
+                        m_LineInfo.nEndWordIndex);
+}
+
+CPVT_WordPlace CSection::Line::GetPrevWordPlace(
+    const CPVT_WordPlace& place) const {
+  if (place.nWordIndex > m_LineInfo.nEndWordIndex) {
+    return CPVT_WordPlace(place.nSecIndex, place.nLineIndex,
+                          m_LineInfo.nEndWordIndex);
+  }
+  return CPVT_WordPlace(place.nSecIndex, place.nLineIndex,
+                        place.nWordIndex - 1);
+}
+
+CPVT_WordPlace CSection::Line::GetNextWordPlace(
+    const CPVT_WordPlace& place) const {
+  if (place.nWordIndex < m_LineInfo.nBeginWordIndex) {
+    return CPVT_WordPlace(place.nSecIndex, place.nLineIndex,
+                          m_LineInfo.nBeginWordIndex);
+  }
+  return CPVT_WordPlace(place.nSecIndex, place.nLineIndex,
+                        place.nWordIndex + 1);
+}
+
 CSection::CSection(CPDF_VariableText* pVT) : m_pVT(pVT) {
   DCHECK(m_pVT);
 }
@@ -38,7 +70,7 @@
 }
 
 CPVT_WordPlace CSection::AddLine(const CPVT_LineInfo& lineinfo) {
-  m_LineArray.push_back(std::make_unique<CLine>(lineinfo));
+  m_LineArray.push_back(std::make_unique<Line>(lineinfo));
   return CPVT_WordPlace(SecPlace.nSecIndex, m_LineArray.size() - 1, -1);
 }
 
@@ -71,7 +103,7 @@
   if (place.nLineIndex >= pdfium::CollectionSize<int32_t>(m_LineArray))
     return GetEndWordPlace();
 
-  CLine* pLine = m_LineArray[place.nLineIndex].get();
+  Line* pLine = m_LineArray[place.nLineIndex].get();
   if (place.nWordIndex == pLine->m_LineInfo.nBeginWordIndex)
     return CPVT_WordPlace(place.nSecIndex, place.nLineIndex, -1);
 
@@ -91,7 +123,7 @@
   if (place.nLineIndex >= pdfium::CollectionSize<int32_t>(m_LineArray))
     return GetEndWordPlace();
 
-  CLine* pLine = m_LineArray[place.nLineIndex].get();
+  Line* pLine = m_LineArray[place.nLineIndex].get();
   if (place.nWordIndex < pLine->m_LineInfo.nEndWordIndex)
     return pLine->GetNextWordPlace(place);
 
@@ -106,7 +138,7 @@
   int32_t nRight = pdfium::CollectionSize<int32_t>(m_LineArray) - 1;
   int32_t nMid = (nLeft + nRight) / 2;
   while (nLeft <= nRight) {
-    CLine* pLine = m_LineArray[nMid].get();
+    Line* pLine = m_LineArray[nMid].get();
     if (place.nWordIndex < pLine->m_LineInfo.nBeginWordIndex) {
       nRight = nMid - 1;
       nMid = (nLeft + nRight) / 2;
@@ -128,7 +160,7 @@
   int32_t nRight = pdfium::CollectionSize<int32_t>(m_LineArray) - 1;
   int32_t nMid = pdfium::CollectionSize<int32_t>(m_LineArray) / 2;
   while (nLeft <= nRight) {
-    CLine* pLine = m_LineArray[nMid].get();
+    Line* pLine = m_LineArray[nMid].get();
     float fTop = pLine->m_LineInfo.fLineY - pLine->m_LineInfo.fLineAscent -
                  m_pVT->GetLineLeading();
     float fBottom = pLine->m_LineInfo.fLineY - pLine->m_LineInfo.fLineDescent;
@@ -166,7 +198,7 @@
   if (!pdfium::IndexInBounds(m_LineArray, lineplace.nLineIndex))
     return GetBeginWordPlace();
 
-  CLine* pLine = m_LineArray[lineplace.nLineIndex].get();
+  Line* pLine = m_LineArray[lineplace.nLineIndex].get();
   return SearchWordPlace(
       fx - m_Rect.left,
       CPVT_WordRange(pLine->GetNextWordPlace(pLine->GetBeginWordPlace()),
diff --git a/core/fpdfdoc/csection.h b/core/fpdfdoc/csection.h
index 7a307cc..16a5bc9 100644
--- a/core/fpdfdoc/csection.h
+++ b/core/fpdfdoc/csection.h
@@ -10,7 +10,7 @@
 #include <memory>
 #include <vector>
 
-#include "core/fpdfdoc/cline.h"
+#include "core/fpdfdoc/cpvt_lineinfo.h"
 #include "core/fpdfdoc/cpvt_wordinfo.h"
 #include "core/fpdfdoc/cpvt_wordrange.h"
 #include "core/fpdfdoc/ctypeset.h"
@@ -25,6 +25,19 @@
 
 class CSection final {
  public:
+  class Line {
+   public:
+    explicit Line(const CPVT_LineInfo& lineinfo);
+    ~Line();
+
+    CPVT_WordPlace GetBeginWordPlace() const;
+    CPVT_WordPlace GetEndWordPlace() const;
+    CPVT_WordPlace GetPrevWordPlace(const CPVT_WordPlace& place) const;
+    CPVT_WordPlace GetNextWordPlace(const CPVT_WordPlace& place) const;
+    CPVT_WordPlace LinePlace;
+    CPVT_LineInfo m_LineInfo;
+  };
+
   explicit CSection(CPDF_VariableText* pVT);
   ~CSection();
 
@@ -48,7 +61,7 @@
 
   CPVT_WordPlace SecPlace;
   CPVT_FloatRect m_Rect;
-  std::vector<std::unique_ptr<CLine>> m_LineArray;
+  std::vector<std::unique_ptr<Line>> m_LineArray;
   std::vector<std::unique_ptr<CPVT_WordInfo>> m_WordArray;
 
  private:
diff --git a/core/fpdfdoc/ctypeset.cpp b/core/fpdfdoc/ctypeset.cpp
index ea5c9e0..b5c9663 100644
--- a/core/fpdfdoc/ctypeset.cpp
+++ b/core/fpdfdoc/ctypeset.cpp
@@ -8,7 +8,6 @@
 
 #include <algorithm>
 
-#include "core/fpdfdoc/cline.h"
 #include "core/fpdfdoc/cpdf_variabletext.h"
 #include "core/fpdfdoc/cpvt_wordinfo.h"
 #include "core/fpdfdoc/csection.h"
@@ -193,7 +192,7 @@
   float x = 0.0f;
   float y = m_pVT->GetLineLeading() + fLineAscent;
   int32_t nStart = 0;
-  CLine* pLine = m_pSection->m_LineArray.front().get();
+  CSection::Line* pLine = m_pSection->m_LineArray.front().get();
   switch (m_pVT->GetAlignment()) {
     case 0:
       pLine->m_LineInfo.fLineX = fNodeWidth * VARIABLETEXT_HALF;
@@ -454,7 +453,7 @@
     float fPosX = 0.0f;
     float fPosY = 0.0f;
     for (int32_t l = 0; l < nTotalLines; l++) {
-      CLine* pLine = m_pSection->m_LineArray[l].get();
+      CSection::Line* pLine = m_pSection->m_LineArray[l].get();
       switch (m_pVT->GetAlignment()) {
         default:
         case 0: