Update selectedcontent element to match spec [chromium/src : main]

0 views
Skip to first unread message

David Baron (Gerrit)

unread,
Dec 8, 2025, 3:19:02 PM (4 days ago) Dec 8
to David Baron, AyeAye, Chromium LUCI CQ, blink-re...@chromium.org, blink-revie...@chromium.org, blink-rev...@chromium.org, blink-...@chromium.org, jmedle...@chromium.org, kinuko...@chromium.org
Attention needed from Joey Arhar

David Baron added 9 comments

Commit Message
Line 14, Patchset 6 (Latest):This patch implements the behavior in the spec behind a flag.
David Baron . unresolved

maybe say that the flag is enabled by default, since my default interpretation when reading "behind a flag" is that the flag isn't on yet

File third_party/blink/renderer/core/dom/tree_ordered_list.h
Line 113, Patchset 6 (Latest): for (const T* node : nodes_) {
if (node == node_to_check) {
return true;
}
}
return false;
David Baron . unresolved

Just use the `LinkedHashSet` implementation?

```suggestion
return nodes_.Contains(node_to_check);
```

Although probably also inline it in the class definition at that point?

File third_party/blink/renderer/core/html/forms/html_selected_content_element.cc
Line 53, Patchset 6 (Latest): // <seletedoption> can lead to infinite loops.
David Baron . unresolved
```suggestion
// <selectedcontent> can lead to infinite loops.
```
Line 55, Patchset 6 (Latest): // The HTML spec has a "break" here, but we continue instead because we
David Baron . unresolved

I don't see this "break" in the spec (reading the [post-connection steps](https://html.spec.whatwg.org/multipage/form-elements.html#the-selectedcontent-element:html-element-post-connection-steps)). (Though I also don't see anything that makes the code wrong, just the comment.)

Line 60, Patchset 6 (Latest): }
if (auto* select = DynamicTo<HTMLSelectElement>(ancestor)) {
David Baron . unresolved
```suggestion
} else if (auto* select = DynamicTo<HTMLSelectElement>(ancestor)) {
```
Line 73, Patchset 6 (Latest): if (nearest_ancestor_select_ && !disabled_) {
David Baron . unresolved

This doesn't seem sufficient. If a `<select>` initially has a working `<selectedcontent>`, and then somebody inserts a new one *before* it that the algorithm makes *disabled*, I think we need to update the select at that point so that the previously-working one gets cleared, no? (That said, I'm reading the spec somewhat quickly so I may have missed something.)

Line 85, Patchset 6 (Latest): // <seletedoption> can lead to infinite loops.
David Baron . unresolved
```suggestion
// <selectedcontent> can lead to infinite loops.
```
Line 106, Patchset 6 (Latest): // the spec since the spec doesn't have a dached nearest_ancestor_select_, but
David Baron . unresolved
```suggestion
// the spec since the spec doesn't have a cached nearest_ancestor_select_, but
```
Line 107, Patchset 6 (Latest): // the behavior is the same.
David Baron . unresolved

Is the behavior the same? Won't there be detectable mutations here that the spec says shouldn't happen?

Open in Gerrit

Related details

Attention is currently required from:
  • Joey Arhar
Submit Requirements:
  • requirement satisfiedCode-Coverage
  • requirement 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: I904f83292ec6e6619eb72cdddfc740440edcc753
Gerrit-Change-Number: 7127725
Gerrit-PatchSet: 6
Gerrit-Owner: Joey Arhar <jar...@chromium.org>
Gerrit-Reviewer: David Baron <dba...@chromium.org>
Gerrit-Reviewer: Joey Arhar <jar...@chromium.org>
Gerrit-Attention: Joey Arhar <jar...@chromium.org>
Gerrit-Comment-Date: Mon, 08 Dec 2025 20:18:56 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
satisfied_requirement
unsatisfied_requirement
open
diffy

Joey Arhar (Gerrit)

unread,
Dec 9, 2025, 12:50:01 AM (4 days ago) Dec 9
to David Baron, AyeAye, Chromium LUCI CQ, blink-re...@chromium.org, blink-revie...@chromium.org, blink-rev...@chromium.org, blink-...@chromium.org, jmedle...@chromium.org, kinuko...@chromium.org
Attention needed from David Baron

Joey Arhar added 9 comments

Commit Message
Line 14, Patchset 6 (Latest):This patch implements the behavior in the spec behind a flag.
David Baron . resolved

maybe say that the flag is enabled by default, since my default interpretation when reading "behind a flag" is that the flag isn't on yet

Joey Arhar

good point, i changed the flag to experimental

File third_party/blink/renderer/core/dom/tree_ordered_list.h
Line 113, Patchset 6 (Latest): for (const T* node : nodes_) {
if (node == node_to_check) {
return true;
}
}
return false;
David Baron . resolved

Just use the `LinkedHashSet` implementation?

```suggestion
return nodes_.Contains(node_to_check);
```

Although probably also inline it in the class definition at that point?

Joey Arhar

Done

File third_party/blink/renderer/core/html/forms/html_selected_content_element.cc
Line 53, Patchset 6 (Latest): // <seletedoption> can lead to infinite loops.
David Baron . resolved
```suggestion
// <selectedcontent> can lead to infinite loops.
```
Joey Arhar

Done

Line 55, Patchset 6 (Latest): // The HTML spec has a "break" here, but we continue instead because we
David Baron . unresolved

I don't see this "break" in the spec (reading the [post-connection steps](https://html.spec.whatwg.org/multipage/form-elements.html#the-selectedcontent-element:html-element-post-connection-steps)). (Though I also don't see anything that makes the code wrong, just the comment.)

Joey Arhar

A break is being added here: https://github.com/whatwg/html/pull/11878

I added a link to it in the commit message.

I suppose that I could wait for the PR to be merged first, but I found it helpful to implement in order to review that PR.

Line 60, Patchset 6 (Latest): }
if (auto* select = DynamicTo<HTMLSelectElement>(ancestor)) {
David Baron . resolved
```suggestion
} else if (auto* select = DynamicTo<HTMLSelectElement>(ancestor)) {
```
Joey Arhar

Done

Line 73, Patchset 6 (Latest): if (nearest_ancestor_select_ && !disabled_) {
David Baron . unresolved

This doesn't seem sufficient. If a `<select>` initially has a working `<selectedcontent>`, and then somebody inserts a new one *before* it that the algorithm makes *disabled*, I think we need to update the select at that point so that the previously-working one gets cleared, no? (That said, I'm reading the spec somewhat quickly so I may have missed something.)

Joey Arhar

Without this disabled check, this test will infinitely loop: https://source.chromium.org/chromium/chromium/src/+/main:third_party/blink/web_tests/external/wpt/html/semantics/forms/the-select-element/customizable-select/selectedcontent-in-option-crash.html

I'm not really inclined to make cases like this any less broken since putting a selectedcontent element inside another one or inside an option is not something that anybody should ever do. I can try to make it clear selectedcontent elements without doing any cloning though if you still think we should.

Line 85, Patchset 6 (Latest): // <seletedoption> can lead to infinite loops.
David Baron . resolved
```suggestion
// <selectedcontent> can lead to infinite loops.
```
Joey Arhar

Done

Line 106, Patchset 6 (Latest): // the spec since the spec doesn't have a dached nearest_ancestor_select_, but
David Baron . resolved
```suggestion
// the spec since the spec doesn't have a cached nearest_ancestor_select_, but
```
Joey Arhar

Done

Line 107, Patchset 6 (Latest): // the behavior is the same.
David Baron . unresolved

Is the behavior the same? Won't there be detectable mutations here that the spec says shouldn't happen?

Joey Arhar

I added DCHECKs with logic which more closely matches the spec. How does it look?

Open in Gerrit

Related details

Attention is currently required from:
  • David Baron
Submit Requirements:
  • requirement satisfiedCode-Coverage
  • requirement 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: I904f83292ec6e6619eb72cdddfc740440edcc753
Gerrit-Change-Number: 7127725
Gerrit-PatchSet: 6
Gerrit-Owner: Joey Arhar <jar...@chromium.org>
Gerrit-Reviewer: David Baron <dba...@chromium.org>
Gerrit-Reviewer: Joey Arhar <jar...@chromium.org>
Gerrit-Attention: David Baron <dba...@chromium.org>
Gerrit-Comment-Date: Tue, 09 Dec 2025 05:49:49 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
Comment-In-Reply-To: David Baron <dba...@chromium.org>
satisfied_requirement
unsatisfied_requirement
open
diffy

David Baron (Gerrit)

unread,
Dec 9, 2025, 11:05:01 AM (3 days ago) Dec 9
to David Baron, AyeAye, Chromium LUCI CQ, blink-re...@chromium.org, blink-revie...@chromium.org, blink-rev...@chromium.org, blink-...@chromium.org, jmedle...@chromium.org, kinuko...@chromium.org
Attention needed from Joey Arhar

David Baron added 1 comment

File third_party/blink/renderer/core/html/forms/html_selected_content_element.cc
Line 73, Patchset 6: if (nearest_ancestor_select_ && !disabled_) {
David Baron . unresolved

This doesn't seem sufficient. If a `<select>` initially has a working `<selectedcontent>`, and then somebody inserts a new one *before* it that the algorithm makes *disabled*, I think we need to update the select at that point so that the previously-working one gets cleared, no? (That said, I'm reading the spec somewhat quickly so I may have missed something.)

Joey Arhar

Without this disabled check, this test will infinitely loop: https://source.chromium.org/chromium/chromium/src/+/main:third_party/blink/web_tests/external/wpt/html/semantics/forms/the-select-element/customizable-select/selectedcontent-in-option-crash.html

I'm not really inclined to make cases like this any less broken since putting a selectedcontent element inside another one or inside an option is not something that anybody should ever do. I can try to make it clear selectedcontent elements without doing any cloning though if you still think we should.

David Baron

As I commented on the PR, would it make sense here if we have a separate `updateSelect` boolean that gets set to `false` if we make the `selectedcontent` `disabled` because of the `selectedcontent` ancestor check, but not if it's because of the `option` ancestor check?

(Also, I'm still thinking about the multiple-select-ancestors case; I just realized the spec is wrong there and I need to make another comment on the PR!)

Open in Gerrit

Related details

Attention is currently required from:
  • Joey Arhar
Submit Requirements:
  • requirement satisfiedCode-Coverage
  • requirement 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: I904f83292ec6e6619eb72cdddfc740440edcc753
Gerrit-Change-Number: 7127725
Gerrit-PatchSet: 7
Gerrit-Owner: Joey Arhar <jar...@chromium.org>
Gerrit-Reviewer: David Baron <dba...@chromium.org>
Gerrit-Reviewer: Joey Arhar <jar...@chromium.org>
Gerrit-Attention: Joey Arhar <jar...@chromium.org>
Gerrit-Comment-Date: Tue, 09 Dec 2025 16:04:50 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
Comment-In-Reply-To: Joey Arhar <jar...@chromium.org>
Comment-In-Reply-To: David Baron <dba...@chromium.org>
satisfied_requirement
unsatisfied_requirement
open
diffy

Joey Arhar (Gerrit)

unread,
Dec 11, 2025, 7:48:26 PM (yesterday) Dec 11
to David Baron, AyeAye, Chromium LUCI CQ, blink-re...@chromium.org, blink-revie...@chromium.org, blink-rev...@chromium.org, blink-...@chromium.org, jmedle...@chromium.org, kinuko...@chromium.org
Attention needed from David Baron

Joey Arhar added 1 comment

File third_party/blink/renderer/core/html/forms/html_selected_content_element.cc
Line 73, Patchset 6: if (nearest_ancestor_select_ && !disabled_) {
David Baron . unresolved

This doesn't seem sufficient. If a `<select>` initially has a working `<selectedcontent>`, and then somebody inserts a new one *before* it that the algorithm makes *disabled*, I think we need to update the select at that point so that the previously-working one gets cleared, no? (That said, I'm reading the spec somewhat quickly so I may have missed something.)

Joey Arhar

Without this disabled check, this test will infinitely loop: https://source.chromium.org/chromium/chromium/src/+/main:third_party/blink/web_tests/external/wpt/html/semantics/forms/the-select-element/customizable-select/selectedcontent-in-option-crash.html

I'm not really inclined to make cases like this any less broken since putting a selectedcontent element inside another one or inside an option is not something that anybody should ever do. I can try to make it clear selectedcontent elements without doing any cloning though if you still think we should.

David Baron

As I commented on the PR, would it make sense here if we have a separate `updateSelect` boolean that gets set to `false` if we make the `selectedcontent` `disabled` because of the `selectedcontent` ancestor check, but not if it's because of the `option` ancestor check?

(Also, I'm still thinking about the multiple-select-ancestors case; I just realized the spec is wrong there and I need to make another comment on the PR!)

Joey Arhar

I tried adding an updateSelect boolean, but it still makes selectedcontent-in-option-crash.html have an infinite loop. I can debug and provide more context, but does it look like I implemented it correctly in the latest patch set?

Open in Gerrit

Related details

Attention is currently required from:
  • David Baron
Submit Requirements:
  • requirement satisfiedCode-Coverage
  • requirement 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: I904f83292ec6e6619eb72cdddfc740440edcc753
Gerrit-Change-Number: 7127725
Gerrit-PatchSet: 7
Gerrit-Owner: Joey Arhar <jar...@chromium.org>
Gerrit-Reviewer: David Baron <dba...@chromium.org>
Gerrit-Reviewer: Joey Arhar <jar...@chromium.org>
Gerrit-Attention: David Baron <dba...@chromium.org>
Gerrit-Comment-Date: Fri, 12 Dec 2025 00:48:15 +0000
satisfied_requirement
unsatisfied_requirement
open
diffy

David Baron (Gerrit)

unread,
12:15 PM (8 hours ago) 12:15 PM
to David Baron, AyeAye, Chromium LUCI CQ, blink-re...@chromium.org, blink-revie...@chromium.org, blink-rev...@chromium.org, blink-...@chromium.org, jmedle...@chromium.org, kinuko...@chromium.org
Attention needed from Joey Arhar

David Baron added 1 comment

File third_party/blink/renderer/core/html/forms/html_selected_content_element.cc
Line 55, Patchset 6: // The HTML spec has a "break" here, but we continue instead because we
David Baron . unresolved

I don't see this "break" in the spec (reading the [post-connection steps](https://html.spec.whatwg.org/multipage/form-elements.html#the-selectedcontent-element:html-element-post-connection-steps)). (Though I also don't see anything that makes the code wrong, just the comment.)

Joey Arhar

A break is being added here: https://github.com/whatwg/html/pull/11878

I added a link to it in the commit message.

I suppose that I could wait for the PR to be merged first, but I found it helpful to implement in order to review that PR.

David Baron

I think it's also probably ok to set `update_select` to false in the case a few lines lower where you set `disabled_` to true because of nested selects.

(I think the case where updating is clearly needed is the case where you're inserting a `<selectedcontent>` inside an `<option>`.)

Open in Gerrit

Related details

Attention is currently required from:
  • Joey Arhar
Submit Requirements:
  • requirement satisfiedCode-Coverage
  • requirement 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: I904f83292ec6e6619eb72cdddfc740440edcc753
Gerrit-Change-Number: 7127725
Gerrit-PatchSet: 9
Gerrit-Owner: Joey Arhar <jar...@chromium.org>
Gerrit-Reviewer: David Baron <dba...@chromium.org>
Gerrit-Reviewer: Joey Arhar <jar...@chromium.org>
Gerrit-Attention: Joey Arhar <jar...@chromium.org>
Gerrit-Comment-Date: Fri, 12 Dec 2025 17:15:31 +0000
satisfied_requirement
unsatisfied_requirement
open
diffy
Reply all
Reply to author
Forward
0 new messages