Bug 1869043 assert that graph set access is main thread only r=padenot
[gecko.git] / widget / cocoa / NativeMenuSupport.mm
blob2e94f6f7cfd9abbb0a128a3e847ddb2c70f17304
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
23   // ownership.
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