1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*-
4 /* This Source Code Form is subject to the terms of the Mozilla Public
5 * License, v. 2.0. If a copy of the MPL was not distributed with this file,
6 * You can obtain one at http://mozilla.org/MPL/2.0/. */
8 #ifndef mozilla_WidgetUtils_h
9 #define mozilla_WidgetUtils_h
11 #include "mozilla/AlreadyAddRefed.h"
12 #include "mozilla/gfx/Matrix.h"
16 class nsPIDOMWindowOuter
;
20 // NB: these must match up with pseudo-enum in nsIScreen.idl.
30 gfx::Matrix
ComputeTransformForRotation(const nsIntRect
& aBounds
,
31 ScreenRotation aRotation
);
33 gfx::Matrix
ComputeTransformForUnRotation(const nsIntRect
& aBounds
,
34 ScreenRotation aRotation
);
36 nsIntRect
RotateRect(nsIntRect aRect
, const nsIntRect
& aBounds
,
37 ScreenRotation aRotation
);
44 * Shutdown() is called when "xpcom-will-shutdown" is notified. This is
45 * useful when you need to observe the notification in XP level code under
48 static void Shutdown();
51 * Starting at the docshell item for the passed in DOM window this looks up
52 * the docshell tree until it finds a docshell item that has a widget.
54 static already_AddRefed
<nsIWidget
> DOMWindowToWidget(
55 nsPIDOMWindowOuter
* aDOMWindow
);
58 * Compute our keyCode value (NS_VK_*) from an ASCII character.
60 static uint32_t ComputeKeyCodeFromChar(uint32_t aCharCode
);
63 * Get unshifted charCode and shifted charCode for aKeyCode if the keyboad
64 * layout is a Latin keyboard layout.
66 * @param aKeyCode Our keyCode (NS_VK_*).
67 * @param aIsCapsLock TRUE if CapsLock is Locked. Otherwise, FALSE.
68 * This is used only when aKeyCode is NS_VK_[0-9].
69 * @param aUnshiftedCharCode CharCode for aKeyCode without Shift key.
70 * This may be zero if aKeyCode key doesn't input
72 * Note that must not be nullptr.
73 * @param aShiftedCharCode CharCode for aKeyCOde with Shift key.
74 * This is always 0 when aKeyCode isn't
76 * Note that must not be nullptr.
78 static void GetLatinCharCodeForKeyCode(uint32_t aKeyCode
, bool aIsCapsLock
,
79 uint32_t* aUnshiftedCharCode
,
80 uint32_t* aShiftedCharCode
);
83 * Send bidi keyboard information to content process
85 static void SendBidiKeyboardInfoToContent();
88 * Get branchShortName from string bundle
90 static void GetBrandShortName(nsAString
& aBrandName
);
92 /* When packaged as a snap, strict confinement needs to be accounted for.
93 See https://snapcraft.io/docs for details.
94 Return the snap's instance name, or null when not running as a snap. */
95 static const char* GetSnapInstanceName();
99 } // namespace mozilla
101 #endif // mozilla_WidgetUtils_h