Bug 1671598 [wpt PR 26128] - [AspectRatio] Fix divide by zero with a small float...
[gecko.git] / widget / WidgetUtils.h
bloba93fe27f06bb8dc9fe115839436b6b316d9bc7c7
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/EventForwards.h"
12 #include "mozilla/gfx/Matrix.h"
13 #include "nsCOMPtr.h"
14 #include "nsIWidget.h"
15 #include "nsRect.h"
17 class nsPIDOMWindowOuter;
19 namespace mozilla {
21 // NB: these must match up with pseudo-enum in nsIScreen.idl.
22 enum ScreenRotation {
23 ROTATION_0 = 0,
24 ROTATION_90,
25 ROTATION_180,
26 ROTATION_270,
28 ROTATION_COUNT
31 gfx::Matrix ComputeTransformForRotation(const nsIntRect& aBounds,
32 ScreenRotation aRotation);
34 gfx::Matrix ComputeTransformForUnRotation(const nsIntRect& aBounds,
35 ScreenRotation aRotation);
37 nsIntRect RotateRect(nsIntRect aRect, const nsIntRect& aBounds,
38 ScreenRotation aRotation);
40 namespace widget {
42 class WidgetUtils {
43 public:
44 /**
45 * Shutdown() is called when "xpcom-will-shutdown" is notified. This is
46 * useful when you need to observe the notification in XP level code under
47 * widget.
49 static void Shutdown();
51 /**
52 * Starting at the docshell item for the passed in DOM window this looks up
53 * the docshell tree until it finds a docshell item that has a widget.
55 static already_AddRefed<nsIWidget> DOMWindowToWidget(
56 nsPIDOMWindowOuter* aDOMWindow);
58 /**
59 * Compute our keyCode value (NS_VK_*) from an ASCII character.
61 static uint32_t ComputeKeyCodeFromChar(uint32_t aCharCode);
63 /**
64 * Get unshifted charCode and shifted charCode for aKeyCode if the keyboad
65 * layout is a Latin keyboard layout.
67 * @param aKeyCode Our keyCode (NS_VK_*).
68 * @param aIsCapsLock TRUE if CapsLock is Locked. Otherwise, FALSE.
69 * This is used only when aKeyCode is NS_VK_[0-9].
70 * @param aUnshiftedCharCode CharCode for aKeyCode without Shift key.
71 * This may be zero if aKeyCode key doesn't input
72 * a Latin character.
73 * Note that must not be nullptr.
74 * @param aShiftedCharCode CharCode for aKeyCOde with Shift key.
75 * This is always 0 when aKeyCode isn't
76 * NS_VK_[A-Z].
77 * Note that must not be nullptr.
79 static void GetLatinCharCodeForKeyCode(uint32_t aKeyCode, bool aIsCapsLock,
80 uint32_t* aUnshiftedCharCode,
81 uint32_t* aShiftedCharCode);
83 /**
84 * Does device have touch support
86 static uint32_t IsTouchDeviceSupportPresent();
88 /**
89 * Send bidi keyboard information to content process
91 static void SendBidiKeyboardInfoToContent();
93 /**
94 * Get branchShortName from string bundle
96 static void GetBrandShortName(nsAString& aBrandName);
99 } // namespace widget
100 } // namespace mozilla
102 #endif // mozilla_WidgetUtils_h