Bug 1892041 - Part 3: Update test exclusions. r=spidermonkey-reviewers,dminor
[gecko.git] / widget / WidgetUtils.h
blob1971c3854c6ed5d841e053e734c5b5c238069b1b
1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*-
2 * vim: sw=2 ts=8 et :
3 */
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"
13 #include "nsRect.h"
15 class nsIWidget;
16 class nsPIDOMWindowOuter;
18 namespace mozilla {
20 // NB: these must match up with pseudo-enum in nsIScreen.idl.
21 enum ScreenRotation {
22 ROTATION_0 = 0,
23 ROTATION_90,
24 ROTATION_180,
25 ROTATION_270,
27 ROTATION_COUNT
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);
39 namespace widget {
41 class WidgetUtils {
42 public:
43 /**
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
46 * widget.
48 static void Shutdown();
50 /**
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);
57 /**
58 * Compute our keyCode value (NS_VK_*) from an ASCII character.
60 static uint32_t ComputeKeyCodeFromChar(uint32_t aCharCode);
62 /**
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
71 * a Latin character.
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
75 * NS_VK_[A-Z].
76 * Note that must not be nullptr.
78 static void GetLatinCharCodeForKeyCode(uint32_t aKeyCode, bool aIsCapsLock,
79 uint32_t* aUnshiftedCharCode,
80 uint32_t* aShiftedCharCode);
82 /**
83 * Send bidi keyboard information to content process
85 static void SendBidiKeyboardInfoToContent();
87 /**
88 * Get branchShortName from string bundle
90 static void GetBrandShortName(nsAString& aBrandName);
93 } // namespace widget
94 } // namespace mozilla
96 #endif // mozilla_WidgetUtils_h