Move CFX_WideTextBuf out of fx_basic

This CL moves CFX_WideTextBuf to its own files and updates includes as
needed.

Change-Id: Ibe66ecf3e66f8f01dd8e9eaf6b467588be86ad4f
Reviewed-on: https://pdfium-review.googlesource.com/12413
Reviewed-by: Tom Sepez <tsepez@chromium.org>
Commit-Queue: dsinclair <dsinclair@chromium.org>
diff --git a/BUILD.gn b/BUILD.gn
index cbf6fa0..b20d3a1 100644
--- a/BUILD.gn
+++ b/BUILD.gn
@@ -827,8 +827,9 @@
     "core/fxcrt/cfx_weak_ptr.h",
     "core/fxcrt/cfx_widestring.cpp",
     "core/fxcrt/cfx_widestring.h",
+    "core/fxcrt/cfx_widetextbuf.cpp",
+    "core/fxcrt/cfx_widetextbuf.h",
     "core/fxcrt/fx_basic.h",
-    "core/fxcrt/fx_basic_buffer.cpp",
     "core/fxcrt/fx_basic_gcc.cpp",
     "core/fxcrt/fx_basic_utf.cpp",
     "core/fxcrt/fx_basic_util.cpp",
diff --git a/core/fpdfapi/font/cpdf_tounicodemap.h b/core/fpdfapi/font/cpdf_tounicodemap.h
index 83db6e3..90a2638 100644
--- a/core/fpdfapi/font/cpdf_tounicodemap.h
+++ b/core/fpdfapi/font/cpdf_tounicodemap.h
@@ -11,7 +11,7 @@
 
 #include "core/fpdfapi/parser/cpdf_stream.h"
 #include "core/fxcrt/cfx_unowned_ptr.h"
-#include "core/fxcrt/fx_basic.h"
+#include "core/fxcrt/cfx_widetextbuf.h"
 
 class CPDF_CID2UnicodeMap;
 
diff --git a/core/fpdftext/cpdf_textpage.h b/core/fpdftext/cpdf_textpage.h
index 0f507de..6a4c873 100644
--- a/core/fpdftext/cpdf_textpage.h
+++ b/core/fpdftext/cpdf_textpage.h
@@ -12,7 +12,7 @@
 
 #include "core/fpdfapi/page/cpdf_pageobjectlist.h"
 #include "core/fxcrt/cfx_unowned_ptr.h"
-#include "core/fxcrt/fx_basic.h"
+#include "core/fxcrt/cfx_widetextbuf.h"
 #include "core/fxcrt/fx_coordinates.h"
 #include "core/fxcrt/fx_string.h"
 
diff --git a/core/fxcrt/cfx_utf8decoder.h b/core/fxcrt/cfx_utf8decoder.h
index 50c2a39..dcf5ef7 100644
--- a/core/fxcrt/cfx_utf8decoder.h
+++ b/core/fxcrt/cfx_utf8decoder.h
@@ -7,7 +7,7 @@
 #ifndef CORE_FXCRT_CFX_UTF8DECODER_H_
 #define CORE_FXCRT_CFX_UTF8DECODER_H_
 
-#include "core/fxcrt/fx_basic.h"
+#include "core/fxcrt/cfx_widetextbuf.h"
 
 class CFX_UTF8Decoder {
  public:
diff --git a/core/fxcrt/fx_basic_buffer.cpp b/core/fxcrt/cfx_widetextbuf.cpp
similarity index 86%
rename from core/fxcrt/fx_basic_buffer.cpp
rename to core/fxcrt/cfx_widetextbuf.cpp
index e282aa4..246124b 100644
--- a/core/fxcrt/fx_basic_buffer.cpp
+++ b/core/fxcrt/cfx_widetextbuf.cpp
@@ -1,17 +1,10 @@
-// Copyright 2014 PDFium Authors. All rights reserved.
+// Copyright 2017 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 <algorithm>
-#include <limits>
-#include <memory>
-#include <utility>
-
-#include "core/fxcrt/fx_basic.h"
-#include "core/fxcrt/fx_safe_types.h"
-#include "third_party/base/numerics/safe_conversions.h"
+#include "core/fxcrt/cfx_widetextbuf.h"
 
 void CFX_WideTextBuf::AppendChar(wchar_t ch) {
   ExpandBuf(sizeof(wchar_t));
diff --git a/core/fxcrt/cfx_widetextbuf.h b/core/fxcrt/cfx_widetextbuf.h
new file mode 100644
index 0000000..0c9b6ff
--- /dev/null
+++ b/core/fxcrt/cfx_widetextbuf.h
@@ -0,0 +1,44 @@
+// Copyright 2017 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_FXCRT_CFX_WIDETEXTBUF_H_
+#define CORE_FXCRT_CFX_WIDETEXTBUF_H_
+
+#include "core/fxcrt/cfx_binarybuf.h"
+#include "core/fxcrt/fx_string.h"
+#include "core/fxcrt/fx_system.h"
+
+class CFX_WideTextBuf : public CFX_BinaryBuf {
+ public:
+  void AppendChar(wchar_t wch);
+  FX_STRSIZE GetLength() const { return m_DataSize / sizeof(wchar_t); }
+  wchar_t* GetBuffer() const {
+    return reinterpret_cast<wchar_t*>(m_pBuffer.get());
+  }
+
+  CFX_WideStringC AsStringC() const {
+    return CFX_WideStringC(reinterpret_cast<const wchar_t*>(m_pBuffer.get()),
+                           m_DataSize / sizeof(wchar_t));
+  }
+  CFX_WideString MakeString() const {
+    return CFX_WideString(reinterpret_cast<const wchar_t*>(m_pBuffer.get()),
+                          m_DataSize / sizeof(wchar_t));
+  }
+
+  void Delete(int start_index, int count) {
+    CFX_BinaryBuf::Delete(start_index * sizeof(wchar_t),
+                          count * sizeof(wchar_t));
+  }
+
+  CFX_WideTextBuf& operator<<(int i);
+  CFX_WideTextBuf& operator<<(double f);
+  CFX_WideTextBuf& operator<<(const wchar_t* lpsz);
+  CFX_WideTextBuf& operator<<(const CFX_WideStringC& str);
+  CFX_WideTextBuf& operator<<(const CFX_WideString& str);
+  CFX_WideTextBuf& operator<<(const CFX_WideTextBuf& buf);
+};
+
+#endif  // CORE_FXCRT_CFX_WIDETEXTBUF_H_
diff --git a/core/fxcrt/fx_basic.h b/core/fxcrt/fx_basic.h
index 6052cc8..f3eb03f 100644
--- a/core/fxcrt/fx_basic.h
+++ b/core/fxcrt/fx_basic.h
@@ -22,36 +22,6 @@
 #define FX_IsOdd(a) ((a)&1)
 #endif  // PDF_ENABLE_XFA
 
-class CFX_WideTextBuf : public CFX_BinaryBuf {
- public:
-  void AppendChar(wchar_t wch);
-  FX_STRSIZE GetLength() const { return m_DataSize / sizeof(wchar_t); }
-  wchar_t* GetBuffer() const {
-    return reinterpret_cast<wchar_t*>(m_pBuffer.get());
-  }
-
-  CFX_WideStringC AsStringC() const {
-    return CFX_WideStringC(reinterpret_cast<const wchar_t*>(m_pBuffer.get()),
-                           m_DataSize / sizeof(wchar_t));
-  }
-  CFX_WideString MakeString() const {
-    return CFX_WideString(reinterpret_cast<const wchar_t*>(m_pBuffer.get()),
-                          m_DataSize / sizeof(wchar_t));
-  }
-
-  void Delete(int start_index, int count) {
-    CFX_BinaryBuf::Delete(start_index * sizeof(wchar_t),
-                          count * sizeof(wchar_t));
-  }
-
-  CFX_WideTextBuf& operator<<(int i);
-  CFX_WideTextBuf& operator<<(double f);
-  CFX_WideTextBuf& operator<<(const wchar_t* lpsz);
-  CFX_WideTextBuf& operator<<(const CFX_WideStringC& str);
-  CFX_WideTextBuf& operator<<(const CFX_WideString& str);
-  CFX_WideTextBuf& operator<<(const CFX_WideTextBuf& buf);
-};
-
 template <class DataType, int FixedSize>
 class CFX_FixedBufGrow {
  public:
diff --git a/core/fxcrt/xml/cfx_xmlelement.cpp b/core/fxcrt/xml/cfx_xmlelement.cpp
index eb60e68..e72b77c 100644
--- a/core/fxcrt/xml/cfx_xmlelement.cpp
+++ b/core/fxcrt/xml/cfx_xmlelement.cpp
@@ -6,6 +6,7 @@
 
 #include "core/fxcrt/xml/cfx_xmlelement.h"
 
+#include "core/fxcrt/cfx_widetextbuf.h"
 #include "core/fxcrt/fx_extension.h"
 #include "core/fxcrt/xml/cfx_xmlchardata.h"
 #include "core/fxcrt/xml/cfx_xmltext.h"
diff --git a/core/fxcrt/xml/cxml_parser.cpp b/core/fxcrt/xml/cxml_parser.cpp
index 5e3fca7..9679e2c 100644
--- a/core/fxcrt/xml/cxml_parser.cpp
+++ b/core/fxcrt/xml/cxml_parser.cpp
@@ -12,6 +12,7 @@
 #include <vector>
 
 #include "core/fxcrt/cfx_utf8decoder.h"
+#include "core/fxcrt/cfx_widetextbuf.h"
 #include "core/fxcrt/fx_extension.h"
 #include "core/fxcrt/xml/cxml_content.h"
 #include "core/fxcrt/xml/cxml_element.h"
diff --git a/testing/libfuzzer/pdf_fm2js_fuzzer.cc b/testing/libfuzzer/pdf_fm2js_fuzzer.cc
index 226fb40..de56106 100644
--- a/testing/libfuzzer/pdf_fm2js_fuzzer.cc
+++ b/testing/libfuzzer/pdf_fm2js_fuzzer.cc
@@ -5,7 +5,7 @@
 #include <cstddef>
 #include <cstdint>
 
-#include "core/fxcrt/fx_basic.h"
+#include "core/fxcrt/cfx_widetextbuf.h"
 #include "core/fxcrt/fx_safe_types.h"
 #include "core/fxcrt/fx_string.h"
 #include "xfa/fxfa/fm2js/cxfa_fm2jscontext.h"
diff --git a/xfa/fxfa/fm2js/cxfa_fm2jscontext.cpp b/xfa/fxfa/fm2js/cxfa_fm2jscontext.cpp
index 944dfea..73e6c22 100644
--- a/xfa/fxfa/fm2js/cxfa_fm2jscontext.cpp
+++ b/xfa/fxfa/fm2js/cxfa_fm2jscontext.cpp
@@ -12,6 +12,7 @@
 #include <string>
 
 #include "core/fxcrt/cfx_decimal.h"
+#include "core/fxcrt/cfx_widetextbuf.h"
 #include "core/fxcrt/fx_extension.h"
 #include "fxjs/cfxjse_arguments.h"
 #include "fxjs/cfxjse_class.h"
diff --git a/xfa/fxfa/fm2js/cxfa_fm2jscontext.h b/xfa/fxfa/fm2js/cxfa_fm2jscontext.h
index abc9548..37586d0 100644
--- a/xfa/fxfa/fm2js/cxfa_fm2jscontext.h
+++ b/xfa/fxfa/fm2js/cxfa_fm2jscontext.h
@@ -14,6 +14,7 @@
 #include "fxjs/cfxjse_context.h"
 #include "xfa/fxfa/parser/xfa_resolvenode_rs.h"
 
+class CFX_WideTextBuf;
 class CXFA_Document;
 
 class CXFA_FM2JSContext : public CFXJSE_HostObject {
diff --git a/xfa/fxfa/fm2js/cxfa_fmexpression.cpp b/xfa/fxfa/fm2js/cxfa_fmexpression.cpp
index e323a33..2faa191 100644
--- a/xfa/fxfa/fm2js/cxfa_fmexpression.cpp
+++ b/xfa/fxfa/fm2js/cxfa_fmexpression.cpp
@@ -8,7 +8,7 @@
 
 #include <utility>
 
-#include "core/fxcrt/fx_basic.h"
+#include "core/fxcrt/cfx_widetextbuf.h"
 
 namespace {
 
diff --git a/xfa/fxfa/fm2js/cxfa_fmexpression.h b/xfa/fxfa/fm2js/cxfa_fmexpression.h
index b2bbc43..47b2d9c 100644
--- a/xfa/fxfa/fm2js/cxfa_fmexpression.h
+++ b/xfa/fxfa/fm2js/cxfa_fmexpression.h
@@ -23,6 +23,8 @@
   XFA_FM_EXPTYPE_CONTINUE,
 };
 
+class CFX_WideTextBuf;
+
 class CXFA_FMExpression {
  public:
   explicit CXFA_FMExpression(uint32_t line);
diff --git a/xfa/fxfa/fm2js/cxfa_fmparser_unittest.cpp b/xfa/fxfa/fm2js/cxfa_fmparser_unittest.cpp
index 4a17067..a7e784e 100644
--- a/xfa/fxfa/fm2js/cxfa_fmparser_unittest.cpp
+++ b/xfa/fxfa/fm2js/cxfa_fmparser_unittest.cpp
@@ -6,6 +6,7 @@
 
 #include <vector>
 
+#include "core/fxcrt/cfx_widetextbuf.h"
 #include "testing/gtest/include/gtest/gtest.h"
 #include "testing/test_support.h"
 #include "third_party/base/ptr_util.h"
diff --git a/xfa/fxfa/fm2js/cxfa_fmsimpleexpression.cpp b/xfa/fxfa/fm2js/cxfa_fmsimpleexpression.cpp
index c30c44a..fc07609 100644
--- a/xfa/fxfa/fm2js/cxfa_fmsimpleexpression.cpp
+++ b/xfa/fxfa/fm2js/cxfa_fmsimpleexpression.cpp
@@ -9,6 +9,7 @@
 #include <algorithm>
 #include <utility>
 
+#include "core/fxcrt/cfx_widetextbuf.h"
 #include "core/fxcrt/fx_extension.h"
 #include "third_party/base/logging.h"
 
diff --git a/xfa/fxfa/fm2js/cxfa_fmsimpleexpression.h b/xfa/fxfa/fm2js/cxfa_fmsimpleexpression.h
index e473349..a9e9f90 100644
--- a/xfa/fxfa/fm2js/cxfa_fmsimpleexpression.h
+++ b/xfa/fxfa/fm2js/cxfa_fmsimpleexpression.h
@@ -10,7 +10,6 @@
 #include <memory>
 #include <vector>
 
-#include "core/fxcrt/fx_basic.h"
 #include "xfa/fxfa/fm2js/cxfa_fmlexer.h"
 
 #define RUNTIMEFUNCTIONRETURNVALUE L"pfm_ret"
@@ -44,6 +43,8 @@
   VARFILTER
 };
 
+class CFX_WideTextBuf;
+
 CFX_WideStringC XFA_FM_EXPTypeToString(
     XFA_FM_SimpleExpressionType simpleExpType);
 
diff --git a/xfa/fxfa/fm2js/cxfa_fmsimpleexpression_unittest.cpp b/xfa/fxfa/fm2js/cxfa_fmsimpleexpression_unittest.cpp
index 18a67f4..c465c96 100644
--- a/xfa/fxfa/fm2js/cxfa_fmsimpleexpression_unittest.cpp
+++ b/xfa/fxfa/fm2js/cxfa_fmsimpleexpression_unittest.cpp
@@ -7,6 +7,7 @@
 #include <memory>
 #include <utility>
 
+#include "core/fxcrt/cfx_widetextbuf.h"
 #include "core/fxcrt/fx_string.h"
 #include "testing/gtest/include/gtest/gtest.h"
 #include "testing/test_support.h"
diff --git a/xfa/fxfa/parser/cxfa_dataexporter.cpp b/xfa/fxfa/parser/cxfa_dataexporter.cpp
index 05586e1..0af9bd4 100644
--- a/xfa/fxfa/parser/cxfa_dataexporter.cpp
+++ b/xfa/fxfa/parser/cxfa_dataexporter.cpp
@@ -9,7 +9,7 @@
 #include <vector>
 
 #include "core/fxcrt/cfx_memorystream.h"
-#include "core/fxcrt/fx_basic.h"
+#include "core/fxcrt/cfx_widetextbuf.h"
 #include "core/fxcrt/fx_codepage.h"
 #include "core/fxcrt/xml/cfx_xmldoc.h"
 #include "core/fxcrt/xml/cfx_xmlelement.h"
diff --git a/xfa/fxfa/parser/cxfa_scriptcontext.cpp b/xfa/fxfa/parser/cxfa_scriptcontext.cpp
index 24b1e3c..e7c8629 100644
--- a/xfa/fxfa/parser/cxfa_scriptcontext.cpp
+++ b/xfa/fxfa/parser/cxfa_scriptcontext.cpp
@@ -9,6 +9,7 @@
 #include <utility>
 
 #include "core/fxcrt/cfx_autorestorer.h"
+#include "core/fxcrt/cfx_widetextbuf.h"
 #include "core/fxcrt/fx_extension.h"
 #include "fxjs/cfxjse_arguments.h"
 #include "fxjs/cfxjse_class.h"
diff --git a/xfa/fxfa/parser/cxfa_simple_parser.cpp b/xfa/fxfa/parser/cxfa_simple_parser.cpp
index ee2a244..dd72f40 100644
--- a/xfa/fxfa/parser/cxfa_simple_parser.cpp
+++ b/xfa/fxfa/parser/cxfa_simple_parser.cpp
@@ -11,6 +11,7 @@
 
 #include "core/fxcrt/cfx_checksumcontext.h"
 #include "core/fxcrt/cfx_seekablestreamproxy.h"
+#include "core/fxcrt/cfx_widetextbuf.h"
 #include "core/fxcrt/fx_codepage.h"
 #include "core/fxcrt/fx_extension.h"
 #include "core/fxcrt/xml/cfx_xmlchardata.h"