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

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

mercurial