[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}
This commit is contained in:

committed by
Chromium LUCI CQ

parent
7c52343568
commit
53331a875a
pdf/pdfium
@ -2174,9 +2174,13 @@ bool PDFiumEngine::IsReadOnly() const {
|
||||
|
||||
void PDFiumEngine::SetReadOnly(bool enable) {
|
||||
read_only_ = enable;
|
||||
SetFormHighlight(!read_only_);
|
||||
ClearTextSelection();
|
||||
}
|
||||
|
||||
void PDFiumEngine::SetFormHighlight(bool enable_form) {
|
||||
// Restore form highlights.
|
||||
if (!read_only_) {
|
||||
if (enable_form) {
|
||||
FPDF_SetFormFieldHighlightAlpha(form(), kFormHighlightAlpha);
|
||||
return;
|
||||
}
|
||||
@ -2184,8 +2188,9 @@ void PDFiumEngine::SetReadOnly(bool enable) {
|
||||
// Hide form highlights.
|
||||
FPDF_SetFormFieldHighlightAlpha(form(), /*alpha=*/0);
|
||||
KillFormFocus();
|
||||
}
|
||||
|
||||
// Unselect text.
|
||||
void PDFiumEngine::ClearTextSelection() {
|
||||
SelectionChangeInvalidator selection_invalidator(this);
|
||||
selection_.clear();
|
||||
}
|
||||
|
@ -850,6 +850,11 @@ class PDFiumEngine : public DocumentLoader::Client, public IFSDK_PAUSE {
|
||||
// requests the thumbnail for that page.
|
||||
void MaybeRequestPendingThumbnail(int page_index);
|
||||
|
||||
// Sets whether form highlight should be enabled or cleared.
|
||||
void SetFormHighlight(bool enable_form);
|
||||
|
||||
void ClearTextSelection();
|
||||
|
||||
const raw_ptr<PDFiumEngineClient> client_;
|
||||
|
||||
// The current document layout.
|
||||
|
Reference in New Issue
Block a user