Bug 1477919 [wpt PR 12154] - url: DecodeURLEscapeSequences() should not apply UTF...
[gecko.git] / widget / WidgetUtils.h
blob142f0cf1683f0022975fadeb8f4216382c068c64
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,
38 const nsIntRect& aBounds,
39 ScreenRotation aRotation);
41 namespace widget {
43 class WidgetUtils
45 public:
46 /**
47 * Shutdown() is called when "xpcom-will-shutdown" is notified. This is
48 * useful when you need to observe the notification in XP level code under
49 * widget.
51 static void Shutdown();
53 /**
54 * Starting at the docshell item for the passed in DOM window this looks up
55 * the docshell tree until it finds a docshell item that has a widget.
57 static already_AddRefed<nsIWidget> DOMWindowToWidget(nsPIDOMWindowOuter* aDOMWindow);
59 /**
60 * Compute our keyCode value (NS_VK_*) from an ASCII character.
62 static uint32_t ComputeKeyCodeFromChar(uint32_t aCharCode);
64 /**
65 * Get unshifted charCode and shifted charCode for aKeyCode if the keyboad
66 * layout is a Latin keyboard layout.
68 * @param aKeyCode Our keyCode (NS_VK_*).
69 * @param aIsCapsLock TRUE if CapsLock is Locked. Otherwise, FALSE.
70 * This is used only when aKeyCode is NS_VK_[0-9].
71 * @param aUnshiftedCharCode CharCode for aKeyCode without Shift key.
72 * This may be zero if aKeyCode key doesn't input
73 * a Latin character.
74 * Note that must not be nullptr.
75 * @param aShiftedCharCode CharCode for aKeyCOde with Shift key.
76 * This is always 0 when aKeyCode isn't
77 * NS_VK_[A-Z].
78 * Note that must not be nullptr.
80 static void GetLatinCharCodeForKeyCode(uint32_t aKeyCode,
81 bool aIsCapsLock,
82 uint32_t* aUnshiftedCharCode,
83 uint32_t* aShiftedCharCode);
85 /**
86 * Does device have touch support
88 static uint32_t IsTouchDeviceSupportPresent();
90 /**
91 * Send bidi keyboard information to content process
93 static void SendBidiKeyboardInfoToContent();
95 /**
96 * Get branchShortName from string bundle
98 static void GetBrandShortName(nsAString& aBrandName);
102 } // namespace widget
103 } // namespace mozilla
105 #endif // mozilla_WidgetUtils_h