0
Commit Graph

2298 Commits

Author SHA1 Message Date
8472c15f08 [PDF] Use AccessibilityTextRunInfo to calculate selection rectangles
PDFiumPage::GetTextRunInfo() already has good heuristics to calculate
the set of characters that form a text run. Use it in
PDFiumRange::GetScreenRects() to create a rectangle for every text run.
Then add more heuristics to merge the rectangles when they have
sufficient overlap in the horizontal direction. As a result, the text
selection, which is based on GetScreenRects() calculations, will appear
more continuous and less jagged.

Update test expectations to match the new code's behavior.

Keep the original FPDFText_CountRects()-based implementation around,
behind an emergency kill switch, in case the new code has serious
problems.

Bug: 40448046
Change-Id: I17b9dd744671c6721faaf9060622cff788371f1f
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6237116
Reviewed-by: Andy Phan <andyphan@chromium.org>
Reviewed-by: Alan Screen <awscreen@chromium.org>
Commit-Queue: Lei Zhang <thestig@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1417508}
2025-02-07 12:03:53 -08:00
35be0f8e3c [PDF] Change Searchified text tracking method
Currently, PDFiumPage tracks Searchified text at the granuarity of
words, but the tracking gets confused after PDFiumPage::Unload() gets
called, because the handles to the tracked text objects are no longer
valid. Given the assumption that a PDFiumPage either only contains text
from the PDF itself or only contains text from Searchify, simplify
Searchified text tracking from word granuarity to page granuarity. This
avoids the tracking confusion without requiring writing tags into the
PDF.

Bug: 376304020
Change-Id: I890b2be37ef7974b10920bc6b47126711d533d57
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6223665
Reviewed-by: Ramin Halavati <rhalavati@chromium.org>
Commit-Queue: Lei Zhang <thestig@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1417182}
2025-02-06 23:37:45 -08:00
d2a4453896 [PDF] Use PDFiumEngine::GetCurrentOrientation() internally
Refactor PDFiumEngine by using `PDFiumEngine::GetCurrentOrientation()`
instead of using `layout_.options().default_page_orientation()`, which
is the same thing.

This removes some redundancy and slightly improves readability.

Change-Id: I7cdf006b02aaf2a4377392e2e35acd15b5b2447e
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6235350
Reviewed-by: Lei Zhang <thestig@chromium.org>
Commit-Queue: Andy Phan <andyphan@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1416852}
2025-02-06 09:28:17 -08:00
a79e2430a6 [PDF] Clean up PDFiumRange::GetScreenRects()
- Return early whenever possible.
- Call PDFiumPage::GetTextPage() once and reuse the returned value.

Change-Id: Id49980d2fb19d6f3f2d1a9de646e6ed4a8d29405
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6238338
Reviewed-by: Alan Screen <awscreen@chromium.org>
Commit-Queue: Lei Zhang <thestig@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1416613}
2025-02-05 22:18:35 -08:00
a8d5beb257 Update base::FilePath::StringPieceType usage outside of //base
Replace StringPieceType with StringViewType, since base::StringPiece has
been replaced by std::string_view.

Change-Id: I22826fb9df1a71d4ec1fadecaef969db52971d3b
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6235785
Reviewed-by: Peter Kasting <pkasting@chromium.org>
Auto-Submit: Lei Zhang <thestig@chromium.org>
Owners-Override: Peter Kasting <pkasting@chromium.org>
Commit-Queue: Peter Kasting <pkasting@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1416425}
2025-02-05 13:18:29 -08:00
254bd3158d [PDF] Avoid unneeded cache invalidation in PDFiumRange::SetCharCount()
Currently, PDFiumRange::SetCharCount() will unconditionally mark the
PDFiumRange instance's cached screen rects as dirty. This is unnecessary
if the character count has not changed. Check for this condition and
turn SetCharCount() into a no-op.

Change-Id: I699d916b155d8e237774d7b408474e304bd07daa
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6230982
Reviewed-by: Andy Phan <andyphan@chromium.org>
Commit-Queue: Lei Zhang <thestig@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1416281}
2025-02-05 10:24:49 -08:00
bbcaa4dd3e [PDF] Add back documentation for PDFiumPage::GetTextRunInfo()
The comments that describe what this method does got lost in
https://crrev.com/1363484. Add them back.

Change-Id: Idf57e6d99043950fe24446214e8828e7ec0e05a7
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6231360
Reviewed-by: Ramin Halavati <rhalavati@chromium.org>
Commit-Queue: Lei Zhang <thestig@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1416279}
2025-02-05 10:23:39 -08:00
6c6d44856c [PDF] Delete old code path that PdfPaintManagerDrawsBackground replaced
Now that https://crrev.com/1370910 has reached Stable channel, delete
the PdfPaintManagerDrawsBackground kill switch and the old code path
that is now unreachable.

Bug: 40216952
Change-Id: Idc3f5ea612e660335b08a22977e61030f5ec9cfa
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6216505
Reviewed-by: Andy Phan <andyphan@chromium.org>
Commit-Queue: Lei Zhang <thestig@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1415716}
2025-02-04 11:33:09 -08:00
e07c9618f6 [PDF Ink Signatures] Ignore inputs of a different type while stroking
Fix a crash where PdfInkModule::RecordStrokePosition() complains the
inputs are made with different tool types. Check the tool type and
ignore the event if the types are different.

Bug: 391387325
Change-Id: If5fec5a9ca5e4d2aa3a6d5c95f7194ba8a53e917
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6195922
Reviewed-by: Alan Screen <awscreen@chromium.org>
Commit-Queue: Lei Zhang <thestig@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1415108}
2025-02-03 12:04:43 -08:00
e856e48e96 [PDF Ink Signatures] Add AnnotationWithMouseInterruptedByPenEvents test
Add a new test case for PdfInkModuleStrokeTest to show how mouse and pen
inputs interact, based on manual testing on Windows.

Change-Id: Ie552fc5918f63503078ec4ad8f2ed26bf3f9b48a
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6216372
Reviewed-by: Alan Screen <awscreen@chromium.org>
Commit-Queue: Lei Zhang <thestig@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1415071}
2025-02-03 11:05:50 -08:00
e967cc2938 [PDF] Add test for text selection that involves a page with no text
Add a new test PDF where there is an empty page in the middle. Use it in
a new PDFiumEngineTest.SelectTextAcrossEmptyPage test case to exercise
more PDFiumEngine code.

Change-Id: I2b91595005cdac9d2272d481cdcdd7b6cc637f7a
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6221114
Reviewed-by: Ramin Halavati <rhalavati@chromium.org>
Commit-Queue: Lei Zhang <thestig@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1415045}
2025-02-03 10:35:01 -08:00
7558f0e93b [lensoverlay] Render and scroll to text fragment highlights in PDF.
Change-Id: Ifd20ff9c8edb646dd9a338e9b30d3e0c2a12ff09
Bug: 383575917
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6195057
Reviewed-by: Lei Zhang <thestig@chromium.org>
Commit-Queue: Juan Mojica <juanmojica@google.com>
Cr-Commit-Position: refs/heads/main@{#1415007}
2025-02-03 09:52:00 -08:00
c7e39020fe Don't select empty PDF pages when "Select All" is requested.
`PDFiumEngine::SelectAll` selected all pages regardless of having text
or not, while `PDFiumEngine::Selection` only selects pages in the given
range that include text.
To make the behavior consistent, update the former to only select pages
with text.


Bug: 387387738, 392926460
Change-Id: Iee4833d7b44acc8e5ef7175560f77de0b4a1ed25
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6218255
Commit-Queue: Ramin Halavati <rhalavati@chromium.org>
Reviewed-by: Lei Zhang <thestig@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1414767}
2025-02-02 23:14:08 -08:00
1e8ec3e2ef Update AccessibilityViewportInfo to use Selection struct.
This CL does not change any behavior, just clean up.

Bug: 387387738
Change-Id: I66b01b4d68fb5c88b41d4dd16cbf4c52cb35196e
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6221302
Reviewed-by: Lei Zhang <thestig@chromium.org>
Commit-Queue: Ramin Halavati <rhalavati@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1414762}
2025-02-02 23:04:24 -08:00
9f667cbe2e [PDF] Remove HasUnsupportedFeature Mojo interface
This IPC message to the browser ends up as a no-op, as the browser no
longer displays an infobar in response. Remove the IPC, considering it
has been a no-op for nearly a decade.

Change-Id: I673cd8a2558b4a84afd5d573c020ff701a3c237e
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6220800
Reviewed-by: Tom Sepez <tsepez@chromium.org>
Commit-Queue: Lei Zhang <thestig@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1414512}
2025-01-31 19:00:17 -08:00
ed451fa497 [PDF] Rename PDFiumPage::GetThumbnail() to CreateThumbnail()
Give this method a name that better describes what it does. Also update
comments to clarify that this method does not render the thumbnail.

Change-Id: Ibe15681cf2151ef5c88fedb360250a2a73306d42
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6220491
Reviewed-by: Alan Screen <awscreen@chromium.org>
Commit-Queue: Lei Zhang <thestig@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1413959}
2025-01-31 01:00:31 -08:00
746b80a9f4 Update PDFiumEngine::GetSelection() to return an optional value.
`PDFiumEngine::GetSelection()` did not distinguish between when nothing
was selected, and when an empty first page was selected.

Bug: 387387738
Change-Id: Ib5e7748b41183199682968610cef41fbf1c61305
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6218239
Commit-Queue: Ramin Halavati <rhalavati@chromium.org>
Reviewed-by: Lei Zhang <thestig@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1413923}
2025-01-30 22:21:51 -08:00
bcef8924d7 Delay committing searchify results if page is being painted.
If a page is in progressive paint, committing searchify results can
crash PDFium. Hence delay adding the changes to the page until paint
completes for that page.

Bug: 392885625
Change-Id: I1d052985a7bdfbe98bd8f9d3051d1a28b031f3d2
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6218539
Commit-Queue: Ramin Halavati <rhalavati@chromium.org>
Reviewed-by: Lei Zhang <thestig@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1413919}
2025-01-30 22:08:47 -08:00
c82e0ee274 [PDF] Remove PDFiumEngine::pages()
This recently added accessor is actually not necessary, as callers can
use PDFiumEngine::GetNumberOfPages() and GetPage() instead.

Change-Id: Icfeaaa5e41e42537c543532d32745d10abdf6750
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6220286
Commit-Queue: Lei Zhang <thestig@chromium.org>
Reviewed-by: Juan Mojica <juanmojica@google.com>
Cr-Commit-Position: refs/heads/main@{#1413862}
2025-01-30 17:34:59 -08:00
55288fec1d Refactor drawing highlights and scrolling into functions for PDFs.
This refactors code to draw the PDF selection box highlights and
scrolling to bounding rects into functions that can be shared. This is a
precursor CL to rendering and scrolling to text fragment highlights.

Change-Id: I9e5c0d05a270d7ec930efba505cc9a88b4ab3a75
Bug: 383575917
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6219663
Reviewed-by: Lei Zhang <thestig@chromium.org>
Commit-Queue: Juan Mojica <juanmojica@google.com>
Cr-Commit-Position: refs/heads/main@{#1413793}
2025-01-30 15:08:58 -08:00
48ba13db87 [PDF Ink Signatures] Ignore touch events after a pen event
Make the behavior in this scenario more consistent with other apps.
Change PdfInkModule's to remember if it ever received a pen event, and
ignore touch events after that. Update tests with the new expectations,
add ApplyStrokeWithTouchAtPointsNotHandled() as needed, and remove the
now fulfilled TODOs.

Bug: 392650039
Change-Id: I38c45d8fc369748c49619e3448f713651e5e3797
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6216548
Commit-Queue: Lei Zhang <thestig@chromium.org>
Reviewed-by: Alan Screen <awscreen@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1413686}
2025-01-30 12:30:42 -08:00
89760182ba [PDF Ink Signatures] Add IgnoreTouchEventsAfterPenEvent test case
Add a test case for a scenario where the sequence of events is a mix of
touch and pen events. Set the expectations to the current behavior, and
add TODOs for getting to the desired behavior.

Bug: 392650039
Change-Id: I1f51aa1c2754b933ad394e980fca0e8f7e8fe4ba
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6216546
Reviewed-by: Alan Screen <awscreen@chromium.org>
Commit-Queue: Lei Zhang <thestig@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1413679}
2025-01-30 12:24:20 -08:00
4b0d645dad [PDF Ink Signatures] Simplify GetToolTypeFromTouchEvent()
GetToolTypeFromTouchEvent() has a TODO that assumes it has to deal with
multi-touch, but it turns out all the callers already rejected
multi-touch events. As such, remove the TODO and simplify
GetToolTypeFromTouchEvent() to just check the first and only touch.

Bug: 377733396
Change-Id: I7d9b19c6ac3f341106b39d9d64287f97eaa0e83f
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6216547
Commit-Queue: Lei Zhang <thestig@chromium.org>
Reviewed-by: Andy Phan <andyphan@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1413675}
2025-01-30 12:17:39 -08:00
44583e8618 [PDF Ink Signatures] Consolidate code that enables the feature in tests
- Use the existing EnableAnnotationMode() helper instead of
  re-implementing it.
- Add the check to make sure PdfInkModule is enabled to
  EnableAnnotationMode(), instead of making the callers do it.

Change-Id: I551fd1bd72698def36e8422c4a5841ff20270d69
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6217489
Commit-Queue: Lei Zhang <thestig@chromium.org>
Reviewed-by: Alan Screen <awscreen@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1413641}
2025-01-30 11:36:27 -08:00
6c765ca6f1 [lensoverlay] Support parsing and searching for text fragments in PDF.
Rendering the highlights will come in a follow-up CL.

Change-Id: I76ca388bd11cce8a3ddd6cd04474d0157fecd909
Bug: 383575917
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6173296
Commit-Queue: Juan Mojica <juanmojica@google.com>
Reviewed-by: Lei Zhang <thestig@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1413612}
2025-01-30 10:55:44 -08:00
e34d414dde [PDF] Use chrome_pdf::Result in more code
Since Result is an enum and not an enum class, it is very easy to mix up
this enum and ints. To prepare for making Result an enum class, start
using it in some callbacks. This forces the compiler to be stricter
about type checking. Then use Result in more places to fix the compile
errors. For url_loader_unittest.cc in particular, split the existing
mock callback variable into two separate variables for open and read
operations.

Change-Id: I1c830fd88aba39542fa60508d9e1c26ed1744e5c
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6216483
Reviewed-by: Andy Phan <andyphan@chromium.org>
Commit-Queue: Lei Zhang <thestig@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1413268}
2025-01-29 17:49:57 -08:00
c6ac18c6aa [PDF] Simplify chrome_pdf::URLLoaderWrapper::OpenRange()'s callback
Instead of taking an int, the callback OpenRange() runs only needs a
boolean to indicate success. Update all related code to pass in a
boolean. Then a success value of true is easier to understand than a
result value of Result::kSuccess, which is often written as 0. This
cleanup means less work in a future CL to convert Result from enum to
enum class.

Change-Id: I00589ca711721f586899325a01fca196eb8d33bd
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6216499
Reviewed-by: Andy Phan <andyphan@chromium.org>
Commit-Queue: Lei Zhang <thestig@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1413256}
2025-01-29 17:11:14 -08:00
8726d30ed0 Suppress unsafe_libc_call warning for initial identified files.
See docs/unsafe_buffers.md for details. Enforcement is not yet
enabled, but this set of files are not in compliance with the
new warnings.

Bug: 390223051
Change-Id: I4e24c2141b9399f572678302c833947494098b29
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6187925
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@{#1412673}
2025-01-28 18:11:08 -08:00
aece0d42b5 Remove WebVector: Automatic changes
Replace WebVector (which has been an alias of std::vector since
crrev.com/c/6204022) with std::vector.

function cg() {
  git grep --name-only "$1" -- *.mm *.h *.cc
}
sed -i 's/include.*web_vector.h"/include <vector>/' `cg web_vector.h`
sed -i '/^using blink::WebVector;/d' `cg 'using blink::WebVector'`
sed -i '/^using ::blink::WebVector;/d' `cg 'using ::blink::WebVector'`
sed -i 's/blink::WebVector\b/std::vector/g' `cg blink::WebVector`
sed -i 's/\bWebVector\b/std::vector/g' `cg WebVector`
git checkout -- third_party/blink/public/platform/web_vector.h
git cl format

Only manual changes are to remove unused "#include <vector>" added by
the above script, based on presubmit warnings.

BYPASS_LARGE_CHANGE_WARNING=`git cl split` will create too many CLs needing too many reviewers while this CL doesn't need much manual review.

Bug: 40865165
Change-Id: Ib70af44863ceaa73f470c77abe74d8994e2822a2
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6209609
Owners-Override: Kentaro Hara <haraken@chromium.org>
Reviewed-by: Kentaro Hara <haraken@chromium.org>
Commit-Queue: Xianzhu Wang <wangxianzhu@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1412669}
2025-01-28 17:57:12 -08:00
54565c8a1d [PDF Ink Signatures] Add metric for PDFs loaded with V2 Ink annotations
Add a metric to track the number of PDFs loaded with V2 Ink annotations.
In order to do so, add a method in PDFiumEngine to check if a PDF has
any V2 Ink paths, without having to store and transform the paths.

This metric only tracks PDFs loaded for users with Ink2 enabled.

Bug: 380433757
Change-Id: I412ab1cb4a9b9a763e0f704527e234145b12e306
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6181044
Reviewed-by: Alan Screen <awscreen@chromium.org>
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@{#1411985}
2025-01-27 16:42:25 -08:00
85e3b7c091 [cleanup] Replace base::ranges with std::ranges: pdf/
Done entirely with `git grep` and `sed` + `git cl format`, no
hand-editing.

Bug: 386918226
Change-Id: Ib625085b15fcc55372f0715b417cf6f14b8a6910
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6203125
Code-Coverage: findit-for-me@appspot.gserviceaccount.com <findit-for-me@appspot.gserviceaccount.com>
Reviewed-by: Lei Zhang <thestig@chromium.org>
Commit-Queue: Peter Kasting <pkasting@chromium.org>
Auto-Submit: Peter Kasting <pkasting@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1411902}
2025-01-27 14:16:10 -08:00
d563b3b56b [PDF Ink Signatures] Add test helper to create mouse move events
Add CreateMouseMoveWithLeftButtonEventAtPoint() to simplify a commonly
set of MouseEventBuilder calls.

Change-Id: I173631a97e614d745c646822bc88ab6ec826bb77
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6195921
Reviewed-by: Alan Screen <awscreen@chromium.org>
Commit-Queue: Lei Zhang <thestig@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1411044}
2025-01-24 10:37:51 -08:00
cdb9fae486 [PDF Ink Signatures] Add logging to diagnose a CHECK() failure
Log the error status in PdfInkModule::RecordStrokePosition() to better
understand why a CHECK() failed. Existing crash dumps do not contain
this information.

Bug: 391387325
Change-Id: Iea49c78bb558a3a35f47e6ce1ae36105265c993f
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6194601
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@{#1410571}
2025-01-23 14:48:36 -08:00
aed5f66971 [PDF Ink Signatures] Minimize drawing overhead if no in-progress stroke
Since https://crrev.com/1380766 landed, PdfInkModule::Draw() only has
work to do if there is an in-progress stroke.  Rendering for all
previous strokes are handled as objects within the PDF document.

Introduce a new query so that callers can determine if there is
anything for PdfInkModule to draw.  This allows the caller to reduce
the overhead for drawing in the common case where there is currently
no active stroke being drawn.

Also update the PdfInkModule::Draw() API comment to reflect what it
currently draws, and also its requirements given that it can now expect
only to be called for an in-progress stroke.

Bug: 391666319
Change-Id: Ie6a89cfde9a3893e05ac10852f91550c64b9f093
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6191591
Reviewed-by: Lei Zhang <thestig@chromium.org>
Code-Coverage: findit-for-me@appspot.gserviceaccount.com <findit-for-me@appspot.gserviceaccount.com>
Commit-Queue: Alan Screen <awscreen@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1410558}
2025-01-23 14:24:30 -08:00
82ee6dc25c Save extracted text for searchified PDFs.
If a PDF is searchified, the extracted text is written to the file when
the PDF is saved.
This is done behind `chrome_pdf::features::kPdfSearchifySave` flag which
is disabled by default.
In a next CL (http://crrev.com/c/6110470), the user will be given the
option to save the original PDF or the PDF with extracted text.

Bug: 382610226
Change-Id: I73e1028ce60211e8bed165ffaff7f6630c9103c4
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6049156
Reviewed-by: Andy Phan <andyphan@chromium.org>
Reviewed-by: Lei Zhang <thestig@chromium.org>
Reviewed-by: Alan Screen <awscreen@chromium.org>
Commit-Queue: Ramin Halavati <rhalavati@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1407724}
2025-01-16 21:33:54 -08:00
24dd13d8ac Avoid OOM in chrome_pdf::PdfViewWebPlugin::OnViewportChanged()
In cases where the viewport is too large, an image buffer allocation
will fail and cause a crash inside SkBitmap::allocPixels(). Switch to
SkBitmap::tryAllocPixels() to avoid this crash. Presumably when the
viewport gets resized back to a normal size, OnViewportChanged() will
run again, successfully allocation the buffer, and the PDF Viewer will
recover.

Bug: 386572857
Change-Id: I1db92e2aed0b515316636e408c2942daf9ce4f65
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6180508
Reviewed-by: Ben Wagner <bungeman@google.com>
Commit-Queue: Lei Zhang <thestig@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1407620}
2025-01-16 15:44:13 -08:00
09e49a1a48 [PDF Ink Signatures] Add stroke input device type metric
Add a metric to track the input device type of a drawn stroke. An input
device type can be mouse, touch, or pen.

To do so, track the tool type during the lifetime of an erase stroke.
Draw strokes already track this.

Bug: 380433757
Change-Id: Iff1b72460510179ccd6da50e4dc7557e56b9f264
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6150443
Reviewed-by: Alan Screen <awscreen@chromium.org>
Reviewed-by: Lei Zhang <thestig@chromium.org>
Code-Coverage: findit-for-me@appspot.gserviceaccount.com <findit-for-me@appspot.gserviceaccount.com>
Commit-Queue: Andy Phan <andyphan@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1406908}
2025-01-15 12:36:01 -08:00
812f0e219b [lensoverlay] Add message plumbing for rendering text fragments in PDF.
The parsing, searching, and rendering of the text fragments will take
place in follow-up CLs. This message is currently a no-op.

Change-Id: I2e1b2ce5eb5bd3bb638d1ceb8acd14a59a0d5684
Bug: 383575917
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6166811
Reviewed-by: Andy Phan <andyphan@chromium.org>
Commit-Queue: Juan Mojica <juanmojica@google.com>
Reviewed-by: Lei Zhang <thestig@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1406772}
2025-01-15 09:07:40 -08:00
b2beab971f [PDF Ink Signatures] Differentiate between touch and pen events
Initially, all touch and pen events were treated as touch events and
used a touch tool type for strokes. Instead, identify when the touch
event is actually a pen event and use the pen tool type for pen events.

Note that WebPluginContainerImpl::HandleEvent() treats pen events as
blink::WebTouchEvents for compatibility, which is why this distinction
needs to be made when handling blink::WebTouchEvents in
pdf_ink_module.cc.

Bug: 377733396, 380433757
Change-Id: I8a434a4998b44f934c18fe26c003469d1763095a
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6168829
Code-Coverage: findit-for-me@appspot.gserviceaccount.com <findit-for-me@appspot.gserviceaccount.com>
Commit-Queue: Andy Phan <andyphan@chromium.org>
Reviewed-by: Lei Zhang <thestig@chromium.org>
Reviewed-by: Dave Tapuska <dtapuska@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1406307}
2025-01-14 12:33:46 -08:00
809199bebc [PDF Ink Signatures] Refactor RunStroke.*Test() thumbnail expectations
Refactor the thumbnail expectations by splitting it into its own private
helper method.

This will reduce the amount of existing duplicated code and potential
duplicate code in https://crrev.com/c/6168829.

Bug: 377733396, 380433757
Change-Id: I4f6194b1338eb5fe1565dfcde16a8cd3ad22b5ab
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6169558
Commit-Queue: Andy Phan <andyphan@chromium.org>
Reviewed-by: 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@{#1406305}
2025-01-14 12:32:38 -08:00
f85e36dd0d [PDF Ink Signatures] Avoid updating drawing brush during stroke
A user can simultaneously apply different modes of input (such as mouse
+ keyboard, or mouse + touchscreen) to cause a change in tool state in
the middle of a drawing stroke.

Modify PdfInkModule so that the current drawing brush can not be
changed while there is an in-progress drawing stroke.  Any changes to
drawing tool state is captured and applied after an in-progress stroke
is finished, making the changes only applicable to subsequent strokes.
This includes delaying an update to the cursor image, so that it
consistently matches the PdfInkBrush state.

Bug: 381908888
Change-Id: Icbeb342b9c3d7e614be6ee044c7355a3041c4a44
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6103003
Reviewed-by: 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>
Commit-Queue: Alan Screen <awscreen@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1405717}
2025-01-13 13:32:43 -08:00
a3551e7a1a Tagged PDFs: Stores the tag's type in the accessibility data in Chrome's PDF Viewer
The "structure tree" inside a PDF file provides information that can be
used by assistive software to expose the organization and semantics of
the file's elements, e.g. indicate where the headings are, or present
some textual information as a table.
PDFs with a "structure tree" are called "tagged".

This patch starts the journey of supporting tagged PDFs by exposing the
tag's type, i.e. the accessibility role, of every text span to assistive
software. This allows, e.g. headings, and list bullets to be supported.

Design doc at:
https://docs.google.com/document/d/1ScD93clMA7AtViWINnaQgRTAK3vbpMshQZQXmWkfCyQ/edit?usp=sharing

AX-Relnotes: n/a.
Change-Id: Id56a8d6e21196c383b0d38ceac24923bf5fadd86
Bug: 40707542
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5980169
Reviewed-by: Ramin Halavati <rhalavati@chromium.org>
Commit-Queue: Nektarios Paisios <nektar@chromium.org>
Reviewed-by: Kyungjun Lee <kyungjunlee@google.com>
Reviewed-by: Lei Zhang <thestig@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1405381}
2025-01-12 23:17:29 -08:00
ba6a7c96e3 PDF: Handle FPDFPage_GetRotation() error in PDFiumPage::GetBoundingBox()
If FPDFPage_GetRotation() returns -1, do not cast that to enum class
Rotation, which does not have a corresponding enum value.

Bug: 388557904
Change-Id: Id6e3c788a67b6ce4c36e09b38bdb913ad548dd13
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6168649
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@{#1405103}
2025-01-10 17:06:26 -08:00
090ba9ab51 Add new method to grab current visible page from PDF renderer
This CL adds a method to get the current visible PDF page. In a follow
up CL, I'll use the new page index to grab text from the
X pages after the one the user is viewing and include it in the partial
upload request.

Bug: 387306854
Change-Id: Ibc145a5c7cb5f359614814393d671f3fea460299
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6134412
Reviewed-by: Matthew Denton <mpdenton@chromium.org>
Reviewed-by: Ali Stanfield <stanfield@google.com>
Reviewed-by: Lei Zhang <thestig@chromium.org>
Commit-Queue: Duncan Mercer <mercerd@google.com>
Cr-Commit-Position: refs/heads/main@{#1405010}
2025-01-10 14:10:56 -08:00
c7fec6992e [PDF Ink Signatures] Add test for drawing brush type change mid-stroke
A user can simultaneously apply different modes of input (such as mouse
+ keyboard, or mouse + touchscreen) to cause a change in tool state in
the middle of a drawing stroke.

Add a test for changing the drawing brush type in the middle of an
in-progress stroke, such as from the pen to the highlighter.  This
causes the entire stroke to change with the updated state, which is not
the desired behavior.

Bug: 381908888
Change-Id: I908c252d7b08868a277e96bb2673fd7661fea088
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6115082
Reviewed-by: Lei Zhang <thestig@chromium.org>
Reviewed-by: Andy Phan <andyphan@chromium.org>
Commit-Queue: 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@{#1399470}
2024-12-20 18:12:13 -08:00
687012f46b Roll src/third_party/ink/src/ d21aa587b..e5673a4ff (1 commit)
d21aa587ba..e5673a4ff2

$ git log d21aa587b..e5673a4ff --date=short --no-merges --format='%ad %ae %s'
2024-11-12 sfreilich Rename ModeledShape to PartitionedMesh

Created with:
  roll-dep src/third_party/ink/src

Then update Chromium build rules, includes, and type references to match
the Ink rename. Variables still keep their "shape" names, as they do in
Ink.

Change-Id: I2f390013590d505c1c9dcc5f5c5cdfa35a4a327b
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6112871
Reviewed-by: Alan Screen <awscreen@chromium.org>
Commit-Queue: Lei Zhang <thestig@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1399420}
2024-12-20 15:53:20 -08:00
2fa76fa7a8 [PDF Ink Signatures] Avoid overwriting in-progress eraser state
A user can simultaneously apply different modes of input (such as mouse
+ keyboard, or mouse + touchscreen) to cause a change in tool state in
the middle of a drawing stroke.

When a user changes the size of the eraser in the middle of an eraser
stroke, the internal eraser state is getting overwritten in such a way
that the PDF viewer will crash if a user performs a subsequent stroke.
Add protection in PdfInkModule to avoid overwriting the state so that a
crash is avoided.

This scenario also illustrates that changes to the eraser size gets
immediately applied to an in-progress stroke.  This is not the desired
behavior, as such changes should only be applied to subsequent strokes.
Add a TODO to note that this behavior still needs to be addressed.

Bug: 381908888
Change-Id: I782420ec24893ba85227c3f70d13e8deddcee118
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6103002
Commit-Queue: Alan Screen <awscreen@chromium.org>
Code-Coverage: findit-for-me@appspot.gserviceaccount.com <findit-for-me@appspot.gserviceaccount.com>
Reviewed-by: Andy Phan <andyphan@chromium.org>
Reviewed-by: Lei Zhang <thestig@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1398958}
2024-12-19 17:04:18 -08:00
d63ab1b2f0 [PDF Ink Signatures] Avoid overwriting in-progress drawing state
A user can simultaneously apply different modes of input (such as mouse
+ keyboard, or mouse + touchscreen) to cause a change in tool state in
the middle of a drawing stroke.

When a user changes the color or size of a pen/highlighter in the
middle of a drawing stroke, the internal drawing state is getting
overwritten in such a way that the PDF viewer will crash if a user
performs a subsequent stroke.  Add protection in PdfInkModule to avoid
overwriting the state so that a crash is avoided.

This scenario also illustrates that changes to the pen color or size
get immediately applied to an in-progress stroke.  This is not the
desired behavior, as such changes should only be applied to subsequent
strokes.  Add TODOs to note that this behavior still needs to be
addressed.

Bug: 381908888
Change-Id: I254b65bbb05090415a73adb28bcfc9e4be8e24f8
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6102042
Reviewed-by: 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>
Commit-Queue: Alan Screen <awscreen@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1398955}
2024-12-19 17:02:25 -08:00
3860137d25 [PDF Ink Signatures] Finish in-progress stroke on tool type change
A user can simultaneously apply different modes of input (such as mouse
+ keyboard, or mouse + touchscreen) to cause a change in tool state in
the middle of a draw or erase stroke.  Such actions should not cause
the PDF viewer to crash.

Avoid this crash by automatically finishing the in-progress stroke at
the time of the tool type change.  The event which would normally
signal to finish the stroke is now considered unhandled since the
stroke already finished.

Bug: 381908888
Change-Id: Ia5690e271886d82864fd155bd09c00da7b9d7a37
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6103525
Reviewed-by: Lei Zhang <thestig@chromium.org>
Commit-Queue: 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>
Cr-Commit-Position: refs/heads/main@{#1398878}
2024-12-19 14:37:54 -08:00
88ba2ce076 C++11 std::array rewrite for memory safety [17/19]
Split from:
https://chromium-review.googlesource.com/c/chromium/src/+/6004959/21

Generated patch
---------------
- Tool: ./tool/clang/spanify/rewrite-multiple-platform.sh
- Platform: Linux.
- Filter: This includes 2400/4222 patches. I included the std::array
      ones and excluded build errors.

Google announcement:
--------------------
https://groups.google.com/a/google.com/g/chrome-memory-safety/c/RMiO4gaVLQA/m/Yz-3NCObAgAJ

Benchmarks:
----------
See design doc and
https://chromium-review.googlesource.com/c/chromium/src/+/6004959/21

Description
-----------
The consensus during the memory safety summit was to begin rewriting
relevant C-style arrays to C++11 std::array. It can be done immediately,
offers better developer ergonomics, and fix large chunks of the
-Wunsafe-buffer-usage errors in Chrome.

To clarify, this effort is complementary to the longer plan work with
enabling -fsanitize=array-bounds, and we plan to leverage both,
especially for protecting 3p code.

[Attached] is a document detailing the rationale, benefits, and
considerations for potential compile-time and performance impacts.

[Attached]:https://docs.google.com/document/d/1z5aBDg26lHmNDjXRCysElWKx7E4PAJXqykI_k7ondJI/edit?tab=t.0#heading=h.cqgo7wvp0kzt

NO_IFTTT=No need to update base/debug/stack_trace.h

Bug: 378069401
Change-Id: I5d2420ca9261f62a8a21f037ecd1850ecdb58210
R: dcheng@chromium.org
AX-Relnotes: n/a.
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6039266
Auto-Submit: Arthur Sonzogni <arthursonzogni@chromium.org>
Reviewed-by: Daniel Cheng <dcheng@chromium.org>
Owners-Override: Daniel Cheng <dcheng@chromium.org>
Commit-Queue: Daniel Cheng <dcheng@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1396391}
2024-12-14 10:53:10 -08:00