WidgetUtils.h 3.1 KB

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