Start using C++17. - Replace pdfium::size() with std::size(). - Update README.md. Bug: pdfium:1766,pdfium:1780 Change-Id: Ie4dae21ec7da78cc32dab52f3580d6c94a9fa586 Reviewed-on: https://pdfium-review.googlesource.com/c/pdfium/+/92790 Reviewed-by: Tom Sepez <tsepez@chromium.org> Commit-Queue: Lei Zhang <thestig@chromium.org>
diff --git a/README.md b/README.md index 286bda8..4db2bd1 100644 --- a/README.md +++ b/README.md
@@ -95,8 +95,7 @@ For sample applications like `pdfium_test` to build, one must set `pdf_is_standalone = true`. -By default, the entire project builds with C++14. When building with the -experimental Skia backend, Skia itself it built with C++17. +By default, the entire project builds with C++17. When complete the arguments will be stored in `<directory>/args.gn`, and GN will automatically use the new arguments to generate build files.
diff --git a/core/fdrm/fx_crypt_unittest.cpp b/core/fdrm/fx_crypt_unittest.cpp index 28035c6..4fce87e 100644 --- a/core/fdrm/fx_crypt_unittest.cpp +++ b/core/fdrm/fx_crypt_unittest.cpp
@@ -10,7 +10,6 @@ #include "testing/gtest/include/gtest/gtest.h" #include "testing/utils/hash.h" -#include "third_party/base/cxx17_backports.h" namespace { @@ -200,7 +199,7 @@ CRYPT_SHA1Generate(reinterpret_cast<const uint8_t*>(kInput), strlen(kInput), actual); - for (size_t i = 0; i < pdfium::size(kExpected); i++) + for (size_t i = 0; i < std::size(kExpected); i++) EXPECT_EQ(kExpected[i], actual[i]) << " at byte " << i; } @@ -215,7 +214,7 @@ CRYPT_SHA1Generate(reinterpret_cast<const uint8_t*>(kInput), strlen(kInput), actual); - for (size_t i = 0; i < pdfium::size(kExpected); i++) + for (size_t i = 0; i < std::size(kExpected); i++) EXPECT_EQ(kExpected[i], actual[i]) << " at byte " << i; } @@ -231,7 +230,7 @@ CRYPT_SHA1Generate(reinterpret_cast<const uint8_t*>(kInput), strlen(kInput), actual); - for (size_t i = 0; i < pdfium::size(kExpected); i++) + for (size_t i = 0; i < std::size(kExpected); i++) EXPECT_EQ(kExpected[i], actual[i]) << " at byte " << i; } @@ -244,7 +243,7 @@ uint8_t actual[32]; CRYPT_SHA256Generate(reinterpret_cast<const uint8_t*>(kInput), strlen(kInput), actual); - for (size_t i = 0; i < pdfium::size(kExpected); ++i) + for (size_t i = 0; i < std::size(kExpected); ++i) EXPECT_EQ(kExpected[i], actual[i]) << " at byte " << i; } @@ -258,7 +257,7 @@ uint8_t actual[32]; CRYPT_SHA256Generate(reinterpret_cast<const uint8_t*>(kInput), strlen(kInput), actual); - for (size_t i = 0; i < pdfium::size(kExpected); ++i) + for (size_t i = 0; i < std::size(kExpected); ++i) EXPECT_EQ(kExpected[i], actual[i]) << " at byte " << i; } @@ -273,7 +272,7 @@ uint8_t actual[32]; CRYPT_SHA256Generate(reinterpret_cast<const uint8_t*>(kInput), strlen(kInput), actual); - for (size_t i = 0; i < pdfium::size(kExpected); ++i) + for (size_t i = 0; i < std::size(kExpected); ++i) EXPECT_EQ(kExpected[i], actual[i]) << " at byte " << i; } @@ -330,7 +329,7 @@ 72, 115, 0, 47, 94, 29, 45, 14, 111}; CRYPT_rc4_context context; static const uint8_t kFooBar[] = "foobar"; - CRYPT_ArcFourSetup(&context, {kFooBar, pdfium::size(kFooBar) - 1}); + CRYPT_ArcFourSetup(&context, {kFooBar, std::size(kFooBar) - 1}); CheckArcFourContext(context, 0, 0, kFoobarPermutation); } } @@ -348,18 +347,18 @@ CRYPT_rc4_context context; CRYPT_ArcFourSetup(&context, {}); - uint8_t data_short[pdfium::size(kDataShort)]; - memcpy(data_short, kDataShort, pdfium::size(kDataShort)); + uint8_t data_short[std::size(kDataShort)]; + memcpy(data_short, kDataShort, std::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( - pdfium::size(kExpectedEncryptedDataShort) == pdfium::size(data_short), + std::size(kExpectedEncryptedDataShort) == std::size(data_short), "data_short mismatch"); CRYPT_ArcFourCrypt(&context, data_short); - for (size_t i = 0; i < pdfium::size(data_short); ++i) + for (size_t i = 0; i < std::size(data_short); ++i) EXPECT_EQ(kExpectedEncryptedDataShort[i], data_short[i]) << i; static const uint8_t kPermutation[CRYPT_rc4_context::kPermutationLength] = { @@ -388,8 +387,8 @@ CRYPT_rc4_context context; CRYPT_ArcFourSetup(&context, {}); - uint8_t data_long[pdfium::size(kDataLong)]; - memcpy(data_long, kDataLong, pdfium::size(kDataLong)); + uint8_t data_long[std::size(kDataLong)]; + memcpy(data_long, kDataLong, std::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, @@ -411,12 +410,11 @@ 208, 161, 105, 226, 164, 114, 80, 137, 58, 107, 109, 42, 110, 100, 202, 170, 224, 89, 28, 5, 138, 19, 253, 105, 220, 105, 24, 187, 109, 89, 205, 89, 202}; - static_assert( - pdfium::size(kExpectedEncryptedDataLong) == pdfium::size(data_long), - "data_long mismatch"); - static_assert(pdfium::size(data_long) > 256, "too short"); + static_assert(std::size(kExpectedEncryptedDataLong) == std::size(data_long), + "data_long mismatch"); + static_assert(std::size(data_long) > 256, "too short"); CRYPT_ArcFourCrypt(&context, data_long); - for (size_t i = 0; i < pdfium::size(data_long); ++i) + for (size_t i = 0; i < std::size(data_long); ++i) EXPECT_EQ(kExpectedEncryptedDataLong[i], data_long[i]) << i; static const uint8_t kPermutation[CRYPT_rc4_context::kPermutationLength] = { @@ -444,20 +442,20 @@ { CRYPT_rc4_context context; static const uint8_t kFooBar[] = "foobar"; - CRYPT_ArcFourSetup(&context, {kFooBar, pdfium::size(kFooBar) - 1}); + CRYPT_ArcFourSetup(&context, {kFooBar, std::size(kFooBar) - 1}); - uint8_t data_short[pdfium::size(kDataShort)]; - memcpy(data_short, kDataShort, pdfium::size(kDataShort)); + uint8_t data_short[std::size(kDataShort)]; + memcpy(data_short, kDataShort, std::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( - pdfium::size(kExpectedEncryptedDataShort) == pdfium::size(data_short), + std::size(kExpectedEncryptedDataShort) == std::size(data_short), "data_short mismatch"); CRYPT_ArcFourCrypt(&context, data_short); - for (size_t i = 0; i < pdfium::size(data_short); ++i) + for (size_t i = 0; i < std::size(data_short); ++i) EXPECT_EQ(kExpectedEncryptedDataShort[i], data_short[i]) << i; static const uint8_t kPermutation[CRYPT_rc4_context::kPermutationLength] = { @@ -485,10 +483,10 @@ { CRYPT_rc4_context context; static const uint8_t kFooBar[] = "foobar"; - CRYPT_ArcFourSetup(&context, {kFooBar, pdfium::size(kFooBar) - 1}); + CRYPT_ArcFourSetup(&context, {kFooBar, std::size(kFooBar) - 1}); - uint8_t data_long[pdfium::size(kDataLong)]; - memcpy(data_long, kDataLong, pdfium::size(kDataLong)); + uint8_t data_long[std::size(kDataLong)]; + memcpy(data_long, kDataLong, std::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, @@ -510,12 +508,11 @@ 22, 110, 43, 56, 94, 127, 48, 96, 47, 172, 3, 31, 130, 249, 243, 73, 206, 89, 9, 93, 156, 167, 205, 166, 75, 227, 36, 34, 81, 124, 195, 246, 152}; - static_assert( - pdfium::size(kExpectedEncryptedDataLong) == pdfium::size(data_long), - "data_long mismatch"); - static_assert(pdfium::size(data_long) > 256, "too short"); + static_assert(std::size(kExpectedEncryptedDataLong) == std::size(data_long), + "data_long mismatch"); + static_assert(std::size(data_long) > 256, "too short"); CRYPT_ArcFourCrypt(&context, data_long); - for (size_t i = 0; i < pdfium::size(data_long); ++i) + for (size_t i = 0; i < std::size(data_long); ++i) EXPECT_EQ(kExpectedEncryptedDataLong[i], data_long[i]) << i; static const uint8_t kPermutation[CRYPT_rc4_context::kPermutationLength] = { @@ -552,7 +549,7 @@ uint8_t actual[48]; CRYPT_SHA384Generate(reinterpret_cast<const uint8_t*>(kInput), strlen(kInput), actual); - for (size_t i = 0; i < pdfium::size(kExpected); ++i) + for (size_t i = 0; i < std::size(kExpected); ++i) EXPECT_EQ(kExpected[i], actual[i]) << " at byte " << i; } @@ -568,7 +565,7 @@ uint8_t actual[48]; CRYPT_SHA384Generate(reinterpret_cast<const uint8_t*>(kInput), strlen(kInput), actual); - for (size_t i = 0; i < pdfium::size(kExpected); ++i) + for (size_t i = 0; i < std::size(kExpected); ++i) EXPECT_EQ(kExpected[i], actual[i]) << " at byte " << i; } @@ -586,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 < pdfium::size(kExpected); ++i) + for (size_t i = 0; i < std::size(kExpected); ++i) EXPECT_EQ(kExpected[i], actual[i]) << " at byte " << i; } @@ -602,7 +599,7 @@ uint8_t actual[64]; CRYPT_SHA512Generate(reinterpret_cast<const uint8_t*>(kInput), strlen(kInput), actual); - for (size_t i = 0; i < pdfium::size(kExpected); ++i) + for (size_t i = 0; i < std::size(kExpected); ++i) EXPECT_EQ(kExpected[i], actual[i]) << " at byte " << i; } @@ -620,7 +617,7 @@ uint8_t actual[64]; CRYPT_SHA512Generate(reinterpret_cast<const uint8_t*>(kInput), strlen(kInput), actual); - for (size_t i = 0; i < pdfium::size(kExpected); ++i) + for (size_t i = 0; i < std::size(kExpected); ++i) EXPECT_EQ(kExpected[i], actual[i]) << " at byte " << i; } @@ -640,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 < pdfium::size(kExpected); ++i) + for (size_t i = 0; i < std::size(kExpected); ++i) EXPECT_EQ(kExpected[i], actual[i]) << " at byte " << i; }
diff --git a/core/fpdfapi/cmaps/CNS1/cmaps_cns1.cpp b/core/fpdfapi/cmaps/CNS1/cmaps_cns1.cpp index 65abefb..8c5a3c9 100644 --- a/core/fpdfapi/cmaps/CNS1/cmaps_cns1.cpp +++ b/core/fpdfapi/cmaps/CNS1/cmaps_cns1.cpp
@@ -6,7 +6,7 @@ #include "core/fpdfapi/cmaps/CNS1/cmaps_cns1.h" -#include "third_party/base/cxx17_backports.h" +#include <iterator> const FXCMAP_CMap kFXCMAP_CNS1_cmaps[] = { {"B5pc-H", kFXCMAP_B5pc_H_0, nullptr, 247, 0, FXCMAP_CMap::Range, 0}, @@ -35,4 +35,4 @@ FXCMAP_CMap::Range, -1}, }; -const size_t kFXCMAP_CNS1_cmaps_size = pdfium::size(kFXCMAP_CNS1_cmaps); +const size_t kFXCMAP_CNS1_cmaps_size = std::size(kFXCMAP_CNS1_cmaps);
diff --git a/core/fpdfapi/cmaps/GB1/cmaps_gb1.cpp b/core/fpdfapi/cmaps/GB1/cmaps_gb1.cpp index 62634ae..3419ae8 100644 --- a/core/fpdfapi/cmaps/GB1/cmaps_gb1.cpp +++ b/core/fpdfapi/cmaps/GB1/cmaps_gb1.cpp
@@ -6,7 +6,7 @@ #include "core/fpdfapi/cmaps/GB1/cmaps_gb1.h" -#include "third_party/base/cxx17_backports.h" +#include <iterator> const FXCMAP_CMap kFXCMAP_GB1_cmaps[] = { {"GB-EUC-H", kFXCMAP_GB_EUC_H_0, nullptr, 90, 0, FXCMAP_CMap::Range, 0}, @@ -33,4 +33,4 @@ FXCMAP_CMap::Range, -1}, }; -const size_t kFXCMAP_GB1_cmaps_size = pdfium::size(kFXCMAP_GB1_cmaps); +const size_t kFXCMAP_GB1_cmaps_size = std::size(kFXCMAP_GB1_cmaps);
diff --git a/core/fpdfapi/cmaps/Japan1/cmaps_japan1.cpp b/core/fpdfapi/cmaps/Japan1/cmaps_japan1.cpp index 0e6828e..8c0a84a 100644 --- a/core/fpdfapi/cmaps/Japan1/cmaps_japan1.cpp +++ b/core/fpdfapi/cmaps/Japan1/cmaps_japan1.cpp
@@ -6,7 +6,7 @@ #include "core/fpdfapi/cmaps/Japan1/cmaps_japan1.h" -#include "third_party/base/cxx17_backports.h" +#include <iterator> const FXCMAP_CMap kFXCMAP_Japan1_cmaps[] = { {"83pv-RKSJ-H", kFXCMAP_83pv_RKSJ_H_1, nullptr, 222, 0, FXCMAP_CMap::Range, @@ -47,4 +47,4 @@ FXCMAP_CMap::Single, -1}, }; -const size_t kFXCMAP_Japan1_cmaps_size = pdfium::size(kFXCMAP_Japan1_cmaps); +const size_t kFXCMAP_Japan1_cmaps_size = std::size(kFXCMAP_Japan1_cmaps);
diff --git a/core/fpdfapi/cmaps/Korea1/cmaps_korea1.cpp b/core/fpdfapi/cmaps/Korea1/cmaps_korea1.cpp index 2fefb3e..d4f85c9 100644 --- a/core/fpdfapi/cmaps/Korea1/cmaps_korea1.cpp +++ b/core/fpdfapi/cmaps/Korea1/cmaps_korea1.cpp
@@ -6,7 +6,7 @@ #include "core/fpdfapi/cmaps/Korea1/cmaps_korea1.h" -#include "third_party/base/cxx17_backports.h" +#include <iterator> const FXCMAP_CMap kFXCMAP_Korea1_cmaps[] = { {"KSC-EUC-H", kFXCMAP_KSC_EUC_H_0, nullptr, 467, 0, FXCMAP_CMap::Range, 0}, @@ -31,4 +31,4 @@ FXCMAP_CMap::Range, -1}, }; -const size_t kFXCMAP_Korea1_cmaps_size = pdfium::size(kFXCMAP_Korea1_cmaps); +const size_t kFXCMAP_Korea1_cmaps_size = std::size(kFXCMAP_Korea1_cmaps);
diff --git a/core/fpdfapi/edit/cpdf_pagecontentgenerator_unittest.cpp b/core/fpdfapi/edit/cpdf_pagecontentgenerator_unittest.cpp index c34138d..55e8bd1 100644 --- a/core/fpdfapi/edit/cpdf_pagecontentgenerator_unittest.cpp +++ b/core/fpdfapi/edit/cpdf_pagecontentgenerator_unittest.cpp
@@ -4,6 +4,7 @@ #include "core/fpdfapi/edit/cpdf_pagecontentgenerator.h" +#include <iterator> #include <memory> #include <utility> @@ -26,7 +27,6 @@ #include "core/fxcrt/fx_memory_wrappers.h" #include "core/fxge/cfx_fillrenderoptions.h" #include "testing/gtest/include/gtest/gtest.h" -#include "third_party/base/cxx17_backports.h" class CPDF_PageContentGeneratorTest : public TestWithPageModule { protected: @@ -411,7 +411,7 @@ const char content[] = "q 1 0 0 1 0 0 cm 3.102 4.6700001 m 5.4500012 .28999999 " "l 4.2399998 3.1499999 4.65 2.98 3.456 0.24 c 3.102 4.6700001 l h f Q\n"; - size_t buf_len = pdfium::size(content); + size_t buf_len = std::size(content); std::unique_ptr<uint8_t, FxFreeDeleter> buf(FX_AllocUninit(uint8_t, buf_len)); memcpy(buf.get(), content, buf_len); auto pStream = pdfium::MakeRetain<CPDF_Stream>(std::move(buf), buf_len,
diff --git a/core/fpdfapi/font/cfx_stockfontarray.cpp b/core/fpdfapi/font/cfx_stockfontarray.cpp index 50fc1ef..adc7069 100644 --- a/core/fpdfapi/font/cfx_stockfontarray.cpp +++ b/core/fpdfapi/font/cfx_stockfontarray.cpp
@@ -6,15 +6,16 @@ #include "core/fpdfapi/font/cfx_stockfontarray.h" +#include <iterator> + #include "core/fpdfapi/font/cpdf_font.h" #include "core/fpdfapi/parser/cpdf_dictionary.h" -#include "third_party/base/cxx17_backports.h" #include "third_party/base/notreached.h" CFX_StockFontArray::CFX_StockFontArray() = default; CFX_StockFontArray::~CFX_StockFontArray() { - for (size_t i = 0; i < pdfium::size(m_StockFonts); ++i) { + for (size_t i = 0; i < std::size(m_StockFonts); ++i) { if (m_StockFonts[i]) { RetainPtr<CPDF_Dictionary> destroy(m_StockFonts[i]->GetFontDict()); m_StockFonts[i]->ClearFontDict(); @@ -24,7 +25,7 @@ RetainPtr<CPDF_Font> CFX_StockFontArray::GetFont( CFX_FontMapper::StandardFont index) const { - if (index < pdfium::size(m_StockFonts)) + if (index < std::size(m_StockFonts)) return m_StockFonts[index]; NOTREACHED(); return nullptr; @@ -32,6 +33,6 @@ void CFX_StockFontArray::SetFont(CFX_FontMapper::StandardFont index, const RetainPtr<CPDF_Font>& pFont) { - if (index < pdfium::size(m_StockFonts)) + if (index < std::size(m_StockFonts)) m_StockFonts[index] = pFont; }
diff --git a/core/fpdfapi/font/cpdf_cidfont.cpp b/core/fpdfapi/font/cpdf_cidfont.cpp index 134f245..d8988b7 100644 --- a/core/fpdfapi/font/cpdf_cidfont.cpp +++ b/core/fpdfapi/font/cpdf_cidfont.cpp
@@ -277,7 +277,7 @@ CPDF_CIDFont::CPDF_CIDFont(CPDF_Document* pDocument, CPDF_Dictionary* pFontDict) : CPDF_Font(pDocument, pFontDict) { - for (size_t i = 0; i < pdfium::size(m_CharBBox); ++i) + for (size_t i = 0; i < std::size(m_CharBBox); ++i) m_CharBBox[i] = FX_RECT(-1, -1, -1, -1); } @@ -869,7 +869,7 @@ if (m_Charset != CIDSET_JAPAN1 || m_pFontFile) return nullptr; - const auto* pEnd = kJapan1VerticalCIDs + pdfium::size(kJapan1VerticalCIDs); + const auto* pEnd = kJapan1VerticalCIDs + std::size(kJapan1VerticalCIDs); const auto* pTransform = std::lower_bound( kJapan1VerticalCIDs, pEnd, cid, [](const CIDTransform& entry, uint16_t cid) { return entry.cid < cid; });
diff --git a/core/fpdfapi/font/cpdf_cmapparser.cpp b/core/fpdfapi/font/cpdf_cmapparser.cpp index 8f0a5fc..e772a54 100644 --- a/core/fpdfapi/font/cpdf_cmapparser.cpp +++ b/core/fpdfapi/font/cpdf_cmapparser.cpp
@@ -8,6 +8,8 @@ #include <ctype.h> +#include <iterator> + #include "core/fpdfapi/cmaps/fpdf_cmaps.h" #include "core/fpdfapi/parser/cpdf_array.h" #include "core/fpdfapi/parser/cpdf_dictionary.h" @@ -16,7 +18,6 @@ #include "core/fxcrt/fx_safe_types.h" #include "core/fxge/fx_freetype.h" #include "third_party/base/check.h" -#include "third_party/base/cxx17_backports.h" namespace { @@ -204,10 +205,10 @@ CIDSet CPDF_CMapParser::CharsetFromOrdering(ByteStringView ordering) { static const char* const kCharsetNames[CIDSET_NUM_SETS] = { nullptr, "GB1", "CNS1", "Japan1", "Korea1", "UCS"}; - static_assert(pdfium::size(kCharsetNames) == CIDSET_NUM_SETS, + static_assert(std::size(kCharsetNames) == CIDSET_NUM_SETS, "Too many CID sets"); - for (size_t charset = 1; charset < pdfium::size(kCharsetNames); ++charset) { + for (size_t charset = 1; charset < std::size(kCharsetNames); ++charset) { if (ordering == kCharsetNames[charset]) return static_cast<CIDSet>(charset); }
diff --git a/core/fpdfapi/font/cpdf_font.cpp b/core/fpdfapi/font/cpdf_font.cpp index 3aac938..9161023 100644 --- a/core/fpdfapi/font/cpdf_font.cpp +++ b/core/fpdfapi/font/cpdf_font.cpp
@@ -33,7 +33,6 @@ #include "core/fxge/fx_font.h" #include "core/fxge/fx_freetype.h" #include "third_party/base/check.h" -#include "third_party/base/cxx17_backports.h" #include "third_party/base/numerics/safe_conversions.h" namespace { @@ -309,7 +308,7 @@ RetainPtr<CPDF_Font> pFont; if (type == "TrueType") { ByteString tag = pFontDict->GetStringFor("BaseFont").First(4); - for (size_t i = 0; i < pdfium::size(kChineseFontNames); ++i) { + for (size_t i = 0; i < std::size(kChineseFontNames); ++i) { if (tag == ByteString(kChineseFontNames[i], kChineseFontNameSize)) { const CPDF_Dictionary* pFontDesc = pFontDict->GetDictFor("FontDescriptor");
diff --git a/core/fpdfapi/font/cpdf_fontencoding.cpp b/core/fpdfapi/font/cpdf_fontencoding.cpp index b4d3ca3..2d30ada 100644 --- a/core/fpdfapi/font/cpdf_fontencoding.cpp +++ b/core/fpdfapi/font/cpdf_fontencoding.cpp
@@ -6,6 +6,8 @@ #include "core/fpdfapi/font/cpdf_fontencoding.h" +#include <iterator> + #include "constants/font_encodings.h" #include "core/fpdfapi/parser/cpdf_array.h" #include "core/fpdfapi/parser/cpdf_dictionary.h" @@ -15,7 +17,6 @@ #include "core/fxge/fx_font.h" #include "core/fxge/fx_freetype.h" #include "third_party/abseil-cpp/absl/types/optional.h" -#include "third_party/base/cxx17_backports.h" #include "third_party/base/notreached.h" namespace { @@ -1657,7 +1658,7 @@ } // namespace int CPDF_FontEncoding::CharCodeFromUnicode(wchar_t unicode) const { - for (size_t i = 0; i < pdfium::size(m_Unicodes); i++) { + for (size_t i = 0; i < std::size(m_Unicodes); i++) { if (m_Unicodes[i] == unicode) return static_cast<int>(i); } @@ -1667,7 +1668,7 @@ CPDF_FontEncoding::CPDF_FontEncoding(FontEncoding predefined_encoding) { const uint16_t* pSrc = UnicodesForPredefinedCharSet(predefined_encoding); if (pSrc) { - for (size_t i = 0; i < pdfium::size(m_Unicodes); i++) + for (size_t i = 0; i < std::size(m_Unicodes); i++) m_Unicodes[i] = pSrc[i]; } else { memset(m_Unicodes, 0, sizeof(m_Unicodes)); @@ -1690,7 +1691,7 @@ for (FontEncoding cs : kEncodings) { const uint16_t* pSrc = UnicodesForPredefinedCharSet(cs); bool match = true; - for (size_t i = 0; i < pdfium::size(m_Unicodes); i++) { + for (size_t i = 0; i < std::size(m_Unicodes); i++) { if (m_Unicodes[i] != pSrc[i]) { match = false; break; @@ -1717,7 +1718,7 @@ const uint16_t* pStandard = UnicodesForPredefinedCharSet(FontEncoding::kWinAnsi); auto pDiff = pdfium::MakeRetain<CPDF_Array>(); - for (size_t i = 0; i < pdfium::size(m_Unicodes); i++) { + for (size_t i = 0; i < std::size(m_Unicodes); i++) { if (pStandard[i] == m_Unicodes[i]) continue;
diff --git a/core/fpdfapi/font/cpdf_simplefont.cpp b/core/fpdfapi/font/cpdf_simplefont.cpp index 39fb2af..a02b32b 100644 --- a/core/fpdfapi/font/cpdf_simplefont.cpp +++ b/core/fpdfapi/font/cpdf_simplefont.cpp
@@ -16,7 +16,6 @@ #include "core/fxcrt/fx_codepage.h" #include "core/fxge/fx_font.h" #include "core/fxge/fx_freetype.h" -#include "third_party/base/cxx17_backports.h" #include "third_party/base/numerics/safe_math.h" namespace { @@ -39,7 +38,7 @@ : CPDF_Font(pDocument, pFontDict) { memset(m_CharWidth, 0xff, sizeof(m_CharWidth)); memset(m_GlyphIndex, 0xff, sizeof(m_GlyphIndex)); - for (size_t i = 0; i < pdfium::size(m_CharBBox); ++i) + for (size_t i = 0; i < std::size(m_CharBBox); ++i) m_CharBBox[i] = FX_RECT(-1, -1, -1, -1); } @@ -241,7 +240,7 @@ if (FontStyleIsAllCaps(m_Flags)) { static const unsigned char kLowercases[][2] = { {'a', 'z'}, {0xe0, 0xf6}, {0xf8, 0xfd}}; - for (size_t range = 0; range < pdfium::size(kLowercases); ++range) { + for (size_t range = 0; range < std::size(kLowercases); ++range) { const auto& lower = kLowercases[range]; for (int i = lower[0]; i <= lower[1]; ++i) { if (m_GlyphIndex[i] != 0xffff && m_pFontFile)
diff --git a/core/fpdfapi/font/cpdf_type3font.cpp b/core/fpdfapi/font/cpdf_type3font.cpp index a6f3bb9..82ea835 100644 --- a/core/fpdfapi/font/cpdf_type3font.cpp +++ b/core/fpdfapi/font/cpdf_type3font.cpp
@@ -7,6 +7,7 @@ #include "core/fpdfapi/font/cpdf_type3font.h" #include <algorithm> +#include <iterator> #include <type_traits> #include <utility> @@ -17,7 +18,6 @@ #include "core/fxcrt/autorestorer.h" #include "core/fxcrt/fx_system.h" #include "third_party/base/check.h" -#include "third_party/base/cxx17_backports.h" namespace { @@ -149,7 +149,7 @@ } int CPDF_Type3Font::GetCharWidthF(uint32_t charcode) { - if (charcode >= pdfium::size(m_CharWidthL)) + if (charcode >= std::size(m_CharWidthL)) charcode = 0; if (m_CharWidthL[charcode])
diff --git a/core/fpdfapi/page/cpdf_colorspace.cpp b/core/fpdfapi/page/cpdf_colorspace.cpp index d463f24..cad0880 100644 --- a/core/fpdfapi/page/cpdf_colorspace.cpp +++ b/core/fpdfapi/page/cpdf_colorspace.cpp
@@ -705,14 +705,14 @@ const CPDF_Array* pParam = pDict->GetArrayFor("Gamma"); if (pParam) { m_bHasGamma = true; - for (size_t i = 0; i < pdfium::size(m_Gamma); ++i) + for (size_t i = 0; i < std::size(m_Gamma); ++i) m_Gamma[i] = pParam->GetNumberAt(i); } pParam = pDict->GetArrayFor("Matrix"); if (pParam) { m_bHasMatrix = true; - for (size_t i = 0; i < pdfium::size(m_Matrix); ++i) + for (size_t i = 0; i < std::size(m_Matrix); ++i) m_Matrix[i] = pParam->GetNumberAt(i); } return 3; @@ -819,10 +819,9 @@ const CPDF_Array* pParam = pDict->GetArrayFor("Range"); static constexpr float kDefaultRanges[kRangesCount] = {-100.0f, 100.0f, -100.0f, 100.0f}; - static_assert( - pdfium::size(kDefaultRanges) == std::extent<decltype(m_Ranges)>(), - "Range size mismatch"); - for (size_t i = 0; i < pdfium::size(kDefaultRanges); ++i) + static_assert(std::size(kDefaultRanges) == std::extent<decltype(m_Ranges)>(), + "Range size mismatch"); + for (size_t i = 0; i < std::size(kDefaultRanges); ++i) m_Ranges[i] = pParam ? pParam->GetNumberAt(i) : kDefaultRanges[i]; return 3; }
diff --git a/core/fpdfapi/page/cpdf_docpagedata.cpp b/core/fpdfapi/page/cpdf_docpagedata.cpp index 677312c..f36bc7b 100644 --- a/core/fpdfapi/page/cpdf_docpagedata.cpp +++ b/core/fpdfapi/page/cpdf_docpagedata.cpp
@@ -41,7 +41,6 @@ #include "core/fxge/fx_font.h" #include "third_party/base/check.h" #include "third_party/base/containers/contains.h" -#include "third_party/base/cxx17_backports.h" namespace { @@ -502,7 +501,7 @@ } } else { size_t i = CalculateEncodingDict(charset, pBaseDict); - if (i < pdfium::size(kFX_CharsetUnicodes)) { + if (i < std::size(kFX_CharsetUnicodes)) { const uint16_t* pUnicodes = kFX_CharsetUnicodes[i].m_pUnicodes; for (int j = 0; j < 128; j++) { int glyph_index = pEncoding->GlyphFromCharCode(pUnicodes[j]); @@ -532,7 +531,7 @@ nStemV = pFont->GetSubstFont()->m_Weight / 5; } else { static const char stem_chars[] = {'i', 'I', '!', '1'}; - const size_t count = pdfium::size(stem_chars); + const size_t count = std::size(stem_chars); uint32_t glyph = pEncoding->GlyphFromCharCode(stem_chars[0]); nStemV = pFont->GetGlyphWidth(glyph); for (size_t i = 1; i < count; i++) { @@ -639,11 +638,11 @@ size_t CPDF_DocPageData::CalculateEncodingDict(FX_Charset charset, CPDF_Dictionary* pBaseDict) { size_t i; - for (i = 0; i < pdfium::size(kFX_CharsetUnicodes); ++i) { + for (i = 0; i < std::size(kFX_CharsetUnicodes); ++i) { if (kFX_CharsetUnicodes[i].m_Charset == charset) break; } - if (i == pdfium::size(kFX_CharsetUnicodes)) + if (i == std::size(kFX_CharsetUnicodes)) return i; CPDF_Dictionary* pEncodingDict =
diff --git a/core/fpdfapi/page/cpdf_psengine_unittest.cpp b/core/fpdfapi/page/cpdf_psengine_unittest.cpp index 1ba4a40..fdaea52 100644 --- a/core/fpdfapi/page/cpdf_psengine_unittest.cpp +++ b/core/fpdfapi/page/cpdf_psengine_unittest.cpp
@@ -2,11 +2,12 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +#include "core/fpdfapi/page/cpdf_psengine.h" + +#include <iterator> #include <limits> -#include "core/fpdfapi/page/cpdf_psengine.h" #include "testing/gtest/include/gtest/gtest.h" -#include "third_party/base/cxx17_backports.h" namespace { @@ -71,7 +72,7 @@ CPDF_PSProc proc; EXPECT_EQ(0U, proc.num_operators()); - for (size_t i = 0; i < pdfium::size(kTestData); ++i) { + for (size_t i = 0; i < std::size(kTestData); ++i) { ByteStringView word(kTestData[i].name); proc.AddOperatorForTesting(word); ASSERT_EQ(i + 1, proc.num_operators());
diff --git a/core/fpdfapi/page/cpdf_streamcontentparser.cpp b/core/fpdfapi/page/cpdf_streamcontentparser.cpp index 7126777..02cee34 100644 --- a/core/fpdfapi/page/cpdf_streamcontentparser.cpp +++ b/core/fpdfapi/page/cpdf_streamcontentparser.cpp
@@ -41,7 +41,6 @@ #include "core/fxge/cfx_graphstatedata.h" #include "third_party/base/check.h" #include "third_party/base/containers/contains.h" -#include "third_party/base/cxx17_backports.h" #include "third_party/base/no_destructor.h" #include "third_party/base/notreached.h" #include "third_party/base/span.h" @@ -178,7 +177,7 @@ ByteString key = it.first; CPDF_Object* value = it.second.Get(); ByteStringView fullname = FindFullName( - kInlineKeyAbbr, pdfium::size(kInlineKeyAbbr), key.AsStringView()); + kInlineKeyAbbr, std::size(kInlineKeyAbbr), key.AsStringView()); if (!fullname.IsEmpty()) { AbbrReplacementOp op; op.is_replace_key = true; @@ -190,9 +189,8 @@ if (value->IsName()) { ByteString name = value->GetString(); - fullname = - FindFullName(kInlineValueAbbr, pdfium::size(kInlineValueAbbr), - name.AsStringView()); + fullname = FindFullName(kInlineValueAbbr, std::size(kInlineValueAbbr), + name.AsStringView()); if (!fullname.IsEmpty()) { AbbrReplacementOp op; op.is_replace_key = false; @@ -218,9 +216,8 @@ CPDF_Object* pElement = pArray->GetObjectAt(i); if (pElement->IsName()) { ByteString name = pElement->GetString(); - ByteStringView fullname = - FindFullName(kInlineValueAbbr, pdfium::size(kInlineValueAbbr), - name.AsStringView()); + ByteStringView fullname = FindFullName( + kInlineValueAbbr, std::size(kInlineValueAbbr), name.AsStringView()); if (!fullname.IsEmpty()) pArray->SetNewAt<CPDF_Name>(i, ByteString(fullname)); } else { @@ -1640,13 +1637,13 @@ // static ByteStringView CPDF_StreamContentParser::FindKeyAbbreviationForTesting( ByteStringView abbr) { - return FindFullName(kInlineKeyAbbr, pdfium::size(kInlineKeyAbbr), abbr); + return FindFullName(kInlineKeyAbbr, std::size(kInlineKeyAbbr), abbr); } // static ByteStringView CPDF_StreamContentParser::FindValueAbbreviationForTesting( ByteStringView abbr) { - return FindFullName(kInlineValueAbbr, pdfium::size(kInlineValueAbbr), abbr); + return FindFullName(kInlineValueAbbr, std::size(kInlineValueAbbr), abbr); } CPDF_StreamContentParser::ContentParam::ContentParam() = default;
diff --git a/core/fpdfapi/parser/cpdf_array_unittest.cpp b/core/fpdfapi/parser/cpdf_array_unittest.cpp index 7982b3a..213cb5d 100644 --- a/core/fpdfapi/parser/cpdf_array_unittest.cpp +++ b/core/fpdfapi/parser/cpdf_array_unittest.cpp
@@ -4,6 +4,7 @@ #include "core/fpdfapi/parser/cpdf_array.h" +#include <iterator> #include <memory> #include <utility> @@ -12,7 +13,6 @@ #include "core/fpdfapi/parser/cpdf_number.h" #include "core/fpdfapi/parser/cpdf_reference.h" #include "testing/gtest/include/gtest/gtest.h" -#include "third_party/base/cxx17_backports.h" TEST(ArrayTest, GetBooleanAt) { auto arr = pdfium::MakeRetain<CPDF_Array>(); @@ -38,29 +38,29 @@ { const int elems[] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10}; auto arr = pdfium::MakeRetain<CPDF_Array>(); - for (size_t i = 0; i < pdfium::size(elems); ++i) + for (size_t i = 0; i < std::size(elems); ++i) arr->AppendNew<CPDF_Number>(elems[i]); for (size_t i = 0; i < 3; ++i) arr->RemoveAt(3); const int expected[] = {1, 2, 3, 7, 8, 9, 10}; - ASSERT_EQ(pdfium::size(expected), arr->size()); - for (size_t i = 0; i < pdfium::size(expected); ++i) + ASSERT_EQ(std::size(expected), arr->size()); + for (size_t i = 0; i < std::size(expected); ++i) EXPECT_EQ(expected[i], arr->GetIntegerAt(i)); arr->RemoveAt(4); arr->RemoveAt(4); const int expected2[] = {1, 2, 3, 7, 10}; - ASSERT_EQ(pdfium::size(expected2), arr->size()); - for (size_t i = 0; i < pdfium::size(expected2); ++i) + ASSERT_EQ(std::size(expected2), arr->size()); + for (size_t i = 0; i < std::size(expected2); ++i) EXPECT_EQ(expected2[i], arr->GetIntegerAt(i)); } { // When the range is out of bound, RemoveAt() has no effect. const int elems[] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10}; auto arr = pdfium::MakeRetain<CPDF_Array>(); - for (size_t i = 0; i < pdfium::size(elems); ++i) + for (size_t i = 0; i < std::size(elems); ++i) arr->AppendNew<CPDF_Number>(elems[i]); arr->RemoveAt(11); - EXPECT_EQ(pdfium::size(elems), arr->size()); + EXPECT_EQ(std::size(elems), arr->size()); } } @@ -68,9 +68,9 @@ const int elems[] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10}; auto arr = pdfium::MakeRetain<CPDF_Array>(); EXPECT_EQ(0U, arr->size()); - for (size_t i = 0; i < pdfium::size(elems); ++i) + for (size_t i = 0; i < std::size(elems); ++i) arr->AppendNew<CPDF_Number>(elems[i]); - EXPECT_EQ(pdfium::size(elems), arr->size()); + EXPECT_EQ(std::size(elems), arr->size()); arr->Clear(); EXPECT_EQ(0U, arr->size()); } @@ -85,17 +85,17 @@ TEST(ArrayTest, InsertAt) { const int elems[] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10}; auto arr = pdfium::MakeRetain<CPDF_Array>(); - for (size_t i = 0; i < pdfium::size(elems); ++i) + for (size_t i = 0; i < std::size(elems); ++i) arr->InsertNewAt<CPDF_Number>(i, elems[i]); - ASSERT_EQ(pdfium::size(elems), arr->size()); - for (size_t i = 0; i < pdfium::size(elems); ++i) + ASSERT_EQ(std::size(elems), arr->size()); + for (size_t i = 0; i < std::size(elems); ++i) EXPECT_EQ(elems[i], arr->GetIntegerAt(i)); arr->InsertNewAt<CPDF_Number>(3, 33); arr->InsertNewAt<CPDF_Number>(6, 55); arr->InsertNewAt<CPDF_Number>(12, 12); const int expected[] = {1, 2, 3, 33, 4, 5, 55, 6, 7, 8, 9, 10, 12}; - ASSERT_EQ(pdfium::size(expected), arr->size()); - for (size_t i = 0; i < pdfium::size(expected); ++i) + ASSERT_EQ(std::size(expected), arr->size()); + for (size_t i = 0; i < std::size(expected); ++i) EXPECT_EQ(expected[i], arr->GetIntegerAt(i)); } @@ -111,11 +111,11 @@ // Basic case. const int elems[] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10}; auto arr = pdfium::MakeRetain<CPDF_Array>(); - for (size_t i = 0; i < pdfium::size(elems); ++i) + for (size_t i = 0; i < std::size(elems); ++i) arr->InsertNewAt<CPDF_Number>(i, elems[i]); RetainPtr<CPDF_Array> arr2 = ToArray(arr->Clone()); ASSERT_EQ(arr->size(), arr2->size()); - for (size_t i = 0; i < pdfium::size(elems); ++i) { + for (size_t i = 0; i < std::size(elems); ++i) { // Clone() always create new objects. EXPECT_NE(arr->GetObjectAt(i), arr2->GetObjectAt(i)); EXPECT_EQ(arr->GetIntegerAt(i), arr2->GetIntegerAt(i)); @@ -228,12 +228,12 @@ const int elems[] = {-23, -11, 3, 455, 2345877, 0, 7895330, -12564334, 10000, -100000}; auto arr = pdfium::MakeRetain<CPDF_Array>(); - for (size_t i = 0; i < pdfium::size(elems); ++i) + for (size_t i = 0; i < std::size(elems); ++i) arr->InsertNewAt<CPDF_Number>(i, elems[i]); size_t index = 0; CPDF_ArrayLocker locker(arr.Get()); for (const auto& it : locker) EXPECT_EQ(elems[index++], it->AsNumber()->GetInteger()); - EXPECT_EQ(pdfium::size(elems), index); + EXPECT_EQ(std::size(elems), index); }
diff --git a/core/fpdfapi/parser/cpdf_object_stream_unittest.cpp b/core/fpdfapi/parser/cpdf_object_stream_unittest.cpp index e17ee81..8b0c9ab 100644 --- a/core/fpdfapi/parser/cpdf_object_stream_unittest.cpp +++ b/core/fpdfapi/parser/cpdf_object_stream_unittest.cpp
@@ -4,6 +4,8 @@ #include "core/fpdfapi/parser/cpdf_object_stream.h" +#include <iterator> + #include "core/fpdfapi/parser/cpdf_dictionary.h" #include "core/fpdfapi/parser/cpdf_indirect_object_holder.h" #include "core/fpdfapi/parser/cpdf_name.h" @@ -12,7 +14,6 @@ #include "core/fpdfapi/parser/cpdf_string.h" #include "testing/gmock/include/gmock/gmock.h" #include "testing/gtest/include/gtest/gtest.h" -#include "third_party/base/cxx17_backports.h" using testing::ElementsAre; @@ -193,7 +194,7 @@ auto dict = pdfium::MakeRetain<CPDF_Dictionary>(); dict->SetNewFor<CPDF_Name>("Type", "ObjStm"); dict->SetNewFor<CPDF_Number>("N", 3); - constexpr int kTooBigOffset = pdfium::size(kNormalStreamContent); + constexpr int kTooBigOffset = std::size(kNormalStreamContent); dict->SetNewFor<CPDF_Number>("First", kTooBigOffset); auto stream = pdfium::MakeRetain<CPDF_Stream>(
diff --git a/core/fpdfapi/parser/cpdf_object_unittest.cpp b/core/fpdfapi/parser/cpdf_object_unittest.cpp index 88ded70..7fa62d4 100644 --- a/core/fpdfapi/parser/cpdf_object_unittest.cpp +++ b/core/fpdfapi/parser/cpdf_object_unittest.cpp
@@ -23,7 +23,6 @@ #include "core/fpdfapi/parser/cpdf_string.h" #include "core/fxcrt/fx_memory_wrappers.h" #include "testing/gtest/include/gtest/gtest.h" -#include "third_party/base/cxx17_backports.h" namespace { @@ -72,7 +71,7 @@ m_DictObj->SetNewFor<CPDF_Number>("num", 0.23f); // Stream object. const char content[] = "abcdefghijklmnopqrstuvwxyz"; - size_t buf_len = pdfium::size(content); + size_t buf_len = std::size(content); std::unique_ptr<uint8_t, FxFreeDeleter> buf( FX_AllocUninit(uint8_t, buf_len)); memcpy(buf.get(), content, buf_len); @@ -95,7 +94,7 @@ CPDF_Object::kNumber, CPDF_Object::kString, CPDF_Object::kString, CPDF_Object::kName, CPDF_Object::kArray, CPDF_Object::kDictionary, CPDF_Object::kStream, CPDF_Object::kNullobj}; - for (size_t i = 0; i < pdfium::size(objs); ++i) + for (size_t i = 0; i < std::size(objs); ++i) m_DirectObjs.emplace_back(objs[i]); // Indirect references to indirect objects. @@ -341,7 +340,7 @@ "changed", "", "NewName"}; const char* const expected[] = {"true", "false", "3.125", "97", "changed", "", "NewName"}; - for (size_t i = 0; i < pdfium::size(set_values); ++i) { + for (size_t i = 0; i < std::size(set_values); ++i) { m_DirectObjs[i]->SetString(set_values[i]); EXPECT_STREQ(expected[i], m_DirectObjs[i]->GetString().c_str()); } @@ -449,7 +448,7 @@ {1, 2, 3, 4, 5, 6}, {2.3f, 4.05f, 3, -2, -3, 0.0f}, {0.05f, 0.1f, 0.56f, 0.67f, 1.34f, 99.9f}}; - for (size_t i = 0; i < pdfium::size(elems); ++i) { + for (size_t i = 0; i < std::size(elems); ++i) { auto arr = pdfium::MakeRetain<CPDF_Array>(); CFX_Matrix matrix(elems[i][0], elems[i][1], elems[i][2], elems[i][3], elems[i][4], elems[i][5]); @@ -470,7 +469,7 @@ {1, 2, 5, 6}, {2.3f, 4.05f, -3, 0.0f}, {0.05f, 0.1f, 1.34f, 99.9f}}; - for (size_t i = 0; i < pdfium::size(elems); ++i) { + for (size_t i = 0; i < std::size(elems); ++i) { auto arr = pdfium::MakeRetain<CPDF_Array>(); CFX_FloatRect rect(elems[i][0], elems[i][1], elems[i][2], elems[i][3]); for (size_t j = 0; j < 4; ++j) @@ -488,9 +487,9 @@ // Boolean array. const bool vals[] = {true, false, false, true, true}; auto arr = pdfium::MakeRetain<CPDF_Array>(); - for (size_t i = 0; i < pdfium::size(vals); ++i) + for (size_t i = 0; i < std::size(vals); ++i) arr->InsertNewAt<CPDF_Boolean>(i, vals[i]); - for (size_t i = 0; i < pdfium::size(vals); ++i) { + for (size_t i = 0; i < std::size(vals); ++i) { TestArrayAccessors(arr.Get(), i, // Array and index. vals[i] ? "true" : "false", // String value. nullptr, // Const string value. @@ -505,9 +504,9 @@ // Integer array. const int vals[] = {10, 0, -345, 2089345456, -1000000000, 567, 93658767}; auto arr = pdfium::MakeRetain<CPDF_Array>(); - for (size_t i = 0; i < pdfium::size(vals); ++i) + for (size_t i = 0; i < std::size(vals); ++i) arr->InsertNewAt<CPDF_Number>(i, vals[i]); - for (size_t i = 0; i < pdfium::size(vals); ++i) { + for (size_t i = 0; i < std::size(vals); ++i) { char buf[33]; TestArrayAccessors(arr.Get(), i, // Array and index. FXSYS_itoa(vals[i], buf, 10), // String value. @@ -526,9 +525,9 @@ const char* const expected_str[] = { "0", "0", "10", "10", "0.0345", "897.34", "-2.5", "-1", "-345", "0"}; auto arr = pdfium::MakeRetain<CPDF_Array>(); - for (size_t i = 0; i < pdfium::size(vals); ++i) + for (size_t i = 0; i < std::size(vals); ++i) arr->InsertNewAt<CPDF_Number>(i, vals[i]); - for (size_t i = 0; i < pdfium::size(vals); ++i) { + for (size_t i = 0; i < std::size(vals); ++i) { TestArrayAccessors(arr.Get(), i, // Array and index. expected_str[i], // String value. nullptr, // Const string value. @@ -545,11 +544,11 @@ ".", "EYREW", "It is a joke :)"}; auto string_array = pdfium::MakeRetain<CPDF_Array>(); auto name_array = pdfium::MakeRetain<CPDF_Array>(); - for (size_t i = 0; i < pdfium::size(vals); ++i) { + for (size_t i = 0; i < std::size(vals); ++i) { string_array->InsertNewAt<CPDF_String>(i, vals[i], false); name_array->InsertNewAt<CPDF_Name>(i, vals[i]); } - for (size_t i = 0; i < pdfium::size(vals); ++i) { + for (size_t i = 0; i < std::size(vals); ++i) { TestArrayAccessors(string_array.Get(), i, // Array and index. vals[i], // String value. vals[i], // Const string value. @@ -646,7 +645,7 @@ vals[i]->SetNewFor<CPDF_Number>(key.c_str(), value); } uint8_t content[] = "content: this is a stream"; - size_t data_size = pdfium::size(content); + size_t data_size = std::size(content); std::unique_ptr<uint8_t, FxFreeDeleter> data( FX_AllocUninit(uint8_t, data_size)); memcpy(data.get(), content, data_size); @@ -732,9 +731,9 @@ float vals[] = {1.0f, -1.0f, 0, 0.456734f, 12345.54321f, 0.5f, 1000, 0.000045f}; auto arr = pdfium::MakeRetain<CPDF_Array>(); - for (size_t i = 0; i < pdfium::size(vals); ++i) + for (size_t i = 0; i < std::size(vals); ++i) arr->AppendNew<CPDF_Number>(vals[i]); - for (size_t i = 0; i < pdfium::size(vals); ++i) { + for (size_t i = 0; i < std::size(vals); ++i) { EXPECT_EQ(CPDF_Object::kNumber, arr->GetObjectAt(i)->GetType()); EXPECT_EQ(vals[i], arr->GetObjectAt(i)->GetNumber()); } @@ -743,9 +742,9 @@ TEST(PDFArrayTest, AddInteger) { int vals[] = {0, 1, 934435456, 876, 10000, -1, -24354656, -100}; auto arr = pdfium::MakeRetain<CPDF_Array>(); - for (size_t i = 0; i < pdfium::size(vals); ++i) + for (size_t i = 0; i < std::size(vals); ++i) arr->AppendNew<CPDF_Number>(vals[i]); - for (size_t i = 0; i < pdfium::size(vals); ++i) { + for (size_t i = 0; i < std::size(vals); ++i) { EXPECT_EQ(CPDF_Object::kNumber, arr->GetObjectAt(i)->GetType()); EXPECT_EQ(vals[i], arr->GetObjectAt(i)->GetNumber()); } @@ -761,7 +760,7 @@ string_array->AppendNew<CPDF_String>(val, false); name_array->AppendNew<CPDF_Name>(val); } - for (size_t i = 0; i < pdfium::size(kVals); ++i) { + for (size_t i = 0; i < std::size(kVals); ++i) { EXPECT_EQ(CPDF_Object::kString, string_array->GetObjectAt(i)->GetType()); EXPECT_STREQ(kVals[i], string_array->GetObjectAt(i)->GetString().c_str()); EXPECT_EQ(CPDF_Object::kName, name_array->GetObjectAt(i)->GetType()); @@ -784,7 +783,7 @@ auto arr = pdfium::MakeRetain<CPDF_Array>(); auto arr1 = pdfium::MakeRetain<CPDF_Array>(); // Create two arrays of references by different AddReference() APIs. - for (size_t i = 0; i < pdfium::size(indirect_objs); ++i) { + for (size_t i = 0; i < std::size(indirect_objs); ++i) { holder->ReplaceIndirectObjectIfHigherGeneration(obj_nums[i], indirect_objs[i]); arr->AppendNew<CPDF_Reference>(holder.get(), obj_nums[i]); @@ -792,7 +791,7 @@ indirect_objs[i]->GetObjNum()); } // Check indirect objects. - for (size_t i = 0; i < pdfium::size(obj_nums); ++i) + for (size_t i = 0; i < std::size(obj_nums); ++i) EXPECT_EQ(indirect_objs[i], holder->GetOrParseIndirectObject(obj_nums[i])); // Check arrays. EXPECT_EQ(arr->size(), arr1->size());
diff --git a/core/fpdfapi/parser/cpdf_parser_unittest.cpp b/core/fpdfapi/parser/cpdf_parser_unittest.cpp index a88a472..25b6d28 100644 --- a/core/fpdfapi/parser/cpdf_parser_unittest.cpp +++ b/core/fpdfapi/parser/cpdf_parser_unittest.cpp
@@ -20,7 +20,6 @@ #include "testing/gmock/include/gmock/gmock.h" #include "testing/gtest/include/gtest/gtest.h" #include "testing/utils/path_service.h" -#include "third_party/base/cxx17_backports.h" using testing::Return; @@ -97,9 +96,9 @@ ASSERT_TRUE(parser.RebuildCrossRef()); const FX_FILESIZE offsets[] = {0, 15, 61, 154, 296, 374, 450}; const uint16_t versions[] = {0, 0, 2, 4, 6, 8, 0}; - for (size_t i = 0; i < pdfium::size(offsets); ++i) + for (size_t i = 0; i < std::size(offsets); ++i) EXPECT_EQ(offsets[i], GetObjInfo(parser, i).pos); - for (size_t i = 0; i < pdfium::size(versions); ++i) + for (size_t i = 0; i < std::size(versions); ++i) EXPECT_EQ(versions[i], GetObjInfo(parser, i).gennum); } @@ -137,9 +136,9 @@ CPDF_TestParser::ObjectType::kFree, CPDF_TestParser::ObjectType::kNotCompressed, CPDF_TestParser::ObjectType::kNotCompressed}; - static_assert(pdfium::size(kOffsets) == pdfium::size(kTypes), + static_assert(std::size(kOffsets) == std::size(kTypes), "kOffsets / kTypes size mismatch"); - for (size_t i = 0; i < pdfium::size(kOffsets); ++i) { + for (size_t i = 0; i < std::size(kOffsets); ++i) { EXPECT_EQ(kOffsets[i], GetObjInfo(parser, i).pos); EXPECT_EQ(kTypes[i], GetObjInfo(parser, i).type); } @@ -177,9 +176,9 @@ CPDF_TestParser::ObjectType::kFree, CPDF_TestParser::ObjectType::kFree, CPDF_TestParser::ObjectType::kNotCompressed}; - static_assert(pdfium::size(kOffsets) == pdfium::size(kTypes), + static_assert(std::size(kOffsets) == std::size(kTypes), "kOffsets / kTypes size mismatch"); - for (size_t i = 0; i < pdfium::size(kOffsets); ++i) { + for (size_t i = 0; i < std::size(kOffsets); ++i) { EXPECT_EQ(kOffsets[i], GetObjInfo(parser, i).pos); EXPECT_EQ(kTypes[i], GetObjInfo(parser, i).type); } @@ -217,9 +216,9 @@ CPDF_TestParser::ObjectType::kFree, CPDF_TestParser::ObjectType::kFree, CPDF_TestParser::ObjectType::kNotCompressed}; - static_assert(pdfium::size(kOffsets) == pdfium::size(kTypes), + static_assert(std::size(kOffsets) == std::size(kTypes), "kOffsets / kTypes size mismatch"); - for (size_t i = 0; i < pdfium::size(kOffsets); ++i) { + for (size_t i = 0; i < std::size(kOffsets); ++i) { EXPECT_EQ(kOffsets[i], GetObjInfo(parser, i).pos); EXPECT_EQ(kTypes[i], GetObjInfo(parser, i).type); } @@ -249,9 +248,9 @@ CPDF_TestParser::ObjectType::kFree, CPDF_TestParser::ObjectType::kNotCompressed, CPDF_TestParser::ObjectType::kNotCompressed}; - static_assert(pdfium::size(kOffsets) == pdfium::size(kTypes), + static_assert(std::size(kOffsets) == std::size(kTypes), "kOffsets / kTypes size mismatch"); - for (size_t i = 0; i < pdfium::size(kOffsets); ++i) { + for (size_t i = 0; i < std::size(kOffsets); ++i) { EXPECT_EQ(kOffsets[i], GetObjInfo(parser, i).pos); EXPECT_EQ(kTypes[i], GetObjInfo(parser, i).type); }
diff --git a/core/fpdfapi/parser/cpdf_security_handler.cpp b/core/fpdfapi/parser/cpdf_security_handler.cpp index b54b707..ae592d2 100644 --- a/core/fpdfapi/parser/cpdf_security_handler.cpp +++ b/core/fpdfapi/parser/cpdf_security_handler.cpp
@@ -21,7 +21,6 @@ #include "core/fxcrt/fx_random.h" #include "third_party/base/check.h" #include "third_party/base/check_op.h" -#include "third_party/base/cxx17_backports.h" #include "third_party/base/notreached.h" namespace { @@ -556,7 +555,7 @@ if (m_Revision >= 5) { uint32_t random[4]; - FX_Random_GenerateMT(random, pdfium::size(random)); + FX_Random_GenerateMT(random, std::size(random)); CRYPT_sha2_context sha; CRYPT_SHA256Start(&sha); CRYPT_SHA256Update(&sha, reinterpret_cast<uint8_t*>(random),
diff --git a/core/fpdfapi/parser/cpdf_simple_parser_unittest.cpp b/core/fpdfapi/parser/cpdf_simple_parser_unittest.cpp index 482ce6e..3632df1 100644 --- a/core/fpdfapi/parser/cpdf_simple_parser_unittest.cpp +++ b/core/fpdfapi/parser/cpdf_simple_parser_unittest.cpp
@@ -4,10 +4,11 @@ #include "core/fpdfapi/parser/cpdf_simple_parser.h" +#include <iterator> + #include "core/fpdfapi/parser/fpdf_parser_utility.h" #include "testing/gtest/include/gtest/gtest.h" #include "testing/test_support.h" -#include "third_party/base/cxx17_backports.h" #include "third_party/base/span.h" TEST(SimpleParserTest, GetWord) { @@ -49,7 +50,7 @@ STR_IN_OUT_CASE(" $^&&*\t\0sdff ", "$^&&*"), STR_IN_OUT_CASE("\n\r+3.5656 -11.0", "+3.5656"), }; - for (size_t i = 0; i < pdfium::size(test_data); ++i) { + for (size_t i = 0; i < std::size(test_data); ++i) { const pdfium::StrFuncTestData& data = test_data[i]; CPDF_SimpleParser parser(pdfium::make_span(data.input, data.input_size)); ByteStringView word = parser.GetWord();
diff --git a/core/fpdfapi/parser/fpdf_parser_decode_unittest.cpp b/core/fpdfapi/parser/fpdf_parser_decode_unittest.cpp index 7f65d61..d73a8df 100644 --- a/core/fpdfapi/parser/fpdf_parser_decode_unittest.cpp +++ b/core/fpdfapi/parser/fpdf_parser_decode_unittest.cpp
@@ -4,6 +4,8 @@ #include "core/fpdfapi/parser/fpdf_parser_decode.h" +#include <iterator> + #include "core/fpdfapi/parser/cpdf_array.h" #include "core/fpdfapi/parser/cpdf_dictionary.h" #include "core/fpdfapi/parser/cpdf_name.h" @@ -11,7 +13,6 @@ #include "core/fxcrt/fx_memory_wrappers.h" #include "testing/gtest/include/gtest/gtest.h" #include "testing/test_support.h" -#include "third_party/base/cxx17_backports.h" TEST(ParserDecodeTest, ValidateDecoderPipeline) { { @@ -239,7 +240,7 @@ 96), }; - for (size_t i = 0; i < pdfium::size(flate_decode_cases); ++i) { + for (size_t i = 0; i < std::size(flate_decode_cases); ++i) { const pdfium::DecodeTestData& data = flate_decode_cases[i]; std::unique_ptr<uint8_t, FxFreeDeleter> buf; uint32_t buf_size; @@ -273,7 +274,7 @@ "\x2b\x58\x1a\x9a\x83\x8c\x49\xe3\x0a\x04\x42\x00\x37\x4c\x1b\x42"), }; - for (size_t i = 0; i < pdfium::size(flate_encode_cases); ++i) { + for (size_t i = 0; i < std::size(flate_encode_cases); ++i) { const pdfium::StrFuncTestData& data = flate_encode_cases[i]; std::unique_ptr<uint8_t, FxFreeDeleter> buf; uint32_t buf_size;
diff --git a/core/fpdfapi/render/cpdf_docrenderdata_unittest.cpp b/core/fpdfapi/render/cpdf_docrenderdata_unittest.cpp index 685b706..49c1148 100644 --- a/core/fpdfapi/render/cpdf_docrenderdata_unittest.cpp +++ b/core/fpdfapi/render/cpdf_docrenderdata_unittest.cpp
@@ -4,6 +4,7 @@ #include "core/fpdfapi/render/cpdf_docrenderdata.h" +#include <iterator> #include <memory> #include <utility> @@ -14,7 +15,6 @@ #include "core/fpdfapi/parser/cpdf_stream.h" #include "core/fxcrt/fx_memory_wrappers.h" #include "testing/gtest/include/gtest/gtest.h" -#include "third_party/base/cxx17_backports.h" namespace { @@ -88,7 +88,7 @@ func_dict->SetNewFor<CPDF_Number>("BitsPerSample", 8); static const char content[] = "1234"; - size_t len = pdfium::size(content); + size_t len = std::size(content); std::unique_ptr<uint8_t, FxFreeDeleter> buf(FX_AllocUninit(uint8_t, len)); memcpy(buf.get(), content, len); return pdfium::MakeRetain<CPDF_Stream>(std::move(buf), len, @@ -130,7 +130,7 @@ range_array->AppendNew<CPDF_Number>(1); static const char content[] = "{ 360 mul sin 2 div }"; - size_t len = pdfium::size(content); + size_t len = std::size(content); std::unique_ptr<uint8_t, FxFreeDeleter> buf(FX_AllocUninit(uint8_t, len)); memcpy(buf.get(), content, len); return pdfium::MakeRetain<CPDF_Stream>(std::move(buf), len, @@ -150,7 +150,7 @@ range_array->AppendNew<CPDF_Number>(1); static const char content[] = "garbage"; - size_t len = pdfium::size(content); + size_t len = std::size(content); std::unique_ptr<uint8_t, FxFreeDeleter> buf(FX_AllocUninit(uint8_t, len)); memcpy(buf.get(), content, len); return pdfium::MakeRetain<CPDF_Stream>(std::move(buf), len, @@ -178,11 +178,11 @@ auto r_samples = func->GetSamplesR(); auto g_samples = func->GetSamplesG(); auto b_samples = func->GetSamplesB(); - ASSERT_EQ(pdfium::size(kExpectedType2FunctionSamples), r_samples.size()); - ASSERT_EQ(pdfium::size(kExpectedType2FunctionSamples), g_samples.size()); - ASSERT_EQ(pdfium::size(kExpectedType2FunctionSamples), b_samples.size()); + ASSERT_EQ(std::size(kExpectedType2FunctionSamples), r_samples.size()); + ASSERT_EQ(std::size(kExpectedType2FunctionSamples), g_samples.size()); + ASSERT_EQ(std::size(kExpectedType2FunctionSamples), b_samples.size()); - for (size_t i = 0; i < pdfium::size(kExpectedType2FunctionSamples); ++i) { + for (size_t i = 0; i < std::size(kExpectedType2FunctionSamples); ++i) { EXPECT_EQ(kExpectedType2FunctionSamples[i], r_samples[i]); EXPECT_EQ(kExpectedType2FunctionSamples[i], g_samples[i]); EXPECT_EQ(kExpectedType2FunctionSamples[i], b_samples[i]); @@ -214,11 +214,11 @@ auto r_samples = func->GetSamplesR(); auto g_samples = func->GetSamplesG(); auto b_samples = func->GetSamplesB(); - ASSERT_EQ(pdfium::size(kExpectedType0FunctionSamples), r_samples.size()); - ASSERT_EQ(pdfium::size(kExpectedType2FunctionSamples), g_samples.size()); - ASSERT_EQ(pdfium::size(kExpectedType4FunctionSamples), b_samples.size()); + ASSERT_EQ(std::size(kExpectedType0FunctionSamples), r_samples.size()); + ASSERT_EQ(std::size(kExpectedType2FunctionSamples), g_samples.size()); + ASSERT_EQ(std::size(kExpectedType4FunctionSamples), b_samples.size()); - for (size_t i = 0; i < pdfium::size(kExpectedType2FunctionSamples); ++i) { + for (size_t i = 0; i < std::size(kExpectedType2FunctionSamples); ++i) { EXPECT_EQ(kExpectedType0FunctionSamples[i], r_samples[i]); EXPECT_EQ(kExpectedType2FunctionSamples[i], g_samples[i]); EXPECT_EQ(kExpectedType4FunctionSamples[i], b_samples[i]);
diff --git a/core/fpdfdoc/cpdf_aaction.cpp b/core/fpdfdoc/cpdf_aaction.cpp index edc1b01..3c9535a 100644 --- a/core/fpdfdoc/cpdf_aaction.cpp +++ b/core/fpdfdoc/cpdf_aaction.cpp
@@ -6,8 +6,9 @@ #include "core/fpdfdoc/cpdf_aaction.h" +#include <iterator> + #include "core/fpdfapi/parser/cpdf_dictionary.h" -#include "third_party/base/cxx17_backports.h" namespace { @@ -37,7 +38,7 @@ // |kAATypes| should have one less element than enum AActionType due to // |kDocumentOpen|, which is an artificial type. -static_assert(pdfium::size(kAATypes) == CPDF_AAction::kNumberOfActions - 1, +static_assert(std::size(kAATypes) == CPDF_AAction::kNumberOfActions - 1, "kAATypes count mismatch"); } // namespace
diff --git a/core/fpdfdoc/cpdf_action.cpp b/core/fpdfdoc/cpdf_action.cpp index e899c83..56b6e57 100644 --- a/core/fpdfdoc/cpdf_action.cpp +++ b/core/fpdfdoc/cpdf_action.cpp
@@ -6,6 +6,8 @@ #include "core/fpdfdoc/cpdf_action.h" +#include <iterator> + #include "constants/stream_dict_common.h" #include "core/fpdfapi/parser/cpdf_array.h" #include "core/fpdfapi/parser/cpdf_dictionary.h" @@ -13,7 +15,6 @@ #include "core/fpdfapi/parser/cpdf_name.h" #include "core/fpdfapi/parser/fpdf_parser_utility.h" #include "core/fpdfdoc/cpdf_filespec.h" -#include "third_party/base/cxx17_backports.h" namespace { @@ -41,9 +42,9 @@ return Type::kUnknown; static_assert( - pdfium::size(kActionTypeStrings) == static_cast<size_t>(Type::kLast), + std::size(kActionTypeStrings) == static_cast<size_t>(Type::kLast), "Type mismatch"); - for (size_t i = 0; i < pdfium::size(kActionTypeStrings); ++i) { + for (size_t i = 0; i < std::size(kActionTypeStrings); ++i) { if (csType == kActionTypeStrings[i]) return static_cast<Type>(i + 1); }
diff --git a/core/fpdfdoc/cpdf_defaultappearance_unittest.cpp b/core/fpdfdoc/cpdf_defaultappearance_unittest.cpp index 46dd624..cbdd51a 100644 --- a/core/fpdfdoc/cpdf_defaultappearance_unittest.cpp +++ b/core/fpdfdoc/cpdf_defaultappearance_unittest.cpp
@@ -4,10 +4,11 @@ #include "core/fpdfdoc/cpdf_defaultappearance.h" +#include <iterator> + #include "core/fpdfapi/parser/cpdf_simple_parser.h" #include "testing/gtest/include/gtest/gtest.h" #include "testing/test_support.h" -#include "third_party/base/cxx17_backports.h" #include "third_party/base/span.h" TEST(CPDFDefaultAppearanceTest, FindTagParamFromStart) { @@ -38,7 +39,7 @@ }; CPDF_DefaultAppearance da; - for (size_t i = 0; i < pdfium::size(test_data); ++i) { + for (size_t i = 0; i < std::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 f3b1152..34fb416 100644 --- a/core/fpdfdoc/cpdf_dest.cpp +++ b/core/fpdfdoc/cpdf_dest.cpp
@@ -7,13 +7,13 @@ #include "core/fpdfdoc/cpdf_dest.h" #include <algorithm> +#include <iterator> #include "core/fpdfapi/parser/cpdf_array.h" #include "core/fpdfapi/parser/cpdf_document.h" #include "core/fpdfapi/parser/cpdf_name.h" #include "core/fpdfapi/parser/cpdf_number.h" #include "core/fpdfdoc/cpdf_nametree.h" -#include "third_party/base/cxx17_backports.h" namespace { @@ -25,7 +25,7 @@ constexpr uint8_t kZoomModeMaxParamCount[] = {0, 3, 0, 1, 1, 4, 0, 1, 1, 0}; -static_assert(pdfium::size(kZoomModes) == pdfium::size(kZoomModeMaxParamCount), +static_assert(std::size(kZoomModes) == std::size(kZoomModeMaxParamCount), "Zoom mode count Mismatch"); } // namespace
diff --git a/core/fpdfdoc/cpdf_filespec.cpp b/core/fpdfdoc/cpdf_filespec.cpp index 9af7b9c..5eb1116 100644 --- a/core/fpdfdoc/cpdf_filespec.cpp +++ b/core/fpdfdoc/cpdf_filespec.cpp
@@ -6,6 +6,8 @@ #include "core/fpdfdoc/cpdf_filespec.h" +#include <iterator> + #include "build/build_config.h" #include "constants/stream_dict_common.h" #include "core/fpdfapi/parser/cpdf_dictionary.h" @@ -16,7 +18,6 @@ #include "core/fpdfapi/parser/fpdf_parser_decode.h" #include "core/fxcrt/fx_system.h" #include "third_party/base/check.h" -#include "third_party/base/cxx17_backports.h" #include "third_party/base/notreached.h" namespace { @@ -140,7 +141,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 : pdfium::size(kKeys); + size_t end = pDict->GetStringFor("FS") == "URL" ? 2 : std::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 aef0810..2458677 100644 --- a/core/fpdfdoc/cpdf_filespec_unittest.cpp +++ b/core/fpdfdoc/cpdf_filespec_unittest.cpp
@@ -2,6 +2,8 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +#include "core/fpdfdoc/cpdf_filespec.h" + #include <memory> #include <utility> #include <vector> @@ -12,11 +14,9 @@ #include "core/fpdfapi/parser/cpdf_number.h" #include "core/fpdfapi/parser/cpdf_stream.h" #include "core/fpdfapi/parser/cpdf_string.h" -#include "core/fpdfdoc/cpdf_filespec.h" #include "core/fxcrt/fx_memory_wrappers.h" #include "testing/gtest/include/gtest/gtest.h" #include "testing/test_support.h" -#include "third_party/base/cxx17_backports.h" TEST(cpdf_filespec, EncodeDecodeFileName) { static const std::vector<pdfium::NullTermWstrFuncTestData> test_data = { @@ -102,12 +102,11 @@ }; // Keyword fields in reverse order of precedence to retrieve the file name. const char* const keywords[] = {"Unix", "Mac", "DOS", "F", "UF"}; - static_assert(pdfium::size(test_data) == pdfium::size(keywords), - "size mismatch"); + static_assert(std::size(test_data) == std::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 < pdfium::size(keywords); ++i) { + for (size_t i = 0; i < std::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()); } @@ -198,12 +197,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(pdfium::size(keys) == pdfium::size(streams), "size mismatch"); + static_assert(std::size(keys) == std::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 < pdfium::size(keys); ++i) { + for (size_t i = 0; i < std::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 56333ab..28b7beb 100644 --- a/core/fpdfdoc/cpdf_formcontrol.cpp +++ b/core/fpdfdoc/cpdf_formcontrol.cpp
@@ -6,6 +6,8 @@ #include "core/fpdfdoc/cpdf_formcontrol.h" +#include <iterator> + #include "core/fpdfapi/font/cpdf_font.h" #include "core/fpdfapi/page/cpdf_docpagedata.h" #include "core/fpdfapi/parser/cpdf_array.h" @@ -16,7 +18,6 @@ #include "core/fpdfapi/parser/fpdf_parser_utility.h" #include "core/fpdfdoc/cpdf_interactiveform.h" #include "third_party/base/check.h" -#include "third_party/base/cxx17_backports.h" namespace { @@ -128,7 +129,7 @@ CPDF_FormControl::HighlightingMode CPDF_FormControl::GetHighlightingMode() const { ByteString csH = m_pWidgetDict->GetStringFor("H", "I"); - for (size_t i = 0; i < pdfium::size(kHighlightModes); ++i) { + for (size_t i = 0; i < std::size(kHighlightModes); ++i) { // TODO(tsepez): disambiguate string ctors. if (csH == ByteStringView(kHighlightModes[i])) return static_cast<HighlightingMode>(i);
diff --git a/core/fxcodec/basic/a85_unittest.cpp b/core/fxcodec/basic/a85_unittest.cpp index 782e0b4..93b121e 100644 --- a/core/fxcodec/basic/a85_unittest.cpp +++ b/core/fxcodec/basic/a85_unittest.cpp
@@ -4,13 +4,13 @@ #include <stdint.h> +#include <iterator> #include <limits> #include <memory> #include "core/fxcodec/basic/basicmodule.h" #include "core/fxcrt/fx_memory_wrappers.h" #include "testing/gtest/include/gtest/gtest.h" -#include "third_party/base/cxx17_backports.h" TEST(fxcodec, A85TestBadInputs) { const uint8_t src_buf[] = {1, 2, 3, 4}; @@ -34,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(pdfium::size(expected_out), dest_size); + ASSERT_EQ(std::size(expected_out), dest_size); // Check the output auto dest_buf_span = pdfium::make_span(dest_buf.get(), dest_size); @@ -55,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(pdfium::size(expected_out_1leftover), dest_size); + ASSERT_EQ(std::size(expected_out_1leftover), dest_size); // Check the output auto dest_buf_span = pdfium::make_span(dest_buf.get(), dest_size); @@ -73,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(pdfium::size(expected_out_2leftover), dest_size); + ASSERT_EQ(std::size(expected_out_2leftover), dest_size); // Check the output auto dest_buf_span = pdfium::make_span(dest_buf.get(), dest_size); @@ -91,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(pdfium::size(expected_out_3leftover), dest_size); + ASSERT_EQ(std::size(expected_out_3leftover), dest_size); // Check the output auto dest_buf_span = pdfium::make_span(dest_buf.get(), dest_size); @@ -112,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(pdfium::size(expected_out), dest_size); + ASSERT_EQ(std::size(expected_out), dest_size); // Check the output auto dest_buf_span = pdfium::make_span(dest_buf.get(), dest_size); @@ -129,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(pdfium::size(expected_out_2), dest_size); + ASSERT_EQ(std::size(expected_out_2), dest_size); // Check the output auto dest_buf_span = pdfium::make_span(dest_buf.get(), dest_size); @@ -147,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(pdfium::size(expected_out_leftover), dest_size); + ASSERT_EQ(std::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 a377998..2a50d71 100644 --- a/core/fxcodec/gif/cfx_gifcontext.cpp +++ b/core/fxcodec/gif/cfx_gifcontext.cpp
@@ -7,12 +7,12 @@ #include "core/fxcodec/gif/cfx_gifcontext.h" #include <algorithm> +#include <iterator> #include <utility> #include "core/fxcodec/cfx_codec_memory.h" #include "core/fxcrt/fx_system.h" #include "core/fxcrt/stl_util.h" -#include "third_party/base/cxx17_backports.h" namespace fxcodec { @@ -284,7 +284,7 @@ if (gif_image->row_num >= static_cast<int32_t>(gif_image->image_info.height)) { img_pass_num_++; - if (img_pass_num_ == pdfium::size(kGifInterlaceStep)) { + if (img_pass_num_ == std::size(kGifInterlaceStep)) { DecodingFailureAtTailCleanup(gif_image); return GifDecoder::Status::kError; }
diff --git a/core/fxcodec/gif/lzw_decompressor_unittest.cpp b/core/fxcodec/gif/lzw_decompressor_unittest.cpp index f14fa14..54d6bac 100644 --- a/core/fxcodec/gif/lzw_decompressor_unittest.cpp +++ b/core/fxcodec/gif/lzw_decompressor_unittest.cpp
@@ -7,9 +7,10 @@ #include <stdint.h> #include <string.h> +#include <iterator> + #include "testing/gmock/include/gmock/gmock.h" #include "testing/gtest/include/gtest/gtest.h" -#include "third_party/base/cxx17_backports.h" using ::testing::ElementsAreArray; @@ -35,7 +36,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 < pdfium::size(dest_buf); ++i) + for (size_t i = 0; i < std::size(dest_buf); ++i) EXPECT_EQ(static_cast<uint8_t>(-1), dest_buf[i]); EXPECT_EQ(10u, *(decompressor->DecompressedNextForTest())); @@ -56,7 +57,7 @@ size_t i = 0; for (; i < 5; ++i) EXPECT_EQ(9 - i, dest_buf[i]); - for (; i < pdfium::size(dest_buf); ++i) + for (; i < std::size(dest_buf); ++i) EXPECT_EQ(static_cast<uint8_t>(-1), dest_buf[i]); EXPECT_EQ(5u, *(decompressor->DecompressedNextForTest())); @@ -73,12 +74,12 @@ uint8_t dest_buf[20]; memset(dest_buf, static_cast<uint8_t>(-1), sizeof(dest_buf)); - EXPECT_EQ(10u, decompressor->ExtractDataForTest(dest_buf, - pdfium::size(dest_buf))); + EXPECT_EQ(10u, + decompressor->ExtractDataForTest(dest_buf, std::size(dest_buf))); size_t i = 0; for (; i < 10; ++i) EXPECT_EQ(9 - i, dest_buf[i]); - for (; i < pdfium::size(dest_buf); ++i) + for (; i < std::size(dest_buf); ++i) EXPECT_EQ(static_cast<uint8_t>(-1), dest_buf[i]); EXPECT_EQ(0u, *(decompressor->DecompressedNextForTest())); @@ -92,10 +93,10 @@ ASSERT_NE(nullptr, decompressor); uint8_t image_data[10]; - uint32_t image_size = pdfium::size(image_data); + uint32_t image_size = std::size(image_data); uint8_t output_data[10]; - uint32_t output_size = pdfium::size(output_data); + uint32_t output_size = std::size(output_data); decompressor->SetSource(nullptr, image_size); EXPECT_EQ(LZWDecompressor::Status::kError, @@ -123,18 +124,18 @@ ASSERT_NE(nullptr, decompressor); uint8_t image_data[] = {0x44, 0x01}; - uint32_t image_size = pdfium::size(image_data); + uint32_t image_size = std::size(image_data); uint8_t expected_data[] = {0x00}; - uint8_t output_data[pdfium::size(expected_data)]; + uint8_t output_data[std::size(expected_data)]; memset(output_data, 0, sizeof(output_data)); - uint32_t output_size = pdfium::size(output_data); + uint32_t output_size = std::size(output_data); decompressor->SetSource(image_data, image_size); EXPECT_EQ(LZWDecompressor::Status::kSuccess, decompressor->Decode(output_data, &output_size)); - EXPECT_EQ(pdfium::size(output_data), output_size); + EXPECT_EQ(std::size(output_data), output_size); EXPECT_TRUE(0 == memcmp(expected_data, output_data, sizeof(expected_data))); } @@ -146,7 +147,7 @@ static constexpr uint8_t kImageData[] = {0x84, 0x8F, 0xA9, 0xCB, 0xED, 0x0F, 0x63, 0x2B}; - uint32_t image_size = pdfium::size(kImageData); + uint32_t image_size = std::size(kImageData); static constexpr uint8_t kExpectedData[] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, @@ -158,15 +159,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[pdfium::size(kExpectedData)]; + uint8_t output_data[std::size(kExpectedData)]; memset(output_data, 0, sizeof(output_data)); - uint32_t output_size = pdfium::size(output_data); + uint32_t output_size = std::size(output_data); decompressor->SetSource(kImageData, image_size); EXPECT_EQ(LZWDecompressor::Status::kSuccess, decompressor->Decode(output_data, &output_size)); - EXPECT_EQ(pdfium::size(output_data), output_size); + EXPECT_EQ(std::size(output_data), output_size); EXPECT_TRUE(0 == memcmp(kExpectedData, output_data, sizeof(kExpectedData))); } @@ -179,7 +180,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 = pdfium::size(kImageData); + uint32_t image_size = std::size(kImageData); static constexpr uint8_t kExpectedData[] = { 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, @@ -192,15 +193,15 @@ 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01}; - uint8_t output_data[pdfium::size(kExpectedData)]; + uint8_t output_data[std::size(kExpectedData)]; memset(output_data, 0, sizeof(output_data)); - uint32_t output_size = pdfium::size(output_data); + uint32_t output_size = std::size(output_data); decompressor->SetSource(kImageData, image_size); EXPECT_EQ(LZWDecompressor::Status::kSuccess, decompressor->Decode(output_data, &output_size)); - EXPECT_EQ(pdfium::size(output_data), output_size); + EXPECT_EQ(std::size(output_data), output_size); EXPECT_TRUE(0 == memcmp(kExpectedData, output_data, sizeof(kExpectedData))); } @@ -209,23 +210,23 @@ ASSERT_NE(nullptr, decompressor); static constexpr uint8_t kImageData[] = {0x84, 0x6f, 0x05}; - decompressor->SetSource(kImageData, pdfium::size(kImageData)); + decompressor->SetSource(kImageData, std::size(kImageData)); static constexpr uint8_t kExpectedScanline[] = {0x00, 0x00, 0x00, 0x00}; - uint8_t output_data[pdfium::size(kExpectedScanline)]; + uint8_t output_data[std::size(kExpectedScanline)]; memset(output_data, 0xFF, sizeof(output_data)); - uint32_t output_size = pdfium::size(output_data); + uint32_t output_size = std::size(output_data); EXPECT_EQ(LZWDecompressor::Status::kInsufficientDestSize, decompressor->Decode(output_data, &output_size)); - EXPECT_EQ(pdfium::size(kExpectedScanline), output_size); + EXPECT_EQ(std::size(kExpectedScanline), output_size); EXPECT_THAT(output_data, ElementsAreArray(kExpectedScanline)); memset(output_data, 0xFF, sizeof(output_data)); - output_size = pdfium::size(output_data); + output_size = std::size(output_data); EXPECT_EQ(LZWDecompressor::Status::kSuccess, decompressor->Decode(output_data, &output_size)); - EXPECT_EQ(pdfium::size(kExpectedScanline), output_size); + EXPECT_EQ(std::size(kExpectedScanline), output_size); EXPECT_THAT(output_data, ElementsAreArray(kExpectedScanline)); } @@ -240,11 +241,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 = pdfium::size(kImageData); + uint32_t image_size = std::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 = pdfium::size(output_data); + uint32_t output_size = std::size(output_data); decompressor->SetSource(kImageData, image_size); EXPECT_EQ(LZWDecompressor::Status::kError,
diff --git a/core/fxcodec/jbig2/JBig2_ArithDecoder.cpp b/core/fxcodec/jbig2/JBig2_ArithDecoder.cpp index 0aec465..09eaaf3 100644 --- a/core/fxcodec/jbig2/JBig2_ArithDecoder.cpp +++ b/core/fxcodec/jbig2/JBig2_ArithDecoder.cpp
@@ -6,9 +6,10 @@ #include "core/fxcodec/jbig2/JBig2_ArithDecoder.h" +#include <iterator> + #include "core/fxcodec/jbig2/JBig2_BitStream.h" #include "third_party/base/check.h" -#include "third_party/base/cxx17_backports.h" namespace { @@ -42,13 +43,13 @@ if (qe.bSwitch) m_MPS = !m_MPS; m_I = qe.NLPS; - DCHECK(m_I < pdfium::size(kQeTable)); + DCHECK(m_I < std::size(kQeTable)); return D; } int JBig2ArithCtx::DecodeNMPS(const JBig2ArithQe& qe) { m_I = qe.NMPS; - DCHECK(m_I < pdfium::size(kQeTable)); + DCHECK(m_I < std::size(kQeTable)); return MPS(); } @@ -66,7 +67,7 @@ int CJBig2_ArithDecoder::Decode(JBig2ArithCtx* pCX) { DCHECK(pCX); - DCHECK(pCX->I() < pdfium::size(kQeTable)); + DCHECK(pCX->I() < std::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 c162c6c..be9ddf5 100644 --- a/core/fxcodec/jbig2/JBig2_ArithIntDecoder.cpp +++ b/core/fxcodec/jbig2/JBig2_ArithIntDecoder.cpp
@@ -9,7 +9,6 @@ #include <vector> #include "core/fxcrt/fx_safe_types.h" -#include "third_party/base/cxx17_backports.h" namespace { @@ -30,7 +29,7 @@ std::vector<JBig2ArithCtx>* context, int* prev, size_t depth) { - static const size_t kDepthEnd = pdfium::size(kArithIntDecodeData) - 1; + static const size_t kDepthEnd = std::size(kArithIntDecodeData) - 1; if (depth == kDepthEnd) return kDepthEnd;
diff --git a/core/fxcodec/jbig2/JBig2_HuffmanTable.cpp b/core/fxcodec/jbig2/JBig2_HuffmanTable.cpp index 43ae0df..dc26635 100644 --- a/core/fxcodec/jbig2/JBig2_HuffmanTable.cpp +++ b/core/fxcodec/jbig2/JBig2_HuffmanTable.cpp
@@ -6,13 +6,13 @@ #include "core/fxcodec/jbig2/JBig2_HuffmanTable.h" +#include <iterator> #include <limits> #include "core/fxcodec/jbig2/JBig2_BitStream.h" #include "core/fxcodec/jbig2/JBig2_Context.h" #include "core/fxcrt/fx_safe_types.h" #include "third_party/base/check.h" -#include "third_party/base/cxx17_backports.h" namespace { @@ -107,24 +107,24 @@ constexpr HuffmanTable kHuffmanTables[16] = { {false, nullptr, 0}, // Zero dummy to preserve indexing. - {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)}}; + {false, kTableLine1, std::size(kTableLine1)}, + {true, kTableLine2, std::size(kTableLine2)}, + {true, kTableLine3, std::size(kTableLine3)}, + {false, kTableLine4, std::size(kTableLine4)}, + {false, kTableLine5, std::size(kTableLine5)}, + {false, kTableLine6, std::size(kTableLine6)}, + {false, kTableLine7, std::size(kTableLine7)}, + {true, kTableLine8, std::size(kTableLine8)}, + {true, kTableLine9, std::size(kTableLine9)}, + {true, kTableLine10, std::size(kTableLine10)}, + {false, kTableLine11, std::size(kTableLine11)}, + {false, kTableLine12, std::size(kTableLine12)}, + {false, kTableLine13, std::size(kTableLine13)}, + {false, kTableLine14, std::size(kTableLine14)}, + {false, kTableLine15, std::size(kTableLine15)}}; static_assert(CJBig2_HuffmanTable::kNumHuffmanTables == - pdfium::size(kHuffmanTables), + std::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 a20ecff..98595d4 100644 --- a/core/fxcrt/cfx_seekablestreamproxy_unittest.cpp +++ b/core/fxcrt/cfx_seekablestreamproxy_unittest.cpp
@@ -4,10 +4,11 @@ #include "core/fxcrt/cfx_seekablestreamproxy.h" +#include <iterator> + #include "core/fxcrt/cfx_readonlymemorystream.h" #include "core/fxcrt/retain_ptr.h" #include "testing/gtest/include/gtest/gtest.h" -#include "third_party/base/cxx17_backports.h" #include "third_party/base/span.h" TEST(SeekableStreamProxyTest, NullStream) { @@ -16,7 +17,7 @@ pdfium::make_span<const uint8_t>(nullptr, 0))); wchar_t buffer[16]; - EXPECT_EQ(0u, proxy_stream->ReadBlock(buffer, pdfium::size(buffer))); + EXPECT_EQ(0u, proxy_stream->ReadBlock(buffer, std::size(buffer))); } TEST(SeekableStreamProxyTest, DefaultStreamBOMNotRecognized) { @@ -26,7 +27,7 @@ reinterpret_cast<const uint8_t*>(data), sizeof(data) - 1))); wchar_t buffer[16]; - EXPECT_EQ(0u, proxy_stream->ReadBlock(buffer, pdfium::size(buffer))); + EXPECT_EQ(0u, proxy_stream->ReadBlock(buffer, std::size(buffer))); } TEST(SeekableStreamProxyTest, UTF8Stream) { @@ -36,7 +37,7 @@ reinterpret_cast<const uint8_t*>(data), sizeof(data) - 1))); wchar_t buffer[16]; - EXPECT_EQ(3u, proxy_stream->ReadBlock(buffer, pdfium::size(buffer))); + EXPECT_EQ(3u, proxy_stream->ReadBlock(buffer, std::size(buffer))); EXPECT_EQ(L'*', buffer[0]); EXPECT_EQ(L'\u00A2', buffer[1]); EXPECT_EQ(L'*', buffer[2]); @@ -49,7 +50,7 @@ reinterpret_cast<const uint8_t*>(data), sizeof(data) - 1))); wchar_t buffer[16]; - EXPECT_EQ(2u, proxy_stream->ReadBlock(buffer, pdfium::size(buffer))); + EXPECT_EQ(2u, proxy_stream->ReadBlock(buffer, std::size(buffer))); EXPECT_EQ(L'A', buffer[0]); EXPECT_EQ(L'\u0142', buffer[1]); } @@ -61,7 +62,7 @@ reinterpret_cast<const uint8_t*>(data), sizeof(data) - 1))); wchar_t buffer[16]; - EXPECT_EQ(2u, proxy_stream->ReadBlock(buffer, pdfium::size(buffer))); + EXPECT_EQ(2u, proxy_stream->ReadBlock(buffer, std::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 644e214..e71781b 100644 --- a/core/fxcrt/fx_coordinates.cpp +++ b/core/fxcrt/fx_coordinates.cpp
@@ -9,13 +9,13 @@ #include <math.h> #include <algorithm> +#include <iterator> #include <utility> #include "build/build_config.h" #include "core/fxcrt/fx_extension.h" #include "core/fxcrt/fx_safe_types.h" #include "core/fxcrt/fx_system.h" -#include "third_party/base/cxx17_backports.h" #ifndef NDEBUG #include <ostream> @@ -501,7 +501,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 < pdfium::size(points); i++) { + for (size_t i = 1; i < std::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 70837fe..f3e7f3c 100644 --- a/core/fxcrt/fx_extension_unittest.cpp +++ b/core/fxcrt/fx_extension_unittest.cpp
@@ -6,10 +6,10 @@ #include <math.h> +#include <iterator> #include <limits> #include "testing/gtest/include/gtest/gtest.h" -#include "third_party/base/cxx17_backports.h" TEST(fxcrt, FXSYS_IsLowerASCII) { EXPECT_TRUE(FXSYS_IsLowerASCII('a')); @@ -198,8 +198,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 < pdfium::size(ascending); ++i) { - for (size_t j = 0; j < pdfium::size(ascending); ++j) { + for (size_t i = 0; i < std::size(ascending); ++i) { + for (size_t j = 0; j < std::size(ascending); ++j) { if (i == j) { EXPECT_TRUE(FXSYS_SafeEQ(ascending[i], ascending[j])) << " at " << i << " " << j;
diff --git a/core/fxcrt/fx_memory.cpp b/core/fxcrt/fx_memory.cpp index c0a9b8f..7dfc251 100644 --- a/core/fxcrt/fx_memory.cpp +++ b/core/fxcrt/fx_memory.cpp
@@ -8,6 +8,7 @@ #include <stdlib.h> // For abort(). +#include <iterator> #include <limits> #include "build/build_config.h" @@ -81,7 +82,7 @@ constexpr DWORD kOomExceptionCode = 0xe0000008; ULONG_PTR exception_args[] = {size}; ::RaiseException(kOomExceptionCode, EXCEPTION_NONCONTINUABLE, - pdfium::size(exception_args), exception_args); + std::size(exception_args), exception_args); #endif // Terminate cleanly.
diff --git a/core/fxcrt/fx_string.cpp b/core/fxcrt/fx_string.cpp index 96675d9..4a4e2fc 100644 --- a/core/fxcrt/fx_string.cpp +++ b/core/fxcrt/fx_string.cpp
@@ -6,11 +6,12 @@ #include "core/fxcrt/fx_string.h" +#include <iterator> + #include "core/fxcrt/cfx_utf8decoder.h" #include "core/fxcrt/cfx_utf8encoder.h" #include "core/fxcrt/fx_extension.h" #include "third_party/base/compiler_specific.h" -#include "third_party/base/cxx17_backports.h" ByteString FX_UTF8Encode(WideStringView wsStr) { CFX_UTF8Encoder encoder; @@ -137,7 +138,7 @@ float StringToFloat(ByteStringView strc) { return StringTo<float>(strc, kFractionScalesFloat, - pdfium::size(kFractionScalesFloat)); + std::size(kFractionScalesFloat)); } float StringToFloat(WideStringView wsStr) { @@ -150,7 +151,7 @@ double StringToDouble(ByteStringView strc) { return StringTo<double>(strc, kFractionScalesDouble, - pdfium::size(kFractionScalesDouble)); + std::size(kFractionScalesDouble)); } double StringToDouble(WideStringView wsStr) {
diff --git a/core/fxcrt/fx_system_unittest.cpp b/core/fxcrt/fx_system_unittest.cpp index 1f33377..7917eb4 100644 --- a/core/fxcrt/fx_system_unittest.cpp +++ b/core/fxcrt/fx_system_unittest.cpp
@@ -4,13 +4,13 @@ #include <math.h> +#include <iterator> #include <limits> #include "build/build_config.h" #include "core/fxcrt/fx_string.h" #include "core/fxcrt/fx_system.h" #include "testing/gtest/include/gtest/gtest.h" -#include "third_party/base/cxx17_backports.h" // Unit test covering cases where PDFium replaces well-known library // functionality on any given platformn. @@ -275,7 +275,7 @@ good_time.tm_sec = 59; wchar_t buf[100] = {}; - EXPECT_EQ(19u, FXSYS_wcsftime(buf, pdfium::size(buf), L"%Y-%m-%dT%H:%M:%S", + EXPECT_EQ(19u, FXSYS_wcsftime(buf, std::size(buf), L"%Y-%m-%dT%H:%M:%S", &good_time)); EXPECT_STREQ(L"1974-08-09T11:59:59", buf); @@ -290,7 +290,7 @@ for (int year = -2500; year <= 8500; ++year) { year_time.tm_year = year; wchar_t year_buf[100] = {}; - FXSYS_wcsftime(year_buf, pdfium::size(year_buf), L"%Y-%m-%dT%H:%M:%S", + FXSYS_wcsftime(year_buf, std::size(year_buf), L"%Y-%m-%dT%H:%M:%S", &year_time); } @@ -303,7 +303,7 @@ bad_time.tm_min = -1; bad_time.tm_sec = -1; - FXSYS_wcsftime(buf, pdfium::size(buf), L"%y-%m-%dT%H:%M:%S", &bad_time); + FXSYS_wcsftime(buf, std::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 = {}; @@ -314,7 +314,7 @@ feb_time.tm_min = 00; feb_time.tm_sec = 00; - FXSYS_wcsftime(buf, pdfium::size(buf), L"%y-%m-%dT%H:%M:%S", &feb_time); + FXSYS_wcsftime(buf, std::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 9b69e98..358500f 100644 --- a/core/fxcrt/fx_unicode.cpp +++ b/core/fxcrt/fx_unicode.cpp
@@ -8,8 +8,9 @@ #include <stddef.h> +#include <iterator> + #include "third_party/base/check.h" -#include "third_party/base/cxx17_backports.h" namespace { @@ -33,7 +34,7 @@ #undef CHARPROP____ constexpr size_t kTextLayoutCodePropertiesSize = - pdfium::size(kTextLayoutCodeProperties); + std::size(kTextLayoutCodeProperties); static_assert(kTextLayoutCodePropertiesSize == 65536, "missing characters"); @@ -66,7 +67,7 @@ #undef CHARPROP____ constexpr size_t kExtendedTextLayoutCodePropertiesSize = - pdfium::size(kExtendedTextLayoutCodeProperties); + std::size(kExtendedTextLayoutCodeProperties); static_assert(kExtendedTextLayoutCodePropertiesSize == 65536, "missing characters"); @@ -125,7 +126,7 @@ }; constexpr size_t kFXTextLayoutBidiMirrorSize = - pdfium::size(kFXTextLayoutBidiMirror); + std::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 80370b5..8632280 100644 --- a/core/fxcrt/widestring_unittest.cpp +++ b/core/fxcrt/widestring_unittest.cpp
@@ -12,7 +12,6 @@ #include "core/fxcrt/fx_string.h" #include "testing/gtest/include/gtest/gtest.h" #include "third_party/base/containers/contains.h" -#include "third_party/base/cxx17_backports.h" #include "third_party/base/span.h" namespace fxcrt { @@ -1150,7 +1149,7 @@ {L"\x3132\x6162", ByteString("\x32\x31\x62\x61\0\0", 6)}, }; - for (size_t i = 0; i < pdfium::size(utf16le_encode_cases); ++i) { + for (size_t i = 0; i < std::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 7722e64..a59d9fe 100644 --- a/core/fxge/android/cfpf_skiafontmgr.cpp +++ b/core/fxge/android/cfpf_skiafontmgr.cpp
@@ -7,6 +7,7 @@ #include "core/fxge/android/cfpf_skiafontmgr.h" #include <algorithm> +#include <iterator> #include <utility> #include "core/fxcrt/fx_codepage.h" @@ -18,7 +19,6 @@ #include "core/fxge/fx_font.h" #include "core/fxge/fx_freetype.h" #include "third_party/base/containers/adapters.h" -#include "third_party/base/cxx17_backports.h" namespace { @@ -248,10 +248,10 @@ return family_iter->second.get(); uint32_t dwFaceName = FPF_SKIANormalizeFontName(bsFamilyname); - uint32_t dwSubst = FPF_SkiaGetSubstFont(dwFaceName, kSkiaFontmap, - pdfium::size(kSkiaFontmap)); + uint32_t dwSubst = + FPF_SkiaGetSubstFont(dwFaceName, kSkiaFontmap, std::size(kSkiaFontmap)); uint32_t dwSubstSans = FPF_SkiaGetSubstFont(dwFaceName, kSkiaSansFontMap, - pdfium::size(kSkiaSansFontMap)); + std::size(kSkiaSansFontMap)); bool bMaybeSymbol = FPF_SkiaMaybeSymbol(bsFamilyname); if (uCharset != FX_Charset::kMSWin_Arabic && FPF_SkiaMaybeArabic(bsFamilyname)) {
diff --git a/core/fxge/cfx_folderfontinfo.cpp b/core/fxge/cfx_folderfontinfo.cpp index 8da1719..c40c13b 100644 --- a/core/fxge/cfx_folderfontinfo.cpp +++ b/core/fxge/cfx_folderfontinfo.cpp
@@ -6,6 +6,7 @@ #include "core/fxge/cfx_folderfontinfo.h" +#include <iterator> #include <limits> #include <utility> @@ -19,7 +20,6 @@ #include "core/fxge/cfx_fontmapper.h" #include "core/fxge/fx_font.h" #include "third_party/base/containers/contains.h" -#include "third_party/base/cxx17_backports.h" namespace { @@ -302,8 +302,7 @@ } void* CFX_FolderFontInfo::GetSubstFont(const ByteString& face) { - for (size_t iBaseFont = 0; iBaseFont < pdfium::size(Base14Substs); - iBaseFont++) { + for (size_t iBaseFont = 0; iBaseFont < std::size(Base14Substs); iBaseFont++) { if (face == Base14Substs[iBaseFont].m_pName) return GetFont(Base14Substs[iBaseFont].m_pSubstName); }
diff --git a/core/fxge/cfx_font.cpp b/core/fxge/cfx_font.cpp index 4df6de4..6e4fc0f 100644 --- a/core/fxge/cfx_font.cpp +++ b/core/fxge/cfx_font.cpp
@@ -26,7 +26,6 @@ #include "core/fxge/fx_font.h" #include "core/fxge/scoped_font_transform.h" #include "third_party/base/check.h" -#include "third_party/base/cxx17_backports.h" #include "third_party/base/numerics/safe_conversions.h" #include "third_party/base/span.h" @@ -241,9 +240,9 @@ }; constexpr size_t kWeightPowArraySize = 100; -static_assert(kWeightPowArraySize == pdfium::size(kWeightPow), "Wrong size"); -static_assert(kWeightPowArraySize == pdfium::size(kWeightPow11), "Wrong size"); -static_assert(kWeightPowArraySize == pdfium::size(kWeightPowShiftJis), +static_assert(kWeightPowArraySize == std::size(kWeightPow), "Wrong size"); +static_assert(kWeightPowArraySize == std::size(kWeightPow11), "Wrong size"); +static_assert(kWeightPowArraySize == std::size(kWeightPowShiftJis), "Wrong size"); } // namespace @@ -274,7 +273,7 @@ // static ByteString CFX_Font::GetDefaultFontNameByCharset(FX_Charset nCharset) { - for (size_t i = 0; i < pdfium::size(kDefaultTTFMap) - 1; ++i) { + for (size_t i = 0; i < std::size(kDefaultTTFMap) - 1; ++i) { if (static_cast<int>(nCharset) == kDefaultTTFMap[i].charset) return kDefaultTTFMap[i].fontname; } @@ -780,7 +779,7 @@ // |angle| is non-positive so |-angle| is used as the index. Need to make sure // |angle| != INT_MIN since -INT_MIN is undefined. if (angle > 0 || angle == std::numeric_limits<int>::min() || - static_cast<size_t>(-angle) >= pdfium::size(kAngleSkew)) { + static_cast<size_t>(-angle) >= std::size(kAngleSkew)) { return -58; } return kAngleSkew[-angle];
diff --git a/core/fxge/cfx_fontmgr.cpp b/core/fxge/cfx_fontmgr.cpp index 0775982..23b79e0 100644 --- a/core/fxge/cfx_fontmgr.cpp +++ b/core/fxge/cfx_fontmgr.cpp
@@ -6,6 +6,7 @@ #include "core/fxge/cfx_fontmgr.h" +#include <iterator> #include <memory> #include <utility> @@ -16,7 +17,6 @@ #include "core/fxge/fx_font.h" #include "core/fxge/systemfontinfo_iface.h" #include "third_party/base/check_op.h" -#include "third_party/base/cxx17_backports.h" namespace { @@ -41,7 +41,7 @@ {kFoxitSymbolFontData, 16729}, {kFoxitDingbatsFontData, 29513}, }; -static_assert(pdfium::size(kFoxitFonts) == CFX_FontMapper::kNumStandardFonts, +static_assert(std::size(kFoxitFonts) == CFX_FontMapper::kNumStandardFonts, "Wrong font count"); constexpr BuiltinFont kGenericSansFont = {kFoxitSansMMFontData, 66919}; @@ -76,12 +76,12 @@ CFX_FontMgr::FontDesc::~FontDesc() = default; void CFX_FontMgr::FontDesc::SetFace(size_t index, CFX_Face* face) { - CHECK_LT(index, pdfium::size(m_TTCFaces)); + CHECK_LT(index, std::size(m_TTCFaces)); m_TTCFaces[index].Reset(face); } CFX_Face* CFX_FontMgr::FontDesc::GetFace(size_t index) const { - CHECK_LT(index, pdfium::size(m_TTCFaces)); + CHECK_LT(index, std::size(m_TTCFaces)); return m_TTCFaces[index].Get(); } @@ -145,7 +145,7 @@ // static pdfium::span<const uint8_t> CFX_FontMgr::GetStandardFont(size_t index) { - CHECK_LT(index, pdfium::size(kFoxitFonts)); + CHECK_LT(index, std::size(kFoxitFonts)); return pdfium::make_span(kFoxitFonts[index].m_pFontData, kFoxitFonts[index].m_dwSize); }
diff --git a/core/fxge/dib/cfx_dibbase.cpp b/core/fxge/dib/cfx_dibbase.cpp index 3bab977..a315567 100644 --- a/core/fxge/dib/cfx_dibbase.cpp +++ b/core/fxge/dib/cfx_dibbase.cpp
@@ -23,7 +23,6 @@ #include "core/fxge/dib/cfx_imagetransformer.h" #include "third_party/base/check.h" #include "third_party/base/check_op.h" -#include "third_party/base/cxx17_backports.h" #include "third_party/base/notreached.h" #include "third_party/base/span.h" @@ -180,7 +179,7 @@ int src_top) { pdfium::span<const uint32_t> src_palette = pSrcBitmap->GetPaletteSpan(); uint8_t gray[256]; - for (size_t i = 0; i < pdfium::size(gray); ++i) { + for (size_t i = 0; i < std::size(gray); ++i) { gray[i] = FXRGB2GRAY(FXARGB_R(src_palette[i]), FXARGB_G(src_palette[i]), FXARGB_B(src_palette[i])); }
diff --git a/core/fxge/dib/cfx_imagetransformer.cpp b/core/fxge/dib/cfx_imagetransformer.cpp index f566413..2554912 100644 --- a/core/fxge/dib/cfx_imagetransformer.cpp +++ b/core/fxge/dib/cfx_imagetransformer.cpp
@@ -8,6 +8,7 @@ #include <math.h> +#include <iterator> #include <memory> #include <utility> @@ -17,7 +18,6 @@ #include "core/fxge/dib/fx_dib.h" #include "third_party/base/check.h" #include "third_party/base/compiler_specific.h" -#include "third_party/base/cxx17_backports.h" #include "third_party/base/notreached.h" #include "third_party/base/numerics/safe_conversions.h" @@ -306,10 +306,10 @@ if (m_Storer.GetBitmap()->HasPalette()) { pdfium::span<const uint32_t> palette = m_Storer.GetBitmap()->GetPaletteSpan(); - for (size_t i = 0; i < pdfium::size(argb); i++) + for (size_t i = 0; i < std::size(argb); i++) argb[i] = palette[i]; } else { - for (size_t i = 0; i < pdfium::size(argb); i++) { + for (size_t i = 0; i < std::size(argb); i++) { uint32_t v = static_cast<uint32_t>(i); argb[i] = ArgbEncode(0xff, v, v, v); }
diff --git a/core/fxge/linux/fx_linux_impl.cpp b/core/fxge/linux/fx_linux_impl.cpp index fa2367e..86e0244 100644 --- a/core/fxge/linux/fx_linux_impl.cpp +++ b/core/fxge/linux/fx_linux_impl.cpp
@@ -4,6 +4,7 @@ // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com +#include <iterator> #include <memory> #include <utility> @@ -15,7 +16,6 @@ #include "core/fxge/fx_font.h" #include "core/fxge/systemfontinfo_iface.h" #include "third_party/base/check.h" -#include "third_party/base/cxx17_backports.h" #if !BUILDFLAG(IS_LINUX) && !BUILDFLAG(IS_CHROMEOS) && !defined(OS_FUCHSIA) && \ !defined(OS_ASMJS) @@ -106,7 +106,7 @@ switch (charset) { case FX_Charset::kShiftJIS: { JpFontFamily index = GetJapanesePreference(face, weight, pitch_family); - DCHECK(index < pdfium::size(kLinuxJpFontList)); + DCHECK(index < std::size(kLinuxJpFontList)); for (const char* name : kLinuxJpFontList[index]) { auto it = m_FontList.find(name); if (it != m_FontList.end())
diff --git a/core/fxge/win32/cgdi_plus_ext.cpp b/core/fxge/win32/cgdi_plus_ext.cpp index 22297c4..c747408 100644 --- a/core/fxge/win32/cgdi_plus_ext.cpp +++ b/core/fxge/win32/cgdi_plus_ext.cpp
@@ -25,7 +25,6 @@ #include "core/fxge/cfx_path.h" #include "core/fxge/dib/cfx_dibitmap.h" #include "core/fxge/win32/cwin32_platform.h" -#include "third_party/base/cxx17_backports.h" #include "third_party/base/numerics/safe_conversions.h" #include "third_party/base/span.h" @@ -114,7 +113,7 @@ "GdipSetWorldTransform", "GdipSetPixelOffsetMode", }; -static_assert(pdfium::size(g_GdipFuncNames) == +static_assert(std::size(g_GdipFuncNames) == static_cast<size_t>(FuncId_GdipSetPixelOffsetMode) + 1, "g_GdipFuncNames has wrong size"); @@ -378,7 +377,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 < pdfium::size(kPairs); ++i) { + for (size_t i = 0; i < std::size(kPairs); ++i) { size_t pair1 = kPairs[i][0]; size_t pair2 = kPairs[i][1]; @@ -552,8 +551,8 @@ if (!m_hModule) return; - m_Functions.resize(pdfium::size(g_GdipFuncNames)); - for (size_t i = 0; i < pdfium::size(g_GdipFuncNames); ++i) { + m_Functions.resize(std::size(g_GdipFuncNames)); + for (size_t i = 0; i < std::size(g_GdipFuncNames); ++i) { m_Functions[i] = GetProcAddress(m_hModule, g_GdipFuncNames[i]); if (!m_Functions[i]) { m_hModule = nullptr;
diff --git a/core/fxge/win32/cwin32_platform.cpp b/core/fxge/win32/cwin32_platform.cpp index 46532e1..c34fa37 100644 --- a/core/fxge/win32/cwin32_platform.cpp +++ b/core/fxge/win32/cwin32_platform.cpp
@@ -6,13 +6,13 @@ #include "core/fxge/win32/cwin32_platform.h" +#include <iterator> #include <memory> #include <utility> #include "core/fxcrt/fx_codepage.h" #include "core/fxge/cfx_folderfontinfo.h" #include "core/fxge/cfx_gemodule.h" -#include "third_party/base/cxx17_backports.h" #include "third_party/base/numerics/safe_conversions.h" #include "third_party/base/win/scoped_select_object.h" #include "third_party/base/win/win_util.h" @@ -63,7 +63,7 @@ }; bool GetSubFontName(ByteString* name) { - for (size_t i = 0; i < pdfium::size(kJpFontNameMap); ++i) { + for (size_t i = 0; i < std::size(kJpFontNameMap); ++i) { if (!FXSYS_stricmp(name->c_str(), kJpFontNameMap[i].m_pSrcFontName)) { *name = kJpFontNameMap[i].m_pSubFontName; return true; @@ -327,13 +327,13 @@ char facebuf[100]; { ScopedSelectObject select_object(m_hDC, hFont); - ::GetTextFaceA(m_hDC, pdfium::size(facebuf), facebuf); + ::GetTextFaceA(m_hDC, std::size(facebuf), facebuf); } if (new_face.EqualNoCase(facebuf)) return hFont; WideString wsFace = WideString::FromDefANSI(facebuf); - for (size_t i = 0; i < pdfium::size(kVariantNames); ++i) { + for (size_t i = 0; i < std::size(kVariantNames); ++i) { if (new_face != kVariantNames[i].m_pFaceName) continue;
diff --git a/fpdfsdk/cpdfsdk_appstream.cpp b/fpdfsdk/cpdfsdk_appstream.cpp index e688299..017eeaf 100644 --- a/fpdfsdk/cpdfsdk_appstream.cpp +++ b/fpdfsdk/cpdfsdk_appstream.cpp
@@ -8,6 +8,7 @@ #include <math.h> +#include <iterator> #include <memory> #include <sstream> #include <utility> @@ -36,7 +37,6 @@ #include "fpdfsdk/pwl/cpwl_edit.h" #include "fpdfsdk/pwl/cpwl_edit_impl.h" #include "fpdfsdk/pwl/cpwl_wnd.h" -#include "third_party/base/cxx17_backports.h" #include "third_party/base/numerics/safe_conversions.h" namespace { @@ -172,8 +172,8 @@ {CFX_PointF(0.40f, 0.60f), CFX_PointF(0.28f, 0.66f), CFX_PointF(0.30f, 0.56f)}}; - for (size_t i = 0; i < pdfium::size(pts); ++i) { - for (size_t j = 0; j < pdfium::size(pts[0]); ++j) { + for (size_t i = 0; i < std::size(pts); ++i) { + for (size_t j = 0; j < std::size(pts[0]); ++j) { pts[i][j].x = pts[i][j].x * fWidth + crBBox.left; pts[i][j].y *= pts[i][j].y * fHeight + crBBox.bottom; } @@ -182,8 +182,8 @@ fxcrt::ostringstream csAP; csAP << pts[0][0].x << " " << pts[0][0].y << " " << kMoveToOperator << "\n"; - for (size_t i = 0; i < pdfium::size(pts); ++i) { - size_t nNext = i < pdfium::size(pts) - 1 ? i + 1 : 0; + for (size_t i = 0; i < std::size(pts); ++i) { + size_t nNext = i < std::size(pts) - 1 ? i + 1 : 0; float px1 = pts[i][1].x - pts[i][0].x; float py1 = pts[i][1].y - pts[i][0].y; @@ -307,8 +307,8 @@ csAP << points[0].x << " " << points[0].y << " " << kMoveToOperator << "\n"; int next = 0; - for (size_t i = 0; i < pdfium::size(points); ++i) { - next = (next + 2) % pdfium::size(points); + for (size_t i = 0; i < std::size(points); ++i) { + next = (next + 2) % std::size(points); csAP << points[next].x << " " << points[next].y << " " << kLineToOperator << "\n"; }
diff --git a/fpdfsdk/fpdf_annot.cpp b/fpdfsdk/fpdf_annot.cpp index 27edb59..131ffc0 100644 --- a/fpdfsdk/fpdf_annot.cpp +++ b/fpdfsdk/fpdf_annot.cpp
@@ -38,7 +38,6 @@ #include "fpdfsdk/cpdfsdk_helpers.h" #include "fpdfsdk/cpdfsdk_interactiveform.h" #include "third_party/base/check.h" -#include "third_party/base/cxx17_backports.h" #include "third_party/base/numerics/safe_conversions.h" #include "third_party/base/ptr_util.h" @@ -1032,10 +1031,9 @@ return false; static constexpr const char* kModeKeyForMode[] = {"N", "R", "D"}; - static_assert( - pdfium::size(kModeKeyForMode) == FPDF_ANNOT_APPEARANCEMODE_COUNT, - "length of kModeKeyForMode should be equal to " - "FPDF_ANNOT_APPEARANCEMODE_COUNT"); + static_assert(std::size(kModeKeyForMode) == FPDF_ANNOT_APPEARANCEMODE_COUNT, + "length of kModeKeyForMode should be equal to " + "FPDF_ANNOT_APPEARANCEMODE_COUNT"); const char* modeKey = kModeKeyForMode[appearanceMode]; CPDF_Dictionary* pApDict = pAnnotDict->GetDictFor(pdfium::annotation::kAP);
diff --git a/fpdfsdk/fpdf_annot_embeddertest.cpp b/fpdfsdk/fpdf_annot_embeddertest.cpp index 5055768..1e45eb1 100644 --- a/fpdfsdk/fpdf_annot_embeddertest.cpp +++ b/fpdfsdk/fpdf_annot_embeddertest.cpp
@@ -28,7 +28,6 @@ #include "testing/gtest/include/gtest/gtest.h" #include "testing/utils/hash.h" #include "third_party/base/containers/contains.h" -#include "third_party/base/cxx17_backports.h" #include "third_party/base/span.h" using pdfium::kAnnotationStampWithApChecksum; @@ -152,8 +151,7 @@ EXPECT_EQ("Form", sub_type); // Check that the appearance stream is same as we just set. - const uint32_t kStreamDataSize = - pdfium::size(kStreamData) * sizeof(FPDF_WCHAR); + const uint32_t kStreamDataSize = std::size(kStreamData) * sizeof(FPDF_WCHAR); unsigned long normal_length_bytes = FPDFAnnot_GetAP( annot.get(), FPDF_ANNOT_APPEARANCEMODE_NORMAL, nullptr, 0); ASSERT_EQ(kStreamDataSize, normal_length_bytes); @@ -228,21 +226,18 @@ static constexpr FS_POINTF kFirstInkStroke[] = { {80.0f, 90.0f}, {81.0f, 91.0f}, {82.0f, 92.0f}, {83.0f, 93.0f}, {84.0f, 94.0f}, {85.0f, 95.0f}}; - static constexpr size_t kFirstStrokePointCount = - pdfium::size(kFirstInkStroke); + static constexpr size_t kFirstStrokePointCount = std::size(kFirstInkStroke); static constexpr FS_POINTF kSecondInkStroke[] = { {70.0f, 90.0f}, {71.0f, 91.0f}, {72.0f, 92.0f}}; - static constexpr size_t kSecondStrokePointCount = - pdfium::size(kSecondInkStroke); + static constexpr size_t kSecondStrokePointCount = std::size(kSecondInkStroke); static constexpr FS_POINTF kThirdInkStroke[] = {{60.0f, 90.0f}, {61.0f, 91.0f}, {62.0f, 92.0f}, {63.0f, 93.0f}, {64.0f, 94.0f}}; - static constexpr size_t kThirdStrokePointCount = - pdfium::size(kThirdInkStroke); + static constexpr size_t kThirdStrokePointCount = std::size(kThirdInkStroke); // Negative test: |annot| is passed as nullptr. EXPECT_EQ(-1, FPDFAnnot_AddInkStroke(nullptr, kFirstInkStroke, @@ -321,7 +316,7 @@ static constexpr FS_POINTF kInkStroke[] = {{80.0f, 90.0f}, {81.0f, 91.0f}, {82.0f, 92.0f}, {83.0f, 93.0f}, {84.0f, 94.0f}, {85.0f, 95.0f}}; - static constexpr size_t kPointCount = pdfium::size(kInkStroke); + static constexpr size_t kPointCount = std::size(kInkStroke); // InkStroke should get added to ink annotation. Also inklist should get // created. @@ -2807,7 +2802,7 @@ FPDF_FORMFIELD_CHECKBOX, FPDF_FORMFIELD_RADIOBUTTON}; - for (size_t i = 0; i < pdfium::size(kExpectedAnnotTypes); ++i) { + for (size_t i = 0; i < std::size(kExpectedAnnotTypes); ++i) { ScopedFPDFAnnotation annot(FPDFPage_GetAnnot(page, i)); ASSERT_TRUE(annot); EXPECT_EQ(kExpectedAnnotTypes[i], @@ -2979,9 +2974,9 @@ // Test invalid parameters. EXPECT_FALSE(FPDFAnnot_SetFocusableSubtypes(nullptr, kDefaultSubtypes, - pdfium::size(kDefaultSubtypes))); + std::size(kDefaultSubtypes))); EXPECT_FALSE(FPDFAnnot_SetFocusableSubtypes(form_handle(), nullptr, - pdfium::size(kDefaultSubtypes))); + std::size(kDefaultSubtypes))); EXPECT_EQ(-1, FPDFAnnot_GetFocusableSubtypesCount(nullptr)); std::vector<FPDF_ANNOTATION_SUBTYPE> subtypes(1); @@ -3016,7 +3011,7 @@ // Make links and highlights focusable. static constexpr FPDF_ANNOTATION_SUBTYPE kSubTypes[] = {FPDF_ANNOT_LINK, FPDF_ANNOT_HIGHLIGHT}; - constexpr int kSubTypesCount = pdfium::size(kSubTypes); + constexpr int kSubTypesCount = std::size(kSubTypes); ASSERT_TRUE( FPDFAnnot_SetFocusableSubtypes(form_handle(), kSubTypes, kSubTypesCount)); ASSERT_EQ(kSubTypesCount, FPDFAnnot_GetFocusableSubtypesCount(form_handle()));
diff --git a/fpdfsdk/fpdf_formfill_embeddertest.cpp b/fpdfsdk/fpdf_formfill_embeddertest.cpp index 269187f..8a3b263 100644 --- a/fpdfsdk/fpdf_formfill_embeddertest.cpp +++ b/fpdfsdk/fpdf_formfill_embeddertest.cpp
@@ -21,7 +21,6 @@ #include "testing/gtest/include/gtest/gtest.h" #include "third_party/base/check.h" #include "third_party/base/check_op.h" -#include "third_party/base/cxx17_backports.h" using pdfium::kTextFormChecksum; @@ -833,7 +832,7 @@ static constexpr int kExpectedAnnotIndex[] = {1, 2, 3, 0}; // Tabs should iterate focus over annotations. - for (size_t i = 0; i < pdfium::size(kExpectedAnnotIndex); ++i) { + for (size_t i = 0; i < std::size(kExpectedAnnotIndex); ++i) { ASSERT_TRUE(FORM_OnKeyDown(form_handle(), page, FWL_VKEY_Tab, 0)); int page_index = -2; FPDF_ANNOTATION annot = nullptr; @@ -857,7 +856,7 @@ static constexpr int kExpectedAnnotIndex[] = {0, 3, 2, 1}; // Shift-tabs should iterate focus over annotations. - for (size_t i = 0; i < pdfium::size(kExpectedAnnotIndex); ++i) { + for (size_t i = 0; i < std::size(kExpectedAnnotIndex); ++i) { ASSERT_TRUE(FORM_OnKeyDown(form_handle(), page, FWL_VKEY_Tab, FWL_EVENTFLAG_ShiftKey)); int page_index = -2; @@ -3312,7 +3311,7 @@ // Set Widget and Link as supported tabbable annots. constexpr FPDF_ANNOTATION_SUBTYPE kFocusableSubtypes[] = {FPDF_ANNOT_WIDGET, FPDF_ANNOT_LINK}; - constexpr size_t kSubtypeCount = pdfium::size(kFocusableSubtypes); + constexpr size_t kSubtypeCount = std::size(kFocusableSubtypes); ASSERT_TRUE(FPDFAnnot_SetFocusableSubtypes( form_handle(), kFocusableSubtypes, kSubtypeCount)); }
diff --git a/fpdfsdk/fpdf_ppo_embeddertest.cpp b/fpdfsdk/fpdf_ppo_embeddertest.cpp index 41e70d0..6ee78d9 100644 --- a/fpdfsdk/fpdf_ppo_embeddertest.cpp +++ b/fpdfsdk/fpdf_ppo_embeddertest.cpp
@@ -2,6 +2,8 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +#include <iterator> + #include "core/fpdfapi/page/cpdf_form.h" #include "core/fpdfapi/page/cpdf_formobject.h" #include "fpdfsdk/cpdfsdk_helpers.h" @@ -13,7 +15,6 @@ #include "testing/embedder_test.h" #include "testing/embedder_test_constants.h" #include "testing/gtest/include/gtest/gtest.h" -#include "third_party/base/cxx17_backports.h" namespace { @@ -56,9 +57,8 @@ EXPECT_TRUE(FPDF_CopyViewerPreferences(output_doc.get(), document())); static constexpr int kPageIndices[] = {1}; - EXPECT_TRUE(FPDF_ImportPagesByIndex(output_doc.get(), document(), - kPageIndices, pdfium::size(kPageIndices), - 0)); + EXPECT_TRUE(FPDF_ImportPagesByIndex( + output_doc.get(), document(), kPageIndices, std::size(kPageIndices), 0)); EXPECT_EQ(1, FPDF_GetPageCount(output_doc.get())); UnloadPage(page); @@ -368,24 +368,20 @@ EXPECT_TRUE(output_doc); static constexpr int kBadIndices1[] = {-1}; - EXPECT_FALSE(FPDF_ImportPagesByIndex(output_doc.get(), document(), - kBadIndices1, pdfium::size(kBadIndices1), - 0)); + EXPECT_FALSE(FPDF_ImportPagesByIndex( + output_doc.get(), document(), kBadIndices1, std::size(kBadIndices1), 0)); static constexpr int kBadIndices2[] = {1}; - EXPECT_FALSE(FPDF_ImportPagesByIndex(output_doc.get(), document(), - kBadIndices2, pdfium::size(kBadIndices2), - 0)); + EXPECT_FALSE(FPDF_ImportPagesByIndex( + output_doc.get(), document(), kBadIndices2, std::size(kBadIndices2), 0)); static constexpr int kBadIndices3[] = {-1, 0, 1}; - EXPECT_FALSE(FPDF_ImportPagesByIndex(output_doc.get(), document(), - kBadIndices3, pdfium::size(kBadIndices3), - 0)); + EXPECT_FALSE(FPDF_ImportPagesByIndex( + output_doc.get(), document(), kBadIndices3, std::size(kBadIndices3), 0)); static constexpr int kBadIndices4[] = {42}; - EXPECT_FALSE(FPDF_ImportPagesByIndex(output_doc.get(), document(), - kBadIndices4, pdfium::size(kBadIndices4), - 0)); + EXPECT_FALSE(FPDF_ImportPagesByIndex( + output_doc.get(), document(), kBadIndices4, std::size(kBadIndices4), 0)); UnloadPage(page); } @@ -401,26 +397,26 @@ static constexpr int kGoodIndices1[] = {0, 0, 0, 0}; EXPECT_TRUE(FPDF_ImportPagesByIndex(output_doc.get(), document(), - kGoodIndices1, - pdfium::size(kGoodIndices1), 0)); + kGoodIndices1, std::size(kGoodIndices1), + 0)); EXPECT_EQ(4, FPDF_GetPageCount(output_doc.get())); static constexpr int kGoodIndices2[] = {0}; EXPECT_TRUE(FPDF_ImportPagesByIndex(output_doc.get(), document(), - kGoodIndices2, - pdfium::size(kGoodIndices2), 0)); + kGoodIndices2, std::size(kGoodIndices2), + 0)); EXPECT_EQ(5, FPDF_GetPageCount(output_doc.get())); static constexpr int kGoodIndices3[] = {4}; EXPECT_TRUE(FPDF_ImportPagesByIndex(output_doc.get(), document(), - kGoodIndices3, - pdfium::size(kGoodIndices3), 0)); + kGoodIndices3, std::size(kGoodIndices3), + 0)); EXPECT_EQ(6, FPDF_GetPageCount(output_doc.get())); static constexpr int kGoodIndices4[] = {1, 2, 3}; EXPECT_TRUE(FPDF_ImportPagesByIndex(output_doc.get(), document(), - kGoodIndices4, - pdfium::size(kGoodIndices4), 0)); + kGoodIndices4, std::size(kGoodIndices4), + 0)); EXPECT_EQ(9, FPDF_GetPageCount(output_doc.get())); // Passing in a nullptr should import all the pages. @@ -487,7 +483,7 @@ static constexpr int kIndices[] = {0}; EXPECT_TRUE(FPDF_ImportPagesByIndex(output_doc, document(), kIndices, - pdfium::size(kIndices), 0)); + std::size(kIndices), 0)); FPDF_CloseDocument(output_doc); UnloadPage(page); @@ -521,7 +517,7 @@ static constexpr int kIndices[] = {0, 1, 2, 3}; EXPECT_TRUE(FPDF_ImportPagesByIndex(output_doc, document(), kIndices, - pdfium::size(kIndices), 0)); + std::size(kIndices), 0)); ASSERT_EQ(4, FPDF_GetPageCount(output_doc)); for (size_t i = 0; i < 4; ++i) { FPDF_PAGE page = FPDF_LoadPage(output_doc, i); @@ -548,7 +544,7 @@ static constexpr int kIndices[] = {0}; EXPECT_TRUE(FPDF_ImportPagesByIndex(new_doc.get(), document(), kIndices, - pdfium::size(kIndices), 0)); + std::size(kIndices), 0)); EXPECT_EQ(1, FPDF_GetPageCount(new_doc.get())); ScopedFPDFPage new_page(FPDF_LoadPage(new_doc.get(), 0));
diff --git a/fpdfsdk/fpdf_signature_embeddertest.cpp b/fpdfsdk/fpdf_signature_embeddertest.cpp index 317ef24..2517731 100644 --- a/fpdfsdk/fpdf_signature_embeddertest.cpp +++ b/fpdfsdk/fpdf_signature_embeddertest.cpp
@@ -7,7 +7,6 @@ #include "public/fpdf_signature.h" #include "testing/embedder_test.h" #include "testing/fx_string_testhelpers.h" -#include "third_party/base/cxx17_backports.h" class FPDFSignatureEmbedderTest : public EmbedderTest {}; @@ -141,7 +140,7 @@ // FPDFSignatureObj_GetReason() positive testing. constexpr char kReason[] = "test reason"; // Return value includes the terminating NUL that is provided. - constexpr unsigned long kReasonUTF16Size = pdfium::size(kReason) * 2; + constexpr unsigned long kReasonUTF16Size = std::size(kReason) * 2; constexpr wchar_t kReasonWide[] = L"test reason"; unsigned long size = FPDFSignatureObj_GetReason(signature, nullptr, 0); ASSERT_EQ(kReasonUTF16Size, size);
diff --git a/fpdfsdk/fpdf_structtree_embeddertest.cpp b/fpdfsdk/fpdf_structtree_embeddertest.cpp index 3417654..36e6f37 100644 --- a/fpdfsdk/fpdf_structtree_embeddertest.cpp +++ b/fpdfsdk/fpdf_structtree_embeddertest.cpp
@@ -2,11 +2,12 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +#include <iterator> + #include "public/fpdf_structtree.h" #include "testing/embedder_test.h" #include "testing/fx_string_testhelpers.h" #include "third_party/abseil-cpp/absl/types/optional.h" -#include "third_party/base/cxx17_backports.h" class FPDFStructTreeEmbedderTest : public EmbedderTest {}; @@ -57,7 +58,7 @@ // Deliberately pass in a small buffer size to make sure |buffer| remains // untouched. ASSERT_EQ(24U, FPDF_StructElement_GetAltText(gchild_element, buffer, 1)); - for (size_t i = 0; i < pdfium::size(buffer); ++i) + for (size_t i = 0; i < std::size(buffer); ++i) EXPECT_EQ(0U, buffer[i]); EXPECT_EQ(-1, FPDF_StructElement_GetMarkedContentID(gchild_element)); @@ -108,7 +109,7 @@ // Deliberately pass in a small buffer size to make sure |buffer| remains // untouched. ASSERT_EQ(24U, FPDF_StructElement_GetActualText(gchild_element, buffer, 1)); - for (size_t i = 0; i < pdfium::size(buffer); ++i) + for (size_t i = 0; i < std::size(buffer); ++i) EXPECT_EQ(0U, buffer[i]); ASSERT_EQ(24U, FPDF_StructElement_GetActualText(gchild_element, buffer, sizeof(buffer))); @@ -412,7 +413,7 @@ // Deliberately pass in a small buffer size to make sure |buffer| remains // untouched. ASSERT_EQ(18U, FPDF_StructElement_GetType(element, buffer, 1)); - for (size_t i = 0; i < pdfium::size(buffer); ++i) + for (size_t i = 0; i < std::size(buffer); ++i) EXPECT_EQ(0U, buffer[i]); ASSERT_EQ(18U, FPDF_StructElement_GetType(element, buffer, sizeof(buffer))); @@ -446,7 +447,7 @@ // Deliberately pass in a small buffer size to make sure `buffer` remains // untouched. ASSERT_EQ(22U, FPDF_StructElement_GetObjType(child, buffer, 1)); - for (size_t i = 0; i < pdfium::size(buffer); ++i) + for (size_t i = 0; i < std::size(buffer); ++i) EXPECT_EQ(0U, buffer[i]); ASSERT_EQ(22U, @@ -460,7 +461,7 @@ ASSERT_EQ(0U, FPDF_StructElement_GetObjType(gchild, buffer, sizeof(buffer))); // Buffer is untouched. - for (size_t i = 0; i < pdfium::size(buffer); ++i) + for (size_t i = 0; i < std::size(buffer); ++i) EXPECT_EQ(0U, buffer[i]); ASSERT_EQ(1, FPDF_StructElement_CountChildren(gchild)); @@ -530,7 +531,7 @@ // Deliberately pass in a small buffer size to make sure |buffer| remains // untouched. ASSERT_EQ(20U, FPDF_StructElement_GetTitle(element, buffer, 1)); - for (size_t i = 0; i < pdfium::size(buffer); ++i) + for (size_t i = 0; i < std::size(buffer); ++i) EXPECT_EQ(0U, buffer[i]); ASSERT_EQ(20U, @@ -601,7 +602,7 @@ ASSERT_TRUE( FPDF_StructElement_Attr_GetName(attr, 1, buffer, 1, &out_len)); EXPECT_EQ(2U, out_len); - for (size_t i = 0; i < pdfium::size(buffer); ++i) + for (size_t i = 0; i < std::size(buffer); ++i) EXPECT_EQ(0, buffer[i]); ASSERT_TRUE(FPDF_StructElement_Attr_GetName(attr, 1, buffer,
diff --git a/fpdfsdk/fpdf_text_embeddertest.cpp b/fpdfsdk/fpdf_text_embeddertest.cpp index ee7278b..51715e0 100644 --- a/fpdfsdk/fpdf_text_embeddertest.cpp +++ b/fpdfsdk/fpdf_text_embeddertest.cpp
@@ -15,12 +15,11 @@ #include "testing/embedder_test.h" #include "testing/fx_string_testhelpers.h" #include "testing/gtest/include/gtest/gtest.h" -#include "third_party/base/cxx17_backports.h" namespace { constexpr char kHelloGoodbyeText[] = "Hello, world!\r\nGoodbye, world!"; -constexpr int kHelloGoodbyeTextSize = pdfium::size(kHelloGoodbyeText); +constexpr int kHelloGoodbyeTextSize = std::size(kHelloGoodbyeText); bool check_unsigned_shorts(const char* expected, const unsigned short* actual, @@ -675,7 +674,7 @@ "http://example.com/", "http://www.abc.com", }; - static const int kNumLinks = static_cast<int>(pdfium::size(kExpectedUrls)); + static const int kNumLinks = static_cast<int>(std::size(kExpectedUrls)); EXPECT_EQ(kNumLinks, FPDFLink_CountWebLinks(pagelink)); @@ -686,7 +685,7 @@ EXPECT_EQ(static_cast<int>(expected_len), FPDFLink_GetURL(pagelink, i, nullptr, 0)); EXPECT_EQ(static_cast<int>(expected_len), - FPDFLink_GetURL(pagelink, i, buffer, pdfium::size(buffer))); + FPDFLink_GetURL(pagelink, i, buffer, std::size(buffer))); EXPECT_TRUE(check_unsigned_shorts(kExpectedUrls[i], buffer, expected_len)); } @@ -713,8 +712,7 @@ static const int kUrlSize = static_cast<int>(sizeof(kExpectedUrl)); EXPECT_EQ(kUrlSize, FPDFLink_GetURL(pagelink, 1, nullptr, 0)); - EXPECT_EQ(kUrlSize, - FPDFLink_GetURL(pagelink, 1, buffer, pdfium::size(buffer))); + EXPECT_EQ(kUrlSize, FPDFLink_GetURL(pagelink, 1, buffer, std::size(buffer))); EXPECT_TRUE(check_unsigned_shorts(kExpectedUrl, buffer, kUrlSize)); FPDFLink_CloseWebLinks(pagelink); @@ -848,7 +846,7 @@ 16, 16, 16, 16, 16, 16, 16, 16, 16, 16}; int count = FPDFText_CountChars(textpage); - ASSERT_EQ(pdfium::size(kExpectedFontsSizes), static_cast<size_t>(count)); + ASSERT_EQ(std::size(kExpectedFontsSizes), static_cast<size_t>(count)); for (int i = 0; i < count; ++i) EXPECT_EQ(kExpectedFontsSizes[i], FPDFText_GetFontSize(textpage, i)) << i; @@ -967,18 +965,17 @@ static constexpr int kStartIndex = 238; ASSERT_EQ(268, FPDFText_CountChars(textpage)); - for (size_t i = 0; i < pdfium::size(kData); ++i) + for (size_t i = 0; i < std::size(kData); ++i) EXPECT_EQ(kData[i], FPDFText_GetUnicode(textpage, kStartIndex + i)); - unsigned short buffer[pdfium::size(kData) + 1]; + unsigned short buffer[std::size(kData) + 1]; memset(buffer, 0xbd, sizeof(buffer)); - int count = - FPDFText_GetText(textpage, kStartIndex, pdfium::size(kData), buffer); + int count = FPDFText_GetText(textpage, kStartIndex, std::size(kData), buffer); ASSERT_GT(count, 0); - ASSERT_EQ(pdfium::size(kData) + 1, static_cast<size_t>(count)); - for (size_t i = 0; i < pdfium::size(kData); ++i) + ASSERT_EQ(std::size(kData) + 1, static_cast<size_t>(count)); + for (size_t i = 0; i < std::size(kData); ++i) EXPECT_EQ(kData[i], buffer[i]); - EXPECT_EQ(0, buffer[pdfium::size(kData)]); + EXPECT_EQ(0, buffer[std::size(kData)]); FPDFText_ClosePage(textpage); UnloadPage(page); @@ -1000,8 +997,8 @@ 0x0056, 0x0065, 0x0072, 0x0069, 0x0074, 0x0061, 0xfffe, 0x0073, 0x0065, 0x0072, 0x0075, 0x006D, 0x0000}; { - constexpr int count = pdfium::size(soft_expected) - 1; - unsigned short buffer[pdfium::size(soft_expected)]; + constexpr int count = std::size(soft_expected) - 1; + unsigned short buffer[std::size(soft_expected)]; memset(buffer, 0, sizeof(buffer)); EXPECT_EQ(count + 1, FPDFText_GetText(textpage, 0, count, buffer)); @@ -1013,14 +1010,14 @@ { // There isn't the \0 in the actual doc, but there is a \r\n, so need to // add 1 to get aligned. - constexpr size_t offset = pdfium::size(soft_expected) + 1; + constexpr size_t offset = std::size(soft_expected) + 1; // Expecting 'User-\r\ngenerated', the - is a unicode character, so cannnot // store in a char[]. constexpr unsigned short hard_expected[] = { 0x0055, 0x0073, 0x0065, 0x0072, 0x2010, 0x000d, 0x000a, 0x0067, 0x0065, 0x006e, 0x0065, 0x0072, 0x0061, 0x0074, 0x0065, 0x0064, 0x0000}; - constexpr int count = pdfium::size(hard_expected) - 1; - unsigned short buffer[pdfium::size(hard_expected)]; + constexpr int count = std::size(hard_expected) - 1; + unsigned short buffer[std::size(hard_expected)]; EXPECT_EQ(count + 1, FPDFText_GetText(textpage, offset, count, buffer)); for (int i = 0; i < count; i++) @@ -1102,7 +1099,7 @@ 0x0061, 0x0073, 0x0020, 0x0063, 0x006f, 0x006d, 0x006d, 0x0069, 0x0074, 0x0074, 0x0065, 0x0064, 0x002c, 0x0020, 0x0069, 0x0074, 0x0020, 0x006e, 0x006f, 0x0074, 0x0069, 0x0002, 0x0066, 0x0069}; - static_assert(page_range_length == pdfium::size(expected), + static_assert(page_range_length == std::size(expected), "Expected should be the same size as the range being " "extracted from page."); EXPECT_LT(page_range_offset + page_range_length, @@ -1204,7 +1201,7 @@ // Positive testing. constexpr char kHelloText[] = "Hello, world!"; // Return value includes the terminating NUL that is provided. - constexpr unsigned long kHelloUTF16Size = pdfium::size(kHelloText) * 2; + constexpr unsigned long kHelloUTF16Size = std::size(kHelloText) * 2; constexpr wchar_t kHelloWideText[] = L"Hello, world!"; unsigned long size = FPDFTextObj_GetText(text_object, text_page, nullptr, 0); ASSERT_EQ(kHelloUTF16Size, size); @@ -1322,14 +1319,14 @@ ASSERT_TRUE(text_page); constexpr char kText[] = "ABCD"; - constexpr size_t kTextSize = pdfium::size(kText); + constexpr size_t kTextSize = std::size(kText); // -1 for CountChars not including the \0 EXPECT_EQ(static_cast<int>(kTextSize) - 1, FPDFText_CountChars(text_page.get())); unsigned short buffer[kTextSize]; int num_chars = - FPDFText_GetText(text_page.get(), 0, pdfium::size(buffer) - 1, buffer); + FPDFText_GetText(text_page.get(), 0, std::size(buffer) - 1, buffer); ASSERT_EQ(static_cast<int>(kTextSize), num_chars); EXPECT_TRUE(check_unsigned_shorts(kText, buffer, kTextSize)); } @@ -1345,9 +1342,8 @@ FPDF_TEXTPAGE text_page = FPDFText_LoadPage(page); ASSERT_TRUE(text_page); - static constexpr int kSubstringsSize[] = {pdfium::size("Hello,"), - pdfium::size(" world!\r\n"), - pdfium::size("Goodbye,")}; + static constexpr int kSubstringsSize[] = { + std::size("Hello,"), std::size(" world!\r\n"), std::size("Goodbye,")}; // -1 for CountChars not including the \0, but +1 for the extra control // character. @@ -1497,7 +1493,7 @@ TEST_F(FPDFTextEmbedderTest, GetMatrix) { constexpr char kExpectedText[] = "A1\r\nA2\r\nA3"; - constexpr size_t kExpectedTextSize = pdfium::size(kExpectedText); + constexpr size_t kExpectedTextSize = std::size(kExpectedText); constexpr FS_MATRIX kExpectedMatrices[] = { {12.0f, 0.0f, 0.0f, 10.0f, 66.0f, 90.0f}, {12.0f, 0.0f, 0.0f, 10.0f, 66.0f, 90.0f}, @@ -1510,7 +1506,7 @@ {1.0f, 0.0f, 0.0f, 0.833333, 60.0f, 130.0f}, {1.0f, 0.0f, 0.0f, 0.833333, 60.0f, 130.0f}, }; - constexpr size_t kExpectedCount = pdfium::size(kExpectedMatrices); + constexpr size_t kExpectedCount = std::size(kExpectedMatrices); static_assert(kExpectedCount + 1 == kExpectedTextSize, "Bad expected matrix size"); @@ -1663,7 +1659,7 @@ TEST_F(FPDFTextEmbedderTest, BigtableTextExtraction) { constexpr char kExpectedText[] = "{fay,jeff,sanjay,wilsonh,kerr,m3b,tushar,\x02k es,gruber}@google.com"; - constexpr int kExpectedTextCount = pdfium::size(kExpectedText) - 1; + constexpr int kExpectedTextCount = std::size(kExpectedText) - 1; ASSERT_TRUE(OpenDocument("bigtable_mini.pdf")); FPDF_PAGE page = LoadPage(0);
diff --git a/fpdfsdk/fpdf_view_embeddertest.cpp b/fpdfsdk/fpdf_view_embeddertest.cpp index 2c1706d..e015466 100644 --- a/fpdfsdk/fpdf_view_embeddertest.cpp +++ b/fpdfsdk/fpdf_view_embeddertest.cpp
@@ -24,7 +24,6 @@ #include "testing/utils/hash.h" #include "testing/utils/path_service.h" #include "third_party/base/check.h" -#include "third_party/base/cxx17_backports.h" using pdfium::kManyRectanglesChecksum; @@ -1106,9 +1105,9 @@ {"postamble", 11u, "6b79e25da35d86634ea27c38f64cf243"}, }; - ASSERT_EQ(static_cast<int>(pdfium::size(kExpectedResults)), + ASSERT_EQ(static_cast<int>(std::size(kExpectedResults)), FPDF_GetXFAPacketCount(document())); - for (size_t i = 0; i < pdfium::size(kExpectedResults); ++i) { + for (size_t i = 0; i < std::size(kExpectedResults); ++i) { char name_buffer[20] = {}; ASSERT_EQ(strlen(kExpectedResults[i].name) + 1, FPDF_GetXFAPacketName(document(), i, nullptr, 0)); @@ -1134,16 +1133,16 @@ EXPECT_EQ(0u, FPDF_GetXFAPacketName(nullptr, 0, nullptr, 0)); EXPECT_EQ(0u, FPDF_GetXFAPacketName(document(), -1, nullptr, 0)); - EXPECT_EQ(0u, FPDF_GetXFAPacketName( - document(), pdfium::size(kExpectedResults), nullptr, 0)); + EXPECT_EQ(0u, FPDF_GetXFAPacketName(document(), std::size(kExpectedResults), + nullptr, 0)); unsigned long buflen = 123; EXPECT_FALSE(FPDF_GetXFAPacketContent(nullptr, 0, nullptr, 0, &buflen)); EXPECT_EQ(123u, buflen); EXPECT_FALSE(FPDF_GetXFAPacketContent(document(), -1, nullptr, 0, &buflen)); EXPECT_EQ(123u, buflen); - EXPECT_FALSE(FPDF_GetXFAPacketContent( - document(), pdfium::size(kExpectedResults), nullptr, 0, &buflen)); + EXPECT_FALSE(FPDF_GetXFAPacketContent(document(), std::size(kExpectedResults), + nullptr, 0, &buflen)); EXPECT_EQ(123u, buflen); EXPECT_FALSE(FPDF_GetXFAPacketContent(document(), 0, nullptr, 0, nullptr)); }
diff --git a/fpdfsdk/pwl/cpwl_sbbutton.cpp b/fpdfsdk/pwl/cpwl_sbbutton.cpp index 68e52c6..bd55556 100644 --- a/fpdfsdk/pwl/cpwl_sbbutton.cpp +++ b/fpdfsdk/pwl/cpwl_sbbutton.cpp
@@ -10,7 +10,6 @@ #include <vector> #include "core/fxge/cfx_renderdevice.h" -#include "third_party/base/cxx17_backports.h" CPWL_SBButton::CPWL_SBButton( const CreateParams& cp, @@ -55,13 +54,13 @@ 5.0f, 3.0f, 5.0f}; static constexpr float kOffsetsMinY[] = {4.0f, 3.0f, 5.0f, 3.0f, 4.0f, 6.0f, 4.0f}; - static_assert(pdfium::size(kOffsetsX) == pdfium::size(kOffsetsY), + static_assert(std::size(kOffsetsX) == std::size(kOffsetsY), "Wrong offset count"); - static_assert(pdfium::size(kOffsetsX) == pdfium::size(kOffsetsMinY), + static_assert(std::size(kOffsetsX) == std::size(kOffsetsMinY), "Wrong offset count"); const float* pOffsetsY = m_eSBButtonType == Type::kMinButton ? kOffsetsMinY : kOffsetsY; - for (size_t i = 0; i < pdfium::size(kOffsetsX); ++i) + for (size_t i = 0; i < std::size(kOffsetsX); ++i) pts.push_back(CFX_PointF(fX + kOffsetsX[i], fY + pOffsetsY[i])); pDevice->DrawFillArea(mtUser2Device, pts, ArgbEncode(nTransparency, 255, 255, 255));
diff --git a/fxbarcode/datamatrix/BC_C40Encoder.cpp b/fxbarcode/datamatrix/BC_C40Encoder.cpp index 1f783c7..063eb98 100644 --- a/fxbarcode/datamatrix/BC_C40Encoder.cpp +++ b/fxbarcode/datamatrix/BC_C40Encoder.cpp
@@ -22,6 +22,8 @@ #include "fxbarcode/datamatrix/BC_C40Encoder.h" +#include <iterator> + #include "core/fxcrt/fx_extension.h" #include "fxbarcode/common/BC_CommonBitMatrix.h" #include "fxbarcode/datamatrix/BC_Encoder.h" @@ -29,7 +31,6 @@ #include "fxbarcode/datamatrix/BC_HighLevelEncoder.h" #include "fxbarcode/datamatrix/BC_SymbolInfo.h" #include "third_party/base/check.h" -#include "third_party/base/cxx17_backports.h" namespace { @@ -41,7 +42,7 @@ wchar_t cw[2]; cw[0] = static_cast<wchar_t>(v / 256); cw[1] = static_cast<wchar_t>(v % 256); - return WideString(cw, pdfium::size(cw)); + return WideString(cw, std::size(cw)); } } // namespace
diff --git a/fxbarcode/datamatrix/BC_DataMatrixWriter_unittest.cpp b/fxbarcode/datamatrix/BC_DataMatrixWriter_unittest.cpp index b6009fc..aaf4e9c 100644 --- a/fxbarcode/datamatrix/BC_DataMatrixWriter_unittest.cpp +++ b/fxbarcode/datamatrix/BC_DataMatrixWriter_unittest.cpp
@@ -7,7 +7,6 @@ #include <vector> #include "testing/gtest/include/gtest/gtest.h" -#include "third_party/base/cxx17_backports.h" class CBC_DataMatrixWriterTest : public testing::Test { public: @@ -42,10 +41,10 @@ // clang-format on std::vector<uint8_t, FxAllocAllocator<uint8_t>> data = writer.Encode(L"", &width, &height); - ASSERT_EQ(pdfium::size(kExpectedData), data.size()); + ASSERT_EQ(std::size(kExpectedData), data.size()); ASSERT_EQ(kExpectedDimension, width); ASSERT_EQ(kExpectedDimension, height); - for (size_t i = 0; i < pdfium::size(kExpectedData); ++i) + for (size_t i = 0; i < std::size(kExpectedData); ++i) EXPECT_EQ(kExpectedData[i], data[i]) << i; } { @@ -70,10 +69,10 @@ // clang-format on std::vector<uint8_t, FxAllocAllocator<uint8_t>> data = writer.Encode(L"helloworld", &width, &height); - ASSERT_EQ(pdfium::size(kExpectedData), data.size()); + ASSERT_EQ(std::size(kExpectedData), data.size()); ASSERT_EQ(kExpectedDimension, width); ASSERT_EQ(kExpectedDimension, height); - for (size_t i = 0; i < pdfium::size(kExpectedData); ++i) + for (size_t i = 0; i < std::size(kExpectedData); ++i) EXPECT_EQ(kExpectedData[i], data[i]) << i; } { @@ -94,10 +93,10 @@ // clang-format on std::vector<uint8_t, FxAllocAllocator<uint8_t>> data = writer.Encode(L"12345", &width, &height); - ASSERT_EQ(pdfium::size(kExpectedData), data.size()); + ASSERT_EQ(std::size(kExpectedData), data.size()); ASSERT_EQ(kExpectedDimension, width); ASSERT_EQ(kExpectedDimension, height); - for (size_t i = 0; i < pdfium::size(kExpectedData); ++i) + for (size_t i = 0; i < std::size(kExpectedData); ++i) EXPECT_EQ(kExpectedData[i], data[i]) << i; } { @@ -126,10 +125,10 @@ // clang-format on std::vector<uint8_t, FxAllocAllocator<uint8_t>> data = writer.Encode(L"abcdefghijklmnopqrst", &width, &height); - ASSERT_EQ(pdfium::size(kExpectedData), data.size()); + ASSERT_EQ(std::size(kExpectedData), data.size()); ASSERT_EQ(kExpectedDimension, width); ASSERT_EQ(kExpectedDimension, height); - for (size_t i = 0; i < pdfium::size(kExpectedData); ++i) + for (size_t i = 0; i < std::size(kExpectedData); ++i) EXPECT_EQ(kExpectedData[i], data[i]) << i; } {
diff --git a/fxbarcode/datamatrix/BC_ErrorCorrection.cpp b/fxbarcode/datamatrix/BC_ErrorCorrection.cpp index c3a87d1..cee4027 100644 --- a/fxbarcode/datamatrix/BC_ErrorCorrection.cpp +++ b/fxbarcode/datamatrix/BC_ErrorCorrection.cpp
@@ -29,7 +29,6 @@ #include "fxbarcode/datamatrix/BC_Encoder.h" #include "fxbarcode/datamatrix/BC_SymbolInfo.h" #include "third_party/base/check.h" -#include "third_party/base/cxx17_backports.h" namespace { @@ -147,7 +146,7 @@ DCHECK(numECWords > 0); const size_t len = codewords.GetLength(); - static constexpr size_t kFactorTableNum = pdfium::size(FACTOR_SETS); + static constexpr size_t kFactorTableNum = std::size(FACTOR_SETS); size_t table = 0; while (table < kFactorTableNum && FACTOR_SETS[table] != numECWords) ++table;
diff --git a/fxbarcode/datamatrix/BC_SymbolInfo.cpp b/fxbarcode/datamatrix/BC_SymbolInfo.cpp index 7bec809..5858be4 100644 --- a/fxbarcode/datamatrix/BC_SymbolInfo.cpp +++ b/fxbarcode/datamatrix/BC_SymbolInfo.cpp
@@ -22,10 +22,11 @@ #include "fxbarcode/datamatrix/BC_SymbolInfo.h" +#include <iterator> + #include "fxbarcode/common/BC_CommonBitMatrix.h" #include "fxbarcode/datamatrix/BC_DataMatrixSymbolInfo144.h" #include "fxbarcode/datamatrix/BC_Encoder.h" -#include "third_party/base/cxx17_backports.h" #include "third_party/base/notreached.h" namespace { @@ -55,7 +56,7 @@ {816, 336, 136, 56, 24, 24, 16}, {1050, 408, 175, 68, 18, 18, 36}, {1304, 496, 163, 62, 20, 20, 36}}; -constexpr size_t kSymbolDataSize = pdfium::size(kSymbolData); +constexpr size_t kSymbolDataSize = std::size(kSymbolData); static_assert(kSymbolDataSize + 1 == kSymbolsCount, "Wrong kSymbolDataSize"); } // namespace
diff --git a/fxbarcode/oned/BC_OnedCodaBarWriter.cpp b/fxbarcode/oned/BC_OnedCodaBarWriter.cpp index 6c4da2d..b432a5f 100644 --- a/fxbarcode/oned/BC_OnedCodaBarWriter.cpp +++ b/fxbarcode/oned/BC_OnedCodaBarWriter.cpp
@@ -22,13 +22,14 @@ #include "fxbarcode/oned/BC_OnedCodaBarWriter.h" +#include <iterator> + #include "core/fxcrt/fx_extension.h" #include "core/fxcrt/fx_memory.h" #include "fxbarcode/BC_Writer.h" #include "fxbarcode/common/BC_CommonBitMatrix.h" #include "fxbarcode/oned/BC_OneDimWriter.h" #include "third_party/base/containers/contains.h" -#include "third_party/base/cxx17_backports.h" namespace { @@ -39,9 +40,9 @@ const int8_t kOnedCodaCharacterEncoding[] = { 0x03, 0x06, 0x09, 0x60, 0x12, 0x42, 0x21, 0x24, 0x30, 0x48, 0x0c, 0x18, 0x45, 0x51, 0x54, 0x15, 0x1A, 0x29, 0x0B, 0x0E, 0x1A, 0x29}; -static_assert(pdfium::size(kOnedCodaCharacterEncoding) == 22, "Wrong size"); -static_assert(pdfium::size(kOnedCodaCharacterEncoding) == - pdfium::size(kOnedCodaAlphabet), +static_assert(std::size(kOnedCodaCharacterEncoding) == 22, "Wrong size"); +static_assert(std::size(kOnedCodaCharacterEncoding) == + std::size(kOnedCodaAlphabet), "Wrong size"); const char kStartEndChars[] = {'A', 'B', 'C', 'D', 'T', 'N', '*', 'E', @@ -157,7 +158,7 @@ break; } int8_t code = 0; - for (size_t i = 0; i < pdfium::size(kOnedCodaAlphabet); i++) { + for (size_t i = 0; i < std::size(kOnedCodaAlphabet); i++) { if (ch == kOnedCodaAlphabet[i]) { code = kOnedCodaCharacterEncoding[i]; break;
diff --git a/fxbarcode/oned/BC_OnedCode128Writer_unittest.cpp b/fxbarcode/oned/BC_OnedCode128Writer_unittest.cpp index 380c73b..56cbe73 100644 --- a/fxbarcode/oned/BC_OnedCode128Writer_unittest.cpp +++ b/fxbarcode/oned/BC_OnedCode128Writer_unittest.cpp
@@ -4,8 +4,9 @@ #include "fxbarcode/oned/BC_OnedCode128Writer.h" +#include <iterator> + #include "testing/gtest/include/gtest/gtest.h" -#include "third_party/base/cxx17_backports.h" namespace { @@ -32,7 +33,7 @@ {"321ABC", 722, {104, 19, 18, 17, 33, 34, 35}, 7}, {"XYZ", 448, {104, 56, 57, 58}, 4}, }; - for (size_t i = 0; i < pdfium::size(kTestCases); ++i) { + for (size_t i = 0; i < std::size(kTestCases); ++i) { FXSYS_snprintf(buf, sizeof(buf) - 1, "Test case %zu", i); SCOPED_TRACE(buf); const TestCase& test_case = kTestCases[i]; @@ -65,7 +66,7 @@ {"321ABC", 933, {105, 32, 1, 65, 66, 67}, 6}, {"XYZ", 641, {105, 88, 89, 90}, 4}, }; - for (size_t i = 0; i < pdfium::size(kTestCases); ++i) { + for (size_t i = 0; i < std::size(kTestCases); ++i) { FXSYS_snprintf(buf, sizeof(buf) - 1, "Test case %zu", i); SCOPED_TRACE(buf); const TestCase& test_case = kTestCases[i];
diff --git a/fxbarcode/oned/BC_OnedCode39Writer.cpp b/fxbarcode/oned/BC_OnedCode39Writer.cpp index 4ca2054..3935e07 100644 --- a/fxbarcode/oned/BC_OnedCode39Writer.cpp +++ b/fxbarcode/oned/BC_OnedCode39Writer.cpp
@@ -23,6 +23,7 @@ #include "fxbarcode/oned/BC_OnedCode39Writer.h" #include <algorithm> +#include <iterator> #include <memory> #include "core/fxcrt/fx_extension.h" @@ -30,7 +31,6 @@ #include "fxbarcode/BC_Writer.h" #include "fxbarcode/common/BC_CommonBitMatrix.h" #include "fxbarcode/oned/BC_OneDimWriter.h" -#include "third_party/base/cxx17_backports.h" namespace { @@ -38,13 +38,13 @@ '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', '-', '.', ' ', '*', '$', '/', '+', '%'}; -constexpr size_t kOnedCode39AlphabetLen = pdfium::size(kOnedCode39Alphabet); +constexpr size_t kOnedCode39AlphabetLen = std::size(kOnedCode39Alphabet); const char kOnedCode39Checksum[] = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', '-', '.', ' ', '$', '/', '+', '%'}; -static_assert(pdfium::size(kOnedCode39Checksum) == 43, "Wrong size"); +static_assert(std::size(kOnedCode39Checksum) == 43, "Wrong size"); const int16_t kOnedCode39CharacterEncoding[] = { 0x0034, 0x0121, 0x0061, 0x0160, 0x0031, 0x0130, 0x0070, 0x0025, 0x0124, @@ -52,7 +52,7 @@ 0x004C, 0x001C, 0x0103, 0x0043, 0x0142, 0x0013, 0x0112, 0x0052, 0x0007, 0x0106, 0x0046, 0x0016, 0x0181, 0x00C1, 0x01C0, 0x0091, 0x0190, 0x00D0, 0x0085, 0x0184, 0x00C4, 0x0094, 0x00A8, 0x00A2, 0x008A, 0x002A}; -static_assert(pdfium::size(kOnedCode39CharacterEncoding) == 44, "Wrong size"); +static_assert(std::size(kOnedCode39CharacterEncoding) == 44, "Wrong size"); bool IsInOnedCode39Alphabet(wchar_t ch) { return FXSYS_IsDecimalDigit(ch) || (ch >= L'A' && ch <= L'Z') || ch == L'-' || @@ -154,7 +154,7 @@ if (j >= kOnedCode39AlphabetLen) return '*'; } - return kOnedCode39Checksum[checksum % pdfium::size(kOnedCode39Checksum)]; + return kOnedCode39Checksum[checksum % std::size(kOnedCode39Checksum)]; } uint8_t* CBC_OnedCode39Writer::EncodeImpl(const ByteString& contents,
diff --git a/fxbarcode/pdf417/BC_PDF417HighLevelEncoder_unittest.cpp b/fxbarcode/pdf417/BC_PDF417HighLevelEncoder_unittest.cpp index 03380a2d..0227289 100644 --- a/fxbarcode/pdf417/BC_PDF417HighLevelEncoder_unittest.cpp +++ b/fxbarcode/pdf417/BC_PDF417HighLevelEncoder_unittest.cpp
@@ -7,7 +7,6 @@ #include <vector> #include "testing/gtest/include/gtest/gtest.h" -#include "third_party/base/cxx17_backports.h" TEST(PDF417HighLevelEncoderTest, EncodeHighLevel) { static constexpr struct EncodeHighLevelCase { @@ -40,7 +39,7 @@ {L"0000000000000", L"\x0386\x000f\x00d9\x017b\x000b\x0064", 6}, }; - for (size_t i = 0; i < pdfium::size(kEncodeHighLevelCases); ++i) { + for (size_t i = 0; i < std::size(kEncodeHighLevelCases); ++i) { const EncodeHighLevelCase& testcase = kEncodeHighLevelCases[i]; WideStringView input(testcase.input); WideString expected(testcase.expected, testcase.expected_length); @@ -84,7 +83,7 @@ L"\u039c\u00c9\u031f\u012a\u00d2\u02d0", 6}, }; - for (size_t i = 0; i < pdfium::size(kEncodeBinaryCases); ++i) { + for (size_t i = 0; i < std::size(kEncodeBinaryCases); ++i) { const EncodeBinaryCase& testcase = kEncodeBinaryCases[i]; std::vector<uint8_t> input_array; size_t input_length = strlen(testcase.input); @@ -151,7 +150,7 @@ 18}, }; - for (size_t i = 0; i < pdfium::size(kEncodeNumericCases); ++i) { + for (size_t i = 0; i < std::size(kEncodeNumericCases); ++i) { const EncodeNumericCase& testcase = kEncodeNumericCases[i]; WideString input(testcase.input); WideString expected(testcase.expected, testcase.expected_length); @@ -196,7 +195,7 @@ {L"123FOO45678", 6, 5}, }; - for (size_t i = 0; i < pdfium::size(kConsecutiveDigitCases); ++i) { + for (size_t i = 0; i < std::size(kConsecutiveDigitCases); ++i) { const ConsecutiveDigitCase& testcase = kConsecutiveDigitCases[i]; WideString input(testcase.input); int actual_count = @@ -256,7 +255,7 @@ {L"XXX121XXX12345678901234", 0, 9}, }; - for (size_t i = 0; i < pdfium::size(kConsecutiveTextCases); ++i) { + for (size_t i = 0; i < std::size(kConsecutiveTextCases); ++i) { const ConsecutiveTextCase& testcase = kConsecutiveTextCases[i]; WideString input(testcase.input); int actual_count =
diff --git a/fxbarcode/pdf417/BC_PDF417Writer_unittest.cpp b/fxbarcode/pdf417/BC_PDF417Writer_unittest.cpp index ac06eec..9ecb0de 100644 --- a/fxbarcode/pdf417/BC_PDF417Writer_unittest.cpp +++ b/fxbarcode/pdf417/BC_PDF417Writer_unittest.cpp
@@ -7,7 +7,6 @@ #include <vector> #include "testing/gtest/include/gtest/gtest.h" -#include "third_party/base/cxx17_backports.h" class CBC_PDF417WriterTest : public testing::Test { public: @@ -416,10 +415,10 @@ 1, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 0, 1, 0, 0, 0, 1, 0, 1, 0, 0, 1}; std::vector<uint8_t, FxAllocAllocator<uint8_t>> data = writer.Encode(L"", &width, &height); - ASSERT_EQ(pdfium::size(kExpectedData), data.size()); + ASSERT_EQ(std::size(kExpectedData), data.size()); ASSERT_EQ(kExpectedWidth, width); ASSERT_EQ(kExpectedHeight, height); - for (size_t i = 0; i < pdfium::size(kExpectedData); ++i) + for (size_t i = 0; i < std::size(kExpectedData); ++i) EXPECT_EQ(kExpectedData[i], data[i]) << i; } { @@ -814,10 +813,10 @@ 1, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 0, 1, 0, 0, 0, 1, 0, 1, 0, 0, 1}; std::vector<uint8_t, FxAllocAllocator<uint8_t>> data = writer.Encode(L"hello world", &width, &height); - ASSERT_EQ(pdfium::size(kExpectedData), data.size()); + ASSERT_EQ(std::size(kExpectedData), data.size()); ASSERT_EQ(kExpectedWidth, width); ASSERT_EQ(kExpectedHeight, height); - for (size_t i = 0; i < pdfium::size(kExpectedData); ++i) + for (size_t i = 0; i < std::size(kExpectedData); ++i) EXPECT_EQ(kExpectedData[i], data[i]) << i; } }
diff --git a/fxbarcode/qrcode/BC_QRCodeWriter_unittest.cpp b/fxbarcode/qrcode/BC_QRCodeWriter_unittest.cpp index 43855a7..d703caf 100644 --- a/fxbarcode/qrcode/BC_QRCodeWriter_unittest.cpp +++ b/fxbarcode/qrcode/BC_QRCodeWriter_unittest.cpp
@@ -7,7 +7,6 @@ #include <vector> #include "testing/gtest/include/gtest/gtest.h" -#include "third_party/base/cxx17_backports.h" class CBC_QRCodeWriterTest : public testing::Test { public: @@ -53,10 +52,10 @@ // clang-format on std::vector<uint8_t, FxAllocAllocator<uint8_t>> data = writer.Encode(L"", 0, &width, &height); - ASSERT_EQ(pdfium::size(kExpectedData), data.size()); + ASSERT_EQ(std::size(kExpectedData), data.size()); ASSERT_EQ(kExpectedDimension, width); ASSERT_EQ(kExpectedDimension, height); - for (size_t i = 0; i < pdfium::size(kExpectedData); ++i) + for (size_t i = 0; i < std::size(kExpectedData); ++i) EXPECT_EQ(kExpectedData[i], data[i]) << i; } { @@ -88,10 +87,10 @@ // clang-format on std::vector<uint8_t, FxAllocAllocator<uint8_t>> data = writer.Encode(L"", 1, &width, &height); - ASSERT_EQ(pdfium::size(kExpectedData), data.size()); + ASSERT_EQ(std::size(kExpectedData), data.size()); ASSERT_EQ(kExpectedDimension, width); ASSERT_EQ(kExpectedDimension, height); - for (size_t i = 0; i < pdfium::size(kExpectedData); ++i) + for (size_t i = 0; i < std::size(kExpectedData); ++i) EXPECT_EQ(kExpectedData[i], data[i]) << i; } { @@ -123,10 +122,10 @@ // clang-format on std::vector<uint8_t, FxAllocAllocator<uint8_t>> data = writer.Encode(L"", 2, &width, &height); - ASSERT_EQ(pdfium::size(kExpectedData), data.size()); + ASSERT_EQ(std::size(kExpectedData), data.size()); ASSERT_EQ(kExpectedDimension, width); ASSERT_EQ(kExpectedDimension, height); - for (size_t i = 0; i < pdfium::size(kExpectedData); ++i) + for (size_t i = 0; i < std::size(kExpectedData); ++i) EXPECT_EQ(kExpectedData[i], data[i]) << i; } { @@ -158,10 +157,10 @@ // clang-format on std::vector<uint8_t, FxAllocAllocator<uint8_t>> data = writer.Encode(L"", 3, &width, &height); - ASSERT_EQ(pdfium::size(kExpectedData), data.size()); + ASSERT_EQ(std::size(kExpectedData), data.size()); ASSERT_EQ(kExpectedDimension, width); ASSERT_EQ(kExpectedDimension, height); - for (size_t i = 0; i < pdfium::size(kExpectedData); ++i) + for (size_t i = 0; i < std::size(kExpectedData); ++i) EXPECT_EQ(kExpectedData[i], data[i]) << i; } { @@ -193,10 +192,10 @@ // clang-format on std::vector<uint8_t, FxAllocAllocator<uint8_t>> data = writer.Encode(L"hello world", 0, &width, &height); - ASSERT_EQ(pdfium::size(kExpectedData), data.size()); + ASSERT_EQ(std::size(kExpectedData), data.size()); ASSERT_EQ(kExpectedDimension, width); ASSERT_EQ(kExpectedDimension, height); - for (size_t i = 0; i < pdfium::size(kExpectedData); ++i) + for (size_t i = 0; i < std::size(kExpectedData); ++i) EXPECT_EQ(kExpectedData[i], data[i]) << i; } { @@ -228,10 +227,10 @@ // clang-format on std::vector<uint8_t, FxAllocAllocator<uint8_t>> data = writer.Encode(L"hello world", 1, &width, &height); - ASSERT_EQ(pdfium::size(kExpectedData), data.size()); + ASSERT_EQ(std::size(kExpectedData), data.size()); ASSERT_EQ(kExpectedDimension, width); ASSERT_EQ(kExpectedDimension, height); - for (size_t i = 0; i < pdfium::size(kExpectedData); ++i) + for (size_t i = 0; i < std::size(kExpectedData); ++i) EXPECT_EQ(kExpectedData[i], data[i]) << i; } { @@ -266,10 +265,10 @@ 1}; std::vector<uint8_t, FxAllocAllocator<uint8_t>> data = writer.Encode(L"hello world", 2, &width, &height); - ASSERT_EQ(pdfium::size(kExpectedData), data.size()); + ASSERT_EQ(std::size(kExpectedData), data.size()); ASSERT_EQ(kExpectedDimension, width); ASSERT_EQ(kExpectedDimension, height); - for (size_t i = 0; i < pdfium::size(kExpectedData); ++i) + for (size_t i = 0; i < std::size(kExpectedData); ++i) EXPECT_EQ(kExpectedData[i], data[i]) << i; } { @@ -304,10 +303,10 @@ 1}; std::vector<uint8_t, FxAllocAllocator<uint8_t>> data = writer.Encode(L"hello world", 3, &width, &height); - ASSERT_EQ(pdfium::size(kExpectedData), data.size()); + ASSERT_EQ(std::size(kExpectedData), data.size()); ASSERT_EQ(kExpectedDimension, width); ASSERT_EQ(kExpectedDimension, height); - for (size_t i = 0; i < pdfium::size(kExpectedData); ++i) + for (size_t i = 0; i < std::size(kExpectedData); ++i) EXPECT_EQ(kExpectedData[i], data[i]) << i; } }
diff --git a/fxbarcode/qrcode/BC_QRCoderEncoder.cpp b/fxbarcode/qrcode/BC_QRCoderEncoder.cpp index 03d4ff1..b4bc114 100644 --- a/fxbarcode/qrcode/BC_QRCoderEncoder.cpp +++ b/fxbarcode/qrcode/BC_QRCoderEncoder.cpp
@@ -42,7 +42,6 @@ #include "third_party/abseil-cpp/absl/types/optional.h" #include "third_party/base/check.h" #include "third_party/base/check_op.h" -#include "third_party/base/cxx17_backports.h" using ModeStringPair = std::pair<CBC_QRCoderMode*, ByteString>; @@ -66,7 +65,7 @@ if (code < 32) return -1; size_t code_index = static_cast<size_t>(code - 32); - if (code_index >= pdfium::size(kAlphaNumericTable)) + if (code_index >= std::size(kAlphaNumericTable)) return -1; return kAlphaNumericTable[code_index]; }
diff --git a/fxbarcode/qrcode/BC_QRCoderMatrixUtil.cpp b/fxbarcode/qrcode/BC_QRCoderMatrixUtil.cpp index 23d76f9..afb7a7e 100644 --- a/fxbarcode/qrcode/BC_QRCoderMatrixUtil.cpp +++ b/fxbarcode/qrcode/BC_QRCoderMatrixUtil.cpp
@@ -22,6 +22,8 @@ #include "fxbarcode/qrcode/BC_QRCoderMatrixUtil.h" +#include <iterator> + #include "fxbarcode/common/BC_CommonByteMatrix.h" #include "fxbarcode/qrcode/BC_QRCoder.h" #include "fxbarcode/qrcode/BC_QRCoderBitVector.h" @@ -29,7 +31,6 @@ #include "fxbarcode/qrcode/BC_QRCoderMaskUtil.h" #include "third_party/base/check.h" #include "third_party/base/check_op.h" -#include "third_party/base/cxx17_backports.h" namespace { @@ -333,7 +334,7 @@ return true; const size_t index = version - 2; - if (index >= pdfium::size(kPositionAdjustmentPatternCoordinates)) + if (index >= std::size(kPositionAdjustmentPatternCoordinates)) return false; const auto* coordinates = &kPositionAdjustmentPatternCoordinates[index][0];
diff --git a/fxjs/cjs_globalarrays.cpp b/fxjs/cjs_globalarrays.cpp index e7fef52..dbfda2c 100644 --- a/fxjs/cjs_globalarrays.cpp +++ b/fxjs/cjs_globalarrays.cpp
@@ -6,7 +6,8 @@ #include "fxjs/cjs_globalarrays.h" -#include "third_party/base/cxx17_backports.h" +#include <iterator> + #include "third_party/base/numerics/safe_conversions.h" #include "v8/include/v8-container.h" #include "v8/include/v8-isolate.h" @@ -16,7 +17,7 @@ static const wchar_t* const values[] = {__VA_ARGS__}; \ v8::Local<v8::Array> array = (rt)->NewArray(); \ v8::Local<v8::Context> ctx = (rt)->GetIsolate()->GetCurrentContext(); \ - for (size_t i = 0; i < pdfium::size(values); ++i) { \ + for (size_t i = 0; i < std::size(values); ++i) { \ array \ ->Set(ctx, pdfium::base::checked_cast<uint32_t>(i), \ (rt)->NewString(values[i])) \
diff --git a/fxjs/cjs_publicmethods.cpp b/fxjs/cjs_publicmethods.cpp index 503d868..89c6cfe 100644 --- a/fxjs/cjs_publicmethods.cpp +++ b/fxjs/cjs_publicmethods.cpp
@@ -36,7 +36,6 @@ #include "fxjs/js_resources.h" #include "third_party/abseil-cpp/absl/types/optional.h" #include "third_party/base/check.h" -#include "third_party/base/cxx17_backports.h" #include "third_party/base/numerics/safe_conversions.h" #include "v8/include/v8-container.h" @@ -933,7 +932,7 @@ int nMonth = 1; sTemp = wsArray[1]; - for (size_t i = 0; i < pdfium::size(fxjs::kMonths); ++i) { + for (size_t i = 0; i < std::size(fxjs::kMonths); ++i) { if (sTemp == fxjs::kMonths[i]) { nMonth = static_cast<int>(i) + 1; break; @@ -992,8 +991,8 @@ if (params.size() != 1) return CJS_Result::Failure(JSMessage::kParamError); - int iIndex = WithinBoundsOrZero(pRuntime->ToInt32(params[0]), - pdfium::size(kDateFormats)); + int iIndex = + WithinBoundsOrZero(pRuntime->ToInt32(params[0]), std::size(kDateFormats)); std::vector<v8::Local<v8::Value>> newParams; newParams.push_back(pRuntime->NewString(kDateFormats[iIndex])); return AFDate_FormatEx(pRuntime, newParams); @@ -1006,8 +1005,8 @@ if (params.size() != 1) return CJS_Result::Failure(JSMessage::kParamError); - int iIndex = WithinBoundsOrZero(pRuntime->ToInt32(params[0]), - pdfium::size(kDateFormats)); + int iIndex = + WithinBoundsOrZero(pRuntime->ToInt32(params[0]), std::size(kDateFormats)); std::vector<v8::Local<v8::Value>> newParams; newParams.push_back(pRuntime->NewString(kDateFormats[iIndex])); return AFDate_KeystrokeEx(pRuntime, newParams); @@ -1020,8 +1019,8 @@ if (params.size() != 1) return CJS_Result::Failure(JSMessage::kParamError); - int iIndex = WithinBoundsOrZero(pRuntime->ToInt32(params[0]), - pdfium::size(kTimeFormats)); + int iIndex = + WithinBoundsOrZero(pRuntime->ToInt32(params[0]), std::size(kTimeFormats)); std::vector<v8::Local<v8::Value>> newParams; newParams.push_back(pRuntime->NewString(kTimeFormats[iIndex])); return AFDate_FormatEx(pRuntime, newParams); @@ -1033,8 +1032,8 @@ if (params.size() != 1) return CJS_Result::Failure(JSMessage::kParamError); - int iIndex = WithinBoundsOrZero(pRuntime->ToInt32(params[0]), - pdfium::size(kTimeFormats)); + int iIndex = + WithinBoundsOrZero(pRuntime->ToInt32(params[0]), std::size(kTimeFormats)); std::vector<v8::Local<v8::Value>> newParams; newParams.push_back(pRuntime->NewString(kTimeFormats[iIndex])); return AFDate_KeystrokeEx(pRuntime, newParams);
diff --git a/fxjs/cjs_publicmethods_unittest.cpp b/fxjs/cjs_publicmethods_unittest.cpp index 95fdbd8..d6f0e08 100644 --- a/fxjs/cjs_publicmethods_unittest.cpp +++ b/fxjs/cjs_publicmethods_unittest.cpp
@@ -4,8 +4,9 @@ #include "fxjs/cjs_publicmethods.h" +#include <iterator> + #include "testing/gtest/include/gtest/gtest.h" -#include "third_party/base/cxx17_backports.h" TEST(CJS_PublicMethods, IsNumber) { // TODO(weili): Check whether results from case 0, 1, 10, 15 are intended. @@ -43,7 +44,7 @@ {L"0123", true}, {L"9876123", true}, }; - for (size_t i = 0; i < pdfium::size(test_data); ++i) { + for (size_t i = 0; i < std::size(test_data); ++i) { EXPECT_EQ(test_data[i].expected, CJS_PublicMethods::IsNumber(test_data[i].input)) << "for case " << i;
diff --git a/fxjs/cjs_util.cpp b/fxjs/cjs_util.cpp index 756ffb3..fb9fe7d 100644 --- a/fxjs/cjs_util.cpp +++ b/fxjs/cjs_util.cpp
@@ -24,7 +24,6 @@ #include "fxjs/js_define.h" #include "fxjs/js_resources.h" #include "third_party/base/check_op.h" -#include "third_party/base/cxx17_backports.h" #include "v8/include/v8-date.h" #if BUILDFLAG(IS_ANDROID) @@ -217,7 +216,7 @@ cFormat.erase(std::remove(cFormat.begin(), cFormat.end(), '%'), cFormat.end()); - for (size_t i = 0; i < pdfium::size(TbConvertTable); ++i) { + for (size_t i = 0; i < std::size(TbConvertTable); ++i) { size_t nFound = 0; while (true) { nFound = cFormat.find(TbConvertTable[i].lpszJSMark, nFound); @@ -238,7 +237,7 @@ {L'M', min}, {L's', sec}, }; - for (size_t i = 0; i < pdfium::size(cTableAd); ++i) { + for (size_t i = 0; i < std::size(cTableAd); ++i) { size_t nFound = 0; while (true) { nFound = cFormat.find(cTableAd[i].js_mark, nFound);
diff --git a/fxjs/cjs_util_unittest.cpp b/fxjs/cjs_util_unittest.cpp index 39b7318..832e0a5 100644 --- a/fxjs/cjs_util_unittest.cpp +++ b/fxjs/cjs_util_unittest.cpp
@@ -4,8 +4,9 @@ #include "fxjs/cjs_util.h" +#include <iterator> + #include "testing/gtest/include/gtest/gtest.h" -#include "third_party/base/cxx17_backports.h" TEST(CJS_Util, ParseDataType) { struct ParseDataTypeCase { @@ -105,7 +106,7 @@ {L"%10s", CJS_Util::DataType::kString}, }; - for (size_t i = 0; i < pdfium::size(cases); i++) { + for (size_t i = 0; i < std::size(cases); i++) { WideString input(cases[i].input_string); EXPECT_EQ(cases[i].expected, CJS_Util::ParseDataType(&input)) << cases[i].input_string;
diff --git a/fxjs/fx_date_helpers.cpp b/fxjs/fx_date_helpers.cpp index 77e9772..194797f 100644 --- a/fxjs/fx_date_helpers.cpp +++ b/fxjs/fx_date_helpers.cpp
@@ -10,11 +10,12 @@ #include <time.h> #include <wctype.h> +#include <iterator> + #include "build/build_config.h" #include "core/fxcrt/fx_extension.h" #include "core/fxcrt/fx_system.h" #include "fpdfsdk/cpdfsdk_helpers.h" -#include "third_party/base/cxx17_backports.h" namespace fxjs { namespace { @@ -114,7 +115,7 @@ // Check for February onwards. static constexpr int kCumulativeDaysInMonths[] = { 59, 90, 120, 151, 181, 212, 243, 273, 304, 334, 365}; - for (size_t i = 0; i < pdfium::size(kCumulativeDaysInMonths); ++i) { + for (size_t i = 0; i < std::size(kCumulativeDaysInMonths); ++i) { if (day < kCumulativeDaysInMonths[i]) return static_cast<int>(i) + 1; } @@ -434,7 +435,7 @@ nSkip = FindSubWordLength(value, j); if (nSkip == KMonthAbbreviationLength) { WideString sMonth = value.Substr(j, KMonthAbbreviationLength); - for (size_t m = 0; m < pdfium::size(kMonths); ++m) { + for (size_t m = 0; m < std::size(kMonths); ++m) { if (sMonth.CompareNoCase(kMonths[m]) == 0) { nMonth = static_cast<int>(m) + 1; i += 3; @@ -471,7 +472,7 @@ if (nSkip <= kLongestFullMonthLength) { WideString sMonth = value.Substr(j, nSkip); sMonth.MakeLower(); - for (size_t m = 0; m < pdfium::size(kFullMonths); ++m) { + for (size_t m = 0; m < std::size(kFullMonths); ++m) { WideString sFullMonths = WideString(kFullMonths[m]); sFullMonths.MakeLower(); if (sFullMonths.Contains(sMonth.AsStringView())) {
diff --git a/fxjs/xfa/cfxjse_formcalc_context.cpp b/fxjs/xfa/cfxjse_formcalc_context.cpp index a5a4650..7d6a5fe 100644 --- a/fxjs/xfa/cfxjse_formcalc_context.cpp +++ b/fxjs/xfa/cfxjse_formcalc_context.cpp
@@ -299,7 +299,7 @@ 255, 2, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 1, 255, 255, 255, 255, 255, 255, 255, 255, }; -static_assert(pdfium::size(kAltTableDate) == L'a' - L'A' + 1, +static_assert(std::size(kAltTableDate) == L'a' - L'A' + 1, "Invalid kAltTableDate size."); const uint8_t kAltTableTime[] = { @@ -307,7 +307,7 @@ 255, 6, 255, 255, 255, 255, 255, 7, 255, 255, 255, 255, 255, 1, 17, 255, 255, 255, 255, 255, 255, 255, }; -static_assert(pdfium::size(kAltTableTime) == L'a' - L'A' + 1, +static_assert(std::size(kAltTableTime) == L'a' - L'A' + 1, "Invalid kAltTableTime size."); void AlternateDateTimeSymbols(WideString* pPattern, @@ -979,7 +979,7 @@ szEncode[3] = 0; for (wchar_t ch : wsURL) { size_t i = 0; - size_t iCount = pdfium::size(kStrUnsafe); + size_t iCount = std::size(kStrUnsafe); while (i < iCount) { if (ch == kStrUnsafe[i]) { int32_t iIndex = ch / 16; @@ -994,7 +994,7 @@ continue; i = 0; - iCount = pdfium::size(kStrReserved); + iCount = std::size(kStrReserved); while (i < iCount) { if (ch == kStrReserved[i]) { int32_t iIndex = ch / 16; @@ -1009,7 +1009,7 @@ continue; i = 0; - iCount = pdfium::size(kStrSpecial); + iCount = std::size(kStrSpecial); while (i < iCount) { if (ch == kStrSpecial[i]) { wsResultBuf.AppendChar(ch); @@ -1667,14 +1667,14 @@ } // namespace const FXJSE_CLASS_DESCRIPTOR kFormCalcDescriptor = { - kClassTag, // tag - "XFA_FormCalcClass", // name - kFormCalcFunctions, // methods - pdfium::size(kFormCalcFunctions), // number of methods - nullptr, // dynamic prop type - nullptr, // dynamic prop getter - nullptr, // dynamic prop setter - nullptr, // dynamic prop method call + kClassTag, // tag + "XFA_FormCalcClass", // name + kFormCalcFunctions, // methods + std::size(kFormCalcFunctions), // number of methods + nullptr, // dynamic prop type + nullptr, // dynamic prop getter + nullptr, // dynamic prop setter + nullptr, // dynamic prop method call }; // static
diff --git a/testing/fuzzers/pdf_cfgas_stringformatter_fuzzer.cc b/testing/fuzzers/pdf_cfgas_stringformatter_fuzzer.cc index 5eaf376..d1b9922 100644 --- a/testing/fuzzers/pdf_cfgas_stringformatter_fuzzer.cc +++ b/testing/fuzzers/pdf_cfgas_stringformatter_fuzzer.cc
@@ -6,12 +6,13 @@ #include <stdint.h> +#include <iterator> + #include "core/fxcrt/cfx_datetime.h" #include "core/fxcrt/fx_string.h" #include "public/fpdfview.h" #include "testing/fuzzers/pdfium_fuzzer_util.h" #include "testing/fuzzers/xfa_process_state.h" -#include "third_party/base/cxx17_backports.h" #include "v8/include/cppgc/heap.h" #include "v8/include/cppgc/persistent.h" #include "xfa/fxfa/parser/cxfa_localemgr.h" @@ -35,8 +36,8 @@ cppgc::Heap* heap = state->GetHeap(); uint8_t test_selector = data[0] % 10; - uint8_t locale_selector = data[1] % pdfium::size(kLocales); - uint8_t type_selector = data[2] % pdfium::size(kTypes); + uint8_t locale_selector = data[1] % std::size(kLocales); + uint8_t type_selector = data[2] % std::size(kTypes); data += 3; size -= 3;
diff --git a/testing/fuzzers/pdf_scanlinecompositor_fuzzer.cc b/testing/fuzzers/pdf_scanlinecompositor_fuzzer.cc index 9a9d735..a0f2cf9 100644 --- a/testing/fuzzers/pdf_scanlinecompositor_fuzzer.cc +++ b/testing/fuzzers/pdf_scanlinecompositor_fuzzer.cc
@@ -2,6 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +#include <iterator> #include <memory> #include "core/fxcrt/fx_safe_types.h" @@ -9,7 +10,6 @@ #include "core/fxge/dib/cfx_dibitmap.h" #include "core/fxge/dib/fx_dib.h" #include "testing/fuzzers/pdfium_fuzzer_util.h" -#include "third_party/base/cxx17_backports.h" namespace { @@ -49,8 +49,8 @@ BlendMode blend_mode = static_cast<BlendMode>( data[28] % (static_cast<int>(BlendMode::kLast) + 1)); - FXDIB_Format dest_format = kFormat[data[29] % pdfium::size(kFormat)]; - FXDIB_Format src_format = kFormat[data[30] % pdfium::size(kFormat)]; + FXDIB_Format dest_format = kFormat[data[29] % std::size(kFormat)]; + FXDIB_Format src_format = kFormat[data[30] % std::size(kFormat)]; bool is_clip = !(data[31] % 2); bool is_rgb_byte_order = !(data[32] % 2); size -= kParameterSize;
diff --git a/testing/fuzzers/pdf_xfa_fdp_fuzzer.cc b/testing/fuzzers/pdf_xfa_fdp_fuzzer.cc index b5dd112..2323837 100644 --- a/testing/fuzzers/pdf_xfa_fdp_fuzzer.cc +++ b/testing/fuzzers/pdf_xfa_fdp_fuzzer.cc
@@ -11,7 +11,6 @@ #include "testing/fuzzers/pdf_fuzzer_templates.h" #include "testing/fuzzers/pdfium_fuzzer_helper.h" #include "third_party/base/containers/adapters.h" -#include "third_party/base/cxx17_backports.h" class PDFiumXFAFuzzer : public PDFiumFuzzerHelper { public: @@ -215,7 +214,7 @@ }; size_t elem_selector = data_provider->ConsumeIntegralInRange<size_t>( - 0, pdfium::size(kXfaScriptFuncs) - 1); + 0, std::size(kXfaScriptFuncs) - 1); return kXfaScriptFuncs[elem_selector]; } @@ -311,7 +310,7 @@ }; size_t elem_selector = data_provider->ConsumeIntegralInRange<size_t>( - 0, pdfium::size(kXfaFuncParams) - 1); + 0, std::size(kXfaFuncParams) - 1); return MaybeQuote(data_provider, kXfaFuncParams[elem_selector]); } @@ -641,7 +640,7 @@ }; size_t elem_selector = data_provider->ConsumeIntegralInRange<size_t>( - 0, pdfium::size(kXfaElemTags) - 1); + 0, std::size(kXfaElemTags) - 1); return kXfaElemTags[elem_selector]; } @@ -663,7 +662,7 @@ }; size_t elem_selector = data_provider->ConsumeIntegralInRange<size_t>( - 0, pdfium::size(kXfaTagVals) - 1); + 0, std::size(kXfaTagVals) - 1); return MaybeQuote(data_provider, kXfaTagVals[elem_selector]); } @@ -689,7 +688,7 @@ "y", }; size_t elem_selector = data_provider->ConsumeIntegralInRange<size_t>( - 0, pdfium::size(kXfaTagNames) - 1); + 0, std::size(kXfaTagNames) - 1); return kXfaTagNames[elem_selector]; }
diff --git a/third_party/base/allocator/partition_allocator/partition_alloc.h b/third_party/base/allocator/partition_allocator/partition_alloc.h index ca091b6..0f4f83a 100644 --- a/third_party/base/allocator/partition_allocator/partition_alloc.h +++ b/third_party/base/allocator/partition_allocator/partition_alloc.h
@@ -63,6 +63,8 @@ #include <limits.h> #include <string.h> +#include <iterator> + #include "build/build_config.h" #include "third_party/base/allocator/partition_allocator/page_allocator.h" #include "third_party/base/allocator/partition_allocator/partition_alloc_constants.h" @@ -75,7 +77,6 @@ #include "third_party/base/bits.h" #include "third_party/base/check.h" #include "third_party/base/compiler_specific.h" -#include "third_party/base/cxx17_backports.h" #include "third_party/base/sys_byteorder.h" #if defined(MEMORY_TOOL_REPLACES_ALLOCATOR) @@ -501,7 +502,7 @@ public: SizeSpecificPartitionAllocator() { memset(actual_buckets_, 0, - sizeof(internal::PartitionBucket) * pdfium::size(actual_buckets_)); + sizeof(internal::PartitionBucket) * std::size(actual_buckets_)); } ~SizeSpecificPartitionAllocator() = default; static const size_t kMaxAllocation = N - kAllocationGranularity;
diff --git a/third_party/base/cxx17_backports.h b/third_party/base/cxx17_backports.h index 9d6a966..0672331 100644 --- a/third_party/base/cxx17_backports.h +++ b/third_party/base/cxx17_backports.h
@@ -13,18 +13,6 @@ namespace pdfium { -// C++14 implementation of C++17's std::size(): -// http://en.cppreference.com/w/cpp/iterator/size -template <typename Container> -constexpr auto size(const Container& c) -> decltype(c.size()) { - return c.size(); -} - -template <typename T, size_t N> -constexpr size_t size(const T (&array)[N]) noexcept { - return N; -} - // C++14 implementation of C++17's std::clamp(): // https://en.cppreference.com/w/cpp/algorithm/clamp // Please note that the C++ spec makes it undefined behavior to call std::clamp
diff --git a/xfa/fde/cfde_wordbreak_data.cpp b/xfa/fde/cfde_wordbreak_data.cpp index 2e1a3f0..1afb3c7 100644 --- a/xfa/fde/cfde_wordbreak_data.cpp +++ b/xfa/fde/cfde_wordbreak_data.cpp
@@ -6,9 +6,10 @@ #include "xfa/fde/cfde_wordbreak_data.h" +#include <iterator> + #include "core/fxcrt/fx_system.h" #include "third_party/base/check.h" -#include "third_party/base/cxx17_backports.h" namespace { @@ -2826,7 +2827,7 @@ WordBreakProperty FX_GetWordBreakProperty(wchar_t wcCodePoint) { size_t index = static_cast<size_t>(wcCodePoint) / 2; - if (index >= pdfium::size(kCodePointProperties)) + if (index >= std::size(kCodePointProperties)) return WordBreakProperty::kNone; uint8_t dwProperty = kCodePointProperties[index];
diff --git a/xfa/fgas/crt/cfgas_stringformatter.cpp b/xfa/fgas/crt/cfgas_stringformatter.cpp index a5d1e8b..b2097df 100644 --- a/xfa/fgas/crt/cfgas_stringformatter.cpp +++ b/xfa/fgas/crt/cfgas_stringformatter.cpp
@@ -17,7 +17,6 @@ #include "core/fxcrt/fx_extension.h" #include "core/fxcrt/fx_safe_types.h" #include "third_party/base/containers/contains.h" -#include "third_party/base/cxx17_backports.h" #include "third_party/base/notreached.h" #include "xfa/fgas/crt/cfgas_decimal.h" #include "xfa/fgas/crt/locale_mgr_iface.h" @@ -454,7 +453,7 @@ ResolveZone(tz_diff_minutes, pLocale, &hour, &minute); } else { // Search the timezone list. There are only 8 of them, so linear scan. - for (size_t i = 0; i < pdfium::size(kFXLocaleTimeZoneData); ++i) { + for (size_t i = 0; i < std::size(kFXLocaleTimeZoneData); ++i) { const FX_LOCALETIMEZONEINFO& info = kFXLocaleTimeZoneData[i]; if (tz != info.name) continue;
diff --git a/xfa/fgas/crt/cfgas_stringformatter_unittest.cpp b/xfa/fgas/crt/cfgas_stringformatter_unittest.cpp index 183d967..101021e 100644 --- a/xfa/fgas/crt/cfgas_stringformatter_unittest.cpp +++ b/xfa/fgas/crt/cfgas_stringformatter_unittest.cpp
@@ -6,6 +6,8 @@ #include "xfa/fgas/crt/cfgas_stringformatter.h" +#include <iterator> + #include "build/build_config.h" #include "core/fpdfapi/page/cpdf_pagemodule.h" #include "core/fxcrt/cfx_datetime.h" @@ -13,7 +15,6 @@ #include "testing/fxgc_unittest.h" #include "testing/gtest/include/gtest/gtest.h" #include "testing/scoped_set_tz.h" -#include "third_party/base/cxx17_backports.h" #include "v8/include/cppgc/persistent.h" #include "xfa/fxfa/parser/cxfa_localemgr.h" @@ -89,7 +90,7 @@ // as they are not supported. In theory there are the full width versions // of DDD, DDDD, MMM, MMMM, E, e, gg, YYY, YYYYY. - for (size_t i = 0; i < pdfium::size(tests); ++i) { + for (size_t i = 0; i < std::size(tests); ++i) { WideString result; CFGAS_StringFormatter fmt(tests[i].pattern); EXPECT_TRUE(fmt.FormatDateTime(Mgr(tests[i].locale), tests[i].input, @@ -140,7 +141,7 @@ { ScopedSetTZ scoped_tz("UTC+2"); - for (size_t i = 0; i < pdfium::size(tests); ++i) { + for (size_t i = 0; i < std::size(tests); ++i) { WideString result; CFGAS_StringFormatter fmt(tests[i].pattern); EXPECT_TRUE(fmt.FormatDateTime(Mgr(tests[i].locale), tests[i].input, @@ -172,7 +173,7 @@ {L"en", L"9111T1111:", L"MMM D, YYYYTh:MM:SS A", L"Jan 1, 9111 11:11:00 AM"}}; - for (size_t i = 0; i < pdfium::size(tests); ++i) { + for (size_t i = 0; i < std::size(tests); ++i) { WideString result; CFGAS_StringFormatter fmt(tests[i].pattern); EXPECT_TRUE(fmt.FormatDateTime( @@ -201,7 +202,7 @@ L"time{'At 'HH:MM Z}date{' on 'MMM DD, YYYY}", L"At 10:30 GMT on Jul 16, 1999"}}; - for (size_t i = 0; i < pdfium::size(tests); ++i) { + for (size_t i = 0; i < std::size(tests); ++i) { WideString result; CFGAS_StringFormatter fmt(tests[i].pattern); EXPECT_TRUE(fmt.FormatDateTime( @@ -263,7 +264,7 @@ // not supported. In theory there are the full width versions of DDD, // DDDD, MMM, MMMM, E, e, gg, YYY, YYYYY. - for (size_t i = 0; i < pdfium::size(tests); ++i) { + for (size_t i = 0; i < std::size(tests); ++i) { CFX_DateTime result; CFGAS_StringFormatter fmt(tests[i].pattern); EXPECT_TRUE(fmt.ParseDateTime(Mgr(tests[i].locale), tests[i].input, @@ -291,7 +292,7 @@ // // kkkk, HHH, HHHH, KKK, KKKK, MMM, MMMM, SSS, SSSS plus 2 more that the // // spec apparently forgot to list the symbol. -// for (size_t i = 0; i < pdfium::size(tests); ++i) { +// for (size_t i = 0; i < std::size(tests); ++i) { // CFX_DateTime result; // EXPECT_TRUE(fmt(tests[i].locale) // ->ParseDateTime(tests[i].input, tests[i].pattern, @@ -617,7 +618,7 @@ {L"A1C-1234-D", L"000-9999-X", L"A1C1234D"}, {L"A1C-1234-D text", L"000-9999-X 'text'", L"A1C1234D"}}; - for (size_t i = 0; i < pdfium::size(tests); ++i) { + for (size_t i = 0; i < std::size(tests); ++i) { WideString result; CFGAS_StringFormatter fmt(tests[i].pattern); EXPECT_TRUE(fmt.ParseText(tests[i].input, &result)); @@ -648,7 +649,7 @@ {L"en", L"K1#5K2", L"00X OO9", L"K1# 5K2"}, }; - for (size_t i = 0; i < pdfium::size(tests); ++i) { + for (size_t i = 0; i < std::size(tests); ++i) { WideString result; CFGAS_StringFormatter fmt(tests[i].pattern); EXPECT_TRUE(fmt.FormatText(tests[i].input, &result)); @@ -665,7 +666,7 @@ {L"No data", L"null{'No data'}"}, }; - for (size_t i = 0; i < pdfium::size(tests); ++i) { + for (size_t i = 0; i < std::size(tests); ++i) { CFGAS_StringFormatter fmt(tests[i].pattern); EXPECT_TRUE(fmt.ParseNull(tests[i].input)) << " TEST: " << i; } @@ -677,7 +678,7 @@ const wchar_t* output; } tests[] = {{L"null{'n/a'}", L"n/a"}, {L"null{}", L""}}; - for (size_t i = 0; i < pdfium::size(tests); ++i) { + for (size_t i = 0; i < std::size(tests); ++i) { WideString result; CFGAS_StringFormatter fmt(tests[i].pattern); EXPECT_TRUE(fmt.FormatNull(&result)); @@ -691,7 +692,7 @@ const wchar_t* pattern; } tests[] = {{L"", L"zero{}"}, {L"9", L"zero{9}"}, {L"a", L"zero{'a'}"}}; - for (size_t i = 0; i < pdfium::size(tests); ++i) { + for (size_t i = 0; i < std::size(tests); ++i) { CFGAS_StringFormatter fmt(tests[i].pattern); EXPECT_TRUE(fmt.ParseZero(tests[i].input)) << " TEST: " << i; } @@ -709,7 +710,7 @@ // {L"0.0", L"zero{9}", L"0"}, {L"0", L"zero{}", L""}}; - for (size_t i = 0; i < pdfium::size(tests); ++i) { + for (size_t i = 0; i < std::size(tests); ++i) { WideString result; CFGAS_StringFormatter fmt(tests[i].pattern); EXPECT_TRUE(fmt.FormatZero(&result));
diff --git a/xfa/fgas/font/cfgas_fontmgr.cpp b/xfa/fgas/font/cfgas_fontmgr.cpp index 069cf65..29e3bd6 100644 --- a/xfa/fgas/font/cfgas_fontmgr.cpp +++ b/xfa/fgas/font/cfgas_fontmgr.cpp
@@ -7,6 +7,7 @@ #include "xfa/fgas/font/cfgas_fontmgr.h" #include <algorithm> +#include <iterator> #include <memory> #include <utility> @@ -23,7 +24,6 @@ #include "core/fxge/fx_font.h" #include "third_party/base/check.h" #include "third_party/base/containers/contains.h" -#include "third_party/base/cxx17_backports.h" #include "third_party/base/numerics/safe_conversions.h" #include "third_party/base/span.h" #include "xfa/fgas/font/cfgas_gefont.h" @@ -350,7 +350,7 @@ FX_CodePage::kMSDOS_US}; uint16_t FX_GetCodePageBit(FX_CodePage wCodePage) { - for (size_t i = 0; i < pdfium::size(kCodePages); ++i) { + for (size_t i = 0; i < std::size(kCodePages); ++i) { if (kCodePages[i] == wCodePage) return static_cast<uint16_t>(i); }
diff --git a/xfa/fgas/font/cfgas_pdffontmgr.cpp b/xfa/fgas/font/cfgas_pdffontmgr.cpp index a34bc98..84070ca 100644 --- a/xfa/fgas/font/cfgas_pdffontmgr.cpp +++ b/xfa/fgas/font/cfgas_pdffontmgr.cpp
@@ -7,6 +7,7 @@ #include "xfa/fgas/font/cfgas_pdffontmgr.h" #include <algorithm> +#include <iterator> #include "core/fpdfapi/font/cpdf_font.h" #include "core/fpdfapi/page/cpdf_docpagedata.h" @@ -15,7 +16,6 @@ #include "core/fpdfapi/parser/fpdf_parser_utility.h" #include "core/fxge/fx_font.h" #include "third_party/base/check.h" -#include "third_party/base/cxx17_backports.h" #include "xfa/fgas/font/cfgas_fontmgr.h" #include "xfa/fgas/font/cfgas_gefont.h" @@ -98,7 +98,7 @@ ByteString CFGAS_PDFFontMgr::PsNameToFontName(const ByteString& strPsName, bool bBold, bool bItalic) { - for (size_t i = 0; i < pdfium::size(kXFAPDFFontName); ++i) { + for (size_t i = 0; i < std::size(kXFAPDFFontName); ++i) { if (strPsName == kXFAPDFFontName[i][0]) { size_t index = 1; if (bBold)
diff --git a/xfa/fgas/font/fgas_fontutils.cpp b/xfa/fgas/font/fgas_fontutils.cpp index 6e6835d..4e26044 100644 --- a/xfa/fgas/font/fgas_fontutils.cpp +++ b/xfa/fgas/font/fgas_fontutils.cpp
@@ -6,10 +6,11 @@ #include "xfa/fgas/font/fgas_fontutils.h" +#include <iterator> + #include "build/build_config.h" #include "core/fxcrt/fx_codepage.h" #include "core/fxcrt/fx_extension.h" -#include "third_party/base/cxx17_backports.h" #include "xfa/fgas/font/cfgas_fontmgr.h" namespace { @@ -2448,7 +2449,7 @@ WideString FGAS_FontNameToEnglishName(WideStringView wsLocalName) { uint32_t dwLocalNameHash = FX_HashCode_GetLoweredW(wsLocalName); - const FGAS_FontInfo* pEnd = kXFAFontsMap + pdfium::size(kXFAFontsMap); + const FGAS_FontInfo* pEnd = kXFAFontsMap + std::size(kXFAFontsMap); const FGAS_FontInfo* pFontInfo = std::lower_bound(kXFAFontsMap, pEnd, dwLocalNameHash, [](const FGAS_FontInfo& entry, uint32_t hash) { @@ -2464,7 +2465,7 @@ wsFontNameTemp.Remove(L' '); uint32_t dwCurFontNameHash = FX_HashCode_GetLoweredW(wsFontNameTemp.AsStringView()); - const FGAS_FontInfo* pEnd = kXFAFontsMap + pdfium::size(kXFAFontsMap); + const FGAS_FontInfo* pEnd = kXFAFontsMap + std::size(kXFAFontsMap); const FGAS_FontInfo* pFontInfo = std::lower_bound(kXFAFontsMap, pEnd, dwCurFontNameHash, [](const FGAS_FontInfo& entry, uint32_t hash) {
diff --git a/xfa/fgas/graphics/cfgas_gegraphics.cpp b/xfa/fgas/graphics/cfgas_gegraphics.cpp index 2e17570..3163cc3 100644 --- a/xfa/fgas/graphics/cfgas_gegraphics.cpp +++ b/xfa/fgas/graphics/cfgas_gegraphics.cpp
@@ -8,6 +8,7 @@ #include <math.h> +#include <iterator> #include <memory> #include "core/fxcrt/fx_system.h" @@ -16,7 +17,6 @@ #include "core/fxge/cfx_unicodeencoding.h" #include "core/fxge/dib/cfx_dibitmap.h" #include "third_party/base/check.h" -#include "third_party/base/cxx17_backports.h" #include "xfa/fgas/graphics/cfgas_gecolor.h" #include "xfa/fgas/graphics/cfgas_gepath.h" #include "xfa/fgas/graphics/cfgas_gepattern.h" @@ -106,8 +106,8 @@ }}; const FX_HATCHDATA& GetHatchBitmapData(size_t index) { - return index < pdfium::size(kHatchBitmapData) ? kHatchBitmapData[index] - : kHatchPlaceHolder; + return index < std::size(kHatchBitmapData) ? kHatchBitmapData[index] + : kHatchPlaceHolder; } } // namespace
diff --git a/xfa/fgas/layout/cfgas_char.cpp b/xfa/fgas/layout/cfgas_char.cpp index 8563097..92015df 100644 --- a/xfa/fgas/layout/cfgas_char.cpp +++ b/xfa/fgas/layout/cfgas_char.cpp
@@ -7,11 +7,11 @@ #include "xfa/fgas/layout/cfgas_char.h" #include <algorithm> +#include <iterator> #include "core/fxcrt/fx_extension.h" #include "core/fxcrt/stl_util.h" #include "third_party/base/check.h" -#include "third_party/base/cxx17_backports.h" namespace { @@ -239,29 +239,29 @@ } FX_BIDIWEAKSTATE GetWeakState(FX_BIDIWEAKSTATE eState, FX_BIDICLASS eClass) { - DCHECK(static_cast<size_t>(eState) < pdfium::size(kWeakStates)); - DCHECK(static_cast<size_t>(eClass) < pdfium::size(kWeakStates[0])); + DCHECK(static_cast<size_t>(eState) < std::size(kWeakStates)); + DCHECK(static_cast<size_t>(eClass) < std::size(kWeakStates[0])); return kWeakStates[static_cast<size_t>(eState)][static_cast<size_t>(eClass)]; } FX_BIDIWEAKACTION GetWeakAction(FX_BIDIWEAKSTATE eState, FX_BIDICLASS eClass) { - DCHECK(static_cast<size_t>(eState) < pdfium::size(kWeakActions)); - DCHECK(static_cast<size_t>(eClass) < pdfium::size(kWeakActions[0])); + DCHECK(static_cast<size_t>(eState) < std::size(kWeakActions)); + DCHECK(static_cast<size_t>(eClass) < std::size(kWeakActions[0])); return kWeakActions[static_cast<size_t>(eState)][static_cast<size_t>(eClass)]; } FX_BIDINEUTRALSTATE GetNeutralState(FX_BIDINEUTRALSTATE eState, FX_BIDICLASS eClass) { - DCHECK(static_cast<size_t>(eState) < pdfium::size(kNeutralStates)); - DCHECK(static_cast<size_t>(eClass) < pdfium::size(kNeutralStates[0])); + DCHECK(static_cast<size_t>(eState) < std::size(kNeutralStates)); + DCHECK(static_cast<size_t>(eClass) < std::size(kNeutralStates[0])); return kNeutralStates[static_cast<size_t>(eState)] [static_cast<size_t>(eClass)]; } FX_BIDINEUTRALACTION GetNeutralAction(FX_BIDINEUTRALSTATE eState, FX_BIDICLASS eClass) { - DCHECK(static_cast<size_t>(eState) < pdfium::size(kNeutralActions)); - DCHECK(static_cast<size_t>(eClass) < pdfium::size(kNeutralActions[0])); + DCHECK(static_cast<size_t>(eState) < std::size(kNeutralActions)); + DCHECK(static_cast<size_t>(eClass) < std::size(kNeutralActions[0])); return kNeutralActions[static_cast<size_t>(eState)] [static_cast<size_t>(eClass)]; }
diff --git a/xfa/fgas/layout/fgas_arabic.cpp b/xfa/fgas/layout/fgas_arabic.cpp index 9327524..2709cb7 100644 --- a/xfa/fgas/layout/fgas_arabic.cpp +++ b/xfa/fgas/layout/fgas_arabic.cpp
@@ -6,8 +6,9 @@ #include "xfa/fgas/layout/fgas_arabic.h" +#include <iterator> + #include "core/fxcrt/fx_unicode.h" -#include "third_party/base/cxx17_backports.h" #include "xfa/fgas/layout/cfgas_char.h" namespace { @@ -118,7 +119,7 @@ }; constexpr uint16_t kFirstFormTableEntry = 0x0622; constexpr uint16_t kLastFormTableEntry = - kFirstFormTableEntry + pdfium::size(kFormTable) - 1; + kFirstFormTableEntry + std::size(kFormTable) - 1; constexpr FX_ARAALEF kAlefTable[] = { {0x0622, 0xFEF5}, @@ -130,7 +131,7 @@ constexpr uint16_t kShaddaTable[] = {0xFC5E, 0xFC5F, 0xFC60, 0xFC61, 0xFC62}; constexpr uint16_t kFirstShaddaTableEntry = 0x064c; constexpr uint16_t kLastShaddaTableEntry = - kFirstShaddaTableEntry + pdfium::size(kShaddaTable) - 1; + kFirstShaddaTableEntry + std::size(kShaddaTable) - 1; const FX_ARBFORMTABLE* GetArabicFormTable(wchar_t unicode) { if (unicode < kFirstFormTableEntry || unicode > kLastFormTableEntry)
diff --git a/xfa/fgas/layout/fgas_linebreak.cpp b/xfa/fgas/layout/fgas_linebreak.cpp index a13a948..7519e9a 100644 --- a/xfa/fgas/layout/fgas_linebreak.cpp +++ b/xfa/fgas/layout/fgas_linebreak.cpp
@@ -6,9 +6,10 @@ #include "xfa/fgas/layout/fgas_linebreak.h" +#include <iterator> + #include "core/fxcrt/fx_unicode.h" #include "third_party/base/check.h" -#include "third_party/base/cxx17_backports.h" namespace { @@ -227,7 +228,7 @@ FX_BREAKPROPERTY next_char) { size_t row = static_cast<size_t>(curr_char); size_t col = static_cast<size_t>(next_char); - DCHECK(row < pdfium::size(kFX_LineBreak_PairTable)); - DCHECK(col < pdfium::size(kFX_LineBreak_PairTable[0])); + DCHECK(row < std::size(kFX_LineBreak_PairTable)); + DCHECK(col < std::size(kFX_LineBreak_PairTable[0])); return kFX_LineBreak_PairTable[row][col]; }
diff --git a/xfa/fwl/theme/cfwl_checkboxtp.cpp b/xfa/fwl/theme/cfwl_checkboxtp.cpp index 6cff533..0270e84 100644 --- a/xfa/fwl/theme/cfwl_checkboxtp.cpp +++ b/xfa/fwl/theme/cfwl_checkboxtp.cpp
@@ -8,8 +8,9 @@ #include <math.h> +#include <iterator> + #include "core/fxge/cfx_path.h" -#include "third_party/base/cxx17_backports.h" #include "xfa/fde/cfde_textout.h" #include "xfa/fgas/graphics/cfgas_gecolor.h" #include "xfa/fgas/graphics/cfgas_gegraphics.h" @@ -143,8 +144,8 @@ path.MoveTo(points[0]); int next = 0; - for (size_t i = 0; i < pdfium::size(points); ++i) { - next = (next + 2) % pdfium::size(points); + for (size_t i = 0; i < std::size(points); ++i) { + next = (next + 2) % std::size(points); path.LineTo(points[next]); } pGraphics->SaveGraphState();
diff --git a/xfa/fxfa/formcalc/cxfa_fmlexer_unittest.cpp b/xfa/fxfa/formcalc/cxfa_fmlexer_unittest.cpp index 14bc834..7bef343 100644 --- a/xfa/fxfa/formcalc/cxfa_fmlexer_unittest.cpp +++ b/xfa/fxfa/formcalc/cxfa_fmlexer_unittest.cpp
@@ -7,7 +7,6 @@ #include <vector> #include "testing/gtest/include/gtest/gtest.h" -#include "third_party/base/cxx17_backports.h" TEST(CXFA_FMLexerTest, NullString) { WideStringView null_string; @@ -181,7 +180,7 @@ {L".#", TOKdotscream}, {L".*", TOKdotstar}}; - for (size_t i = 0; i < pdfium::size(op); ++i) { + for (size_t i = 0; i < std::size(op); ++i) { CXFA_FMLexer lexer(op[i].op); CXFA_FMLexer::Token token = lexer.NextToken(); EXPECT_EQ(op[i].token, token.m_type);
diff --git a/xfa/fxfa/parser/xfa_basic_data.cpp b/xfa/fxfa/parser/xfa_basic_data.cpp index 7994f88..f746a37 100644 --- a/xfa/fxfa/parser/xfa_basic_data.cpp +++ b/xfa/fxfa/parser/xfa_basic_data.cpp
@@ -40,7 +40,6 @@ #include "fxjs/xfa/cjx_treelist.h" #include "fxjs/xfa/cjx_wsdlconnection.h" #include "fxjs/xfa/cjx_xfa.h" -#include "third_party/base/cxx17_backports.h" #include "xfa/fxfa/fxfa_basic.h" namespace { @@ -80,7 +79,7 @@ #undef ELEM____ }; -static_assert(pdfium::size(kElementRecords) == pdfium::size(kElementNames), +static_assert(std::size(kElementRecords) == std::size(kElementNames), "Size mismatch"); struct AttributeRecord { @@ -105,7 +104,7 @@ #undef ATTR____ }; -static_assert(pdfium::size(kAttributeRecords) == pdfium::size(kAttributeNames), +static_assert(std::size(kAttributeRecords) == std::size(kAttributeNames), "Size mismatch"); struct AttributeValueRecord { @@ -130,8 +129,8 @@ #undef VALUE____ }; -static_assert(pdfium::size(kAttributeValueRecords) == - pdfium::size(kAttributeValueNames), +static_assert(std::size(kAttributeValueRecords) == + std::size(kAttributeValueNames), "Size mismatch"); struct ElementAttributeRecord { @@ -155,8 +154,8 @@ #undef ELEM_ATTR____ }; -static_assert(pdfium::size(kElementAttributeRecords) == - pdfium::size(kElementAttributeCallbacks), +static_assert(std::size(kElementAttributeRecords) == + std::size(kElementAttributeCallbacks), "Size mismatch"); } // namespace
diff --git a/xfa/fxfa/parser/xfa_utils_unittest.cpp b/xfa/fxfa/parser/xfa_utils_unittest.cpp index 5493ce4..932827c 100644 --- a/xfa/fxfa/parser/xfa_utils_unittest.cpp +++ b/xfa/fxfa/parser/xfa_utils_unittest.cpp
@@ -4,8 +4,9 @@ #include "xfa/fxfa/parser/xfa_utils.h" +#include <iterator> + #include "testing/gtest/include/gtest/gtest.h" -#include "third_party/base/cxx17_backports.h" TEST(XfaUtilsImpTest, XFA_MapRotation) { struct TestCase { @@ -17,7 +18,7 @@ {91, 91}, {359, 359}, {360, 0}, {361, 1}, {100000, 280}}; - for (size_t i = 0; i < pdfium::size(TestCases); ++i) { + for (size_t i = 0; i < std::size(TestCases); ++i) { EXPECT_EQ(TestCases[i].expected_output, XFA_MapRotation(TestCases[i].input)); }