16088 Commits

Author SHA1 Message Date
Lei Zhang
b9ebffc36e Fix typo in {Byte,Wide}StringView.TrimmedRight tests
In ByteStringView.TrimmedRight, there exists a variable that should be
used on the next line, but is not due to a typo. Put the variable to
use. Do the same for the WideStringView version of the test.

Change-Id: If47e56271003d8cfb3e381c967e5a1a97fb3c166
Reviewed-on: https://pdfium-review.googlesource.com/c/pdfium/+/118073
Commit-Queue: Lei Zhang <thestig@chromium.org>
Reviewed-by: Tom Sepez <tsepez@chromium.org>
Reviewed-by: Thomas Sepez <tsepez@google.com>
2024-04-02 21:32:14 +00:00
Tom Sepez
567dff87b6 Avoid unsafe indexing in EncodeURL()
-- use std::array<> where useful.
-- use pdfium::contains() to avoid indexing otherwise.

Change-Id: I7c2ba4c6f71ab6ae94822a711c322ee1658ac82c
Reviewed-on: https://pdfium-review.googlesource.com/c/pdfium/+/118070
Reviewed-by: Thomas Sepez <tsepez@google.com>
Commit-Queue: Tom Sepez <tsepez@chromium.org>
Reviewed-by: Lei Zhang <thestig@chromium.org>
2024-04-02 21:07:47 +00:00
Lei Zhang
7ca0110e33 Use WriteFloat() inside WriteColorToStream()
Avoid writing out color values that violate the PDF spec.

Change-Id: I1a7b52407bedfbea443a306906e32236473addbe
Reviewed-on: https://pdfium-review.googlesource.com/c/pdfium/+/117396
Reviewed-by: Tom Sepez <tsepez@chromium.org>
Reviewed-by: Thomas Sepez <tsepez@google.com>
Commit-Queue: Lei Zhang <thestig@chromium.org>
2024-04-02 20:58:35 +00:00
Tom Sepez
f6df154e35 Fix some unsafe buffer usage in CPDF_Dest.
Change-Id: Ia7d1ebb773361c17a9fc3eee1562483c24e66fd9
Reviewed-on: https://pdfium-review.googlesource.com/c/pdfium/+/118071
Reviewed-by: Lei Zhang <thestig@chromium.org>
Reviewed-by: Thomas Sepez <tsepez@google.com>
Commit-Queue: Tom Sepez <tsepez@chromium.org>
2024-04-02 20:39:01 +00:00
Tom Sepez
6ddcbf24bc Mark one remaining unsafe function in core/fpdfapi/edit.
This will allow the entire directory to be included into
UNSAFE checks once the format of the paths.txt file matures.

Change-Id: Ia57ebf136e7cdf7ce73928230a223884135a80d9
Reviewed-on: https://pdfium-review.googlesource.com/c/pdfium/+/117933
Reviewed-by: Lei Zhang <thestig@chromium.org>
Reviewed-by: Thomas Sepez <tsepez@google.com>
Commit-Queue: Tom Sepez <tsepez@chromium.org>
2024-04-02 20:30:17 +00:00
Lei Zhang
2855deed06 Do not write out /Page objects that are not in the page tree
FPDFPage_Delete() may not work as expected when used in conjunction with
FPDF_SaveAsCopy(). The CPDF_Creator code that saves the PDF does not
understand the structure of the document's page tree. Therefore, it
only looks at references to determine whether to save referenced
objects, or to discard orphaned objects. This becomes a problem when
bookmarks or other objects has references to page objects, as the page
objects are not considered orphaned.

Fix this problem by augmenting the page deletion code in CPDF_Document.
After a page has been deleted, check to see if there are any references
to the page in the page tree. If it is no longer in the page tree,
replace it with an object of type null.

Since it is likely impossible to traverse the entire PDF's object tree
and correctly remove all the references to a page, use the null object
type to null out the page is the best way to effectively remove it,
while preventing references to it from dangling. Objects that become
orphaned as a result of this modification, such as the page content
stream, will be pruned by CPDF_Creator.

Bug: pdfium:2146
Change-Id: I474ff921e2239f27652f5308b56d1c1b74b51d77
Reviewed-on: https://pdfium-review.googlesource.com/c/pdfium/+/117910
Reviewed-by: Thomas Sepez <tsepez@google.com>
Commit-Queue: Lei Zhang <thestig@chromium.org>
Reviewed-by: Tom Sepez <tsepez@chromium.org>
2024-04-02 16:07:02 +00:00
Andy Phan
e4cebef61b Roll tools/rust/ 1d0018c65..eaff38a21 (6 commits)
1d0018c655..eaff38a21e

Created with:
  roll-dep tools/rust

Change-Id: I02772ab8e67122fb8d92c68e08a00522507d8d4b
Reviewed-on: https://pdfium-review.googlesource.com/c/pdfium/+/118033
Reviewed-by: Lei Zhang <thestig@chromium.org>
Commit-Queue: Lei Zhang <thestig@chromium.org>
Auto-Submit: Andy Phan <andyphan@chromium.org>
2024-04-02 01:41:54 +00:00
Andy Phan
b870f68534 Roll third_party/skia/ 32f1cb507..7338f5521 (263 commits)
https://skia.googlesource.com/skia.git/+log/32f1cb50734a..7338f5521e05

Created with:
  roll-dep third_party/skia

Change-Id: I9297ed02d9ccfd9b148e6b19edb12661f22d5e31
Reviewed-on: https://pdfium-review.googlesource.com/c/pdfium/+/118034
Auto-Submit: Andy Phan <andyphan@chromium.org>
Commit-Queue: Lei Zhang <thestig@chromium.org>
Reviewed-by: Lei Zhang <thestig@chromium.org>
2024-04-02 01:41:51 +00:00
Andy Phan
93c8137d8b Roll base/allocator/partition_allocator/ c702699cc..8a9c3373f (30 commits)
c702699cce..8a9c3373fe

Created with:
  roll-dep base/allocator/partition_allocator

Change-Id: I466767ec5e1931ebbdc980064c11c711ad65924a
Reviewed-on: https://pdfium-review.googlesource.com/c/pdfium/+/118031
Reviewed-by: Lei Zhang <thestig@chromium.org>
Auto-Submit: Andy Phan <andyphan@chromium.org>
Commit-Queue: Lei Zhang <thestig@chromium.org>
2024-04-01 22:05:18 +00:00
Andy Phan
e707409fc7 Roll third_party/libc++abi/src/ fc6253a64..1317096ef (2 commits)
fc6253a642..1317096ef8

Created with:
  roll-dep third_party/libc++abi/src

Change-Id: I218fd701b8c206325d423af68fad6c69989d2527
Reviewed-on: https://pdfium-review.googlesource.com/c/pdfium/+/118030
Reviewed-by: Lei Zhang <thestig@chromium.org>
Commit-Queue: Lei Zhang <thestig@chromium.org>
Auto-Submit: Andy Phan <andyphan@chromium.org>
2024-04-01 21:58:55 +00:00
Andy Phan
6123bc06a2 Roll third_party/libunwind/src/ fc505746f..419b03c0b (2 commits)
fc505746f0..419b03c0b8

Created with:
  roll-dep third_party/libunwind/src

Change-Id: I48a0127b2a20db027e05751255465a9328d0c5e9
Reviewed-on: https://pdfium-review.googlesource.com/c/pdfium/+/118012
Commit-Queue: Lei Zhang <thestig@chromium.org>
Reviewed-by: Lei Zhang <thestig@chromium.org>
Auto-Submit: Andy Phan <andyphan@chromium.org>
2024-04-01 21:57:51 +00:00
Andy Phan
77b0d2a1bf Update reclient_version to 0.134.1.2c9285b-gomaip
Change-Id: I52ec3577ead9ff968e234aa79ca0d56b1639af88
Reviewed-on: https://pdfium-review.googlesource.com/c/pdfium/+/118032
Commit-Queue: Lei Zhang <thestig@chromium.org>
Auto-Submit: Andy Phan <andyphan@chromium.org>
Reviewed-by: Lei Zhang <thestig@chromium.org>
2024-04-01 21:48:18 +00:00
Andy Phan
9dfab8917a Roll third_party/googletest/src/ e4fdb87e7..eff443c6e (7 commits)
e4fdb87e76..eff443c6ef

Created with:
  roll-dep third_party/googletest/src

Change-Id: Ie67f4e195e986bcd5ca3d194cfc6774472d5b617
Reviewed-on: https://pdfium-review.googlesource.com/c/pdfium/+/118011
Reviewed-by: Lei Zhang <thestig@chromium.org>
Auto-Submit: Andy Phan <andyphan@chromium.org>
Commit-Queue: Lei Zhang <thestig@chromium.org>
2024-04-01 21:25:14 +00:00
Andy Phan
bf35e11101 Roll third_party/freetype/src/ 2a790a9f4..f42ce2556 (4 commits)
2a790a9f49..f42ce25563

Created with:
  roll-dep third_party/freetype/src

Change-Id: I32ce6c2fee379830833af58313c60cf2b4e7d6bc
Reviewed-on: https://pdfium-review.googlesource.com/c/pdfium/+/118010
Auto-Submit: Andy Phan <andyphan@chromium.org>
Commit-Queue: Lei Zhang <thestig@chromium.org>
Reviewed-by: Lei Zhang <thestig@chromium.org>
2024-04-01 20:50:28 +00:00
Lei Zhang
483e5e1f5d Change cfx_cmyk_to_srgb code to return struct FX_RGB
Use FX_RGB consistently for color representation.

Change-Id: I282232f7eb6b91816af068edd152dccd46364596
Reviewed-on: https://pdfium-review.googlesource.com/c/pdfium/+/117391
Reviewed-by: Thomas Sepez <tsepez@google.com>
Reviewed-by: Tom Sepez <tsepez@chromium.org>
Commit-Queue: Lei Zhang <thestig@chromium.org>
2024-04-01 19:28:36 +00:00
Tom Sepez
0095eef10f Improve comments and naming in calculate_pitch.h
Change-Id: I73b557bac38ffa9097eeffb973ee676ef3371499
Reviewed-on: https://pdfium-review.googlesource.com/c/pdfium/+/117931
Reviewed-by: Thomas Sepez <tsepez@google.com>
Commit-Queue: Tom Sepez <tsepez@chromium.org>
Reviewed-by: Lei Zhang <thestig@chromium.org>
2024-04-01 18:29:16 +00:00
Andy Phan
d43b6ce462 Update gn_version to 93ee9b91423c1f1f53fb5f6cba7b8eef6247a564
Change-Id: Ie675b41ce9e0c9ed06439ecfe37f1b70cf9440f3
Reviewed-on: https://pdfium-review.googlesource.com/c/pdfium/+/117970
Commit-Queue: Lei Zhang <thestig@chromium.org>
Auto-Submit: Andy Phan <andyphan@chromium.org>
Reviewed-by: Lei Zhang <thestig@chromium.org>
2024-04-01 18:00:59 +00:00
pdfium-autoroll
8ba296abd3 Roll Depot Tools from fbb0301f1f70 to 4a9d989f52e9 (81 revisions)
fbb0301f1f..4a9d989f52

If this roll has caused a breakage, revert this CL and stop the roller
using the controls here:
https://autoroll.skia.org/r/depot-tools-pdfium
Please CC pdfium-reviews+autoroller@googlegroups.com,thestig@chromium.org on the revert to ensure that a human
is aware of the problem.

To report a problem with the AutoRoller itself, please file a bug:
https://issues.skia.org/issues/new?component=1389291&template=1850622

Documentation for the AutoRoller is here:
https://skia.googlesource.com/buildbot/+doc/main/autoroll/README.md

Bug: None
Tbr: pdfium-reviews+autoroller@googlegroups.com
Change-Id: I92ab955a33c0e0f4ebd9178de669969b7d0193d5
Reviewed-on: https://pdfium-review.googlesource.com/c/pdfium/+/117930
Commit-Queue: pdfium-autoroll <pdfium-autoroll@skia-public.iam.gserviceaccount.com>
Bot-Commit: pdfium-autoroll <pdfium-autoroll@skia-public.iam.gserviceaccount.com>
2024-04-01 16:07:58 +00:00
pdfium-autoroll
027aa4b67d Roll Code Coverage from 10ce382356ce to f459fdcdfc6c (9 revisions)
10ce382356..f459fdcdfc

If this roll has caused a breakage, revert this CL and stop the roller
using the controls here:
https://autoroll.skia.org/r/code-coverage-pdfium
Please CC dhoss@chromium.org,pdfium-reviews+autoroller@googlegroups.com,thestig@chromium.org on the revert to ensure that a human
is aware of the problem.

To report a problem with the AutoRoller itself, please file a bug:
https://issues.skia.org/issues/new?component=1389291&template=1850622

Documentation for the AutoRoller is here:
https://skia.googlesource.com/buildbot/+doc/main/autoroll/README.md

Bug: None
Tbr: pdfium-reviews+autoroller@googlegroups.com
Change-Id: I62075f8ddaa385a895fe6ed2f21c20d73525323c
Reviewed-on: https://pdfium-review.googlesource.com/c/pdfium/+/117950
Commit-Queue: pdfium-autoroll <pdfium-autoroll@skia-public.iam.gserviceaccount.com>
Bot-Commit: pdfium-autoroll <pdfium-autoroll@skia-public.iam.gserviceaccount.com>
2024-04-01 16:07:54 +00:00
Lei Zhang
d7ec4201ba Switch CPDF_MeshStream to use FX_RGB
Consistently use this struct instead of std::array.

Change-Id: I9ccfd55834bc0a118d9e6c937604be6796005522
Reviewed-on: https://pdfium-review.googlesource.com/c/pdfium/+/117817
Commit-Queue: Lei Zhang <thestig@chromium.org>
Reviewed-by: Tom Sepez <tsepez@chromium.org>
Reviewed-by: Thomas Sepez <tsepez@google.com>
2024-03-30 05:55:59 +00:00
Lei Zhang
ffbbea8d37 Add struct FX_RGB
Add a way to represent the RGB channels, with easy access to the color
components.

Change-Id: I051482e9e60ac73d3a1b73e6eeaa8b355d6f34be
Reviewed-on: https://pdfium-review.googlesource.com/c/pdfium/+/117816
Reviewed-by: Tom Sepez <tsepez@chromium.org>
Reviewed-by: Thomas Sepez <tsepez@google.com>
Commit-Queue: Lei Zhang <thestig@chromium.org>
2024-03-30 05:38:19 +00:00
Tom Sepez
2238fbe1b6 Add fpdfsdk/{pwl,formfiller,fpdfxfa}/ directories to unsafe buffers.
The code is already clean with respect to UNSAFE_BUFFERS.

Change-Id: I0076c7ec9210e16cc186119bb4a8f27bd68098f7
Reviewed-on: https://pdfium-review.googlesource.com/c/pdfium/+/117815
Commit-Queue: Tom Sepez <tsepez@chromium.org>
Reviewed-by: Lei Zhang <thestig@chromium.org>
Reviewed-by: Thomas Sepez <tsepez@google.com>
2024-03-30 03:03:15 +00:00
Tom Sepez
e9b7be916f Make SBThemeData::clrBtnBK a one-dimensional array.
The code only ever uses the values at [N][1].

-- convert to std::array while at it.

Change-Id: I94ace32fb6b9d936394992619e138620eaef764b
Reviewed-on: https://pdfium-review.googlesource.com/c/pdfium/+/117857
Reviewed-by: Thomas Sepez <tsepez@google.com>
Reviewed-by: Lei Zhang <thestig@chromium.org>
Commit-Queue: Tom Sepez <tsepez@chromium.org>
2024-03-30 02:51:58 +00:00
Tom Sepez
008339888a Remove FXSYS_wcstof in favor of system wcstof().
Currently, this always copies, but we can avoid this in many (not all)
cases with a subsequent CL. There is a slight difference with large
numbers, so this is a check that thing still render properly.

Change-Id: Id4c9d061ed69ca59c5fed0e31cd5feb4574c5e6f
Reviewed-on: https://pdfium-review.googlesource.com/c/pdfium/+/117331
Reviewed-by: Lei Zhang <thestig@chromium.org>
Reviewed-by: Thomas Sepez <tsepez@google.com>
Commit-Queue: Tom Sepez <tsepez@chromium.org>
2024-03-30 02:06:17 +00:00
Lei Zhang
e5458325d3 Add some FPDFDocEmbedderTests that delete pages and save
Exercise FPDFPage_Delete() followed by FPDF_SaveAsCopy() under a variety
of situations. Show that FPDF_SaveAsCopy() is writing out more data than
necessary.

Bug: pdfium:2146
Change-Id: Ic520acc6a86fbf9b14854e3ba4d2b1ee71fa904b
Reviewed-on: https://pdfium-review.googlesource.com/c/pdfium/+/117770
Reviewed-by: Thomas Sepez <tsepez@google.com>
Commit-Queue: Lei Zhang <thestig@chromium.org>
Reviewed-by: Tom Sepez <tsepez@chromium.org>
2024-03-29 23:50:23 +00:00
Lei Zhang
fb8abcb82a Enforce checking the return value of CFX_DIBitmap::Create()
Add the nodiscard attribute to CFX_DIBitmap::Create(). Then change all
callers that did not check the return result to do so. Fail gracefully
when it obvious how to do so. Otherwise wrap the Create() call with
CHECK().

Change-Id: Ibab42b2306e8f8a93d8d87472fcec0cb3250df73
Reviewed-on: https://pdfium-review.googlesource.com/c/pdfium/+/115412
Reviewed-by: Thomas Sepez <tsepez@google.com>
Reviewed-by: Tom Sepez <tsepez@chromium.org>
Commit-Queue: Lei Zhang <thestig@chromium.org>
2024-03-29 23:35:29 +00:00
Tom Sepez
8111f89461 Put unsafe buffer configuration into PDFium
This CL creates a new pdfium_unsafe_buffers_paths.txt in the
top-level directory which lists which sub-directories have been
made safe against C-style pointer arithmetic.

Change-Id: Ibe3e7bc2e3e85e573119a6123c93bc70d91f0330
Reviewed-on: https://pdfium-review.googlesource.com/c/pdfium/+/117850
Commit-Queue: Tom Sepez <tsepez@chromium.org>
Reviewed-by: Lei Zhang <thestig@chromium.org>
Reviewed-by: Thomas Sepez <tsepez@google.com>
2024-03-29 17:04:55 +00:00
Tom Sepez
fe581ab872 Roll build/ e9a12f276..e5ff2eff3 (85 commits)
Manual roll to pick up changes related to unsafe-buffers.

e9a12f2766..e5ff2eff3b

Created with:
  roll-dep build

Change-Id: I2a464f7205f34cf5870f156d95cb40e034a4fd37
Reviewed-on: https://pdfium-review.googlesource.com/c/pdfium/+/117810
Auto-Submit: Tom Sepez <tsepez@chromium.org>
Commit-Queue: Lei Zhang <thestig@chromium.org>
Reviewed-by: Thomas Sepez <tsepez@google.com>
Reviewed-by: Lei Zhang <thestig@chromium.org>
2024-03-28 23:54:00 +00:00
Tom Sepez
e58d4d723b Roll third_party/icu/ 1112fa6b3..d94ab131b (8 commits)
1112fa6b3b..d94ab131bc

Created with:
  roll-dep third_party/icu

Change-Id: I520663e0fe66552d1cabd7f32ad697b0f40c38f5
Reviewed-on: https://pdfium-review.googlesource.com/c/pdfium/+/117812
Reviewed-by: Thomas Sepez <tsepez@google.com>
Commit-Queue: Tom Sepez <tsepez@chromium.org>
Reviewed-by: Lei Zhang <thestig@chromium.org>
2024-03-28 23:35:02 +00:00
Tom Sepez
278639036a Flag remaining unsafe buffer usage in fxcrt.
-- Suppress enforcement in tests.
-- Also add one missing case in span.h

Change-Id: Ib5a52d858a67545618099bd745a0a173b4a2c2ca
Reviewed-on: https://pdfium-review.googlesource.com/c/pdfium/+/117811
Commit-Queue: Tom Sepez <tsepez@chromium.org>
Reviewed-by: Lei Zhang <thestig@chromium.org>
Reviewed-by: Thomas Sepez <tsepez@google.com>
2024-03-28 21:53:49 +00:00
Lei Zhang
e21f71a905 Change CPDF_MeshStream::ReadColor() to return an array
Use std::array<float, 3> consistently for color representation.

Also mark some CPDF_MeshStream methods as const.

Change-Id: I0c80cd34d916615b46525d260b1b9501e638f3fa
Reviewed-on: https://pdfium-review.googlesource.com/c/pdfium/+/117390
Reviewed-by: Tom Sepez <tsepez@chromium.org>
Commit-Queue: Lei Zhang <thestig@chromium.org>
Reviewed-by: Thomas Sepez <tsepez@google.com>
2024-03-28 20:47:01 +00:00
Lei Zhang
1f9ae706c7 Fix undefined behavior in DrawGouraud()
Use pdfium::ClampSub() to avoid undefined behavior in some DrawGouraud()
calculations. The exact result is not critical, as it only affects pixel
values.

Bug: chromium:40813106
Change-Id: I7eaecb1f64fa1c4f46c051280337f0d414a582f0
Reviewed-on: https://pdfium-review.googlesource.com/c/pdfium/+/117730
Reviewed-by: Thomas Sepez <tsepez@google.com>
Reviewed-by: Tom Sepez <tsepez@chromium.org>
Commit-Queue: Lei Zhang <thestig@chromium.org>
2024-03-28 18:43:16 +00:00
Lei Zhang
d9a0209550 Fix some nits in DrawGouraud()
- Mark some references as const-ref.
- Consolidate repeated calculations.

Change-Id: I459f3602dce352deaf9d61e667967ce0446a98cd
Reviewed-on: https://pdfium-review.googlesource.com/c/pdfium/+/117710
Reviewed-by: Thomas Sepez <tsepez@google.com>
Commit-Queue: Lei Zhang <thestig@chromium.org>
Reviewed-by: Tom Sepez <tsepez@chromium.org>
2024-03-28 18:43:09 +00:00
pdfium-autoroll
1c2507320e Roll Catapult from 4dc7721a1444 to 949df6114f3f (83 revisions)
https://chromium.googlesource.com/catapult.git/+log/4dc7721a1444..949df6114f3f

If this roll has caused a breakage, revert this CL and stop the roller
using the controls here:
https://autoroll.skia.org/r/catapult-pdfium
Please CC dhoss@chromium.org,pdfium-reviews+autoroller@googlegroups.com,thestig@chromium.org on the revert to ensure that a human
is aware of the problem.

To report a problem with the AutoRoller itself, please file a bug:
https://issues.skia.org/issues/new?component=1389291&template=1850622

Documentation for the AutoRoller is here:
https://skia.googlesource.com/buildbot/+doc/main/autoroll/README.md

Bug: None
Tbr: pdfium-reviews+autoroller@googlegroups.com
Change-Id: I9aa877c5e84ba13a63cd67142aed6d79fda691e7
Reviewed-on: https://pdfium-review.googlesource.com/c/pdfium/+/117751
Bot-Commit: pdfium-autoroll <pdfium-autoroll@skia-public.iam.gserviceaccount.com>
Commit-Queue: pdfium-autoroll <pdfium-autoroll@skia-public.iam.gserviceaccount.com>
2024-03-25 05:51:01 +00:00
pdfium-autoroll
ec275ee3e5 Roll libpng from 3c7486b231c7 to 5140e80f1841 (1 revision)
3c7486b231..5140e80f18

If this roll has caused a breakage, revert this CL and stop the roller
using the controls here:
https://autoroll.skia.org/r/libpng-pdfium
Please CC pdfium-reviews+autoroller@googlegroups.com,thestig@chromium.org on the revert to ensure that a human
is aware of the problem.

To report a problem with the AutoRoller itself, please file a bug:
https://issues.skia.org/issues/new?component=1389291&template=1850622

Documentation for the AutoRoller is here:
https://skia.googlesource.com/buildbot/+doc/main/autoroll/README.md

Bug: None
Tbr: pdfium-reviews+autoroller@googlegroups.com
Change-Id: I762e8e5ef5870cfdf7fc996019e8440634bfd742
Reviewed-on: https://pdfium-review.googlesource.com/c/pdfium/+/117750
Bot-Commit: pdfium-autoroll <pdfium-autoroll@skia-public.iam.gserviceaccount.com>
Commit-Queue: pdfium-autoroll <pdfium-autoroll@skia-public.iam.gserviceaccount.com>
2024-03-25 05:46:13 +00:00
Ben Wagner
c0800e8bd2 Remove Skia Sfntly dependency
Skia no longer supports use of Sfntly as a font subsetter, remove this
unused mention to clarify this.

Change-Id: I08ce184bf3a75de45f4fcc1917719964669514ce
Reviewed-on: https://pdfium-review.googlesource.com/c/pdfium/+/117690
Commit-Queue: Ben Wagner <bungeman@google.com>
Reviewed-by: Ben Wagner <bungeman@google.com>
Reviewed-by: Lei Zhang <thestig@chromium.org>
2024-03-19 20:42:40 +00:00
Tom Sepez
27062af253 Remove more wide string literals.
There are all, in fact, 7-bit ASCII.

Change-Id: Ifb063cc983b73ea3acbc5a21c07ff344a9222135
Reviewed-on: https://pdfium-review.googlesource.com/c/pdfium/+/117630
Reviewed-by: Thomas Sepez <tsepez@google.com>
Reviewed-by: Lei Zhang <thestig@chromium.org>
Commit-Queue: Tom Sepez <tsepez@chromium.org>
2024-03-19 20:38:06 +00:00
Tom Sepez
7df1650655 Remove some FXSYS_ functions in favor of std::char_traits<>.
Follow-on CL from an offline discussion about "what is char traits
good for?"

Change-Id: Ief99e97e8337b97bcc6816e3168df9835d95e5f9
Reviewed-on: https://pdfium-review.googlesource.com/c/pdfium/+/117671
Reviewed-by: Thomas Sepez <tsepez@google.com>
Reviewed-by: Lei Zhang <thestig@chromium.org>
Commit-Queue: Tom Sepez <tsepez@chromium.org>
2024-03-19 18:17:30 +00:00
Tom Sepez
11b5f3bdb8 Simplify CFXJSE_NodeHelper::CreateNodeForCondition().
Avoid making ints from string literals. Simplify flow and avoid boolean
state variable `bAll`.

Change-Id: I79d9d03c9fb4884031e32869aff717f40d8f1148
Reviewed-on: https://pdfium-review.googlesource.com/c/pdfium/+/117672
Commit-Queue: Tom Sepez <tsepez@chromium.org>
Reviewed-by: Thomas Sepez <tsepez@google.com>
Reviewed-by: Lei Zhang <thestig@chromium.org>
2024-03-19 00:54:48 +00:00
Lei Zhang
a9646b4603 Fix regression in coverage_report.py
Restore the original way that coverage_report.py was calling
subprocess.call(). Before https://pdfium-review.googlesource.com/117451,
the arguments were:

['ninja', ..., 'target1', ..., 'targetN'].

Now, they unintentionally became:

['autoninja', ..., ['target1', ..., 'targetN']].

Remove the extra nested list to avoid Python exceptions from the
subprocess module.

Change-Id: Ieab165b3cc206bff26ee105d5a7b9832ec46a721
Reviewed-on: https://pdfium-review.googlesource.com/c/pdfium/+/117670
Reviewed-by: Thomas Sepez <tsepez@google.com>
Commit-Queue: Lei Zhang <thestig@chromium.org>
2024-03-18 22:58:41 +00:00
Lei Zhang
adc1b16a38 Set a default GN enable_safe_libstdcxx value
Synchronize //build_overrides/build.gni with the Chromium file of the
same path and set enable_safe_libstdcxx to true by default. This more
properly reassembles https://crrev.com/1266874 in PDFium.

Bug: pdfium:2144
Change-Id: If20961778d16a8cfacd17de1c256901c0dcd3131
Reviewed-on: https://pdfium-review.googlesource.com/c/pdfium/+/117650
Commit-Queue: Lei Zhang <thestig@chromium.org>
Reviewed-by: Thomas Sepez <tsepez@google.com>
2024-03-18 20:19:51 +00:00
Lei Zhang
2f6cef867a Avoid a compiler compatibility issue with CPDF_DefaultAppearance
Some older Clang compilers get confused by StringTemplate usage in
CPDF_DefaultAppearance's default constructor. Avoid this issue by
removing the default constructor and changing the only caller to use the
1-param ctor instead.

Change-Id: If2b43fdcf94ff5d6f666c83f451f8a9e8fa67339
Reviewed-on: https://pdfium-review.googlesource.com/c/pdfium/+/117610
Commit-Queue: Tom Sepez <tsepez@chromium.org>
Reviewed-by: Thomas Sepez <tsepez@google.com>
Reviewed-by: Tom Sepez <tsepez@chromium.org>
Commit-Queue: Lei Zhang <thestig@chromium.org>
2024-03-18 18:14:44 +00:00
Tom Sepez
e15b92e443 Convert some WideString::CompareNoCase() to EqualsASCIINoCase().
Then remove some wasted padding by converting L"" literals to "".

-- Fixes botch in CharEncodingFromString() where `== 0` was missing.

Change-Id: Ia1647cf7db6e6f073f35d9560b89d751dd1e92f1
Reviewed-on: https://pdfium-review.googlesource.com/c/pdfium/+/117551
Reviewed-by: Lei Zhang <thestig@chromium.org>
Reviewed-by: Thomas Sepez <tsepez@google.com>
Commit-Queue: Tom Sepez <tsepez@chromium.org>
2024-03-16 20:10:31 +00:00
Tom Sepez
71a0c1d891 Replace ptr/size pair with span in FXJSE_CLASS_DESCRIPTOR.
pdfium::span<> should be constexpr-enough to use here. Then use
a range-based for loop and avoid C-style indexing.

Change-Id: Idc36e51f390be10d42dc57ee9af2c66736276d86
Reviewed-on: https://pdfium-review.googlesource.com/c/pdfium/+/117530
Reviewed-by: Thomas Sepez <tsepez@google.com>
Reviewed-by: Lei Zhang <thestig@chromium.org>
Commit-Queue: Tom Sepez <tsepez@chromium.org>
2024-03-16 20:02:33 +00:00
Tom Sepez
e8ef976cb7 Remove in-out parameter from GetFontFamily.
Change-Id: I783a1edfc127faf6e20295aee4e068a54675ddb1
Reviewed-on: https://pdfium-review.googlesource.com/c/pdfium/+/117590
Reviewed-by: Thomas Sepez <tsepez@google.com>
Reviewed-by: Lei Zhang <thestig@chromium.org>
Commit-Queue: Tom Sepez <tsepez@chromium.org>
2024-03-16 02:36:46 +00:00
Tom Sepez
11f9c86740 Enable UNOWNED_PTR_EXCLUSION checks for debug builds only.
Clang's inability to optimize out some redundant CHECK()s was noticed
while working on an unrelated CL. This is caused by the issue noted in
crbug.com/40836910, where __attribute__((annotate()) changed code gen
as a side effect of placating warnings in the plugin.

Bug: chromium:40836910
Change-Id: Idde4cecd3c329c4c7bac728d5c376a4574cd8f77
Reviewed-on: https://pdfium-review.googlesource.com/c/pdfium/+/117550
Commit-Queue: Tom Sepez <tsepez@chromium.org>
Reviewed-by: Lei Zhang <thestig@chromium.org>
Reviewed-by: Thomas Sepez <tsepez@google.com>
2024-03-16 01:55:56 +00:00
Tom Sepez
b214b50e4e Adjust BUILD.gn files for path-based unsafe buffer warnings.
Prepare for using the clang plugin-based filtering mechanism for
unsafe buffer warnings. This is enabled automatically as appropriate in
build/config/clang/BUILD.gn (sync'ed from outside of pdfium repository
along with other tools). It is enabled on a directory-by-directory basis
based on some paths.txt file (location to be specified via a GN variable
following a build/ roll past https://crrev.com/c/5369835.

Change-Id: I030dc5d15b2b9ea0541af146bcce5d61df13ffee
Reviewed-on: https://pdfium-review.googlesource.com/c/pdfium/+/117510
Reviewed-by: Lei Zhang <thestig@chromium.org>
Reviewed-by: Thomas Sepez <tsepez@google.com>
Commit-Queue: Tom Sepez <tsepez@chromium.org>
2024-03-16 01:32:43 +00:00
Lei Zhang
2dc6941219 Remove another parameter from CPDF_AnnotList methods
Save the CPDF_Page pointer passed into the CPDF_AnnotList ctor and reuse
it, instead of making the caller pass it in multiple times.

Change-Id: I4222e51343dc3f82ab4c2d59ecc9b986b8bfe3ae
Reviewed-on: https://pdfium-review.googlesource.com/c/pdfium/+/117454
Reviewed-by: Tom Sepez <tsepez@chromium.org>
Reviewed-by: Thomas Sepez <tsepez@google.com>
Commit-Queue: Lei Zhang <thestig@chromium.org>
2024-03-16 00:50:19 +00:00
Tom Sepez
7063716b1f Avoid calls to c_str() in cpdf_filespec.cpp.
Even better, remove the unsafe pointer arithmetic being performed on
these results.

Change-Id: I692dd13c43af59c636f0b2b12dd0ac356ea18fd7
Reviewed-on: https://pdfium-review.googlesource.com/c/pdfium/+/117492
Commit-Queue: Tom Sepez <tsepez@chromium.org>
Reviewed-by: Thomas Sepez <tsepez@google.com>
Reviewed-by: Lei Zhang <thestig@chromium.org>
2024-03-13 03:21:26 +00:00
Tom Sepez
c9f2bf1838 Avoid duplicate checks in StringViewTemplate<>::Substr().
Incur the complexity of UNSAFE_BUFFERS() in order to bypass the same
checks that were just made being performed via span<>::subspan(). This
should be optimized out on official builds, but debug builds are still
slower.

Change-Id: I2bac2928f28b35dd71e569ce66f991b67918cdd4
Reviewed-on: https://pdfium-review.googlesource.com/c/pdfium/+/117292
Reviewed-by: Lei Zhang <thestig@chromium.org>
Commit-Queue: Tom Sepez <tsepez@chromium.org>
Reviewed-by: Thomas Sepez <tsepez@google.com>
2024-03-13 02:54:06 +00:00