Track autofillable elements using the TrackedElement framework [chromium/src : main]

0 views
Skip to first unread message

Nan Lin (Gerrit)

unread,
May 27, 2026, 9:27:06 AM (5 days ago) May 27
to Khushal Sagar, Chromium LUCI CQ, android-bu...@system.gserviceaccount.com, chromium...@chromium.org, blink-rev...@chromium.org, blink-...@chromium.org, cc-...@chromium.org, jmedle...@chromium.org, kinuko...@chromium.org
Attention needed from Khushal Sagar

Nan Lin added 2 comments

Patchset-level comments
File-level comment, Patchset 6 (Latest):
Nan Lin . resolved

Hi Khushal, could you PTAL, thanks!

File third_party/blink/renderer/core/html/forms/html_form_control_element.cc
Line 137, Patchset 6 (Latest): UpdateAutofillableElementTracking();
Nan Lin . unresolved

We can't do this in the constructor, as it will call the pure virtual function HTMLFormControlElement::FormControlType(().

Open in Gerrit

Related details

Attention is currently required from:
  • Khushal Sagar
Submit Requirements:
  • requirement satisfiedCode-Coverage
  • requirement is not satisfiedCode-Owners
  • requirement is not satisfiedCode-Review
  • requirement is not satisfiedNo-Unresolved-Comments
  • requirement is not satisfiedReview-Enforcement
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: I24160bea69ffb60e9f097c3c0018965cefd45c6f
Gerrit-Change-Number: 7877684
Gerrit-PatchSet: 6
Gerrit-Owner: Nan Lin <lin...@chromium.org>
Gerrit-Reviewer: Khushal Sagar <khusha...@chromium.org>
Gerrit-Reviewer: Nan Lin <lin...@chromium.org>
Gerrit-Attention: Khushal Sagar <khusha...@chromium.org>
Gerrit-Comment-Date: Wed, 27 May 2026 13:26:57 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
satisfied_requirement
unsatisfied_requirement
open
diffy

Khushal Sagar (Gerrit)

unread,
May 29, 2026, 9:45:33 PM (3 days ago) May 29
to Nan Lin, Chromium LUCI CQ, android-bu...@system.gserviceaccount.com, chromium...@chromium.org, blink-rev...@chromium.org, blink-...@chromium.org, cc-...@chromium.org, jmedle...@chromium.org, kinuko...@chromium.org
Attention needed from Nan Lin

Khushal Sagar added 5 comments

File third_party/blink/renderer/core/html/forms/html_form_control_element.cc
Line 273, Patchset 6 (Latest):bool HTMLFormControlElement::ShouldTrackAutofillableElement() const {
Khushal Sagar . unresolved

nit: IsEligibleForAutofillableElementTracking? Because this is deciding if the element should be considered for tracking but whether we should actually track depends on the runtime feature check you have below.

Line 274, Patchset 6 (Latest): return IsAutofillable();
Khushal Sagar . unresolved

Since this depends on autofillable state changing, UpdateAutofillableElementTracking() needs to be called whenever that state changes. Does blink get a callback for it?

All the tests here are manually calling UpdateAutofillableElementTracking() after that bit flips but what will call this in production?

Line 288, Patchset 6 (Latest): // We only need to track the element if it's rendered.
Khushal Sagar . unresolved

Does it matter? If it's not in the layout it won't be in the painted content anyway. That avoids having to call the update function when the layout state changes.

File third_party/blink/renderer/core/html/forms/html_select_element.h
Line 440, Patchset 6 (Latest): // TODO(b/469401911): Handle <select> related data as well.
Khushal Sagar . unresolved

What special case do we need for select element? Is there a scenario where it should be redacted even if its not autofillable?

File third_party/blink/renderer/core/html/forms/html_select_element.cc
Line 1263, Patchset 6 (Latest): UpdateAutofillableElementTracking();
Khushal Sagar . unresolved

I'm not following why this needs to be called here...

Open in Gerrit

Related details

Attention is currently required from:
  • Nan Lin
Submit Requirements:
  • requirement satisfiedCode-Coverage
  • requirement is not satisfiedCode-Owners
  • requirement is not satisfiedCode-Review
  • requirement is not satisfiedNo-Unresolved-Comments
  • requirement is not satisfiedReview-Enforcement
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: I24160bea69ffb60e9f097c3c0018965cefd45c6f
Gerrit-Change-Number: 7877684
Gerrit-PatchSet: 6
Gerrit-Owner: Nan Lin <lin...@chromium.org>
Gerrit-Reviewer: Khushal Sagar <khusha...@chromium.org>
Gerrit-Reviewer: Nan Lin <lin...@chromium.org>
Gerrit-Attention: Nan Lin <lin...@chromium.org>
Gerrit-Comment-Date: Sat, 30 May 2026 01:45:20 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
satisfied_requirement
unsatisfied_requirement
open
diffy

Nan Lin (Gerrit)

unread,
10:15 AM (5 hours ago) 10:15 AM
to Khushal Sagar, Chromium LUCI CQ, android-bu...@system.gserviceaccount.com, chromium...@chromium.org, blink-rev...@chromium.org, blink-...@chromium.org, cc-...@chromium.org, jmedle...@chromium.org, kinuko...@chromium.org
Attention needed from Khushal Sagar

Nan Lin added 6 comments

Patchset-level comments
File-level comment, Patchset 6:
Nan Lin . resolved

Thanks!

File third_party/blink/renderer/core/html/forms/html_form_control_element.cc
Line 273, Patchset 6:bool HTMLFormControlElement::ShouldTrackAutofillableElement() const {
Khushal Sagar . resolved

nit: IsEligibleForAutofillableElementTracking? Because this is deciding if the element should be considered for tracking but whether we should actually track depends on the runtime feature check you have below.

Nan Lin

This was to align with ShouldTrackPassword(), I'll rename that as well. Thanks.

Line 274, Patchset 6: return IsAutofillable();
Khushal Sagar . unresolved

Since this depends on autofillable state changing, UpdateAutofillableElementTracking() needs to be called whenever that state changes. Does blink get a callback for it?

All the tests here are manually calling UpdateAutofillableElementTracking() after that bit flips but what will call this in production?

Nan Lin

`InAutofillable()` eventually calls [`GetAutofillFormControlType()`](https://source.chromium.org/chromium/chromium/src/+/main:components/autofill/content/renderer/form_autofill_util.cc;drc=5acb55861d6ffcd18e43831faccba49abbfef0b7;l=2364?q=IsAutofillable&ss=chromium) which depends on the input type. The bit is flipped manually in the unit tests as the autofill client is not available. On production,`UpdateAutofillableElementTracking()` will be called whenever the form control type may change.

Line 288, Patchset 6: // We only need to track the element if it's rendered.
Khushal Sagar . unresolved

Does it matter? If it's not in the layout it won't be in the painted content anyway. That avoids having to call the update function when the layout state changes.

Nan Lin

It doesn't really matter. But as noted in https://chromium-review.git.corp.google.com/c/chromium/src/+/7877684/comment/2e09035f_61fb95be/, unfortunately we can't do this in the constructor, as it will call the pure virtual function `HTMLFormControlElement::FormControlType()`. Or is there a better code path to trigger this?

File third_party/blink/renderer/core/html/forms/html_select_element.h
Line 440, Patchset 6: // TODO(b/469401911): Handle <select> related data as well.
Khushal Sagar . unresolved

What special case do we need for select element? Is there a scenario where it should be redacted even if its not autofillable?

Nan Lin

This is mostly to align with the APC redaction which currently doesn't redact the select element. https://source.chromium.org/chromium/chromium/src/+/main:components/optimization_guide/content/browser/page_content_proto_util.cc;l=691?q=page_content_proto_util.cc&ss=chromium

To be consistent, the redaction of APC and screenshot should be in sync.

File third_party/blink/renderer/core/html/forms/html_select_element.cc
Line 1263, Patchset 6: UpdateAutofillableElementTracking();
Khushal Sagar . unresolved

I'm not following why this needs to be called here...

Nan Lin

Since `IsAutofillable()` depends on the form control type. We call this here as single and multiple selects have different form control types. Although selects are not actually tracked yet, I think we should still call it here to avoid future errors.

Open in Gerrit

Related details

Attention is currently required from:
  • Khushal Sagar
Submit Requirements:
  • requirement satisfiedCode-Coverage
  • requirement is not satisfiedCode-Owners
  • requirement is not satisfiedCode-Review
  • requirement is not satisfiedNo-Unresolved-Comments
  • requirement is not satisfiedReview-Enforcement
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: I24160bea69ffb60e9f097c3c0018965cefd45c6f
Gerrit-Change-Number: 7877684
Gerrit-PatchSet: 7
Gerrit-Attention: Khushal Sagar <khusha...@chromium.org>
Gerrit-Comment-Date: Mon, 01 Jun 2026 14:15:07 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
Comment-In-Reply-To: Khushal Sagar <khusha...@chromium.org>
satisfied_requirement
unsatisfied_requirement
open
diffy

Khushal Sagar (Gerrit)

unread,
2:40 PM (1 hour ago) 2:40 PM
to Nan Lin, Chromium LUCI CQ, android-bu...@system.gserviceaccount.com, chromium...@chromium.org, blink-rev...@chromium.org, blink-...@chromium.org, cc-...@chromium.org, jmedle...@chromium.org, kinuko...@chromium.org
Attention needed from Nan Lin

Khushal Sagar added 4 comments

File third_party/blink/renderer/core/html/forms/html_form_control_element.cc
Line 137, Patchset 6: UpdateAutofillableElementTracking();
Nan Lin . unresolved

We can't do this in the constructor, as it will call the pure virtual function HTMLFormControlElement::FormControlType(().

Khushal Sagar

It should be handled by the code that changes `IsAutofillable()` since the element is going to start off as not autofillable anyway. So we shouldn't need to call it at creation at all.

Line 274, Patchset 6: return IsAutofillable();
Khushal Sagar . unresolved

Since this depends on autofillable state changing, UpdateAutofillableElementTracking() needs to be called whenever that state changes. Does blink get a callback for it?

All the tests here are manually calling UpdateAutofillableElementTracking() after that bit flips but what will call this in production?

Nan Lin

`InAutofillable()` eventually calls [`GetAutofillFormControlType()`](https://source.chromium.org/chromium/chromium/src/+/main:components/autofill/content/renderer/form_autofill_util.cc;drc=5acb55861d6ffcd18e43831faccba49abbfef0b7;l=2364?q=IsAutofillable&ss=chromium) which depends on the input type. The bit is flipped manually in the unit tests as the autofill client is not available. On production,`UpdateAutofillableElementTracking()` will be called whenever the form control type may change.

Khushal Sagar

Can you add the production logic for dispatching UpdateAutofillableElementTracking() within this CL?

I see that whether an element is autofillable is outside Blink [here](https://source.chromium.org/chromium/chromium/src/+/main:components/autofill/content/renderer/form_autofill_util.cc;l=2364;drc=5dcb514d2b27639844ebb3acffd720651faa435d). It's based on the element's type but that's an internal detail of the autofill code. It's not a good idea to bake any assumptions about that here. So I like the idea of blink just getting a callback when autofill state has been invalidated.

File third_party/blink/renderer/core/html/forms/html_select_element.h
Line 440, Patchset 6: // TODO(b/469401911): Handle <select> related data as well.
Khushal Sagar . unresolved

What special case do we need for select element? Is there a scenario where it should be redacted even if its not autofillable?

Nan Lin

This is mostly to align with the APC redaction which currently doesn't redact the select element. https://source.chromium.org/chromium/chromium/src/+/main:components/optimization_guide/content/browser/page_content_proto_util.cc;l=691?q=page_content_proto_util.cc&ss=chromium

To be consistent, the redaction of APC and screenshot should be in sync.

Khushal Sagar

What's final data structure being sent via TrackedElement? I can see a couple of options:

1. The renderer sends all information necessary to make the decision (including that its a select element), and the browser combines it with its own information to make the final decision. This would align closer to how APC based redaction is working, in case we shouldn't need to special-case select elements here. That logic can live in one place in the browser.

2. The renderer makes the redaction decision and only tracks elements which must be redacted if in the screenshot.

I think you're going with #1? Do you mind putting up a CL which uses the tracked element data to redact in the browser code. That'll help me see the full picture.

File third_party/blink/renderer/core/html/forms/html_select_element.cc
Line 1263, Patchset 6: UpdateAutofillableElementTracking();
Khushal Sagar . unresolved

I'm not following why this needs to be called here...

Nan Lin

Since `IsAutofillable()` depends on the form control type. We call this here as single and multiple selects have different form control types. Although selects are not actually tracked yet, I think we should still call it here to avoid future errors.

Khushal Sagar

See comment above, it's brittle to have this assumption in blink code: IsAutofillable depends on form control type. That detail is hidden behind the chrome_client API and blink shouldn't know when that state could have changed.

Does the autofill code already get a callback when the form control type has changed? Ideally autofill code should get calls about events it needs to know about to track autofill state. And Blink should get one callback saying, "autofillability for this element has changed".

Open in Gerrit

Related details

Attention is currently required from:
  • Nan Lin
Submit Requirements:
  • requirement satisfiedCode-Coverage
  • requirement is not satisfiedCode-Owners
  • requirement is not satisfiedCode-Review
  • requirement is not satisfiedNo-Unresolved-Comments
  • requirement is not satisfiedReview-Enforcement
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: I24160bea69ffb60e9f097c3c0018965cefd45c6f
Gerrit-Change-Number: 7877684
Gerrit-PatchSet: 7
Gerrit-Owner: Nan Lin <lin...@chromium.org>
Gerrit-Reviewer: Khushal Sagar <khusha...@chromium.org>
Gerrit-Reviewer: Nan Lin <lin...@chromium.org>
Gerrit-Attention: Nan Lin <lin...@chromium.org>
Gerrit-Comment-Date: Mon, 01 Jun 2026 18:39:56 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
Comment-In-Reply-To: Nan Lin <lin...@chromium.org>
Comment-In-Reply-To: Khushal Sagar <khusha...@chromium.org>
satisfied_requirement
unsatisfied_requirement
open
diffy

Nan Lin (Gerrit)

unread,
2:44 PM (1 hour ago) 2:44 PM
to Khushal Sagar, Chromium LUCI CQ, android-bu...@system.gserviceaccount.com, chromium...@chromium.org, blink-rev...@chromium.org, blink-...@chromium.org, cc-...@chromium.org, jmedle...@chromium.org, kinuko...@chromium.org
Attention needed from Christoph Schwering and Khushal Sagar

Nan Lin added 1 comment

File third_party/blink/renderer/core/html/forms/html_select_element.cc
Line 1263, Patchset 6: UpdateAutofillableElementTracking();
Khushal Sagar . unresolved

I'm not following why this needs to be called here...

Nan Lin

Since `IsAutofillable()` depends on the form control type. We call this here as single and multiple selects have different form control types. Although selects are not actually tracked yet, I think we should still call it here to avoid future errors.

Khushal Sagar

See comment above, it's brittle to have this assumption in blink code: IsAutofillable depends on form control type. That detail is hidden behind the chrome_client API and blink shouldn't know when that state could have changed.

Does the autofill code already get a callback when the form control type has changed? Ideally autofill code should get calls about events it needs to know about to track autofill state. And Blink should get one callback saying, "autofillability for this element has changed".

Nan Lin

@schw...@google.com Would you mind chiming in here? Is there a way for blink to get a callback when `IsAutofillableElement()` changes on the autofill side? Thanks.

Open in Gerrit

Related details

Attention is currently required from:
  • Christoph Schwering
  • Khushal Sagar
Submit Requirements:
  • requirement satisfiedCode-Coverage
  • requirement is not satisfiedCode-Owners
  • requirement is not satisfiedCode-Review
  • requirement is not satisfiedNo-Unresolved-Comments
  • requirement is not satisfiedReview-Enforcement
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: I24160bea69ffb60e9f097c3c0018965cefd45c6f
Gerrit-Change-Number: 7877684
Gerrit-PatchSet: 7
Gerrit-Owner: Nan Lin <lin...@chromium.org>
Gerrit-Reviewer: Khushal Sagar <khusha...@chromium.org>
Gerrit-Reviewer: Nan Lin <lin...@chromium.org>
Gerrit-CC: Christoph Schwering <schw...@google.com>
Gerrit-Attention: Khushal Sagar <khusha...@chromium.org>
Gerrit-Attention: Christoph Schwering <schw...@google.com>
Gerrit-Comment-Date: Mon, 01 Jun 2026 18:43:56 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
Comment-In-Reply-To: Khushal Sagar <khusha...@chromium.org>
Comment-In-Reply-To: Nan Lin <lin...@chromium.org>
satisfied_requirement
unsatisfied_requirement
open
diffy

Nan Lin (Gerrit)

unread,
3:00 PM (1 hour ago) 3:00 PM
to Khushal Sagar, Chromium LUCI CQ, android-bu...@system.gserviceaccount.com, chromium...@chromium.org, blink-rev...@chromium.org, blink-...@chromium.org, cc-...@chromium.org, jmedle...@chromium.org, kinuko...@chromium.org
Attention needed from Christoph Schwering and Khushal Sagar

Nan Lin added 1 comment

File third_party/blink/renderer/core/html/forms/html_select_element.cc
Line 1263, Patchset 6: UpdateAutofillableElementTracking();
Khushal Sagar . unresolved

I'm not following why this needs to be called here...

Nan Lin

Since `IsAutofillable()` depends on the form control type. We call this here as single and multiple selects have different form control types. Although selects are not actually tracked yet, I think we should still call it here to avoid future errors.

Khushal Sagar

See comment above, it's brittle to have this assumption in blink code: IsAutofillable depends on form control type. That detail is hidden behind the chrome_client API and blink shouldn't know when that state could have changed.

Does the autofill code already get a callback when the form control type has changed? Ideally autofill code should get calls about events it needs to know about to track autofill state. And Blink should get one callback saying, "autofillability for this element has changed".

Nan Lin

@schw...@google.com Would you mind chiming in here? Is there a way for blink to get a callback when `IsAutofillableElement()` changes on the autofill side? Thanks.

Nan Lin

Based on code search, I don't find a dedicated callback from Blink within the autofill component for when a form control's type attribute changes. @schw...@google.com may know this better and hopefully can give some suggestions here.

Gerrit-Comment-Date: Mon, 01 Jun 2026 19:00:02 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
satisfied_requirement
unsatisfied_requirement
open
diffy
Reply all
Reply to author
Forward
0 new messages