[PDF Ink Signatures] Add state management for text annotations [chromium/src : main]

0 views
Skip to first unread message

Andy Phan (Gerrit)

unread,
Mar 28, 2025, 12:54:13 PM3/28/25
to Rebekah Potter, Chromium Metrics Reviews, AyeAye, Chromium LUCI CQ, chromium...@chromium.org, asvitkine...@chromium.org, chromium-a...@chromium.org, extension...@chromium.org, pdf-r...@chromium.org
Attention needed from Rebekah Potter

Andy Phan added 5 comments

File chrome/browser/resources/pdf/constants.ts
Line 44, Patchset 7 (Latest):export interface TextStyles {
Andy Phan . unresolved

Will this be used by multiple files? I think it's only being used in one file and can be moved there.

File chrome/browser/resources/pdf/ink2_manager.ts
Line 155, Patchset 7 (Latest): // TODO: Replace this with a real call to the plugin, once the backend has
Andy Phan . unresolved

Nit: add a bug number.

File chrome/test/data/pdf/ink2_manager_test.ts
Line 53, Patchset 7 (Latest): chrome.test.assertEq(expected.type, brushUpdates[index]!.type);
Andy Phan . unresolved

Store as a variable and assert this so we don't have to use `!` everytime? Same with line 109.

Line 54, Patchset 7 (Latest): // Test doesn't currently use eraser, so assert the brush has a color.
Andy Phan . unresolved

Should we test eraser?

Line 154, Patchset 7 (Latest): manager.setTextColor({r: 0, b: 100, g: 0});
Andy Phan . unresolved

Nit: create a `const` to be consistent with the test above. Same with line 159.

Open in Gerrit

Related details

Attention is currently required from:
  • Rebekah Potter
Submit Requirements:
  • requirement satisfiedCode-Coverage
  • requirement is not satisfiedCode-Review
  • requirement is not satisfiedNo-Unresolved-Comments
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
Gerrit-MessageType: comment
Gerrit-Project: chromium/src
Gerrit-Branch: main
Gerrit-Change-Id: I1ae7e833a4cf0c167b6afac50c28bdb77ed4bad8
Gerrit-Change-Number: 6394083
Gerrit-PatchSet: 7
Gerrit-Owner: Rebekah Potter <rbpo...@chromium.org>
Gerrit-Reviewer: Andy Phan <andy...@chromium.org>
Gerrit-Reviewer: Rebekah Potter <rbpo...@chromium.org>
Gerrit-CC: Chromium Metrics Reviews <chromium-met...@google.com>
Gerrit-Attention: Rebekah Potter <rbpo...@chromium.org>
Gerrit-Comment-Date: Fri, 28 Mar 2025 16:54:02 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
satisfied_requirement
unsatisfied_requirement
open
diffy

Rebekah Potter (Gerrit)

unread,
Mar 28, 2025, 1:59:22 PM3/28/25
to Chromium Metrics Reviews, AyeAye, Andy Phan, Chromium LUCI CQ, chromium...@chromium.org, asvitkine...@chromium.org, chromium-a...@chromium.org, extension...@chromium.org, pdf-r...@chromium.org
Attention needed from Andy Phan

Rebekah Potter voted and added 5 comments

Votes added by Rebekah Potter

Commit-Queue+1

5 comments

File chrome/browser/resources/pdf/constants.ts
Line 44, Patchset 7:export interface TextStyles {
Andy Phan . unresolved

Will this be used by multiple files? I think it's only being used in one file and can be moved there.

Rebekah Potter

We can't move only this interface because AnnotationText uses it, and importing the interface back into this file from the manager would create a circular dependency.

AnnotationText itself is indeed only used in the manager in this CL, but will be needed in the next CL in the chain in the new text side panel element. Seems like a lot of churn to put all of these 3 types in the manager for 1 CL only to revert back in its child. Do you want me to combine the 2 CLs instead so that it's clear where this is used (along with the new manager APIs, which are also unused in prod code in this CL)?

File chrome/browser/resources/pdf/ink2_manager.ts
Line 155, Patchset 7: // TODO: Replace this with a real call to the plugin, once the backend has
Andy Phan . resolved

Nit: add a bug number.

Rebekah Potter

Done

File chrome/test/data/pdf/ink2_manager_test.ts
Line 53, Patchset 7: chrome.test.assertEq(expected.type, brushUpdates[index]!.type);
Andy Phan . resolved

Store as a variable and assert this so we don't have to use `!` everytime? Same with line 109.

Rebekah Potter

`!` is fine to use for array elements as long as the length of the array has previously been asserted, which is done on line 52. This is just an issue with TS compiler not realizing that the assertion on line 52 means that this can't be undefined.

Asserting the array length is at least `N` and then using `!` for `array[index]` for `index < N` is standard practice for WebUI tests.

Line 54, Patchset 7: // Test doesn't currently use eraser, so assert the brush has a color.
Andy Phan . unresolved

Should we test eraser?

Rebekah Potter

From the perspective of the manager these two are handled the same way, no? It's testing the setBrushType() API and that it correctly requests the brush from the plugin and then fires an event with that updated brush. There's no difference in handling in Ink2Manager for eraser vs highlighter. Obviously there is a difference in handling in the UI elements, which handle the eraser case differently, but this is a unit test for the manager itself; UI element behavior should be tested in dedicated tests for those UI elements.

More broadly I don't think we need to test every value that can be set using these APIs. Testing each once is fine, since they handle all values in the same way.

Updated this to use an if() so that we avoid the comment, and if you'd prefer to test the eraser case instead of the highlighter we can do that easily. LMK if that's your preference.

Line 154, Patchset 7: manager.setTextColor({r: 0, b: 100, g: 0});
Andy Phan . resolved

Nit: create a `const` to be consistent with the test above. Same with line 159.

Rebekah Potter

Done

Open in Gerrit

Related details

Attention is currently required from:
  • Andy Phan
Submit Requirements:
  • requirement satisfiedCode-Coverage
  • requirement is not satisfiedCode-Review
  • requirement is not satisfiedNo-Unresolved-Comments
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
Gerrit-MessageType: comment
Gerrit-Project: chromium/src
Gerrit-Branch: main
Gerrit-Change-Id: I1ae7e833a4cf0c167b6afac50c28bdb77ed4bad8
Gerrit-Change-Number: 6394083
Gerrit-PatchSet: 8
Gerrit-Owner: Rebekah Potter <rbpo...@chromium.org>
Gerrit-Reviewer: Andy Phan <andy...@chromium.org>
Gerrit-Reviewer: Rebekah Potter <rbpo...@chromium.org>
Gerrit-CC: Chromium Metrics Reviews <chromium-met...@google.com>
Gerrit-Attention: Andy Phan <andy...@chromium.org>
Gerrit-Comment-Date: Fri, 28 Mar 2025 17:59:10 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: Yes
Comment-In-Reply-To: Andy Phan <andy...@chromium.org>
satisfied_requirement
unsatisfied_requirement
open
diffy

Andy Phan (Gerrit)

unread,
Mar 28, 2025, 2:06:39 PM3/28/25
to Rebekah Potter, Chromium Metrics Reviews, AyeAye, Chromium LUCI CQ, chromium...@chromium.org, asvitkine...@chromium.org, chromium-a...@chromium.org, extension...@chromium.org, pdf-r...@chromium.org
Attention needed from Rebekah Potter

Andy Phan voted Code-Review+1

Code-Review+1
Open in Gerrit

Related details

Attention is currently required from:
  • Rebekah Potter
Submit Requirements:
  • requirement satisfiedCode-Coverage
  • requirement satisfiedCode-Review
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
Gerrit-MessageType: comment
Gerrit-Project: chromium/src
Gerrit-Branch: main
Gerrit-Change-Id: I1ae7e833a4cf0c167b6afac50c28bdb77ed4bad8
Gerrit-Change-Number: 6394083
Gerrit-PatchSet: 8
Gerrit-Owner: Rebekah Potter <rbpo...@chromium.org>
Gerrit-Reviewer: Andy Phan <andy...@chromium.org>
Gerrit-Reviewer: Rebekah Potter <rbpo...@chromium.org>
Gerrit-CC: Chromium Metrics Reviews <chromium-met...@google.com>
Gerrit-Attention: Rebekah Potter <rbpo...@chromium.org>
Gerrit-Comment-Date: Fri, 28 Mar 2025 18:06:29 +0000
Gerrit-HasComments: No
Gerrit-Has-Labels: Yes
satisfied_requirement
open
diffy

Andy Phan (Gerrit)

unread,
Mar 28, 2025, 2:06:40 PM3/28/25
to Rebekah Potter, Chromium Metrics Reviews, AyeAye, Chromium LUCI CQ, chromium...@chromium.org, asvitkine...@chromium.org, chromium-a...@chromium.org, extension...@chromium.org, pdf-r...@chromium.org
Attention needed from Rebekah Potter

Andy Phan added 3 comments

File chrome/browser/resources/pdf/constants.ts
Line 44, Patchset 7:export interface TextStyles {
Andy Phan . resolved

Will this be used by multiple files? I think it's only being used in one file and can be moved there.

Rebekah Potter

We can't move only this interface because AnnotationText uses it, and importing the interface back into this file from the manager would create a circular dependency.

AnnotationText itself is indeed only used in the manager in this CL, but will be needed in the next CL in the chain in the new text side panel element. Seems like a lot of churn to put all of these 3 types in the manager for 1 CL only to revert back in its child. Do you want me to combine the 2 CLs instead so that it's clear where this is used (along with the new manager APIs, which are also unused in prod code in this CL)?

Andy Phan

AnnotationText uses it, ...

Ahh, right. It's fine to leave as-is.

File chrome/test/data/pdf/ink2_manager_test.ts
Line 53, Patchset 7: chrome.test.assertEq(expected.type, brushUpdates[index]!.type);
Andy Phan . resolved

Store as a variable and assert this so we don't have to use `!` everytime? Same with line 109.

Rebekah Potter

`!` is fine to use for array elements as long as the length of the array has previously been asserted, which is done on line 52. This is just an issue with TS compiler not realizing that the assertion on line 52 means that this can't be undefined.

Asserting the array length is at least `N` and then using `!` for `array[index]` for `index < N` is standard practice for WebUI tests.

Andy Phan

Ack, thanks.

Line 54, Patchset 7: // Test doesn't currently use eraser, so assert the brush has a color.
Andy Phan . resolved

Should we test eraser?

Rebekah Potter

From the perspective of the manager these two are handled the same way, no? It's testing the setBrushType() API and that it correctly requests the brush from the plugin and then fires an event with that updated brush. There's no difference in handling in Ink2Manager for eraser vs highlighter. Obviously there is a difference in handling in the UI elements, which handle the eraser case differently, but this is a unit test for the manager itself; UI element behavior should be tested in dedicated tests for those UI elements.

More broadly I don't think we need to test every value that can be set using these APIs. Testing each once is fine, since they handle all values in the same way.

Updated this to use an if() so that we avoid the comment, and if you'd prefer to test the eraser case instead of the highlighter we can do that easily. LMK if that's your preference.

Andy Phan

Ack. That makes sense. How it is now is fine.

Open in Gerrit

Related details

Attention is currently required from:
  • Rebekah Potter
Submit Requirements:
  • requirement satisfiedCode-Coverage
  • requirement is not satisfiedCode-Review
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
Gerrit-MessageType: comment
Gerrit-Project: chromium/src
Gerrit-Branch: main
Gerrit-Change-Id: I1ae7e833a4cf0c167b6afac50c28bdb77ed4bad8
Gerrit-Change-Number: 6394083
Gerrit-PatchSet: 8
Gerrit-Owner: Rebekah Potter <rbpo...@chromium.org>
Gerrit-Reviewer: Andy Phan <andy...@chromium.org>
Gerrit-Reviewer: Rebekah Potter <rbpo...@chromium.org>
Gerrit-CC: Chromium Metrics Reviews <chromium-met...@google.com>
Gerrit-Attention: Rebekah Potter <rbpo...@chromium.org>
Gerrit-Comment-Date: Fri, 28 Mar 2025 18:06:24 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
Comment-In-Reply-To: Rebekah Potter <rbpo...@chromium.org>
Comment-In-Reply-To: Andy Phan <andy...@chromium.org>
satisfied_requirement
unsatisfied_requirement
open
diffy

Rebekah Potter (Gerrit)

unread,
Mar 28, 2025, 6:13:50 PM3/28/25
to Andy Phan, Chromium Metrics Reviews, AyeAye, Chromium LUCI CQ, chromium...@chromium.org, asvitkine...@chromium.org, chromium-a...@chromium.org, extension...@chromium.org, pdf-r...@chromium.org

Rebekah Potter voted Commit-Queue+2

Commit-Queue+2
Open in Gerrit

Related details

Attention set is empty
Submit Requirements:
  • requirement satisfiedCode-Coverage
  • requirement satisfiedCode-Review
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
Gerrit-MessageType: comment
Gerrit-Project: chromium/src
Gerrit-Branch: main
Gerrit-Change-Id: I1ae7e833a4cf0c167b6afac50c28bdb77ed4bad8
Gerrit-Change-Number: 6394083
Gerrit-PatchSet: 8
Gerrit-Owner: Rebekah Potter <rbpo...@chromium.org>
Gerrit-Reviewer: Andy Phan <andy...@chromium.org>
Gerrit-Reviewer: Rebekah Potter <rbpo...@chromium.org>
Gerrit-CC: Chromium Metrics Reviews <chromium-met...@google.com>
Gerrit-Comment-Date: Fri, 28 Mar 2025 22:13:38 +0000
Gerrit-HasComments: No
Gerrit-Has-Labels: Yes
satisfied_requirement
open
diffy

Chromium LUCI CQ (Gerrit)

unread,
Mar 28, 2025, 6:16:40 PM3/28/25
to Rebekah Potter, Andy Phan, Chromium Metrics Reviews, AyeAye, chromium...@chromium.org, asvitkine...@chromium.org, chromium-a...@chromium.org, extension...@chromium.org, pdf-r...@chromium.org

Chromium LUCI CQ submitted the change

Change information

Commit message:
[PDF Ink Signatures] Add state management for text annotations

Add methods to set and manage text annotations to the Ink2Manager.

Add a test suite for the class for both existing code and the new
additions.

Note that since backend/frontend communication is still TBD for text
annotations, the manager currently just logs to console.info, instead
of notifying the plugin about changes to text properties.
Bug: 402547554
Change-Id: I1ae7e833a4cf0c167b6afac50c28bdb77ed4bad8
Reviewed-by: Andy Phan <andy...@chromium.org>
Commit-Queue: Rebekah Potter <rbpo...@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1439733}
Files:
  • M chrome/browser/pdf/pdf_extension_js_test.cc
  • M chrome/browser/resources/pdf/constants.ts
  • M chrome/browser/resources/pdf/ink2_manager.ts
  • M chrome/browser/resources/pdf/pdf_viewer_wrapper.ts
  • M chrome/test/data/pdf/BUILD.gn
  • A chrome/test/data/pdf/ink2_manager_test.ts
Change size: L
Delta: 6 files changed, 280 insertions(+), 3 deletions(-)
Branch: refs/heads/main
Submit Requirements:
  • requirement satisfiedCode-Review: +1 by Andy Phan
Open in Gerrit
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
Gerrit-MessageType: merged
Gerrit-Project: chromium/src
Gerrit-Branch: main
Gerrit-Change-Id: I1ae7e833a4cf0c167b6afac50c28bdb77ed4bad8
Gerrit-Change-Number: 6394083
Gerrit-PatchSet: 9
Gerrit-Owner: Rebekah Potter <rbpo...@chromium.org>
Gerrit-Reviewer: Andy Phan <andy...@chromium.org>
Gerrit-Reviewer: Chromium LUCI CQ <chromiu...@luci-project-accounts.iam.gserviceaccount.com>
Gerrit-Reviewer: Rebekah Potter <rbpo...@chromium.org>
open
diffy
satisfied_requirement

Lei Zhang (Gerrit)

unread,
2:20 PM (3 hours ago) 2:20 PM
to Chromium LUCI CQ, Rebekah Potter, Lei Zhang, Andy Phan, Chromium Metrics Reviews, android-bu...@system.gserviceaccount.com, chromium...@chromium.org, asvitkine...@chromium.org, chromium-a...@chromium.org, extension...@chromium.org, pdf-r...@chromium.org

Lei Zhang added 1 comment

File chrome/test/data/pdf/ink2_manager_test.ts
Line 154, Patchset 9 (Latest): const blue = {r: 0, b: 100, g: 0};
Lei Zhang . resolved

I have a CL that fixes this. RBG is confusing.

Open in Gerrit

Related details

Attention set is empty
Submit Requirements:
  • requirement satisfiedCode-Coverage
  • requirement satisfiedCode-Owners
  • requirement satisfiedCode-Review
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
Gerrit-MessageType: comment
Gerrit-Project: chromium/src
Gerrit-Branch: main
Gerrit-Change-Id: I1ae7e833a4cf0c167b6afac50c28bdb77ed4bad8
Gerrit-Change-Number: 6394083
Gerrit-PatchSet: 9
Gerrit-Owner: Rebekah Potter <rbpo...@chromium.org>
Gerrit-Reviewer: Andy Phan <andy...@chromium.org>
Gerrit-Reviewer: Chromium LUCI CQ <chromiu...@luci-project-accounts.iam.gserviceaccount.com>
Gerrit-Reviewer: Rebekah Potter <rbpo...@chromium.org>
Gerrit-CC: Chromium Metrics Reviews <chromium-met...@google.com>
Gerrit-CC: Lei Zhang <the...@chromium.org>
Gerrit-Comment-Date: Mon, 01 Jun 2026 18:20:35 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
satisfied_requirement
open
diffy
Reply all
Reply to author
Forward
0 new messages