1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* This Source Code Form is subject to the terms of the Mozilla Public
3  * License, v. 2.0. If a copy of the MPL was not distributed with this
4  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
5 
6 #ifndef mozilla_widget_NativeMenuSupport_h
7 #define mozilla_widget_NativeMenuSupport_h
8 
9 #include "mozilla/RefPtr.h"
10 
11 class nsIWidget;
12 
13 namespace mozilla {
14 
15 namespace dom {
16 class Element;
17 }
18 
19 namespace widget {
20 
21 class NativeMenu;
22 
23 class NativeMenuSupport final {
24  public:
25   // Given a top-level window widget and a menu bar DOM node, sets up native
26   // menus. Once created, native menus are controlled via the DOM, including
27   // destruction.
28   static void CreateNativeMenuBar(nsIWidget* aParent,
29                                   dom::Element* aMenuBarElement);
30 
31   // Given a menupopup DOM node, create a NativeMenu instance that can be shown
32   // as a native context menu.
33   static already_AddRefed<NativeMenu> CreateNativeContextMenu(
34       dom::Element* aPopup);
35 
36   // Whether or not native context menus are enabled.
37   static bool ShouldUseNativeContextMenus();
38 };
39 
40 }  // namespace widget
41 }  // namespace mozilla
42 
43 #endif  // mozilla_widget_NativeMenuSupport_h
44