[menu] Activation behavior for open/close menu on arrow navigation [chromium/src : main]

0 views
Skip to first unread message

Dominic Farolino (Gerrit)

unread,
Jun 16, 2025, 9:58:57 PMJun 16
to Di Zhang, Mason Freed, Chromium LUCI CQ, chromium...@chromium.org, blink-rev...@chromium.org, blink-revie...@chromium.org, blink-...@chromium.org
Attention needed from Di Zhang and Mason Freed

Dominic Farolino added 8 comments

Patchset-level comments
File-level comment, Patchset 4 (Latest):
Dominic Farolino . resolved

Some comments for now that likely apply elsewhere, but I will do a more full pass tomorrow morning too.

Commit Message
Line 9, Patchset 4 (Latest):This patch update the HTMLMenuItemElement::DefaultEventHandler method
Dominic Farolino . unresolved

"updates"

Line 19, Patchset 4 (Latest): ancestor menubar.
Dominic Farolino . unresolved

And do nothing if there is no menubar ancestor?

Line 21, Patchset 4 (Latest): - Close the current menulist.
Dominic Farolino . unresolved

This feels ambiguous? What is the "current" menulist? There are two I can think of:

1. The menulist that this menuitem controls (aka the sub-menulist associated with *this* menuitem)
2. The menulist that this menuitem is a child of

Line 24, Patchset 4 (Latest):- If element is a menuitem in a menubar,
Dominic Farolino . unresolved

Else if?

File third_party/blink/renderer/core/html/html_menu_item_element.cc
Line 300, Patchset 4 (Latest): invoked_menulist->InvokePopover(*this);
Dominic Farolino . unresolved

This runs script, right? Can you add a test that exercises what happens if the popover is closed here while script runs? That should help inform us as to how we should proceed from here. Can `invoked_menulist` be closed at this point?

Line 304, Patchset 4 (Latest): *invoked_menuitems.begin(), /*inclusive*/ true)) {
Dominic Farolino . unresolved

style guide recommends `/*inclusive=*/true`

Line 315, Patchset 4 (Latest): HTMLMenuItemElement* invoker_menuitem;
Dominic Farolino . unresolved

Since this is a pointer, shouldn't we initialize this to non-garbage memory?

Open in Gerrit

Related details

Attention is currently required from:
  • Di Zhang
  • Mason Freed
Submit Requirements:
  • requirement satisfiedCode-Coverage
  • requirement is not satisfiedCode-Owners
  • 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: I97aa335a3e4702caf12d503f7ef6a069086e6307
Gerrit-Change-Number: 6644040
Gerrit-PatchSet: 4
Gerrit-Owner: Di Zhang <dizh...@chromium.org>
Gerrit-Reviewer: Di Zhang <dizh...@chromium.org>
Gerrit-Reviewer: Dominic Farolino <d...@chromium.org>
Gerrit-Reviewer: Mason Freed <mas...@chromium.org>
Gerrit-CC: Joey Arhar <jar...@chromium.org>
Gerrit-Attention: Di Zhang <dizh...@chromium.org>
Gerrit-Attention: Mason Freed <mas...@chromium.org>
Gerrit-Comment-Date: Tue, 17 Jun 2025 01:58:51 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
satisfied_requirement
unsatisfied_requirement
open
diffy

Mason Freed (Gerrit)

unread,
Jun 17, 2025, 4:52:30 PMJun 17
to Di Zhang, Dominic Farolino, Chromium LUCI CQ, chromium...@chromium.org, blink-rev...@chromium.org, blink-revie...@chromium.org, blink-...@chromium.org
Attention needed from Di Zhang

Mason Freed added 17 comments

Commit Message
Line 18, Patchset 6: - Else, close all popovers. If it has an ancestor menubar and its
Mason Freed . unresolved

Why do we close all popovers in this case? At least the Google docs menu opens the next menuitem in the menubar in this case.

File third_party/blink/renderer/core/html/html_element.h
Line 104, Patchset 6: kMenuItem,
Mason Freed . unresolved

I think that (at least) the code right here needs to be modified to take this into account. The `is_popover` variable should apply to menus also, based on the usage here.

https://source.chromium.org/chromium/chromium/src/+/main:third_party/blink/renderer/core/html/html_element.cc;l=2159;drc=ab5261de6f730d1378a27c400f8640440f662303

And it would be very good to add a test of that. You'd need to nest a `<menuitem>` inside a `<div popover>` and have it invoke a `<menulist>`, and make sure all of the popover light dismiss stuff still works correctly. Perhaps also nest a `<button popovertarget=foo>` inside the `<menulist>` and have *that* invoke a separate `<div popover id=foo>`? Just to test out that we covered all of the nesting cases, and menu items really **are** popovers?

Line 104, Patchset 6: kMenuItem,
Mason Freed . unresolved

Should this be "MenuItem" or "MenuList"? The thing in the top layer is the `<menulist>` element, no?

File third_party/blink/renderer/core/html/html_menu_item_element.cc
Line 297, Patchset 6: /*include_event_handler_text=*/true, &document) &&
Mason Freed . unresolved

include_event_handler_text should be `false`, since the `exception_state` is null.

Line 300, Patchset 4: invoked_menulist->InvokePopover(*this);
Dominic Farolino . unresolved

This runs script, right? Can you add a test that exercises what happens if the popover is closed here while script runs? That should help inform us as to how we should proceed from here. Can `invoked_menulist` be closed at this point?

Mason Freed

+1 - yes the popover could be closed in this step. E.g.

```
menulist.addEventListener('beforetoggle',() => menulist.hidePopover());
```

Line 310, Patchset 6: // Else, this does not invoke a menulist and we close all popovers.
Mason Freed . unresolved

nit: `this menuitem does not...`

Line 317, Patchset 6: invoker_menuitem = DynamicTo<HTMLMenuItemElement>(
Mason Freed . unresolved

This will be nullptr if there's an ancestor (non-menu) popover, which I think will lead to all of it being closed, right? That seems wrong.

Line 323, Patchset 6: ancestor_popover, document, HidePopoverFocusBehavior::kNone,
Mason Freed . unresolved

Won't this always be `nullptr`?

Line 333, Patchset 6: if (auto* previous = ancestor_menuitems.NextFocusableMenuItem(
Mason Freed . unresolved

`next` ?

Line 349, Patchset 6: DCHECK(menulist->popoverOpen());
Mason Freed . unresolved

I think you could hit this DCHECK:

```
<menulist id=foo tabindex=0>
<style>
#foo {display:block}
</style>
```

...then focus the menulist and hit the left arrow

Line 354, Patchset 6: /*include_event_handler_text=*/true, &GetDocument());
Mason Freed . unresolved

ditto

Line 357, Patchset 6: invoker, HidePopoverFocusBehavior::kFocusPreviousElement,
Mason Freed . unresolved

Do you want it to focus the previous element in this case? Seems like no, since you're handling focus below.

Line 375, Patchset 6: event.SetDefaultHandled();
Mason Freed . unresolved

Should we set default handled if neither branch above got hit? I.e. what if it was just a `<menuitem>` outside a menulist or menubar?

Line 379, Patchset 6: // TODO: implement scrolling to visible menuitem, for
Mason Freed . unresolved

Can you add a bug link

Line 428, Patchset 6: /*include_event_handler_text=*/true, &GetDocument()) &&
Mason Freed . unresolved

ditto

Line 429, Patchset 6: !invoked_menulist->popoverOpen();
Mason Freed . unresolved

I don't think you need to check for !popoverOpen here - `IsPopoverReady` should do that for you already.

File third_party/blink/web_tests/external/wpt/html/semantics/menu/tentative/focus-menu-elements-nested-arrowoperations.html
Line 51, Patchset 6: await test_driver.send_keys(document.activeElement, Tab);
Mason Freed . unresolved

It might be a good idea to focus a starting element at the start of this test, so that you're starting from a known state.

Open in Gerrit

Related details

Attention is currently required from:
  • Di Zhang
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: I97aa335a3e4702caf12d503f7ef6a069086e6307
Gerrit-Change-Number: 6644040
Gerrit-PatchSet: 6
Gerrit-Owner: Di Zhang <dizh...@chromium.org>
Gerrit-Reviewer: Di Zhang <dizh...@chromium.org>
Gerrit-Reviewer: Dominic Farolino <d...@chromium.org>
Gerrit-Reviewer: Mason Freed <mas...@chromium.org>
Gerrit-CC: Joey Arhar <jar...@chromium.org>
Gerrit-Attention: Di Zhang <dizh...@chromium.org>
Gerrit-Comment-Date: Tue, 17 Jun 2025 20:52:21 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
Comment-In-Reply-To: Dominic Farolino <d...@chromium.org>
satisfied_requirement
unsatisfied_requirement
open
diffy

Di Zhang (Gerrit)

unread,
Jun 17, 2025, 4:57:51 PMJun 17
to Dominic Farolino, Mason Freed, Chromium LUCI CQ, chromium...@chromium.org, blink-rev...@chromium.org, blink-revie...@chromium.org, blink-...@chromium.org
Attention needed from Dominic Farolino and Mason Freed

Di Zhang added 8 comments

Commit Message
Line 9, Patchset 4:This patch update the HTMLMenuItemElement::DefaultEventHandler method
Dominic Farolino . resolved

"updates"

Di Zhang

Done

Line 18, Patchset 6: - Else, close all popovers. If it has an ancestor menubar and its
Mason Freed . unresolved

Why do we close all popovers in this case? At least the Google docs menu opens the next menuitem in the menubar in this case.

Di Zhang

I think it is a similar pattern. It closes all currently opened popovers and focus on the next invoker, if available. The difference is that when it focuses on an invoker menuitem, it automatically opens it. In the current implementation, we need a DOM Activation to open a popover/menulist. Maybe that needs to be changed.

Line 19, Patchset 4: ancestor menubar.
Dominic Farolino . resolved

And do nothing if there is no menubar ancestor?

Di Zhang

Right, I will add that.

Line 21, Patchset 4: - Close the current menulist.
Dominic Farolino . resolved

This feels ambiguous? What is the "current" menulist? There are two I can think of:

1. The menulist that this menuitem controls (aka the sub-menulist associated with *this* menuitem)
2. The menulist that this menuitem is a child of

Di Zhang

Second option.

Line 24, Patchset 4:- If element is a menuitem in a menubar,
Dominic Farolino . resolved

Else if?

Di Zhang

Done

File third_party/blink/renderer/core/html/html_menu_item_element.cc
Line 300, Patchset 4: invoked_menulist->InvokePopover(*this);
Dominic Farolino . unresolved

This runs script, right? Can you add a test that exercises what happens if the popover is closed here while script runs? That should help inform us as to how we should proceed from here. Can `invoked_menulist` be closed at this point?

Di Zhang

If the popover is closed, `can_show` will return true and this line will run. But isn't that what the current test is testing (using ArrowRight to move activeElement to `h`)?
note: This is similar logic as what is used in `HTMLElement::HandleCommandInternal`, where it also calls `IsPopoverReady()` before calling either `HidePopoverInternal()` or `InvokePopover()`.

Line 304, Patchset 4: *invoked_menuitems.begin(), /*inclusive*/ true)) {
Dominic Farolino . resolved

style guide recommends `/*inclusive=*/true`

Di Zhang

Done

Line 315, Patchset 4: HTMLMenuItemElement* invoker_menuitem;
Dominic Farolino . unresolved

Since this is a pointer, shouldn't we initialize this to non-garbage memory?

Di Zhang

I am not sure I understood, but I changed to initialize to nullptr.
I also changed to not enforce menuitem check yet, since it is possible the ancestor invoker is a button.

Open in Gerrit

Related details

Attention is currently required from:
  • Dominic Farolino
  • Mason Freed
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: I97aa335a3e4702caf12d503f7ef6a069086e6307
Gerrit-Change-Number: 6644040
Gerrit-PatchSet: 8
Gerrit-Owner: Di Zhang <dizh...@chromium.org>
Gerrit-Reviewer: Di Zhang <dizh...@chromium.org>
Gerrit-Reviewer: Dominic Farolino <d...@chromium.org>
Gerrit-Reviewer: Mason Freed <mas...@chromium.org>
Gerrit-CC: Joey Arhar <jar...@chromium.org>
Gerrit-Attention: Dominic Farolino <d...@chromium.org>
Gerrit-Attention: Mason Freed <mas...@chromium.org>
Gerrit-Comment-Date: Tue, 17 Jun 2025 20:57:41 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
Comment-In-Reply-To: Dominic Farolino <d...@chromium.org>
Comment-In-Reply-To: Mason Freed <mas...@chromium.org>
satisfied_requirement
unsatisfied_requirement
open
diffy

Di Zhang (Gerrit)

unread,
Jun 18, 2025, 5:17:05 PMJun 18
to Dominic Farolino, Mason Freed, Chromium LUCI CQ, chromium...@chromium.org, blink-rev...@chromium.org, blink-revie...@chromium.org, blink-...@chromium.org
Attention needed from Dominic Farolino and Mason Freed

Di Zhang voted and added 17 comments

Votes added by Di Zhang

Commit-Queue+1

17 comments

Commit Message
Line 18, Patchset 6: - Else, close all popovers. If it has an ancestor menubar and its
Mason Freed . unresolved

Why do we close all popovers in this case? At least the Google docs menu opens the next menuitem in the menubar in this case.

Di Zhang

I think it is a similar pattern. It closes all currently opened popovers and focus on the next invoker, if available. The difference is that when it focuses on an invoker menuitem, it automatically opens it. In the current implementation, we need a DOM Activation to open a popover/menulist. Maybe that needs to be changed.

Di Zhang

After offline chat, agree that there is a risk menus can be inside a popover and that popover shouldn't close. Updated the logic and added a test.

Please take another look at the close popovers logic, thank you.

File third_party/blink/renderer/core/html/html_element.h
Mason Freed . resolved

I think that (at least) the code right here needs to be modified to take this into account. The `is_popover` variable should apply to menus also, based on the usage here.

https://source.chromium.org/chromium/chromium/src/+/main:third_party/blink/renderer/core/html/html_element.cc;l=2159;drc=ab5261de6f730d1378a27c400f8640440f662303

And it would be very good to add a test of that. You'd need to nest a `<menuitem>` inside a `<div popover>` and have it invoke a `<menulist>`, and make sure all of the popover light dismiss stuff still works correctly. Perhaps also nest a `<button popovertarget=foo>` inside the `<menulist>` and have *that* invoke a separate `<div popover id=foo>`? Just to test out that we covered all of the nesting cases, and menu items really **are** popovers?

Di Zhang

Ok. Changed so `is_popover` includes the kMenuList case. Note I added it to bypass the `CHECK(top_layer_element_type != TopLayerElementType::kPopover);` in `TopLayerElementPopoverAncestor`, since previously, it is only called by non-popover elements.

Modified the test to include this case.

Perhaps also nest a <button popovertarget=foo> inside the <menulist> and have that invoke a separate <div popover id=foo>?

A button with popovertarget is not a valid invoker for a menulist and also won't follow the codepath added in this CL (since it only changes arrow key behavior for menuitem). I am not sure what to test here, except that popover works as usual.

Mason Freed . resolved

Should this be "MenuItem" or "MenuList"? The thing in the top layer is the `<menulist>` element, no?

Di Zhang

Good point, changed.

File third_party/blink/renderer/core/html/html_menu_item_element.cc
Line 297, Patchset 6: /*include_event_handler_text=*/true, &document) &&
Mason Freed . resolved

include_event_handler_text should be `false`, since the `exception_state` is null.

Di Zhang

Done

Line 300, Patchset 4: invoked_menulist->InvokePopover(*this);
Dominic Farolino . resolved

This runs script, right? Can you add a test that exercises what happens if the popover is closed here while script runs? That should help inform us as to how we should proceed from here. Can `invoked_menulist` be closed at this point?

Di Zhang

If the popover is closed, `can_show` will return true and this line will run. But isn't that what the current test is testing (using ArrowRight to move activeElement to `h`)?
note: This is similar logic as what is used in `HTMLElement::HandleCommandInternal`, where it also calls `IsPopoverReady()` before calling either `HidePopoverInternal()` or `InvokePopover()`.

Di Zhang

Added a test where there is the event listener for before toggle. The code still runs, but will have popover warnings like "VM26:2 The `beforetoggle` event handler for a popover triggered another popover to be shown or hidden. Or a `loseinterest` event handler was cancelled. This is not recommended.".

Line 310, Patchset 6: // Else, this does not invoke a menulist and we close all popovers.
Mason Freed . resolved

nit: `this menuitem does not...`

Di Zhang

Done

Line 317, Patchset 6: invoker_menuitem = DynamicTo<HTMLMenuItemElement>(
Mason Freed . resolved

This will be nullptr if there's an ancestor (non-menu) popover, which I think will lead to all of it being closed, right? That seems wrong.

Di Zhang

I changed the logic to not have the DynamicTo here and instead just track the invoker. If an invoker is found, then check whether it is a menuitem in a menubar (to use the MenuItemList to find next/previous). If not, focus on invoker.

Line 323, Patchset 6: ancestor_popover, document, HidePopoverFocusBehavior::kNone,
Mason Freed . resolved

Won't this always be `nullptr`?

Di Zhang

Right. I can change to that to be clearer.

Line 333, Patchset 6: if (auto* previous = ancestor_menuitems.NextFocusableMenuItem(
Mason Freed . resolved

`next` ?

Di Zhang

Done

Line 349, Patchset 6: DCHECK(menulist->popoverOpen());
Mason Freed . resolved

I think you could hit this DCHECK:

```
<menulist id=foo tabindex=0>
<style>
#foo {display:block}
</style>
```

...then focus the menulist and hit the left arrow

Di Zhang

You are right. It gets hit. I removed that DCHECK and added the test.

Line 354, Patchset 6: /*include_event_handler_text=*/true, &GetDocument());
Mason Freed . resolved

ditto

Di Zhang

Done

Line 357, Patchset 6: invoker, HidePopoverFocusBehavior::kFocusPreviousElement,
Mason Freed . resolved

Do you want it to focus the previous element in this case? Seems like no, since you're handling focus below.

Di Zhang

Done

Line 375, Patchset 6: event.SetDefaultHandled();
Mason Freed . resolved

Should we set default handled if neither branch above got hit? I.e. what if it was just a `<menuitem>` outside a menulist or menubar?

Di Zhang

Changed to handle event by focusing on invoker in this case. This way, it will behave the same way as if the invoker is a button.

Line 379, Patchset 6: // TODO: implement scrolling to visible menuitem, for
Mason Freed . resolved

Can you add a bug link

Di Zhang

Yes, also added one for each TODO for tracking purposes.

Line 428, Patchset 6: /*include_event_handler_text=*/true, &GetDocument()) &&
Mason Freed . resolved

ditto

Di Zhang

Done

Line 429, Patchset 6: !invoked_menulist->popoverOpen();
Mason Freed . resolved

I don't think you need to check for !popoverOpen here - `IsPopoverReady` should do that for you already.

Di Zhang

Done

File third_party/blink/web_tests/external/wpt/html/semantics/menu/tentative/focus-menu-elements-nested-arrowoperations.html
Line 51, Patchset 6: await test_driver.send_keys(document.activeElement, Tab);
Mason Freed . resolved

It might be a good idea to focus a starting element at the start of this test, so that you're starting from a known state.

Di Zhang

Done

Gerrit-Comment-Date: Wed, 18 Jun 2025 21:16:57 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: Yes
Comment-In-Reply-To: Dominic Farolino <d...@chromium.org>
Comment-In-Reply-To: Di Zhang <dizh...@chromium.org>
Comment-In-Reply-To: Mason Freed <mas...@chromium.org>
satisfied_requirement
unsatisfied_requirement
open
diffy

Mason Freed (Gerrit)

unread,
Jun 18, 2025, 6:15:29 PMJun 18
to Di Zhang, Dominic Farolino, Chromium LUCI CQ, chromium...@chromium.org, blink-rev...@chromium.org, blink-revie...@chromium.org, blink-...@chromium.org
Attention needed from Di Zhang and Dominic Farolino

Mason Freed added 2 comments

Commit Message
Line 29, Patchset 9 (Latest):Note these changes are for arrow navigation starting from a menuitem. A follow-up patch for menulist invoked from button might be
necessary.
Mason Freed . unresolved

nit: can you line wrap this at 72 chars?

File third_party/blink/renderer/core/html/html_element.h
Line 104, Patchset 9 (Latest): kMenuList,
Mason Freed . unresolved

Per our offline conversation, I thought the plan was to remove this entirely now?

Open in Gerrit

Related details

Attention is currently required from:
  • Di Zhang
  • Dominic Farolino
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: I97aa335a3e4702caf12d503f7ef6a069086e6307
Gerrit-Change-Number: 6644040
Gerrit-PatchSet: 9
Gerrit-Owner: Di Zhang <dizh...@chromium.org>
Gerrit-Reviewer: Di Zhang <dizh...@chromium.org>
Gerrit-Reviewer: Dominic Farolino <d...@chromium.org>
Gerrit-Reviewer: Mason Freed <mas...@chromium.org>
Gerrit-CC: Joey Arhar <jar...@chromium.org>
Gerrit-Attention: Dominic Farolino <d...@chromium.org>
Gerrit-Attention: Di Zhang <dizh...@chromium.org>
Gerrit-Comment-Date: Wed, 18 Jun 2025 22:15:13 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
satisfied_requirement
unsatisfied_requirement
open
diffy

Di Zhang (Gerrit)

unread,
Jun 18, 2025, 6:21:09 PMJun 18
to Dominic Farolino, Mason Freed, Chromium LUCI CQ, chromium...@chromium.org, blink-rev...@chromium.org, blink-revie...@chromium.org, blink-...@chromium.org
Attention needed from Dominic Farolino and Mason Freed

Di Zhang added 2 comments

Commit Message
Line 29, Patchset 9:Note these changes are for arrow navigation starting from a menuitem. A follow-up patch for menulist invoked from button might be
necessary.
Mason Freed . resolved

nit: can you line wrap this at 72 chars?

Di Zhang

Done

File third_party/blink/renderer/core/html/html_element.h
Mason Freed . unresolved

Per our offline conversation, I thought the plan was to remove this entirely now?

Attention is currently required from:
  • Dominic Farolino
  • Mason Freed
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: I97aa335a3e4702caf12d503f7ef6a069086e6307
Gerrit-Change-Number: 6644040
Gerrit-PatchSet: 10
Gerrit-Owner: Di Zhang <dizh...@chromium.org>
Gerrit-Reviewer: Di Zhang <dizh...@chromium.org>
Gerrit-Reviewer: Dominic Farolino <d...@chromium.org>
Gerrit-Reviewer: Mason Freed <mas...@chromium.org>
Gerrit-CC: Joey Arhar <jar...@chromium.org>
Gerrit-Attention: Dominic Farolino <d...@chromium.org>
Gerrit-Attention: Mason Freed <mas...@chromium.org>
Gerrit-Comment-Date: Wed, 18 Jun 2025 22:20:58 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
Comment-In-Reply-To: Mason Freed <mas...@chromium.org>
satisfied_requirement
unsatisfied_requirement
open
diffy

Mason Freed (Gerrit)

unread,
Jun 20, 2025, 5:57:31 PMJun 20
to Di Zhang, Dominic Farolino, Chromium LUCI CQ, chromium...@chromium.org, blink-rev...@chromium.org, blink-revie...@chromium.org, blink-...@chromium.org
Attention needed from Di Zhang and Dominic Farolino

Mason Freed added 3 comments

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

I still think it'd be better not to add a value to the enum for menus, since they're just popovers really.

Commit Message
Line 18, Patchset 6: - Else, close all popovers. If it has an ancestor menubar and its
Mason Freed . resolved

Why do we close all popovers in this case? At least the Google docs menu opens the next menuitem in the menubar in this case.

Di Zhang

I think it is a similar pattern. It closes all currently opened popovers and focus on the next invoker, if available. The difference is that when it focuses on an invoker menuitem, it automatically opens it. In the current implementation, we need a DOM Activation to open a popover/menulist. Maybe that needs to be changed.

Di Zhang

After offline chat, agree that there is a risk menus can be inside a popover and that popover shouldn't close. Updated the logic and added a test.

Please take another look at the close popovers logic, thank you.

Mason Freed

The new test looks good.

File third_party/blink/renderer/core/html/html_element.h
Mason Freed . unresolved

Per our offline conversation, I thought the plan was to remove this entirely now?

Di Zhang

Yes, but using only kPopover fails two CHECKs so it felt:
1. https://source.chromium.org/chromium/chromium/src/+/main:third_party/blink/renderer/core/html/html_element.cc;l=2167;drc=4388d13dc2a92e9123085050cf95db052cba8ab3
2. https://source.chromium.org/chromium/chromium/src/+/main:third_party/blink/renderer/core/html/html_element.cc;l=2224;drc=4388d13dc2a92e9123085050cf95db052cba8ab3

So it felt still necessary to have this enum distinction.

Mason Freed

I think maybe those two CHECKs should be adjusted to know about menus, perhaps? I.e. in both cases, it's "ok" if the provided popover is also a `<menulist>`.

Open in Gerrit

Related details

Attention is currently required from:
  • Di Zhang
  • Dominic Farolino
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: I97aa335a3e4702caf12d503f7ef6a069086e6307
Gerrit-Change-Number: 6644040
Gerrit-PatchSet: 10
Gerrit-Owner: Di Zhang <dizh...@chromium.org>
Gerrit-Reviewer: Di Zhang <dizh...@chromium.org>
Gerrit-Reviewer: Dominic Farolino <d...@chromium.org>
Gerrit-Reviewer: Mason Freed <mas...@chromium.org>
Gerrit-CC: Joey Arhar <jar...@chromium.org>
Gerrit-Attention: Dominic Farolino <d...@chromium.org>
Gerrit-Attention: Di Zhang <dizh...@chromium.org>
Gerrit-Comment-Date: Fri, 20 Jun 2025 21:57:21 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
satisfied_requirement
unsatisfied_requirement
open
diffy

Di Zhang (Gerrit)

unread,
Jun 24, 2025, 12:50:39 PMJun 24
to Dominic Farolino, Mason Freed, Chromium LUCI CQ, chromium...@chromium.org, blink-rev...@chromium.org, blink-revie...@chromium.org, blink-...@chromium.org
Attention needed from Dominic Farolino and Mason Freed

Di Zhang voted and added 2 comments

Votes added by Di Zhang

Commit-Queue+1

2 comments

File third_party/blink/renderer/core/html/html_element.h
Mason Freed . resolved

Per our offline conversation, I thought the plan was to remove this entirely now?

Di Zhang

Yes, but using only kPopover fails two CHECKs so it felt:
1. https://source.chromium.org/chromium/chromium/src/+/main:third_party/blink/renderer/core/html/html_element.cc;l=2167;drc=4388d13dc2a92e9123085050cf95db052cba8ab3
2. https://source.chromium.org/chromium/chromium/src/+/main:third_party/blink/renderer/core/html/html_element.cc;l=2224;drc=4388d13dc2a92e9123085050cf95db052cba8ab3

So it felt still necessary to have this enum distinction.

Mason Freed

I think maybe those two CHECKs should be adjusted to know about menus, perhaps? I.e. in both cases, it's "ok" if the provided popover is also a `<menulist>`.

Di Zhang

Done

File third_party/blink/renderer/core/html/html_menu_item_element.cc
Line 315, Patchset 4: HTMLMenuItemElement* invoker_menuitem;
Dominic Farolino . resolved

Since this is a pointer, shouldn't we initialize this to non-garbage memory?

Di Zhang

I am not sure I understood, but I changed to initialize to nullptr.
I also changed to not enforce menuitem check yet, since it is possible the ancestor invoker is a button.

Di Zhang

Done

Open in Gerrit

Related details

Attention is currently required from:
  • Dominic Farolino
  • Mason Freed
Submit Requirements:
  • requirement satisfiedCode-Coverage
  • requirement is not satisfiedCode-Owners
  • 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: I97aa335a3e4702caf12d503f7ef6a069086e6307
Gerrit-Change-Number: 6644040
Gerrit-PatchSet: 11
Gerrit-Owner: Di Zhang <dizh...@chromium.org>
Gerrit-Reviewer: Di Zhang <dizh...@chromium.org>
Gerrit-Reviewer: Dominic Farolino <d...@chromium.org>
Gerrit-Reviewer: Mason Freed <mas...@chromium.org>
Gerrit-CC: Joey Arhar <jar...@chromium.org>
Gerrit-Attention: Dominic Farolino <d...@chromium.org>
Gerrit-Attention: Mason Freed <mas...@chromium.org>
Gerrit-Comment-Date: Tue, 24 Jun 2025 16:50:28 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: Yes
Comment-In-Reply-To: Dominic Farolino <d...@chromium.org>
satisfied_requirement
unsatisfied_requirement
open
diffy

Mason Freed (Gerrit)

unread,
Jun 24, 2025, 2:00:00 PMJun 24
to Di Zhang, Dominic Farolino, Chromium LUCI CQ, chromium...@chromium.org, blink-rev...@chromium.org, blink-revie...@chromium.org, blink-...@chromium.org
Attention needed from Di Zhang and Dominic Farolino

Mason Freed voted and added 2 comments

Votes added by Mason Freed

Code-Review+1

2 comments

Patchset-level comments
File third_party/blink/renderer/core/html/html_element.cc
Line 2229, Patchset 11 (Latest): Element* new_popovers_invoker =
Mason Freed . unresolved

Can you change the comment to:

```
// If top_layer_element is an open menulist popover, find its invoker.
// Since "normal" popovers don't go through this code path (see the
// CHECK above), pass `nullptr` otherwise.
```
Open in Gerrit

Related details

Attention is currently required from:
  • Di Zhang
  • Dominic Farolino
Submit Requirements:
  • requirement satisfiedCode-Coverage
  • requirement satisfiedCode-Owners
  • requirement 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: I97aa335a3e4702caf12d503f7ef6a069086e6307
Gerrit-Change-Number: 6644040
Gerrit-PatchSet: 11
Gerrit-Owner: Di Zhang <dizh...@chromium.org>
Gerrit-Reviewer: Di Zhang <dizh...@chromium.org>
Gerrit-Reviewer: Dominic Farolino <d...@chromium.org>
Gerrit-Reviewer: Mason Freed <mas...@chromium.org>
Gerrit-CC: Joey Arhar <jar...@chromium.org>
Gerrit-Attention: Dominic Farolino <d...@chromium.org>
Gerrit-Attention: Di Zhang <dizh...@chromium.org>
Gerrit-Comment-Date: Tue, 24 Jun 2025 17:59:47 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: Yes
satisfied_requirement
unsatisfied_requirement
open
diffy

Di Zhang (Gerrit)

unread,
Jun 24, 2025, 2:29:36 PMJun 24
to Mason Freed, Dominic Farolino, Chromium LUCI CQ, chromium...@chromium.org, blink-rev...@chromium.org, blink-revie...@chromium.org, blink-...@chromium.org
Attention needed from Dominic Farolino

Di Zhang voted and added 1 comment

Votes added by Di Zhang

Commit-Queue+1

1 comment

File third_party/blink/renderer/core/html/html_element.cc
Line 2229, Patchset 11: Element* new_popovers_invoker =
Mason Freed . resolved

Can you change the comment to:

```
// If top_layer_element is an open menulist popover, find its invoker.
// Since "normal" popovers don't go through this code path (see the
// CHECK above), pass `nullptr` otherwise.
```
Di Zhang

Done

Open in Gerrit

Related details

Attention is currently required from:
  • Dominic Farolino
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: I97aa335a3e4702caf12d503f7ef6a069086e6307
Gerrit-Change-Number: 6644040
Gerrit-PatchSet: 12
Gerrit-Owner: Di Zhang <dizh...@chromium.org>
Gerrit-Reviewer: Di Zhang <dizh...@chromium.org>
Gerrit-Reviewer: Dominic Farolino <d...@chromium.org>
Gerrit-Reviewer: Mason Freed <mas...@chromium.org>
Gerrit-CC: Joey Arhar <jar...@chromium.org>
Gerrit-Attention: Dominic Farolino <d...@chromium.org>
Gerrit-Comment-Date: Tue, 24 Jun 2025 18:29:25 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: Yes
Comment-In-Reply-To: Mason Freed <mas...@chromium.org>
satisfied_requirement
open
diffy

Dominic Farolino (Gerrit)

unread,
Jun 24, 2025, 2:34:58 PMJun 24
to Di Zhang, Mason Freed, Chromium LUCI CQ, chromium...@chromium.org, blink-rev...@chromium.org, blink-revie...@chromium.org, blink-...@chromium.org
Attention needed from Di Zhang

Dominic Farolino voted Code-Review+1

Code-Review+1
Open in Gerrit

Related details

Attention is currently required from:
  • Di Zhang
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: I97aa335a3e4702caf12d503f7ef6a069086e6307
Gerrit-Change-Number: 6644040
Gerrit-PatchSet: 12
Gerrit-Owner: Di Zhang <dizh...@chromium.org>
Gerrit-Reviewer: Di Zhang <dizh...@chromium.org>
Gerrit-Reviewer: Dominic Farolino <d...@chromium.org>
Gerrit-Reviewer: Mason Freed <mas...@chromium.org>
Gerrit-CC: Joey Arhar <jar...@chromium.org>
Gerrit-Attention: Di Zhang <dizh...@chromium.org>
Gerrit-Comment-Date: Tue, 24 Jun 2025 18:34:53 +0000
Gerrit-HasComments: No
Gerrit-Has-Labels: Yes
satisfied_requirement
open
diffy

Di Zhang (Gerrit)

unread,
Jun 24, 2025, 2:40:36 PMJun 24
to Dominic Farolino, Mason Freed, Chromium LUCI CQ, chromium...@chromium.org, blink-rev...@chromium.org, blink-revie...@chromium.org, blink-...@chromium.org

Di Zhang voted Commit-Queue+2

Commit-Queue+2
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: I97aa335a3e4702caf12d503f7ef6a069086e6307
Gerrit-Change-Number: 6644040
Gerrit-PatchSet: 12
Gerrit-Owner: Di Zhang <dizh...@chromium.org>
Gerrit-Reviewer: Di Zhang <dizh...@chromium.org>
Gerrit-Reviewer: Dominic Farolino <d...@chromium.org>
Gerrit-Reviewer: Mason Freed <mas...@chromium.org>
Gerrit-CC: Joey Arhar <jar...@chromium.org>
Gerrit-Comment-Date: Tue, 24 Jun 2025 18:40:27 +0000
Gerrit-HasComments: No
Gerrit-Has-Labels: Yes
satisfied_requirement
open
diffy

Chromium LUCI CQ (Gerrit)

unread,
Jun 24, 2025, 3:17:28 PMJun 24
to Di Zhang, Dominic Farolino, Mason Freed, chromium...@chromium.org, blink-rev...@chromium.org, blink-revie...@chromium.org, blink-...@chromium.org

Chromium LUCI CQ submitted the change

Change information

Commit message:
[menu] Activation behavior for open/close menu on arrow navigation

This patch updates the HTMLMenuItemElement::DefaultEventHandler method
to handle invoking menulist on arrow key navigations. We follow the
suggestions as outlined by APG for menubar [1].

- If element is a menuitem in a menulist,
- If arrow RIGHT,
- If menuitem invokes a sub-menulist,
- If sub-menulist is closed, show the sub-menulist.
- Focus on its first child.

- Else, close all popovers. If it has an ancestor menubar and its
      ancestor invoker has a next menuitem, focus on that next menuitem.
- Else if arrow LEFT,
- Close the menulist that this menuitem is a child of.
- If its invoker is in a menulist, focus on this invoker.
- If its invoker is in a menubar, focus on the previous menuitem.
- Else if element is a menuitem in a menubar,
- If element invokes a menulist,
- If arrow UP, focus the last menuitem in the menulist.
- Else if arrow DOWN, focus the first menuitem in the menulist.


Note these changes are for arrow navigation starting from a menuitem. A
follow-up patch for menulist invoked from button might be necessary.

Change-Id: I97aa335a3e4702caf12d503f7ef6a069086e6307
Bug: 422803239, 406566432
Reviewed-by: Mason Freed <mas...@chromium.org>
Commit-Queue: Di Zhang <dizh...@chromium.org>
Reviewed-by: Dominic Farolino <d...@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1478114}
Files:
  • M third_party/blink/renderer/core/html/html_element.cc
  • M third_party/blink/renderer/core/html/html_menu_item_element.cc
  • M third_party/blink/web_tests/external/wpt/html/semantics/menu/tentative/focus-menu-elements-arrowoperations.html
  • A third_party/blink/web_tests/external/wpt/html/semantics/menu/tentative/focus-menu-elements-nested-arrowoperations.html
Change size: L
Delta: 4 files changed, 261 insertions(+), 25 deletions(-)
Branch: refs/heads/main
Submit Requirements:
  • requirement satisfiedCode-Review: +1 by Mason Freed, +1 by Dominic Farolino
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: I97aa335a3e4702caf12d503f7ef6a069086e6307
Gerrit-Change-Number: 6644040
Gerrit-PatchSet: 13
Gerrit-Owner: Di Zhang <dizh...@chromium.org>
Gerrit-Reviewer: Chromium LUCI CQ <chromiu...@luci-project-accounts.iam.gserviceaccount.com>
Gerrit-Reviewer: Di Zhang <dizh...@chromium.org>
Gerrit-Reviewer: Dominic Farolino <d...@chromium.org>
Gerrit-Reviewer: Mason Freed <mas...@chromium.org>
open
diffy
satisfied_requirement

Blink W3C Test Autoroller (Gerrit)

unread,
Jun 24, 2025, 4:07:34 PMJun 24
to Chromium LUCI CQ, Di Zhang, Dominic Farolino, Mason Freed, chromium...@chromium.org, blink-rev...@chromium.org, blink-revie...@chromium.org, blink-...@chromium.org

Message from Blink W3C Test Autoroller

The WPT PR for this CL has been merged upstream! https://github.com/web-platform-tests/wpt/pull/53363

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: I97aa335a3e4702caf12d503f7ef6a069086e6307
Gerrit-Change-Number: 6644040
Gerrit-PatchSet: 13
Gerrit-Owner: Di Zhang <dizh...@chromium.org>
Gerrit-Reviewer: Chromium LUCI CQ <chromiu...@luci-project-accounts.iam.gserviceaccount.com>
Gerrit-Reviewer: Di Zhang <dizh...@chromium.org>
Gerrit-Reviewer: Dominic Farolino <d...@chromium.org>
Gerrit-Reviewer: Mason Freed <mas...@chromium.org>
Gerrit-CC: Blink W3C Test Autoroller <blink-w3c-te...@chromium.org>
Gerrit-CC: Joey Arhar <jar...@chromium.org>
Gerrit-Comment-Date: Tue, 24 Jun 2025 20:07:30 +0000
Gerrit-HasComments: No
Gerrit-Has-Labels: No
satisfied_requirement
open
diffy
Reply all
Reply to author
Forward
0 new messages