Optimize HTMLSelectElement descendant tracking [chromium/src : main]

0 views
Skip to first unread message

chromeperf@appspot.gserviceaccount.com (Gerrit)

unread,
Jun 18, 2026, 3:47:14 PM (14 days ago) Jun 18
to android-bu...@system.gserviceaccount.com, Chromium LUCI CQ, blink-rev...@chromium.org, blink-...@chromium.org
Attention needed from Joey Arhar

Message from chrom...@appspot.gserviceaccount.com

📍 Job linux-r350-perf/blink_perf.dom complete.

  • select-multiple-add: base median = 2693.782215610561 -> patched median = 3305.875538046479


See results at: https://pinpoint-dot-chromeperf.appspot.com/job/12e7ed9cc90000

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 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: I26a368a056a98fef29236ddb33325fa898cb4ac6
Gerrit-Change-Number: 7963187
Gerrit-PatchSet: 1
Gerrit-Owner: Joey Arhar <jar...@chromium.org>
Gerrit-Reviewer: Joey Arhar <jar...@chromium.org>
Gerrit-Attention: Joey Arhar <jar...@chromium.org>
Gerrit-Comment-Date: Thu, 18 Jun 2026 19:46:55 +0000
Gerrit-HasComments: No
Gerrit-Has-Labels: No
satisfied_requirement
unsatisfied_requirement
open
diffy

Mason Freed (Gerrit)

unread,
Jun 24, 2026, 8:50:39 PM (7 days ago) Jun 24
to chrom...@appspot.gserviceaccount.com, android-bu...@system.gserviceaccount.com, Chromium LUCI CQ, blink-rev...@chromium.org, blink-...@chromium.org
Attention needed from Joey Arhar

Mason Freed voted and added 13 comments

Votes added by Mason Freed

Code-Review+1

13 comments

Patchset-level comments
File-level comment, Patchset 2 (Latest):
Mason Freed . resolved

Looks good to me - just nits and maybe a test add.

File third_party/blink/renderer/core/html/forms/html_select_element.h
Line 565, Patchset 2 (Latest): // multiple are inserted or removed. As an optimization, children which are
// actually option or input elements are not included in this map.
Mason Freed . unresolved

nit: `children which themselves are option or input elements`

File third_party/blink/renderer/core/html/forms/html_select_element.cc
Line 2228, Patchset 2 (Latest): auto it = children_descendant_counts_map_.find(nearest_ancestor_select_child);
Mason Freed . unresolved

Does this need line wrapping?

File third_party/blink/renderer/core/html/forms/html_select_element_test.cc
Line 1150, Patchset 2 (Latest):
Mason Freed . unresolved

{From review agent}

Consider adding a test case to explicitly validate what happens when a node is moved from being a grandchild to a direct child. This will help prevent future regressions.

```
// Move input from grand-child to direct child
auto* c3i = GetElementById("c3i");
select->appendChild(c3i);

// The input is a direct child, so it shouldn't be in the map
EXPECT_FALSE(select->ChildrenDescendantCounts().Contains(c3i));
// The wrapper c3 should no longer have any inputs tracked
EXPECT_EQ(select->ChildrenDescendantCounts().at(c3).num_inputs, 0);
// The wrapper c3 still has its option
EXPECT_EQ(select->ChildrenDescendantCounts().at(c3).num_options, 1);
// The total number of descendant inputs should remain unchanged
EXPECT_EQ(select->NumDescendantInputs(), 2);

// Ensure the DOM and slots are still correct
GetDocument().UpdateStyleAndLayout(DocumentUpdateReason::kTest);
EXPECT_EQ(c3i->AssignedSlot(), input_slot());
```
Line 1229, Patchset 2 (Latest):
Mason Freed . unresolved

Consider adding a test case to explicitly validate what happens when a node is moved from being a grandchild to a direct child. This will help prevent future regressions.

```cpp
// Move input from grand-child to direct child
auto* c3i = GetElementById("c3i");
select->appendChild(c3i);

// The input is a direct child, so it shouldn't be in the map
EXPECT_FALSE(select->ChildrenDescendantCounts().Contains(c3i));
// The wrapper c3 should no longer have any inputs tracked
EXPECT_EQ(select->ChildrenDescendantCounts().at(c3).num_inputs, 0);
// The wrapper c3 still has its option
EXPECT_EQ(select->ChildrenDescendantCounts().at(c3).num_options, 1);
// The total number of descendant inputs should remain unchanged
EXPECT_EQ(select->NumDescendantInputs(), 2);

// Ensure the DOM and slots are still correct
GetDocument().UpdateStyleAndLayout(DocumentUpdateReason::kTest);
EXPECT_EQ(c3i->AssignedSlot(), input_slot());
```
Line 1229, Patchset 2 (Latest):
Mason Freed . unresolved

Consider adding a test case to explicitly validate what happens when a node is moved from being a grandchild to a direct child. This will help prevent future regressions.

```cpp
// Move input from grand-child to direct child
auto* c3i = GetElementById("c3i");
select->appendChild(c3i);

// The input is a direct child, so it shouldn't be in the map
EXPECT_FALSE(select->ChildrenDescendantCounts().Contains(c3i));
// The wrapper c3 should no longer have any inputs tracked
EXPECT_EQ(select->ChildrenDescendantCounts().at(c3).num_inputs, 0);
// The wrapper c3 still has its option
EXPECT_EQ(select->ChildrenDescendantCounts().at(c3).num_options, 1);
// The total number of descendant inputs should remain unchanged
EXPECT_EQ(select->NumDescendantInputs(), 2);

// Ensure the DOM and slots are still correct
GetDocument().UpdateStyleAndLayout(DocumentUpdateReason::kTest);
EXPECT_EQ(c3i->AssignedSlot(), input_slot());
```
Line 1229, Patchset 2 (Latest):
Mason Freed . unresolved

Consider adding a test case to explicitly validate what happens when a node is moved from being a grandchild to a direct child. This will help prevent future regressions.

```cpp
// Move input from grand-child to direct child
auto* c3i = GetElementById("c3i");
select->appendChild(c3i);

// The input is a direct child, so it shouldn't be in the map
EXPECT_FALSE(select->ChildrenDescendantCounts().Contains(c3i));
// The wrapper c3 should no longer have any inputs tracked
EXPECT_EQ(select->ChildrenDescendantCounts().at(c3).num_inputs, 0);
// The wrapper c3 still has its option
EXPECT_EQ(select->ChildrenDescendantCounts().at(c3).num_options, 1);
// The total number of descendant inputs should remain unchanged
EXPECT_EQ(select->NumDescendantInputs(), 2);

// Ensure the DOM and slots are still correct
GetDocument().UpdateStyleAndLayout(DocumentUpdateReason::kTest);
EXPECT_EQ(c3i->AssignedSlot(), input_slot());
```
Line 1229, Patchset 2 (Latest):
Mason Freed . unresolved

Consider adding a test case to explicitly validate what happens when a node is moved from being a grandchild to a direct child. This will help prevent future regressions.

```cpp
// Move input from grand-child to direct child
auto* c3i = GetElementById("c3i");
select->appendChild(c3i);

// The input is a direct child, so it shouldn't be in the map
EXPECT_FALSE(select->ChildrenDescendantCounts().Contains(c3i));
// The wrapper c3 should no longer have any inputs tracked
EXPECT_EQ(select->ChildrenDescendantCounts().at(c3).num_inputs, 0);
// The wrapper c3 still has its option
EXPECT_EQ(select->ChildrenDescendantCounts().at(c3).num_options, 1);
// The total number of descendant inputs should remain unchanged
EXPECT_EQ(select->NumDescendantInputs(), 2);

// Ensure the DOM and slots are still correct
GetDocument().UpdateStyleAndLayout(DocumentUpdateReason::kTest);
EXPECT_EQ(c3i->AssignedSlot(), input_slot());
```
Line 1229, Patchset 2 (Latest):
Mason Freed . unresolved

Consider adding a test case to explicitly validate what happens when a node is moved from being a grandchild to a direct child. This will help prevent future regressions.

```cpp
// Move input from grand-child to direct child
auto* c3i = GetElementById("c3i");
select->appendChild(c3i);

// The input is a direct child, so it shouldn't be in the map
EXPECT_FALSE(select->ChildrenDescendantCounts().Contains(c3i));
// The wrapper c3 should no longer have any inputs tracked
EXPECT_EQ(select->ChildrenDescendantCounts().at(c3).num_inputs, 0);
// The wrapper c3 still has its option
EXPECT_EQ(select->ChildrenDescendantCounts().at(c3).num_options, 1);
// The total number of descendant inputs should remain unchanged
EXPECT_EQ(select->NumDescendantInputs(), 2);

// Ensure the DOM and slots are still correct
GetDocument().UpdateStyleAndLayout(DocumentUpdateReason::kTest);
EXPECT_EQ(c3i->AssignedSlot(), input_slot());
```
Line 1229, Patchset 2 (Latest):
Mason Freed . unresolved

Consider adding a test case to explicitly validate what happens when a node is moved from being a grandchild to a direct child. This will help prevent future regressions.

```cpp
// Move input from grand-child to direct child
auto* c3i = GetElementById("c3i");
select->appendChild(c3i);

// The input is a direct child, so it shouldn't be in the map
EXPECT_FALSE(select->ChildrenDescendantCounts().Contains(c3i));
// The wrapper c3 should no longer have any inputs tracked
EXPECT_EQ(select->ChildrenDescendantCounts().at(c3).num_inputs, 0);
// The wrapper c3 still has its option
EXPECT_EQ(select->ChildrenDescendantCounts().at(c3).num_options, 1);
// The total number of descendant inputs should remain unchanged
EXPECT_EQ(select->NumDescendantInputs(), 2);

// Ensure the DOM and slots are still correct
GetDocument().UpdateStyleAndLayout(DocumentUpdateReason::kTest);
EXPECT_EQ(c3i->AssignedSlot(), input_slot());
```
Line 1229, Patchset 2 (Latest):
Mason Freed . unresolved

Consider adding a test case to explicitly validate what happens when a node is moved from being a grandchild to a direct child. This will help prevent future regressions.

```cpp
// Move input from grand-child to direct child
auto* c3i = GetElementById("c3i");
select->appendChild(c3i);

// The input is a direct child, so it shouldn't be in the map
EXPECT_FALSE(select->ChildrenDescendantCounts().Contains(c3i));
// The wrapper c3 should no longer have any inputs tracked
EXPECT_EQ(select->ChildrenDescendantCounts().at(c3).num_inputs, 0);
// The wrapper c3 still has its option
EXPECT_EQ(select->ChildrenDescendantCounts().at(c3).num_options, 1);
// The total number of descendant inputs should remain unchanged
EXPECT_EQ(select->NumDescendantInputs(), 2);

// Ensure the DOM and slots are still correct
GetDocument().UpdateStyleAndLayout(DocumentUpdateReason::kTest);
EXPECT_EQ(c3i->AssignedSlot(), input_slot());
```
Line 1229, Patchset 2 (Latest):
Mason Freed . unresolved

Consider adding a test case to explicitly validate what happens when a node is moved from being a grandchild to a direct child. This will help prevent future regressions.

```cpp
// Move input from grand-child to direct child
auto* c3i = GetElementById("c3i");
select->appendChild(c3i);

// The input is a direct child, so it shouldn't be in the map
EXPECT_FALSE(select->ChildrenDescendantCounts().Contains(c3i));
// The wrapper c3 should no longer have any inputs tracked
EXPECT_EQ(select->ChildrenDescendantCounts().at(c3).num_inputs, 0);
// The wrapper c3 still has its option
EXPECT_EQ(select->ChildrenDescendantCounts().at(c3).num_options, 1);
// The total number of descendant inputs should remain unchanged
EXPECT_EQ(select->NumDescendantInputs(), 2);

// Ensure the DOM and slots are still correct
GetDocument().UpdateStyleAndLayout(DocumentUpdateReason::kTest);
EXPECT_EQ(c3i->AssignedSlot(), input_slot());
```
Line 1229, Patchset 2 (Latest):
Mason Freed . unresolved

Consider adding a test case to explicitly validate what happens when a node is moved from being a grandchild to a direct child. This will help prevent future regressions.

```cpp
// Move input from grand-child to direct child
auto* c3i = GetElementById("c3i");
select->appendChild(c3i);

// The input is a direct child, so it shouldn't be in the map
EXPECT_FALSE(select->ChildrenDescendantCounts().Contains(c3i));
// The wrapper c3 should no longer have any inputs tracked
EXPECT_EQ(select->ChildrenDescendantCounts().at(c3).num_inputs, 0);
// The wrapper c3 still has its option
EXPECT_EQ(select->ChildrenDescendantCounts().at(c3).num_options, 1);
// The total number of descendant inputs should remain unchanged
EXPECT_EQ(select->NumDescendantInputs(), 2);

// Ensure the DOM and slots are still correct
GetDocument().UpdateStyleAndLayout(DocumentUpdateReason::kTest);
EXPECT_EQ(c3i->AssignedSlot(), input_slot());
```
Open in Gerrit

Related details

Attention is currently required from:
  • Joey Arhar
Submit Requirements:
    • requirement satisfiedCode-Coverage
    • requirement satisfiedCode-Owners
    • requirement 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: I26a368a056a98fef29236ddb33325fa898cb4ac6
    Gerrit-Change-Number: 7963187
    Gerrit-PatchSet: 2
    Gerrit-Owner: Joey Arhar <jar...@chromium.org>
    Gerrit-Reviewer: Joey Arhar <jar...@chromium.org>
    Gerrit-Reviewer: Mason Freed <mas...@chromium.org>
    Gerrit-Comment-Date: Thu, 25 Jun 2026 00:49:50 +0000
    Gerrit-HasComments: Yes
    Gerrit-Has-Labels: Yes
    satisfied_requirement
    unsatisfied_requirement
    open
    diffy

    Joey Arhar (Gerrit)

    unread,
    Jun 25, 2026, 2:08:46 PM (7 days ago) Jun 25
    to Mason Freed, chrom...@appspot.gserviceaccount.com, android-bu...@system.gserviceaccount.com, Chromium LUCI CQ, blink-rev...@chromium.org, blink-...@chromium.org

    Joey Arhar voted and added 12 comments

    Votes added by Joey Arhar

    Code-Review+1
    Commit-Queue+2

    12 comments

    File third_party/blink/renderer/core/html/forms/html_select_element.h
    Line 565, Patchset 2: // multiple are inserted or removed. As an optimization, children which are

    // actually option or input elements are not included in this map.
    Mason Freed . resolved

    nit: `children which themselves are option or input elements`

    Joey Arhar

    Done

    File third_party/blink/renderer/core/html/forms/html_select_element.cc
    Line 2228, Patchset 2: auto it = children_descendant_counts_map_.find(nearest_ancestor_select_child);
    Mason Freed . resolved

    Does this need line wrapping?

    Joey Arhar

    Done

    File third_party/blink/renderer/core/html/forms/html_select_element_test.cc
    Line 1150, Patchset 2:
    Mason Freed . resolved

    {From review agent}

    Consider adding a test case to explicitly validate what happens when a node is moved from being a grandchild to a direct child. This will help prevent future regressions.

    ```
    // Move input from grand-child to direct child
    auto* c3i = GetElementById("c3i");
    select->appendChild(c3i);

    // The input is a direct child, so it shouldn't be in the map
    EXPECT_FALSE(select->ChildrenDescendantCounts().Contains(c3i));
    // The wrapper c3 should no longer have any inputs tracked
    EXPECT_EQ(select->ChildrenDescendantCounts().at(c3).num_inputs, 0);
    // The wrapper c3 still has its option
    EXPECT_EQ(select->ChildrenDescendantCounts().at(c3).num_options, 1);
    // The total number of descendant inputs should remain unchanged
    EXPECT_EQ(select->NumDescendantInputs(), 2);

    // Ensure the DOM and slots are still correct
    GetDocument().UpdateStyleAndLayout(DocumentUpdateReason::kTest);
    EXPECT_EQ(c3i->AssignedSlot(), input_slot());
    ```
    Joey Arhar

    Done

    Line 1229, Patchset 2:
    Mason Freed . resolved

    Consider adding a test case to explicitly validate what happens when a node is moved from being a grandchild to a direct child. This will help prevent future regressions.

    ```cpp
    // Move input from grand-child to direct child
    auto* c3i = GetElementById("c3i");
    select->appendChild(c3i);

    // The input is a direct child, so it shouldn't be in the map
    EXPECT_FALSE(select->ChildrenDescendantCounts().Contains(c3i));
    // The wrapper c3 should no longer have any inputs tracked
    EXPECT_EQ(select->ChildrenDescendantCounts().at(c3).num_inputs, 0);
    // The wrapper c3 still has its option
    EXPECT_EQ(select->ChildrenDescendantCounts().at(c3).num_options, 1);
    // The total number of descendant inputs should remain unchanged
    EXPECT_EQ(select->NumDescendantInputs(), 2);

    // Ensure the DOM and slots are still correct
    GetDocument().UpdateStyleAndLayout(DocumentUpdateReason::kTest);
    EXPECT_EQ(c3i->AssignedSlot(), input_slot());
    ```
    Joey Arhar

    Done

    Line 1229, Patchset 2:
    Mason Freed . resolved

    Consider adding a test case to explicitly validate what happens when a node is moved from being a grandchild to a direct child. This will help prevent future regressions.

    ```cpp
    // Move input from grand-child to direct child
    auto* c3i = GetElementById("c3i");
    select->appendChild(c3i);

    // The input is a direct child, so it shouldn't be in the map
    EXPECT_FALSE(select->ChildrenDescendantCounts().Contains(c3i));
    // The wrapper c3 should no longer have any inputs tracked
    EXPECT_EQ(select->ChildrenDescendantCounts().at(c3).num_inputs, 0);
    // The wrapper c3 still has its option
    EXPECT_EQ(select->ChildrenDescendantCounts().at(c3).num_options, 1);
    // The total number of descendant inputs should remain unchanged
    EXPECT_EQ(select->NumDescendantInputs(), 2);

    // Ensure the DOM and slots are still correct
    GetDocument().UpdateStyleAndLayout(DocumentUpdateReason::kTest);
    EXPECT_EQ(c3i->AssignedSlot(), input_slot());
    ```
    Joey Arhar

    Done

    Line 1229, Patchset 2:
    Mason Freed . resolved

    Consider adding a test case to explicitly validate what happens when a node is moved from being a grandchild to a direct child. This will help prevent future regressions.

    ```cpp
    // Move input from grand-child to direct child
    auto* c3i = GetElementById("c3i");
    select->appendChild(c3i);

    // The input is a direct child, so it shouldn't be in the map
    EXPECT_FALSE(select->ChildrenDescendantCounts().Contains(c3i));
    // The wrapper c3 should no longer have any inputs tracked
    EXPECT_EQ(select->ChildrenDescendantCounts().at(c3).num_inputs, 0);
    // The wrapper c3 still has its option
    EXPECT_EQ(select->ChildrenDescendantCounts().at(c3).num_options, 1);
    // The total number of descendant inputs should remain unchanged
    EXPECT_EQ(select->NumDescendantInputs(), 2);

    // Ensure the DOM and slots are still correct
    GetDocument().UpdateStyleAndLayout(DocumentUpdateReason::kTest);
    EXPECT_EQ(c3i->AssignedSlot(), input_slot());
    ```
    Joey Arhar

    Done

    Line 1229, Patchset 2:
    Mason Freed . resolved

    Consider adding a test case to explicitly validate what happens when a node is moved from being a grandchild to a direct child. This will help prevent future regressions.

    ```cpp
    // Move input from grand-child to direct child
    auto* c3i = GetElementById("c3i");
    select->appendChild(c3i);

    // The input is a direct child, so it shouldn't be in the map
    EXPECT_FALSE(select->ChildrenDescendantCounts().Contains(c3i));
    // The wrapper c3 should no longer have any inputs tracked
    EXPECT_EQ(select->ChildrenDescendantCounts().at(c3).num_inputs, 0);
    // The wrapper c3 still has its option
    EXPECT_EQ(select->ChildrenDescendantCounts().at(c3).num_options, 1);
    // The total number of descendant inputs should remain unchanged
    EXPECT_EQ(select->NumDescendantInputs(), 2);

    // Ensure the DOM and slots are still correct
    GetDocument().UpdateStyleAndLayout(DocumentUpdateReason::kTest);
    EXPECT_EQ(c3i->AssignedSlot(), input_slot());
    ```
    Joey Arhar

    Done

    Line 1229, Patchset 2:
    Mason Freed . resolved

    Consider adding a test case to explicitly validate what happens when a node is moved from being a grandchild to a direct child. This will help prevent future regressions.

    ```cpp
    // Move input from grand-child to direct child
    auto* c3i = GetElementById("c3i");
    select->appendChild(c3i);

    // The input is a direct child, so it shouldn't be in the map
    EXPECT_FALSE(select->ChildrenDescendantCounts().Contains(c3i));
    // The wrapper c3 should no longer have any inputs tracked
    EXPECT_EQ(select->ChildrenDescendantCounts().at(c3).num_inputs, 0);
    // The wrapper c3 still has its option
    EXPECT_EQ(select->ChildrenDescendantCounts().at(c3).num_options, 1);
    // The total number of descendant inputs should remain unchanged
    EXPECT_EQ(select->NumDescendantInputs(), 2);

    // Ensure the DOM and slots are still correct
    GetDocument().UpdateStyleAndLayout(DocumentUpdateReason::kTest);
    EXPECT_EQ(c3i->AssignedSlot(), input_slot());
    ```
    Joey Arhar

    Done

    Line 1229, Patchset 2:
    Mason Freed . resolved

    Consider adding a test case to explicitly validate what happens when a node is moved from being a grandchild to a direct child. This will help prevent future regressions.

    ```cpp
    // Move input from grand-child to direct child
    auto* c3i = GetElementById("c3i");
    select->appendChild(c3i);

    // The input is a direct child, so it shouldn't be in the map
    EXPECT_FALSE(select->ChildrenDescendantCounts().Contains(c3i));
    // The wrapper c3 should no longer have any inputs tracked
    EXPECT_EQ(select->ChildrenDescendantCounts().at(c3).num_inputs, 0);
    // The wrapper c3 still has its option
    EXPECT_EQ(select->ChildrenDescendantCounts().at(c3).num_options, 1);
    // The total number of descendant inputs should remain unchanged
    EXPECT_EQ(select->NumDescendantInputs(), 2);

    // Ensure the DOM and slots are still correct
    GetDocument().UpdateStyleAndLayout(DocumentUpdateReason::kTest);
    EXPECT_EQ(c3i->AssignedSlot(), input_slot());
    ```
    Joey Arhar

    Done

    Line 1229, Patchset 2:
    Mason Freed . resolved

    Consider adding a test case to explicitly validate what happens when a node is moved from being a grandchild to a direct child. This will help prevent future regressions.

    ```cpp
    // Move input from grand-child to direct child
    auto* c3i = GetElementById("c3i");
    select->appendChild(c3i);

    // The input is a direct child, so it shouldn't be in the map
    EXPECT_FALSE(select->ChildrenDescendantCounts().Contains(c3i));
    // The wrapper c3 should no longer have any inputs tracked
    EXPECT_EQ(select->ChildrenDescendantCounts().at(c3).num_inputs, 0);
    // The wrapper c3 still has its option
    EXPECT_EQ(select->ChildrenDescendantCounts().at(c3).num_options, 1);
    // The total number of descendant inputs should remain unchanged
    EXPECT_EQ(select->NumDescendantInputs(), 2);

    // Ensure the DOM and slots are still correct
    GetDocument().UpdateStyleAndLayout(DocumentUpdateReason::kTest);
    EXPECT_EQ(c3i->AssignedSlot(), input_slot());
    ```
    Joey Arhar

    Done

    Line 1229, Patchset 2:
    Mason Freed . resolved

    Consider adding a test case to explicitly validate what happens when a node is moved from being a grandchild to a direct child. This will help prevent future regressions.

    ```cpp
    // Move input from grand-child to direct child
    auto* c3i = GetElementById("c3i");
    select->appendChild(c3i);

    // The input is a direct child, so it shouldn't be in the map
    EXPECT_FALSE(select->ChildrenDescendantCounts().Contains(c3i));
    // The wrapper c3 should no longer have any inputs tracked
    EXPECT_EQ(select->ChildrenDescendantCounts().at(c3).num_inputs, 0);
    // The wrapper c3 still has its option
    EXPECT_EQ(select->ChildrenDescendantCounts().at(c3).num_options, 1);
    // The total number of descendant inputs should remain unchanged
    EXPECT_EQ(select->NumDescendantInputs(), 2);

    // Ensure the DOM and slots are still correct
    GetDocument().UpdateStyleAndLayout(DocumentUpdateReason::kTest);
    EXPECT_EQ(c3i->AssignedSlot(), input_slot());
    ```
    Joey Arhar

    Done

    Line 1229, Patchset 2:
    Mason Freed . resolved

    Consider adding a test case to explicitly validate what happens when a node is moved from being a grandchild to a direct child. This will help prevent future regressions.

    ```cpp
    // Move input from grand-child to direct child
    auto* c3i = GetElementById("c3i");
    select->appendChild(c3i);

    // The input is a direct child, so it shouldn't be in the map
    EXPECT_FALSE(select->ChildrenDescendantCounts().Contains(c3i));
    // The wrapper c3 should no longer have any inputs tracked
    EXPECT_EQ(select->ChildrenDescendantCounts().at(c3).num_inputs, 0);
    // The wrapper c3 still has its option
    EXPECT_EQ(select->ChildrenDescendantCounts().at(c3).num_options, 1);
    // The total number of descendant inputs should remain unchanged
    EXPECT_EQ(select->NumDescendantInputs(), 2);

    // Ensure the DOM and slots are still correct
    GetDocument().UpdateStyleAndLayout(DocumentUpdateReason::kTest);
    EXPECT_EQ(c3i->AssignedSlot(), input_slot());
    ```
    Joey Arhar

    Done

    Open in Gerrit

    Related details

    Attention set is empty
    Submit Requirements:
      • requirement satisfiedCode-Coverage
      • requirement satisfiedCode-Owners
      • requirement satisfiedCode-Review
      • requirement 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: I26a368a056a98fef29236ddb33325fa898cb4ac6
      Gerrit-Change-Number: 7963187
      Gerrit-PatchSet: 3
      Gerrit-Comment-Date: Thu, 25 Jun 2026 18:08:32 +0000
      Gerrit-HasComments: Yes
      Gerrit-Has-Labels: Yes
      Comment-In-Reply-To: Mason Freed <mas...@chromium.org>
      satisfied_requirement
      open
      diffy

      Chromium LUCI CQ (Gerrit)

      unread,
      Jun 25, 2026, 2:13:58 PM (7 days ago) Jun 25
      to Mason Freed, chrom...@appspot.gserviceaccount.com, android-bu...@system.gserviceaccount.com, blink-rev...@chromium.org, blink-...@chromium.org

      Chromium LUCI CQ submitted the change

      Change information

      Commit message:
      Optimize HTMLSelectElement descendant tracking

      Commit 1e01c3e807d05f2371faeff662a4bc1d676b0597 introduced
      children_descendant_counts_map_ to track descendant options and inputs
      for FilterableSelect. However, updating this map for every option
      insertion/removal introduced significant overhead (hash map operations,
      write barriers, and GC tracing) particularly when options are direct
      children of the select.

      This patch optimizes this by:
      1. Skipping children_descendant_counts_map_ operations for direct
      children of the select element, as they can be identified directly
      without the map.
      2. Only tracking and assigning select_child during ancestor walks
      if FilterableSelect is enabled.
      3. Updating slotting logic in select_type.cc to check for direct inputs
      using IsA<HTMLInputElement> since they are no longer in the map.
      Fixed: 512314683
      Change-Id: I26a368a056a98fef29236ddb33325fa898cb4ac6
      Reviewed-by: Mason Freed <mas...@chromium.org>
      Reviewed-by: Joey Arhar <jar...@chromium.org>
      Commit-Queue: Joey Arhar <jar...@chromium.org>
      Cr-Commit-Position: refs/heads/main@{#1652561}
      Files:
      • M third_party/blink/renderer/core/html/forms/html_option_element.cc
      • M third_party/blink/renderer/core/html/forms/html_select_element.cc
      • M third_party/blink/renderer/core/html/forms/html_select_element.h
      • M third_party/blink/renderer/core/html/forms/html_select_element_test.cc
      • M third_party/blink/renderer/core/html/forms/select_type.cc
      Change size: M
      Delta: 5 files changed, 89 insertions(+), 31 deletions(-)
      Branch: refs/heads/main
      Submit Requirements:
      • requirement satisfiedCode-Review: +1 by Mason Freed, +1 by Joey Arhar
      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: I26a368a056a98fef29236ddb33325fa898cb4ac6
      Gerrit-Change-Number: 7963187
      Gerrit-PatchSet: 4
      Gerrit-Owner: Joey Arhar <jar...@chromium.org>
      Gerrit-Reviewer: Chromium LUCI CQ <chromiu...@luci-project-accounts.iam.gserviceaccount.com>
      Gerrit-Reviewer: Joey Arhar <jar...@chromium.org>
      Gerrit-Reviewer: Mason Freed <mas...@chromium.org>
      open
      diffy
      satisfied_requirement
      Reply all
      Reply to author
      Forward
      0 new messages