diff --git a/.gn b/.gn index 516519769d..f13464945b 100644 --- a/.gn +++ b/.gn @@ -42,6 +42,9 @@ default_args = { # PDFium does not use ICU4X implementations for ECMA-402 features. v8_enable_ecma402_icu4x = false + # PDFium does not include the boringssl library. + v8_use_openssl = false + # PDFium has its own unsafe-buffers enforcement directories. clang_unsafe_buffers_paths = "//unsafe_buffers_paths.txt" @@ -72,7 +75,6 @@ no_check_targets = [ "//v8:cppgc_base", "//v8:v8_internal_headers", "//v8/src/inspector:inspector", - "//v8/test/cctest:cctest_sources", "//v8/test/unittests:inspector_unittests_sources", ] diff --git a/DEPS b/DEPS index a37659b2f0..afac0c60f8 100644 --- a/DEPS +++ b/DEPS @@ -90,11 +90,11 @@ vars = { # Three lines of non-changing comments so that # the commit queue can handle CLs rolling brotli # and whatever else without interference from each other. - 'brotli_revision': '803ac71664ad62af1de39ff55e63ebbe07006fc8', + 'brotli_revision': 'ee1fadd362a24bf226c55606caa6b30f15ee0fa1', # Three lines of non-changing comments so that # the commit queue can handle CLs rolling build # and whatever else without interference from each other. - 'build_revision': '0c62137b8623a3fab2c6aa5d7c94f719b3aa31f6', + 'build_revision': '25b83e4e27227b1121cf83fd1cd89a7c81a59afd', # Three lines of non-changing comments so that # the commit queue can handle CLs rolling buildtools # and whatever else without interference from each other. @@ -102,7 +102,7 @@ vars = { # Three lines of non-changing comments so that # the commit queue can handle CLs rolling catapult # and whatever else without interference from each other. - 'catapult_revision': 'c29dedc30c9ff1b0cc677e32a9a959ad5ed41bde', + 'catapult_revision': 'a93a68f704ca422b2c5e8fd2f4fe36397b71c270', # Three lines of non-changing comments so that # the commit queue can handle CLs rolling clang format # and whatever else without interference from each other. @@ -110,7 +110,7 @@ vars = { # Three lines of non-changing comments so that # the commit queue can handle CLs rolling clang # and whatever else without interference from each other. - 'clang_revision': '7ea1bdeeaf498a513c77b66667e56f6f41f9f0b3', + 'clang_revision': '1692d7278beb9a529be6e860f5f029cc37d0ca83', # Three lines of non-changing comments so that # the commit queue can handle CLs rolling code_coverage # and whatever else without interference from each other. @@ -212,7 +212,7 @@ vars = { # Three lines of non-changing comments so that # the commit queue can handle CLs rolling nasm_source # and whatever else without interference from each other. - 'nasm_source_revision': '525a09a813be0f75b646ee93fc2a31c27b87d722', + 'nasm_source_revision': '54b1dcf7995006337c54f6862fd6f77a01e23e4e', # Three lines of non-changing comments so that # the commit queue can handle CLs rolling Ninja CIPD package version # and whatever else without interference from each other. @@ -260,7 +260,7 @@ vars = { # Three lines of non-changing comments so that # the commit queue can handle CLs rolling tools_rust # and whatever else without interference from each other. - 'tools_rust_revision': 'b7b03f53fe7d9e6b781bd1837d92275279ce5794', + 'tools_rust_revision': '49993f7c20c21400fd1d390cbf72994d7b63df17', # Three lines of non-changing comments so that # the commit queue can handle CLs rolling tools_win_revision # and whatever else without interference from each other. @@ -268,11 +268,11 @@ vars = { # Three lines of non-changing comments so that # the commit queue can handle CLs rolling v8 # and whatever else without interference from each other. - 'v8_revision': 'b5156d2a71b52cab0b53a82a165c77612179098b', + 'v8_revision': 'a12d1e5662b89c58b5cca490fc4a770051f0567e', # Three lines of non-changing comments so that # the commit queue can handle CLs rolling zlib # and whatever else without interference from each other. - 'zlib_revision': '9f9f52c60a14e8e772fb561029ae0a121fef7609', + 'zlib_revision': '02826dbec8efeccfcd8960142c75fd704f0ddd03', } # Only these hosts are allowed for dependencies in this DEPS file. @@ -489,171 +489,171 @@ deps = { 'bucket': 'chromium-browser-clang', 'objects': [ { - 'object_name': 'Linux_x64/clang-android-runtime-library-llvmorg-24-init-14453-ge063be79-1.tar.xz', - 'sha256sum': 'dd03492cad72f223d7743c2f4af39c405f5bac7f7f342de09697a45b7108ce4e', - 'size_bytes': 6188284, - 'generation': 1792086693754706, + 'object_name': 'Linux_x64/clang-android-runtime-library-llvmorg-24-init-22088-g7ba4f04e-2.tar.xz', + 'sha256sum': '9c475b960e85fc775208cb37fa419a015d4aed32a3ccb50f2fefd433259e8ac2', + 'size_bytes': 6204692, + 'generation': 1795570298808568, 'condition': 'checkout_android and non_git_source', }, { - 'object_name': 'Linux_x64/clang-linux-runtime-library-llvmorg-24-init-14453-ge063be79-1.tar.xz', - 'sha256sum': '38338f434311fcd12a070757c23830d6076529f4dcbefebc9d094804dc4eca63', - 'size_bytes': 3145380, - 'generation': 1792086698521278, + 'object_name': 'Linux_x64/clang-linux-runtime-library-llvmorg-24-init-22088-g7ba4f04e-2.tar.xz', + 'sha256sum': 'f2259d1723da32cb15b85278bd404dffb9144871432586e45b25f80e8983b837', + 'size_bytes': 3161016, + 'generation': 1795570303202888, 'condition': 'checkout_linux and not host_os == "linux"', }, { - 'object_name': 'Linux_x64/clang-llvmorg-24-init-14453-ge063be79-1.tar.xz', - 'sha256sum': '0b76afc1a29b0583f7723e966b9b65a22b15d8fdcd38e7c567ae32343c68944d', - 'size_bytes': 58394648, - 'generation': 1792086691304470, + 'object_name': 'Linux_x64/clang-llvmorg-24-init-22088-g7ba4f04e-2.tar.xz', + 'sha256sum': '572c7e605f8c85c47a657906e56476b257140cb66543c7ec30afdd24ba5d0592', + 'size_bytes': 59668136, + 'generation': 1795570296342061, 'condition': 'host_os == "linux" and non_git_source', }, { - 'object_name': 'Linux_x64/clang-tidy-llvmorg-24-init-14453-ge063be79-1.tar.xz', - 'sha256sum': 'cf2a7610086b45fb878f606709babd3cbd8e26ea97a087ea47929e4ee871b562', - 'size_bytes': 15213064, - 'generation': 1792086691338093, + 'object_name': 'Linux_x64/clang-tidy-llvmorg-24-init-22088-g7ba4f04e-2.tar.xz', + 'sha256sum': '494e9b091d6d28cc6c10eba876e5d988a28b2f0341fc93d251f97d77a29f979a', + 'size_bytes': 15399668, + 'generation': 1795570296279632, 'condition': 'host_os == "linux" and checkout_clang_tidy and non_git_source', }, { - 'object_name': 'Linux_x64/clangd-llvmorg-24-init-14453-ge063be79-1.tar.xz', - 'sha256sum': '5ef64ed6fdeab8dfd91f11db07c601ce5107fc9e61e9d7a18dcee97af42f03c6', - 'size_bytes': 15595776, - 'generation': 1792086691391942, + 'object_name': 'Linux_x64/clangd-llvmorg-24-init-22088-g7ba4f04e-2.tar.xz', + 'sha256sum': '46be8a77fd48ee64e8cac0b56f77d8c04a866b672b6179d1f183d7a061767952', + 'size_bytes': 15749740, + 'generation': 1795570296337026, 'condition': 'host_os == "linux" and checkout_clangd and non_git_source', }, { - 'object_name': 'Linux_x64/llvm-code-coverage-llvmorg-24-init-14453-ge063be79-1.tar.xz', - 'sha256sum': '756e08684179166571dd155471e0a9c4525223d30b45d776b3d75a4d53b820d3', - 'size_bytes': 2432768, - 'generation': 1792086691721951, + 'object_name': 'Linux_x64/llvm-code-coverage-llvmorg-24-init-22088-g7ba4f04e-2.tar.xz', + 'sha256sum': '3862e232dd53a8d6d04e77807997dea1e7c8766974a47950c937a33d706086ac', + 'size_bytes': 2451628, + 'generation': 1795570296570605, 'condition': 'host_os == "linux" and checkout_clang_coverage_tools and non_git_source', }, { - 'object_name': 'Linux_x64/llvmobjdump-llvmorg-24-init-14453-ge063be79-1.tar.xz', - 'sha256sum': '2282c8a4bdc6e12242989525039a36e7eeb4335b22d39d3b5d624c38083881c5', - 'size_bytes': 6011380, - 'generation': 1792086691439732, + 'object_name': 'Linux_x64/llvmobjdump-llvmorg-24-init-22088-g7ba4f04e-2.tar.xz', + 'sha256sum': '8b96f5a40ddf4bad9409d31ce92277f817043ce8540afce57f37f3cc5fa0386c', + 'size_bytes': 6057980, + 'generation': 1795570296427865, 'condition': '((checkout_linux or checkout_mac or checkout_ios or checkout_android) and host_os == "linux") and non_git_source', }, { - 'object_name': 'Mac/clang-llvmorg-24-init-14453-ge063be79-1.tar.xz', - 'sha256sum': 'ae29ec360eda6e80e96f8638d368ecdeea93d19c18c527c525dc0932bd5243a4', - 'size_bytes': 54834700, - 'generation': 1792086700293656, + 'object_name': 'Mac/clang-llvmorg-24-init-22088-g7ba4f04e-2.tar.xz', + 'sha256sum': '8143ec86e7a8186aaa791d0803acc3f6ec48de5b1032c586ca26220596e0bf7e', + 'size_bytes': 55622340, + 'generation': 1795570304841461, 'condition': 'host_os == "mac" and host_cpu == "x64"', }, { - 'object_name': 'Mac/clang-mac-runtime-library-llvmorg-24-init-14453-ge063be79-1.tar.xz', - 'sha256sum': 'c18444eef64cf27a8913ce73ffa8fd92e6f41306a02bbc82d805aa0c521863e0', - 'size_bytes': 997164, - 'generation': 1792086707123823, + 'object_name': 'Mac/clang-mac-runtime-library-llvmorg-24-init-22088-g7ba4f04e-2.tar.xz', + 'sha256sum': '5e156e2323d4e7ae045b1aad492a2841bf3290c7e6f6cda1ca1dd997e03631d9', + 'size_bytes': 1282632, + 'generation': 1795570311599234, 'condition': '(checkout_mac or checkout_ios) and not host_os == "mac" and non_git_source', }, { - 'object_name': 'Mac/clang-tidy-llvmorg-24-init-14453-ge063be79-1.tar.xz', - 'sha256sum': '3997f34e72dc28eb30af1b8af903ceb6b0f516db7821996297bf296793addc72', - 'size_bytes': 14437076, - 'generation': 1792086700400707, + 'object_name': 'Mac/clang-tidy-llvmorg-24-init-22088-g7ba4f04e-2.tar.xz', + 'sha256sum': '46b6ff4f23fbf52cebddf6f97f258c66370483feaa41600e5107bc5c603503a7', + 'size_bytes': 14541444, + 'generation': 1795570304829931, 'condition': 'host_os == "mac" and host_cpu == "x64" and checkout_clang_tidy', }, { - 'object_name': 'Mac/clangd-llvmorg-24-init-14453-ge063be79-1.tar.xz', - 'sha256sum': '0fc9c351ad3bc6c357cc53a57dad6f8ebf45ba9e38150012cb457812f2a1314f', - 'size_bytes': 15359244, - 'generation': 1792086700318835, + 'object_name': 'Mac/clangd-llvmorg-24-init-22088-g7ba4f04e-2.tar.xz', + 'sha256sum': '901be912b7d4edc0e962730ac50113d4ae0bbb9f7cd8550a6fe80df465032849', + 'size_bytes': 15630772, + 'generation': 1795570304813308, 'condition': 'host_os == "mac" and host_cpu == "x64" and checkout_clangd', }, { - 'object_name': 'Mac/llvm-code-coverage-llvmorg-24-init-14453-ge063be79-1.tar.xz', - 'sha256sum': 'b8b2f099cb029ff36cce33c9983984f547d7da0d9c34c1b427bb1080a31b8047', - 'size_bytes': 2307268, - 'generation': 1792086700464636, + 'object_name': 'Mac/llvm-code-coverage-llvmorg-24-init-22088-g7ba4f04e-2.tar.xz', + 'sha256sum': '51daf34442661f4c8e59990ee084657b4b6eb19d470f8477b3ccb6d1de0d4986', + 'size_bytes': 2324516, + 'generation': 1795570304958967, 'condition': 'host_os == "mac" and host_cpu == "x64" and checkout_clang_coverage_tools', }, { - 'object_name': 'Mac/llvmobjdump-llvmorg-24-init-14453-ge063be79-1.tar.xz', - 'sha256sum': 'eae7800773f3955fd1dcc334d8779b9a232ca6ebd3a79a55be028bd8797b1197', - 'size_bytes': 5586688, - 'generation': 1792086700364844, + 'object_name': 'Mac/llvmobjdump-llvmorg-24-init-22088-g7ba4f04e-2.tar.xz', + 'sha256sum': '2356202c1e848bc5828b2ad92e321bc047eedd43c3e3cbae2b2b4228e8642276', + 'size_bytes': 5627732, + 'generation': 1795570304868447, 'condition': 'host_os == "mac" and host_cpu == "x64"', }, { - 'object_name': 'Mac_arm64/clang-llvmorg-24-init-14453-ge063be79-1.tar.xz', - 'sha256sum': '0a8d887534b3153c7f6860265dc7e075d420174521c60ccd52c2c243949ef468', - 'size_bytes': 44917408, - 'generation': 1792086708845653, + 'object_name': 'Mac_arm64/clang-llvmorg-24-init-22088-g7ba4f04e-2.tar.xz', + 'sha256sum': 'd6b45fe77088ec639eab724044de3136ebd66114172fc6a99316404e3a2813fa', + 'size_bytes': 45679856, + 'generation': 1795570313160951, 'condition': 'host_os == "mac" and host_cpu == "arm64"', }, { - 'object_name': 'Mac_arm64/clang-tidy-llvmorg-24-init-14453-ge063be79-1.tar.xz', - 'sha256sum': '1aee3a0078bbe3b840125f521d3e6d985de61531ee6686a0bef80abc6e6d6a78', - 'size_bytes': 12291060, - 'generation': 1792086708806950, + 'object_name': 'Mac_arm64/clang-tidy-llvmorg-24-init-22088-g7ba4f04e-2.tar.xz', + 'sha256sum': '82088f04fa3d28b3e7ef9c670d2fbfb819c8e871ae472acf22b20d21e4ea89f5', + 'size_bytes': 12427476, + 'generation': 1795570313180770, 'condition': 'host_os == "mac" and host_cpu == "arm64" and checkout_clang_tidy', }, { - 'object_name': 'Mac_arm64/clangd-llvmorg-24-init-14453-ge063be79-1.tar.xz', - 'sha256sum': '799e034e1fdff7eb7d899329ab20bbeb96642234844c9e070797059bd6ce5ee9', - 'size_bytes': 12292508, - 'generation': 1792086709015693, + 'object_name': 'Mac_arm64/clangd-llvmorg-24-init-22088-g7ba4f04e-2.tar.xz', + 'sha256sum': 'a74a70404a093d4e57d96190e39d60d1491c2b55a7a8e893ce9f08b0a968ef67', + 'size_bytes': 12421400, + 'generation': 1795570313176417, 'condition': 'host_os == "mac" and host_cpu == "arm64" and checkout_clangd', }, { - 'object_name': 'Mac_arm64/llvm-code-coverage-llvmorg-24-init-14453-ge063be79-1.tar.xz', - 'sha256sum': 'a77bacfb3e6c08af7d51981d88fb4aa07e4fb797f37937071dd8657b7c2dea8e', - 'size_bytes': 1897140, - 'generation': 1792086709049271, + 'object_name': 'Mac_arm64/llvm-code-coverage-llvmorg-24-init-22088-g7ba4f04e-2.tar.xz', + 'sha256sum': '8be59d32483d306579218d4204da964d4d9374fa93f5d73a26f491b3807d04b7', + 'size_bytes': 1909220, + 'generation': 1795570313318955, 'condition': 'host_os == "mac" and host_cpu == "arm64" and checkout_clang_coverage_tools', }, { - 'object_name': 'Mac_arm64/llvmobjdump-llvmorg-24-init-14453-ge063be79-1.tar.xz', - 'sha256sum': '8d15119ffd7e9d52e86676bfdcfd8159506f0ba6c4b292ae4112cbf15e629d7d', - 'size_bytes': 5269524, - 'generation': 1792086709009144, + 'object_name': 'Mac_arm64/llvmobjdump-llvmorg-24-init-22088-g7ba4f04e-2.tar.xz', + 'sha256sum': '724566d7e4d4c26a205cb0acfa784f253eec22a71ee360b970bd97ca25533277', + 'size_bytes': 5310916, + 'generation': 1795570313233488, 'condition': 'host_os == "mac" and host_cpu == "arm64"', }, { - 'object_name': 'Win/clang-llvmorg-24-init-14453-ge063be79-1.tar.xz', - 'sha256sum': '08abce6e1d01c2fff9b25a09e36d9976296f27842196f96411b8220364481818', - 'size_bytes': 52783904, - 'generation': 1792086718487613, + 'object_name': 'Win/clang-llvmorg-24-init-22088-g7ba4f04e-2.tar.xz', + 'sha256sum': '160fb5eec6942c257f85015062a12e4685f061abe5af8e47bcbb1d280f036c47', + 'size_bytes': 53521076, + 'generation': 1795570321847777, 'condition': 'host_os == "win"', }, { - 'object_name': 'Win/clang-tidy-llvmorg-24-init-14453-ge063be79-1.tar.xz', - 'sha256sum': 'ee25e107e6da91254780b0e9b6fb34198dc03636330c5564a7786e6450916d45', - 'size_bytes': 15436080, - 'generation': 1792086718412245, + 'object_name': 'Win/clang-tidy-llvmorg-24-init-22088-g7ba4f04e-2.tar.xz', + 'sha256sum': 'a0c70bc1d917ecc4f975f75ef3296a21f51b09aa6935447116d929d208883021', + 'size_bytes': 15640204, + 'generation': 1795570321881942, 'condition': 'host_os == "win" and checkout_clang_tidy', }, { - 'object_name': 'Win/clang-win-runtime-library-llvmorg-24-init-14453-ge063be79-1.tar.xz', - 'sha256sum': 'a156f6fa1f149e45faa683f2b2d1cc010df1e29912b3cb0a0dd3e3d9186c513b', - 'size_bytes': 2707764, - 'generation': 1792086725161419, + 'object_name': 'Win/clang-win-runtime-library-llvmorg-24-init-22088-g7ba4f04e-2.tar.xz', + 'sha256sum': '9c3b4fa88296fcfef6d73144b8b96070272b92aaadc2cc36f7ac43456a174a15', + 'size_bytes': 2722764, + 'generation': 1795570328823736, 'condition': 'checkout_win and not host_os == "win"', }, { - 'object_name': 'Win/clangd-llvmorg-24-init-14453-ge063be79-1.tar.xz', - 'sha256sum': '0db39ead1a1f49137570fd5e99ab7520262c2e6444900b551862ae2cccdf6bb8', - 'size_bytes': 15910376, - 'generation': 1792086718402867, + 'object_name': 'Win/clangd-llvmorg-24-init-22088-g7ba4f04e-2.tar.xz', + 'sha256sum': '1d8f7b74f12e521114417c05f8483305bc1e880104fe60f672ffded10248b869', + 'size_bytes': 16104300, + 'generation': 1795570321914165, 'condition': 'host_os == "win" and checkout_clangd', }, { - 'object_name': 'Win/llvm-code-coverage-llvmorg-24-init-14453-ge063be79-1.tar.xz', - 'sha256sum': '3cfd8304148bd6bdd86a99f4e5f01ea2b4fbcbf4f35e29a2ca3cb235cb88c393', - 'size_bytes': 2604364, - 'generation': 1792086718581883, + 'object_name': 'Win/llvm-code-coverage-llvmorg-24-init-22088-g7ba4f04e-2.tar.xz', + 'sha256sum': '0a96cffbd7fefa6d6c50d4f4719e61f9bc96acc58b611ffd8c166783a995fd36', + 'size_bytes': 2623096, + 'generation': 1795570322088115, 'condition': 'host_os == "win" and checkout_clang_coverage_tools', }, { - 'object_name': 'Win/llvmobjdump-llvmorg-24-init-14453-ge063be79-1.tar.xz', - 'sha256sum': '3b58242027a9e86114d05444e9e70a9ed497a6a9e9c14d1b86c355e140503a53', - 'size_bytes': 6123208, - 'generation': 1792086718463583, + 'object_name': 'Win/llvmobjdump-llvmorg-24-init-22088-g7ba4f04e-2.tar.xz', + 'sha256sum': 'f39d5d31c6573cc907d151d4a4e6bc75bf61aed547930ded4cbf09897f33ecb9', + 'size_bytes': 6167812, + 'generation': 1795570321986134, 'condition': '(checkout_linux or checkout_mac or checkout_android) and host_os == "win"', }, ] @@ -668,31 +668,31 @@ deps = { 'bucket': 'chromium-browser-clang', 'objects': [ { - 'object_name': 'Linux_x64/rust-libclang-8a9dd7abdf013ec10cfeaaa3685feba18ef1c90c-6-llvmorg-24-init-14453-ge063be79.tar.xz', - 'sha256sum': '693fd176a27508efb6cbc06b7db9c64abfc19497664dbaf4a9f4d489b8b4239a', - 'size_bytes': 23021680, - 'generation': 1793195408791425, + 'object_name': 'Linux_x64/rust-libclang-277240238554297f93fa9ee3c7643dfa03ccbbb4-2-llvmorg-24-init-22088-g7ba4f04e.tar.xz', + 'sha256sum': '57c9f59097f7f237def35069e287012b45930e0b442e9840276397bca0e9e1aa', + 'size_bytes': 23140276, + 'generation': 1795540677107040, 'condition': 'host_os == "linux" and non_git_source', }, { - 'object_name': 'Mac/rust-libclang-8a9dd7abdf013ec10cfeaaa3685feba18ef1c90c-6-llvmorg-24-init-14453-ge063be79.tar.xz', - 'sha256sum': 'b08bf161b5acaba2fe39d9a8089f8134417bfaef33531b6e4e84365e7c828bfe', - 'size_bytes': 23159048, - 'generation': 1793195412269519, + 'object_name': 'Mac/rust-libclang-277240238554297f93fa9ee3c7643dfa03ccbbb4-2-llvmorg-24-init-22088-g7ba4f04e.tar.xz', + 'sha256sum': '015c1c87fb877ec0e6c5aafeaf5006c7db39e1f5a2c94d00ff11a1bce4329ef3', + 'size_bytes': 23295240, + 'generation': 1795540680254981, 'condition': 'host_os == "mac" and host_cpu == "x64"', }, { - 'object_name': 'Mac_arm64/rust-libclang-8a9dd7abdf013ec10cfeaaa3685feba18ef1c90c-6-llvmorg-24-init-14453-ge063be79.tar.xz', - 'sha256sum': 'aa01ed55d80721dc53acf6fb604113037ba5142f3668ce7f7a02427b787cfea5', - 'size_bytes': 20842496, - 'generation': 1793195415799242, + 'object_name': 'Mac_arm64/rust-libclang-277240238554297f93fa9ee3c7643dfa03ccbbb4-2-llvmorg-24-init-22088-g7ba4f04e.tar.xz', + 'sha256sum': '419463cf0583db39137fef5ba444494515191c8e45dd3ec85e87e3e1a7f051db', + 'size_bytes': 20940708, + 'generation': 1795540683406566, 'condition': 'host_os == "mac" and host_cpu == "arm64"', }, { - 'object_name': 'Win/rust-libclang-8a9dd7abdf013ec10cfeaaa3685feba18ef1c90c-6-llvmorg-24-init-14453-ge063be79.tar.xz', - 'sha256sum': '38438c49085b1770020713fc981bf63a6e7d6398d8c1d7f094ec509347d384e8', - 'size_bytes': 21764276, - 'generation': 1793195419458813, + 'object_name': 'Win/rust-libclang-277240238554297f93fa9ee3c7643dfa03ccbbb4-2-llvmorg-24-init-22088-g7ba4f04e.tar.xz', + 'sha256sum': 'f68d9d19d5926a36a67244549ba24c9d35ac3cd00bc199caa00367a651407c60', + 'size_bytes': 21857176, + 'generation': 1795540686608947, 'condition': 'host_os == "win"', }, ], @@ -731,31 +731,31 @@ deps = { 'bucket': 'chromium-browser-clang', 'objects': [ { - 'object_name': 'Linux_x64/rust-toolchain-8a9dd7abdf013ec10cfeaaa3685feba18ef1c90c-6-llvmorg-24-init-14453-ge063be79.tar.xz', - 'sha256sum': '4b4f64d5e82e845099b6ff63c61df311f8202183f1996ca247e20db6d9cda29c', - 'size_bytes': 287835700, - 'generation': 1793195406905214, + 'object_name': 'Linux_x64/rust-toolchain-277240238554297f93fa9ee3c7643dfa03ccbbb4-2-llvmorg-24-init-22088-g7ba4f04e.tar.xz', + 'sha256sum': '31332199efdde339e5d402f82257650a8706944bfc53c7d0b0c545f63e12f25d', + 'size_bytes': 285246336, + 'generation': 1795540675486514, 'condition': 'host_os == "linux" and non_git_source', }, { - 'object_name': 'Mac/rust-toolchain-8a9dd7abdf013ec10cfeaaa3685feba18ef1c90c-6-llvmorg-24-init-14453-ge063be79.tar.xz', - 'sha256sum': '7bd89fb1973d32d0231a1ffcd48851d629986763695c43ba6e8d8182361c538f', - 'size_bytes': 274877668, - 'generation': 1793195410604331, + 'object_name': 'Mac/rust-toolchain-277240238554297f93fa9ee3c7643dfa03ccbbb4-2-llvmorg-24-init-22088-g7ba4f04e.tar.xz', + 'sha256sum': '1355795cf0dceb022d5275d4b8124a3f69c4571937e75450557f8ee4cfd03da5', + 'size_bytes': 273343364, + 'generation': 1795540678702341, 'condition': 'host_os == "mac" and host_cpu == "x64"', }, { - 'object_name': 'Mac_arm64/rust-toolchain-8a9dd7abdf013ec10cfeaaa3685feba18ef1c90c-6-llvmorg-24-init-14453-ge063be79.tar.xz', - 'sha256sum': '7d1680ebf1d9ea133cd34d5f229c8491fbdbf9fe0da24171b686c8ecb8a4cad8', - 'size_bytes': 258546192, - 'generation': 1793195414074050, + 'object_name': 'Mac_arm64/rust-toolchain-277240238554297f93fa9ee3c7643dfa03ccbbb4-2-llvmorg-24-init-22088-g7ba4f04e.tar.xz', + 'sha256sum': '1295e09ef89b8f6ca09fac6a078437675ef81caf3548085e77f0ffd416380b38', + 'size_bytes': 257090228, + 'generation': 1795540681838583, 'condition': 'host_os == "mac" and host_cpu == "arm64"', }, { - 'object_name': 'Win/rust-toolchain-8a9dd7abdf013ec10cfeaaa3685feba18ef1c90c-6-llvmorg-24-init-14453-ge063be79.tar.xz', - 'sha256sum': '9e519f453f7fea971f531b7e4c5a8e686081b9647d7660deb0641efac306840f', - 'size_bytes': 426696244, - 'generation': 1793195417684260, + 'object_name': 'Win/rust-toolchain-277240238554297f93fa9ee3c7643dfa03ccbbb4-2-llvmorg-24-init-22088-g7ba4f04e.tar.xz', + 'sha256sum': '571031deaa091a0e30604b87d0a293465654eee33280e7114edb1bdf1ca1705e', + 'size_bytes': 425873176, + 'generation': 1795540685051205, 'condition': 'host_os == "win"', }, ], diff --git a/core/fpdfapi/edit/cpdf_pagecontentgenerator_unittest.cpp b/core/fpdfapi/edit/cpdf_pagecontentgenerator_unittest.cpp index 2c0fea8114..5b94d4abed 100644 --- a/core/fpdfapi/edit/cpdf_pagecontentgenerator_unittest.cpp +++ b/core/fpdfapi/edit/cpdf_pagecontentgenerator_unittest.cpp @@ -467,6 +467,41 @@ TEST_F(CPDFPageContentGeneratorTest, ProcessText) { EXPECT_EQ("Helvetica", font_desc->GetNameFor("FontName")); } +TEST_F(CPDFPageContentGeneratorTest, ProcessTextWithUnsupportedType3Font) { + auto doc = std::make_unique(); + doc->CreateNewDoc(); + + RetainPtr page_dict(doc->CreateNewPage(0)); + auto test_page = pdfium::MakeRetain(doc.get(), page_dict); + + auto font_dict = doc->NewIndirect(); + font_dict->SetNewFor("Type", "Font"); + font_dict->SetNewFor("Subtype", "Type3"); + RetainPtr font = + CPDF_DocPageData::FromDocument(doc.get())->GetFont(font_dict); + ASSERT_TRUE(font); + ASSERT_TRUE(font->IsType3Font()); + + auto text_obj = std::make_unique(); + text_obj->mutable_text_state().SetFont(std::move(font)); + text_obj->mutable_text_state().SetFontSize(12.0f); + text_obj->mutable_general_state().SetFillAlpha(0.5f); + text_obj->Transform(CFX_Matrix(1, 0, 0, 1, 100, 100)); + text_obj->SetText("Type3"); + + CPDF_PageContentGenerator generator(test_page.Get()); + fxcrt::ostringstream buf; + TestProcessText(&generator, &buf, text_obj.get()); + // EmbedPDF(faithful-content-rewrite): the fork writes text in a Type 3 + // font like any other, with the font object as its resource; upstream + // writes nothing for it. + EXPECT_EQ( + "q /FXE1 gs 1 0 0 1 100 100 cm BT 1 0 0 1 0 0 Tm /FXF1 12 Tf 0 Tr " + "<5479706533> Tj ET Q\n", + ByteString(buf)); + EXPECT_TRUE(test_page->GetResources()); +} + TEST_F(CPDFPageContentGeneratorTest, ProcessEmptyForm) { auto doc = std::make_unique(); doc->CreateNewDoc(); diff --git a/core/fxcodec/brotli/DEPS b/core/fxcodec/brotli/DEPS index 2e514af196..de76ac69bc 100644 --- a/core/fxcodec/brotli/DEPS +++ b/core/fxcodec/brotli/DEPS @@ -1,3 +1,3 @@ include_rules = [ - "+third_party/brotli/include/brotli", + "+third_party/brotli/src/c/include/brotli", ] diff --git a/core/fxcodec/brotli/brotli_decoder.cpp b/core/fxcodec/brotli/brotli_decoder.cpp index ae36324921..a1e801f401 100644 --- a/core/fxcodec/brotli/brotli_decoder.cpp +++ b/core/fxcodec/brotli/brotli_decoder.cpp @@ -14,7 +14,7 @@ #include "core/fxcrt/epdf_tls.h" #include "core/fxcrt/fx_extension.h" #include "core/fxcrt/numerics/safe_conversions.h" -#include "third_party/brotli/include/brotli/decode.h" +#include "third_party/brotli/src/c/include/brotli/decode.h" namespace { diff --git a/core/fxcodec/jbig2/jbig2_grd_proc.cpp b/core/fxcodec/jbig2/jbig2_grd_proc.cpp index f234e77274..099fa7332c 100644 --- a/core/fxcodec/jbig2/jbig2_grd_proc.cpp +++ b/core/fxcodec/jbig2/jbig2_grd_proc.cpp @@ -7,7 +7,6 @@ #include "core/fxcodec/jbig2/jbig2_grd_proc.h" #include -#include #include #include @@ -17,35 +16,77 @@ #include "core/fxcodec/jbig2/jbig2_image.h" #include "core/fxcrt/check_op.h" #include "core/fxcrt/pauseindicator_iface.h" -#include "core/fxcrt/zip.h" +#include "core/fxcrt/span.h" namespace { -// TODO(crbug.com/567627774): Name this constants better or merge some together. -constexpr std::array kOptConstant1 = { - {0x9b25, 0x0795, 0x00e5}}; -constexpr std::array kOptConstant2 = { - {0x0006, 0x0004, 0x0001}}; -constexpr std::array kOptConstant3 = { - {0xf800, 0x1e00, 0x0380}}; -constexpr std::array kOptConstant4 = { - {0x0000, 0x0001, 0x0003}}; -constexpr std::array kOptConstant5 = { - {0x07f0, 0x01f8, 0x007c}}; -constexpr std::array kOptConstant6 = { - {0x7bf7, 0x0efb, 0x01bd}}; -constexpr std::array kOptConstant7 = { - {0x0800, 0x0200, 0x0080}}; -constexpr std::array kOptConstant8 = { - {0x0010, 0x0008, 0x0004}}; -constexpr std::array kOptConstant9 = { - {0x000c, 0x0009, 0x0007}}; -constexpr std::array kOptConstant10 = { - {0x0007, 0x000f, 0x0007}}; -constexpr std::array kOptConstant11 = { - {0x001f, 0x001f, 0x000f}}; -constexpr std::array kOptConstant12 = { - {0x000f, 0x0007, 0x0003}}; +// The generic region templates (6.2.5.3), for the optimized decoders that +// handle the nominal AT pixel positions. +template +struct TemplateTraits; + +template <> +struct TemplateTraits<0> { + // The context in which SLTP is decoded (6.2.5.7). + static constexpr uint32_t kTpContext = 0x9b25; + static constexpr uint32_t kContextMask = 0x7bf7; + static constexpr int kRow1Shift = 0; + static constexpr uint32_t kRow1ContextMask = 0x07f0; + static constexpr uint32_t kRow1BitMask = 0x0010; + static constexpr bool kHasRow2 = true; + static constexpr int kRow2Shift = 6; + static constexpr uint32_t kRow2ContextMask = 0xf800; + static constexpr uint32_t kRow2BitMask = 0x0800; + // TODO(crbug.com/567627774): Why is the height only trimmed for template 0? + static constexpr bool kTrimHeight = true; + // Whether the progressive decoder checks for a pause only every 50 rows. + static constexpr bool kPauseEvery50Rows = false; +}; + +template <> +struct TemplateTraits<1> { + static constexpr uint32_t kTpContext = 0x0795; + static constexpr uint32_t kContextMask = 0x0efb; + static constexpr int kRow1Shift = 1; + static constexpr uint32_t kRow1ContextMask = 0x01f8; + static constexpr uint32_t kRow1BitMask = 0x0008; + static constexpr bool kHasRow2 = true; + static constexpr int kRow2Shift = 4; + static constexpr uint32_t kRow2ContextMask = 0x1e00; + static constexpr uint32_t kRow2BitMask = 0x0200; + static constexpr bool kTrimHeight = false; + static constexpr bool kPauseEvery50Rows = false; +}; + +template <> +struct TemplateTraits<2> { + static constexpr uint32_t kTpContext = 0x00e5; + static constexpr uint32_t kContextMask = 0x01bd; + static constexpr int kRow1Shift = 3; + static constexpr uint32_t kRow1ContextMask = 0x007c; + static constexpr uint32_t kRow1BitMask = 0x0004; + static constexpr bool kHasRow2 = true; + static constexpr int kRow2Shift = 1; + static constexpr uint32_t kRow2ContextMask = 0x0380; + static constexpr uint32_t kRow2BitMask = 0x0080; + static constexpr bool kTrimHeight = false; + static constexpr bool kPauseEvery50Rows = true; +}; + +template <> +struct TemplateTraits<3> { + static constexpr uint32_t kTpContext = 0x0195; + static constexpr uint32_t kContextMask = 0x01f7; + static constexpr int kRow1Shift = 1; + static constexpr uint32_t kRow1ContextMask = 0x03f0; + static constexpr uint32_t kRow1BitMask = 0x0010; + // Template 3 only looks one row up. kRow2Shift and kRow2ContextMask are + // only used under `if constexpr (kHasRow2)`. + static constexpr bool kHasRow2 = false; + static constexpr uint32_t kRow2BitMask = 0; + static constexpr bool kTrimHeight = false; + static constexpr bool kPauseEvery50Rows = false; +}; struct LineLayout { uint32_t full_bytes; @@ -53,6 +94,99 @@ struct LineLayout { uint32_t last_byte_bits; }; +// `prev1` and `prev2` are the two rows above `row`. +// Returns false if data runs out. +template +bool DecodeOpt3Row(CJBig2_ArithDecoder* decoder, + pdfium::span contexts, + uint32_t row, + pdfium::span prev2, + pdfium::span prev1, + pdfium::span line, + const LineLayout& layout) { + if (row < (Traits::kHasRow2 ? 2u : 1u)) { + const bool has_prev1 = row > 0; + uint32_t val_prev = has_prev1 ? prev1[0] : 0; + uint32_t context = + (val_prev >> Traits::kRow1Shift) & Traits::kRow1ContextMask; + for (uint32_t cc = 0; cc < layout.full_bytes; ++cc) { + if (has_prev1) { + val_prev = (val_prev << 8) | prev1[cc + 1]; + } + uint8_t byte = 0; + for (int32_t k = 7; k >= 0; --k) { + if (decoder->IsComplete()) { + return false; + } + const int bit = decoder->Decode(&contexts[context]); + byte |= bit << k; + context = + ((context & Traits::kContextMask) << 1) | bit | + ((val_prev >> (k + Traits::kRow1Shift)) & Traits::kRow1BitMask); + } + line[cc] = byte; + } + val_prev <<= 8; + uint8_t byte = 0; + for (uint32_t k = 0; k < layout.last_byte_bits; ++k) { + if (decoder->IsComplete()) { + return false; + } + const int bit = decoder->Decode(&contexts[context]); + byte |= bit << (7 - k); + context = + ((context & Traits::kContextMask) << 1) | bit | + ((val_prev >> (7 - k + Traits::kRow1Shift)) & Traits::kRow1BitMask); + } + line[layout.full_bytes] = byte; + return true; + } + + uint32_t val_prev2 = 0; + uint32_t context = 0; + if constexpr (Traits::kHasRow2) { + val_prev2 = prev2[0] << Traits::kRow2Shift; + context = val_prev2 & Traits::kRow2ContextMask; + } + uint32_t val_prev1 = prev1[0]; + context |= (val_prev1 >> Traits::kRow1Shift) & Traits::kRow1ContextMask; + for (uint32_t cc = 0; cc < layout.full_bytes; ++cc) { + if constexpr (Traits::kHasRow2) { + val_prev2 = (val_prev2 << 8) | (prev2[cc + 1] << Traits::kRow2Shift); + } + val_prev1 = (val_prev1 << 8) | prev1[cc + 1]; + uint8_t byte = 0; + for (int32_t k = 7; k >= 0; --k) { + if (decoder->IsComplete()) { + return false; + } + const int bit = decoder->Decode(&contexts[context]); + byte |= bit << k; + context = + ((context & Traits::kContextMask) << 1) | bit | + ((val_prev2 >> k) & Traits::kRow2BitMask) | + ((val_prev1 >> (k + Traits::kRow1Shift)) & Traits::kRow1BitMask); + } + line[cc] = byte; + } + val_prev2 <<= 8; + val_prev1 <<= 8; + uint8_t byte = 0; + for (uint32_t k = 0; k < layout.last_byte_bits; ++k) { + if (decoder->IsComplete()) { + return false; + } + const int bit = decoder->Decode(&contexts[context]); + byte |= bit << (7 - k); + context = + ((context & Traits::kContextMask) << 1) | bit | + ((val_prev2 >> (7 - k)) & Traits::kRow2BitMask) | + ((val_prev1 >> (7 - k + Traits::kRow1Shift)) & Traits::kRow1BitMask); + } + line[layout.full_bytes] = byte; + return true; +} + LineLayout GetLineLayout(uint32_t width) { CHECK_GT(width, 0u); // Note that this deliberately represents 8 bits as: @@ -94,384 +228,17 @@ std::unique_ptr CJBig2_GRDProc::DecodeArith( return std::make_unique(GBW, GBH); } - switch (GBTEMPLATE) { - case 0: - return UseTemplate0Opt3() - ? DecodeArithOpt3<0>(pArithDecoder, gbContexts) - : DecodeArithTemplateUnopt<0>(pArithDecoder, gbContexts); - case 1: - return UseTemplate1Opt3() - ? DecodeArithOpt3<1>(pArithDecoder, gbContexts) - : DecodeArithTemplateUnopt<1>(pArithDecoder, gbContexts); - case 2: - return UseTemplate23Opt3() - ? DecodeArithOpt3<2>(pArithDecoder, gbContexts) - : DecodeArithTemplateUnopt<2>(pArithDecoder, gbContexts); - default: - return UseTemplate23Opt3() - ? DecodeArithTemplate3Opt3(pArithDecoder, gbContexts) - : DecodeArithTemplate3Unopt(pArithDecoder, gbContexts); - } -} - -template -std::unique_ptr CJBig2_GRDProc::DecodeArithOpt3( - CJBig2_ArithDecoder* pArithDecoder, - pdfium::span gbContexts) { - auto GBREG = std::make_unique(GBW, GBH); - if (!GBREG->has_data()) { - return nullptr; - } - - int LTP = 0; - const LineLayout layout = GetLineLayout(GBW); - // TODO(crbug.com/567627774): Why is the height only trimmed when OPT is 0? - const uint32_t height = OPT == 0 ? GBH & 0x7fffffff : GBH; - pdfium::span row_write; - pdfium::span row_prev1; - pdfium::span row_prev2; - for (uint32_t h = 0; h < height; ++h) { - row_prev2 = row_prev1; - row_prev1 = row_write; - row_write = GBREG->GetLine(h); - if (TPGDON) { - if (pArithDecoder->IsComplete()) { - return nullptr; - } - - LTP = LTP ^ pArithDecoder->Decode(&gbContexts[kOptConstant1[OPT]]); - if (LTP) { - GBREG->CopyLine(row_write, row_prev1); - continue; - } - } - - if (h < 2) { - const bool is_second_line = h == 1; - uint32_t val_prev = 0; - if (is_second_line) { - val_prev = row_prev1[0]; - } - uint32_t CONTEXT = - ((val_prev >> kOptConstant4[OPT]) & kOptConstant5[OPT]); - for (uint32_t cc = 0; cc < layout.full_bytes; ++cc) { - if (is_second_line) { - val_prev = (val_prev << 8) | row_prev1[cc + 1]; - } - uint8_t cVal = 0; - for (int32_t k = 7; k >= 0; --k) { - if (pArithDecoder->IsComplete()) { - return nullptr; - } - - int bVal = pArithDecoder->Decode(&gbContexts[CONTEXT]); - cVal |= bVal << k; - CONTEXT = - (((CONTEXT & kOptConstant6[OPT]) << 1) | bVal | - ((val_prev >> (k + kOptConstant4[OPT])) & kOptConstant8[OPT])); - } - row_write[cc] = cVal; - } - val_prev <<= 8; - uint8_t cVal1 = 0; - for (uint32_t k = 0; k < layout.last_byte_bits; ++k) { - if (pArithDecoder->IsComplete()) { - return nullptr; - } - - int bVal = pArithDecoder->Decode(&gbContexts[CONTEXT]); - cVal1 |= bVal << (7 - k); - CONTEXT = (((CONTEXT & kOptConstant6[OPT]) << 1) | bVal | - (((val_prev >> (7 + kOptConstant4[OPT] - k))) & - kOptConstant8[OPT])); - } - row_write[layout.full_bytes] = cVal1; - continue; - } - - uint32_t val_prev2 = row_prev2[0] << kOptConstant2[OPT]; - uint32_t val_prev1 = row_prev1[0]; - uint32_t CONTEXT = (val_prev2 & kOptConstant3[OPT]) | - ((val_prev1 >> kOptConstant4[OPT]) & kOptConstant5[OPT]); - auto row_write_zip = row_write.first(layout.full_bytes); - auto row_prev1_zip = row_prev1.subspan<1u>(); - auto row_prev2_zip = row_prev2.subspan<1u>(); - for (auto [elem_write, elem_prev1, elem_prev2] : - fxcrt::Zip(row_write_zip, row_prev1_zip, row_prev2_zip)) { - val_prev2 = (val_prev2 << 8) | (elem_prev2 << kOptConstant2[OPT]); - val_prev1 = (val_prev1 << 8) | elem_prev1; - uint8_t cVal = 0; - for (int32_t k = 7; k >= 0; --k) { - if (pArithDecoder->IsComplete()) { - return nullptr; - } - - int bVal = pArithDecoder->Decode(&gbContexts[CONTEXT]); - cVal |= bVal << k; - CONTEXT = - (((CONTEXT & kOptConstant6[OPT]) << 1) | bVal | - ((val_prev2 >> k) & kOptConstant7[OPT]) | - ((val_prev1 >> (k + kOptConstant4[OPT])) & kOptConstant8[OPT])); - } - elem_write = cVal; - } - val_prev2 <<= 8; - val_prev1 <<= 8; - uint8_t cVal1 = 0; - for (uint32_t k = 0; k < layout.last_byte_bits; ++k) { - if (pArithDecoder->IsComplete()) { - return nullptr; - } - - int bVal = pArithDecoder->Decode(&gbContexts[CONTEXT]); - cVal1 |= bVal << (7 - k); - CONTEXT = - (((CONTEXT & kOptConstant6[OPT]) << 1) | bVal | - ((val_prev2 >> (7 - k)) & kOptConstant7[OPT]) | - ((val_prev1 >> (7 + kOptConstant4[OPT] - k)) & kOptConstant8[OPT])); - } - row_write[layout.full_bytes] = cVal1; - } - return GBREG; -} - -template -std::unique_ptr CJBig2_GRDProc::DecodeArithTemplateUnopt( - CJBig2_ArithDecoder* pArithDecoder, - pdfium::span gbContexts) { - auto GBREG = std::make_unique(GBW, GBH); - if (!GBREG->has_data()) { + std::unique_ptr image; + ProgressiveArithDecodeState state; + state.pImage = ℑ + state.pArithDecoder = pArithDecoder; + state.gbContexts = gbContexts; + const FXCODEC_STATUS status = StartDecodeArith(&state); + FinishDecode(); + if (status != FXCODEC_STATUS::kDecodeFinished) { return nullptr; } - - GBREG->Fill(false); - int LTP = 0; - const uint8_t MOD2 = UNOPT % 2; - const uint8_t DIV2 = UNOPT / 2; - const uint8_t SHIFT = 4 - UNOPT; - pdfium::span row_write; - pdfium::span row_prev1; - pdfium::span row_prev2; - for (uint32_t h = 0; h < GBH; h++) { - row_prev2 = row_prev1; - row_prev1 = row_write; - row_write = GBREG->GetLine(h); - if (TPGDON) { - if (pArithDecoder->IsComplete()) { - return nullptr; - } - - LTP = LTP ^ pArithDecoder->Decode(&gbContexts[kOptConstant1[UNOPT]]); - if (LTP) { - GBREG->CopyLine(row_write, row_prev1); - continue; - } - } - - pdfium::span row_skip; - if (USESKIP) { - row_skip = SKIP->GetLine(h); - } - pdfium::span row_gbat0 = GBREG->GetLine(h + GBAT[1]); - pdfium::span row_gbat1; - pdfium::span row_gbat2; - pdfium::span row_gbat3; - if (UNOPT == 0) { - row_gbat1 = GBREG->GetLine(h + GBAT[3]); - row_gbat2 = GBREG->GetLine(h + GBAT[5]); - row_gbat3 = GBREG->GetLine(h + GBAT[7]); - } - - uint32_t val_prev2 = GBREG->GetPixel(1 + MOD2, row_prev2); - val_prev2 |= GBREG->GetPixel(MOD2, row_prev2) << 1; - if (UNOPT == 1) { - val_prev2 |= GBREG->GetPixel(0, row_prev2) << 2; - } - uint32_t val_prev1 = GBREG->GetPixel(2 - DIV2, row_prev1); - val_prev1 |= GBREG->GetPixel(1 - DIV2, row_prev1) << 1; - if (UNOPT < 2) { - val_prev1 |= GBREG->GetPixel(0, row_prev1) << 2; - } - uint32_t val_current = 0; - for (uint32_t w = 0; w < GBW; w++) { - int bVal = 0; - if (!USESKIP || !SKIP->GetPixel(w, row_skip)) { - if (pArithDecoder->IsComplete()) { - return nullptr; - } - - uint32_t CONTEXT = val_current; - CONTEXT |= GBREG->GetPixel(w + GBAT[0], row_gbat0) << SHIFT; - CONTEXT |= val_prev1 << (SHIFT + 1); - CONTEXT |= val_prev2 << kOptConstant9[UNOPT]; - if (UNOPT == 0) { - CONTEXT |= GBREG->GetPixel(w + GBAT[2], row_gbat1) << 10; - CONTEXT |= GBREG->GetPixel(w + GBAT[4], row_gbat2) << 11; - CONTEXT |= GBREG->GetPixel(w + GBAT[6], row_gbat3) << 15; - } - bVal = pArithDecoder->Decode(&gbContexts[CONTEXT]); - if (bVal) { - GBREG->SetPixel(w, row_write, bVal); - } - } - val_prev2 = - ((val_prev2 << 1) | GBREG->GetPixel(w + 2 + MOD2, row_prev2)) & - kOptConstant10[UNOPT]; - val_prev1 = - ((val_prev1 << 1) | GBREG->GetPixel(w + 3 - DIV2, row_prev1)) & - kOptConstant11[UNOPT]; - val_current = ((val_current << 1) | bVal) & kOptConstant12[UNOPT]; - } - } - return GBREG; -} - -std::unique_ptr CJBig2_GRDProc::DecodeArithTemplate3Opt3( - CJBig2_ArithDecoder* pArithDecoder, - pdfium::span gbContexts) { - auto GBREG = std::make_unique(GBW, GBH); - if (!GBREG->has_data()) { - return nullptr; - } - - int LTP = 0; - const LineLayout layout = GetLineLayout(GBW); - pdfium::span row_write; - pdfium::span row_prev; - for (uint32_t h = 0; h < GBH; h++) { - row_prev = row_write; - row_write = GBREG->GetLine(h); - if (TPGDON) { - if (pArithDecoder->IsComplete()) { - return nullptr; - } - - LTP = LTP ^ pArithDecoder->Decode(&gbContexts[0x0195]); - if (LTP) { - GBREG->CopyLine(row_write, row_prev); - continue; - } - } - - if (h == 0) { - uint32_t CONTEXT = 0; - for (uint32_t cc = 0; cc < layout.full_bytes; cc++) { - uint8_t cVal = 0; - for (int32_t k = 7; k >= 0; k--) { - if (pArithDecoder->IsComplete()) { - return nullptr; - } - - int bVal = pArithDecoder->Decode(&gbContexts[CONTEXT]); - cVal |= bVal << k; - CONTEXT = ((CONTEXT & 0x01f7) << 1) | bVal; - } - row_write[cc] = cVal; - } - uint8_t cVal1 = 0; - for (uint32_t k = 0; k < layout.last_byte_bits; k++) { - if (pArithDecoder->IsComplete()) { - return nullptr; - } - - int bVal = pArithDecoder->Decode(&gbContexts[CONTEXT]); - cVal1 |= bVal << (7 - k); - CONTEXT = ((CONTEXT & 0x01f7) << 1) | bVal; - } - row_write[layout.full_bytes] = cVal1; - continue; - } - - uint32_t val_prev = row_prev[0]; - uint32_t CONTEXT = (val_prev >> 1) & 0x03f0; - for (uint32_t cc = 0; cc < layout.full_bytes; cc++) { - val_prev = (val_prev << 8) | row_prev[cc + 1]; - uint8_t cVal = 0; - for (int32_t k = 7; k >= 0; k--) { - if (pArithDecoder->IsComplete()) { - return nullptr; - } - - int bVal = pArithDecoder->Decode(&gbContexts[CONTEXT]); - cVal |= bVal << k; - CONTEXT = - ((CONTEXT & 0x01f7) << 1) | bVal | ((val_prev >> (k + 1)) & 0x0010); - } - row_write[cc] = cVal; - } - val_prev <<= 8; - uint8_t cVal1 = 0; - for (uint32_t k = 0; k < layout.last_byte_bits; k++) { - if (pArithDecoder->IsComplete()) { - return nullptr; - } - - int bVal = pArithDecoder->Decode(&gbContexts[CONTEXT]); - cVal1 |= bVal << (7 - k); - CONTEXT = - ((CONTEXT & 0x01f7) << 1) | bVal | ((val_prev >> (8 - k)) & 0x0010); - } - row_write[layout.full_bytes] = cVal1; - } - return GBREG; -} - -std::unique_ptr CJBig2_GRDProc::DecodeArithTemplate3Unopt( - CJBig2_ArithDecoder* pArithDecoder, - pdfium::span gbContexts) { - auto GBREG = std::make_unique(GBW, GBH); - if (!GBREG->has_data()) { - return nullptr; - } - - GBREG->Fill(false); - int LTP = 0; - pdfium::span row_write; - pdfium::span row_prev; - for (uint32_t h = 0; h < GBH; h++) { - row_prev = row_write; - row_write = GBREG->GetLine(h); - if (TPGDON) { - if (pArithDecoder->IsComplete()) { - return nullptr; - } - - LTP = LTP ^ pArithDecoder->Decode(&gbContexts[0x0195]); - if (LTP) { - GBREG->CopyLine(row_write, row_prev); - continue; - } - } - - pdfium::span row_skip; - if (USESKIP) { - row_skip = SKIP->GetLine(h); - } - pdfium::span row_gbat = GBREG->GetLine(h + GBAT[1]); - - uint32_t val_prev = GBREG->GetPixel(1, row_prev); - val_prev |= GBREG->GetPixel(0, row_prev) << 1; - uint32_t val_current = 0; - for (uint32_t w = 0; w < GBW; w++) { - int bVal = 0; - if (!USESKIP || !SKIP->GetPixel(w, row_skip)) { - uint32_t CONTEXT = val_current; - CONTEXT |= GBREG->GetPixel(w + GBAT[0], row_gbat) << 4; - CONTEXT |= val_prev << 5; - if (pArithDecoder->IsComplete()) { - return nullptr; - } - - bVal = pArithDecoder->Decode(&gbContexts[CONTEXT]); - } - if (bVal) { - GBREG->SetPixel(w, row_write, bVal); - } - val_prev = ((val_prev << 1) | GBREG->GetPixel(w + 2, row_prev)) & 0x1f; - val_current = ((val_current << 1) | bVal) & 0x0f; - } - } - return GBREG; + return image; } FXCODEC_STATUS CJBig2_GRDProc::StartDecodeArith( @@ -504,33 +271,33 @@ FXCODEC_STATUS CJBig2_GRDProc::ProgressiveDecodeArith( ProgressiveArithDecodeState* pState) { int iline = loop_index_; - using DecodeFunction = std::function; + using DecodeFunction = + FXCODEC_STATUS (CJBig2_GRDProc::*)(ProgressiveArithDecodeState*); DecodeFunction func; switch (GBTEMPLATE) { case 0: func = UseTemplate0Opt3() - ? &CJBig2_GRDProc::ProgressiveDecodeArithTemplate0Opt3 + ? &CJBig2_GRDProc::ProgressiveDecodeArithOpt3<0> : &CJBig2_GRDProc::ProgressiveDecodeArithTemplate0Unopt; break; case 1: func = UseTemplate1Opt3() - ? &CJBig2_GRDProc::ProgressiveDecodeArithTemplate1Opt3 + ? &CJBig2_GRDProc::ProgressiveDecodeArithOpt3<1> : &CJBig2_GRDProc::ProgressiveDecodeArithTemplate1Unopt; break; case 2: func = UseTemplate23Opt3() - ? &CJBig2_GRDProc::ProgressiveDecodeArithTemplate2Opt3 + ? &CJBig2_GRDProc::ProgressiveDecodeArithOpt3<2> : &CJBig2_GRDProc::ProgressiveDecodeArithTemplate2Unopt; break; default: func = UseTemplate23Opt3() - ? &CJBig2_GRDProc::ProgressiveDecodeArithTemplate3Opt3 + ? &CJBig2_GRDProc::ProgressiveDecodeArithOpt3<3> : &CJBig2_GRDProc::ProgressiveDecodeArithTemplate3Unopt; break; } CJBig2_Image* pImage = pState->pImage->get(); - progressive_status_ = func(*this, pState); + progressive_status_ = (this->*func)(pState); replace_rect_.left = 0; replace_rect_.right = pImage->width(); replace_rect_.top = iline; @@ -588,31 +355,38 @@ void CJBig2_GRDProc::FinishDecode() { line_ = {}; } -FXCODEC_STATUS CJBig2_GRDProc::ProgressiveDecodeArithTemplate0Opt3( +template +FXCODEC_STATUS CJBig2_GRDProc::ProgressiveDecodeArithOpt3( ProgressiveArithDecodeState* pState) { + using Traits = TemplateTraits; CJBig2_Image* pImage = pState->pImage->get(); if (line_.empty()) { line_ = pImage->span(); } - static constexpr TemplateOpt3Params kParams = {.tp_ctx = 0x9b25, - .context_mask = 0x7bf7, - .val1_shift = 0, - .val1_context_mask = 0x07f0, - .val1_bit_mask = 0x0010, - .val2_shift = 6, - .val2_context_mask = 0xf800, - .val2_bit_mask = 0x0800}; const LineLayout layout = GetLineLayout(GBW); - const uint32_t height = GBH & 0x7fffffff; + const uint32_t height = Traits::kTrimHeight ? GBH & 0x7fffffff : GBH; for (; loop_index_ < height; loop_index_++) { - if (!ProgressiveDecodeArithTemplateOpt3Helper( - pState, kParams, layout.full_bytes, layout.last_byte_bits)) { + if (TPGDON) { + if (pState->pArithDecoder->IsComplete()) { + return FXCODEC_STATUS::kError; + } + + ltp_ = ltp_ ^ pState->pArithDecoder->Decode( + &pState->gbContexts[Traits::kTpContext]); + } + if (ltp_) { + CopyPrevLine(pImage); + } else if (!DecodeOpt3Row(pState->pArithDecoder, pState->gbContexts, + loop_index_, line_prev2_, line_prev1_, + line_, layout)) { return FXCODEC_STATUS::kError; } AdvanceLine(pImage); - if (pState->pPause && pState->pPause->NeedToPauseNow()) { + if (pState->pPause && + (!Traits::kPauseEvery50Rows || loop_index_ % 50 == 0) && + pState->pPause->NeedToPauseNow()) { loop_index_++; progressive_status_ = FXCODEC_STATUS::kDecodeToBeContinued; return FXCODEC_STATUS::kDecodeToBeContinued; @@ -699,39 +473,6 @@ FXCODEC_STATUS CJBig2_GRDProc::ProgressiveDecodeArithTemplate0Unopt( return FXCODEC_STATUS::kDecodeFinished; } -FXCODEC_STATUS CJBig2_GRDProc::ProgressiveDecodeArithTemplate1Opt3( - ProgressiveArithDecodeState* pState) { - CJBig2_Image* pImage = pState->pImage->get(); - if (line_.empty()) { - line_ = pImage->span(); - } - - static constexpr TemplateOpt3Params kParams = {.tp_ctx = 0x0795, - .context_mask = 0x0efb, - .val1_shift = 1, - .val1_context_mask = 0x01f8, - .val1_bit_mask = 0x0008, - .val2_shift = 4, - .val2_context_mask = 0x1e00, - .val2_bit_mask = 0x0200}; - const LineLayout layout = GetLineLayout(GBW); - for (; loop_index_ < GBH; loop_index_++) { - if (!ProgressiveDecodeArithTemplateOpt3Helper( - pState, kParams, layout.full_bytes, layout.last_byte_bits)) { - return FXCODEC_STATUS::kError; - } - - AdvanceLine(pImage); - if (pState->pPause && pState->pPause->NeedToPauseNow()) { - loop_index_++; - progressive_status_ = FXCODEC_STATUS::kDecodeToBeContinued; - return FXCODEC_STATUS::kDecodeToBeContinued; - } - } - progressive_status_ = FXCODEC_STATUS::kDecodeFinished; - return FXCODEC_STATUS::kDecodeFinished; -} - FXCODEC_STATUS CJBig2_GRDProc::ProgressiveDecodeArithTemplate1Unopt( ProgressiveArithDecodeState* pState) { CJBig2_Image* pImage = pState->pImage->get(); @@ -801,139 +542,6 @@ FXCODEC_STATUS CJBig2_GRDProc::ProgressiveDecodeArithTemplate1Unopt( return FXCODEC_STATUS::kDecodeFinished; } -FXCODEC_STATUS CJBig2_GRDProc::ProgressiveDecodeArithTemplate2Opt3( - ProgressiveArithDecodeState* pState) { - CJBig2_Image* pImage = pState->pImage->get(); - if (line_.empty()) { - line_ = pImage->span(); - } - - static constexpr TemplateOpt3Params kParams = {.tp_ctx = 0x00e5, - .context_mask = 0x01bd, - .val1_shift = 3, - .val1_context_mask = 0x007c, - .val1_bit_mask = 0x0004, - .val2_shift = 1, - .val2_context_mask = 0x0380, - .val2_bit_mask = 0x0080}; - const LineLayout layout = GetLineLayout(GBW); - for (; loop_index_ < GBH; loop_index_++) { - if (!ProgressiveDecodeArithTemplateOpt3Helper( - pState, kParams, layout.full_bytes, layout.last_byte_bits)) { - return FXCODEC_STATUS::kError; - } - - AdvanceLine(pImage); - if (pState->pPause && loop_index_ % 50 == 0 && - pState->pPause->NeedToPauseNow()) { - loop_index_++; - progressive_status_ = FXCODEC_STATUS::kDecodeToBeContinued; - return FXCODEC_STATUS::kDecodeToBeContinued; - } - } - progressive_status_ = FXCODEC_STATUS::kDecodeFinished; - return FXCODEC_STATUS::kDecodeFinished; -} - -bool CJBig2_GRDProc::ProgressiveDecodeArithTemplateOpt3Helper( - ProgressiveArithDecodeState* state, - const TemplateOpt3Params& params, - uint32_t nLineBytes, - uint32_t nBitsLeft) { - if (TPGDON) { - if (state->pArithDecoder->IsComplete()) { - return false; - } - - ltp_ = - ltp_ ^ state->pArithDecoder->Decode(&state->gbContexts[params.tp_ctx]); - } - if (ltp_) { - CopyPrevLine(state->pImage->get()); - return true; - } - - if (loop_index_ <= 1) { - const bool is_second_line = loop_index_ == 1; - uint32_t val_prev = is_second_line ? line_prev1_[0] : 0; - uint32_t CONTEXT = - (val_prev >> params.val1_shift) & params.val1_context_mask; - for (uint32_t cc = 0; cc < nLineBytes; cc++) { - if (is_second_line) { - val_prev = (val_prev << 8) | line_prev1_[cc + 1]; - } - uint8_t cVal = 0; - for (int32_t k = 7; k >= 0; k--) { - if (state->pArithDecoder->IsComplete()) { - return false; - } - - int bVal = state->pArithDecoder->Decode(&state->gbContexts[CONTEXT]); - cVal |= bVal << k; - CONTEXT = - ((CONTEXT & params.context_mask) << 1) | bVal | - ((val_prev >> (k + params.val1_shift)) & params.val1_bit_mask); - } - line_[cc] = cVal; - } - val_prev <<= 8; - uint8_t cVal1 = 0; - for (uint32_t k = 0; k < nBitsLeft; k++) { - if (state->pArithDecoder->IsComplete()) { - return false; - } - - int bVal = state->pArithDecoder->Decode(&state->gbContexts[CONTEXT]); - cVal1 |= bVal << (7 - k); - CONTEXT = - ((CONTEXT & params.context_mask) << 1) | bVal | - ((val_prev >> (7 - k + params.val1_shift)) & params.val1_bit_mask); - } - line_[nLineBytes] = cVal1; - return true; - } - - uint32_t val_prev2 = line_prev2_[0] << params.val2_shift; - uint32_t val_prev1 = line_prev1_[0]; - uint32_t CONTEXT = - (val_prev2 & params.val2_context_mask) | - ((val_prev1 >> params.val1_shift) & params.val1_context_mask); - for (uint32_t cc = 0; cc < nLineBytes; cc++) { - val_prev2 = (val_prev2 << 8) | (line_prev2_[cc + 1] << params.val2_shift); - val_prev1 = (val_prev1 << 8) | line_prev1_[cc + 1]; - uint8_t cVal = 0; - for (int32_t k = 7; k >= 0; k--) { - if (state->pArithDecoder->IsComplete()) { - return false; - } - - int bVal = state->pArithDecoder->Decode(&state->gbContexts[CONTEXT]); - cVal |= bVal << k; - CONTEXT = ((CONTEXT & params.context_mask) << 1) | bVal | - ((val_prev2 >> k) & params.val2_bit_mask) | - ((val_prev1 >> (k + params.val1_shift)) & params.val1_bit_mask); - } - line_[cc] = cVal; - } - val_prev2 <<= 8; - val_prev1 <<= 8; - uint8_t cVal1 = 0; - for (uint32_t k = 0; k < nBitsLeft; k++) { - if (state->pArithDecoder->IsComplete()) { - return false; - } - - int bVal = state->pArithDecoder->Decode(&state->gbContexts[CONTEXT]); - cVal1 |= bVal << (7 - k); - CONTEXT = - ((CONTEXT & params.context_mask) << 1) | bVal | - ((val_prev2 >> (7 - k)) & params.val2_bit_mask) | - ((val_prev1 >> (7 - k + params.val1_shift)) & params.val1_bit_mask); - } - line_[nLineBytes] = cVal1; - return true; -} - FXCODEC_STATUS CJBig2_GRDProc::ProgressiveDecodeArithTemplate2Unopt( ProgressiveArithDecodeState* pState) { CJBig2_Image* pImage = pState->pImage->get(); @@ -1001,97 +609,6 @@ FXCODEC_STATUS CJBig2_GRDProc::ProgressiveDecodeArithTemplate2Unopt( return FXCODEC_STATUS::kDecodeFinished; } -FXCODEC_STATUS CJBig2_GRDProc::ProgressiveDecodeArithTemplate3Opt3( - ProgressiveArithDecodeState* pState) { - CJBig2_Image* pImage = pState->pImage->get(); - pdfium::span gbContexts = pState->gbContexts; - CJBig2_ArithDecoder* pArithDecoder = pState->pArithDecoder; - if (line_.empty()) { - line_ = pImage->span(); - } - - const LineLayout layout = GetLineLayout(GBW); - for (; loop_index_ < GBH; loop_index_++) { - if (TPGDON) { - if (pArithDecoder->IsComplete()) { - return FXCODEC_STATUS::kError; - } - - ltp_ = ltp_ ^ pArithDecoder->Decode(&gbContexts[0x0195]); - } - if (ltp_) { - CopyPrevLine(pImage); - } else { - if (loop_index_ == 0) { - uint32_t CONTEXT = 0; - for (uint32_t cc = 0; cc < layout.full_bytes; cc++) { - uint8_t cVal = 0; - for (int32_t k = 7; k >= 0; k--) { - if (pArithDecoder->IsComplete()) { - return FXCODEC_STATUS::kError; - } - - int bVal = pArithDecoder->Decode(&gbContexts[CONTEXT]); - cVal |= bVal << k; - CONTEXT = ((CONTEXT & 0x01f7) << 1) | bVal; - } - line_[cc] = cVal; - } - uint8_t cVal1 = 0; - for (uint32_t k = 0; k < layout.last_byte_bits; k++) { - if (pArithDecoder->IsComplete()) { - return FXCODEC_STATUS::kError; - } - - int bVal = pArithDecoder->Decode(&gbContexts[CONTEXT]); - cVal1 |= bVal << (7 - k); - CONTEXT = ((CONTEXT & 0x01f7) << 1) | bVal; - } - line_[layout.full_bytes] = cVal1; - } else { - uint32_t val_prev = line_prev1_[0]; - uint32_t CONTEXT = (val_prev >> 1) & 0x03f0; - for (uint32_t cc = 0; cc < layout.full_bytes; cc++) { - val_prev = (val_prev << 8) | line_prev1_[cc + 1]; - uint8_t cVal = 0; - for (int32_t k = 7; k >= 0; k--) { - if (pArithDecoder->IsComplete()) { - return FXCODEC_STATUS::kError; - } - - int bVal = pArithDecoder->Decode(&gbContexts[CONTEXT]); - cVal |= bVal << k; - CONTEXT = ((CONTEXT & 0x01f7) << 1) | bVal | - ((val_prev >> (k + 1)) & 0x0010); - } - line_[cc] = cVal; - } - val_prev <<= 8; - uint8_t cVal1 = 0; - for (uint32_t k = 0; k < layout.last_byte_bits; k++) { - if (pArithDecoder->IsComplete()) { - return FXCODEC_STATUS::kError; - } - - int bVal = pArithDecoder->Decode(&gbContexts[CONTEXT]); - cVal1 |= bVal << (7 - k); - CONTEXT = ((CONTEXT & 0x01f7) << 1) | bVal | - ((val_prev >> (8 - k)) & 0x0010); - } - line_[layout.full_bytes] = cVal1; - } - } - AdvanceLine(pImage); - if (pState->pPause && pState->pPause->NeedToPauseNow()) { - loop_index_++; - progressive_status_ = FXCODEC_STATUS::kDecodeToBeContinued; - return FXCODEC_STATUS::kDecodeToBeContinued; - } - } - progressive_status_ = FXCODEC_STATUS::kDecodeFinished; - return FXCODEC_STATUS::kDecodeFinished; -} - FXCODEC_STATUS CJBig2_GRDProc::ProgressiveDecodeArithTemplate3Unopt( ProgressiveArithDecodeState* pState) { CJBig2_Image* pImage = pState->pImage->get(); diff --git a/core/fxcodec/jbig2/jbig2_grd_proc.h b/core/fxcodec/jbig2/jbig2_grd_proc.h index 48be463a56..0105e3e572 100644 --- a/core/fxcodec/jbig2/jbig2_grd_proc.h +++ b/core/fxcodec/jbig2/jbig2_grd_proc.h @@ -62,63 +62,28 @@ class CJBig2_GRDProc { std::array GBAT; private: - struct TemplateOpt3Params { - uint32_t tp_ctx; - uint32_t context_mask; - int val1_shift; - uint32_t val1_context_mask; - uint32_t val1_bit_mask; - int val2_shift; - uint32_t val2_context_mask; - uint32_t val2_bit_mask; - }; - bool UseTemplate0Opt3() const; bool UseTemplate1Opt3() const; bool UseTemplate23Opt3() const; FXCODEC_STATUS ProgressiveDecodeArith(ProgressiveArithDecodeState* pState); - FXCODEC_STATUS ProgressiveDecodeArithTemplate0Opt3( - ProgressiveArithDecodeState* pState); FXCODEC_STATUS ProgressiveDecodeArithTemplate0Unopt( ProgressiveArithDecodeState* pState); - FXCODEC_STATUS ProgressiveDecodeArithTemplate1Opt3( - ProgressiveArithDecodeState* pState); FXCODEC_STATUS ProgressiveDecodeArithTemplate1Unopt( ProgressiveArithDecodeState* pState); - FXCODEC_STATUS ProgressiveDecodeArithTemplate2Opt3( - ProgressiveArithDecodeState* pState); FXCODEC_STATUS ProgressiveDecodeArithTemplate2Unopt( ProgressiveArithDecodeState* pState); - FXCODEC_STATUS ProgressiveDecodeArithTemplate3Opt3( - ProgressiveArithDecodeState* pState); FXCODEC_STATUS ProgressiveDecodeArithTemplate3Unopt( ProgressiveArithDecodeState* pState); - bool ProgressiveDecodeArithTemplateOpt3Helper( - ProgressiveArithDecodeState* state, - const TemplateOpt3Params& params, - uint32_t nLineBytes, - uint32_t nBitsLeft); + // The decoders for the nominal AT pixel positions of each template. + template + FXCODEC_STATUS ProgressiveDecodeArithOpt3( + ProgressiveArithDecodeState* pState); void AdvanceLine(const CJBig2_Image* image); void CopyPrevLine(CJBig2_Image* image); - template - std::unique_ptr DecodeArithOpt3( - CJBig2_ArithDecoder* pArithDecoder, - pdfium::span gbContexts); - template - std::unique_ptr DecodeArithTemplateUnopt( - CJBig2_ArithDecoder* pArithDecoder, - pdfium::span gbContexts); - std::unique_ptr DecodeArithTemplate3Opt3( - CJBig2_ArithDecoder* pArithDecoder, - pdfium::span gbContexts); - std::unique_ptr DecodeArithTemplate3Unopt( - CJBig2_ArithDecoder* pArithDecoder, - pdfium::span gbContexts); - uint32_t loop_index_ = 0; pdfium::raw_span line_prev2_; pdfium::raw_span line_prev1_; diff --git a/core/fxcodec/jpeg/jpegmodule_unittest.cpp b/core/fxcodec/jpeg/jpegmodule_unittest.cpp index ba60c087ff..198c391143 100644 --- a/core/fxcodec/jpeg/jpegmodule_unittest.cpp +++ b/core/fxcodec/jpeg/jpegmodule_unittest.cpp @@ -163,6 +163,27 @@ TEST(JpegModuleTest, RewindCorruptedDataFails) { // Rewind should fail cleanly. EXPECT_TRUE(decoder->GetScanline(0).empty()); } + +TEST(JpegModuleTest, RewindFailureIsSticky) { + std::vector jpeg_data = LoadMonaLisa(); + ASSERT_FALSE(jpeg_data.empty()); + + std::unique_ptr decoder = + JpegModule::CreateDecoder(jpeg_data, 120, 120, 3, true, 1, false); + ASSERT_TRUE(decoder); + EXPECT_FALSE(decoder->GetScanline(0).empty()); + EXPECT_FALSE(decoder->GetScanline(1).empty()); + + // Save and corrupt the header bytes so Rewind() fails. + std::vector saved_header(jpeg_data.begin(), jpeg_data.begin() + 10); + std::ranges::fill(pdfium::span(jpeg_data).first<10>(), 0); + EXPECT_TRUE(decoder->GetScanline(0).empty()); + + // Restoring the header must not cause subsequent scanlines to retry Rewind(). + std::ranges::copy(saved_header, jpeg_data.begin()); + EXPECT_TRUE(decoder->GetScanline(0).empty()); + EXPECT_TRUE(decoder->GetScanline(2).empty()); +} #endif // !defined(PDF_ENABLE_RUST_JPEG) TEST(JpegModuleTest, CreateDecoderDownscaled) { diff --git a/core/fxcodec/jpeg/libjpeg_scanline_decoder.cpp b/core/fxcodec/jpeg/libjpeg_scanline_decoder.cpp index f89240cf7c..f7860d71f8 100644 --- a/core/fxcodec/jpeg/libjpeg_scanline_decoder.cpp +++ b/core/fxcodec/jpeg/libjpeg_scanline_decoder.cpp @@ -235,6 +235,10 @@ bool LibjpegScanlineDecoder::CreateImpl(pdfium::span src_span, } bool LibjpegScanlineDecoder::Rewind() { + if (failed_) { + return false; + } + if (started_ || !decompress_created_) { const int expected_orig_width = orig_width_; const int expected_orig_height = orig_height_; @@ -249,6 +253,7 @@ bool LibjpegScanlineDecoder::Rewind() { decompress_created_ = false; } if (!InitDecode(/*bAcceptKnownBadHeader=*/false)) { + failed_ = true; return false; } if (orig_width_ != expected_orig_width || @@ -261,6 +266,7 @@ bool LibjpegScanlineDecoder::Rewind() { jpeg_common_destroy_decompress(&common_); decompress_created_ = false; started_ = false; + failed_ = true; return false; } } @@ -273,6 +279,7 @@ bool LibjpegScanlineDecoder::Rewind() { jpeg_common_destroy_decompress(&common_); decompress_created_ = false; started_ = false; + failed_ = true; return false; } @@ -285,6 +292,7 @@ bool LibjpegScanlineDecoder::Rewind() { jpeg_common_destroy_decompress(&common_); decompress_created_ = false; started_ = false; + failed_ = true; return false; } @@ -293,6 +301,9 @@ bool LibjpegScanlineDecoder::Rewind() { } pdfium::span LibjpegScanlineDecoder::GetNextLine() { + if (!started_ || !decompress_created_) { + return pdfium::span(); + } uint8_t* row_array[] = {scanline_buf_.data()}; int nlines = jpeg_common_read_scanlines(&common_, row_array, 1u); if (nlines <= 0) { diff --git a/core/fxcodec/jpeg/libjpeg_scanline_decoder.h b/core/fxcodec/jpeg/libjpeg_scanline_decoder.h index 47702aa9af..2c7b76a952 100644 --- a/core/fxcodec/jpeg/libjpeg_scanline_decoder.h +++ b/core/fxcodec/jpeg/libjpeg_scanline_decoder.h @@ -71,6 +71,7 @@ class LibjpegScanlineDecoder final : public ScanlineDecoder { DataVector scanline_buf_; bool decompress_created_ = false; bool started_ = false; + bool failed_ = false; bool jpeg_transform_ = false; bool prefer_bgr_output_ = false; uint32_t scale_denom_ = 1; diff --git a/core/fxcodec/scanlinedecoder.cpp b/core/fxcodec/scanlinedecoder.cpp index 640e3c9e72..df76ee75cf 100644 --- a/core/fxcodec/scanlinedecoder.cpp +++ b/core/fxcodec/scanlinedecoder.cpp @@ -36,6 +36,8 @@ pdfium::span ScanlineDecoder::GetScanline(int line) { if (next_line_ < 0 || next_line_ > line) { if (!Rewind()) { + next_line_ = -1; + last_scanline_ = pdfium::span(); return pdfium::span(); } next_line_ = 0; @@ -56,6 +58,8 @@ bool ScanlineDecoder::SkipToScanline(int line, PauseIndicatorIface* pPause) { if (next_line_ < 0 || next_line_ > line) { if (!Rewind()) { + next_line_ = -1; + last_scanline_ = pdfium::span(); return false; } next_line_ = 0; diff --git a/core/fxge/cfx_face.cpp b/core/fxge/cfx_face.cpp index fcf6160db0..0003f266ae 100644 --- a/core/fxge/cfx_face.cpp +++ b/core/fxge/cfx_face.cpp @@ -240,14 +240,20 @@ std::unique_ptr ConvertOutline(const skrifa::Outline& outline) { } #if defined(PDF_ENABLE_FREETYPE) -void CloseContours(pdfium::span points, +bool CloseContours(pdfium::span points, std::vector& contours) { - if (!points.empty()) { - uint16_t last = static_cast(points.size() - 1); - if (contours.empty() || contours.back() != last) { - contours.push_back(last); - } + if (points.empty()) { + return true; + } + pdfium::CheckedNumeric last = points.size() - 1; + if (!last.IsValid()) { + return false; } + uint16_t last_val = last.ValueOrDie(); + if (contours.empty() || contours.back() != last_val) { + contours.push_back(last_val); + } + return true; } struct ConvertedFTOutline { @@ -277,7 +283,9 @@ ConvertedFTOutline ConvertToFTOutline(const skrifa::Outline& outline, if (point_idx >= outline.points.size()) { break; } - CloseContours(result.points, result.contours); + if (!CloseContours(result.points, result.contours)) { + return {}; + } result.points.push_back( ToFTVector(outline.points[point_idx++], scaled_matrix)); result.tags.push_back(FT_CURVE_TAG_ON); @@ -323,11 +331,15 @@ ConvertedFTOutline ConvertToFTOutline(const skrifa::Outline& outline, break; } case skrifa::PathVerb::Close: - CloseContours(result.points, result.contours); + if (!CloseContours(result.points, result.contours)) { + return {}; + } break; } } - CloseContours(result.points, result.contours); + if (!CloseContours(result.points, result.contours)) { + return {}; + } return result; } #endif // defined(PDF_ENABLE_FREETYPE) @@ -631,6 +643,14 @@ wchar_t CFX_Face::UnicodeFromAdobeName(const char* name) { NOTREACHED(); } +#if defined(PDF_ENABLE_FONTATIONS) && defined(PDF_ENABLE_FREETYPE) +// static +bool CFX_Face::CloseContoursForTesting(pdfium::span points, + std::vector& contours) { + return CloseContours(points, contours); +} +#endif // defined(PDF_ENABLE_FONTATIONS) && defined(PDF_ENABLE_FREETYPE) + // static ByteString CFX_Face::AdobeNameFromUnicode(wchar_t unicode) { #if defined(PDF_ENABLE_FONTATIONS) @@ -1056,9 +1076,16 @@ std::unique_ptr CFX_Face::RenderGlyph( return nullptr; } + pdfium::CheckedNumeric n_points = converted.points.size(); + pdfium::CheckedNumeric n_contours = + converted.contours.size(); + if (!n_points.IsValid() || !n_contours.IsValid()) { + return nullptr; + } + FT_Outline ft_outline; - ft_outline.n_points = static_cast(converted.points.size()); - ft_outline.n_contours = static_cast(converted.contours.size()); + ft_outline.n_points = n_points.ValueOrDie(); + ft_outline.n_contours = n_contours.ValueOrDie(); ft_outline.points = converted.points.data(); ft_outline.tags = converted.tags.data(); ft_outline.contours = converted.contours.data(); diff --git a/core/fxge/cfx_face.h b/core/fxge/cfx_face.h index d82bc50d95..8ad19907e4 100644 --- a/core/fxge/cfx_face.h +++ b/core/fxge/cfx_face.h @@ -83,6 +83,10 @@ class CFX_Face final : public Retainable, public Observable { uint32_t face_index); static wchar_t UnicodeFromAdobeName(const char* name); static ByteString AdobeNameFromUnicode(wchar_t unicode); +#if defined(PDF_ENABLE_FONTATIONS) && defined(PDF_ENABLE_FREETYPE) + static bool CloseContoursForTesting(pdfium::span points, + std::vector& contours); +#endif // defined(PDF_ENABLE_FONTATIONS) && defined(PDF_ENABLE_FREETYPE) bool HasGlyphNames() const; bool IsTtOt() const; diff --git a/core/fxge/cfx_face_unittest.cpp b/core/fxge/cfx_face_unittest.cpp index 692da83385..a17f9300a1 100644 --- a/core/fxge/cfx_face_unittest.cpp +++ b/core/fxge/cfx_face_unittest.cpp @@ -5,6 +5,7 @@ #include "core/fxge/cfx_face.h" #include +#include #include "core/fxcrt/cfx_read_only_span_stream.h" #include "core/fxge/cfx_gemodule.h" @@ -74,4 +75,19 @@ TEST(CFXFaceTest, BuiltInGenericFontScaling) { unscaled_bitmap->GetBitmap()->GetWidth()); #endif // defined(PDF_ENABLE_FREETYPE) } + +#if defined(PDF_ENABLE_FREETYPE) +TEST(CFXFaceTest, CloseContoursPointLimit) { + std::vector contours; + std::vector points(65536); + EXPECT_TRUE(CFX_Face::CloseContoursForTesting(points, contours)); + ASSERT_EQ(contours.size(), 1u); + EXPECT_EQ(contours[0], 65535u); + + contours.clear(); + points.resize(65537); + EXPECT_FALSE(CFX_Face::CloseContoursForTesting(points, contours)); + EXPECT_TRUE(contours.empty()); +} +#endif // defined(PDF_ENABLE_FREETYPE) #endif // defined(PDF_ENABLE_FONTATIONS) diff --git a/docs/embedpdf/syncs/2026-12-03-2f366eae34.md b/docs/embedpdf/syncs/2026-12-03-2f366eae34.md new file mode 100644 index 0000000000..db1eb7c22a --- /dev/null +++ b/docs/embedpdf/syncs/2026-12-03-2f366eae34.md @@ -0,0 +1,129 @@ +# Sync 2026-12-03: upstream 31e80351b..2f366eae3 (15 commits) + +## Summary + +Upstream from 2026-11-29 to 2026-12-02, merged into `6160587ad`. + +A toolchain roll (clang, `build/`), zlib 1.4, a Brotli layout change, glyph outline limits, a JPEG +rewind fix, a JBIG2 decoder rework, and a content generator fix our rewrite doesn't need. One +conflict, resolved to ours. The `build/` roll made our darwin library export libc++abi; a new hunk +in `mac/build.patch` hides it again. + +## Likely security fixes + +- `ffa8f64999` 2026-12-01 [fuzztest migration] Add FuzzTest version of pdf_jpx_fuzzer + +A fuzzer, not built by us. Security-relevant and in our builds, though not flagged: `2a42d28da2` +(glyph outlines past FreeType's 16-bit point and contour limits were truncated; now refused), +`3d0fa6231b` (a JPEG decoder whose rewind failed retried on every row), and zlib's zero-initialized +inflate window (`c8f2471eaa`). + +## Conflicts (1 file, 1 block) + +A block with an `EPDF_TLS` count is never resolved by taking upstream's side without putting +`EPDF_TLS` back (rule thread-confined-globals). + +| File | Blocks | Rules in the blocks | EPDF_TLS | Upstream commits | Resolution | +| :-- | --: | :-- | --: | :-- | :-- | +| `core/fpdfapi/edit/cpdf_pagecontentgenerator.cpp` | 1 | faithful-content-rewrite | | `728d97050d` Check font type before writing operators in ProcessText() | Ours; the file is unchanged from fork main. Upstream moved the font-type check ahead of `ProcessGraphics()` so an unsupported font writes nothing. Our `ProcessText()` resolves the font through `RealizeFont()` by object number and writes Type 3 text too; a font it can't name still ends cleanly (`ET`, then the closing `Q`). Git had also placed upstream's moved lines inside our `RealizeFont()`, outside the markers; taking ours drops them. | + +## Write audit (0 lines) + +None. + +## Upstream changes outside the conflicts + +- **Toolchain (`60207438db`, `ff89dc832c`):** clang llvmorg-24-init-14453 to 22088, `build/` (260 + commits), tools/rust, nasm. `build/` commit `c0761ba1a` stops hiding libc++abi's symbols on Apple, + because Chromium now links the system libc++abi there; the other half of that change, in + `buildtools`, hasn't rolled into PDFium, which still links its own libc++abi into our library. Our + darwin dylib then exported 219 more symbols (`__cxa_*`, `typeinfo`, `__cxxabiv1` vtables, all + unversioned) and kept code it used to strip (`__cxa_demangle`): +234 KB. `mac/build.patch` now + defines `_LIBCXXABI_DISABLE_VISIBILITY_ANNOTATIONS` on Apple again; with it the exports are S20's + plus our own new `EPDFForm_HasFieldValuesList`, and the library is 18 KB larger than a Nov 26 + build. Linux, Windows and wasm32 aren't Apple and are unchanged. Drop the hunk when PDFium's + buildtools links the system libc++abi on Apple. +- **zlib 1.4 (`c8f2471eaa`):** zlib and minizip move to 1.4, and inflate zero-initializes its + window. No test that checks exact bytes changed. +- **Brotli (`f1f5b66c6a`):** the headers move to `third_party/brotli/src/`. Our `EPDF_TLS` on + `g_brotli_enabled` stays; release builds keep Brotli off. +- **Glyph outlines (`2a42d28da2`):** `CFX_Face::RenderGlyph()` refuses outlines past 65,535 points + or contours instead of truncating the counts. Merged into our `cfx_face.cpp` without conflict. +- **JPEG (`3d0fa6231b`):** a failed `Rewind()` marks the decoder failed and resets the line + counters. +- **JBIG2 (`4a550bd23f`, `2f366eae34`):** the generic region decoders share one row loop, and + symbols decode through the progressive decoder; no intended behaviour change. The rest of the + series (`026136ff9d`, `c74b422056`) lands next sync. +- **Content generator (`094c22f840`, `728d97050d`):** a test and fix for text in a Type 3 font. See + Conflicts and Tests. +- **`testing/tools/BUILD.gn` (`884eab85f9`):** the data files Chromium's bots package are listed by + name. Our `run_layer_mode.py` isn't listed; our CI runs it from the checkout. +- Not in our builds: V8 and FXJS (`ff89dc832c`, `5a24338b9b`, `f1292c055a`), fuzzers (`ffa8f64999`), + Catapult (`8ac9c24682`). + +## Upstream appearance generator + +None. + +## Globals + +No new globals by the heuristic. `check-globals.py` on the darwin-arm64 release build: ok (263 +shared writable, 26 thread-local, as in S20). + +## Build and patches + +- `DEPS` changed in 5 commits: Catapult, zlib, V8, Brotli, and the toolchain roll (`build/`, clang, + tools/rust, nasm). Synced with `gclient sync --no-history --shallow`. +- `mac/build.patch` gains a hunk in `build/config/c++/BUILD.gn` (above); its toolchain hunk moved by + 23 lines. Every target's patches dry-run against clean sources, and darwin-arm64 and wasm32 build. + +## API diff + +None from upstream. The darwin-arm64 exports match the public headers; see Toolchain for the +libc++abi symbols the patch keeps out. + +## Tests + +- [x] fork unit + embedder tests (darwin-arm64): 1418 unit tests pass, upstream's new ones included + after the change below. Embedder: 12 failing: exactly S20's list, every one "Pixels do not match" + against a Mac PNG golden. Linux runs in the PR's CI. + The 12, as the baseline for the next sync: + - `EPDFMeasureEmbedderTest.CaptionAppearanceGolden` + - `FPDFEditEmbedderTest.SetTextRenderMode` + - `FPDFProgressiveRenderEmbedderTest.RenderAnnotWithPause` + - `FPDFProgressiveRenderEmbedderTest.RenderFormsWithPause` + - `FPDFProgressiveRenderEmbedderTest.RenderHighlightWithColorScheme` + - `FPDFProgressiveRenderEmbedderTest.RenderHighlightWithColorSchemeAndConvertFillToStroke` + - `FPDFProgressiveRenderEmbedderTest.RenderStampWithColorScheme` + - `FPDFProgressiveRenderEmbedderTest.RenderTextWithColorScheme` + - `FPDFProgressiveRenderEmbedderTest.RenderWithPause` + - `FPDFProgressiveRenderEmbedderTest.RenderWithoutPause` + - `FPDFViewEmbedderTest.RenderBug664284WithNoNativeText` + - `FPDFViewEmbedderTest.RenderHelloWorldWithFlags` +- [x] upstream's drawing tests (`run_drawing_tests.py`, not part of our CI): as in S20, 4 of 7 pass, + 3 XFA ones don't run, and `hello_world`, `bug_455199` and `bug_547706` differ by the built-in + standard-font faces. +- [x] layer mode: exit 0; 211 layer-only failures, all expected; 183 crashes, as in S20; 609 + writers, all already recorded by the fork's PRs: this sync adds none and changes no count. (A Mac + recording drops the Linux-only `TransFormWithClipAndSaveWithLocale`; its line stays.) +- [x] tag check (`--base 2f366eae34`): 1019 blocks, 0 untagged. +- [x] C API check: ok, 605 functions in 24 headers. +- [x] globals check: ok. +- [x] wasm build: builds locally. +- [ ] ThreadSanitizer soak: in the PR's CI. +- [ ] engine tests and engine-conformance with the local runtime: not run for this sync. +- changed expectations, each with its reason: + - `CPDFPageContentGeneratorTest.ProcessTextWithUnsupportedType3Font` (`094c22f840`, `728d97050d`): + the fork writes text in a Type 3 font like any other (rule faithful-content-rewrite), so the + test expects the whole text object, `q /FXE1 gs 1 0 0 1 100 100 cm BT 1 0 0 1 0 0 Tm /FXF1 12 Tf + 0 Tr <5479706533> Tj ET Q`, and the font in the page's resources. Upstream expects nothing + written and no resources. + +## Ledger changes proposed + +None. + +## Proposed, not done + +- From S19, still open: run upstream's drawing tests in our CI, with `pdfium_test` taking the + standard fonts from the system as the embedder tests do. diff --git a/fxjs/cfxjs_engine.cpp b/fxjs/cfxjs_engine.cpp index 0aad165ddc..7fa7d49fc7 100644 --- a/fxjs/cfxjs_engine.cpp +++ b/fxjs/cfxjs_engine.cpp @@ -187,7 +187,7 @@ class CFXJS_ObjDefinition { fxv8::ThrowExceptionHelper(isolate, "illegal constructor"); return; } - if (info.DataV2().As()->Value() != FXJSOBJTYPE_DYNAMIC) { + if (info.Data().As()->Value() != FXJSOBJTYPE_DYNAMIC) { fxv8::ThrowExceptionHelper(isolate, "not a dynamic object"); return; } diff --git a/fxjs/xfa/cfxjse_class.cpp b/fxjs/xfa/cfxjse_class.cpp index fc84c7165a..9bf535e9f0 100644 --- a/fxjs/xfa/cfxjse_class.cpp +++ b/fxjs/xfa/cfxjse_class.cpp @@ -46,7 +46,7 @@ FXJSE_CLASS_DESCRIPTOR* AsClassDescriptor(void* ptr) { void V8FunctionCallback_Wrapper( const v8::FunctionCallbackInfo& info) { const FXJSE_FUNCTION_DESCRIPTOR* function_info = - AsFunctionDescriptor(info.DataV2().As()->Value( + AsFunctionDescriptor(info.Data().As()->Value( v8::kExternalPointerTypeTagDefault)); if (!function_info) { return; @@ -69,7 +69,7 @@ void V8ConstructorCallback_Wrapper( } const FXJSE_CLASS_DESCRIPTOR* pClassDescriptor = - AsClassDescriptor(info.DataV2().As()->Value( + AsClassDescriptor(info.Data().As()->Value( v8::kExternalPointerTypeTagDefault)); if (!pClassDescriptor) { return; @@ -84,7 +84,7 @@ void V8ConstructorCallback_Wrapper( void Context_GlobalObjToString( const v8::FunctionCallbackInfo& info) { const FXJSE_CLASS_DESCRIPTOR* pClassDescriptor = - AsClassDescriptor(info.DataV2().As()->Value( + AsClassDescriptor(info.Data().As()->Value( v8::kExternalPointerTypeTagDefault)); if (!pClassDescriptor) { return; @@ -106,7 +106,7 @@ void Context_GlobalObjToString( void DynPropGetterAdapter_MethodCallback( const v8::FunctionCallbackInfo& info) { v8::Local hCallBackInfo = - info.DataV2().As().As(); + info.Data().As().As(); if (hCallBackInfo->InternalFieldCount() != 2) { return; } @@ -218,7 +218,7 @@ v8::Intercepted NamedPropertyQueryCallback( v8::Local property, const v8::PropertyCallbackInfo& info) { const FXJSE_CLASS_DESCRIPTOR* pClass = - AsClassDescriptor(info.DataV2().As()->Value( + AsClassDescriptor(info.Data().As()->Value( v8::kExternalPointerTypeTagDefault)); if (!pClass) { return v8::Intercepted::kNo; @@ -242,7 +242,7 @@ v8::Intercepted NamedPropertyGetterCallback( v8::Local property, const v8::PropertyCallbackInfo& info) { const FXJSE_CLASS_DESCRIPTOR* pClass = - AsClassDescriptor(info.DataV2().As()->Value( + AsClassDescriptor(info.Data().As()->Value( v8::kExternalPointerTypeTagDefault)); if (!pClass) { return v8::Intercepted::kNo; @@ -263,7 +263,7 @@ v8::Intercepted NamedPropertySetterCallback( v8::Local value, const v8::PropertyCallbackInfo& info) { const FXJSE_CLASS_DESCRIPTOR* pClass = - AsClassDescriptor(info.DataV2().As()->Value( + AsClassDescriptor(info.Data().As()->Value( v8::kExternalPointerTypeTagDefault)); if (!pClass) { return v8::Intercepted::kNo; diff --git a/fxjs/xfa/cfxjse_engine.h b/fxjs/xfa/cfxjse_engine.h index f1d176e62b..edee54b44e 100644 --- a/fxjs/xfa/cfxjse_engine.h +++ b/fxjs/xfa/cfxjse_engine.h @@ -7,6 +7,7 @@ #ifndef FXJS_XFA_CFXJSE_ENGINE_H_ #define FXJS_XFA_CFXJSE_ENGINE_H_ +#include #include #include #include @@ -219,9 +220,11 @@ class CFXJSE_Engine final : public CFX_IsolateWrapper { CXFA_Script::Type script_type_ = CXFA_Script::Type::Unknown; // |map_object_to_value_| is what ensures the v8 object bound to a // CJX_Object remains valid for the lifetime of the engine. - std::map, v8::Global> + std::map, v8::Global, std::less<>> map_object_to_object_; - std::map, std::unique_ptr> + std::map, + std::unique_ptr, + std::less<>> map_variable_to_context_; cppgc::Persistent target_; UnownedPtr event_param_; diff --git a/patches/embedpdf-runtime/mac/build.patch b/patches/embedpdf-runtime/mac/build.patch index 22f3986ea8..7d53ca54a7 100644 --- a/patches/embedpdf-runtime/mac/build.patch +++ b/patches/embedpdf-runtime/mac/build.patch @@ -1,8 +1,26 @@ +diff --git a/config/c++/BUILD.gn b/config/c++/BUILD.gn +index bcb4df5c0..e78f26cc5 100644 +--- a/config/c++/BUILD.gn ++++ b/config/c++/BUILD.gn +@@ -26,7 +26,12 @@ config("runtime_library") { + if (!libcxx_is_shared) { + # Don't leak any symbols on a static build. + defines += [ "_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS" ] +- if (!export_libcxxabi_from_executables && !is_win && !is_apple) { ++ # EmbedPDF: keep libc++abi hidden on Apple too. Chromium stopped hiding ++ # it there (build c0761ba1a) because it links the system libc++abi ++ # instead, but PDFium's buildtools still links the in-tree copy into our ++ # shared library, which would then export every __cxa_* and typeinfo ++ # symbol. ++ if (!export_libcxxabi_from_executables && !is_win) { + defines += [ "_LIBCXXABI_DISABLE_VISIBILITY_ANNOTATIONS" ] + } + } diff --git a/toolchain/apple/toolchain.gni b/toolchain/apple/toolchain.gni -index d9135a160..8fc71b201 100644 +index c80a644d1..890208285 100644 --- a/toolchain/apple/toolchain.gni +++ b/toolchain/apple/toolchain.gni -@@ -632,6 +632,16 @@ template("single_apple_toolchain") { +@@ -655,6 +655,16 @@ template("single_apple_toolchain") { nm = "${prefix}llvm-nm" otool = "${prefix}llvm-otool" diff --git a/testing/fuzzers/BUILD.gn b/testing/fuzzers/BUILD.gn index d0a85bf87b..a2d318b821 100644 --- a/testing/fuzzers/BUILD.gn +++ b/testing/fuzzers/BUILD.gn @@ -2,6 +2,7 @@ # Use of this source code is governed by a BSD-style license that can be # found in the LICENSE file. +import("//testing/test.gni") import("../../pdfium.gni") config("fuzzer_config") { @@ -587,6 +588,30 @@ pdfium_fuzzer("pdf_jpx_fuzzer") { deps = [ ":pdf_jpx_fuzzer_common" ] } +# FuzzTest version of pdf_jpx_fuzzer. FuzzTest is only available in Chromium +# checkouts, and the seed corpus lives in //pdf/pdfium/fuzzers/corpora/pdf_jpx. +if (build_with_chromium) { + test("pdf_jpx_fuzztest") { + sources = [ "pdf_jpx_fuzztest.cc" ] + fuzztests = [ "PdfJpxFuzzTest.DecodeJpx" ] + + # Not using ":fuzzer_config", as FUZZ_TEST() registration requires a global + # constructor, which "pdfium_strict_config" disallows. + configs += [ + "../..:pdfium_core_config", + "../..:pdfium_noshorten_config", + "//build/config/compiler:wexit_time_destructors", + ] + deps = [ + ":fuzzer_init", + ":pdf_jpx_fuzzer_common", + "../:path_service", + "//third_party/fuzztest:fuzztest_gtest_main", + ] + data = [ "//pdf/pdfium/fuzzers/corpora/pdf_jpx/" ] + } +} + pdfium_fuzzer("pdf_psengine_fuzzer") { sources = [ "pdf_psengine_fuzzer.cc" ] deps = [ "../../core/fpdfapi/page" ] diff --git a/testing/fuzzers/DEPS b/testing/fuzzers/DEPS index fe9eaf63e1..db4a6e6223 100644 --- a/testing/fuzzers/DEPS +++ b/testing/fuzzers/DEPS @@ -2,3 +2,10 @@ include_rules = [ '+fxbarcode', '+xfa', ] + +specific_include_rules = { + # FuzzTest-based fuzzers (only built in Chromium checkouts). + r'.*_fuzztest\.cc': [ + '+third_party/fuzztest/src/fuzztest/fuzztest.h', + ], +} diff --git a/testing/fuzzers/pdf_jpx_fuzztest.cc b/testing/fuzzers/pdf_jpx_fuzztest.cc new file mode 100644 index 0000000000..63876a9de1 --- /dev/null +++ b/testing/fuzzers/pdf_jpx_fuzztest.cc @@ -0,0 +1,66 @@ +// Copyright 2026 The PDFium Authors +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include +#include +#include +#include +#include + +#include "core/fxcodec/jpx/cjpx_decoder.h" +#include "core/fxcrt/check.h" +#include "core/fxcrt/span.h" +#include "testing/fuzzers/pdf_jpx_fuzzer_common.h" +#include "testing/utils/path_service.h" +#include "third_party/fuzztest/src/fuzztest/fuzztest.h" + +namespace { + +using JpxSeed = std::tuple>; + +// Relative to the source root. +constexpr char kCorpusDir[] = "pdf/pdfium/fuzzers/corpora/pdf_jpx"; + +// The seed corpus consists of plain JPEG 2000 files, so pair each file with +// the kNone color space option and default values for the other parameters. +std::vector JpxSeeds() { + const std::string source_dir = PathService::GetSourceDir(); + CHECK(!source_dir.empty()); + const std::string corpus_dir = source_dir + "/" + kCorpusDir; + + std::vector seeds; + for (const auto& [contents] : fuzztest::ReadFilesFromDirectory(corpus_dir)) { + std::vector data(contents.begin(), contents.end()); + seeds.emplace_back(CJPX_Decoder::ColorSpaceOption::kNone, + /*resolution_levels_to_skip=*/0, + /*strict_mode=*/false, std::move(data)); + } + // JPX seed corpus not found. + CHECK(!seeds.empty()); + return seeds; +} + +void DecodeJpx(CJPX_Decoder::ColorSpaceOption color_space_option, + uint8_t resolution_levels_to_skip, + bool strict_mode, + pdfium::span data) { + DecodeJpxForFuzzing(data, color_space_option, + resolution_levels_to_skip, strict_mode); +} + +} // namespace + +FUZZ_TEST(PdfJpxFuzzTest, DecodeJpx).WithDomains( + fuzztest::ElementOf({ + CJPX_Decoder::ColorSpaceOption::kNone, + CJPX_Decoder::ColorSpaceOption::kNormal, + CJPX_Decoder::ColorSpaceOption::kIndexed, + }), + fuzztest::Arbitrary(), + fuzztest::Arbitrary(), + fuzztest::Arbitrary>()) + .WithSeeds(JpxSeeds); diff --git a/testing/tools/BUILD.gn b/testing/tools/BUILD.gn index 6b27cc56ea..49410dd841 100644 --- a/testing/tools/BUILD.gn +++ b/testing/tools/BUILD.gn @@ -67,7 +67,46 @@ if (pdf_is_standalone) { # Unbuilt runtime dependencies. data = [ - ".", + "BUILD.gn", + "PRESUBMIT.py", + "__init__.py", + "adb_push_tests.sh", + "api_check.py", + "common.py", + "coverage/coverage_report.py", + "encode_pdf_filter.py", + "find_performance_steps.py", + "find_surprise_passes.py", + "fixup_pdf_template.py", + "generate_cas_paths.py", + "githelper.py", + "golden_fetch.sh", + "libclang_check.py", + "libclang_check_test.py", + "libcxx_check.py", + "make_expected.sh", + "pdfium_root.py", + "pdftoin_shrdlu.py", + "pngdiffer.py", + "renumber.py", + "run_corpus_tests.py", + "run_drawing_tests.py", + "run_javascript_tests.py", + "run_pixel_tests.py", + "safetynet_compare.py", + "safetynet_conclusions.py", + "safetynet_image.py", + "safetynet_job.py", + "safetynet_measure.py", + "skia_gold/__init__.py", + "skia_gold/pdfium_skia_gold_properties.py", + "skia_gold/pdfium_skia_gold_session.py", + "skia_gold/pdfium_skia_gold_session_manager.py", + "skia_gold/skia_gold.py", + "strip_jp2_comments.py", + "suppressor.py", + "test_runner.py", + "text_diff.py", "../SUPPRESSIONS", "../corpus/", "../../build/skia_gold_common/", diff --git a/third_party/cpu_features/BUILD.gn b/third_party/cpu_features/BUILD.gn index f6fcc3d2be..f89af5ae31 100644 --- a/third_party/cpu_features/BUILD.gn +++ b/third_party/cpu_features/BUILD.gn @@ -3,7 +3,14 @@ # found in the LICENSE file. config("cpu_features_config") { - cflags = [ "-Wno-unused-function" ] + cflags = [ + "-Wno-unused-function", + + # `CpuFeatures_StringView_HasWord()` ends with `return false;` after a + # `for (;;)` loop, which triggers `-Wunreachable-code-return` in C23 mode. + # Remove once https://github.com/google/cpu_features/pull/479 rolls in. + "-Wno-unreachable-code-return", + ] defines = [ "STACK_LINE_READER_BUFFER_SIZE=1024", "HAVE_STRONG_GETAUXVAL",