Move CFX_UTF8Decoder out of fx_basic

This CL moves CFX_UTF8Decoder out of fx_basic and includes where needed.

Change-Id: I1a093a8a77bbefcc90fbb2f81b1da65bfc0512bf
Reviewed-on: https://pdfium-review.googlesource.com/12411
Reviewed-by: Tom Sepez <tsepez@chromium.org>
Commit-Queue: dsinclair <dsinclair@chromium.org>
diff --git a/BUILD.gn b/BUILD.gn
index 0f8ddcd..51480ed 100644
--- a/BUILD.gn
+++ b/BUILD.gn
@@ -820,6 +820,8 @@
     "core/fxcrt/cfx_string_data_template.h",
     "core/fxcrt/cfx_string_pool_template.h",
     "core/fxcrt/cfx_unowned_ptr.h",
+    "core/fxcrt/cfx_utf8decoder.cpp",
+    "core/fxcrt/cfx_utf8decoder.h",
     "core/fxcrt/cfx_weak_ptr.h",
     "core/fxcrt/cfx_widestring.cpp",
     "core/fxcrt/cfx_widestring.h",
diff --git a/core/fxcrt/cfx_bytestring.cpp b/core/fxcrt/cfx_bytestring.cpp
index 13b6673..7a73827 100644
--- a/core/fxcrt/cfx_bytestring.cpp
+++ b/core/fxcrt/cfx_bytestring.cpp
@@ -13,6 +13,7 @@
 #include <string>
 
 #include "core/fxcrt/cfx_string_pool_template.h"
+#include "core/fxcrt/cfx_utf8decoder.h"
 #include "core/fxcrt/fx_codepage.h"
 #include "core/fxcrt/fx_extension.h"
 #include "core/fxcrt/fx_safe_types.h"
diff --git a/core/fxcrt/cfx_utf8decoder.cpp b/core/fxcrt/cfx_utf8decoder.cpp
new file mode 100644
index 0000000..bee5e16
--- /dev/null
+++ b/core/fxcrt/cfx_utf8decoder.cpp
@@ -0,0 +1,47 @@
+// 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 "core/fxcrt/cfx_utf8decoder.h"
+
+void CFX_UTF8Decoder::Clear() {
+  m_Buffer.Clear();
+  m_PendingBytes = 0;
+}
+
+void CFX_UTF8Decoder::AppendCodePoint(uint32_t ch) {
+  m_Buffer.AppendChar(static_cast<wchar_t>(ch));
+}
+
+void CFX_UTF8Decoder::Input(uint8_t byte) {
+  if (byte < 0x80) {
+    m_PendingBytes = 0;
+    m_Buffer.AppendChar(byte);
+  } else if (byte < 0xc0) {
+    if (m_PendingBytes == 0) {
+      return;
+    }
+    m_PendingBytes--;
+    m_PendingChar |= (byte & 0x3f) << (m_PendingBytes * 6);
+    if (m_PendingBytes == 0) {
+      AppendCodePoint(m_PendingChar);
+    }
+  } else if (byte < 0xe0) {
+    m_PendingBytes = 1;
+    m_PendingChar = (byte & 0x1f) << 6;
+  } else if (byte < 0xf0) {
+    m_PendingBytes = 2;
+    m_PendingChar = (byte & 0x0f) << 12;
+  } else if (byte < 0xf8) {
+    m_PendingBytes = 3;
+    m_PendingChar = (byte & 0x07) << 18;
+  } else if (byte < 0xfc) {
+    m_PendingBytes = 4;
+    m_PendingChar = (byte & 0x03) << 24;
+  } else if (byte < 0xfe) {
+    m_PendingBytes = 5;
+    m_PendingChar = (byte & 0x01) << 30;
+  }
+}
diff --git a/core/fxcrt/cfx_utf8decoder.h b/core/fxcrt/cfx_utf8decoder.h
new file mode 100644
index 0000000..50c2a39
--- /dev/null
+++ b/core/fxcrt/cfx_utf8decoder.h
@@ -0,0 +1,28 @@
+// 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_UTF8DECODER_H_
+#define CORE_FXCRT_CFX_UTF8DECODER_H_
+
+#include "core/fxcrt/fx_basic.h"
+
+class CFX_UTF8Decoder {
+ public:
+  CFX_UTF8Decoder() { m_PendingBytes = 0; }
+
+  void Clear();
+  void Input(uint8_t byte);
+  void AppendCodePoint(uint32_t ch);
+  void ClearStatus() { m_PendingBytes = 0; }
+  CFX_WideStringC GetResult() const { return m_Buffer.AsStringC(); }
+
+ private:
+  int m_PendingBytes;
+  uint32_t m_PendingChar;
+  CFX_WideTextBuf m_Buffer;
+};
+
+#endif  // CORE_FXCRT_CFX_UTF8DECODER_H_
diff --git a/core/fxcrt/cfx_widestring.cpp b/core/fxcrt/cfx_widestring.cpp
index 6e4e82d..05a4fc3 100644
--- a/core/fxcrt/cfx_widestring.cpp
+++ b/core/fxcrt/cfx_widestring.cpp
@@ -13,6 +13,7 @@
 #include <cwctype>
 
 #include "core/fxcrt/cfx_string_pool_template.h"
+#include "core/fxcrt/cfx_utf8decoder.h"
 #include "core/fxcrt/fx_codepage.h"
 #include "core/fxcrt/fx_extension.h"
 #include "core/fxcrt/fx_safe_types.h"
diff --git a/core/fxcrt/fx_basic.h b/core/fxcrt/fx_basic.h
index dcbb846..6f67669 100644
--- a/core/fxcrt/fx_basic.h
+++ b/core/fxcrt/fx_basic.h
@@ -87,22 +87,6 @@
   CFX_WideTextBuf& operator<<(const CFX_WideTextBuf& buf);
 };
 
-class CFX_UTF8Decoder {
- public:
-  CFX_UTF8Decoder() { m_PendingBytes = 0; }
-
-  void Clear();
-  void Input(uint8_t byte);
-  void AppendCodePoint(uint32_t ch);
-  void ClearStatus() { m_PendingBytes = 0; }
-  CFX_WideStringC GetResult() const { return m_Buffer.AsStringC(); }
-
- private:
-  int m_PendingBytes;
-  uint32_t m_PendingChar;
-  CFX_WideTextBuf m_Buffer;
-};
-
 template <class DataType, int FixedSize>
 class CFX_FixedBufGrow {
  public:
diff --git a/core/fxcrt/fx_basic_utf.cpp b/core/fxcrt/fx_basic_utf.cpp
index 1bcae61..8a5587d 100644
--- a/core/fxcrt/fx_basic_utf.cpp
+++ b/core/fxcrt/fx_basic_utf.cpp
@@ -59,46 +59,6 @@
 
 }  // namespace
 
-void CFX_UTF8Decoder::Clear() {
-  m_Buffer.Clear();
-  m_PendingBytes = 0;
-}
-
-void CFX_UTF8Decoder::AppendCodePoint(uint32_t ch) {
-  m_Buffer.AppendChar(static_cast<wchar_t>(ch));
-}
-
-void CFX_UTF8Decoder::Input(uint8_t byte) {
-  if (byte < 0x80) {
-    m_PendingBytes = 0;
-    m_Buffer.AppendChar(byte);
-  } else if (byte < 0xc0) {
-    if (m_PendingBytes == 0) {
-      return;
-    }
-    m_PendingBytes--;
-    m_PendingChar |= (byte & 0x3f) << (m_PendingBytes * 6);
-    if (m_PendingBytes == 0) {
-      AppendCodePoint(m_PendingChar);
-    }
-  } else if (byte < 0xe0) {
-    m_PendingBytes = 1;
-    m_PendingChar = (byte & 0x1f) << 6;
-  } else if (byte < 0xf0) {
-    m_PendingBytes = 2;
-    m_PendingChar = (byte & 0x0f) << 12;
-  } else if (byte < 0xf8) {
-    m_PendingBytes = 3;
-    m_PendingChar = (byte & 0x07) << 18;
-  } else if (byte < 0xfc) {
-    m_PendingBytes = 4;
-    m_PendingChar = (byte & 0x03) << 24;
-  } else if (byte < 0xfe) {
-    m_PendingBytes = 5;
-    m_PendingChar = (byte & 0x01) << 30;
-  }
-}
-
 CFX_ByteString FX_UTF8Encode(const CFX_WideStringC& wsStr) {
   FX_STRSIZE len = wsStr.GetLength();
   const wchar_t* pStr = wsStr.unterminated_c_str();
diff --git a/core/fxcrt/xml/cxml_parser.cpp b/core/fxcrt/xml/cxml_parser.cpp
index 18103df..5e3fca7 100644
--- a/core/fxcrt/xml/cxml_parser.cpp
+++ b/core/fxcrt/xml/cxml_parser.cpp
@@ -11,6 +11,7 @@
 #include <utility>
 #include <vector>
 
+#include "core/fxcrt/cfx_utf8decoder.h"
 #include "core/fxcrt/fx_extension.h"
 #include "core/fxcrt/xml/cxml_content.h"
 #include "core/fxcrt/xml/cxml_element.h"