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/. */
6 #include "mozilla/widget/NativeMenuSupport.h"
8 #include "MainThreadUtils.h"
9 #include "mozilla/StaticPrefs_browser.h"
10 #include "mozilla/StaticPrefs_widget.h"
11 #include "NativeMenuMac.h"
12 #include "nsCocoaWindow.h"
13 #include "nsMenuBarX.h"
15 namespace mozilla::widget {
17 void NativeMenuSupport::CreateNativeMenuBar(nsIWidget* aParent,
18 dom::Element* aMenuBarElement) {
19 MOZ_RELEASE_ASSERT(NS_IsMainThread(),
20 "Attempting to create native menu bar on wrong thread!");
22 // Create the menubar and give it to the parent window. The parent takes
24 static_cast<nsCocoaWindow*>(aParent)->SetMenuBar(
25 MakeRefPtr<nsMenuBarX>(aMenuBarElement));
28 already_AddRefed<NativeMenu> NativeMenuSupport::CreateNativeContextMenu(
29 dom::Element* aPopup) {
30 return MakeAndAddRef<NativeMenuMac>(aPopup);
33 bool NativeMenuSupport::ShouldUseNativeContextMenus() {
34 return StaticPrefs::widget_macos_native_context_menus();
37 } // namespace mozilla::widget