Stop including stl_util.h in headers.

- Move the include in observed_ptr.h to observed_ptr.cpp.
- Remove an unneeded include in string_view_template.h.
- Then do IWYU to fix the build.

Change-Id: Ie54cb4231c869f364be7dabc62215133bed37f5f
Reviewed-on: https://pdfium-review.googlesource.com/c/pdfium/+/69070
Commit-Queue: Lei Zhang <thestig@chromium.org>
Reviewed-by: Tom Sepez <tsepez@chromium.org>
diff --git a/core/fxcrt/observed_ptr.cpp b/core/fxcrt/observed_ptr.cpp
index f192e69..dae2244 100644
--- a/core/fxcrt/observed_ptr.cpp
+++ b/core/fxcrt/observed_ptr.cpp
@@ -4,6 +4,8 @@
 
 #include "core/fxcrt/observed_ptr.h"
 
+#include "third_party/base/stl_util.h"
+
 namespace fxcrt {
 
 Observable::Observable() = default;
@@ -12,4 +14,20 @@
   NotifyObservers();
 }
 
+void Observable::AddObserver(ObserverIface* pObserver) {
+  ASSERT(!pdfium::ContainsKey(m_Observers, pObserver));
+  m_Observers.insert(pObserver);
+}
+
+void Observable::RemoveObserver(ObserverIface* pObserver) {
+  ASSERT(pdfium::ContainsKey(m_Observers, pObserver));
+  m_Observers.erase(pObserver);
+}
+
+void Observable::NotifyObservers() {
+  for (auto* pObserver : m_Observers)
+    pObserver->OnObservableDestroyed();
+  m_Observers.clear();
+}
+
 }  // namespace fxcrt
diff --git a/core/fxcrt/observed_ptr.h b/core/fxcrt/observed_ptr.h
index 9568705..ce5995f 100644
--- a/core/fxcrt/observed_ptr.h
+++ b/core/fxcrt/observed_ptr.h
@@ -8,7 +8,6 @@
 #include <set>
 
 #include "core/fxcrt/fx_system.h"
-#include "third_party/base/stl_util.h"
 
 namespace fxcrt {
 
@@ -23,21 +22,12 @@
 
   Observable();
   Observable(const Observable& that) = delete;
-  ~Observable();
-  void AddObserver(ObserverIface* pObserver) {
-    ASSERT(!pdfium::ContainsKey(m_Observers, pObserver));
-    m_Observers.insert(pObserver);
-  }
-  void RemoveObserver(ObserverIface* pObserver) {
-    ASSERT(pdfium::ContainsKey(m_Observers, pObserver));
-    m_Observers.erase(pObserver);
-  }
-  void NotifyObservers() {
-    for (auto* pObserver : m_Observers)
-      pObserver->OnObservableDestroyed();
-    m_Observers.clear();
-  }
   Observable& operator=(const Observable& that) = delete;
+  ~Observable();
+
+  void AddObserver(ObserverIface* pObserver);
+  void RemoveObserver(ObserverIface* pObserver);
+  void NotifyObservers();
 
  protected:
   size_t ActiveObserversForTesting() const { return m_Observers.size(); }
diff --git a/core/fxcrt/string_view_template.h b/core/fxcrt/string_view_template.h
index e50a71d..d8b15f2 100644
--- a/core/fxcrt/string_view_template.h
+++ b/core/fxcrt/string_view_template.h
@@ -15,7 +15,6 @@
 #include "core/fxcrt/fx_system.h"
 #include "third_party/base/optional.h"
 #include "third_party/base/span.h"
-#include "third_party/base/stl_util.h"
 
 namespace fxcrt {
 
diff --git a/fpdfsdk/cpdfsdk_annotiterator.cpp b/fpdfsdk/cpdfsdk_annotiterator.cpp
index 1e0867a..36a13bb 100644
--- a/fpdfsdk/cpdfsdk_annotiterator.cpp
+++ b/fpdfsdk/cpdfsdk_annotiterator.cpp
@@ -12,6 +12,7 @@
 #include "core/fpdfapi/parser/cpdf_dictionary.h"
 #include "fpdfsdk/cpdfsdk_annot.h"
 #include "fpdfsdk/cpdfsdk_pageview.h"
+#include "third_party/base/stl_util.h"
 
 namespace {
 
diff --git a/fpdfsdk/cpdfsdk_baannothandler.cpp b/fpdfsdk/cpdfsdk_baannothandler.cpp
index ea50f58..10bde5c 100644
--- a/fpdfsdk/cpdfsdk_baannothandler.cpp
+++ b/fpdfsdk/cpdfsdk_baannothandler.cpp
@@ -17,6 +17,7 @@
 #include "fpdfsdk/cpdfsdk_formfillenvironment.h"
 #include "fpdfsdk/cpdfsdk_pageview.h"
 #include "fpdfsdk/formfiller/cffl_formfiller.h"
+#include "third_party/base/stl_util.h"
 
 namespace {
 
diff --git a/fpdfsdk/fpdf_edittext.cpp b/fpdfsdk/fpdf_edittext.cpp
index 04a5421..3dc4334 100644
--- a/fpdfsdk/fpdf_edittext.cpp
+++ b/fpdfsdk/fpdf_edittext.cpp
@@ -29,6 +29,7 @@
 #include "fpdfsdk/cpdfsdk_helpers.h"
 #include "public/fpdf_edit.h"
 #include "third_party/base/ptr_util.h"
+#include "third_party/base/stl_util.h"
 
 // These checks are here because core/ and public/ cannot depend on each other.
 static_assert(static_cast<int>(TextRenderingMode::MODE_UNKNOWN) ==
diff --git a/fpdfsdk/fpdf_transformpage.cpp b/fpdfsdk/fpdf_transformpage.cpp
index 53de22b..0afd461 100644
--- a/fpdfsdk/fpdf_transformpage.cpp
+++ b/fpdfsdk/fpdf_transformpage.cpp
@@ -27,6 +27,7 @@
 #include "fpdfsdk/cpdfsdk_helpers.h"
 #include "third_party/base/ptr_util.h"
 #include "third_party/base/span.h"
+#include "third_party/base/stl_util.h"
 
 namespace {
 
diff --git a/fxjs/cfx_v8_unittest.cpp b/fxjs/cfx_v8_unittest.cpp
index 7b9ecb5..762ecd7 100644
--- a/fxjs/cfx_v8_unittest.cpp
+++ b/fxjs/cfx_v8_unittest.cpp
@@ -4,6 +4,7 @@
 
 #include "fxjs/cfx_v8_unittest.h"
 
+#include <cmath>
 #include <memory>
 
 #include "fxjs/cfx_v8.h"
diff --git a/xfa/fgas/layout/cfx_char.cpp b/xfa/fgas/layout/cfx_char.cpp
index 13f1cc9..cd258f9 100644
--- a/xfa/fgas/layout/cfx_char.cpp
+++ b/xfa/fgas/layout/cfx_char.cpp
@@ -10,6 +10,7 @@
 
 #include "core/fxcrt/fx_extension.h"
 #include "core/fxcrt/fx_memory.h"
+#include "third_party/base/stl_util.h"
 
 namespace {