2 /* -*- Mode: c++; tab-width: 2; indent-tabs-mode: nil; -*- */
3 /* This Source Code Form is subject to the terms of the Mozilla Public
4 * License, v. 2.0. If a copy of the MPL was not distributed with this
5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
7 #ifndef mozilla_widget_NativeMenuGtk_h
8 #define mozilla_widget_NativeMenuGtk_h
10 #include "mozilla/widget/NativeMenu.h"
11 #include "mozilla/EventForwards.h"
24 class NativeMenuGtk
: public NativeMenu
{
26 // Whether we can use native menu popups on GTK.
29 explicit NativeMenuGtk(dom::Element
* aElement
);
32 MOZ_CAN_RUN_SCRIPT_BOUNDARY
void ShowAsContextMenu(
33 nsIFrame
* aClickedFrame
, const CSSIntPoint
& aPosition
,
34 bool aIsContextMenu
) override
;
35 bool Close() override
;
36 void ActivateItem(dom::Element
* aItemElement
, Modifiers aModifiers
,
37 int16_t aButton
, ErrorResult
& aRv
) override
;
38 void OpenSubmenu(dom::Element
* aMenuElement
) override
;
39 void CloseSubmenu(dom::Element
* aMenuElement
) override
;
40 RefPtr
<dom::Element
> Element() override
;
41 void AddObserver(NativeMenu::Observer
* aObserver
) override
{
42 mObservers
.AppendElement(aObserver
);
44 void RemoveObserver(NativeMenu::Observer
* aObserver
) override
{
45 mObservers
.RemoveElement(aObserver
);
48 MOZ_CAN_RUN_SCRIPT
void OnUnmap();
51 virtual ~NativeMenuGtk();
53 MOZ_CAN_RUN_SCRIPT
void FireEvent(EventMessage
);
55 bool mPoppedUp
= false;
56 RefPtr
<GtkWidget
> mNativeMenu
;
57 RefPtr
<MenuModel
> mMenuModel
;
58 nsTArray
<NativeMenu::Observer
*> mObservers
;
62 } // namespace mozilla