Replace remaining FX_ArraySize() usage with pdfium::size().

Similar to how Chromium replaced arraysize() with base::size() in
https://crrev.com/621760. Remove FX_ArraySize().

Change-Id: Id9d2b9cdd2a13c87f808fa4f4d0658561df731f1
Bug: 1435
Reviewed-on: https://pdfium-review.googlesource.com/c/pdfium/+/69572
Commit-Queue: Lei Zhang <thestig@google.com>
Reviewed-by: Tom Sepez <tsepez@chromium.org>
diff --git a/core/fdrm/fx_crypt_unittest.cpp b/core/fdrm/fx_crypt_unittest.cpp
index 8b6fd7d..808071a 100644
--- a/core/fdrm/fx_crypt_unittest.cpp
+++ b/core/fdrm/fx_crypt_unittest.cpp
@@ -9,9 +9,9 @@
 #include <string>
 #include <vector>
 
-#include "core/fxcrt/fx_memory.h"
 #include "testing/gtest/include/gtest/gtest.h"
 #include "testing/utils/hash.h"
+#include "third_party/base/stl_util.h"
 
 namespace {
 
@@ -201,7 +201,7 @@
   CRYPT_SHA1Generate(reinterpret_cast<const uint8_t*>(kInput), strlen(kInput),
                      actual);
 
-  for (size_t i = 0; i < FX_ArraySize(kExpected); i++)
+  for (size_t i = 0; i < pdfium::size(kExpected); i++)
     EXPECT_EQ(kExpected[i], actual[i]) << " at byte " << i;
 }
 
@@ -216,7 +216,7 @@
   CRYPT_SHA1Generate(reinterpret_cast<const uint8_t*>(kInput), strlen(kInput),
                      actual);
 
-  for (size_t i = 0; i < FX_ArraySize(kExpected); i++)
+  for (size_t i = 0; i < pdfium::size(kExpected); i++)
     EXPECT_EQ(kExpected[i], actual[i]) << " at byte " << i;
 }
 
@@ -232,7 +232,7 @@
   CRYPT_SHA1Generate(reinterpret_cast<const uint8_t*>(kInput), strlen(kInput),
                      actual);
 
-  for (size_t i = 0; i < FX_ArraySize(kExpected); i++)
+  for (size_t i = 0; i < pdfium::size(kExpected); i++)
     EXPECT_EQ(kExpected[i], actual[i]) << " at byte " << i;
 }
 
@@ -245,7 +245,7 @@
   uint8_t actual[32];
   CRYPT_SHA256Generate(reinterpret_cast<const uint8_t*>(kInput), strlen(kInput),
                        actual);
-  for (size_t i = 0; i < FX_ArraySize(kExpected); ++i)
+  for (size_t i = 0; i < pdfium::size(kExpected); ++i)
     EXPECT_EQ(kExpected[i], actual[i]) << " at byte " << i;
 }
 
@@ -259,7 +259,7 @@
   uint8_t actual[32];
   CRYPT_SHA256Generate(reinterpret_cast<const uint8_t*>(kInput), strlen(kInput),
                        actual);
-  for (size_t i = 0; i < FX_ArraySize(kExpected); ++i)
+  for (size_t i = 0; i < pdfium::size(kExpected); ++i)
     EXPECT_EQ(kExpected[i], actual[i]) << " at byte " << i;
 }
 
@@ -274,7 +274,7 @@
   uint8_t actual[32];
   CRYPT_SHA256Generate(reinterpret_cast<const uint8_t*>(kInput), strlen(kInput),
                        actual);
-  for (size_t i = 0; i < FX_ArraySize(kExpected); ++i)
+  for (size_t i = 0; i < pdfium::size(kExpected); ++i)
     EXPECT_EQ(kExpected[i], actual[i]) << " at byte " << i;
 }
 
@@ -327,7 +327,7 @@
         29,  45,  14,  111};
     CRYPT_rc4_context context;
     static const uint8_t kFooBar[] = "foobar";
-    CRYPT_ArcFourSetup(&context, {kFooBar, FX_ArraySize(kFooBar) - 1});
+    CRYPT_ArcFourSetup(&context, {kFooBar, pdfium::size(kFooBar) - 1});
     CheckArcFourContext(context, 0, 0, kFoobarPermutation);
   }
 }
@@ -345,18 +345,18 @@
     CRYPT_rc4_context context;
     CRYPT_ArcFourSetup(&context, {});
 
-    uint8_t data_short[FX_ArraySize(kDataShort)];
-    memcpy(data_short, kDataShort, FX_ArraySize(kDataShort));
+    uint8_t data_short[pdfium::size(kDataShort)];
+    memcpy(data_short, kDataShort, pdfium::size(kDataShort));
     static const uint8_t kExpectedEncryptedDataShort[] = {
         138, 112, 236, 97,  242, 66,  52,  89,  225, 38,  88,  8,
         47,  78,  216, 24,  170, 106, 26,  199, 208, 131, 157, 242,
         55,  11,  25,  90,  66,  182, 19,  255, 210, 181, 85,  69,
         31,  240, 206, 171, 97,  62,  202, 172, 30,  252};
     static_assert(
-        FX_ArraySize(kExpectedEncryptedDataShort) == FX_ArraySize(data_short),
+        pdfium::size(kExpectedEncryptedDataShort) == pdfium::size(data_short),
         "data_short mismatch");
     CRYPT_ArcFourCrypt(&context, data_short);
-    for (size_t i = 0; i < FX_ArraySize(data_short); ++i)
+    for (size_t i = 0; i < pdfium::size(data_short); ++i)
       EXPECT_EQ(kExpectedEncryptedDataShort[i], data_short[i]) << i;
 
     static const uint8_t kPermutation[kRC4ContextPermutationLength] = {
@@ -385,8 +385,8 @@
     CRYPT_rc4_context context;
     CRYPT_ArcFourSetup(&context, {});
 
-    uint8_t data_long[FX_ArraySize(kDataLong)];
-    memcpy(data_long, kDataLong, FX_ArraySize(kDataLong));
+    uint8_t data_long[pdfium::size(kDataLong)];
+    memcpy(data_long, kDataLong, pdfium::size(kDataLong));
     static const uint8_t kExpectedEncryptedDataLong[] = {
         138, 112, 236, 97,  242, 66,  52,  89,  225, 38,  88,  8,   47,  78,
         216, 24,  170, 106, 26,  199, 208, 131, 157, 242, 55,  11,  25,  90,
@@ -409,11 +409,11 @@
         202, 170, 224, 89,  28,  5,   138, 19,  253, 105, 220, 105, 24,  187,
         109, 89,  205, 89,  202};
     static_assert(
-        FX_ArraySize(kExpectedEncryptedDataLong) == FX_ArraySize(data_long),
+        pdfium::size(kExpectedEncryptedDataLong) == pdfium::size(data_long),
         "data_long mismatch");
-    static_assert(FX_ArraySize(data_long) > 256, "too short");
+    static_assert(pdfium::size(data_long) > 256, "too short");
     CRYPT_ArcFourCrypt(&context, data_long);
-    for (size_t i = 0; i < FX_ArraySize(data_long); ++i)
+    for (size_t i = 0; i < pdfium::size(data_long); ++i)
       EXPECT_EQ(kExpectedEncryptedDataLong[i], data_long[i]) << i;
 
     static const uint8_t kPermutation[kRC4ContextPermutationLength] = {
@@ -441,20 +441,20 @@
   {
     CRYPT_rc4_context context;
     static const uint8_t kFooBar[] = "foobar";
-    CRYPT_ArcFourSetup(&context, {kFooBar, FX_ArraySize(kFooBar) - 1});
+    CRYPT_ArcFourSetup(&context, {kFooBar, pdfium::size(kFooBar) - 1});
 
-    uint8_t data_short[FX_ArraySize(kDataShort)];
-    memcpy(data_short, kDataShort, FX_ArraySize(kDataShort));
+    uint8_t data_short[pdfium::size(kDataShort)];
+    memcpy(data_short, kDataShort, pdfium::size(kDataShort));
     static const uint8_t kExpectedEncryptedDataShort[] = {
         59,  193, 117, 206, 167, 54,  218, 7,   229, 214, 188, 55,
         90,  205, 196, 25,  36,  114, 199, 218, 161, 107, 122, 119,
         106, 167, 44,  175, 240, 123, 192, 102, 174, 167, 105, 187,
         202, 70,  121, 81,  17,  30,  5,   138, 116, 166};
     static_assert(
-        FX_ArraySize(kExpectedEncryptedDataShort) == FX_ArraySize(data_short),
+        pdfium::size(kExpectedEncryptedDataShort) == pdfium::size(data_short),
         "data_short mismatch");
     CRYPT_ArcFourCrypt(&context, data_short);
-    for (size_t i = 0; i < FX_ArraySize(data_short); ++i)
+    for (size_t i = 0; i < pdfium::size(data_short); ++i)
       EXPECT_EQ(kExpectedEncryptedDataShort[i], data_short[i]) << i;
 
     static const uint8_t kPermutation[kRC4ContextPermutationLength] = {
@@ -482,10 +482,10 @@
   {
     CRYPT_rc4_context context;
     static const uint8_t kFooBar[] = "foobar";
-    CRYPT_ArcFourSetup(&context, {kFooBar, FX_ArraySize(kFooBar) - 1});
+    CRYPT_ArcFourSetup(&context, {kFooBar, pdfium::size(kFooBar) - 1});
 
-    uint8_t data_long[FX_ArraySize(kDataLong)];
-    memcpy(data_long, kDataLong, FX_ArraySize(kDataLong));
+    uint8_t data_long[pdfium::size(kDataLong)];
+    memcpy(data_long, kDataLong, pdfium::size(kDataLong));
     static const uint8_t kExpectedEncryptedDataLong[] = {
         59,  193, 117, 206, 167, 54,  218, 7,   229, 214, 188, 55,  90,  205,
         196, 25,  36,  114, 199, 218, 161, 107, 122, 119, 106, 167, 44,  175,
@@ -508,11 +508,11 @@
         243, 73,  206, 89,  9,   93,  156, 167, 205, 166, 75,  227, 36,  34,
         81,  124, 195, 246, 152};
     static_assert(
-        FX_ArraySize(kExpectedEncryptedDataLong) == FX_ArraySize(data_long),
+        pdfium::size(kExpectedEncryptedDataLong) == pdfium::size(data_long),
         "data_long mismatch");
-    static_assert(FX_ArraySize(data_long) > 256, "too short");
+    static_assert(pdfium::size(data_long) > 256, "too short");
     CRYPT_ArcFourCrypt(&context, data_long);
-    for (size_t i = 0; i < FX_ArraySize(data_long); ++i)
+    for (size_t i = 0; i < pdfium::size(data_long); ++i)
       EXPECT_EQ(kExpectedEncryptedDataLong[i], data_long[i]) << i;
 
     static const uint8_t kPermutation[kRC4ContextPermutationLength] = {
@@ -549,7 +549,7 @@
   uint8_t actual[48];
   CRYPT_SHA384Generate(reinterpret_cast<const uint8_t*>(kInput), strlen(kInput),
                        actual);
-  for (size_t i = 0; i < FX_ArraySize(kExpected); ++i)
+  for (size_t i = 0; i < pdfium::size(kExpected); ++i)
     EXPECT_EQ(kExpected[i], actual[i]) << " at byte " << i;
 }
 
@@ -565,7 +565,7 @@
   uint8_t actual[48];
   CRYPT_SHA384Generate(reinterpret_cast<const uint8_t*>(kInput), strlen(kInput),
                        actual);
-  for (size_t i = 0; i < FX_ArraySize(kExpected); ++i)
+  for (size_t i = 0; i < pdfium::size(kExpected); ++i)
     EXPECT_EQ(kExpected[i], actual[i]) << " at byte " << i;
 }
 
@@ -583,7 +583,7 @@
   EXPECT_EQ(112u, strlen(kInput));
   CRYPT_SHA384Generate(reinterpret_cast<const uint8_t*>(kInput), strlen(kInput),
                        actual);
-  for (size_t i = 0; i < FX_ArraySize(kExpected); ++i)
+  for (size_t i = 0; i < pdfium::size(kExpected); ++i)
     EXPECT_EQ(kExpected[i], actual[i]) << " at byte " << i;
 }
 
@@ -599,7 +599,7 @@
   uint8_t actual[64];
   CRYPT_SHA512Generate(reinterpret_cast<const uint8_t*>(kInput), strlen(kInput),
                        actual);
-  for (size_t i = 0; i < FX_ArraySize(kExpected); ++i)
+  for (size_t i = 0; i < pdfium::size(kExpected); ++i)
     EXPECT_EQ(kExpected[i], actual[i]) << " at byte " << i;
 }
 
@@ -617,7 +617,7 @@
   uint8_t actual[64];
   CRYPT_SHA512Generate(reinterpret_cast<const uint8_t*>(kInput), strlen(kInput),
                        actual);
-  for (size_t i = 0; i < FX_ArraySize(kExpected); ++i)
+  for (size_t i = 0; i < pdfium::size(kExpected); ++i)
     EXPECT_EQ(kExpected[i], actual[i]) << " at byte " << i;
 }
 
@@ -637,6 +637,6 @@
   EXPECT_EQ(112u, strlen(kInput));
   CRYPT_SHA512Generate(reinterpret_cast<const uint8_t*>(kInput), strlen(kInput),
                        actual);
-  for (size_t i = 0; i < FX_ArraySize(kExpected); ++i)
+  for (size_t i = 0; i < pdfium::size(kExpected); ++i)
     EXPECT_EQ(kExpected[i], actual[i]) << " at byte " << i;
 }
diff --git a/core/fpdfdoc/cpdf_aaction.cpp b/core/fpdfdoc/cpdf_aaction.cpp
index 46fe173..e0ae9e9 100644
--- a/core/fpdfdoc/cpdf_aaction.cpp
+++ b/core/fpdfdoc/cpdf_aaction.cpp
@@ -7,7 +7,7 @@
 #include "core/fpdfdoc/cpdf_aaction.h"
 
 #include "core/fpdfapi/parser/cpdf_dictionary.h"
-#include "core/fxcrt/fx_memory.h"
+#include "third_party/base/stl_util.h"
 
 namespace {
 
@@ -37,7 +37,7 @@
 
 // |kAATypes| should have one less element than enum AActionType due to
 // |kDocumentOpen|, which is an artificial type.
-static_assert(FX_ArraySize(kAATypes) == CPDF_AAction::kNumberOfActions - 1,
+static_assert(pdfium::size(kAATypes) == CPDF_AAction::kNumberOfActions - 1,
               "kAATypes count mismatch");
 
 }  // namespace
diff --git a/core/fpdfdoc/cpdf_defaultappearance_unittest.cpp b/core/fpdfdoc/cpdf_defaultappearance_unittest.cpp
index 252d37e..58c3e6d 100644
--- a/core/fpdfdoc/cpdf_defaultappearance_unittest.cpp
+++ b/core/fpdfdoc/cpdf_defaultappearance_unittest.cpp
@@ -4,10 +4,10 @@
 
 #include "core/fpdfdoc/cpdf_defaultappearance.h"
 
-#include "core/fxcrt/fx_memory.h"
 #include "testing/gtest/include/gtest/gtest.h"
 #include "testing/test_support.h"
 #include "third_party/base/span.h"
+#include "third_party/base/stl_util.h"
 
 TEST(CPDFDefaultAppearanceTest, FindTagParamFromStart) {
   static const struct FindTagTestStruct {
@@ -37,7 +37,7 @@
   };
 
   CPDF_DefaultAppearance da;
-  for (size_t i = 0; i < FX_ArraySize(test_data); ++i) {
+  for (size_t i = 0; i < pdfium::size(test_data); ++i) {
     CPDF_SimpleParser parser(
         pdfium::make_span(test_data[i].input, test_data[i].input_size));
     EXPECT_EQ(test_data[i].result,
diff --git a/core/fpdfdoc/cpdf_dest.cpp b/core/fpdfdoc/cpdf_dest.cpp
index f0c3592..3740723 100644
--- a/core/fpdfdoc/cpdf_dest.cpp
+++ b/core/fpdfdoc/cpdf_dest.cpp
@@ -13,7 +13,7 @@
 #include "core/fpdfapi/parser/cpdf_name.h"
 #include "core/fpdfapi/parser/cpdf_number.h"
 #include "core/fpdfdoc/cpdf_nametree.h"
-#include "core/fxcrt/fx_memory.h"
+#include "third_party/base/stl_util.h"
 
 namespace {
 
@@ -26,8 +26,8 @@
 
 const uint8_t g_sZoomModeMaxParamCount[] = {0, 3, 0, 1, 1, 4, 0, 1, 1, 0};
 
-static_assert(FX_ArraySize(g_sZoomModes) ==
-                  FX_ArraySize(g_sZoomModeMaxParamCount),
+static_assert(pdfium::size(g_sZoomModes) ==
+                  pdfium::size(g_sZoomModeMaxParamCount),
               "Zoom mode count Mismatch");
 
 }  // namespace
diff --git a/core/fpdfdoc/cpdf_filespec.cpp b/core/fpdfdoc/cpdf_filespec.cpp
index 506e176..5e52f3e 100644
--- a/core/fpdfdoc/cpdf_filespec.cpp
+++ b/core/fpdfdoc/cpdf_filespec.cpp
@@ -17,6 +17,7 @@
 #include "core/fpdfapi/parser/cpdf_string.h"
 #include "core/fpdfapi/parser/fpdf_parser_decode.h"
 #include "core/fxcrt/fx_system.h"
+#include "third_party/base/stl_util.h"
 
 namespace {
 
@@ -139,7 +140,7 @@
   // List of keys to check for the file specification string.
   // Follows the same precedence order as GetFileName().
   static constexpr const char* kKeys[] = {"UF", "F", "DOS", "Mac", "Unix"};
-  size_t end = pDict->GetStringFor("FS") == "URL" ? 2 : FX_ArraySize(kKeys);
+  size_t end = pDict->GetStringFor("FS") == "URL" ? 2 : pdfium::size(kKeys);
   for (size_t i = 0; i < end; ++i) {
     ByteString key = kKeys[i];
     if (!pDict->GetUnicodeTextFor(key).IsEmpty()) {
diff --git a/core/fpdfdoc/cpdf_filespec_unittest.cpp b/core/fpdfdoc/cpdf_filespec_unittest.cpp
index 389a521..83acbd5 100644
--- a/core/fpdfdoc/cpdf_filespec_unittest.cpp
+++ b/core/fpdfdoc/cpdf_filespec_unittest.cpp
@@ -16,6 +16,7 @@
 #include "core/fxcrt/fx_memory_wrappers.h"
 #include "testing/gtest/include/gtest/gtest.h"
 #include "testing/test_support.h"
+#include "third_party/base/stl_util.h"
 
 TEST(cpdf_filespec, EncodeDecodeFileName) {
   static const std::vector<pdfium::NullTermWstrFuncTestData> test_data = {
@@ -101,12 +102,12 @@
     };
     // Keyword fields in reverse order of precedence to retrieve the file name.
     const char* const keywords[] = {"Unix", "Mac", "DOS", "F", "UF"};
-    static_assert(FX_ArraySize(test_data) == FX_ArraySize(keywords),
+    static_assert(pdfium::size(test_data) == pdfium::size(keywords),
                   "size mismatch");
     auto dict_obj = pdfium::MakeRetain<CPDF_Dictionary>();
     CPDF_FileSpec file_spec(dict_obj.Get());
     EXPECT_TRUE(file_spec.GetFileName().IsEmpty());
-    for (size_t i = 0; i < FX_ArraySize(keywords); ++i) {
+    for (size_t i = 0; i < pdfium::size(keywords); ++i) {
       dict_obj->SetNewFor<CPDF_String>(keywords[i], test_data[i].input);
       EXPECT_STREQ(test_data[i].expected, file_spec.GetFileName().c_str());
     }
@@ -197,12 +198,12 @@
     const wchar_t file_name[] = L"test.pdf";
     const char* const keys[] = {"Unix", "Mac", "DOS", "F", "UF"};
     const char* const streams[] = {"test1", "test2", "test3", "test4", "test5"};
-    static_assert(FX_ArraySize(keys) == FX_ArraySize(streams), "size mismatch");
+    static_assert(pdfium::size(keys) == pdfium::size(streams), "size mismatch");
     CPDF_Dictionary* file_dict =
         file_spec.GetObj()->AsDictionary()->GetDictFor("EF");
 
     // Keys in reverse order of precedence to retrieve the file content stream.
-    for (size_t i = 0; i < FX_ArraySize(keys); ++i) {
+    for (size_t i = 0; i < pdfium::size(keys); ++i) {
       // Set the file name.
       dict_obj->SetNewFor<CPDF_String>(keys[i], file_name);
 
diff --git a/core/fpdfdoc/cpdf_formcontrol.cpp b/core/fpdfdoc/cpdf_formcontrol.cpp
index db9e9ae..a4f4b3d 100644
--- a/core/fpdfdoc/cpdf_formcontrol.cpp
+++ b/core/fpdfdoc/cpdf_formcontrol.cpp
@@ -17,6 +17,7 @@
 #include "core/fpdfapi/parser/fpdf_parser_decode.h"
 #include "core/fpdfapi/parser/fpdf_parser_utility.h"
 #include "core/fpdfdoc/cpdf_interactiveform.h"
+#include "third_party/base/stl_util.h"
 
 namespace {
 
@@ -129,7 +130,7 @@
     return Invert;
 
   ByteString csH = m_pWidgetDict->GetStringFor("H", "I");
-  for (size_t i = 0; i < FX_ArraySize(kHighlightModes); ++i) {
+  for (size_t i = 0; i < pdfium::size(kHighlightModes); ++i) {
     if (csH == kHighlightModes[i])
       return static_cast<HighlightingMode>(i);
   }
diff --git a/core/fpdftext/cpdf_linkextract_unittest.cpp b/core/fpdftext/cpdf_linkextract_unittest.cpp
index 014bedb..316f039 100644
--- a/core/fpdftext/cpdf_linkextract_unittest.cpp
+++ b/core/fpdftext/cpdf_linkextract_unittest.cpp
@@ -4,8 +4,8 @@
 
 #include "core/fpdftext/cpdf_linkextract.h"
 
-#include "core/fxcrt/fx_memory.h"
 #include "testing/gtest/include/gtest/gtest.h"
+#include "third_party/base/stl_util.h"
 
 // Class to help test functions in CPDF_LinkExtract class.
 class CPDF_TestLinkExtract final : public CPDF_LinkExtract {
@@ -31,7 +31,7 @@
       L"abc@.xyz.org",    // Domain name should not start with '.'.
       L"fan@g..com"       // Domain name should not have consecutive '.'
   };
-  for (size_t i = 0; i < FX_ArraySize(invalid_strs); ++i) {
+  for (size_t i = 0; i < pdfium::size(invalid_strs); ++i) {
     const wchar_t* const input = invalid_strs[i];
     WideString text_str(input);
     EXPECT_FALSE(extractor.CheckMailLink(&text_str)) << input;
@@ -52,7 +52,7 @@
       {L"fan@g.com..", L"fan@g.com"},           // Trim the ending periods.
       {L"CAP.cap@Gmail.Com", L"CAP.cap@Gmail.Com"},  // Keep the original case.
   };
-  for (size_t i = 0; i < FX_ArraySize(valid_strs); ++i) {
+  for (size_t i = 0; i < pdfium::size(valid_strs); ++i) {
     const wchar_t* const input = valid_strs[i][0];
     WideString text_str(input);
     WideString expected_str(L"mailto:");
@@ -79,7 +79,7 @@
       L"abc.example.com",  // URL without scheme.
   };
   const int32_t DEFAULT_VALUE = -42;
-  for (size_t i = 0; i < FX_ArraySize(invalid_cases); ++i) {
+  for (size_t i = 0; i < pdfium::size(invalid_cases); ++i) {
     const wchar_t* const input = invalid_cases[i];
     WideString text_str(input);
     int32_t start_offset = DEFAULT_VALUE;
@@ -174,7 +174,7 @@
       {L"www.测试。net。", L"http://www.测试。net。", 0, 11},
       {L"www.测试.net;", L"http://www.测试.net;", 0, 11},
   };
-  for (size_t i = 0; i < FX_ArraySize(valid_cases); ++i) {
+  for (size_t i = 0; i < pdfium::size(valid_cases); ++i) {
     const wchar_t* const input = valid_cases[i].input_string;
     WideString text_str(input);
     int32_t start_offset = DEFAULT_VALUE;
diff --git a/core/fxcodec/basic/a85_unittest.cpp b/core/fxcodec/basic/a85_unittest.cpp
index e01d3d2..109adda 100644
--- a/core/fxcodec/basic/a85_unittest.cpp
+++ b/core/fxcodec/basic/a85_unittest.cpp
@@ -10,6 +10,7 @@
 #include "core/fxcodec/basic/basicmodule.h"
 #include "core/fxcrt/fx_memory_wrappers.h"
 #include "testing/gtest/include/gtest/gtest.h"
+#include "third_party/base/stl_util.h"
 
 TEST(fxcodec, A85TestBadInputs) {
   const uint8_t src_buf[] = {1, 2, 3, 4};
@@ -33,7 +34,7 @@
   // Should have 5 chars for each set of 4 and 2 terminators.
   const uint8_t expected_out[] = {33, 60, 78, 63, 43,  115,
                                   56, 87, 45, 33, 126, 62};
-  ASSERT_EQ(FX_ArraySize(expected_out), dest_size);
+  ASSERT_EQ(pdfium::size(expected_out), dest_size);
 
   // Check the output
   auto dest_buf_span = pdfium::make_span(dest_buf.get(), dest_size);
@@ -54,7 +55,7 @@
 
     // 5 chars for first symbol + 2 + 2 terminators.
     uint8_t expected_out_1leftover[] = {33, 60, 78, 63, 43, 114, 114, 126, 62};
-    ASSERT_EQ(FX_ArraySize(expected_out_1leftover), dest_size);
+    ASSERT_EQ(pdfium::size(expected_out_1leftover), dest_size);
 
     // Check the output
     auto dest_buf_span = pdfium::make_span(dest_buf.get(), dest_size);
@@ -72,7 +73,7 @@
     // 5 chars for first symbol + 3 + 2 terminators.
     const uint8_t expected_out_2leftover[] = {33,  60, 78, 63,  43,
                                               115, 56, 68, 126, 62};
-    ASSERT_EQ(FX_ArraySize(expected_out_2leftover), dest_size);
+    ASSERT_EQ(pdfium::size(expected_out_2leftover), dest_size);
 
     // Check the output
     auto dest_buf_span = pdfium::make_span(dest_buf.get(), dest_size);
@@ -90,7 +91,7 @@
     // 5 chars for first symbol + 4 + 2 terminators.
     const uint8_t expected_out_3leftover[] = {33, 60, 78,  63,  43, 115,
                                               56, 77, 114, 126, 62};
-    ASSERT_EQ(FX_ArraySize(expected_out_3leftover), dest_size);
+    ASSERT_EQ(pdfium::size(expected_out_3leftover), dest_size);
 
     // Check the output
     auto dest_buf_span = pdfium::make_span(dest_buf.get(), dest_size);
@@ -111,7 +112,7 @@
 
     // Should have 5 chars for first set of 4 + 1 for z + 2 terminators.
     const uint8_t expected_out[] = {33, 60, 78, 63, 43, 122, 126, 62};
-    ASSERT_EQ(FX_ArraySize(expected_out), dest_size);
+    ASSERT_EQ(pdfium::size(expected_out), dest_size);
 
     // Check the output
     auto dest_buf_span = pdfium::make_span(dest_buf.get(), dest_size);
@@ -128,7 +129,7 @@
 
     // Should have 5 chars for set of 4 + 1 for z + 2 terminators.
     const uint8_t expected_out_2[] = {122, 33, 60, 78, 63, 43, 126, 62};
-    ASSERT_EQ(FX_ArraySize(expected_out_2), dest_size);
+    ASSERT_EQ(pdfium::size(expected_out_2), dest_size);
 
     // Check the output
     auto dest_buf_span = pdfium::make_span(dest_buf.get(), dest_size);
@@ -146,7 +147,7 @@
     // Should have 5 chars for set of 4 + 3 for last 2 + 2 terminators.
     const uint8_t expected_out_leftover[] = {33, 60, 78, 63,  43,
                                              33, 33, 33, 126, 62};
-    ASSERT_EQ(FX_ArraySize(expected_out_leftover), dest_size);
+    ASSERT_EQ(pdfium::size(expected_out_leftover), dest_size);
 
     // Check the output
     auto dest_buf_span = pdfium::make_span(dest_buf.get(), dest_size);
diff --git a/core/fxcodec/gif/cfx_gifcontext.cpp b/core/fxcodec/gif/cfx_gifcontext.cpp
index d78f47a..6fc16aa 100644
--- a/core/fxcodec/gif/cfx_gifcontext.cpp
+++ b/core/fxcodec/gif/cfx_gifcontext.cpp
@@ -298,7 +298,7 @@
             if (gif_image->row_num >=
                 static_cast<int32_t>(gif_image->image_info.height)) {
               img_pass_num_++;
-              if (img_pass_num_ == FX_ArraySize(kGifInterlaceStep)) {
+              if (img_pass_num_ == pdfium::size(kGifInterlaceStep)) {
                 DecodingFailureAtTailCleanup(gif_image);
                 return CFX_GifDecodeStatus::Error;
               }
diff --git a/core/fxcodec/gif/cfx_lzwdecompressor_unittest.cpp b/core/fxcodec/gif/cfx_lzwdecompressor_unittest.cpp
index 58cb086..ac824ac4 100644
--- a/core/fxcodec/gif/cfx_lzwdecompressor_unittest.cpp
+++ b/core/fxcodec/gif/cfx_lzwdecompressor_unittest.cpp
@@ -4,8 +4,8 @@
 
 #include "core/fxcodec/gif/cfx_lzwdecompressor.h"
 
-#include "core/fxcrt/fx_memory.h"
 #include "testing/gtest/include/gtest/gtest.h"
+#include "third_party/base/stl_util.h"
 
 TEST(CFX_LZWDecompressor, CreateBadParams) {
   EXPECT_EQ(nullptr, CFX_LZWDecompressor::Create(0x10, 0x02));
@@ -29,7 +29,7 @@
     memset(dest_buf, static_cast<uint8_t>(-1), sizeof(dest_buf));
 
     EXPECT_EQ(0u, decompressor->ExtractDataForTest(dest_buf, 0));
-    for (size_t i = 0; i < FX_ArraySize(dest_buf); ++i)
+    for (size_t i = 0; i < pdfium::size(dest_buf); ++i)
       EXPECT_EQ(static_cast<uint8_t>(-1), dest_buf[i]);
 
     EXPECT_EQ(10u, *(decompressor->DecompressedNextForTest()));
@@ -50,7 +50,7 @@
     size_t i = 0;
     for (; i < 5; ++i)
       EXPECT_EQ(9 - i, dest_buf[i]);
-    for (; i < FX_ArraySize(dest_buf); ++i)
+    for (; i < pdfium::size(dest_buf); ++i)
       EXPECT_EQ(static_cast<uint8_t>(-1), dest_buf[i]);
 
     EXPECT_EQ(5u, *(decompressor->DecompressedNextForTest()));
@@ -68,11 +68,11 @@
     memset(dest_buf, static_cast<uint8_t>(-1), sizeof(dest_buf));
 
     EXPECT_EQ(10u, decompressor->ExtractDataForTest(dest_buf,
-                                                    FX_ArraySize(dest_buf)));
+                                                    pdfium::size(dest_buf)));
     size_t i = 0;
     for (; i < 10; ++i)
       EXPECT_EQ(9 - i, dest_buf[i]);
-    for (; i < FX_ArraySize(dest_buf); ++i)
+    for (; i < pdfium::size(dest_buf); ++i)
       EXPECT_EQ(static_cast<uint8_t>(-1), dest_buf[i]);
 
     EXPECT_EQ(0u, *(decompressor->DecompressedNextForTest()));
@@ -86,10 +86,10 @@
   ASSERT_NE(nullptr, decompressor);
 
   uint8_t image_data[10];
-  uint32_t image_size = FX_ArraySize(image_data);
+  uint32_t image_size = pdfium::size(image_data);
 
   uint8_t output_data[10];
-  uint32_t output_size = FX_ArraySize(output_data);
+  uint32_t output_size = pdfium::size(output_data);
 
   EXPECT_EQ(
       CFX_GifDecodeStatus::Error,
@@ -115,18 +115,18 @@
   ASSERT_NE(nullptr, decompressor);
 
   uint8_t image_data[] = {0x44, 0x01};
-  uint32_t image_size = FX_ArraySize(image_data);
+  uint32_t image_size = pdfium::size(image_data);
 
   uint8_t expected_data[] = {0x00};
-  uint8_t output_data[FX_ArraySize(expected_data)];
+  uint8_t output_data[pdfium::size(expected_data)];
   memset(output_data, 0, sizeof(output_data));
-  uint32_t output_size = FX_ArraySize(output_data);
+  uint32_t output_size = pdfium::size(output_data);
 
   EXPECT_EQ(
       CFX_GifDecodeStatus::Success,
       decompressor->Decode(image_data, image_size, output_data, &output_size));
 
-  EXPECT_EQ(FX_ArraySize(output_data), output_size);
+  EXPECT_EQ(pdfium::size(output_data), output_size);
   EXPECT_TRUE(0 == memcmp(expected_data, output_data, sizeof(expected_data)));
 }
 
@@ -138,7 +138,7 @@
 
   static constexpr uint8_t kImageData[] = {0x84, 0x8F, 0xA9, 0xCB,
                                            0xED, 0x0F, 0x63, 0x2B};
-  uint32_t image_size = FX_ArraySize(kImageData);
+  uint32_t image_size = pdfium::size(kImageData);
 
   static constexpr uint8_t kExpectedData[] = {
       0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
@@ -150,15 +150,15 @@
       0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
       0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
       0x00, 0x00, 0x00, 0x00};
-  uint8_t output_data[FX_ArraySize(kExpectedData)];
+  uint8_t output_data[pdfium::size(kExpectedData)];
   memset(output_data, 0, sizeof(output_data));
-  uint32_t output_size = FX_ArraySize(output_data);
+  uint32_t output_size = pdfium::size(output_data);
 
   EXPECT_EQ(
       CFX_GifDecodeStatus::Success,
       decompressor->Decode(kImageData, image_size, output_data, &output_size));
 
-  EXPECT_EQ(FX_ArraySize(output_data), output_size);
+  EXPECT_EQ(pdfium::size(output_data), output_size);
   EXPECT_TRUE(0 == memcmp(kExpectedData, output_data, sizeof(kExpectedData)));
 }
 
@@ -171,7 +171,7 @@
   static constexpr uint8_t kImageData[] = {
       0x8C, 0x2D, 0x99, 0x87, 0x2A, 0x1C, 0xDC, 0x33, 0xA0, 0x02, 0x75,
       0xEC, 0x95, 0xFA, 0xA8, 0xDE, 0x60, 0x8C, 0x04, 0x91, 0x4C, 0x01};
-  uint32_t image_size = FX_ArraySize(kImageData);
+  uint32_t image_size = pdfium::size(kImageData);
 
   static constexpr uint8_t kExpectedData[] = {
       0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01,
@@ -184,15 +184,15 @@
       0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01,
       0x01, 0x01, 0x01, 0x01};
 
-  uint8_t output_data[FX_ArraySize(kExpectedData)];
+  uint8_t output_data[pdfium::size(kExpectedData)];
   memset(output_data, 0, sizeof(output_data));
-  uint32_t output_size = FX_ArraySize(output_data);
+  uint32_t output_size = pdfium::size(output_data);
 
   EXPECT_EQ(
       CFX_GifDecodeStatus::Success,
       decompressor->Decode(kImageData, image_size, output_data, &output_size));
 
-  EXPECT_EQ(FX_ArraySize(output_data), output_size);
+  EXPECT_EQ(pdfium::size(output_data), output_size);
   EXPECT_TRUE(0 == memcmp(kExpectedData, output_data, sizeof(kExpectedData)));
 }
 
@@ -207,11 +207,11 @@
       0x30, 0xC9, 0x49, 0x81, 0xBD, 0x78, 0xE8, 0xCD, 0x89, 0xFF,
       0x60, 0x20, 0x8E, 0xE4, 0x61, 0x9E, 0xA8, 0xA1, 0xAE, 0x2C,
       0xE2, 0xBE, 0xB0, 0x20, 0xCF, 0x74, 0x61, 0xDF, 0x78, 0x04};
-  uint32_t image_size = FX_ArraySize(kImageData);
+  uint32_t image_size = pdfium::size(kImageData);
 
   uint8_t output_data[100];  // The uncompressed data is for a 10x10 image
   memset(output_data, 0, sizeof(output_data));
-  uint32_t output_size = FX_ArraySize(output_data);
+  uint32_t output_size = pdfium::size(output_data);
 
   EXPECT_EQ(
       CFX_GifDecodeStatus::Error,
diff --git a/core/fxcodec/jbig2/JBig2_ArithDecoder.cpp b/core/fxcodec/jbig2/JBig2_ArithDecoder.cpp
index 8d3fc5a..92bcd21 100644
--- a/core/fxcodec/jbig2/JBig2_ArithDecoder.cpp
+++ b/core/fxcodec/jbig2/JBig2_ArithDecoder.cpp
@@ -7,7 +7,7 @@
 #include "core/fxcodec/jbig2/JBig2_ArithDecoder.h"
 
 #include "core/fxcodec/jbig2/JBig2_BitStream.h"
-#include "core/fxcrt/fx_memory.h"
+#include "third_party/base/stl_util.h"
 
 namespace {
 
@@ -41,13 +41,13 @@
   if (qe.bSwitch)
     m_MPS = !m_MPS;
   m_I = qe.NLPS;
-  ASSERT(m_I < FX_ArraySize(kQeTable));
+  ASSERT(m_I < pdfium::size(kQeTable));
   return D;
 }
 
 int JBig2ArithCtx::DecodeNMPS(const JBig2ArithQe& qe) {
   m_I = qe.NMPS;
-  ASSERT(m_I < FX_ArraySize(kQeTable));
+  ASSERT(m_I < pdfium::size(kQeTable));
   return MPS();
 }
 
@@ -65,7 +65,7 @@
 
 int CJBig2_ArithDecoder::Decode(JBig2ArithCtx* pCX) {
   ASSERT(pCX);
-  ASSERT(pCX->I() < FX_ArraySize(kQeTable));
+  ASSERT(pCX->I() < pdfium::size(kQeTable));
 
   const JBig2ArithCtx::JBig2ArithQe& qe = kQeTable[pCX->I()];
   m_A -= qe.Qe;
diff --git a/core/fxcodec/jbig2/JBig2_ArithIntDecoder.cpp b/core/fxcodec/jbig2/JBig2_ArithIntDecoder.cpp
index efef77e..79cc015 100644
--- a/core/fxcodec/jbig2/JBig2_ArithIntDecoder.cpp
+++ b/core/fxcodec/jbig2/JBig2_ArithIntDecoder.cpp
@@ -8,8 +8,8 @@
 
 #include <vector>
 
-#include "core/fxcrt/fx_memory.h"
 #include "core/fxcrt/fx_safe_types.h"
+#include "third_party/base/stl_util.h"
 
 namespace {
 
@@ -28,7 +28,7 @@
                        std::vector<JBig2ArithCtx>* context,
                        int* prev,
                        size_t depth) {
-  static const size_t kDepthEnd = FX_ArraySize(g_ArithIntDecodeData) - 1;
+  static const size_t kDepthEnd = pdfium::size(g_ArithIntDecodeData) - 1;
   if (depth == kDepthEnd)
     return kDepthEnd;
 
diff --git a/core/fxcodec/jbig2/JBig2_HuffmanTable.cpp b/core/fxcodec/jbig2/JBig2_HuffmanTable.cpp
index 547cfd4..4eb49ca 100644
--- a/core/fxcodec/jbig2/JBig2_HuffmanTable.cpp
+++ b/core/fxcodec/jbig2/JBig2_HuffmanTable.cpp
@@ -11,8 +11,8 @@
 
 #include "core/fxcodec/jbig2/JBig2_BitStream.h"
 #include "core/fxcodec/jbig2/JBig2_Context.h"
-#include "core/fxcrt/fx_memory.h"
 #include "core/fxcrt/fx_safe_types.h"
+#include "third_party/base/stl_util.h"
 
 namespace {
 
@@ -107,24 +107,24 @@
 
 constexpr HuffmanTable kHuffmanTables[16] = {
     {false, nullptr, 0},  // Zero dummy to preserve indexing.
-    {false, kTableLine1, FX_ArraySize(kTableLine1)},
-    {true, kTableLine2, FX_ArraySize(kTableLine2)},
-    {true, kTableLine3, FX_ArraySize(kTableLine3)},
-    {false, kTableLine4, FX_ArraySize(kTableLine4)},
-    {false, kTableLine5, FX_ArraySize(kTableLine5)},
-    {false, kTableLine6, FX_ArraySize(kTableLine6)},
-    {false, kTableLine7, FX_ArraySize(kTableLine7)},
-    {true, kTableLine8, FX_ArraySize(kTableLine8)},
-    {true, kTableLine9, FX_ArraySize(kTableLine9)},
-    {true, kTableLine10, FX_ArraySize(kTableLine10)},
-    {false, kTableLine11, FX_ArraySize(kTableLine11)},
-    {false, kTableLine12, FX_ArraySize(kTableLine12)},
-    {false, kTableLine13, FX_ArraySize(kTableLine13)},
-    {false, kTableLine14, FX_ArraySize(kTableLine14)},
-    {false, kTableLine15, FX_ArraySize(kTableLine15)}};
+    {false, kTableLine1, pdfium::size(kTableLine1)},
+    {true, kTableLine2, pdfium::size(kTableLine2)},
+    {true, kTableLine3, pdfium::size(kTableLine3)},
+    {false, kTableLine4, pdfium::size(kTableLine4)},
+    {false, kTableLine5, pdfium::size(kTableLine5)},
+    {false, kTableLine6, pdfium::size(kTableLine6)},
+    {false, kTableLine7, pdfium::size(kTableLine7)},
+    {true, kTableLine8, pdfium::size(kTableLine8)},
+    {true, kTableLine9, pdfium::size(kTableLine9)},
+    {true, kTableLine10, pdfium::size(kTableLine10)},
+    {false, kTableLine11, pdfium::size(kTableLine11)},
+    {false, kTableLine12, pdfium::size(kTableLine12)},
+    {false, kTableLine13, pdfium::size(kTableLine13)},
+    {false, kTableLine14, pdfium::size(kTableLine14)},
+    {false, kTableLine15, pdfium::size(kTableLine15)}};
 
 static_assert(CJBig2_HuffmanTable::kNumHuffmanTables ==
-                  FX_ArraySize(kHuffmanTables),
+                  pdfium::size(kHuffmanTables),
               "kNumHuffmanTables must be equal to the size of kHuffmanTables");
 
 }  // namespace
diff --git a/core/fxcrt/cfx_seekablestreamproxy_unittest.cpp b/core/fxcrt/cfx_seekablestreamproxy_unittest.cpp
index e91e250..2acb520 100644
--- a/core/fxcrt/cfx_seekablestreamproxy_unittest.cpp
+++ b/core/fxcrt/cfx_seekablestreamproxy_unittest.cpp
@@ -11,6 +11,7 @@
 #include "core/fxcrt/retain_ptr.h"
 #include "testing/gtest/include/gtest/gtest.h"
 #include "third_party/base/span.h"
+#include "third_party/base/stl_util.h"
 
 TEST(SeekableStreamProxyTest, NullStream) {
   auto proxy_stream = pdfium::MakeRetain<CFX_SeekableStreamProxy>(
@@ -18,7 +19,7 @@
           pdfium::make_span<const uint8_t>(nullptr, 0)));
 
   wchar_t buffer[16];
-  EXPECT_EQ(0u, proxy_stream->ReadBlock(buffer, FX_ArraySize(buffer)));
+  EXPECT_EQ(0u, proxy_stream->ReadBlock(buffer, pdfium::size(buffer)));
 }
 
 TEST(SeekableStreamProxyTest, DefaultStreamBOMNotRecognized) {
@@ -28,7 +29,7 @@
           reinterpret_cast<const uint8_t*>(data), sizeof(data) - 1)));
 
   wchar_t buffer[16];
-  EXPECT_EQ(0u, proxy_stream->ReadBlock(buffer, FX_ArraySize(buffer)));
+  EXPECT_EQ(0u, proxy_stream->ReadBlock(buffer, pdfium::size(buffer)));
 }
 
 TEST(SeekableStreamProxyTest, UTF8Stream) {
@@ -38,7 +39,7 @@
           reinterpret_cast<const uint8_t*>(data), sizeof(data) - 1)));
 
   wchar_t buffer[16];
-  EXPECT_EQ(3u, proxy_stream->ReadBlock(buffer, FX_ArraySize(buffer)));
+  EXPECT_EQ(3u, proxy_stream->ReadBlock(buffer, pdfium::size(buffer)));
   EXPECT_EQ(L'*', buffer[0]);
   EXPECT_EQ(L'\u00A2', buffer[1]);
   EXPECT_EQ(L'*', buffer[2]);
@@ -51,7 +52,7 @@
           reinterpret_cast<const uint8_t*>(data), sizeof(data) - 1)));
 
   wchar_t buffer[16];
-  EXPECT_EQ(2u, proxy_stream->ReadBlock(buffer, FX_ArraySize(buffer)));
+  EXPECT_EQ(2u, proxy_stream->ReadBlock(buffer, pdfium::size(buffer)));
   EXPECT_EQ(L'A', buffer[0]);
   EXPECT_EQ(L'\u0142', buffer[1]);
 }
@@ -63,7 +64,7 @@
           reinterpret_cast<const uint8_t*>(data), sizeof(data) - 1)));
 
   wchar_t buffer[16];
-  EXPECT_EQ(2u, proxy_stream->ReadBlock(buffer, FX_ArraySize(buffer)));
+  EXPECT_EQ(2u, proxy_stream->ReadBlock(buffer, pdfium::size(buffer)));
   EXPECT_EQ(L'A', buffer[0]);
   EXPECT_EQ(L'\u0142', buffer[1]);
 }
diff --git a/core/fxcrt/fx_coordinates.cpp b/core/fxcrt/fx_coordinates.cpp
index ccbc1f6..1395df0 100644
--- a/core/fxcrt/fx_coordinates.cpp
+++ b/core/fxcrt/fx_coordinates.cpp
@@ -10,8 +10,8 @@
 
 #include "build/build_config.h"
 #include "core/fxcrt/fx_extension.h"
-#include "core/fxcrt/fx_memory.h"
 #include "core/fxcrt/fx_safe_types.h"
+#include "third_party/base/stl_util.h"
 
 namespace {
 
@@ -413,7 +413,7 @@
   float new_left = points[0].x;
   float new_top = points[0].y;
   float new_bottom = points[0].y;
-  for (size_t i = 1; i < FX_ArraySize(points); i++) {
+  for (size_t i = 1; i < pdfium::size(points); i++) {
     new_right = std::max(new_right, points[i].x);
     new_left = std::min(new_left, points[i].x);
     new_top = std::max(new_top, points[i].y);
diff --git a/core/fxcrt/fx_extension_unittest.cpp b/core/fxcrt/fx_extension_unittest.cpp
index d4163d3..74a63f0 100644
--- a/core/fxcrt/fx_extension_unittest.cpp
+++ b/core/fxcrt/fx_extension_unittest.cpp
@@ -6,8 +6,8 @@
 
 #include <limits>
 
-#include "core/fxcrt/fx_memory.h"
 #include "testing/gtest/include/gtest/gtest.h"
+#include "third_party/base/stl_util.h"
 
 TEST(fxcrt, FXSYS_IsLowerASCII) {
   EXPECT_TRUE(FXSYS_IsLowerASCII('a'));
@@ -196,8 +196,8 @@
   const float fNan = std::numeric_limits<float>::quiet_NaN();
   const float ascending[] = {fMin, 1.0f, 2.0f, fMax, fInf, fNan};
 
-  for (size_t i = 0; i < FX_ArraySize(ascending); ++i) {
-    for (size_t j = 0; j < FX_ArraySize(ascending); ++j) {
+  for (size_t i = 0; i < pdfium::size(ascending); ++i) {
+    for (size_t j = 0; j < pdfium::size(ascending); ++j) {
       if (i == j) {
         EXPECT_TRUE(FXSYS_SafeEQ(ascending[i], ascending[j]))
             << " at " << i << " " << j;
diff --git a/core/fxcrt/fx_memory.h b/core/fxcrt/fx_memory.h
index b2f582f..ca9a08a 100644
--- a/core/fxcrt/fx_memory.h
+++ b/core/fxcrt/fx_memory.h
@@ -74,21 +74,6 @@
 
 void FX_Free(void* ptr);
 
-// The FX_ArraySize(arr) macro returns the # of elements in an array arr.
-// The expression is a compile-time constant, and therefore can be
-// used in defining new arrays, for example.  If you use FX_ArraySize on
-// a pointer by mistake, you will get a compile-time error.
-//
-// One caveat is that FX_ArraySize() doesn't accept any array of an
-// anonymous type or a type defined inside a function.
-#define FX_ArraySize(array) (sizeof(ArraySizeHelper(array)))
-
-// This template function declaration is used in defining FX_ArraySize.
-// Note that the function doesn't need an implementation, as we only
-// use its type.
-template <typename T, size_t N>
-char (&ArraySizeHelper(T (&array)[N]))[N];
-
 // Round up to the power-of-two boundary N.
 template <int N, typename T>
 inline T FxAlignToBoundary(T size) {
diff --git a/core/fxcrt/fx_string.cpp b/core/fxcrt/fx_string.cpp
index d4a6d38..4ff16ea 100644
--- a/core/fxcrt/fx_string.cpp
+++ b/core/fxcrt/fx_string.cpp
@@ -13,6 +13,7 @@
 #include "core/fxcrt/cfx_utf8encoder.h"
 #include "core/fxcrt/fx_extension.h"
 #include "third_party/base/compiler_specific.h"
+#include "third_party/base/stl_util.h"
 
 ByteString FX_UTF8Encode(WideStringView wsStr) {
   CFX_UTF8Encoder encoder;
@@ -139,7 +140,7 @@
 
 float StringToFloat(ByteStringView strc) {
   return StringTo<float>(strc, kFractionScalesFloat,
-                         FX_ArraySize(kFractionScalesFloat));
+                         pdfium::size(kFractionScalesFloat));
 }
 
 float StringToFloat(WideStringView wsStr) {
@@ -152,7 +153,7 @@
 
 double StringToDouble(ByteStringView strc) {
   return StringTo<double>(strc, kFractionScalesDouble,
-                          FX_ArraySize(kFractionScalesDouble));
+                          pdfium::size(kFractionScalesDouble));
 }
 
 double StringToDouble(WideStringView wsStr) {
diff --git a/core/fxcrt/fx_system_unittest.cpp b/core/fxcrt/fx_system_unittest.cpp
index 63bebc1..2b51c15 100644
--- a/core/fxcrt/fx_system_unittest.cpp
+++ b/core/fxcrt/fx_system_unittest.cpp
@@ -5,10 +5,10 @@
 #include <limits>
 
 #include "build/build_config.h"
-#include "core/fxcrt/fx_memory.h"
 #include "core/fxcrt/fx_string.h"
 #include "core/fxcrt/fx_system.h"
 #include "testing/gtest/include/gtest/gtest.h"
+#include "third_party/base/stl_util.h"
 
 // Unit test covering cases where PDFium replaces well-known library
 // functionality on any given platformn.
@@ -273,7 +273,7 @@
   good_time.tm_sec = 59;
 
   wchar_t buf[100] = {};
-  EXPECT_EQ(19u, FXSYS_wcsftime(buf, FX_ArraySize(buf), L"%Y-%m-%dT%H:%M:%S",
+  EXPECT_EQ(19u, FXSYS_wcsftime(buf, pdfium::size(buf), L"%Y-%m-%dT%H:%M:%S",
                                 &good_time));
   EXPECT_STREQ(L"1974-08-09T11:59:59", buf);
 
@@ -288,7 +288,7 @@
   for (int year = -2500; year <= 8500; ++year) {
     year_time.tm_year = year;
     wchar_t year_buf[100] = {};
-    FXSYS_wcsftime(year_buf, FX_ArraySize(year_buf), L"%Y-%m-%dT%H:%M:%S",
+    FXSYS_wcsftime(year_buf, pdfium::size(year_buf), L"%Y-%m-%dT%H:%M:%S",
                    &year_time);
   }
 
@@ -301,7 +301,7 @@
   bad_time.tm_min = -1;
   bad_time.tm_sec = -1;
 
-  FXSYS_wcsftime(buf, FX_ArraySize(buf), L"%y-%m-%dT%H:%M:%S", &bad_time);
+  FXSYS_wcsftime(buf, pdfium::size(buf), L"%y-%m-%dT%H:%M:%S", &bad_time);
 
   // Ensure wcsftime handles bad-ish day without crashing (Feb 30).
   struct tm feb_time = {};
@@ -312,7 +312,7 @@
   feb_time.tm_min = 00;
   feb_time.tm_sec = 00;
 
-  FXSYS_wcsftime(buf, FX_ArraySize(buf), L"%y-%m-%dT%H:%M:%S", &feb_time);
+  FXSYS_wcsftime(buf, pdfium::size(buf), L"%y-%m-%dT%H:%M:%S", &feb_time);
 }
 
 TEST(fxcrt, FXSYS_atoi) {
diff --git a/core/fxcrt/fx_unicode.cpp b/core/fxcrt/fx_unicode.cpp
index f6f102b..abcd091 100644
--- a/core/fxcrt/fx_unicode.cpp
+++ b/core/fxcrt/fx_unicode.cpp
@@ -6,7 +6,7 @@
 
 #include "core/fxcrt/fx_unicode.h"
 
-#include "core/fxcrt/fx_memory.h"
+#include "third_party/base/stl_util.h"
 
 namespace {
 
@@ -30,7 +30,7 @@
 #undef CHARPROP____
 
 constexpr size_t kTextLayoutCodePropertiesSize =
-    FX_ArraySize(kTextLayoutCodeProperties);
+    pdfium::size(kTextLayoutCodeProperties);
 
 static_assert(kTextLayoutCodePropertiesSize == 65536, "missing characters");
 
@@ -63,7 +63,7 @@
 #undef CHARPROP____
 
 constexpr size_t kExtendedTextLayoutCodePropertiesSize =
-    FX_ArraySize(kExtendedTextLayoutCodeProperties);
+    pdfium::size(kExtendedTextLayoutCodeProperties);
 
 static_assert(kExtendedTextLayoutCodePropertiesSize == 65536,
               "missing characters");
@@ -122,7 +122,7 @@
 };
 
 constexpr size_t kFXTextLayoutBidiMirrorSize =
-    FX_ArraySize(kFXTextLayoutBidiMirror);
+    pdfium::size(kFXTextLayoutBidiMirror);
 
 // Check that the mirror indicies in the fx_ucddata.inc table are in bounds.
 #undef CHARPROP____
diff --git a/core/fxcrt/widestring_unittest.cpp b/core/fxcrt/widestring_unittest.cpp
index 084393e..26ce498 100644
--- a/core/fxcrt/widestring_unittest.cpp
+++ b/core/fxcrt/widestring_unittest.cpp
@@ -9,7 +9,6 @@
 #include <vector>
 
 #include "build/build_config.h"
-#include "core/fxcrt/fx_memory.h"
 #include "core/fxcrt/fx_string.h"
 #include "testing/gtest/include/gtest/gtest.h"
 #include "third_party/base/span.h"
@@ -1108,7 +1107,7 @@
       {L"\x3132\x6162", ByteString("\x32\x31\x62\x61\0\0", 6)},
   };
 
-  for (size_t i = 0; i < FX_ArraySize(utf16le_encode_cases); ++i) {
+  for (size_t i = 0; i < pdfium::size(utf16le_encode_cases); ++i) {
     EXPECT_EQ(utf16le_encode_cases[i].bs,
               utf16le_encode_cases[i].ws.ToUTF16LE())
         << " for case number " << i;
diff --git a/core/fxge/android/cfpf_skiafontmgr.cpp b/core/fxge/android/cfpf_skiafontmgr.cpp
index 1115fbf..5f58e4b 100644
--- a/core/fxge/android/cfpf_skiafontmgr.cpp
+++ b/core/fxge/android/cfpf_skiafontmgr.cpp
@@ -11,13 +11,13 @@
 
 #include "core/fxcrt/fx_codepage.h"
 #include "core/fxcrt/fx_extension.h"
-#include "core/fxcrt/fx_memory.h"
 #include "core/fxcrt/fx_stream.h"
 #include "core/fxcrt/fx_system.h"
 #include "core/fxge/android/cfpf_skiafont.h"
 #include "core/fxge/android/cfpf_skiapathfont.h"
 #include "core/fxge/fx_font.h"
 #include "core/fxge/fx_freetype.h"
+#include "third_party/base/stl_util.h"
 
 namespace {
 
@@ -263,9 +263,9 @@
 
   uint32_t dwFaceName = FPF_SKIANormalizeFontName(bsFamilyname);
   uint32_t dwSubst = FPF_SkiaGetSubstFont(dwFaceName, g_SkiaFontmap,
-                                          FX_ArraySize(g_SkiaFontmap));
+                                          pdfium::size(g_SkiaFontmap));
   uint32_t dwSubstSans = FPF_SkiaGetSubstFont(dwFaceName, g_SkiaSansFontMap,
-                                              FX_ArraySize(g_SkiaSansFontMap));
+                                              pdfium::size(g_SkiaSansFontMap));
   bool bMaybeSymbol = FPF_SkiaMaybeSymbol(bsFamilyname);
   if (uCharset != FX_CHARSET_MSWin_Arabic &&
       FPF_SkiaMaybeArabic(bsFamilyname)) {
diff --git a/core/fxge/cfx_folderfontinfo.cpp b/core/fxge/cfx_folderfontinfo.cpp
index 6b659ba..75c4de9 100644
--- a/core/fxge/cfx_folderfontinfo.cpp
+++ b/core/fxge/cfx_folderfontinfo.cpp
@@ -285,7 +285,7 @@
 }
 
 void* CFX_FolderFontInfo::GetSubstFont(const ByteString& face) {
-  for (size_t iBaseFont = 0; iBaseFont < FX_ArraySize(Base14Substs);
+  for (size_t iBaseFont = 0; iBaseFont < pdfium::size(Base14Substs);
        iBaseFont++) {
     if (face == Base14Substs[iBaseFont].m_pName)
       return GetFont(Base14Substs[iBaseFont].m_pSubstName);
diff --git a/core/fxge/cfx_fontmapper.cpp b/core/fxge/cfx_fontmapper.cpp
index da133d9..576b704 100644
--- a/core/fxge/cfx_fontmapper.cpp
+++ b/core/fxge/cfx_fontmapper.cpp
@@ -225,7 +225,7 @@
   if (bsStyle.IsEmpty())
     return std::make_tuple(false, FXFONT_NORMAL, 0);
 
-  for (int i = FX_ArraySize(g_FontStyles) - 1; i >= 0; --i) {
+  for (int i = pdfium::size(g_FontStyles) - 1; i >= 0; --i) {
     const FX_FontStyle* pStyle = g_FontStyles + i;
     if (!pStyle || pStyle->len > bsStyle.GetLength())
       continue;
diff --git a/core/fxge/cfx_fontmgr.cpp b/core/fxge/cfx_fontmgr.cpp
index b585cf1..e90910a 100644
--- a/core/fxge/cfx_fontmgr.cpp
+++ b/core/fxge/cfx_fontmgr.cpp
@@ -15,6 +15,7 @@
 #include "core/fxge/fontdata/chromefontdata/chromefontdata.h"
 #include "core/fxge/fx_font.h"
 #include "core/fxge/systemfontinfo_iface.h"
+#include "third_party/base/stl_util.h"
 
 namespace {
 
@@ -74,12 +75,12 @@
 CFX_FontMgr::FontDesc::~FontDesc() = default;
 
 void CFX_FontMgr::FontDesc::SetFace(size_t index, CFX_Face* face) {
-  ASSERT(index < FX_ArraySize(m_TTCFaces));
+  ASSERT(index < pdfium::size(m_TTCFaces));
   m_TTCFaces[index].Reset(face);
 }
 
 CFX_Face* CFX_FontMgr::FontDesc::GetFace(size_t index) const {
-  ASSERT(index < FX_ArraySize(m_TTCFaces));
+  ASSERT(index < pdfium::size(m_TTCFaces));
   return m_TTCFaces[index].Get();
 }
 
@@ -160,12 +161,12 @@
 // static
 Optional<pdfium::span<const uint8_t>> CFX_FontMgr::GetBuiltinFont(
     size_t index) {
-  if (index < FX_ArraySize(g_FoxitFonts)) {
+  if (index < pdfium::size(g_FoxitFonts)) {
     return pdfium::make_span(g_FoxitFonts[index].m_pFontData,
                              g_FoxitFonts[index].m_dwSize);
   }
-  size_t mm_index = index - FX_ArraySize(g_FoxitFonts);
-  if (mm_index < FX_ArraySize(g_MMFonts)) {
+  size_t mm_index = index - pdfium::size(g_FoxitFonts);
+  if (mm_index < pdfium::size(g_MMFonts)) {
     return pdfium::make_span(g_MMFonts[mm_index].m_pFontData,
                              g_MMFonts[mm_index].m_dwSize);
   }
diff --git a/core/fxge/dib/cfx_dibbase.cpp b/core/fxge/dib/cfx_dibbase.cpp
index 2ad7465..32a73f0 100644
--- a/core/fxge/dib/cfx_dibbase.cpp
+++ b/core/fxge/dib/cfx_dibbase.cpp
@@ -11,6 +11,7 @@
 #include <utility>
 #include <vector>
 
+#include "core/fxcrt/fx_memory.h"
 #include "core/fxcrt/fx_safe_types.h"
 #include "core/fxge/cfx_cliprgn.h"
 #include "core/fxge/dib/cfx_bitmapstorer.h"
@@ -19,6 +20,7 @@
 #include "core/fxge/dib/cfx_imagestretcher.h"
 #include "core/fxge/dib/cfx_imagetransformer.h"
 #include "third_party/base/logging.h"
+#include "third_party/base/stl_util.h"
 
 namespace {
 
@@ -191,14 +193,14 @@
     uint8_t r;
     uint8_t g;
     uint8_t b;
-    for (size_t i = 0; i < FX_ArraySize(gray); ++i) {
+    for (size_t i = 0; i < pdfium::size(gray); ++i) {
       std::tie(r, g, b) = AdobeCMYK_to_sRGB1(
           FXSYS_GetCValue(src_plt[i]), FXSYS_GetMValue(src_plt[i]),
           FXSYS_GetYValue(src_plt[i]), FXSYS_GetKValue(src_plt[i]));
       gray[i] = FXRGB2GRAY(r, g, b);
     }
   } else {
-    for (size_t i = 0; i < FX_ArraySize(gray); ++i) {
+    for (size_t i = 0; i < pdfium::size(gray); ++i) {
       gray[i] = FXRGB2GRAY(FXARGB_R(src_plt[i]), FXARGB_G(src_plt[i]),
                            FXARGB_B(src_plt[i]));
     }
diff --git a/core/fxge/dib/cfx_imagetransformer.cpp b/core/fxge/dib/cfx_imagetransformer.cpp
index bc0c778..79044dc 100644
--- a/core/fxge/dib/cfx_imagetransformer.cpp
+++ b/core/fxge/dib/cfx_imagetransformer.cpp
@@ -514,13 +514,13 @@
   uint32_t argb[256];
   FX_ARGB* pPal = m_Storer.GetBitmap()->GetPalette();
   if (pPal) {
-    for (size_t i = 0; i < FX_ArraySize(argb); i++)
+    for (size_t i = 0; i < pdfium::size(argb); i++)
       argb[i] = pPal[i];
   } else if (m_Storer.GetBitmap()->IsCmykImage()) {
-    for (size_t i = 0; i < FX_ArraySize(argb); i++)
+    for (size_t i = 0; i < pdfium::size(argb); i++)
       argb[i] = 255 - i;
   } else {
-    for (size_t i = 0; i < FX_ArraySize(argb); i++)
+    for (size_t i = 0; i < pdfium::size(argb); i++)
       argb[i] = 0xff000000 | (i * 0x010101);
   }
   int destBpp = cdata.bitmap->GetBPP() / 8;
diff --git a/core/fxge/fx_ge_linux.cpp b/core/fxge/fx_ge_linux.cpp
index c76c99d..68c704c 100644
--- a/core/fxge/fx_ge_linux.cpp
+++ b/core/fxge/fx_ge_linux.cpp
@@ -13,6 +13,7 @@
 #include "core/fxge/cfx_gemodule.h"
 #include "core/fxge/fx_font.h"
 #include "core/fxge/systemfontinfo_iface.h"
+#include "third_party/base/stl_util.h"
 
 #if _FX_PLATFORM_ == _FX_PLATFORM_LINUX_
 namespace {
@@ -100,7 +101,7 @@
   switch (charset) {
     case FX_CHARSET_ShiftJIS: {
       uint8_t index = GetJapanesePreference(family, weight, pitch_family);
-      ASSERT(index < FX_ArraySize(g_LinuxJpFontList));
+      ASSERT(index < pdfium::size(g_LinuxJpFontList));
       for (const char* name : g_LinuxJpFontList[index]) {
         auto it = m_FontList.find(name);
         if (it != m_FontList.end())
diff --git a/core/fxge/win32/fx_win32_device.cpp b/core/fxge/win32/fx_win32_device.cpp
index 3fe4a50..4aca5c4 100644
--- a/core/fxge/win32/fx_win32_device.cpp
+++ b/core/fxge/win32/fx_win32_device.cpp
@@ -11,7 +11,6 @@
 #include <vector>
 
 #include "core/fxcrt/fx_codepage.h"
-#include "core/fxcrt/fx_memory.h"
 #include "core/fxcrt/fx_system.h"
 #include "core/fxcrt/maybe_owned.h"
 #include "core/fxge/cfx_folderfontinfo.h"
@@ -28,6 +27,7 @@
 #include "core/fxge/win32/win32_int.h"
 #include "third_party/base/ptr_util.h"
 #include "third_party/base/span.h"
+#include "third_party/base/stl_util.h"
 #include "third_party/base/win/win_util.h"
 
 #ifndef _SKIA_SUPPORT_
@@ -73,7 +73,7 @@
 };
 
 bool GetSubFontName(ByteString* name) {
-  for (size_t i = 0; i < FX_ArraySize(g_JpFontNameMap); ++i) {
+  for (size_t i = 0; i < pdfium::size(g_JpFontNameMap); ++i) {
     if (!FXSYS_stricmp(name->c_str(), g_JpFontNameMap[i].m_pSrcFontName)) {
       *name = g_JpFontNameMap[i].m_pSubFontName;
       return true;
@@ -583,7 +583,7 @@
     return hFont;
 
   WideString wsFace = WideString::FromDefANSI(facebuf);
-  for (size_t i = 0; i < FX_ArraySize(g_VariantNames); ++i) {
+  for (size_t i = 0; i < pdfium::size(g_VariantNames); ++i) {
     if (face != g_VariantNames[i].m_pFaceName)
       continue;
 
diff --git a/core/fxge/win32/fx_win32_gdipext.cpp b/core/fxge/win32/fx_win32_gdipext.cpp
index 1743155..20cf77f 100644
--- a/core/fxge/win32/fx_win32_gdipext.cpp
+++ b/core/fxge/win32/fx_win32_gdipext.cpp
@@ -14,6 +14,7 @@
 #include <utility>
 #include <vector>
 
+#include "core/fxcrt/fx_memory.h"
 #include "core/fxcrt/fx_system.h"
 #include "core/fxge/cfx_gemodule.h"
 #include "core/fxge/cfx_graphstatedata.h"
@@ -21,6 +22,7 @@
 #include "core/fxge/win32/cfx_windowsdib.h"
 #include "core/fxge/win32/win32_int.h"
 #include "third_party/base/span.h"
+#include "third_party/base/stl_util.h"
 
 // Has to come before gdiplus.h
 namespace Gdiplus {
@@ -125,7 +127,7 @@
     "GdipSetWorldTransform",
     "GdipSetPixelOffsetMode",
 };
-static_assert(FX_ArraySize(g_GdipFuncNames) ==
+static_assert(pdfium::size(g_GdipFuncNames) ==
                   static_cast<size_t>(FuncId_GdipSetPixelOffsetMode) + 1,
               "g_GdipFuncNames has wrong size");
 
@@ -489,7 +491,7 @@
     pdfium::span<const Gdiplus::PointF> points,
     const CFX_Matrix* pMatrix) {
   static constexpr size_t kPairs[3][2] = {{1, 2}, {0, 2}, {0, 1}};
-  for (size_t i = 0; i < FX_ArraySize(kPairs); ++i) {
+  for (size_t i = 0; i < pdfium::size(kPairs); ++i) {
     size_t pair1 = kPairs[i][0];
     size_t pair2 = kPairs[i][1];
 
@@ -760,8 +762,8 @@
   if (!m_hModule)
     return;
 
-  m_Functions.resize(FX_ArraySize(g_GdipFuncNames));
-  for (size_t i = 0; i < FX_ArraySize(g_GdipFuncNames); ++i) {
+  m_Functions.resize(pdfium::size(g_GdipFuncNames));
+  for (size_t i = 0; i < pdfium::size(g_GdipFuncNames); ++i) {
     m_Functions[i] = GetProcAddress(m_hModule, g_GdipFuncNames[i]);
     if (!m_Functions[i]) {
       m_hModule = nullptr;