Disentangle pdfium::span<> from unowned_ptr<>.

We need only have the raw_ptr<> or T* variations now that the code
has been consolidated against base::raw_ptr<>. Hence, UnownedPtr can
once again be part of fxcrt, rather than its own component. Then
remove UNOWNED_PTR_IS_BASE_RAW_PTR which is now the same as
PDF_USE_PARTITION_ALLOC.

-- remove pre-existing unused include_dirs while at it.
-- use inline initialization and `= default` while at it.

Change-Id: Ib852cca35cd6de9294efda1c1baaf16e89aa330e
Reviewed-on: https://pdfium-review.googlesource.com/c/pdfium/+/112531
Reviewed-by: Lei Zhang <thestig@chromium.org>
Commit-Queue: Tom Sepez <tsepez@chromium.org>
diff --git a/core/fxcodec/BUILD.gn b/core/fxcodec/BUILD.gn
index 3040dae..deee958 100644
--- a/core/fxcodec/BUILD.gn
+++ b/core/fxcodec/BUILD.gn
@@ -73,8 +73,7 @@
     "../../:pdfium_strict_config",
     "../../:pdfium_noshorten_config",
   ]
-  include_dirs = []
-  public_deps = [ "../fxcrt:unowned_ptr" ]
+  public_deps = [ "../../third_party:pdfium_base" ]
   deps = [
     "../../third_party:lcms2",
     "../../third_party:libopenjpeg2",
@@ -83,7 +82,6 @@
     "../fxge",
     "//third_party:jpeg",
   ]
-
   if (pdf_enable_xfa) {
     sources += [
       "jpeg/jpeg_progressive_decoder.cpp",
diff --git a/core/fxcrt/BUILD.gn b/core/fxcrt/BUILD.gn
index e8b6aa8..9e80bc6 100644
--- a/core/fxcrt/BUILD.gn
+++ b/core/fxcrt/BUILD.gn
@@ -6,18 +6,6 @@
 import("../../pdfium.gni")
 import("../../testing/test.gni")
 
-source_set("unowned_ptr") {
-  sources = [ "unowned_ptr.h" ]
-  deps = [ "../../third_party:pdfium_compiler_specific" ]
-  configs += [ "../../:pdfium_strict_config" ]
-  if (pdf_use_partition_alloc) {
-    public_deps = [
-      "//base/allocator/partition_allocator/src/partition_alloc:partition_alloc_buildflags",
-      "//base/allocator/partition_allocator/src/partition_alloc:raw_ptr",
-    ]
-  }
-}
-
 source_set("fxcrt") {
   sources = [
     "autonuller.h",
@@ -94,6 +82,7 @@
     "string_pool_template.h",
     "string_view_template.h",
     "tree_node.h",
+    "unowned_ptr.h",
     "utf16.h",
     "weak_ptr.h",
     "widestring.cpp",
@@ -133,17 +122,19 @@
     "../../third_party:fx_tiff",
     "../../xfa/*",
   ]
-  deps = [ "../../third_party:pdfium_base" ]
+  deps = [
+    "../../third_party:pdfium_base",
+    "../../third_party:pdfium_compiler_specific",
+  ]
   public_deps = [
-    ":unowned_ptr",
     "../../:freetype_common",
     "../../third_party:pdfium_base",
     "//third_party/icu:icuuc",
   ]
   if (pdf_use_partition_alloc) {
     sources += [ "fx_memory_pa.cpp" ]
-    deps += [
-      "//base/allocator/partition_allocator/src/partition_alloc",
+    deps += [ "//base/allocator/partition_allocator/src/partition_alloc" ]
+    public_deps += [
       "//base/allocator/partition_allocator/src/partition_alloc:partition_alloc_buildflags",
       "//base/allocator/partition_allocator/src/partition_alloc:raw_ptr",
     ]
diff --git a/core/fxcrt/unowned_ptr.h b/core/fxcrt/unowned_ptr.h
index 964ef7c..ac820c7 100644
--- a/core/fxcrt/unowned_ptr.h
+++ b/core/fxcrt/unowned_ptr.h
@@ -55,8 +55,6 @@
 static_assert(raw_ptr<int>::kZeroOnConstruct, "Unsafe build arguments");
 static_assert(raw_ptr<int>::kZeroOnMove, "Unsafe build arguments");
 
-#define UNOWNED_PTR_IS_BASE_RAW_PTR
-
 template <typename T>
 using UnownedPtr = raw_ptr<T>;
 
diff --git a/third_party/BUILD.gn b/third_party/BUILD.gn
index 27a06b8..bf12e49 100644
--- a/third_party/BUILD.gn
+++ b/third_party/BUILD.gn
@@ -572,9 +572,12 @@
   ]
   public_deps = [
     ":pdfium_compiler_specific",
-    "../core/fxcrt:unowned_ptr",
     "//third_party/abseil-cpp:absl",
   ]
+  if (pdf_use_partition_alloc) {
+    public_deps +=
+        [ "//base/allocator/partition_allocator/src/partition_alloc:raw_ptr" ]
+  }
   if (is_win) {
     sources += [
       "base/win/scoped_select_object.h",
diff --git a/third_party/DEPS b/third_party/DEPS
index dfd263b..6ffb470 100644
--- a/third_party/DEPS
+++ b/third_party/DEPS
@@ -3,5 +3,5 @@
   '+core/fxcrt/fx_coordinates.h',
   '+core/fxcrt/fx_memory.h',
   '+core/fxcrt/fx_system.h',
-  '+core/fxcrt/unowned_ptr.h',
+  '+partition_alloc/pointers',
 ]
diff --git a/third_party/base/containers/span.h b/third_party/base/containers/span.h
index 435fafa..0d600c3 100644
--- a/third_party/base/containers/span.h
+++ b/third_party/base/containers/span.h
@@ -13,10 +13,13 @@
 #include <type_traits>
 #include <utility>
 
-#include "core/fxcrt/unowned_ptr.h"
 #include "third_party/base/check.h"
 #include "third_party/base/compiler_specific.h"
 
+#if defined(PDF_USE_PARTITION_ALLOC)
+#include "partition_alloc/pointers/raw_ptr.h"
+#endif
+
 namespace pdfium {
 
 constexpr size_t dynamic_extent = static_cast<size_t>(-1);
@@ -187,7 +190,7 @@
   using const_reverse_iterator = std::reverse_iterator<const_iterator>;
 
   // [span.cons], span constructors, copy, assignment, and destructor
-  constexpr span() noexcept : data_(nullptr), size_(0) {}
+  constexpr span() noexcept = default;
   constexpr span(T* data, size_t size) noexcept : data_(data), size_(size) {
     DCHECK(data_ || size_ == 0);
   }
@@ -202,8 +205,8 @@
   // Conversion from a container that provides |T* data()| and |integral_type
   // size()|. Note that |data()| may not return nullptr for some empty
   // containers, which can lead to container overflow errors when probing
-  // unowned ptrs.
-#if defined(ADDRESS_SANITIZER) && defined(UNOWNED_PTR_IS_BASE_RAW_PTR)
+  // raw ptrs.
+#if defined(ADDRESS_SANITIZER) && defined(PDF_USE_PARTITION_ALLOC)
   template <typename Container,
             typename = internal::EnableIfSpanCompatibleContainer<Container, T>>
   constexpr span(Container& container)
@@ -298,12 +301,12 @@
   }
 
  private:
-#if defined(UNOWNED_PTR_IS_BASE_RAW_PTR)
+#if defined(PDF_USE_PARTITION_ALLOC)
   raw_ptr<T, AllowPtrArithmetic> data_ = nullptr;
 #else
-  UnownedPtr<T> data_;
+  T* data_ = nullptr;
 #endif
-  size_t size_;
+  size_t size_ = 0;
 };
 
 // [span.comparison], span comparison operators