Backed out changeset b4a0f8afc02e (bug 1857946) for causing bc failures at browser...
[gecko.git] / widget / cocoa / nsMenuUtilsX.h
blob0ec8d8555dbd27eace7f938a6e8d2f2c4c161aa2
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 implementation.
19 namespace nsMenuUtilsX {
20 void DispatchCommandTo(nsIContent* aTargetContent, NSEventModifierFlags aModifierFlags,
21 int16_t aButton);
22 NSString* GetTruncatedCocoaLabel(const nsString& itemLabel);
23 uint8_t GeckoModifiersForNodeAttribute(const nsString& modifiersAttribute);
24 unsigned int MacModifiersForGeckoModifiers(uint8_t geckoModifiers);
25 nsMenuBarX* GetHiddenWindowMenuBar(); // returned object is not retained
26 NSMenuItem* GetStandardEditMenuItem(); // returned object is not retained
27 bool NodeIsHiddenOrCollapsed(nsIContent* aContent);
29 // Find the menu item by following the path aLocationString from aRootMenu.
30 // aLocationString is a '|'-separated list of integers, where each integer is
31 // the index of the menu item in the menu.
32 // aIsMenuBar needs to be true if aRootMenu is the app's mainMenu, so that the
33 // app menu can be skipped during the search.
34 NSMenuItem* NativeMenuItemWithLocation(NSMenu* aRootMenu, NSString* aLocationString,
35 bool aIsMenuBar);
37 // Traverse the menu tree and check that there are no cycles or NSMenu(Item) objects that are used
38 // more than once. If inconsistencies are found, these functions crash the process.
39 void CheckNativeMenuConsistency(NSMenu* aMenu);
40 void CheckNativeMenuConsistency(NSMenuItem* aMenuItem);
42 // Print out debugging information about the native menu tree structure.
43 void DumpNativeMenu(NSMenu* aMenu);
44 void DumpNativeMenuItem(NSMenuItem* aMenuItem);
46 extern bool gIsSynchronouslyActivatingNativeMenuItemDuringTest;
48 } // namespace nsMenuUtilsX
50 #endif // nsMenuUtilsX_h_