summaryrefslogtreecommitdiffstats
path: root/widget/cocoa/nsMenuUtilsX.h
blob: 5b8993713bd7317816a555c05270b8f1516138ac (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */

#ifndef nsMenuUtilsX_h_
#define nsMenuUtilsX_h_

#include "nscore.h"
#include "nsStringFwd.h"

#import <Cocoa/Cocoa.h>

class nsIContent;
class nsMenuBarX;
class nsMenuX;

// Namespace containing utility functions used in our native menu
// implementation.
namespace nsMenuUtilsX {
void DispatchCommandTo(nsIContent* aTargetContent,
                       NSEventModifierFlags aModifierFlags, int16_t aButton);
NSString* GetTruncatedCocoaLabel(const nsString& itemLabel);
uint8_t GeckoModifiersForNodeAttribute(const nsString& modifiersAttribute);
unsigned int MacModifiersForGeckoModifiers(uint8_t geckoModifiers);
nsMenuBarX* GetHiddenWindowMenuBar();   // returned object is not retained
NSMenuItem* GetStandardEditMenuItem();  // returned object is not retained
bool NodeIsHiddenOrCollapsed(nsIContent* aContent);

// Find the menu item by following the path aLocationString from aRootMenu.
// aLocationString is a '|'-separated list of integers, where each integer is
// the index of the menu item in the menu.
// aIsMenuBar needs to be true if aRootMenu is the app's mainMenu, so that the
// app menu can be skipped during the search.
NSMenuItem* NativeMenuItemWithLocation(NSMenu* aRootMenu,
                                       NSString* aLocationString,
                                       bool aIsMenuBar);

// Traverse the menu tree and check that there are no cycles or NSMenu(Item)
// objects that are used more than once. If inconsistencies are found, these
// functions crash the process.
void CheckNativeMenuConsistency(NSMenu* aMenu);
void CheckNativeMenuConsistency(NSMenuItem* aMenuItem);

// Print out debugging information about the native menu tree structure.
void DumpNativeMenu(NSMenu* aMenu);
void DumpNativeMenuItem(NSMenuItem* aMenuItem);

extern bool gIsSynchronouslyActivatingNativeMenuItemDuringTest;

}  // namespace nsMenuUtilsX

#endif  // nsMenuUtilsX_h_