michael@0: /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- michael@0: * michael@0: * This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: #ifndef __mozilla_widget_WidgetUtils_h__ michael@0: #define __mozilla_widget_WidgetUtils_h__ michael@0: michael@0: #include "nsCOMPtr.h" michael@0: #include "nsIWidget.h" michael@0: #include "nsPIDOMWindow.h" michael@0: #include "nsIDOMWindow.h" michael@0: #include "mozilla/EventForwards.h" michael@0: michael@0: namespace mozilla { michael@0: namespace widget { michael@0: michael@0: class WidgetUtils michael@0: { michael@0: public: michael@0: michael@0: /** michael@0: * Starting at the docshell item for the passed in DOM window this looks up michael@0: * the docshell tree until it finds a docshell item that has a widget. michael@0: */ michael@0: static already_AddRefed DOMWindowToWidget(nsIDOMWindow *aDOMWindow); michael@0: michael@0: /** michael@0: * Compute our keyCode value (NS_VK_*) from an ASCII character. michael@0: */ michael@0: static uint32_t ComputeKeyCodeFromChar(uint32_t aCharCode); michael@0: michael@0: /** michael@0: * Get unshifted charCode and shifted charCode for aKeyCode if the keyboad michael@0: * layout is a Latin keyboard layout. michael@0: * michael@0: * @param aKeyCode Our keyCode (NS_VK_*). michael@0: * @param aIsCapsLock TRUE if CapsLock is Locked. Otherwise, FALSE. michael@0: * This is used only when aKeyCode is NS_VK_[0-9]. michael@0: * @param aUnshiftedCharCode CharCode for aKeyCode without Shift key. michael@0: * This may be zero if aKeyCode key doesn't input michael@0: * a Latin character. michael@0: * Note that must not be nullptr. michael@0: * @param aShiftedCharCode CharCode for aKeyCOde with Shift key. michael@0: * This is always 0 when aKeyCode isn't michael@0: * NS_VK_[A-Z]. michael@0: * Note that must not be nullptr. michael@0: */ michael@0: static void GetLatinCharCodeForKeyCode(uint32_t aKeyCode, michael@0: bool aIsCapsLock, michael@0: uint32_t* aUnshiftedCharCode, michael@0: uint32_t* aShiftedCharCode); michael@0: michael@0: /** michael@0: * GetDeadKeyNameIndex() returns a key name index for dead key or michael@0: * "Unidentified". This method can return the index from non-combining michael@0: * unicode character, e.g., '`' returns KEY_NAME_INDEX_DeadGrave. michael@0: * So, you cannot use this method for checking if the char is a dead char. michael@0: */ michael@0: static KeyNameIndex GetDeadKeyNameIndex(char16_t aChar); michael@0: }; michael@0: michael@0: } // namespace widget michael@0: } // namespace mozilla michael@0: michael@0: #endif