0
Commit Graph

2025 Commits

Author SHA1 Message Date
53331a875a [PDF Ink Signatures] Refactor PDFiumEngine::ReadOnly()
Refactor by moving the form highlight and selection logic into separate
helper methods. In https://crrev.com/c/5841317, these helper methods
will be reused to remove form highlights and text selection when
entering annotation mode.

Bug: 353923998
Change-Id: Ic1424a4b967b29f27a6f24045b9d044f53132dad
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5841316
Commit-Queue: Andy Phan <andyphan@chromium.org>
Code-Coverage: findit-for-me@appspot.gserviceaccount.com <findit-for-me@appspot.gserviceaccount.com>
Reviewed-by: Lei Zhang <thestig@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1352366}
2024-09-06 23:36:39 +00:00
28686eebfe [PDF Ink Signatures] Blend highlighter color options
The highlighter color options have an opacity of 1, when the actual
brush color has an opacity of 0.4f. Take into account the transparency
in the visible color option by transforming the actual highlighter color
using the alpha blending formula with a white background.

This is purely a presentational change in the UI.

NO_IFTTT=New IFTTT, did not change original value.

Bug: 351868764
Change-Id: Ic4445ed1c7e13d4c7ca33ad4c0c3c2e2ac8dd607
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5840546
Reviewed-by: Lei Zhang <thestig@chromium.org>
Reviewed-by: Rebekah Potter <rbpotter@chromium.org>
Commit-Queue: Andy Phan <andyphan@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1352288}
2024-09-06 21:17:21 +00:00
c2e890261e spanification: WebAssociatedURLLoaderClient
Pass a span<const char> to DidReceiveData().

Bug: 351564777
Change-Id: Iccf9c41cf7af89b913870ba60acff5e18fe29114
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5829129
Commit-Queue: Fredrik Söderquist <fs@opera.com>
Reviewed-by: Derek Schuff <dschuff@chromium.org>
Reviewed-by: Lei Zhang <thestig@chromium.org>
Reviewed-by: Dave Tapuska <dtapuska@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1351934}
2024-09-06 10:32:11 +00:00
73e5f5ac31 [PDF Ink Signatures] Refresh Ink thumbnail along with PDF thumbnail
When the frontend asks the backend to (re)generate the PDF thumbnail,
also generate the Ink thumbnail for the same page if it exists. This
makes the Ink thumbnail render correctly if the frontend cleared the
previously generated thumbnails for some page.

Implement this by taking PdfViewWebPlugin::UpdateThumbnail() and
splitting the relevant part out as GenerateAndSendInkThumbnail().
Then call GenerateAndSendInkThumbnail() in SendThumbnail().

Bug: 353942908
Change-Id: Ib004b2d9d3af4050a74cafafe9c865e59cd4a3ec
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5838007
Commit-Queue: Lei Zhang <thestig@chromium.org>
Reviewed-by: Andy Phan <andyphan@chromium.org>
Reviewed-by: Alan Screen <awscreen@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1351738}
2024-09-05 22:09:17 +00:00
1fb6027884 Make PDF font proxy default and remove feature
PDFs now get non-embedded fonts via a skia/mojo proxy
rather than using "direct" access via sandbox hooks &
sandbox IPCs.

This CL removes the WinPdfUseFontProxy feature and
associated plumbing content code for allowing access to the
local fonts dir.

Bug: 344643689
Change-Id: Idbb5a9ef2e6c24a4f1c08c6505437c9ca1696096
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5805910
Reviewed-by: Lei Zhang <thestig@chromium.org>
Reviewed-by: Will Harris <wfh@chromium.org>
Reviewed-by: Nasko Oskov <nasko@chromium.org>
Commit-Queue: Alex Gough <ajgo@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1351684}
2024-09-05 20:53:12 +00:00
de2dcd1f77 [PDF Ink Signatures] Draw thumbnails and send them to the frontend
PdfInkModule will notify PdfViewWebPlugin that a thumbnail update is
necessary when the following events occur:

- Drawing stroke finishes
- Erasing stroke finishes
- Undo
- Redo

Then PdfViewWebPlugin will get the thumbnail size from the PDF engine,
generate a transparent thumbnail with the Ink strokes, and send that to
the frontend. The frontend can then overlay this thumbnail on top of the
thumbnail for the page contents. With two thumbnails, the relatively
static page contents thumbnail does not need to be repeatedly
regenerated.

Bug: 353942908
Change-Id: I4adaac90d3c15aa723d42bfb9e9b95d0b7d77828
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5824214
Reviewed-by: Alan Screen <awscreen@chromium.org>
Code-Coverage: findit-for-me@appspot.gserviceaccount.com <findit-for-me@appspot.gserviceaccount.com>
Commit-Queue: Lei Zhang <thestig@chromium.org>
Reviewed-by: Andy Phan <andyphan@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1351607}
2024-09-05 18:58:14 +00:00
e6ced42232 Consolidate some duplicate input test code in //pdf
- Add MouseEventBuilder::CreateLeftMouseUpAtPosition() and use it where
  applicable.
- Add PdfViewWebPluginTest::TestSendInputEvent() and simplify test cases
  that send input events and maybe check the cursor after.

Change-Id: I0fe9b1adfa0e69828962501cd069b66308f7b1a2
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5839558
Reviewed-by: Alan Screen <awscreen@chromium.org>
Commit-Queue: Lei Zhang <thestig@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1351602}
2024-09-05 18:52:58 +00:00
0db1a0248c spanification: WebPlugin / WebPluginContainerImpl
Pass a span<const char> to DidReceiveData().

Bug: 351564777
Change-Id: Ib8e36cbe12025bef3b2f83ad1f31491dff7e89d5
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5834089
Reviewed-by: Lei Zhang <thestig@chromium.org>
Reviewed-by: Dave Tapuska <dtapuska@chromium.org>
Commit-Queue: Fredrik Söderquist <fs@opera.com>
Cr-Commit-Position: refs/heads/main@{#1351293}
2024-09-05 09:24:59 +00:00
be4e2a6f82 [lensoverlay] Send PDF bytes for contextualization
When the feature flag is enabled, extracts the PDF bytes from the PDF
renderer process and sends them to the Lens server to help with
contextualization. This CL is meant to help prototype and unblock server
side work, not be used on any real users yet. Therefore the logic is
gated by a feature flag defaulted to off. Bytes only leave the device if
the user invokes the Lens Overlay after manually turning on the feature
flag.

Before enabling the flag for real users, updates will be made to our
privacy data notice so no bytes leave the device unless the user
consents.

More info in the design doc linked in the bug.

Bug: 361409401
AX-Relnotes: n/a.
Change-Id: I9c261fe4e02a607a845bcef6bb2375830880ff37
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5811891
Reviewed-by: Lei Zhang <thestig@chromium.org>
Commit-Queue: Duncan Mercer <mercerd@google.com>
Reviewed-by: Jason Hu <hujasonx@google.com>
Cr-Commit-Position: refs/heads/main@{#1350343}
2024-09-03 19:34:16 +00:00
6d767216ff PDF Viewer: Record find-in-page user actions
This uses the same approach as https://crrev.com/c/5818311 to record
find-in-page actions to the PDF.Actions histogram. This gives better
insight into which features are being used in the PDF Viewer.

Here, the feature is triggered by the browser's frontend, which then
talks to the PDF Viewer's backend and bypasses the PDF Viewer frontend.
To record these actions, the backend has to send a simple message to the
frontend.

Bug: 350222373
Change-Id: I563e70bd8b7e00eda804db5ec3a287ebdb53a255
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5823641
Reviewed-by: Rebekah Potter <rbpotter@chromium.org>
Commit-Queue: Lei Zhang <thestig@chromium.org>
Reviewed-by: Alan Screen <awscreen@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1348769}
2024-08-29 18:15:38 +00:00
88c70dd35b PDF Viewer: Record cut/copy/paste user actions
The PDF.Actions histogram is incomplete and does not show how often
users interact with text in PDFs via cut/copy/paste. Add new histogram
enum values to record these actions.

Unlike most existing actions that are initiated in the PDF Viewer's
frontend and recorded there, cut/copy/paste take place in the backend.
To record these actions, the backend has to send a simple message to the
frontend.

Along the way, update the owners for PDF.Actions, and add the enum
values from https://crrev.com/1178835 which are missing in enums.xml.

Bug: 350222373
Change-Id: I6c9c554640e77b181a7df25e676b1d53f898a542
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5818311
Reviewed-by: Alan Screen <awscreen@chromium.org>
Reviewed-by: Rebekah Potter <rbpotter@chromium.org>
Commit-Queue: Lei Zhang <thestig@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1348705}
2024-08-29 17:18:53 +00:00
cc4a3146d3 Add NOTREACHED() to many //pdf switch statements
Given the following code snippets:

void Foo(Enum e) {
  switch (e) {
    case ...:
      ...
      return;
  }
}

int Bar(Enum e) {
  switch (e) {
    case ...:
      ...
      return val;
  }
}

If the switch statements do not have a default case, since all defined
enum values are handled, then undefined enum values can cause undefined
behavior as suggested in https://abseil.io/tips/147. Avoid this by
guarding the UB code path with NOTREACHED().

Clang actually generates "ud2" instructions in debug builds in the
places where this CL adds NOTREACHED(). Whereas in release builds, Clang
does whatever it wants.

Also do IWYU for base/notreached.h in this directory.

Change-Id: I4bbfe8ed091627608bc84f9658fe2c01dc47fec1
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5813603
Commit-Queue: Lei Zhang <thestig@chromium.org>
Reviewed-by: Peter Boström <pbos@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1347070}
2024-08-26 23:57:20 +00:00
844ff63776 Switch from NOTREACHED() to CHECK_OP in //pdf
This follow-up to https://crrev.com/1346787 rewrites:

if (!foo) {
  NOTREACHED();
}

to CHECK(foo);

Change-Id: I57772df51ecc6e589dfdf7e2672ed34d70aab0ee
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5813468
Reviewed-by: Peter Boström <pbos@chromium.org>
Commit-Queue: Lei Zhang <thestig@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1347063}
2024-08-26 23:46:55 +00:00
f24ea1cb41 Migrate to NOTREACHED() in pdf/
NOTREACHED() and NOTREACHED_IN_MIGRATION() are both CHECK-fatal now.
The former is [[noreturn]] so this CL also performs dead-code removal
after the NOTREACHED().

This CL does not attempt to do additional rewrites of any surrounding
code, like:

if (!foo) {
  NOTREACHED();
}

to CHECK(foo);

Those transforms take a non-trivial amount of time (and there are
thousands of instances). Cleanup can be left as an exercise for the
reader.

Bug: 40580068
Low-Coverage-Reason: OTHER Should-be-unreachable code
Change-Id: I0d9e7d1dc3324cdb0fd4b3ce3ce9a7ee2c6079ea
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5802701
Reviewed-by: Lei Zhang <thestig@chromium.org>
Commit-Queue: Lei Zhang <thestig@chromium.org>
Auto-Submit: Peter Boström <pbos@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1346787}
2024-08-26 16:46:15 +00:00
a9f1eee7ed [PDF Ink Signatures] Restructure InkBrushBehavior
Update InkBrushBehavior to match the latest changes to
ink::BrushBehavior. Although InkBrushBehavior is not actively used,
keeping it in sync will make it easier to use, should it be needed.

Bug: 339682315
Change-Id: I3397ad1284a0b2738805b8426a871206f69359ac
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5805411
Reviewed-by: Andy Phan <andyphan@chromium.org>
Commit-Queue: Lei Zhang <thestig@chromium.org>
Code-Coverage: findit-for-me@appspot.gserviceaccount.com <findit-for-me@appspot.gserviceaccount.com>
Reviewed-by: Alan Screen <awscreen@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1346279}
2024-08-23 23:39:48 +00:00
1f71dd2fb8 [PDF CR23] Add feature and flags
Add a feature flag for toggling Chrome Refresh 2023 for the PDF viewer.
Add a chrome://flags entry so users can toggle it.

Bug: 360265881
Change-Id: Ie1a498cab3b6a78c21031e4043fcab6b109549cd
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5805148
Reviewed-by: Lei Zhang <thestig@chromium.org>
Commit-Queue: Andy Phan <andyphan@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1346033}
2024-08-23 17:00:36 +00:00
4d12261e0a [PDF Ink Signatures] Add EraseStrokesAcrossTwoPages test
Add PdfInkModuleStrokeTest.EraseStrokesAcrossTwoPages to check an eraser
stroke across two pages erases strokes on both pages.

Bug: 352720912
Change-Id: I377c18509ebabb498d71b25d7e3b03e746ccf812
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5787686
Reviewed-by: Andy Phan <andyphan@chromium.org>
Reviewed-by: Alan Screen <awscreen@chromium.org>
Code-Coverage: findit-for-me@appspot.gserviceaccount.com <findit-for-me@appspot.gserviceaccount.com>
Commit-Queue: Lei Zhang <thestig@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1343087}
2024-08-16 22:54:46 +00:00
929422a714 Reuse chrome_pdf::GetTestDataFilePath() in test_document_loader.cc
Delete some nearly identical code.

Change-Id: If8b759683bc7a471ac2aadc7f9246249e037dbbd
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5789005
Commit-Queue: Lei Zhang <thestig@chromium.org>
Reviewed-by: Alan Screen <awscreen@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1343054}
2024-08-16 21:42:56 +00:00
fe2dc809ac Switch to base::ReadFileToBytes() in PDFiumEngineExportsTest
By using base::ReadFileToBytes() instead of base::ReadFileToString(),
the code in PDFiumEngineExportsTest:

1) Avoids having to deal with an out-parameter.
2) Avoids std::string to std::vector conversions.
3) Can pass the read result directly into the consumers without needing
   to explicitly create spans.

Change-Id: If0056cf612db6945936a90c63b246a93242b9c4f
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5792124
Reviewed-by: Alan Screen <awscreen@chromium.org>
Commit-Queue: Lei Zhang <thestig@chromium.org>
Code-Coverage: findit-for-me@appspot.gserviceaccount.com <findit-for-me@appspot.gserviceaccount.com>
Cr-Commit-Position: refs/heads/main@{#1343053}
2024-08-16 21:42:38 +00:00
acd4a7344a Tweak PDF getThumbnail message and related code
- Change PluginController.requestThumbnail() to take a page index.
  Adjust its 2 callers.
- Rename the getThumbnail message's "page" key to "pageIndex".

Change-Id: Ib9b52cc1f67dae332a624ee8575516be0142429e
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5789329
Reviewed-by: Andy Phan <andyphan@chromium.org>
Commit-Queue: Lei Zhang <thestig@chromium.org>
Code-Coverage: findit-for-me@appspot.gserviceaccount.com <findit-for-me@appspot.gserviceaccount.com>
Cr-Commit-Position: refs/heads/main@{#1343016}
2024-08-16 20:39:05 +00:00
0689c19473 Consistently use "page index" in Blink and PDF printing code
Avoid the use of "page number", which is oftentimes considered 1-based.
Consistently use the "page index" terminology, which makes it clearer
that the values are 0-based.

Change-Id: I3c29b56b759731371881d730c8a5dc307c773b8e
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5791835
Commit-Queue: Lei Zhang <thestig@chromium.org>
Reviewed-by: Kentaro Hara <haraken@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1342900}
2024-08-16 17:25:42 +00:00
8638b9541c Rename PDF IsPageVisible() parameter from "index" to "page_index"
Make it extra clear what the index refers to.

Change-Id: I2f2d973a75681c4b3b83e05428114380277ec9f5
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5791834
Commit-Queue: Lei Zhang <thestig@chromium.org>
Reviewed-by: Andy Phan <andyphan@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1342896}
2024-08-16 17:20:40 +00:00
a7b468babb [PDF Ink Signatures] Make the pen brush round
Set the pen brush's corner rounding value to 1, on the scale of [0, 1].
Add unit tests for the brush's corner rounding value, using the same
method as opacity value testing.

Bug: 353942923
Change-Id: I3f3f556fb809bc9a8d0d6219dc44cca6818618cf
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5789221
Code-Coverage: findit-for-me@appspot.gserviceaccount.com <findit-for-me@appspot.gserviceaccount.com>
Reviewed-by: Andy Phan <andyphan@chromium.org>
Commit-Queue: Lei Zhang <thestig@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1342447}
2024-08-15 20:08:56 +00:00
3d0699027c [PDF Ink Signatures] Scale drawing tool cursor size with page zoom
Make the cursor look bigger when the page is zoomed in, as the strokes
drawn are bigger too. Cursor min/max sizes still apply.

Bug: 342602620
Change-Id: I2de0cdfe306c8e1aacc61c56cff70db106fab9c9
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5787460
Reviewed-by: Andy Phan <andyphan@chromium.org>
Code-Coverage: findit-for-me@appspot.gserviceaccount.com <findit-for-me@appspot.gserviceaccount.com>
Commit-Queue: Lei Zhang <thestig@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1342438}
2024-08-15 19:47:23 +00:00
331f9214d9 [PDF Ink Signatures] Switch from floats to ints in cursor code
The cursor is a bitmap, and bitmaps have integer sizes. So switch to
ints where appropriate.

Bug: 342602620
Change-Id: I12f555d14fbabc66e70447fe73cbf5e2dbeca954
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5787372
Reviewed-by: Andy Phan <andyphan@chromium.org>
Commit-Queue: Lei Zhang <thestig@chromium.org>
Code-Coverage: findit-for-me@appspot.gserviceaccount.com <findit-for-me@appspot.gserviceaccount.com>
Cr-Commit-Position: refs/heads/main@{#1342420}
2024-08-15 19:21:32 +00:00
55266eafa7 [PDF Ink Signatures] Clip stroke drawing to page content area
The canvas passed to the Ink library contains more than just the page
content area. Even though Ink strokes are limited to the page content
area, Ink may render wide strokes past the page border. Clip the canvas
to prevent this rendering issue.

Bug: 352578790
Change-Id: Ic890142f9c2b53a514945cb746000f1856f6b17d
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5787520
Reviewed-by: Andy Phan <andyphan@chromium.org>
Code-Coverage: findit-for-me@appspot.gserviceaccount.com <findit-for-me@appspot.gserviceaccount.com>
Commit-Queue: Lei Zhang <thestig@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1342345}
2024-08-15 17:38:57 +00:00
5faa765c54 Convert non-conforming UNSAFE_BUFFERS() usage to UNSAFE_TODO().
Per the updated unsafe_buffers.md, UNSAFE_BUFFERS() should only
be used for cases where subsequent spanification is not possible, and
that other cases should use the UNSAFE_TODO() macro.

Then update existing usage to conform to this convention. Code lacking
safety comments is converted to UNSAFE_TODO() as well.

Document some functions that should propagate unsafety to their
callers via UNSAFE_BUFFER_USAGE but do not enforce this.

Change-Id: Ieb6472102a2e245d040b4d4ad50317c2358d9783
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5786346
Code-Coverage: findit-for-me@appspot.gserviceaccount.com <findit-for-me@appspot.gserviceaccount.com>
Reviewed-by: Daniel Cheng <dcheng@chromium.org>
Commit-Queue: Daniel Cheng <dcheng@chromium.org>
Owners-Override: Daniel Cheng <dcheng@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1342098}
2024-08-15 02:46:46 +00:00
01ab59ae08 Migrate NOTREACHED_NORETURN -> NOTREACHED
NOTREACHED() has turned [[noreturn]] so the former macro isn't needed
anymore.

This does not attempt to do a rewrite of any surrounding code, like:

if (!foo) {
  NOTREACHED();
}

to CHECK(foo);

Those transforms take a non-trivial amount of time (and there are
thousands of instances). Cleanup can be left as an exercise for the
reader.

NO_IFTTT=No-op-rename migration.

Bug: 40580068
Change-Id: I068c5fdce9dc4c352d8bdd62bb3cd2c0a2d59659
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5782602
Reviewed-by: Daniel Cheng <dcheng@chromium.org>
Owners-Override: Daniel Cheng <dcheng@chromium.org>
Commit-Queue: Daniel Cheng <dcheng@chromium.org>
Commit-Queue: Peter Boström <pbos@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1342096}
2024-08-15 02:39:49 +00:00
343444b692 [PDF Ink Signatures] Refactor PdfInkModule::Draw()
In PdfInkModule::Draw(), move some repeated calls to
PdfInkModule::Client out of a for-loop. Save the results and reuse them.
Also save the PdfInkModule::Client::GetPageContentsRect() result in a
variable for reuse in an upcoming CL.

Change-Id: I230460a9a108a920300f4e95e01d7fb4ab897616
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5786531
Code-Coverage: findit-for-me@appspot.gserviceaccount.com <findit-for-me@appspot.gserviceaccount.com>
Reviewed-by: Andy Phan <andyphan@chromium.org>
Commit-Queue: Lei Zhang <thestig@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1341990}
2024-08-14 22:23:22 +00:00
436e7bc0bf [PDF Ink Signatures] Use custom cursor for drawing tools
Use GenerateToolCursor() in PdfInkModule to draw custom cursors that
match the color/size of the selected drawing tool.

Bug: 342602620
Change-Id: Ib05f8ca9ebf8575b9d57fde37b80e2df9c87af93
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5778151
Code-Coverage: findit-for-me@appspot.gserviceaccount.com <findit-for-me@appspot.gserviceaccount.com>
Commit-Queue: Lei Zhang <thestig@chromium.org>
Reviewed-by: Andy Phan <andyphan@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1341401}
2024-08-14 01:25:20 +00:00
9b8bfde008 [PDF Ink Signatures] Move test message creation code to their own file
Move 2 PdfInkModuleTest methods for creating test messages out of
pdf_ink_module_unittest.cc and into their own file. This code can then
be shared with tests in other files.

Change-Id: I8a635c83bc50b1b17a97f447e2a934cf10e065d9
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5784294
Commit-Queue: Lei Zhang <thestig@chromium.org>
Reviewed-by: Andy Phan <andyphan@chromium.org>
Code-Coverage: findit-for-me@appspot.gserviceaccount.com <findit-for-me@appspot.gserviceaccount.com>
Cr-Commit-Position: refs/heads/main@{#1341321}
2024-08-13 22:35:52 +00:00
9440e05fe3 [PDF Ink Signatures] Add functions to draw custom cursors
Add CursorDiameterFromBrushSize() to convert brush sizes into cursor
diameters.

Add GenerateToolCursor() to generate bitmaps to represent cursors of a
given color and diameter.

Bug: 342602620
Change-Id: I03ab0a312aa6b8be7a26d906ed928f74a19e515c
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5778150
Code-Coverage: findit-for-me@appspot.gserviceaccount.com <findit-for-me@appspot.gserviceaccount.com>
Reviewed-by: Andy Phan <andyphan@chromium.org>
Commit-Queue: Lei Zhang <thestig@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1340602}
2024-08-12 21:05:30 +00:00
f9024522d2 [PDF Ink Signatures] Store a full ui::Cursor in PdfViewWebPlugin
Take a step towards implementing custom cursors by storing a full cursor
object, instead of just a cursor type in PdfViewWebPlugin.

Bug: 342602620
Change-Id: I992f625128677cb284151aadbb885bb1f035cb33
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5758190
Reviewed-by: Andy Phan <andyphan@chromium.org>
Code-Coverage: findit-for-me@appspot.gserviceaccount.com <findit-for-me@appspot.gserviceaccount.com>
Commit-Queue: Lei Zhang <thestig@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1340601}
2024-08-12 21:05:20 +00:00
c1d35982e6 [PDF Ink Signatures] Move CheckToolSizeIsInRange() into pdf_ink_brush.h
Move this function out of an anonymous namespace, and make it a static
method in PdfInkBrush. Then the function can be used in more places.

Bug: 342602620
Change-Id: Id0b445b8ef672bc213acadab20573c5e7fb88dd7
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5778759
Commit-Queue: Lei Zhang <thestig@chromium.org>
Code-Coverage: findit-for-me@appspot.gserviceaccount.com <findit-for-me@appspot.gserviceaccount.com>
Reviewed-by: Andy Phan <andyphan@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1339990}
2024-08-10 01:28:51 +00:00
fe55ecaafe [PDF Ink Signatures] Validate brush tool size
Now that the frontend is only using the side bar and not the older
annotation bar, the brush sizes sent to the backend are always in the
expected range. Validate them. Also use base::checked_cast() to make
sure there is no funny business when converting from doubles to floats,
and consolidate the size handling code, now that every tool has a size.

Bug: 341282609
Change-Id: I7fd2bee6cbec6d980bb82ee986ca5506d8fd5a71
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5778127
Commit-Queue: Lei Zhang <thestig@chromium.org>
Reviewed-by: Andy Phan <andyphan@chromium.org>
Code-Coverage: findit-for-me@appspot.gserviceaccount.com <findit-for-me@appspot.gserviceaccount.com>
Cr-Commit-Position: refs/heads/main@{#1339979}
2024-08-10 00:41:11 +00:00
109f6f16ea [PDF Ink Signatures] Fix boundary cases for VisiblePageIndexFromPoint()
Change VisiblePageIndexFromPoint() to avoid rounding its input. Then
boundary cases work as expected.

Bug: 358296950
Change-Id: I3885f6e8b7ffe0ec910fdfccb54725a52a9864e7
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5773239
Reviewed-by: Andy Phan <andyphan@chromium.org>
Code-Coverage: findit-for-me@appspot.gserviceaccount.com <findit-for-me@appspot.gserviceaccount.com>
Commit-Queue: Lei Zhang <thestig@chromium.org>
Reviewed-by: Nigi <nigi@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1339361}
2024-08-08 23:06:20 +00:00
76ead4b7c9 [PDF Ink Signatures] Add more VisiblePageIndexFromPoint() boundary tests
Add more test cases to show what happens with points that are just
outside of page boundaries. Currently, VisiblePageIndexFromPoint()
round the points from floats to integers, and these outside points are
then considered part of a page.

Bug: 358296950
Change-Id: I5b4b19e6ceeda1b5abb3b093dbf819ed2b956c5d
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5773238
Commit-Queue: Lei Zhang <thestig@chromium.org>
Code-Coverage: findit-for-me@appspot.gserviceaccount.com <findit-for-me@appspot.gserviceaccount.com>
Reviewed-by: Andy Phan <andyphan@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1339359}
2024-08-08 23:05:10 +00:00
7927adca19 Use move semantics with PdfViewWebPlugin's WebPluginParams
Consistently use move semantics to avoid extra copies.

Change-Id: I78f4fff41ab32cd961e5811fd7d206a97a8d4b8d
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5770929
Commit-Queue: Lei Zhang <thestig@chromium.org>
Reviewed-by: Andy Phan <andyphan@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1339348}
2024-08-08 22:50:04 +00:00
02b00b2308 [PDF Ink Signatures] Disable undo/redo when text form field is focused
Disable the undo/redo buttons when the text form field is focused. To do
so, PdfViewWebPlugin needs to send the type of form field focus to the
PDF extension.

Fixed: 355578909
Change-Id: Id208986b9d92e25ab2522717541ce8220d056145
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5767173
Commit-Queue: Andy Phan <andyphan@chromium.org>
Code-Coverage: findit-for-me@appspot.gserviceaccount.com <findit-for-me@appspot.gserviceaccount.com>
Reviewed-by: Rebekah Potter <rbpotter@chromium.org>
Reviewed-by: Lei Zhang <thestig@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1338868}
2024-08-08 04:42:53 +00:00
30991981df [PDF Ink Signatures] Refactor PdfInkModule code that records strokes
Every time a new position gets added to a stroke, the following happens:

1) The position gets converted to a canonical position.
2) A time stamp is calculated.
3) The result of (1) and (2) gets appended to a vector.

Since this happens in several places, consolidate the repeated code that
performs the above actions into PdfInkModule::RecordStrokePosition().

Change-Id: I676bc66af7c8b9d085c2df82138ec85d1563d4f9
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5750615
Reviewed-by: Andy Phan <andyphan@chromium.org>
Reviewed-by: Alan Screen <awscreen@chromium.org>
Code-Coverage: findit-for-me@appspot.gserviceaccount.com <findit-for-me@appspot.gserviceaccount.com>
Commit-Queue: Lei Zhang <thestig@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1335829}
2024-08-01 01:59:35 +00:00
d9d25a18da [PDF Ink Signatures] Extrapolate stroke when crossing page boundary
When input events cross over the page boundary sufficiently fast, the
discrete events PdfInkModule receives may leave gaps between the end of
a stroke segment and the page boundary. Detect when this condition
happens in PdfInkModule::ContinueStroke(), and extrapolate the missing
segment using CalculatePageBoundaryIntersectPoint().

Bug: 352578791
Change-Id: Iba19f14607e08bd4c33d2663c549f7d264c6af44
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5749713
Reviewed-by: Alan Screen <awscreen@chromium.org>
Reviewed-by: Andy Phan <andyphan@chromium.org>
Code-Coverage: findit-for-me@appspot.gserviceaccount.com <findit-for-me@appspot.gserviceaccount.com>
Commit-Queue: Lei Zhang <thestig@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1335821}
2024-08-01 01:54:45 +00:00
d6e4278aaf Enable WinPdfUseFontProxy by default in M129
Make WinPdfUseFontProxy on by default in M129. A flag
(pdf-win-use-font-proxy) exists for users to toggle this
until it is removed.

Bug: 344643689
Change-Id: I8accdf7eba2c3ac0bf2a5dbfddb597afe2647066
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5754127
Commit-Queue: Alex Gough <ajgo@chromium.org>
Reviewed-by: Lei Zhang <thestig@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1335817}
2024-08-01 01:52:23 +00:00
c38fabe91a [PDF Ink Signatures] Add CalculatePageBoundaryIntersectPoint() helper
Add a utility function that calculates where a line that starts inside a
rect and ends outside a rect intersects the rect. This will be used to
calculate where strokes enter/exit the page, given input events do not
always perfectly land at page boundaries.

Bug: 352578791
Change-Id: If8e33d09a0fe29ffd8f5b578d3ab8c8d2455ec97
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5751342
Commit-Queue: Lei Zhang <thestig@chromium.org>
Reviewed-by: Andy Phan <andyphan@chromium.org>
Reviewed-by: Alan Screen <awscreen@chromium.org>
Code-Coverage: findit-for-me@appspot.gserviceaccount.com <findit-for-me@appspot.gserviceaccount.com>
Cr-Commit-Position: refs/heads/main@{#1335789}
2024-08-01 01:35:54 +00:00
39d9e5e432 [PDF Ink Signatures] Enable undo/redo even when not in annotation mode
With the new UI refresh, the undo and redo buttons are now in the viewer
toolbar, which is always displayed, even when the viewer is not in
annotation mode.

Since the buttons can always be clicked, allow the backend to undo/redo
even when annotation mode is disabled.

Bug: 355578909
Change-Id: I5c8fc11c3882b8e0f536b9bd9b182372d039678b
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5744321
Reviewed-by: Lei Zhang <thestig@chromium.org>
Code-Coverage: findit-for-me@appspot.gserviceaccount.com <findit-for-me@appspot.gserviceaccount.com>
Reviewed-by: Alan Screen <awscreen@chromium.org>
Commit-Queue: Andy Phan <andyphan@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1334411}
2024-07-29 20:01:51 +00:00
13f2b6f6d7 Replace various FPDFText_* API usage inside pdfium_page.cc
Now that FPDFText_GetTextObject() exists, many existing FPDFText_* API
calls inside pdfium_page.cc can be replaced with an equivalent
FPDFTextObj_* API call, or FPDFFont_* API call:

FPDFText_GetFontSize()    -> FPDFTextObj_GetFontSize()
FPDFText_GetFontInfo()    -> FPDFFont_GetBaseFontName() and
                             FPDFFont_GetFlags()
FPDFText_GetFontWeight()  -> FPDFFont_GetWeight()
FPDFText_GetFillColor()   -> FPDFPageObj_GetFillColor()
FPDFText_GetStrokeColor() -> FPDFText_GetStrokeColor()

Make these conversions and add more error checking as needed, to clear
the way for removing these FPDFText_* APIs from PDFium.

As part of the conversions, many functions that take the pair
(FPDF_TEXTPAGE, int /*char_index*/) can be simplified to just take
FPDF_PAGEOBJECT. Do this recursively to simplify more related code.

Bug: 353746891, 353746892
Change-Id: I846093a8ee5979415eefa2121936c3ba81b08c49
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5719478
Code-Coverage: findit-for-me@appspot.gserviceaccount.com <findit-for-me@appspot.gserviceaccount.com>
Reviewed-by: Alan Screen <awscreen@chromium.org>
Commit-Queue: Lei Zhang <thestig@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1333795}
2024-07-26 21:52:32 +00:00
1fe9480e3b [PDF Ink Signatures] Handle position in mouse up events
Most of the time, the mouse up event has the same position as the most
recent mouse move event. However, this is not always the case and the
position may be different. Handle this possibility by processing the
mouse up event like it was also a mouse move event at the same position.
When drawing, this can now frequently trigger a condition where the
mouse position did not change between two calls. For this case, treat
mouse move events where the position did not change from the last
position as no-ops.

Then update all the unit tests to account for this new behavior.

Bug: 335524380
Change-Id: I5f332fe2082e95343623dada65ad9cff73bc52ff
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5726894
Reviewed-by: Alan Screen <awscreen@chromium.org>
Commit-Queue: Lei Zhang <thestig@chromium.org>
Reviewed-by: Andy Phan <andyphan@chromium.org>
Code-Coverage: findit-for-me@appspot.gserviceaccount.com <findit-for-me@appspot.gserviceaccount.com>
Cr-Commit-Position: refs/heads/main@{#1332438}
2024-07-24 17:42:34 +00:00
d4e5b90d18 Limit max DPI of extracted images from PDFs for OCR.
OCR needs at most 300 DPI images. `chrome_pdf::GetImageForOcr` is
updated to reduce its output size if the image has higher resolution.

Bug: 353445502
Change-Id: I5601bc2cf6358df0f7b7a00230ee157c55677735
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5718048
Commit-Queue: Ramin Halavati <rhalavati@chromium.org>
Reviewed-by: Lei Zhang <thestig@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1330904}
2024-07-22 05:37:17 +00:00
76653f5c32 [PDF Ink Signatures] Tidy pdf_ink_brush.cc
- Remove some comments that are already in pdf_ink_brush.h.
- Update some bug numbers to reference newly filed bugs that are more
  narrowly scoped.

Bug: 335524380, 353942923
Change-Id: I90a3936969b3ed183ac9a0720ca1db149383d759
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5723300
Auto-Submit: Lei Zhang <thestig@chromium.org>
Reviewed-by: Andy Phan <andyphan@chromium.org>
Commit-Queue: Andy Phan <andyphan@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1330312}
2024-07-19 16:55:00 +00:00
298530b0ed Disable PDF OCR in Print Preview mode.
PdfAccessibilityTree gets the page and image index of the images in PDF
and stores them in OCR requests, and later fetches the images when OCR
is ready to process them.
PDFs are generated dynamically in print preview mode and the indices may
change during accessibility tree generation and OCR steps.
To fix the issue OCR is now disabled in Print preview, and will be
supported later in PDFium layer.

AX-Relnotes: Unlabeled images are not OCRed in print preview.
Bug: 353205017
Change-Id: If599784531041bf614a0fc768f8aae3f46fd38fc
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5720529
Reviewed-by: Lei Zhang <thestig@chromium.org>
Reviewed-by: David Tseng <dtseng@chromium.org>
Commit-Queue: Ramin Halavati <rhalavati@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1330269}
2024-07-19 15:42:48 +00:00
3667134c31 Apply PDF rotations to OCR generated accessibility tree.
Page orientation is passed to PdfAccessibilityTree and is applied to the
bounding rects generated by OCR.

AX-Relnotes: If user rotates a PDF, OCR generated text boundaries are also rotated.
Bug: 40918374
Change-Id: I74b9a7c5c5137ff0e07124036d3e2672d20912b6
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5701644
Reviewed-by: Lei Zhang <thestig@chromium.org>
Commit-Queue: Ramin Halavati <rhalavati@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1330020}
2024-07-19 04:26:34 +00:00