Cache option's ancestor optgroup [chromium/src : main]

0 views
Skip to first unread message

David Baron (Gerrit)

unread,
Oct 8, 2025, 10:42:12 AM (11 days ago) Oct 8
to David Baron, Chromium LUCI CQ, AyeAye, blink-rev...@chromium.org, blink-...@chromium.org
Attention needed from Joey Arhar

David Baron added 6 comments

Patchset-level comments
File-level comment, Patchset 2 (Latest):
David Baron . resolved

This mostly looks good, but a few comments below. I'm pushing a little bit on code simplicity here because this code has tended to accumulate unneeded complexity in the past, so I'd like to try to push to simplifying where it's easy to do so.

Commit Message
Line 13, Patchset 2 (Latest):This patch also updates some apperance:auto text indentation for options
David Baron . unresolved

Please fix this WARNING reported by Spellchecker: "apperance" is a possible misspelling of "appearance".

To bypass Spellchecker, ...

"apperance" is a possible misspelling of "appearance".

To bypass Spellchecker, add a footer with DISABLE_SPELLCHECKER

File third_party/blink/renderer/core/html/forms/html_option_element.cc
Line 431, Patchset 2 (Latest): nearest_ancestor_select_ = select;
David Baron . unresolved

I think at this point `SetOwnerSelectElement` makes the code more confusing rather than less. In paricular, it requires that the reader of the code understand that `nearest_ancestor_optgroup_` and `nearest_ancestor_select_` are actually both set when this function is called.

I think at this point it's probably beneficial to just remove the method and inline it into the two callers (`InsertedInto` and `RemovedFrom`, which you're both already modifying). I don't think you need the `DCHECK()` anymore since both callers are just setting `nearest_ancestor_select_` based on the result of the method.

Line 518, Patchset 2 (Latest): auto select_and_optgroup =
HTMLSelectElement::NearestAncestorSelectNoNesting(*this);
HTMLSelectElement* new_ancestor_select = select_and_optgroup.first;
SetOwnerSelectElement(new_ancestor_select);
nearest_ancestor_optgroup_ = select_and_optgroup.second;
David Baron . unresolved
Optional comment, but I think it's perhaps a little more readable if you use `std::tie()`:
```suggestion
HTMLSelectElement* new_ancestor_select;
std::tie(new_ancestor_select, nearest_ancestor_optgroup_) =
HTMLSelectElement::NearestAncestorSelectNoNesting(*this);
SetOwnerSelectElement(new_ancestor_select);
```
and a little bit more so if you also take my suggestion above about dropping `SetOwnerSelectElement` since then it just becomes:
```suggestion
std::tie(nearest_ancestor_select_, nearest_ancestor_optgroup_) =
HTMLSelectElement::NearestAncestorSelectNoNesting(*this);
```
Line 534, Patchset 2 (Latest):
auto select_and_optgroup =
HTMLSelectElement::NearestAncestorSelectNoNesting(*this);
nearest_ancestor_optgroup_ = select_and_optgroup.second;
HTMLSelectElement* new_ancestor_select = select_and_optgroup.first;
HTMLSelectElement* old_ancestor_select = nearest_ancestor_select_;
David Baron . unresolved

Same advice here about `std::tie()` and dropping `SetOwnerSelectElement`... just make sure to assign to `old_ancestor_select` first!

File third_party/blink/renderer/core/html/forms/html_select_element.h
Line 173, Patchset 2 (Latest): NearestAncestorSelectNoNesting(const Element& element);
David Baron . unresolved

Maybe this should be renamed at this point? Maybe something like `AssociatedAncestorSelectAndOptgroup` or just `AssociatedSelectAndOptgroup`?

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: Ia2a0640f975721d2e43d96bd17187e115702d04c
Gerrit-Change-Number: 7001300
Gerrit-PatchSet: 2
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: Wed, 08 Oct 2025 14:42:07 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
satisfied_requirement
unsatisfied_requirement
open
diffy

Joey Arhar (Gerrit)

unread,
Oct 15, 2025, 4:50:50 PM (4 days ago) Oct 15
to David Baron, Chromium LUCI CQ, AyeAye, blink-rev...@chromium.org, blink-...@chromium.org
Attention needed from David Baron

Joey Arhar added 5 comments

Commit Message
Line 13, Patchset 2 (Latest):This patch also updates some apperance:auto text indentation for options
David Baron . resolved

Please fix this WARNING reported by Spellchecker: "apperance" is a possible misspelling of "appearance".

To bypass Spellchecker, ...

"apperance" is a possible misspelling of "appearance".

To bypass Spellchecker, add a footer with DISABLE_SPELLCHECKER

Joey Arhar

Done

File third_party/blink/renderer/core/html/forms/html_option_element.cc
Line 431, Patchset 2 (Latest): nearest_ancestor_select_ = select;
David Baron . resolved

I think at this point `SetOwnerSelectElement` makes the code more confusing rather than less. In paricular, it requires that the reader of the code understand that `nearest_ancestor_optgroup_` and `nearest_ancestor_select_` are actually both set when this function is called.

I think at this point it's probably beneficial to just remove the method and inline it into the two callers (`InsertedInto` and `RemovedFrom`, which you're both already modifying). I don't think you need the `DCHECK()` anymore since both callers are just setting `nearest_ancestor_select_` based on the result of the method.

Joey Arhar

i agree, i deleted this method

Line 518, Patchset 2 (Latest): auto select_and_optgroup =
HTMLSelectElement::NearestAncestorSelectNoNesting(*this);
HTMLSelectElement* new_ancestor_select = select_and_optgroup.first;
SetOwnerSelectElement(new_ancestor_select);
nearest_ancestor_optgroup_ = select_and_optgroup.second;
David Baron . resolved
Optional comment, but I think it's perhaps a little more readable if you use `std::tie()`:
```suggestion
HTMLSelectElement* new_ancestor_select;
std::tie(new_ancestor_select, nearest_ancestor_optgroup_) =
HTMLSelectElement::NearestAncestorSelectNoNesting(*this);
SetOwnerSelectElement(new_ancestor_select);
```
and a little bit more so if you also take my suggestion above about dropping `SetOwnerSelectElement` since then it just becomes:
```suggestion
std::tie(nearest_ancestor_select_, nearest_ancestor_optgroup_) =
HTMLSelectElement::NearestAncestorSelectNoNesting(*this);
```
Joey Arhar

Done

Line 534, Patchset 2 (Latest):
auto select_and_optgroup =
HTMLSelectElement::NearestAncestorSelectNoNesting(*this);
nearest_ancestor_optgroup_ = select_and_optgroup.second;
HTMLSelectElement* new_ancestor_select = select_and_optgroup.first;
HTMLSelectElement* old_ancestor_select = nearest_ancestor_select_;
David Baron . resolved

Same advice here about `std::tie()` and dropping `SetOwnerSelectElement`... just make sure to assign to `old_ancestor_select` first!

Joey Arhar

Done

File third_party/blink/renderer/core/html/forms/html_select_element.h
Line 173, Patchset 2 (Latest): NearestAncestorSelectNoNesting(const Element& element);
David Baron . resolved

Maybe this should be renamed at this point? Maybe something like `AssociatedAncestorSelectAndOptgroup` or just `AssociatedSelectAndOptgroup`?

Joey Arhar

Done

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 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: Ia2a0640f975721d2e43d96bd17187e115702d04c
    Gerrit-Change-Number: 7001300
    Gerrit-PatchSet: 2
    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: Wed, 15 Oct 2025 20:50:29 +0000
    Gerrit-HasComments: Yes
    Gerrit-Has-Labels: No
    Comment-In-Reply-To: David Baron <dba...@chromium.org>
    satisfied_requirement
    unsatisfied_requirement
    open
    diffy

    AI Code Reviewer (Gerrit)

    unread,
    Oct 15, 2025, 4:52:04 PM (4 days ago) Oct 15
    to David Baron, Chromium LUCI CQ, AyeAye, blink-rev...@chromium.org, blink-...@chromium.org
    Attention needed from David Baron

    AI Code Reviewer added 1 comment

    File third_party/blink/renderer/core/html/forms/html_select_element.h
    Line 173, Patchset 3 (Latest): AssociatedSelectAndOptgroup(const Element& element);
    AI Code Reviewer . unresolved

    nit: The parameter name 'element' can be omitted from the function declaration in the header file, as its purpose is clear from the type 'Element'. (Blink Style Guide: Naming - May leave obvious parameter names out of function declarations)

    _To keep this interaction as brief and non-intrusive as possible, please consider responding with one of following options:
    **Done** | **Won't fix**: reason | **b/<bug_id>** | **Invalid:** reason

    This comment was generated by [Experimental Blink C++ Code Review Agent](http://go/blink-c++-code-review-agent).AI reviews can sometimes be inaccurate; We appreciate your 🙏 feedback 🙏 to help us improve.[File a bug](http://go/blink-c++-code-review-agent-feedback) | [Provide feedback on chat](https://chat.google.com/room/AAQA0zhQHe0?cls=4) | [Opt-out](https://ganpati2.corp.google.com/group/peep-genai-blink-agent-optout.prod)_

    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: Ia2a0640f975721d2e43d96bd17187e115702d04c
      Gerrit-Change-Number: 7001300
      Gerrit-PatchSet: 3
      Gerrit-Owner: Joey Arhar <jar...@chromium.org>
      Gerrit-Reviewer: David Baron <dba...@chromium.org>
      Gerrit-Reviewer: Joey Arhar <jar...@chromium.org>
      Gerrit-CC: AI Code Reviewer <peep-gen...@system.gserviceaccount.com>
      Gerrit-Attention: David Baron <dba...@chromium.org>
      Gerrit-Comment-Date: Wed, 15 Oct 2025 20:52:00 +0000
      Gerrit-HasComments: Yes
      Gerrit-Has-Labels: No
      satisfied_requirement
      unsatisfied_requirement
      open
      diffy

      David Baron (Gerrit)

      unread,
      Oct 16, 2025, 12:12:39 PM (3 days ago) Oct 16
      to David Baron, AI Code Reviewer, Chromium LUCI CQ, AyeAye, blink-rev...@chromium.org, blink-...@chromium.org
      Attention needed from Joey Arhar

      David Baron voted Code-Review+1

      Code-Review+1
      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 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: Ia2a0640f975721d2e43d96bd17187e115702d04c
        Gerrit-Change-Number: 7001300
        Gerrit-PatchSet: 3
        Gerrit-Owner: Joey Arhar <jar...@chromium.org>
        Gerrit-Reviewer: David Baron <dba...@chromium.org>
        Gerrit-Reviewer: Joey Arhar <jar...@chromium.org>
        Gerrit-CC: AI Code Reviewer <peep-gen...@system.gserviceaccount.com>
        Gerrit-Attention: Joey Arhar <jar...@chromium.org>
        Gerrit-Comment-Date: Thu, 16 Oct 2025 16:12:33 +0000
        Gerrit-HasComments: No
        Gerrit-Has-Labels: Yes
        satisfied_requirement
        unsatisfied_requirement
        open
        diffy

        Joey Arhar (Gerrit)

        unread,
        Oct 16, 2025, 10:01:16 PM (3 days ago) Oct 16
        to David Baron, AI Code Reviewer, Chromium LUCI CQ, AyeAye, blink-rev...@chromium.org, blink-...@chromium.org

        Joey Arhar added 1 comment

        File third_party/blink/renderer/core/html/forms/html_select_element.h
        Line 173, Patchset 3 (Latest): AssociatedSelectAndOptgroup(const Element& element);
        AI Code Reviewer . resolved

        nit: The parameter name 'element' can be omitted from the function declaration in the header file, as its purpose is clear from the type 'Element'. (Blink Style Guide: Naming - May leave obvious parameter names out of function declarations)

        _To keep this interaction as brief and non-intrusive as possible, please consider responding with one of following options:
        **Done** | **Won't fix**: reason | **b/<bug_id>** | **Invalid:** reason

        This comment was generated by [Experimental Blink C++ Code Review Agent](http://go/blink-c++-code-review-agent).AI reviews can sometimes be inaccurate; We appreciate your 🙏 feedback 🙏 to help us improve.[File a bug](http://go/blink-c++-code-review-agent-feedback) | [Provide feedback on chat](https://chat.google.com/room/AAQA0zhQHe0?cls=4) | [Opt-out](https://ganpati2.corp.google.com/group/peep-genai-blink-agent-optout.prod)_

        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: Ia2a0640f975721d2e43d96bd17187e115702d04c
          Gerrit-Change-Number: 7001300
          Gerrit-PatchSet: 3
          Gerrit-Owner: Joey Arhar <jar...@chromium.org>
          Gerrit-Reviewer: David Baron <dba...@chromium.org>
          Gerrit-Reviewer: Joey Arhar <jar...@chromium.org>
          Gerrit-CC: AI Code Reviewer <peep-gen...@system.gserviceaccount.com>
          Gerrit-Comment-Date: Fri, 17 Oct 2025 02:01:05 +0000
          Gerrit-HasComments: Yes
          Gerrit-Has-Labels: No
          Comment-In-Reply-To: AI Code Reviewer <peep-gen...@system.gserviceaccount.com>
          satisfied_requirement
          open
          diffy

          Chromium LUCI CQ (Gerrit)

          unread,
          Oct 16, 2025, 10:58:21 PM (3 days ago) Oct 16
          to David Baron, AI Code Reviewer, AyeAye, blink-rev...@chromium.org, blink-...@chromium.org

          Chromium LUCI CQ submitted the change with unreviewed changes

          Unreviewed changes

          3 is the latest approved patch-set.
          The change was submitted with unreviewed changes in the following files:

          ```
          The name of the file: third_party/blink/renderer/core/html/forms/html_select_element.h
          Insertions: 1, Deletions: 1.

          @@ -170,7 +170,7 @@
          // there is an <optgroup> in between the provided element and the returned
          // <select>.
          static std::pair<HTMLSelectElement*, HTMLOptGroupElement*>
          - AssociatedSelectAndOptgroup(const Element& element);
          + AssociatedSelectAndOptgroup(const Element&);

          void AccessKeyAction(SimulatedClickCreationScope creation_scope) override;
          void SelectOptionByAccessKey(HTMLOptionElement*);
          ```

          Change information

          Commit message:
          Cache option's ancestor optgroup

          Now that we are using the nearest ancestor optgroup to change some
          behaviors, it makes sense to cache it during the same tree traversal
          that we are already doing for the nearest ancestor select element.

          This patch also updates some appearance:auto text indentation for
          options when they are inside an optgroup to look for an ancestor
          optgroup rather than a parent optgroup.
          Change-Id: Ia2a0640f975721d2e43d96bd17187e115702d04c
          Reviewed-by: David Baron <dba...@chromium.org>
          Commit-Queue: Joey Arhar <jar...@chromium.org>
          Cr-Commit-Position: refs/heads/main@{#1531191}
          Files:
          • M third_party/blink/renderer/core/html/forms/html_opt_group_element.cc
          • M third_party/blink/renderer/core/html/forms/html_option_element.cc
          • M third_party/blink/renderer/core/html/forms/html_option_element.h
          • 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/option_list.cc
          • M third_party/blink/renderer/core/html/html_hr_element.cc
          • M third_party/blink/web_tests/fast/forms/select/optgroup-rendering.html
          Change size: M
          Delta: 8 files changed, 88 insertions(+), 90 deletions(-)
          Branch: refs/heads/main
          Submit Requirements:
          • requirement satisfiedCode-Review: +1 by David Baron
          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: Ia2a0640f975721d2e43d96bd17187e115702d04c
          Gerrit-Change-Number: 7001300
          Gerrit-PatchSet: 5
          Gerrit-Owner: Joey Arhar <jar...@chromium.org>
          Gerrit-Reviewer: Chromium LUCI CQ <chromiu...@luci-project-accounts.iam.gserviceaccount.com>
          open
          diffy
          satisfied_requirement
          Reply all
          Reply to author
          Forward
          0 new messages