Bug 1805414 - Remove nsMenuFrame and nsMenuParent. r=smaug,Jamie,desktop-theme-reviewers,settings-reviewers,dao

Move most the event handling stuff to the DOM. I've left nsMenuBarFrame
for now, but I will be removing that in the future.

The basic set up is:

  * nsMenuParent becomes XULMenuParentElement (menubar or popup, manages
    the current active menu item)

  * nsMenuFrame -> XULButtonElements that return true for IsMenu().
    Can't use XULMenuElement because of <button type=menu>, which
    behaves like a, well, menu.

This makes the a11y events for menus (DOMMenuItem{Active,Inactive}) make
sense (before that we were firing duplicate Inactive events etc, and the
event order was rather suspicious).

Differential Revision: https://phabricator.services.mozilla.com/D164210
This commit is contained in:
Emilio Cobos Álvarez
2023-01-04 19:01:13 +00:00
parent 8f71f71f88
commit 59e7b13fee
77 changed files with 2472 additions and 3323 deletions

View File

@@ -150,7 +150,6 @@
// For style data reconstruction
#include "nsStyleChangeList.h"
#include "nsCSSFrameConstructor.h"
#include "nsMenuFrame.h"
#include "nsTreeBodyFrame.h"
#include "XULTreeElement.h"
#include "nsMenuPopupFrame.h"
@@ -8851,12 +8850,11 @@ bool PresShell::EventHandler::AdjustContextMenuKeyEvent(
WidgetMouseEvent* aMouseEvent) {
// if a menu is open, open the context menu relative to the active item on the
// menu.
nsXULPopupManager* pm = nsXULPopupManager::GetInstance();
if (pm) {
if (nsXULPopupManager* pm = nsXULPopupManager::GetInstance()) {
nsIFrame* popupFrame = pm->GetTopPopup(ePopupTypeMenu);
if (popupFrame) {
nsIFrame* itemFrame =
(static_cast<nsMenuPopupFrame*>(popupFrame))->GetCurrentMenuItem();
nsIFrame* itemFrame = (static_cast<nsMenuPopupFrame*>(popupFrame))
->GetCurrentMenuItemFrame();
if (!itemFrame) itemFrame = popupFrame;
nsCOMPtr<nsIWidget> widget = popupFrame->GetNearestWidget();