Use iosfwd in more headers.

Forward declaring shaves compilation costs down 1%.

Change-Id: Iea0c1d73db25327ebd4de8e895f912181774a670
Reviewed-on: https://pdfium-review.googlesource.com/c/pdfium/+/79991
Reviewed-by: Tom Sepez <tsepez@chromium.org>
Commit-Queue: Lei Zhang <thestig@chromium.org>
diff --git a/core/fpdfapi/edit/cpdf_contentstream_write_utils.cpp b/core/fpdfapi/edit/cpdf_contentstream_write_utils.cpp
index 28165b1..612303d 100644
--- a/core/fpdfapi/edit/cpdf_contentstream_write_utils.cpp
+++ b/core/fpdfapi/edit/cpdf_contentstream_write_utils.cpp
@@ -4,6 +4,8 @@
 
 #include "core/fpdfapi/edit/cpdf_contentstream_write_utils.h"
 
+#include <ostream>
+
 #include "third_party/skia_shared/SkFloatToDecimal.h"
 
 std::ostream& WriteFloat(std::ostream& stream, float value) {
diff --git a/core/fpdfapi/edit/cpdf_contentstream_write_utils.h b/core/fpdfapi/edit/cpdf_contentstream_write_utils.h
index 3e14c9f..c94e99e 100644
--- a/core/fpdfapi/edit/cpdf_contentstream_write_utils.h
+++ b/core/fpdfapi/edit/cpdf_contentstream_write_utils.h
@@ -5,7 +5,7 @@
 #ifndef CORE_FPDFAPI_EDIT_CPDF_CONTENTSTREAM_WRITE_UTILS_H_
 #define CORE_FPDFAPI_EDIT_CPDF_CONTENTSTREAM_WRITE_UTILS_H_
 
-#include <ostream>
+#include <iosfwd>
 
 #include "core/fxcrt/fx_coordinates.h"
 
diff --git a/core/fpdfapi/edit/cpdf_stringarchivestream.cpp b/core/fpdfapi/edit/cpdf_stringarchivestream.cpp
index 492fb2a..9cb1336 100644
--- a/core/fpdfapi/edit/cpdf_stringarchivestream.cpp
+++ b/core/fpdfapi/edit/cpdf_stringarchivestream.cpp
@@ -4,6 +4,8 @@
 
 #include "core/fpdfapi/edit/cpdf_stringarchivestream.h"
 
+#include <sstream>
+
 #include "third_party/base/notreached.h"
 
 CPDF_StringArchiveStream::CPDF_StringArchiveStream(std::ostringstream* stream)
diff --git a/core/fpdfapi/parser/fpdf_parser_utility.cpp b/core/fpdfapi/parser/fpdf_parser_utility.cpp
index f621911..e47eccf 100644
--- a/core/fpdfapi/parser/fpdf_parser_utility.cpp
+++ b/core/fpdfapi/parser/fpdf_parser_utility.cpp
@@ -6,6 +6,8 @@
 
 #include "core/fpdfapi/parser/fpdf_parser_utility.h"
 
+#include <ostream>
+
 #include "core/fpdfapi/parser/cpdf_array.h"
 #include "core/fpdfapi/parser/cpdf_boolean.h"
 #include "core/fpdfapi/parser/cpdf_dictionary.h"
diff --git a/core/fpdfapi/parser/fpdf_parser_utility.h b/core/fpdfapi/parser/fpdf_parser_utility.h
index 75f4076..41f0fd8 100644
--- a/core/fpdfapi/parser/fpdf_parser_utility.h
+++ b/core/fpdfapi/parser/fpdf_parser_utility.h
@@ -7,7 +7,7 @@
 #ifndef CORE_FPDFAPI_PARSER_FPDF_PARSER_UTILITY_H_
 #define CORE_FPDFAPI_PARSER_FPDF_PARSER_UTILITY_H_
 
-#include <ostream>
+#include <iosfwd>
 #include <vector>
 
 #include "core/fxcrt/fx_string.h"
diff --git a/core/fxcrt/bytestring.cpp b/core/fxcrt/bytestring.cpp
index 3f81852..0defe22 100644
--- a/core/fxcrt/bytestring.cpp
+++ b/core/fxcrt/bytestring.cpp
@@ -10,6 +10,7 @@
 
 #include <algorithm>
 #include <cctype>
+#include <sstream>
 #include <string>
 #include <utility>
 
diff --git a/core/fxcrt/bytestring.h b/core/fxcrt/bytestring.h
index cbb49ac..cba9a0f 100644
--- a/core/fxcrt/bytestring.h
+++ b/core/fxcrt/bytestring.h
@@ -8,9 +8,8 @@
 #define CORE_FXCRT_BYTESTRING_H_
 
 #include <functional>
+#include <iosfwd>
 #include <iterator>
-#include <ostream>
-#include <sstream>
 #include <utility>
 
 #include "core/fxcrt/fx_system.h"
diff --git a/core/fxcrt/fx_coordinates.cpp b/core/fxcrt/fx_coordinates.cpp
index 1395df0..ac49903 100644
--- a/core/fxcrt/fx_coordinates.cpp
+++ b/core/fxcrt/fx_coordinates.cpp
@@ -13,6 +13,10 @@
 #include "core/fxcrt/fx_safe_types.h"
 #include "third_party/base/stl_util.h"
 
+#ifndef NDEBUG
+#include <ostream>
+#endif
+
 namespace {
 
 void MatchFloatRange(float f1, float f2, int* i1, int* i2) {
diff --git a/core/fxcrt/fx_coordinates.h b/core/fxcrt/fx_coordinates.h
index 9bb029f..e96bf10 100644
--- a/core/fxcrt/fx_coordinates.h
+++ b/core/fxcrt/fx_coordinates.h
@@ -12,7 +12,7 @@
 #include "core/fxcrt/fx_system.h"
 
 #ifndef NDEBUG
-#include <ostream>
+#include <iosfwd>
 #endif
 
 template <class BaseType>
diff --git a/core/fxcrt/string_view_template.h b/core/fxcrt/string_view_template.h
index d8b15f2..10ee7f4 100644
--- a/core/fxcrt/string_view_template.h
+++ b/core/fxcrt/string_view_template.h
@@ -8,6 +8,7 @@
 #define CORE_FXCRT_STRING_VIEW_TEMPLATE_H_
 
 #include <algorithm>
+#include <cctype>
 #include <iterator>
 #include <type_traits>
 #include <vector>
diff --git a/core/fxcrt/widestring.h b/core/fxcrt/widestring.h
index e1d0f49..ad24799 100644
--- a/core/fxcrt/widestring.h
+++ b/core/fxcrt/widestring.h
@@ -8,8 +8,8 @@
 #define CORE_FXCRT_WIDESTRING_H_
 
 #include <functional>
+#include <iosfwd>
 #include <iterator>
-#include <ostream>
 #include <utility>
 
 #include "core/fxcrt/fx_system.h"
diff --git a/fxjs/xfa/cfxjse_formcalc_context.cpp b/fxjs/xfa/cfxjse_formcalc_context.cpp
index 3342bb9..7ac6619 100644
--- a/fxjs/xfa/cfxjse_formcalc_context.cpp
+++ b/fxjs/xfa/cfxjse_formcalc_context.cpp
@@ -10,6 +10,7 @@
 
 #include <algorithm>
 #include <cctype>
+#include <sstream>
 #include <utility>
 
 #include "core/fxcrt/cfx_datetime.h"
diff --git a/testing/fx_string_testhelpers.cpp b/testing/fx_string_testhelpers.cpp
index 23a8e98..51983de 100644
--- a/testing/fx_string_testhelpers.cpp
+++ b/testing/fx_string_testhelpers.cpp
@@ -6,6 +6,7 @@
 
 #include <iomanip>
 #include <ios>
+#include <ostream>
 
 #include "core/fxcrt/cfx_datetime.h"
 #include "core/fxcrt/fx_string.h"
diff --git a/testing/fx_string_testhelpers.h b/testing/fx_string_testhelpers.h
index adfa7bd..78594e4 100644
--- a/testing/fx_string_testhelpers.h
+++ b/testing/fx_string_testhelpers.h
@@ -5,8 +5,8 @@
 #ifndef TESTING_FX_STRING_TESTHELPERS_H_
 #define TESTING_FX_STRING_TESTHELPERS_H_
 
+#include <iosfwd>
 #include <memory>
-#include <ostream>
 #include <string>
 #include <vector>