Bug 1931425 - Limit how often moz-label's #setStyles runs r=reusable-components-revie...
[gecko.git] / widget / cocoa / nsMenuUtilsX.h
blob5b8993713bd7317816a555c05270b8f1516138ac
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 #ifndef nsMenuUtilsX_h_
7 #define nsMenuUtilsX_h_
9 #include "nscore.h"
10 #include "nsStringFwd.h"
12 #import <Cocoa/Cocoa.h>
14 class nsIContent;
15 class nsMenuBarX;
16 class nsMenuX;
18 // Namespace containing utility functions used in our native menu
19 // implementation.
20 namespace nsMenuUtilsX {
21 void DispatchCommandTo(nsIContent* aTargetContent,
22 NSEventModifierFlags aModifierFlags, int16_t aButton);
23 NSString* GetTruncatedCocoaLabel(const nsString& itemLabel);
24 uint8_t GeckoModifiersForNodeAttribute(const nsString& modifiersAttribute);
25 unsigned int MacModifiersForGeckoModifiers(uint8_t geckoModifiers);
26 nsMenuBarX* GetHiddenWindowMenuBar(); // returned object is not retained
27 NSMenuItem* GetStandardEditMenuItem(); // returned object is not retained
28 bool NodeIsHiddenOrCollapsed(nsIContent* aContent);
30 // Find the menu item by following the path aLocationString from aRootMenu.
31 // aLocationString is a '|'-separated list of integers, where each integer is
32 // the index of the menu item in the menu.
33 // aIsMenuBar needs to be true if aRootMenu is the app's mainMenu, so that the
34 // app menu can be skipped during the search.
35 NSMenuItem* NativeMenuItemWithLocation(NSMenu* aRootMenu,
36 NSString* aLocationString,
37 bool aIsMenuBar);
39 // Traverse the menu tree and check that there are no cycles or NSMenu(Item)
40 // objects that are used more than once. If inconsistencies are found, these
41 // functions crash the process.
42 void CheckNativeMenuConsistency(NSMenu* aMenu);
43 void CheckNativeMenuConsistency(NSMenuItem* aMenuItem);
45 // Print out debugging information about the native menu tree structure.
46 void DumpNativeMenu(NSMenu* aMenu);
47 void DumpNativeMenuItem(NSMenuItem* aMenuItem);
49 extern bool gIsSynchronouslyActivatingNativeMenuItemDuringTest;
51 } // namespace nsMenuUtilsX
53 #endif // nsMenuUtilsX_h_