mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-01-23 13:04:28 +00:00
Bug 1705120 - Add OnNativeMenuWillActivateItem observer method for NativeMenu::Observer and call it at the right times. r=harry
Differential Revision: https://phabricator.services.mozilla.com/D114435
This commit is contained in:
parent
607f63b94a
commit
0350405261
@ -891,6 +891,9 @@ void nsXULPopupManager::OnNativeSubMenuClosed(
|
||||
mNativeMenuSubmenuStates.Remove(aPopupElement);
|
||||
}
|
||||
|
||||
void nsXULPopupManager::OnNativeMenuWillActivateItem(
|
||||
mozilla::dom::Element* aMenuItemElement) {}
|
||||
|
||||
void nsXULPopupManager::ShowPopupAtScreenRect(
|
||||
nsIContent* aPopup, const nsAString& aPosition, const nsIntRect& aRect,
|
||||
bool aIsContextMenu, bool aAttributesOverride, Event* aTriggerEvent) {
|
||||
|
@ -368,6 +368,8 @@ class nsXULPopupManager final : public nsIDOMEventListener,
|
||||
void OnNativeSubMenuWillOpen(mozilla::dom::Element* aPopupElement) override;
|
||||
void OnNativeSubMenuDidOpen(mozilla::dom::Element* aPopupElement) override;
|
||||
void OnNativeSubMenuClosed(mozilla::dom::Element* aPopupElement) override;
|
||||
void OnNativeMenuWillActivateItem(
|
||||
mozilla::dom::Element* aMenuItemElement) override;
|
||||
|
||||
static nsXULPopupManager* sInstance;
|
||||
|
||||
|
@ -73,6 +73,10 @@ class NativeMenu {
|
||||
|
||||
// Called after the popuphidden event of a submenu fired.
|
||||
virtual void OnNativeSubMenuClosed(dom::Element* aPopupElement) = 0;
|
||||
|
||||
// Called before the command event of an activated menu item fires.
|
||||
virtual void OnNativeMenuWillActivateItem(
|
||||
dom::Element* aMenuItemElement) = 0;
|
||||
};
|
||||
|
||||
// Add an observer that gets notified of menu opening and closing.
|
||||
|
@ -193,7 +193,15 @@ void NativeMenuMac::OnMenuDidOpen(dom::Element* aPopupElement) {
|
||||
}
|
||||
|
||||
void NativeMenuMac::OnMenuWillActivateItem(mozilla::dom::Element* aPopupElement,
|
||||
mozilla::dom::Element* aMenuItemElement) {}
|
||||
mozilla::dom::Element* aMenuItemElement) {
|
||||
// Our caller isn't keeping us alive, so make sure we stay alive throughout this function in case
|
||||
// one of the observer notifications destroys us.
|
||||
RefPtr<NativeMenuMac> kungFuDeathGrip(this);
|
||||
|
||||
for (NativeMenu::Observer* observer : mObservers.Clone()) {
|
||||
observer->OnNativeMenuWillActivateItem(aMenuItemElement);
|
||||
}
|
||||
}
|
||||
|
||||
void NativeMenuMac::OnMenuClosed(dom::Element* aPopupElement) {
|
||||
// Our caller isn't keeping us alive, so make sure we stay alive throughout this function in case
|
||||
|
Loading…
x
Reference in New Issue
Block a user