widget/shared/WidgetUtils.h

Thu, 22 Jan 2015 13:21:57 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 22 Jan 2015 13:21:57 +0100
branch
TOR_BUG_9701
changeset 15
b8a032363ba2
permissions
-rw-r--r--

Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6

     1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
     2  *
     3  * This Source Code Form is subject to the terms of the Mozilla Public
     4  * License, v. 2.0. If a copy of the MPL was not distributed with this
     5  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
     7 #ifndef __mozilla_widget_WidgetUtils_h__
     8 #define __mozilla_widget_WidgetUtils_h__
    10 #include "nsCOMPtr.h"
    11 #include "nsIWidget.h"
    12 #include "nsPIDOMWindow.h"
    13 #include "nsIDOMWindow.h"
    14 #include "mozilla/EventForwards.h"
    16 namespace mozilla {
    17 namespace widget {
    19 class WidgetUtils
    20 {
    21 public:
    23   /**
    24    * Starting at the docshell item for the passed in DOM window this looks up
    25    * the docshell tree until it finds a docshell item that has a widget.
    26    */
    27   static already_AddRefed<nsIWidget> DOMWindowToWidget(nsIDOMWindow *aDOMWindow);
    29   /**
    30    * Compute our keyCode value (NS_VK_*) from an ASCII character.
    31    */
    32   static uint32_t ComputeKeyCodeFromChar(uint32_t aCharCode);
    34   /**
    35    * Get unshifted charCode and shifted charCode for aKeyCode if the keyboad
    36    * layout is a Latin keyboard layout.
    37    *
    38    * @param aKeyCode            Our keyCode (NS_VK_*).
    39    * @param aIsCapsLock         TRUE if CapsLock is Locked.  Otherwise, FALSE.
    40    *                            This is used only when aKeyCode is NS_VK_[0-9].
    41    * @param aUnshiftedCharCode  CharCode for aKeyCode without Shift key.
    42    *                            This may be zero if aKeyCode key doesn't input
    43    *                            a Latin character.
    44    *                            Note that must not be nullptr.
    45    * @param aShiftedCharCode    CharCode for aKeyCOde with Shift key.
    46    *                            This is always 0 when aKeyCode isn't
    47    *                            NS_VK_[A-Z].
    48    *                            Note that must not be nullptr.
    49    */
    50   static void GetLatinCharCodeForKeyCode(uint32_t aKeyCode,
    51                                          bool aIsCapsLock,
    52                                          uint32_t* aUnshiftedCharCode,
    53                                          uint32_t* aShiftedCharCode);
    55   /**
    56    * GetDeadKeyNameIndex() returns a key name index for dead key or
    57    * "Unidentified".  This method can return the index from non-combining
    58    * unicode character, e.g., '`' returns KEY_NAME_INDEX_DeadGrave.
    59    * So, you cannot use this method for checking if the char is a dead char.
    60    */
    61   static KeyNameIndex GetDeadKeyNameIndex(char16_t aChar);
    62 };
    64 } // namespace widget
    65 } // namespace mozilla
    67 #endif

mercurial