2013-09-24 14:04:16 +04:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
|
|
|
|
2016-09-20 05:22:26 +03:00
|
|
|
#include "gfxPrefs.h"
|
2013-09-24 14:04:16 +04:00
|
|
|
#include "mozilla/BasicEvents.h"
|
2013-10-18 10:10:20 +04:00
|
|
|
#include "mozilla/ContentEvents.h"
|
2017-07-19 12:39:34 +03:00
|
|
|
#include "mozilla/EventStateManager.h"
|
2014-02-27 14:51:15 +04:00
|
|
|
#include "mozilla/InternalMutationEvent.h"
|
2013-09-24 14:04:16 +04:00
|
|
|
#include "mozilla/MiscEvents.h"
|
|
|
|
#include "mozilla/MouseEvents.h"
|
2014-05-22 08:06:05 +04:00
|
|
|
#include "mozilla/Preferences.h"
|
2013-10-18 10:10:20 +04:00
|
|
|
#include "mozilla/TextEvents.h"
|
|
|
|
#include "mozilla/TouchEvents.h"
|
2018-02-09 19:17:09 +03:00
|
|
|
#include "mozilla/dom/KeyboardEventBinding.h"
|
2017-07-10 11:42:01 +03:00
|
|
|
#include "nsContentUtils.h"
|
2017-07-19 12:39:34 +03:00
|
|
|
#include "nsIContent.h"
|
Bug 1297013 part.2 Implement some helper methods to log constants related to event handling r=smaug
This patch implements some helper methods to log constants related to event handling.
ToString(KeyNameIndex) and ToString(CodeNameIndex) converts the enum itmes to human readable string. They use WidgetKeyboardEvent's helper class which returns Unicode text. Therefore, this need to convert from UTF16 to UTF8. That's the reason why these methods don't return |const char*|.
GetDOMKeyCodeName(uint32_t) returns DOM keycode name if it's defined. Otherwise, returns hexadecimal value. For generating switch-case statement, VirtualKeyCodeList.h shouldn't include ",". Therefore, this patch removes "," from VirtualKeyCodeList.h and append it at defining NS_DEFINE_VK. Additionally, the last item of enum and array should not end with ",". Therefore, this adds dummy last item at each of them. Finally, some of the keyCode values are shared between 2 keys. Therefore, it needs to support NS_DISALLOW_SAME_KEYCODE for switch-case generator. See the comment in the file for more detail.
GetModifiersName(Modifiers) returns all modifier names included in the given value.
MozReview-Commit-ID: 9i2ftFOTpDn
--HG--
extra : rebase_source : 458a4d28624dc10dd4454f2e7708d746d1fcb045
2016-09-14 18:48:47 +03:00
|
|
|
#include "nsPrintfCString.h"
|
2013-09-24 14:04:16 +04:00
|
|
|
|
|
|
|
namespace mozilla {
|
|
|
|
|
2015-09-17 06:05:44 +03:00
|
|
|
/******************************************************************************
|
|
|
|
* Global helper methods
|
|
|
|
******************************************************************************/
|
|
|
|
|
|
|
|
const char* ToChar(EventMessage aEventMessage) {
|
|
|
|
switch (aEventMessage) {
|
|
|
|
#define NS_EVENT_MESSAGE(aMessage) \
|
|
|
|
case aMessage: \
|
|
|
|
return #aMessage;
|
|
|
|
|
|
|
|
#include "mozilla/EventMessageList.h"
|
|
|
|
|
|
|
|
#undef NS_EVENT_MESSAGE
|
|
|
|
default:
|
|
|
|
return "illegal event message";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
const char* ToChar(EventClassID aEventClassID) {
|
|
|
|
switch (aEventClassID) {
|
|
|
|
#define NS_ROOT_EVENT_CLASS(aPrefix, aName) \
|
|
|
|
case eBasic##aName##Class: \
|
|
|
|
return "eBasic" #aName "Class";
|
|
|
|
|
|
|
|
#define NS_EVENT_CLASS(aPrefix, aName) \
|
|
|
|
case e##aName##Class: \
|
|
|
|
return "e" #aName "Class";
|
|
|
|
|
|
|
|
#include "mozilla/EventClassList.h"
|
|
|
|
|
|
|
|
#undef NS_EVENT_CLASS
|
|
|
|
#undef NS_ROOT_EVENT_CLASS
|
|
|
|
default:
|
|
|
|
return "illegal event class ID";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
Bug 1297013 part.2 Implement some helper methods to log constants related to event handling r=smaug
This patch implements some helper methods to log constants related to event handling.
ToString(KeyNameIndex) and ToString(CodeNameIndex) converts the enum itmes to human readable string. They use WidgetKeyboardEvent's helper class which returns Unicode text. Therefore, this need to convert from UTF16 to UTF8. That's the reason why these methods don't return |const char*|.
GetDOMKeyCodeName(uint32_t) returns DOM keycode name if it's defined. Otherwise, returns hexadecimal value. For generating switch-case statement, VirtualKeyCodeList.h shouldn't include ",". Therefore, this patch removes "," from VirtualKeyCodeList.h and append it at defining NS_DEFINE_VK. Additionally, the last item of enum and array should not end with ",". Therefore, this adds dummy last item at each of them. Finally, some of the keyCode values are shared between 2 keys. Therefore, it needs to support NS_DISALLOW_SAME_KEYCODE for switch-case generator. See the comment in the file for more detail.
GetModifiersName(Modifiers) returns all modifier names included in the given value.
MozReview-Commit-ID: 9i2ftFOTpDn
--HG--
extra : rebase_source : 458a4d28624dc10dd4454f2e7708d746d1fcb045
2016-09-14 18:48:47 +03:00
|
|
|
const nsCString ToString(KeyNameIndex aKeyNameIndex) {
|
|
|
|
if (aKeyNameIndex == KEY_NAME_INDEX_USE_STRING) {
|
|
|
|
return NS_LITERAL_CSTRING("USE_STRING");
|
|
|
|
}
|
|
|
|
nsAutoString keyName;
|
|
|
|
WidgetKeyboardEvent::GetDOMKeyName(aKeyNameIndex, keyName);
|
|
|
|
return NS_ConvertUTF16toUTF8(keyName);
|
|
|
|
}
|
|
|
|
|
|
|
|
const nsCString ToString(CodeNameIndex aCodeNameIndex) {
|
|
|
|
if (aCodeNameIndex == CODE_NAME_INDEX_USE_STRING) {
|
|
|
|
return NS_LITERAL_CSTRING("USE_STRING");
|
|
|
|
}
|
|
|
|
nsAutoString codeName;
|
|
|
|
WidgetKeyboardEvent::GetDOMCodeName(aCodeNameIndex, codeName);
|
|
|
|
return NS_ConvertUTF16toUTF8(codeName);
|
|
|
|
}
|
|
|
|
|
2017-12-02 04:46:31 +03:00
|
|
|
const char* ToChar(Command aCommand) {
|
|
|
|
if (aCommand == CommandDoNothing) {
|
|
|
|
return "CommandDoNothing";
|
|
|
|
}
|
|
|
|
|
|
|
|
switch (aCommand) {
|
|
|
|
#define NS_DEFINE_COMMAND(aName, aCommandStr) \
|
|
|
|
case Command##aName: \
|
|
|
|
return "Command" #aName;
|
Bug 1403759 - part 2: Handle edit/selection commands like insertNewline: in TextInputHandler::HandleCommand() r=m_kato
Let's make TextInputHandler::HandleCommand() handle other
commands which are caused by Backspace, Delete, Tab, ArrowUp,
ArrowDown, ArrowRight, ArrowLeft, PageUp, PageDown, Home, End
and Escape keys with various modifiers.
This patch makes Korean users can do most key operation in
editor even with composing Hangul character.
Note that this patch has a hack for cancelOperation: command.
The command is typically fired for Escape key press. However,
it's also fired for Command + Period. Unfortunately, this
behavior is really odd if subclass of NSResponder implements
|void cancelOperation:(id)sender|. If it's implemented,
Cocoa doesn't call its |void keyDown:(NSEvent)theEvent|.
Instead, it calls only |void doCommandBySelector:(SEL)aSelector|
and |void cancelOperation:(id)sender| when Command + Period is
pressed. Therefore, we cannot dispatch keydown nor keypress
event for this key combination if we implement it. Therefore,
this patch doesn't implement the method but handle it in
doCommandBySelector even though the super class of ChildView
cannot handle the command with this path.
MozReview-Commit-ID: 4hS23SiwNJv
--HG--
extra : rebase_source : 38ac1ea494b5f786ecd5c9327efbacd460b59faf
2017-12-02 08:53:10 +03:00
|
|
|
#define NS_DEFINE_COMMAND_NO_EXEC_COMMAND(aName) \
|
|
|
|
case Command##aName: \
|
|
|
|
return "Command" #aName;
|
2017-12-02 04:46:31 +03:00
|
|
|
|
|
|
|
#include "mozilla/CommandList.h"
|
|
|
|
|
|
|
|
#undef NS_DEFINE_COMMAND
|
Bug 1403759 - part 2: Handle edit/selection commands like insertNewline: in TextInputHandler::HandleCommand() r=m_kato
Let's make TextInputHandler::HandleCommand() handle other
commands which are caused by Backspace, Delete, Tab, ArrowUp,
ArrowDown, ArrowRight, ArrowLeft, PageUp, PageDown, Home, End
and Escape keys with various modifiers.
This patch makes Korean users can do most key operation in
editor even with composing Hangul character.
Note that this patch has a hack for cancelOperation: command.
The command is typically fired for Escape key press. However,
it's also fired for Command + Period. Unfortunately, this
behavior is really odd if subclass of NSResponder implements
|void cancelOperation:(id)sender|. If it's implemented,
Cocoa doesn't call its |void keyDown:(NSEvent)theEvent|.
Instead, it calls only |void doCommandBySelector:(SEL)aSelector|
and |void cancelOperation:(id)sender| when Command + Period is
pressed. Therefore, we cannot dispatch keydown nor keypress
event for this key combination if we implement it. Therefore,
this patch doesn't implement the method but handle it in
doCommandBySelector even though the super class of ChildView
cannot handle the command with this path.
MozReview-Commit-ID: 4hS23SiwNJv
--HG--
extra : rebase_source : 38ac1ea494b5f786ecd5c9327efbacd460b59faf
2017-12-02 08:53:10 +03:00
|
|
|
#undef NS_DEFINE_COMMAND_NO_EXEC_COMMAND
|
2017-12-02 04:46:31 +03:00
|
|
|
|
|
|
|
default:
|
|
|
|
return "illegal command value";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
Bug 1297013 part.2 Implement some helper methods to log constants related to event handling r=smaug
This patch implements some helper methods to log constants related to event handling.
ToString(KeyNameIndex) and ToString(CodeNameIndex) converts the enum itmes to human readable string. They use WidgetKeyboardEvent's helper class which returns Unicode text. Therefore, this need to convert from UTF16 to UTF8. That's the reason why these methods don't return |const char*|.
GetDOMKeyCodeName(uint32_t) returns DOM keycode name if it's defined. Otherwise, returns hexadecimal value. For generating switch-case statement, VirtualKeyCodeList.h shouldn't include ",". Therefore, this patch removes "," from VirtualKeyCodeList.h and append it at defining NS_DEFINE_VK. Additionally, the last item of enum and array should not end with ",". Therefore, this adds dummy last item at each of them. Finally, some of the keyCode values are shared between 2 keys. Therefore, it needs to support NS_DISALLOW_SAME_KEYCODE for switch-case generator. See the comment in the file for more detail.
GetModifiersName(Modifiers) returns all modifier names included in the given value.
MozReview-Commit-ID: 9i2ftFOTpDn
--HG--
extra : rebase_source : 458a4d28624dc10dd4454f2e7708d746d1fcb045
2016-09-14 18:48:47 +03:00
|
|
|
const nsCString GetDOMKeyCodeName(uint32_t aKeyCode) {
|
|
|
|
switch (aKeyCode) {
|
|
|
|
#define NS_DISALLOW_SAME_KEYCODE
|
|
|
|
#define NS_DEFINE_VK(aDOMKeyName, aDOMKeyCode) \
|
|
|
|
case aDOMKeyCode: \
|
|
|
|
return NS_LITERAL_CSTRING(#aDOMKeyName);
|
|
|
|
|
|
|
|
#include "mozilla/VirtualKeyCodeList.h"
|
|
|
|
|
|
|
|
#undef NS_DEFINE_VK
|
|
|
|
#undef NS_DISALLOW_SAME_KEYCODE
|
|
|
|
|
|
|
|
default:
|
|
|
|
return nsPrintfCString("Invalid DOM keyCode (0x%08X)", aKeyCode);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-06-04 03:49:21 +03:00
|
|
|
bool IsValidRawTextRangeValue(RawTextRangeType aRawTextRangeType) {
|
|
|
|
switch (static_cast<TextRangeType>(aRawTextRangeType)) {
|
2016-06-03 12:32:22 +03:00
|
|
|
case TextRangeType::eUninitialized:
|
2016-06-03 12:40:06 +03:00
|
|
|
case TextRangeType::eCaret:
|
2016-06-03 12:48:37 +03:00
|
|
|
case TextRangeType::eRawClause:
|
2016-06-03 12:57:21 +03:00
|
|
|
case TextRangeType::eSelectedRawClause:
|
2016-06-03 13:05:32 +03:00
|
|
|
case TextRangeType::eConvertedClause:
|
2016-06-03 13:15:21 +03:00
|
|
|
case TextRangeType::eSelectedClause:
|
2016-06-04 03:49:21 +03:00
|
|
|
return true;
|
|
|
|
default:
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
RawTextRangeType ToRawTextRangeType(TextRangeType aTextRangeType) {
|
|
|
|
return static_cast<RawTextRangeType>(aTextRangeType);
|
|
|
|
}
|
|
|
|
|
|
|
|
TextRangeType ToTextRangeType(RawTextRangeType aRawTextRangeType) {
|
|
|
|
MOZ_ASSERT(IsValidRawTextRangeValue(aRawTextRangeType));
|
|
|
|
return static_cast<TextRangeType>(aRawTextRangeType);
|
|
|
|
}
|
|
|
|
|
|
|
|
const char* ToChar(TextRangeType aTextRangeType) {
|
|
|
|
switch (aTextRangeType) {
|
2016-06-03 12:32:22 +03:00
|
|
|
case TextRangeType::eUninitialized:
|
|
|
|
return "TextRangeType::eUninitialized";
|
2016-06-03 12:40:06 +03:00
|
|
|
case TextRangeType::eCaret:
|
|
|
|
return "TextRangeType::eCaret";
|
2016-06-03 12:48:37 +03:00
|
|
|
case TextRangeType::eRawClause:
|
|
|
|
return "TextRangeType::eRawClause";
|
2016-06-03 12:57:21 +03:00
|
|
|
case TextRangeType::eSelectedRawClause:
|
|
|
|
return "TextRangeType::eSelectedRawClause";
|
2016-06-03 13:05:32 +03:00
|
|
|
case TextRangeType::eConvertedClause:
|
|
|
|
return "TextRangeType::eConvertedClause";
|
2016-06-03 13:15:21 +03:00
|
|
|
case TextRangeType::eSelectedClause:
|
|
|
|
return "TextRangeType::eSelectedClause";
|
2016-06-04 03:49:21 +03:00
|
|
|
default:
|
|
|
|
return "Invalid TextRangeType";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-06-11 05:06:37 +03:00
|
|
|
SelectionType ToSelectionType(TextRangeType aTextRangeType) {
|
|
|
|
switch (aTextRangeType) {
|
|
|
|
case TextRangeType::eRawClause:
|
2016-06-09 12:51:49 +03:00
|
|
|
return SelectionType::eIMERawClause;
|
2016-06-11 05:06:37 +03:00
|
|
|
case TextRangeType::eSelectedRawClause:
|
2016-06-09 13:03:40 +03:00
|
|
|
return SelectionType::eIMESelectedRawClause;
|
2016-06-11 05:06:37 +03:00
|
|
|
case TextRangeType::eConvertedClause:
|
2016-06-09 13:14:17 +03:00
|
|
|
return SelectionType::eIMEConvertedClause;
|
2016-06-11 05:06:37 +03:00
|
|
|
case TextRangeType::eSelectedClause:
|
2016-06-09 13:29:29 +03:00
|
|
|
return SelectionType::eIMESelectedClause;
|
2016-06-11 05:06:37 +03:00
|
|
|
default:
|
|
|
|
MOZ_CRASH("TextRangeType is invalid");
|
2016-06-09 12:35:22 +03:00
|
|
|
return SelectionType::eNormal;
|
2016-06-11 05:06:37 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-10-18 10:10:20 +04:00
|
|
|
/******************************************************************************
|
|
|
|
* As*Event() implementation
|
|
|
|
******************************************************************************/
|
|
|
|
|
|
|
|
#define NS_ROOT_EVENT_CLASS(aPrefix, aName)
|
|
|
|
#define NS_EVENT_CLASS(aPrefix, aName) \
|
|
|
|
aPrefix##aName* WidgetEvent::As##aName() { return nullptr; } \
|
|
|
|
\
|
|
|
|
const aPrefix##aName* WidgetEvent::As##aName() const { \
|
|
|
|
return const_cast<WidgetEvent*>(this)->As##aName(); \
|
|
|
|
}
|
|
|
|
|
|
|
|
#include "mozilla/EventClassList.h"
|
|
|
|
|
|
|
|
#undef NS_EVENT_CLASS
|
|
|
|
#undef NS_ROOT_EVENT_CLASS
|
|
|
|
|
2013-09-24 14:04:16 +04:00
|
|
|
/******************************************************************************
|
|
|
|
* mozilla::WidgetEvent
|
|
|
|
*
|
|
|
|
* Event struct type checking methods.
|
|
|
|
******************************************************************************/
|
|
|
|
|
|
|
|
bool WidgetEvent::IsQueryContentEvent() const {
|
2014-08-04 09:28:49 +04:00
|
|
|
return mClass == eQueryContentEventClass;
|
2013-09-24 14:04:16 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
bool WidgetEvent::IsSelectionEvent() const {
|
2014-08-04 09:28:49 +04:00
|
|
|
return mClass == eSelectionEventClass;
|
2013-09-24 14:04:16 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
bool WidgetEvent::IsContentCommandEvent() const {
|
2014-08-04 09:28:56 +04:00
|
|
|
return mClass == eContentCommandEventClass;
|
2013-09-24 14:04:16 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
bool WidgetEvent::IsNativeEventDelivererForPlugin() const {
|
2014-08-04 09:28:57 +04:00
|
|
|
return mClass == ePluginEventClass;
|
2013-09-24 14:04:16 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************************
|
|
|
|
* mozilla::WidgetEvent
|
|
|
|
*
|
|
|
|
* Event message checking methods.
|
|
|
|
******************************************************************************/
|
|
|
|
|
|
|
|
bool WidgetEvent::HasMouseEventMessage() const {
|
2015-08-22 04:34:51 +03:00
|
|
|
switch (mMessage) {
|
2015-08-29 02:58:30 +03:00
|
|
|
case eMouseDown:
|
2015-08-29 02:58:30 +03:00
|
|
|
case eMouseUp:
|
2015-08-29 02:58:32 +03:00
|
|
|
case eMouseClick:
|
2015-08-29 02:58:31 +03:00
|
|
|
case eMouseDoubleClick:
|
2016-12-01 03:48:02 +03:00
|
|
|
case eMouseAuxClick:
|
2015-08-29 02:58:31 +03:00
|
|
|
case eMouseEnterIntoWidget:
|
2015-08-29 02:58:31 +03:00
|
|
|
case eMouseExitFromWidget:
|
2015-08-29 02:58:32 +03:00
|
|
|
case eMouseActivate:
|
2015-08-29 02:58:32 +03:00
|
|
|
case eMouseOver:
|
2015-08-29 02:58:32 +03:00
|
|
|
case eMouseOut:
|
2015-08-29 02:58:32 +03:00
|
|
|
case eMouseHitTest:
|
2015-08-29 02:58:29 +03:00
|
|
|
case eMouseMove:
|
2013-09-24 14:04:16 +04:00
|
|
|
return true;
|
|
|
|
default:
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
bool WidgetEvent::HasDragEventMessage() const {
|
2015-08-22 04:34:51 +03:00
|
|
|
switch (mMessage) {
|
2015-09-02 09:08:02 +03:00
|
|
|
case eDragEnter:
|
2015-09-02 09:08:02 +03:00
|
|
|
case eDragOver:
|
2015-09-02 09:08:02 +03:00
|
|
|
case eDragExit:
|
2015-09-02 09:08:02 +03:00
|
|
|
case eDrag:
|
2015-09-02 09:08:02 +03:00
|
|
|
case eDragEnd:
|
2015-09-02 09:08:01 +03:00
|
|
|
case eDragStart:
|
2015-09-02 09:08:01 +03:00
|
|
|
case eDrop:
|
2015-09-02 09:08:01 +03:00
|
|
|
case eDragLeave:
|
2013-09-24 14:04:16 +04:00
|
|
|
return true;
|
|
|
|
default:
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
Bug 1406446 - part 1: InputContextAction should treat focus change during handling a user input as caused by user input even if it's caused by JS r=smaug
Currently, widget doesn't show VKB when input context change is caused by JS.
However, if it's caused by an event handler of a user input, user may expect
to open VKB. For example, if a touch event in fake editor causes moving
focus to actual editable node, user expect to show VKB.
Therefore, InputContextAction should declare two causes. One is unknown but
occurred during handling non-keyboard event. The other is unknown but occurred
during handling keyboard event.
However, EventStateManager doesn't have an API to check if it's being handling
a keyboard event. Therefore, this patch adds it first.
AutoHandlingUserInputStatePusher sends event type to StartHandlingUserInput()
and StopHandlingUserInput() of EventStateManager and sUserKeyboardEventDepth
manages the number of nested keyboard event handling. Therefore,
EventStateManager::IsHandlingKeyboardInput() can return if it's handling a
keyboard event.
IMEStateManager uses this new API to adjust the cause of changes of input
context.
Finally, InputContextAction::IsUserInput() is renamed to IsHandlingUserInput()
for consistency with EventStateManager and starts to return true when the
input context change is caused by script while it's handling a user input.
MozReview-Commit-ID: 5JsLqdqeGah
--HG--
extra : rebase_source : 9fcf7687d1bf90eeebbf6eac62d4488ff64b083c
2017-10-23 20:46:15 +03:00
|
|
|
/* static */
|
|
|
|
bool WidgetEvent::IsKeyEventMessage(EventMessage aMessage) {
|
|
|
|
switch (aMessage) {
|
2015-08-29 02:58:27 +03:00
|
|
|
case eKeyDown:
|
2015-08-29 02:58:27 +03:00
|
|
|
case eKeyPress:
|
2015-08-29 02:58:27 +03:00
|
|
|
case eKeyUp:
|
2016-04-22 19:22:49 +03:00
|
|
|
case eKeyDownOnPlugin:
|
|
|
|
case eKeyUpOnPlugin:
|
2016-05-11 15:56:42 +03:00
|
|
|
case eAccessKeyNotFound:
|
2013-09-24 14:04:16 +04:00
|
|
|
return true;
|
|
|
|
default:
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
bool WidgetEvent::HasIMEEventMessage() const {
|
2015-08-22 04:34:51 +03:00
|
|
|
switch (mMessage) {
|
2015-09-11 15:21:27 +03:00
|
|
|
case eCompositionStart:
|
2015-09-11 15:21:27 +03:00
|
|
|
case eCompositionEnd:
|
2015-09-11 15:21:27 +03:00
|
|
|
case eCompositionUpdate:
|
2015-09-11 15:21:27 +03:00
|
|
|
case eCompositionChange:
|
2015-09-11 15:21:26 +03:00
|
|
|
case eCompositionCommitAsIs:
|
2015-09-11 15:21:27 +03:00
|
|
|
case eCompositionCommit:
|
2013-09-24 14:04:16 +04:00
|
|
|
return true;
|
|
|
|
default:
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
bool WidgetEvent::HasPluginActivationEventMessage() const {
|
2015-08-29 02:58:28 +03:00
|
|
|
return mMessage == ePluginActivate || mMessage == ePluginFocus;
|
2013-09-24 14:04:16 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************************
|
|
|
|
* mozilla::WidgetEvent
|
|
|
|
*
|
|
|
|
* Specific event checking methods.
|
|
|
|
******************************************************************************/
|
|
|
|
|
2017-01-19 10:46:59 +03:00
|
|
|
bool WidgetEvent::CanBeSentToRemoteProcess() const {
|
|
|
|
// If this event is explicitly marked as shouldn't be sent to remote process,
|
|
|
|
// just return false.
|
2017-07-05 07:58:41 +03:00
|
|
|
if (IsCrossProcessForwardingStopped()) {
|
2017-01-19 10:46:59 +03:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (mClass == eKeyboardEventClass || mClass == eWheelEventClass) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
switch (mMessage) {
|
|
|
|
case eMouseDown:
|
|
|
|
case eMouseUp:
|
|
|
|
case eMouseMove:
|
|
|
|
case eContextMenu:
|
|
|
|
case eMouseEnterIntoWidget:
|
|
|
|
case eMouseExitFromWidget:
|
|
|
|
case eMouseTouchDrag:
|
|
|
|
case eTouchStart:
|
|
|
|
case eTouchMove:
|
|
|
|
case eTouchEnd:
|
|
|
|
case eTouchCancel:
|
|
|
|
case eDragOver:
|
|
|
|
case eDragExit:
|
|
|
|
case eDrop:
|
|
|
|
return true;
|
|
|
|
default:
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-07-19 12:39:34 +03:00
|
|
|
bool WidgetEvent::WillBeSentToRemoteProcess() const {
|
|
|
|
// This event won't be posted to remote process if it's already explicitly
|
|
|
|
// stopped.
|
|
|
|
if (IsCrossProcessForwardingStopped()) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
// When mOriginalTarget is nullptr, this method shouldn't be used.
|
|
|
|
if (NS_WARN_IF(!mOriginalTarget)) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsCOMPtr<nsIContent> originalTarget = do_QueryInterface(mOriginalTarget);
|
|
|
|
return EventStateManager::IsRemoteTarget(originalTarget);
|
|
|
|
}
|
|
|
|
|
2013-09-24 14:04:16 +04:00
|
|
|
bool WidgetEvent::IsRetargetedNativeEventDelivererForPlugin() const {
|
2013-10-18 10:10:20 +04:00
|
|
|
const WidgetPluginEvent* pluginEvent = AsPluginEvent();
|
2016-03-30 12:07:50 +03:00
|
|
|
return pluginEvent && pluginEvent->mRetargetToFocusedDocument;
|
2013-09-24 14:04:16 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
bool WidgetEvent::IsNonRetargetedNativeEventDelivererForPlugin() const {
|
2013-10-18 10:10:20 +04:00
|
|
|
const WidgetPluginEvent* pluginEvent = AsPluginEvent();
|
2016-03-30 12:07:50 +03:00
|
|
|
return pluginEvent && !pluginEvent->mRetargetToFocusedDocument;
|
2013-09-24 14:04:16 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
bool WidgetEvent::IsIMERelatedEvent() const {
|
|
|
|
return HasIMEEventMessage() || IsQueryContentEvent() || IsSelectionEvent();
|
|
|
|
}
|
|
|
|
|
|
|
|
bool WidgetEvent::IsUsingCoordinates() const {
|
2013-10-28 13:03:19 +04:00
|
|
|
const WidgetMouseEvent* mouseEvent = AsMouseEvent();
|
|
|
|
if (mouseEvent) {
|
|
|
|
return !mouseEvent->IsContextMenuKeyEvent();
|
|
|
|
}
|
2013-09-24 14:04:16 +04:00
|
|
|
return !HasKeyEventMessage() && !IsIMERelatedEvent() &&
|
|
|
|
!HasPluginActivationEventMessage() &&
|
|
|
|
!IsNativeEventDelivererForPlugin() && !IsContentCommandEvent();
|
|
|
|
}
|
|
|
|
|
|
|
|
bool WidgetEvent::IsTargetedAtFocusedWindow() const {
|
2013-10-28 13:03:19 +04:00
|
|
|
const WidgetMouseEvent* mouseEvent = AsMouseEvent();
|
|
|
|
if (mouseEvent) {
|
|
|
|
return mouseEvent->IsContextMenuKeyEvent();
|
|
|
|
}
|
2013-09-24 14:04:16 +04:00
|
|
|
return HasKeyEventMessage() || IsIMERelatedEvent() ||
|
|
|
|
IsContentCommandEvent() || IsRetargetedNativeEventDelivererForPlugin();
|
|
|
|
}
|
|
|
|
|
|
|
|
bool WidgetEvent::IsTargetedAtFocusedContent() const {
|
2013-10-28 13:03:19 +04:00
|
|
|
const WidgetMouseEvent* mouseEvent = AsMouseEvent();
|
|
|
|
if (mouseEvent) {
|
|
|
|
return mouseEvent->IsContextMenuKeyEvent();
|
|
|
|
}
|
2013-09-24 14:04:16 +04:00
|
|
|
return HasKeyEventMessage() || IsIMERelatedEvent() ||
|
|
|
|
IsRetargetedNativeEventDelivererForPlugin();
|
|
|
|
}
|
|
|
|
|
|
|
|
bool WidgetEvent::IsAllowedToDispatchDOMEvent() const {
|
2014-08-04 09:28:46 +04:00
|
|
|
switch (mClass) {
|
2014-08-04 09:28:50 +04:00
|
|
|
case eMouseEventClass:
|
2017-01-03 18:55:48 +03:00
|
|
|
if (mMessage == eMouseTouchDrag) {
|
|
|
|
return false;
|
2016-09-20 09:33:08 +03:00
|
|
|
}
|
|
|
|
MOZ_FALLTHROUGH;
|
2014-08-04 09:28:52 +04:00
|
|
|
case ePointerEventClass:
|
2013-09-24 14:04:16 +04:00
|
|
|
// We want synthesized mouse moves to cause mouseover and mouseout
|
2014-04-01 08:09:23 +04:00
|
|
|
// DOM events (EventStateManager::PreHandleEvent), but not mousemove
|
2013-09-24 14:04:16 +04:00
|
|
|
// DOM events.
|
|
|
|
// Synthesized button up events also do not cause DOM events because they
|
2016-04-18 17:09:02 +03:00
|
|
|
// do not have a reliable mRefPoint.
|
2016-05-12 05:36:41 +03:00
|
|
|
return AsMouseEvent()->mReason == WidgetMouseEvent::eReal;
|
2013-09-24 14:04:16 +04:00
|
|
|
|
2014-08-04 09:28:51 +04:00
|
|
|
case eWheelEventClass: {
|
2013-09-24 14:04:16 +04:00
|
|
|
// wheel event whose all delta values are zero by user pref applied, it
|
|
|
|
// shouldn't cause a DOM event.
|
2013-10-18 10:10:20 +04:00
|
|
|
const WidgetWheelEvent* wheelEvent = AsWheelEvent();
|
2016-03-31 12:09:47 +03:00
|
|
|
return wheelEvent->mDeltaX != 0.0 || wheelEvent->mDeltaY != 0.0 ||
|
2016-03-31 12:18:34 +03:00
|
|
|
wheelEvent->mDeltaZ != 0.0;
|
2013-09-24 14:04:16 +04:00
|
|
|
}
|
2017-02-16 10:05:09 +03:00
|
|
|
case eTouchEventClass:
|
|
|
|
return mMessage != eTouchPointerCancel;
|
2014-03-27 17:53:19 +04:00
|
|
|
// Following events are handled in EventStateManager, so, we don't need to
|
|
|
|
// dispatch DOM event for them into the DOM tree.
|
2014-08-04 09:28:49 +04:00
|
|
|
case eQueryContentEventClass:
|
2014-08-04 09:28:49 +04:00
|
|
|
case eSelectionEventClass:
|
2014-08-04 09:28:56 +04:00
|
|
|
case eContentCommandEventClass:
|
2014-03-27 17:53:19 +04:00
|
|
|
return false;
|
|
|
|
|
2013-09-24 14:04:16 +04:00
|
|
|
default:
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-11-11 13:02:37 +03:00
|
|
|
bool WidgetEvent::IsAllowedToDispatchInSystemGroup() const {
|
|
|
|
// We don't expect to implement default behaviors with pointer events because
|
|
|
|
// if we do, prevent default on mouse events can't prevent default behaviors
|
|
|
|
// anymore.
|
|
|
|
return mClass != ePointerEventClass;
|
|
|
|
}
|
|
|
|
|
2017-08-31 06:14:14 +03:00
|
|
|
bool WidgetEvent::IsBlockedForFingerprintingResistance() const {
|
2018-10-09 14:50:01 +03:00
|
|
|
if (!nsContentUtils::ShouldResistFingerprinting()) {
|
|
|
|
return false;
|
2017-08-31 06:14:14 +03:00
|
|
|
}
|
|
|
|
|
2018-10-09 14:50:01 +03:00
|
|
|
switch (mClass) {
|
|
|
|
case eKeyboardEventClass: {
|
|
|
|
const WidgetKeyboardEvent* keyboardEvent = AsKeyboardEvent();
|
|
|
|
|
|
|
|
return (keyboardEvent->mKeyNameIndex == KEY_NAME_INDEX_Alt ||
|
|
|
|
keyboardEvent->mKeyNameIndex == KEY_NAME_INDEX_Shift ||
|
|
|
|
keyboardEvent->mKeyNameIndex == KEY_NAME_INDEX_Control ||
|
|
|
|
keyboardEvent->mKeyNameIndex == KEY_NAME_INDEX_AltGraph);
|
|
|
|
}
|
|
|
|
case ePointerEventClass: {
|
|
|
|
const WidgetPointerEvent* pointerEvent = AsPointerEvent();
|
|
|
|
|
|
|
|
// We suppress the pointer events if it is not primary for fingerprinting
|
|
|
|
// resistance. It is because of that we want to spoof any pointer event
|
|
|
|
// into a mouse pointer event and the mouse pointer event only has
|
|
|
|
// isPrimary as true.
|
|
|
|
return !pointerEvent->mIsPrimary;
|
|
|
|
}
|
|
|
|
default:
|
|
|
|
return false;
|
|
|
|
}
|
2017-08-31 06:14:14 +03:00
|
|
|
}
|
|
|
|
|
2017-01-17 11:17:06 +03:00
|
|
|
/******************************************************************************
|
|
|
|
* mozilla::WidgetEvent
|
|
|
|
*
|
|
|
|
* Misc methods.
|
|
|
|
******************************************************************************/
|
|
|
|
|
2018-04-05 20:42:41 +03:00
|
|
|
static dom::EventTarget* GetTargetForDOMEvent(dom::EventTarget* aTarget) {
|
2017-01-17 11:17:06 +03:00
|
|
|
return aTarget ? aTarget->GetTargetForDOMEvent() : nullptr;
|
|
|
|
}
|
|
|
|
|
|
|
|
dom::EventTarget* WidgetEvent::GetDOMEventTarget() const {
|
|
|
|
return GetTargetForDOMEvent(mTarget);
|
|
|
|
}
|
|
|
|
|
|
|
|
dom::EventTarget* WidgetEvent::GetCurrentDOMEventTarget() const {
|
|
|
|
return GetTargetForDOMEvent(mCurrentTarget);
|
|
|
|
}
|
|
|
|
|
|
|
|
dom::EventTarget* WidgetEvent::GetOriginalDOMEventTarget() const {
|
|
|
|
if (mOriginalTarget) {
|
|
|
|
return GetTargetForDOMEvent(mOriginalTarget);
|
|
|
|
}
|
|
|
|
return GetDOMEventTarget();
|
|
|
|
}
|
|
|
|
|
2017-07-10 11:42:01 +03:00
|
|
|
void WidgetEvent::PreventDefault(bool aCalledByDefaultHandler,
|
|
|
|
nsIPrincipal* aPrincipal) {
|
|
|
|
if (mMessage == ePointerDown) {
|
|
|
|
if (aCalledByDefaultHandler) {
|
|
|
|
// Shouldn't prevent default on pointerdown by default handlers to stop
|
|
|
|
// firing legacy mouse events. Use MOZ_ASSERT to catch incorrect usages
|
|
|
|
// in debug builds.
|
|
|
|
MOZ_ASSERT(false);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (aPrincipal) {
|
|
|
|
nsAutoString addonId;
|
|
|
|
Unused << NS_WARN_IF(NS_FAILED(aPrincipal->GetAddonId(addonId)));
|
|
|
|
if (!addonId.IsEmpty()) {
|
|
|
|
// Ignore the case that it's called by a web extension.
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
mFlags.PreventDefault(aCalledByDefaultHandler);
|
|
|
|
}
|
|
|
|
|
2017-11-22 01:25:09 +03:00
|
|
|
bool WidgetEvent::IsUserAction() const {
|
|
|
|
if (!IsTrusted()) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
// FYI: eMouseScrollEventClass and ePointerEventClass represent
|
|
|
|
// user action but they are synthesized events.
|
|
|
|
switch (mClass) {
|
|
|
|
case eKeyboardEventClass:
|
|
|
|
case eCompositionEventClass:
|
|
|
|
case eMouseScrollEventClass:
|
|
|
|
case eWheelEventClass:
|
|
|
|
case eGestureNotifyEventClass:
|
|
|
|
case eSimpleGestureEventClass:
|
|
|
|
case eTouchEventClass:
|
|
|
|
case eCommandEventClass:
|
|
|
|
case eContentCommandEventClass:
|
|
|
|
case ePluginEventClass:
|
|
|
|
return true;
|
|
|
|
case eMouseEventClass:
|
|
|
|
case eDragEventClass:
|
|
|
|
case ePointerEventClass:
|
|
|
|
return AsMouseEvent()->IsReal();
|
|
|
|
default:
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-05-22 08:06:05 +04:00
|
|
|
/******************************************************************************
|
|
|
|
* mozilla::WidgetInputEvent
|
|
|
|
******************************************************************************/
|
|
|
|
|
2015-02-19 09:50:19 +03:00
|
|
|
/* static */
|
|
|
|
Modifier WidgetInputEvent::GetModifier(const nsAString& aDOMKeyName) {
|
|
|
|
if (aDOMKeyName.EqualsLiteral("Accel")) {
|
|
|
|
return AccelModifier();
|
|
|
|
}
|
|
|
|
KeyNameIndex keyNameIndex = WidgetKeyboardEvent::GetKeyNameIndex(aDOMKeyName);
|
|
|
|
return WidgetKeyboardEvent::GetModifierForKeyName(keyNameIndex);
|
|
|
|
}
|
|
|
|
|
2014-05-22 08:06:05 +04:00
|
|
|
/* static */
|
|
|
|
Modifier WidgetInputEvent::AccelModifier() {
|
|
|
|
static Modifier sAccelModifier = MODIFIER_NONE;
|
|
|
|
if (sAccelModifier == MODIFIER_NONE) {
|
|
|
|
switch (Preferences::GetInt("ui.key.accelKey", 0)) {
|
2018-06-26 00:20:54 +03:00
|
|
|
case dom::KeyboardEvent_Binding::DOM_VK_META:
|
2014-05-22 08:06:05 +04:00
|
|
|
sAccelModifier = MODIFIER_META;
|
|
|
|
break;
|
2018-06-26 00:20:54 +03:00
|
|
|
case dom::KeyboardEvent_Binding::DOM_VK_WIN:
|
2014-05-22 08:06:05 +04:00
|
|
|
sAccelModifier = MODIFIER_OS;
|
|
|
|
break;
|
2018-06-26 00:20:54 +03:00
|
|
|
case dom::KeyboardEvent_Binding::DOM_VK_ALT:
|
2014-05-22 08:06:05 +04:00
|
|
|
sAccelModifier = MODIFIER_ALT;
|
|
|
|
break;
|
2018-06-26 00:20:54 +03:00
|
|
|
case dom::KeyboardEvent_Binding::DOM_VK_CONTROL:
|
2014-05-22 08:06:05 +04:00
|
|
|
sAccelModifier = MODIFIER_CONTROL;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
#ifdef XP_MACOSX
|
|
|
|
sAccelModifier = MODIFIER_META;
|
|
|
|
#else
|
|
|
|
sAccelModifier = MODIFIER_CONTROL;
|
|
|
|
#endif
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return sAccelModifier;
|
|
|
|
}
|
|
|
|
|
2018-10-10 15:04:17 +03:00
|
|
|
/******************************************************************************
|
|
|
|
* mozilla::WidgetMouseEvent (MouseEvents.h)
|
|
|
|
******************************************************************************/
|
|
|
|
|
|
|
|
/* static */ bool WidgetMouseEvent::IsMiddleClickPasteEnabled() {
|
|
|
|
return Preferences::GetBool("middlemouse.paste", false);
|
|
|
|
}
|
|
|
|
|
2016-01-27 09:09:13 +03:00
|
|
|
/******************************************************************************
|
|
|
|
* mozilla::WidgetWheelEvent (MouseEvents.h)
|
|
|
|
******************************************************************************/
|
|
|
|
|
|
|
|
/* static */ double WidgetWheelEvent::ComputeOverriddenDelta(
|
|
|
|
double aDelta, bool aIsForVertical) {
|
2016-09-20 05:22:26 +03:00
|
|
|
if (!gfxPrefs::MouseWheelHasRootScrollDeltaOverride()) {
|
2016-01-27 09:09:13 +03:00
|
|
|
return aDelta;
|
|
|
|
}
|
2016-09-20 05:22:26 +03:00
|
|
|
int32_t intFactor = aIsForVertical
|
|
|
|
? gfxPrefs::MouseWheelRootScrollVerticalFactor()
|
|
|
|
: gfxPrefs::MouseWheelRootScrollHorizontalFactor();
|
2016-01-27 09:09:13 +03:00
|
|
|
// Making the scroll speed slower doesn't make sense. So, ignore odd factor
|
|
|
|
// which is less than 1.0.
|
|
|
|
if (intFactor <= 100) {
|
|
|
|
return aDelta;
|
|
|
|
}
|
|
|
|
double factor = static_cast<double>(intFactor) / 100;
|
|
|
|
return aDelta * factor;
|
|
|
|
}
|
|
|
|
|
|
|
|
double WidgetWheelEvent::OverriddenDeltaX() const {
|
2016-01-27 09:09:13 +03:00
|
|
|
if (!mAllowToOverrideSystemScrollSpeed) {
|
2016-03-31 12:55:59 +03:00
|
|
|
return mDeltaX;
|
2016-01-27 09:09:13 +03:00
|
|
|
}
|
2016-03-31 12:55:59 +03:00
|
|
|
return ComputeOverriddenDelta(mDeltaX, false);
|
2016-01-27 09:09:13 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
double WidgetWheelEvent::OverriddenDeltaY() const {
|
2016-01-27 09:09:13 +03:00
|
|
|
if (!mAllowToOverrideSystemScrollSpeed) {
|
2016-03-31 12:09:47 +03:00
|
|
|
return mDeltaY;
|
2016-01-27 09:09:13 +03:00
|
|
|
}
|
2016-03-31 12:09:47 +03:00
|
|
|
return ComputeOverriddenDelta(mDeltaY, true);
|
2016-01-27 09:09:13 +03:00
|
|
|
}
|
|
|
|
|
2014-01-08 20:45:30 +04:00
|
|
|
/******************************************************************************
|
|
|
|
* mozilla::WidgetKeyboardEvent (TextEvents.h)
|
|
|
|
******************************************************************************/
|
|
|
|
|
2016-07-20 07:07:53 +03:00
|
|
|
#define NS_DEFINE_KEYNAME(aCPPName, aDOMKeyName) (u"" aDOMKeyName),
|
2016-03-11 05:18:39 +03:00
|
|
|
const char16_t* const WidgetKeyboardEvent::kKeyNames[] = {
|
2015-02-19 09:50:19 +03:00
|
|
|
#include "mozilla/KeyNameList.h"
|
|
|
|
};
|
|
|
|
#undef NS_DEFINE_KEYNAME
|
|
|
|
|
|
|
|
#define NS_DEFINE_PHYSICAL_KEY_CODE_NAME(aCPPName, aDOMCodeName) \
|
2016-07-20 07:07:53 +03:00
|
|
|
(u"" aDOMCodeName),
|
2016-03-11 05:18:39 +03:00
|
|
|
const char16_t* const WidgetKeyboardEvent::kCodeNames[] = {
|
2015-02-19 09:50:19 +03:00
|
|
|
#include "mozilla/PhysicalKeyCodeNameList.h"
|
|
|
|
};
|
|
|
|
#undef NS_DEFINE_PHYSICAL_KEY_CODE_NAME
|
|
|
|
|
|
|
|
WidgetKeyboardEvent::KeyNameIndexHashtable*
|
|
|
|
WidgetKeyboardEvent::sKeyNameIndexHashtable = nullptr;
|
|
|
|
WidgetKeyboardEvent::CodeNameIndexHashtable*
|
|
|
|
WidgetKeyboardEvent::sCodeNameIndexHashtable = nullptr;
|
|
|
|
|
2017-05-19 11:24:20 +03:00
|
|
|
void WidgetKeyboardEvent::InitAllEditCommands() {
|
|
|
|
// If the event was created without widget, e.g., created event in chrome
|
|
|
|
// script, this shouldn't execute native key bindings.
|
|
|
|
if (NS_WARN_IF(!mWidget)) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
// This event should be trusted event here and we shouldn't expose native
|
|
|
|
// key binding information to web contents with untrusted events.
|
|
|
|
if (NS_WARN_IF(!IsTrusted())) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
MOZ_ASSERT(
|
|
|
|
XRE_IsParentProcess(),
|
|
|
|
"It's too expensive to retrieve all edit commands from remote process");
|
|
|
|
MOZ_ASSERT(!AreAllEditCommandsInitialized(),
|
|
|
|
"Shouldn't be called two or more times");
|
|
|
|
|
|
|
|
InitEditCommandsFor(nsIWidget::NativeKeyBindingsForSingleLineEditor);
|
|
|
|
InitEditCommandsFor(nsIWidget::NativeKeyBindingsForMultiLineEditor);
|
|
|
|
InitEditCommandsFor(nsIWidget::NativeKeyBindingsForRichTextEditor);
|
|
|
|
}
|
|
|
|
|
2017-05-19 10:50:30 +03:00
|
|
|
void WidgetKeyboardEvent::InitEditCommandsFor(
|
|
|
|
nsIWidget::NativeKeyBindingsType aType) {
|
2017-05-19 12:46:02 +03:00
|
|
|
if (NS_WARN_IF(!mWidget) || NS_WARN_IF(!IsTrusted())) {
|
|
|
|
return;
|
|
|
|
}
|
2017-05-19 10:50:30 +03:00
|
|
|
|
|
|
|
bool& initialized = IsEditCommandsInitializedRef(aType);
|
|
|
|
if (initialized) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
nsTArray<CommandInt>& commands = EditCommandsRef(aType);
|
2017-05-19 11:49:41 +03:00
|
|
|
mWidget->GetEditCommands(aType, *this, commands);
|
2017-05-19 10:50:30 +03:00
|
|
|
initialized = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool WidgetKeyboardEvent::ExecuteEditCommands(
|
|
|
|
nsIWidget::NativeKeyBindingsType aType, DoCommandCallback aCallback,
|
|
|
|
void* aCallbackData) {
|
|
|
|
// If the event was created without widget, e.g., created event in chrome
|
|
|
|
// script, this shouldn't execute native key bindings.
|
|
|
|
if (NS_WARN_IF(!mWidget)) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
// This event should be trusted event here and we shouldn't expose native
|
|
|
|
// key binding information to web contents with untrusted events.
|
|
|
|
if (NS_WARN_IF(!IsTrusted())) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
InitEditCommandsFor(aType);
|
|
|
|
|
|
|
|
const nsTArray<CommandInt>& commands = EditCommandsRef(aType);
|
|
|
|
if (commands.IsEmpty()) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
for (CommandInt command : commands) {
|
|
|
|
aCallback(static_cast<Command>(command), aCallbackData);
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2015-02-19 09:50:18 +03:00
|
|
|
bool WidgetKeyboardEvent::ShouldCauseKeypressEvents() const {
|
2016-03-16 07:50:01 +03:00
|
|
|
// Currently, we don't dispatch keypress events of modifier keys and
|
|
|
|
// dead keys.
|
2015-02-19 09:50:18 +03:00
|
|
|
switch (mKeyNameIndex) {
|
|
|
|
case KEY_NAME_INDEX_Alt:
|
|
|
|
case KEY_NAME_INDEX_AltGraph:
|
|
|
|
case KEY_NAME_INDEX_CapsLock:
|
|
|
|
case KEY_NAME_INDEX_Control:
|
|
|
|
case KEY_NAME_INDEX_Fn:
|
2015-02-19 09:50:19 +03:00
|
|
|
case KEY_NAME_INDEX_FnLock:
|
2015-02-19 09:50:18 +03:00
|
|
|
// case KEY_NAME_INDEX_Hyper:
|
|
|
|
case KEY_NAME_INDEX_Meta:
|
|
|
|
case KEY_NAME_INDEX_NumLock:
|
|
|
|
case KEY_NAME_INDEX_OS:
|
|
|
|
case KEY_NAME_INDEX_ScrollLock:
|
|
|
|
case KEY_NAME_INDEX_Shift:
|
|
|
|
// case KEY_NAME_INDEX_Super:
|
|
|
|
case KEY_NAME_INDEX_Symbol:
|
2015-02-19 09:50:19 +03:00
|
|
|
case KEY_NAME_INDEX_SymbolLock:
|
2016-03-16 07:50:01 +03:00
|
|
|
case KEY_NAME_INDEX_Dead:
|
2015-02-19 09:50:18 +03:00
|
|
|
return false;
|
|
|
|
default:
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-03-18 05:22:37 +03:00
|
|
|
static bool HasASCIIDigit(const ShortcutKeyCandidateArray& aCandidates) {
|
|
|
|
for (uint32_t i = 0; i < aCandidates.Length(); ++i) {
|
|
|
|
uint32_t ch = aCandidates[i].mCharCode;
|
|
|
|
if (ch >= '0' && ch <= '9') return true;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
static bool CharsCaseInsensitiveEqual(uint32_t aChar1, uint32_t aChar2) {
|
|
|
|
return aChar1 == aChar2 || (IS_IN_BMP(aChar1) && IS_IN_BMP(aChar2) &&
|
|
|
|
ToLowerCase(static_cast<char16_t>(aChar1)) ==
|
|
|
|
ToLowerCase(static_cast<char16_t>(aChar2)));
|
|
|
|
}
|
|
|
|
|
|
|
|
static bool IsCaseChangeableChar(uint32_t aChar) {
|
|
|
|
return IS_IN_BMP(aChar) && ToLowerCase(static_cast<char16_t>(aChar)) !=
|
|
|
|
ToUpperCase(static_cast<char16_t>(aChar));
|
|
|
|
}
|
|
|
|
|
|
|
|
void WidgetKeyboardEvent::GetShortcutKeyCandidates(
|
2017-06-06 02:09:40 +03:00
|
|
|
ShortcutKeyCandidateArray& aCandidates) const {
|
2016-03-18 05:22:37 +03:00
|
|
|
MOZ_ASSERT(aCandidates.IsEmpty(), "aCandidates must be empty");
|
|
|
|
|
|
|
|
// ShortcutKeyCandidate::mCharCode is a candidate charCode.
|
|
|
|
// ShortcutKeyCandidate::mIgnoreShift means the mCharCode should be tried to
|
|
|
|
// execute a command with/without shift key state. If this is TRUE, the
|
|
|
|
// shifted key state should be ignored. Otherwise, don't ignore the state.
|
|
|
|
// the priority of the charCodes are (shift key is not pressed):
|
2016-03-19 14:57:11 +03:00
|
|
|
// 0: PseudoCharCode()/false,
|
2016-03-18 05:22:37 +03:00
|
|
|
// 1: unshiftedCharCodes[0]/false, 2: unshiftedCharCodes[1]/false...
|
|
|
|
// the priority of the charCodes are (shift key is pressed):
|
2016-03-19 14:57:11 +03:00
|
|
|
// 0: PseudoCharCode()/false,
|
2016-03-18 05:22:37 +03:00
|
|
|
// 1: shiftedCharCodes[0]/false, 2: shiftedCharCodes[0]/true,
|
|
|
|
// 3: shiftedCharCodes[1]/false, 4: shiftedCharCodes[1]/true...
|
2016-03-19 14:57:11 +03:00
|
|
|
uint32_t pseudoCharCode = PseudoCharCode();
|
|
|
|
if (pseudoCharCode) {
|
|
|
|
ShortcutKeyCandidate key(pseudoCharCode, false);
|
2016-03-18 05:22:37 +03:00
|
|
|
aCandidates.AppendElement(key);
|
|
|
|
}
|
|
|
|
|
2016-05-12 11:57:21 +03:00
|
|
|
uint32_t len = mAlternativeCharCodes.Length();
|
2016-03-18 05:22:37 +03:00
|
|
|
if (!IsShift()) {
|
|
|
|
for (uint32_t i = 0; i < len; ++i) {
|
2016-05-12 11:57:21 +03:00
|
|
|
uint32_t ch = mAlternativeCharCodes[i].mUnshiftedCharCode;
|
2016-03-19 14:57:11 +03:00
|
|
|
if (!ch || ch == pseudoCharCode) {
|
2016-03-18 05:22:37 +03:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
ShortcutKeyCandidate key(ch, false);
|
|
|
|
aCandidates.AppendElement(key);
|
|
|
|
}
|
|
|
|
// If unshiftedCharCodes doesn't have numeric but shiftedCharCode has it,
|
|
|
|
// this keyboard layout is AZERTY or similar layout, probably.
|
|
|
|
// In this case, Accel+[0-9] should be accessible without shift key.
|
|
|
|
// However, the priority should be lowest.
|
|
|
|
if (!HasASCIIDigit(aCandidates)) {
|
|
|
|
for (uint32_t i = 0; i < len; ++i) {
|
2016-05-12 11:57:21 +03:00
|
|
|
uint32_t ch = mAlternativeCharCodes[i].mShiftedCharCode;
|
2016-03-18 05:22:37 +03:00
|
|
|
if (ch >= '0' && ch <= '9') {
|
|
|
|
ShortcutKeyCandidate key(ch, false);
|
|
|
|
aCandidates.AppendElement(key);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
for (uint32_t i = 0; i < len; ++i) {
|
2016-05-12 11:57:21 +03:00
|
|
|
uint32_t ch = mAlternativeCharCodes[i].mShiftedCharCode;
|
2016-03-18 05:22:37 +03:00
|
|
|
if (!ch) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2016-03-19 14:57:11 +03:00
|
|
|
if (ch != pseudoCharCode) {
|
2016-03-18 05:22:37 +03:00
|
|
|
ShortcutKeyCandidate key(ch, false);
|
|
|
|
aCandidates.AppendElement(key);
|
|
|
|
}
|
|
|
|
|
|
|
|
// If the char is an alphabet, the shift key state should not be
|
|
|
|
// ignored. E.g., Ctrl+Shift+C should not execute Ctrl+C.
|
|
|
|
|
|
|
|
// And checking the charCode is same as unshiftedCharCode too.
|
|
|
|
// E.g., for Ctrl+Shift+(Plus of Numpad) should not run Ctrl+Plus.
|
2016-05-12 11:57:21 +03:00
|
|
|
uint32_t unshiftCh = mAlternativeCharCodes[i].mUnshiftedCharCode;
|
2016-03-18 05:22:37 +03:00
|
|
|
if (CharsCaseInsensitiveEqual(ch, unshiftCh)) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
// On the Hebrew keyboard layout on Windows, the unshifted char is a
|
|
|
|
// localized character but the shifted char is a Latin alphabet,
|
|
|
|
// then, we should not execute without the shift state. See bug 433192.
|
|
|
|
if (IsCaseChangeableChar(ch)) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Setting the alternative charCode candidates for retry without shift
|
|
|
|
// key state only when the shift key is pressed.
|
|
|
|
ShortcutKeyCandidate key(ch, true);
|
|
|
|
aCandidates.AppendElement(key);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Special case for "Space" key. With some keyboard layouts, "Space" with
|
|
|
|
// or without Shift key causes non-ASCII space. For such keyboard layouts,
|
|
|
|
// we should guarantee that the key press works as an ASCII white space key
|
2016-03-26 08:06:16 +03:00
|
|
|
// press. However, if the space key is assigned to a function key, it
|
|
|
|
// shouldn't work as a space key.
|
|
|
|
if (mKeyNameIndex == KEY_NAME_INDEX_USE_STRING &&
|
2016-05-13 10:06:18 +03:00
|
|
|
mCodeNameIndex == CODE_NAME_INDEX_Space && pseudoCharCode != ' ') {
|
|
|
|
ShortcutKeyCandidate spaceKey(' ', false);
|
2016-03-18 05:22:37 +03:00
|
|
|
aCandidates.AppendElement(spaceKey);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-06-06 02:09:40 +03:00
|
|
|
void WidgetKeyboardEvent::GetAccessKeyCandidates(
|
|
|
|
nsTArray<uint32_t>& aCandidates) const {
|
2016-03-18 05:22:37 +03:00
|
|
|
MOZ_ASSERT(aCandidates.IsEmpty(), "aCandidates must be empty");
|
|
|
|
|
|
|
|
// return the lower cased charCode candidates for access keys.
|
|
|
|
// the priority of the charCodes are:
|
|
|
|
// 0: charCode, 1: unshiftedCharCodes[0], 2: shiftedCharCodes[0]
|
|
|
|
// 3: unshiftedCharCodes[1], 4: shiftedCharCodes[1],...
|
2017-11-10 02:42:40 +03:00
|
|
|
uint32_t pseudoCharCode = PseudoCharCode();
|
|
|
|
if (pseudoCharCode) {
|
|
|
|
uint32_t ch = pseudoCharCode;
|
2016-03-18 05:22:37 +03:00
|
|
|
if (IS_IN_BMP(ch)) {
|
|
|
|
ch = ToLowerCase(static_cast<char16_t>(ch));
|
|
|
|
}
|
|
|
|
aCandidates.AppendElement(ch);
|
|
|
|
}
|
2016-05-12 11:57:21 +03:00
|
|
|
for (uint32_t i = 0; i < mAlternativeCharCodes.Length(); ++i) {
|
|
|
|
uint32_t ch[2] = {mAlternativeCharCodes[i].mUnshiftedCharCode,
|
|
|
|
mAlternativeCharCodes[i].mShiftedCharCode};
|
2016-03-18 05:22:37 +03:00
|
|
|
for (uint32_t j = 0; j < 2; ++j) {
|
|
|
|
if (!ch[j]) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
if (IS_IN_BMP(ch[j])) {
|
|
|
|
ch[j] = ToLowerCase(static_cast<char16_t>(ch[j]));
|
|
|
|
}
|
2017-11-10 02:42:40 +03:00
|
|
|
// Don't append the charcode that was already appended.
|
2016-03-18 05:22:37 +03:00
|
|
|
if (aCandidates.IndexOf(ch[j]) == aCandidates.NoIndex) {
|
|
|
|
aCandidates.AppendElement(ch[j]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// Special case for "Space" key. With some keyboard layouts, "Space" with
|
|
|
|
// or without Shift key causes non-ASCII space. For such keyboard layouts,
|
|
|
|
// we should guarantee that the key press works as an ASCII white space key
|
2016-03-26 08:06:16 +03:00
|
|
|
// press. However, if the space key is assigned to a function key, it
|
|
|
|
// shouldn't work as a space key.
|
|
|
|
if (mKeyNameIndex == KEY_NAME_INDEX_USE_STRING &&
|
2017-11-10 02:42:40 +03:00
|
|
|
mCodeNameIndex == CODE_NAME_INDEX_Space && pseudoCharCode != ' ') {
|
2016-05-13 10:06:18 +03:00
|
|
|
aCandidates.AppendElement(' ');
|
2016-03-18 05:22:37 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-07-06 11:36:19 +03:00
|
|
|
// mask values for ui.key.chromeAccess and ui.key.contentAccess
|
|
|
|
#define NS_MODIFIER_SHIFT 1
|
|
|
|
#define NS_MODIFIER_CONTROL 2
|
|
|
|
#define NS_MODIFIER_ALT 4
|
|
|
|
#define NS_MODIFIER_META 8
|
|
|
|
#define NS_MODIFIER_OS 16
|
2018-11-30 13:46:48 +03:00
|
|
|
|
2017-07-06 11:36:19 +03:00
|
|
|
static Modifiers PrefFlagsToModifiers(int32_t aPrefFlags) {
|
|
|
|
Modifiers result = 0;
|
|
|
|
if (aPrefFlags & NS_MODIFIER_SHIFT) {
|
|
|
|
result |= MODIFIER_SHIFT;
|
|
|
|
}
|
|
|
|
if (aPrefFlags & NS_MODIFIER_CONTROL) {
|
|
|
|
result |= MODIFIER_CONTROL;
|
|
|
|
}
|
|
|
|
if (aPrefFlags & NS_MODIFIER_ALT) {
|
|
|
|
result |= MODIFIER_ALT;
|
|
|
|
}
|
|
|
|
if (aPrefFlags & NS_MODIFIER_META) {
|
|
|
|
result |= MODIFIER_META;
|
|
|
|
}
|
|
|
|
if (aPrefFlags & NS_MODIFIER_OS) {
|
|
|
|
result |= MODIFIER_OS;
|
|
|
|
}
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool WidgetKeyboardEvent::ModifiersMatchWithAccessKey(
|
|
|
|
AccessKeyType aType) const {
|
|
|
|
if (!ModifiersForAccessKeyMatching()) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
return ModifiersForAccessKeyMatching() == AccessKeyModifiers(aType);
|
|
|
|
}
|
|
|
|
|
|
|
|
Modifiers WidgetKeyboardEvent::ModifiersForAccessKeyMatching() const {
|
|
|
|
static const Modifiers kModifierMask = MODIFIER_SHIFT | MODIFIER_CONTROL |
|
|
|
|
MODIFIER_ALT | MODIFIER_META |
|
|
|
|
MODIFIER_OS;
|
|
|
|
return mModifiers & kModifierMask;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* static */
|
|
|
|
Modifiers WidgetKeyboardEvent::AccessKeyModifiers(AccessKeyType aType) {
|
|
|
|
switch (GenericAccessModifierKeyPref()) {
|
|
|
|
case -1:
|
|
|
|
break; // use the individual prefs
|
|
|
|
case NS_VK_SHIFT:
|
|
|
|
return MODIFIER_SHIFT;
|
|
|
|
case NS_VK_CONTROL:
|
|
|
|
return MODIFIER_CONTROL;
|
|
|
|
case NS_VK_ALT:
|
|
|
|
return MODIFIER_ALT;
|
|
|
|
case NS_VK_META:
|
|
|
|
return MODIFIER_META;
|
|
|
|
case NS_VK_WIN:
|
|
|
|
return MODIFIER_OS;
|
|
|
|
default:
|
|
|
|
return MODIFIER_NONE;
|
|
|
|
}
|
|
|
|
|
|
|
|
switch (aType) {
|
|
|
|
case AccessKeyType::eChrome:
|
|
|
|
return PrefFlagsToModifiers(ChromeAccessModifierMaskPref());
|
|
|
|
case AccessKeyType::eContent:
|
|
|
|
return PrefFlagsToModifiers(ContentAccessModifierMaskPref());
|
|
|
|
default:
|
|
|
|
return MODIFIER_NONE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* static */
|
|
|
|
int32_t WidgetKeyboardEvent::GenericAccessModifierKeyPref() {
|
|
|
|
static bool sInitialized = false;
|
|
|
|
static int32_t sValue = -1;
|
|
|
|
if (!sInitialized) {
|
|
|
|
nsresult rv =
|
|
|
|
Preferences::AddIntVarCache(&sValue, "ui.key.generalAccessKey", sValue);
|
|
|
|
sInitialized = NS_SUCCEEDED(rv);
|
|
|
|
MOZ_ASSERT(sInitialized);
|
|
|
|
}
|
|
|
|
return sValue;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* static */
|
|
|
|
int32_t WidgetKeyboardEvent::ChromeAccessModifierMaskPref() {
|
|
|
|
static bool sInitialized = false;
|
|
|
|
static int32_t sValue = 0;
|
|
|
|
if (!sInitialized) {
|
|
|
|
nsresult rv =
|
|
|
|
Preferences::AddIntVarCache(&sValue, "ui.key.chromeAccess", sValue);
|
|
|
|
sInitialized = NS_SUCCEEDED(rv);
|
|
|
|
MOZ_ASSERT(sInitialized);
|
|
|
|
}
|
|
|
|
return sValue;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* static */
|
|
|
|
int32_t WidgetKeyboardEvent::ContentAccessModifierMaskPref() {
|
|
|
|
static bool sInitialized = false;
|
|
|
|
static int32_t sValue = 0;
|
|
|
|
if (!sInitialized) {
|
|
|
|
nsresult rv =
|
|
|
|
Preferences::AddIntVarCache(&sValue, "ui.key.contentAccess", sValue);
|
|
|
|
sInitialized = NS_SUCCEEDED(rv);
|
|
|
|
MOZ_ASSERT(sInitialized);
|
|
|
|
}
|
|
|
|
return sValue;
|
|
|
|
}
|
|
|
|
|
2015-02-19 09:50:19 +03:00
|
|
|
/* static */ void WidgetKeyboardEvent::Shutdown() {
|
|
|
|
delete sKeyNameIndexHashtable;
|
|
|
|
sKeyNameIndexHashtable = nullptr;
|
|
|
|
delete sCodeNameIndexHashtable;
|
|
|
|
sCodeNameIndexHashtable = nullptr;
|
|
|
|
}
|
|
|
|
|
2014-01-08 20:45:30 +04:00
|
|
|
/* static */ void WidgetKeyboardEvent::GetDOMKeyName(KeyNameIndex aKeyNameIndex,
|
|
|
|
nsAString& aKeyName) {
|
|
|
|
if (aKeyNameIndex >= KEY_NAME_INDEX_USE_STRING) {
|
|
|
|
aKeyName.Truncate();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2015-02-19 09:50:19 +03:00
|
|
|
MOZ_RELEASE_ASSERT(
|
|
|
|
static_cast<size_t>(aKeyNameIndex) < ArrayLength(kKeyNames),
|
|
|
|
"Illegal key enumeration value");
|
|
|
|
aKeyName = kKeyNames[aKeyNameIndex];
|
2014-01-08 20:45:30 +04:00
|
|
|
}
|
|
|
|
|
2014-05-25 06:08:58 +04:00
|
|
|
/* static */ void WidgetKeyboardEvent::GetDOMCodeName(
|
|
|
|
CodeNameIndex aCodeNameIndex, nsAString& aCodeName) {
|
|
|
|
if (aCodeNameIndex >= CODE_NAME_INDEX_USE_STRING) {
|
|
|
|
aCodeName.Truncate();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
MOZ_RELEASE_ASSERT(
|
|
|
|
static_cast<size_t>(aCodeNameIndex) < ArrayLength(kCodeNames),
|
|
|
|
"Illegal physical code enumeration value");
|
|
|
|
aCodeName = kCodeNames[aCodeNameIndex];
|
|
|
|
}
|
|
|
|
|
2015-02-19 09:50:19 +03:00
|
|
|
/* static */ KeyNameIndex WidgetKeyboardEvent::GetKeyNameIndex(
|
|
|
|
const nsAString& aKeyValue) {
|
|
|
|
if (!sKeyNameIndexHashtable) {
|
|
|
|
sKeyNameIndexHashtable = new KeyNameIndexHashtable(ArrayLength(kKeyNames));
|
|
|
|
for (size_t i = 0; i < ArrayLength(kKeyNames); i++) {
|
|
|
|
sKeyNameIndexHashtable->Put(nsDependentString(kKeyNames[i]),
|
|
|
|
static_cast<KeyNameIndex>(i));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
KeyNameIndex result = KEY_NAME_INDEX_USE_STRING;
|
|
|
|
sKeyNameIndexHashtable->Get(aKeyValue, &result);
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* static */ CodeNameIndex WidgetKeyboardEvent::GetCodeNameIndex(
|
|
|
|
const nsAString& aCodeValue) {
|
|
|
|
if (!sCodeNameIndexHashtable) {
|
|
|
|
sCodeNameIndexHashtable =
|
|
|
|
new CodeNameIndexHashtable(ArrayLength(kCodeNames));
|
|
|
|
for (size_t i = 0; i < ArrayLength(kCodeNames); i++) {
|
|
|
|
sCodeNameIndexHashtable->Put(nsDependentString(kCodeNames[i]),
|
|
|
|
static_cast<CodeNameIndex>(i));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
CodeNameIndex result = CODE_NAME_INDEX_USE_STRING;
|
|
|
|
sCodeNameIndexHashtable->Get(aCodeValue, &result);
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
Bug 1036008 - Use alternative ASCII capable keyboard layout information to decide keyCode even if the key produces an ASCII punctuation character r=smaug
Gecko decides keyCode from an ASCII character which is produced by the key
by itself or with Shift on active keyboard layout or alternative ASCII capable
keyboard layout if active keyboard layout isn't ASCII capable. However, we've
ignored alternative ASCII capable keyboard layout's character if both the
key itself and with Shift don't produce ASCII alphabet nor ASCII numeral,
i.e., ASCII punctuation characters are not used in alternative ASCII capable
keyboard layout because of avoiding mapping a keyCode value to 2 or more keys.
However, setting 0 to keyCode value makes Firefox unusable with some web
applications which are aware of neither KeyboardEvent.key nor
KeyboardEvent.code. So, even if we map same keyCode value to a key, we should
avoid setting keyCode value to 0 as far as possible.
This patch's approach is, we behave same keyCode value as the alternative ASCII
capable keyCode is selected when computed keyCode value of active keyboard
layout is 0. This means that we will make some language users whose keyboard
layout for their language is not ASCII capable can use global web services
which support US keyboard layout of Firefox since the new keyCode values
are mostly computed with US layout on Windows or actual alternative ASCII
capable keyboard layout on macOS and Linux. In other words, we cannot improve
compatibility with web applications which don't support Firefox by this patch
since our keyCode values are really different from Chrome's. So, unfortunately,
if we'd use exactly same keyCode computation as Chromium, we'd break
compatibility with existing web applications which are aware of Firefox since
it's necessary to check UA name or something before using keyCode values.
Note that the most important difference between Windows and the others is,
such keyCode value is computed with alternative ASCII capable keyboard
layout on macOS and Linux but only on Windows, it's computed with OEM virtual
keycode. This means that only on Windows, the keyCode value may be different
from actual alternative ASCII capable keyboard layout's keyCode.
MozReview-Commit-ID: As289r9wp6i
--HG--
extra : rebase_source : 66181403dbe8ca8dab893edc8f4eec1991d544d0
2018-02-16 09:54:07 +03:00
|
|
|
/* static */ uint32_t WidgetKeyboardEvent::GetFallbackKeyCodeOfPunctuationKey(
|
|
|
|
CodeNameIndex aCodeNameIndex) {
|
|
|
|
switch (aCodeNameIndex) {
|
|
|
|
case CODE_NAME_INDEX_Semicolon: // VK_OEM_1 on Windows
|
2018-06-26 00:20:54 +03:00
|
|
|
return dom::KeyboardEvent_Binding::DOM_VK_SEMICOLON;
|
Bug 1036008 - Use alternative ASCII capable keyboard layout information to decide keyCode even if the key produces an ASCII punctuation character r=smaug
Gecko decides keyCode from an ASCII character which is produced by the key
by itself or with Shift on active keyboard layout or alternative ASCII capable
keyboard layout if active keyboard layout isn't ASCII capable. However, we've
ignored alternative ASCII capable keyboard layout's character if both the
key itself and with Shift don't produce ASCII alphabet nor ASCII numeral,
i.e., ASCII punctuation characters are not used in alternative ASCII capable
keyboard layout because of avoiding mapping a keyCode value to 2 or more keys.
However, setting 0 to keyCode value makes Firefox unusable with some web
applications which are aware of neither KeyboardEvent.key nor
KeyboardEvent.code. So, even if we map same keyCode value to a key, we should
avoid setting keyCode value to 0 as far as possible.
This patch's approach is, we behave same keyCode value as the alternative ASCII
capable keyCode is selected when computed keyCode value of active keyboard
layout is 0. This means that we will make some language users whose keyboard
layout for their language is not ASCII capable can use global web services
which support US keyboard layout of Firefox since the new keyCode values
are mostly computed with US layout on Windows or actual alternative ASCII
capable keyboard layout on macOS and Linux. In other words, we cannot improve
compatibility with web applications which don't support Firefox by this patch
since our keyCode values are really different from Chrome's. So, unfortunately,
if we'd use exactly same keyCode computation as Chromium, we'd break
compatibility with existing web applications which are aware of Firefox since
it's necessary to check UA name or something before using keyCode values.
Note that the most important difference between Windows and the others is,
such keyCode value is computed with alternative ASCII capable keyboard
layout on macOS and Linux but only on Windows, it's computed with OEM virtual
keycode. This means that only on Windows, the keyCode value may be different
from actual alternative ASCII capable keyboard layout's keyCode.
MozReview-Commit-ID: As289r9wp6i
--HG--
extra : rebase_source : 66181403dbe8ca8dab893edc8f4eec1991d544d0
2018-02-16 09:54:07 +03:00
|
|
|
case CODE_NAME_INDEX_Equal: // VK_OEM_PLUS on Windows
|
2018-06-26 00:20:54 +03:00
|
|
|
return dom::KeyboardEvent_Binding::DOM_VK_EQUALS;
|
Bug 1036008 - Use alternative ASCII capable keyboard layout information to decide keyCode even if the key produces an ASCII punctuation character r=smaug
Gecko decides keyCode from an ASCII character which is produced by the key
by itself or with Shift on active keyboard layout or alternative ASCII capable
keyboard layout if active keyboard layout isn't ASCII capable. However, we've
ignored alternative ASCII capable keyboard layout's character if both the
key itself and with Shift don't produce ASCII alphabet nor ASCII numeral,
i.e., ASCII punctuation characters are not used in alternative ASCII capable
keyboard layout because of avoiding mapping a keyCode value to 2 or more keys.
However, setting 0 to keyCode value makes Firefox unusable with some web
applications which are aware of neither KeyboardEvent.key nor
KeyboardEvent.code. So, even if we map same keyCode value to a key, we should
avoid setting keyCode value to 0 as far as possible.
This patch's approach is, we behave same keyCode value as the alternative ASCII
capable keyCode is selected when computed keyCode value of active keyboard
layout is 0. This means that we will make some language users whose keyboard
layout for their language is not ASCII capable can use global web services
which support US keyboard layout of Firefox since the new keyCode values
are mostly computed with US layout on Windows or actual alternative ASCII
capable keyboard layout on macOS and Linux. In other words, we cannot improve
compatibility with web applications which don't support Firefox by this patch
since our keyCode values are really different from Chrome's. So, unfortunately,
if we'd use exactly same keyCode computation as Chromium, we'd break
compatibility with existing web applications which are aware of Firefox since
it's necessary to check UA name or something before using keyCode values.
Note that the most important difference between Windows and the others is,
such keyCode value is computed with alternative ASCII capable keyboard
layout on macOS and Linux but only on Windows, it's computed with OEM virtual
keycode. This means that only on Windows, the keyCode value may be different
from actual alternative ASCII capable keyboard layout's keyCode.
MozReview-Commit-ID: As289r9wp6i
--HG--
extra : rebase_source : 66181403dbe8ca8dab893edc8f4eec1991d544d0
2018-02-16 09:54:07 +03:00
|
|
|
case CODE_NAME_INDEX_Comma: // VK_OEM_COMMA on Windows
|
2018-06-26 00:20:54 +03:00
|
|
|
return dom::KeyboardEvent_Binding::DOM_VK_COMMA;
|
Bug 1036008 - Use alternative ASCII capable keyboard layout information to decide keyCode even if the key produces an ASCII punctuation character r=smaug
Gecko decides keyCode from an ASCII character which is produced by the key
by itself or with Shift on active keyboard layout or alternative ASCII capable
keyboard layout if active keyboard layout isn't ASCII capable. However, we've
ignored alternative ASCII capable keyboard layout's character if both the
key itself and with Shift don't produce ASCII alphabet nor ASCII numeral,
i.e., ASCII punctuation characters are not used in alternative ASCII capable
keyboard layout because of avoiding mapping a keyCode value to 2 or more keys.
However, setting 0 to keyCode value makes Firefox unusable with some web
applications which are aware of neither KeyboardEvent.key nor
KeyboardEvent.code. So, even if we map same keyCode value to a key, we should
avoid setting keyCode value to 0 as far as possible.
This patch's approach is, we behave same keyCode value as the alternative ASCII
capable keyCode is selected when computed keyCode value of active keyboard
layout is 0. This means that we will make some language users whose keyboard
layout for their language is not ASCII capable can use global web services
which support US keyboard layout of Firefox since the new keyCode values
are mostly computed with US layout on Windows or actual alternative ASCII
capable keyboard layout on macOS and Linux. In other words, we cannot improve
compatibility with web applications which don't support Firefox by this patch
since our keyCode values are really different from Chrome's. So, unfortunately,
if we'd use exactly same keyCode computation as Chromium, we'd break
compatibility with existing web applications which are aware of Firefox since
it's necessary to check UA name or something before using keyCode values.
Note that the most important difference between Windows and the others is,
such keyCode value is computed with alternative ASCII capable keyboard
layout on macOS and Linux but only on Windows, it's computed with OEM virtual
keycode. This means that only on Windows, the keyCode value may be different
from actual alternative ASCII capable keyboard layout's keyCode.
MozReview-Commit-ID: As289r9wp6i
--HG--
extra : rebase_source : 66181403dbe8ca8dab893edc8f4eec1991d544d0
2018-02-16 09:54:07 +03:00
|
|
|
case CODE_NAME_INDEX_Minus: // VK_OEM_MINUS on Windows
|
2018-06-26 00:20:54 +03:00
|
|
|
return dom::KeyboardEvent_Binding::DOM_VK_HYPHEN_MINUS;
|
Bug 1036008 - Use alternative ASCII capable keyboard layout information to decide keyCode even if the key produces an ASCII punctuation character r=smaug
Gecko decides keyCode from an ASCII character which is produced by the key
by itself or with Shift on active keyboard layout or alternative ASCII capable
keyboard layout if active keyboard layout isn't ASCII capable. However, we've
ignored alternative ASCII capable keyboard layout's character if both the
key itself and with Shift don't produce ASCII alphabet nor ASCII numeral,
i.e., ASCII punctuation characters are not used in alternative ASCII capable
keyboard layout because of avoiding mapping a keyCode value to 2 or more keys.
However, setting 0 to keyCode value makes Firefox unusable with some web
applications which are aware of neither KeyboardEvent.key nor
KeyboardEvent.code. So, even if we map same keyCode value to a key, we should
avoid setting keyCode value to 0 as far as possible.
This patch's approach is, we behave same keyCode value as the alternative ASCII
capable keyCode is selected when computed keyCode value of active keyboard
layout is 0. This means that we will make some language users whose keyboard
layout for their language is not ASCII capable can use global web services
which support US keyboard layout of Firefox since the new keyCode values
are mostly computed with US layout on Windows or actual alternative ASCII
capable keyboard layout on macOS and Linux. In other words, we cannot improve
compatibility with web applications which don't support Firefox by this patch
since our keyCode values are really different from Chrome's. So, unfortunately,
if we'd use exactly same keyCode computation as Chromium, we'd break
compatibility with existing web applications which are aware of Firefox since
it's necessary to check UA name or something before using keyCode values.
Note that the most important difference between Windows and the others is,
such keyCode value is computed with alternative ASCII capable keyboard
layout on macOS and Linux but only on Windows, it's computed with OEM virtual
keycode. This means that only on Windows, the keyCode value may be different
from actual alternative ASCII capable keyboard layout's keyCode.
MozReview-Commit-ID: As289r9wp6i
--HG--
extra : rebase_source : 66181403dbe8ca8dab893edc8f4eec1991d544d0
2018-02-16 09:54:07 +03:00
|
|
|
case CODE_NAME_INDEX_Period: // VK_OEM_PERIOD on Windows
|
2018-06-26 00:20:54 +03:00
|
|
|
return dom::KeyboardEvent_Binding::DOM_VK_PERIOD;
|
Bug 1036008 - Use alternative ASCII capable keyboard layout information to decide keyCode even if the key produces an ASCII punctuation character r=smaug
Gecko decides keyCode from an ASCII character which is produced by the key
by itself or with Shift on active keyboard layout or alternative ASCII capable
keyboard layout if active keyboard layout isn't ASCII capable. However, we've
ignored alternative ASCII capable keyboard layout's character if both the
key itself and with Shift don't produce ASCII alphabet nor ASCII numeral,
i.e., ASCII punctuation characters are not used in alternative ASCII capable
keyboard layout because of avoiding mapping a keyCode value to 2 or more keys.
However, setting 0 to keyCode value makes Firefox unusable with some web
applications which are aware of neither KeyboardEvent.key nor
KeyboardEvent.code. So, even if we map same keyCode value to a key, we should
avoid setting keyCode value to 0 as far as possible.
This patch's approach is, we behave same keyCode value as the alternative ASCII
capable keyCode is selected when computed keyCode value of active keyboard
layout is 0. This means that we will make some language users whose keyboard
layout for their language is not ASCII capable can use global web services
which support US keyboard layout of Firefox since the new keyCode values
are mostly computed with US layout on Windows or actual alternative ASCII
capable keyboard layout on macOS and Linux. In other words, we cannot improve
compatibility with web applications which don't support Firefox by this patch
since our keyCode values are really different from Chrome's. So, unfortunately,
if we'd use exactly same keyCode computation as Chromium, we'd break
compatibility with existing web applications which are aware of Firefox since
it's necessary to check UA name or something before using keyCode values.
Note that the most important difference between Windows and the others is,
such keyCode value is computed with alternative ASCII capable keyboard
layout on macOS and Linux but only on Windows, it's computed with OEM virtual
keycode. This means that only on Windows, the keyCode value may be different
from actual alternative ASCII capable keyboard layout's keyCode.
MozReview-Commit-ID: As289r9wp6i
--HG--
extra : rebase_source : 66181403dbe8ca8dab893edc8f4eec1991d544d0
2018-02-16 09:54:07 +03:00
|
|
|
case CODE_NAME_INDEX_Slash: // VK_OEM_2 on Windows
|
2018-06-26 00:20:54 +03:00
|
|
|
return dom::KeyboardEvent_Binding::DOM_VK_SLASH;
|
Bug 1036008 - Use alternative ASCII capable keyboard layout information to decide keyCode even if the key produces an ASCII punctuation character r=smaug
Gecko decides keyCode from an ASCII character which is produced by the key
by itself or with Shift on active keyboard layout or alternative ASCII capable
keyboard layout if active keyboard layout isn't ASCII capable. However, we've
ignored alternative ASCII capable keyboard layout's character if both the
key itself and with Shift don't produce ASCII alphabet nor ASCII numeral,
i.e., ASCII punctuation characters are not used in alternative ASCII capable
keyboard layout because of avoiding mapping a keyCode value to 2 or more keys.
However, setting 0 to keyCode value makes Firefox unusable with some web
applications which are aware of neither KeyboardEvent.key nor
KeyboardEvent.code. So, even if we map same keyCode value to a key, we should
avoid setting keyCode value to 0 as far as possible.
This patch's approach is, we behave same keyCode value as the alternative ASCII
capable keyCode is selected when computed keyCode value of active keyboard
layout is 0. This means that we will make some language users whose keyboard
layout for their language is not ASCII capable can use global web services
which support US keyboard layout of Firefox since the new keyCode values
are mostly computed with US layout on Windows or actual alternative ASCII
capable keyboard layout on macOS and Linux. In other words, we cannot improve
compatibility with web applications which don't support Firefox by this patch
since our keyCode values are really different from Chrome's. So, unfortunately,
if we'd use exactly same keyCode computation as Chromium, we'd break
compatibility with existing web applications which are aware of Firefox since
it's necessary to check UA name or something before using keyCode values.
Note that the most important difference between Windows and the others is,
such keyCode value is computed with alternative ASCII capable keyboard
layout on macOS and Linux but only on Windows, it's computed with OEM virtual
keycode. This means that only on Windows, the keyCode value may be different
from actual alternative ASCII capable keyboard layout's keyCode.
MozReview-Commit-ID: As289r9wp6i
--HG--
extra : rebase_source : 66181403dbe8ca8dab893edc8f4eec1991d544d0
2018-02-16 09:54:07 +03:00
|
|
|
case CODE_NAME_INDEX_Backquote: // VK_OEM_3 on Windows
|
2018-06-26 00:20:54 +03:00
|
|
|
return dom::KeyboardEvent_Binding::DOM_VK_BACK_QUOTE;
|
Bug 1036008 - Use alternative ASCII capable keyboard layout information to decide keyCode even if the key produces an ASCII punctuation character r=smaug
Gecko decides keyCode from an ASCII character which is produced by the key
by itself or with Shift on active keyboard layout or alternative ASCII capable
keyboard layout if active keyboard layout isn't ASCII capable. However, we've
ignored alternative ASCII capable keyboard layout's character if both the
key itself and with Shift don't produce ASCII alphabet nor ASCII numeral,
i.e., ASCII punctuation characters are not used in alternative ASCII capable
keyboard layout because of avoiding mapping a keyCode value to 2 or more keys.
However, setting 0 to keyCode value makes Firefox unusable with some web
applications which are aware of neither KeyboardEvent.key nor
KeyboardEvent.code. So, even if we map same keyCode value to a key, we should
avoid setting keyCode value to 0 as far as possible.
This patch's approach is, we behave same keyCode value as the alternative ASCII
capable keyCode is selected when computed keyCode value of active keyboard
layout is 0. This means that we will make some language users whose keyboard
layout for their language is not ASCII capable can use global web services
which support US keyboard layout of Firefox since the new keyCode values
are mostly computed with US layout on Windows or actual alternative ASCII
capable keyboard layout on macOS and Linux. In other words, we cannot improve
compatibility with web applications which don't support Firefox by this patch
since our keyCode values are really different from Chrome's. So, unfortunately,
if we'd use exactly same keyCode computation as Chromium, we'd break
compatibility with existing web applications which are aware of Firefox since
it's necessary to check UA name or something before using keyCode values.
Note that the most important difference between Windows and the others is,
such keyCode value is computed with alternative ASCII capable keyboard
layout on macOS and Linux but only on Windows, it's computed with OEM virtual
keycode. This means that only on Windows, the keyCode value may be different
from actual alternative ASCII capable keyboard layout's keyCode.
MozReview-Commit-ID: As289r9wp6i
--HG--
extra : rebase_source : 66181403dbe8ca8dab893edc8f4eec1991d544d0
2018-02-16 09:54:07 +03:00
|
|
|
case CODE_NAME_INDEX_BracketLeft: // VK_OEM_4 on Windows
|
2018-06-26 00:20:54 +03:00
|
|
|
return dom::KeyboardEvent_Binding::DOM_VK_OPEN_BRACKET;
|
Bug 1036008 - Use alternative ASCII capable keyboard layout information to decide keyCode even if the key produces an ASCII punctuation character r=smaug
Gecko decides keyCode from an ASCII character which is produced by the key
by itself or with Shift on active keyboard layout or alternative ASCII capable
keyboard layout if active keyboard layout isn't ASCII capable. However, we've
ignored alternative ASCII capable keyboard layout's character if both the
key itself and with Shift don't produce ASCII alphabet nor ASCII numeral,
i.e., ASCII punctuation characters are not used in alternative ASCII capable
keyboard layout because of avoiding mapping a keyCode value to 2 or more keys.
However, setting 0 to keyCode value makes Firefox unusable with some web
applications which are aware of neither KeyboardEvent.key nor
KeyboardEvent.code. So, even if we map same keyCode value to a key, we should
avoid setting keyCode value to 0 as far as possible.
This patch's approach is, we behave same keyCode value as the alternative ASCII
capable keyCode is selected when computed keyCode value of active keyboard
layout is 0. This means that we will make some language users whose keyboard
layout for their language is not ASCII capable can use global web services
which support US keyboard layout of Firefox since the new keyCode values
are mostly computed with US layout on Windows or actual alternative ASCII
capable keyboard layout on macOS and Linux. In other words, we cannot improve
compatibility with web applications which don't support Firefox by this patch
since our keyCode values are really different from Chrome's. So, unfortunately,
if we'd use exactly same keyCode computation as Chromium, we'd break
compatibility with existing web applications which are aware of Firefox since
it's necessary to check UA name or something before using keyCode values.
Note that the most important difference between Windows and the others is,
such keyCode value is computed with alternative ASCII capable keyboard
layout on macOS and Linux but only on Windows, it's computed with OEM virtual
keycode. This means that only on Windows, the keyCode value may be different
from actual alternative ASCII capable keyboard layout's keyCode.
MozReview-Commit-ID: As289r9wp6i
--HG--
extra : rebase_source : 66181403dbe8ca8dab893edc8f4eec1991d544d0
2018-02-16 09:54:07 +03:00
|
|
|
case CODE_NAME_INDEX_Backslash: // VK_OEM_5 on Windows
|
2018-06-26 00:20:54 +03:00
|
|
|
return dom::KeyboardEvent_Binding::DOM_VK_BACK_SLASH;
|
Bug 1036008 - Use alternative ASCII capable keyboard layout information to decide keyCode even if the key produces an ASCII punctuation character r=smaug
Gecko decides keyCode from an ASCII character which is produced by the key
by itself or with Shift on active keyboard layout or alternative ASCII capable
keyboard layout if active keyboard layout isn't ASCII capable. However, we've
ignored alternative ASCII capable keyboard layout's character if both the
key itself and with Shift don't produce ASCII alphabet nor ASCII numeral,
i.e., ASCII punctuation characters are not used in alternative ASCII capable
keyboard layout because of avoiding mapping a keyCode value to 2 or more keys.
However, setting 0 to keyCode value makes Firefox unusable with some web
applications which are aware of neither KeyboardEvent.key nor
KeyboardEvent.code. So, even if we map same keyCode value to a key, we should
avoid setting keyCode value to 0 as far as possible.
This patch's approach is, we behave same keyCode value as the alternative ASCII
capable keyCode is selected when computed keyCode value of active keyboard
layout is 0. This means that we will make some language users whose keyboard
layout for their language is not ASCII capable can use global web services
which support US keyboard layout of Firefox since the new keyCode values
are mostly computed with US layout on Windows or actual alternative ASCII
capable keyboard layout on macOS and Linux. In other words, we cannot improve
compatibility with web applications which don't support Firefox by this patch
since our keyCode values are really different from Chrome's. So, unfortunately,
if we'd use exactly same keyCode computation as Chromium, we'd break
compatibility with existing web applications which are aware of Firefox since
it's necessary to check UA name or something before using keyCode values.
Note that the most important difference between Windows and the others is,
such keyCode value is computed with alternative ASCII capable keyboard
layout on macOS and Linux but only on Windows, it's computed with OEM virtual
keycode. This means that only on Windows, the keyCode value may be different
from actual alternative ASCII capable keyboard layout's keyCode.
MozReview-Commit-ID: As289r9wp6i
--HG--
extra : rebase_source : 66181403dbe8ca8dab893edc8f4eec1991d544d0
2018-02-16 09:54:07 +03:00
|
|
|
case CODE_NAME_INDEX_BracketRight: // VK_OEM_6 on Windows
|
2018-06-26 00:20:54 +03:00
|
|
|
return dom::KeyboardEvent_Binding::DOM_VK_CLOSE_BRACKET;
|
Bug 1036008 - Use alternative ASCII capable keyboard layout information to decide keyCode even if the key produces an ASCII punctuation character r=smaug
Gecko decides keyCode from an ASCII character which is produced by the key
by itself or with Shift on active keyboard layout or alternative ASCII capable
keyboard layout if active keyboard layout isn't ASCII capable. However, we've
ignored alternative ASCII capable keyboard layout's character if both the
key itself and with Shift don't produce ASCII alphabet nor ASCII numeral,
i.e., ASCII punctuation characters are not used in alternative ASCII capable
keyboard layout because of avoiding mapping a keyCode value to 2 or more keys.
However, setting 0 to keyCode value makes Firefox unusable with some web
applications which are aware of neither KeyboardEvent.key nor
KeyboardEvent.code. So, even if we map same keyCode value to a key, we should
avoid setting keyCode value to 0 as far as possible.
This patch's approach is, we behave same keyCode value as the alternative ASCII
capable keyCode is selected when computed keyCode value of active keyboard
layout is 0. This means that we will make some language users whose keyboard
layout for their language is not ASCII capable can use global web services
which support US keyboard layout of Firefox since the new keyCode values
are mostly computed with US layout on Windows or actual alternative ASCII
capable keyboard layout on macOS and Linux. In other words, we cannot improve
compatibility with web applications which don't support Firefox by this patch
since our keyCode values are really different from Chrome's. So, unfortunately,
if we'd use exactly same keyCode computation as Chromium, we'd break
compatibility with existing web applications which are aware of Firefox since
it's necessary to check UA name or something before using keyCode values.
Note that the most important difference between Windows and the others is,
such keyCode value is computed with alternative ASCII capable keyboard
layout on macOS and Linux but only on Windows, it's computed with OEM virtual
keycode. This means that only on Windows, the keyCode value may be different
from actual alternative ASCII capable keyboard layout's keyCode.
MozReview-Commit-ID: As289r9wp6i
--HG--
extra : rebase_source : 66181403dbe8ca8dab893edc8f4eec1991d544d0
2018-02-16 09:54:07 +03:00
|
|
|
case CODE_NAME_INDEX_Quote: // VK_OEM_7 on Windows
|
2018-06-26 00:20:54 +03:00
|
|
|
return dom::KeyboardEvent_Binding::DOM_VK_QUOTE;
|
Bug 1036008 - Use alternative ASCII capable keyboard layout information to decide keyCode even if the key produces an ASCII punctuation character r=smaug
Gecko decides keyCode from an ASCII character which is produced by the key
by itself or with Shift on active keyboard layout or alternative ASCII capable
keyboard layout if active keyboard layout isn't ASCII capable. However, we've
ignored alternative ASCII capable keyboard layout's character if both the
key itself and with Shift don't produce ASCII alphabet nor ASCII numeral,
i.e., ASCII punctuation characters are not used in alternative ASCII capable
keyboard layout because of avoiding mapping a keyCode value to 2 or more keys.
However, setting 0 to keyCode value makes Firefox unusable with some web
applications which are aware of neither KeyboardEvent.key nor
KeyboardEvent.code. So, even if we map same keyCode value to a key, we should
avoid setting keyCode value to 0 as far as possible.
This patch's approach is, we behave same keyCode value as the alternative ASCII
capable keyCode is selected when computed keyCode value of active keyboard
layout is 0. This means that we will make some language users whose keyboard
layout for their language is not ASCII capable can use global web services
which support US keyboard layout of Firefox since the new keyCode values
are mostly computed with US layout on Windows or actual alternative ASCII
capable keyboard layout on macOS and Linux. In other words, we cannot improve
compatibility with web applications which don't support Firefox by this patch
since our keyCode values are really different from Chrome's. So, unfortunately,
if we'd use exactly same keyCode computation as Chromium, we'd break
compatibility with existing web applications which are aware of Firefox since
it's necessary to check UA name or something before using keyCode values.
Note that the most important difference between Windows and the others is,
such keyCode value is computed with alternative ASCII capable keyboard
layout on macOS and Linux but only on Windows, it's computed with OEM virtual
keycode. This means that only on Windows, the keyCode value may be different
from actual alternative ASCII capable keyboard layout's keyCode.
MozReview-Commit-ID: As289r9wp6i
--HG--
extra : rebase_source : 66181403dbe8ca8dab893edc8f4eec1991d544d0
2018-02-16 09:54:07 +03:00
|
|
|
case CODE_NAME_INDEX_IntlBackslash: // VK_OEM_5 on Windows (ABNT, etc)
|
|
|
|
case CODE_NAME_INDEX_IntlYen: // VK_OEM_5 on Windows (JIS)
|
|
|
|
case CODE_NAME_INDEX_IntlRo: // VK_OEM_102 on Windows
|
2018-06-26 00:20:54 +03:00
|
|
|
return dom::KeyboardEvent_Binding::DOM_VK_BACK_SLASH;
|
Bug 1036008 - Use alternative ASCII capable keyboard layout information to decide keyCode even if the key produces an ASCII punctuation character r=smaug
Gecko decides keyCode from an ASCII character which is produced by the key
by itself or with Shift on active keyboard layout or alternative ASCII capable
keyboard layout if active keyboard layout isn't ASCII capable. However, we've
ignored alternative ASCII capable keyboard layout's character if both the
key itself and with Shift don't produce ASCII alphabet nor ASCII numeral,
i.e., ASCII punctuation characters are not used in alternative ASCII capable
keyboard layout because of avoiding mapping a keyCode value to 2 or more keys.
However, setting 0 to keyCode value makes Firefox unusable with some web
applications which are aware of neither KeyboardEvent.key nor
KeyboardEvent.code. So, even if we map same keyCode value to a key, we should
avoid setting keyCode value to 0 as far as possible.
This patch's approach is, we behave same keyCode value as the alternative ASCII
capable keyCode is selected when computed keyCode value of active keyboard
layout is 0. This means that we will make some language users whose keyboard
layout for their language is not ASCII capable can use global web services
which support US keyboard layout of Firefox since the new keyCode values
are mostly computed with US layout on Windows or actual alternative ASCII
capable keyboard layout on macOS and Linux. In other words, we cannot improve
compatibility with web applications which don't support Firefox by this patch
since our keyCode values are really different from Chrome's. So, unfortunately,
if we'd use exactly same keyCode computation as Chromium, we'd break
compatibility with existing web applications which are aware of Firefox since
it's necessary to check UA name or something before using keyCode values.
Note that the most important difference between Windows and the others is,
such keyCode value is computed with alternative ASCII capable keyboard
layout on macOS and Linux but only on Windows, it's computed with OEM virtual
keycode. This means that only on Windows, the keyCode value may be different
from actual alternative ASCII capable keyboard layout's keyCode.
MozReview-Commit-ID: As289r9wp6i
--HG--
extra : rebase_source : 66181403dbe8ca8dab893edc8f4eec1991d544d0
2018-02-16 09:54:07 +03:00
|
|
|
default:
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-03-14 17:13:30 +04:00
|
|
|
/* static */ const char* WidgetKeyboardEvent::GetCommandStr(Command aCommand) {
|
|
|
|
#define NS_DEFINE_COMMAND(aName, aCommandStr) , #aCommandStr
|
Bug 1403759 - part 2: Handle edit/selection commands like insertNewline: in TextInputHandler::HandleCommand() r=m_kato
Let's make TextInputHandler::HandleCommand() handle other
commands which are caused by Backspace, Delete, Tab, ArrowUp,
ArrowDown, ArrowRight, ArrowLeft, PageUp, PageDown, Home, End
and Escape keys with various modifiers.
This patch makes Korean users can do most key operation in
editor even with composing Hangul character.
Note that this patch has a hack for cancelOperation: command.
The command is typically fired for Escape key press. However,
it's also fired for Command + Period. Unfortunately, this
behavior is really odd if subclass of NSResponder implements
|void cancelOperation:(id)sender|. If it's implemented,
Cocoa doesn't call its |void keyDown:(NSEvent)theEvent|.
Instead, it calls only |void doCommandBySelector:(SEL)aSelector|
and |void cancelOperation:(id)sender| when Command + Period is
pressed. Therefore, we cannot dispatch keydown nor keypress
event for this key combination if we implement it. Therefore,
this patch doesn't implement the method but handle it in
doCommandBySelector even though the super class of ChildView
cannot handle the command with this path.
MozReview-Commit-ID: 4hS23SiwNJv
--HG--
extra : rebase_source : 38ac1ea494b5f786ecd5c9327efbacd460b59faf
2017-12-02 08:53:10 +03:00
|
|
|
#define NS_DEFINE_COMMAND_NO_EXEC_COMMAND(aName)
|
2016-03-11 05:57:18 +03:00
|
|
|
static const char* const kCommands[] = {
|
2014-03-14 17:13:30 +04:00
|
|
|
"" // CommandDoNothing
|
|
|
|
#include "mozilla/CommandList.h"
|
|
|
|
};
|
|
|
|
#undef NS_DEFINE_COMMAND
|
Bug 1403759 - part 2: Handle edit/selection commands like insertNewline: in TextInputHandler::HandleCommand() r=m_kato
Let's make TextInputHandler::HandleCommand() handle other
commands which are caused by Backspace, Delete, Tab, ArrowUp,
ArrowDown, ArrowRight, ArrowLeft, PageUp, PageDown, Home, End
and Escape keys with various modifiers.
This patch makes Korean users can do most key operation in
editor even with composing Hangul character.
Note that this patch has a hack for cancelOperation: command.
The command is typically fired for Escape key press. However,
it's also fired for Command + Period. Unfortunately, this
behavior is really odd if subclass of NSResponder implements
|void cancelOperation:(id)sender|. If it's implemented,
Cocoa doesn't call its |void keyDown:(NSEvent)theEvent|.
Instead, it calls only |void doCommandBySelector:(SEL)aSelector|
and |void cancelOperation:(id)sender| when Command + Period is
pressed. Therefore, we cannot dispatch keydown nor keypress
event for this key combination if we implement it. Therefore,
this patch doesn't implement the method but handle it in
doCommandBySelector even though the super class of ChildView
cannot handle the command with this path.
MozReview-Commit-ID: 4hS23SiwNJv
--HG--
extra : rebase_source : 38ac1ea494b5f786ecd5c9327efbacd460b59faf
2017-12-02 08:53:10 +03:00
|
|
|
#undef NS_DEFINE_COMMAND_NO_EXEC_COMMAND
|
2014-03-14 17:13:30 +04:00
|
|
|
|
|
|
|
MOZ_RELEASE_ASSERT(static_cast<size_t>(aCommand) < ArrayLength(kCommands),
|
|
|
|
"Illegal command enumeration value");
|
|
|
|
return kCommands[aCommand];
|
|
|
|
}
|
|
|
|
|
2015-01-28 16:36:53 +03:00
|
|
|
/* static */ uint32_t WidgetKeyboardEvent::ComputeLocationFromCodeValue(
|
|
|
|
CodeNameIndex aCodeNameIndex) {
|
|
|
|
// Following commented out cases are not defined in PhysicalKeyCodeNameList.h
|
|
|
|
// but are defined by D3E spec. So, they should be uncommented when the
|
|
|
|
// code values are defined in the header.
|
|
|
|
switch (aCodeNameIndex) {
|
|
|
|
case CODE_NAME_INDEX_AltLeft:
|
|
|
|
case CODE_NAME_INDEX_ControlLeft:
|
|
|
|
case CODE_NAME_INDEX_OSLeft:
|
|
|
|
case CODE_NAME_INDEX_ShiftLeft:
|
2017-02-08 15:04:22 +03:00
|
|
|
return eKeyLocationLeft;
|
2015-01-28 16:36:53 +03:00
|
|
|
case CODE_NAME_INDEX_AltRight:
|
|
|
|
case CODE_NAME_INDEX_ControlRight:
|
|
|
|
case CODE_NAME_INDEX_OSRight:
|
|
|
|
case CODE_NAME_INDEX_ShiftRight:
|
2017-02-08 15:04:22 +03:00
|
|
|
return eKeyLocationRight;
|
2015-01-28 16:36:53 +03:00
|
|
|
case CODE_NAME_INDEX_Numpad0:
|
|
|
|
case CODE_NAME_INDEX_Numpad1:
|
|
|
|
case CODE_NAME_INDEX_Numpad2:
|
|
|
|
case CODE_NAME_INDEX_Numpad3:
|
|
|
|
case CODE_NAME_INDEX_Numpad4:
|
|
|
|
case CODE_NAME_INDEX_Numpad5:
|
|
|
|
case CODE_NAME_INDEX_Numpad6:
|
|
|
|
case CODE_NAME_INDEX_Numpad7:
|
|
|
|
case CODE_NAME_INDEX_Numpad8:
|
|
|
|
case CODE_NAME_INDEX_Numpad9:
|
|
|
|
case CODE_NAME_INDEX_NumpadAdd:
|
|
|
|
case CODE_NAME_INDEX_NumpadBackspace:
|
2015-02-19 09:50:20 +03:00
|
|
|
case CODE_NAME_INDEX_NumpadClear:
|
|
|
|
case CODE_NAME_INDEX_NumpadClearEntry:
|
2015-01-28 16:36:53 +03:00
|
|
|
case CODE_NAME_INDEX_NumpadComma:
|
|
|
|
case CODE_NAME_INDEX_NumpadDecimal:
|
|
|
|
case CODE_NAME_INDEX_NumpadDivide:
|
|
|
|
case CODE_NAME_INDEX_NumpadEnter:
|
|
|
|
case CODE_NAME_INDEX_NumpadEqual:
|
2015-02-19 09:50:20 +03:00
|
|
|
case CODE_NAME_INDEX_NumpadMemoryAdd:
|
|
|
|
case CODE_NAME_INDEX_NumpadMemoryClear:
|
|
|
|
case CODE_NAME_INDEX_NumpadMemoryRecall:
|
|
|
|
case CODE_NAME_INDEX_NumpadMemoryStore:
|
2015-01-28 16:36:53 +03:00
|
|
|
case CODE_NAME_INDEX_NumpadMemorySubtract:
|
|
|
|
case CODE_NAME_INDEX_NumpadMultiply:
|
2015-02-19 09:50:20 +03:00
|
|
|
case CODE_NAME_INDEX_NumpadParenLeft:
|
|
|
|
case CODE_NAME_INDEX_NumpadParenRight:
|
2015-01-28 16:36:53 +03:00
|
|
|
case CODE_NAME_INDEX_NumpadSubtract:
|
2017-02-08 15:04:22 +03:00
|
|
|
return eKeyLocationNumpad;
|
2015-01-28 16:36:53 +03:00
|
|
|
default:
|
2017-02-08 15:04:22 +03:00
|
|
|
return eKeyLocationStandard;
|
2015-01-28 16:36:53 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-02-19 09:50:19 +03:00
|
|
|
/* static */ uint32_t WidgetKeyboardEvent::ComputeKeyCodeFromKeyNameIndex(
|
|
|
|
KeyNameIndex aKeyNameIndex) {
|
|
|
|
switch (aKeyNameIndex) {
|
|
|
|
case KEY_NAME_INDEX_Cancel:
|
2018-06-26 00:20:54 +03:00
|
|
|
return dom::KeyboardEvent_Binding::DOM_VK_CANCEL;
|
2015-02-19 09:50:19 +03:00
|
|
|
case KEY_NAME_INDEX_Help:
|
2018-06-26 00:20:54 +03:00
|
|
|
return dom::KeyboardEvent_Binding::DOM_VK_HELP;
|
2015-02-19 09:50:19 +03:00
|
|
|
case KEY_NAME_INDEX_Backspace:
|
2018-06-26 00:20:54 +03:00
|
|
|
return dom::KeyboardEvent_Binding::DOM_VK_BACK_SPACE;
|
2015-02-19 09:50:19 +03:00
|
|
|
case KEY_NAME_INDEX_Tab:
|
2018-06-26 00:20:54 +03:00
|
|
|
return dom::KeyboardEvent_Binding::DOM_VK_TAB;
|
2015-02-19 09:50:19 +03:00
|
|
|
case KEY_NAME_INDEX_Clear:
|
2018-06-26 00:20:54 +03:00
|
|
|
return dom::KeyboardEvent_Binding::DOM_VK_CLEAR;
|
2015-02-19 09:50:19 +03:00
|
|
|
case KEY_NAME_INDEX_Enter:
|
2018-06-26 00:20:54 +03:00
|
|
|
return dom::KeyboardEvent_Binding::DOM_VK_RETURN;
|
2015-02-19 09:50:19 +03:00
|
|
|
case KEY_NAME_INDEX_Shift:
|
2018-06-26 00:20:54 +03:00
|
|
|
return dom::KeyboardEvent_Binding::DOM_VK_SHIFT;
|
2015-02-19 09:50:19 +03:00
|
|
|
case KEY_NAME_INDEX_Control:
|
2018-06-26 00:20:54 +03:00
|
|
|
return dom::KeyboardEvent_Binding::DOM_VK_CONTROL;
|
2015-02-19 09:50:19 +03:00
|
|
|
case KEY_NAME_INDEX_Alt:
|
2018-06-26 00:20:54 +03:00
|
|
|
return dom::KeyboardEvent_Binding::DOM_VK_ALT;
|
2015-02-19 09:50:19 +03:00
|
|
|
case KEY_NAME_INDEX_Pause:
|
2018-06-26 00:20:54 +03:00
|
|
|
return dom::KeyboardEvent_Binding::DOM_VK_PAUSE;
|
2015-02-19 09:50:19 +03:00
|
|
|
case KEY_NAME_INDEX_CapsLock:
|
2018-06-26 00:20:54 +03:00
|
|
|
return dom::KeyboardEvent_Binding::DOM_VK_CAPS_LOCK;
|
2015-02-19 09:50:19 +03:00
|
|
|
case KEY_NAME_INDEX_Hiragana:
|
|
|
|
case KEY_NAME_INDEX_Katakana:
|
|
|
|
case KEY_NAME_INDEX_HiraganaKatakana:
|
|
|
|
case KEY_NAME_INDEX_KanaMode:
|
2018-06-26 00:20:54 +03:00
|
|
|
return dom::KeyboardEvent_Binding::DOM_VK_KANA;
|
2015-02-19 09:50:19 +03:00
|
|
|
case KEY_NAME_INDEX_HangulMode:
|
2018-06-26 00:20:54 +03:00
|
|
|
return dom::KeyboardEvent_Binding::DOM_VK_HANGUL;
|
2015-02-19 09:50:19 +03:00
|
|
|
case KEY_NAME_INDEX_Eisu:
|
2018-06-26 00:20:54 +03:00
|
|
|
return dom::KeyboardEvent_Binding::DOM_VK_EISU;
|
2015-02-19 09:50:19 +03:00
|
|
|
case KEY_NAME_INDEX_JunjaMode:
|
2018-06-26 00:20:54 +03:00
|
|
|
return dom::KeyboardEvent_Binding::DOM_VK_JUNJA;
|
2015-02-19 09:50:19 +03:00
|
|
|
case KEY_NAME_INDEX_FinalMode:
|
2018-06-26 00:20:54 +03:00
|
|
|
return dom::KeyboardEvent_Binding::DOM_VK_FINAL;
|
2015-02-19 09:50:19 +03:00
|
|
|
case KEY_NAME_INDEX_HanjaMode:
|
2018-06-26 00:20:54 +03:00
|
|
|
return dom::KeyboardEvent_Binding::DOM_VK_HANJA;
|
2015-02-19 09:50:19 +03:00
|
|
|
case KEY_NAME_INDEX_KanjiMode:
|
2018-06-26 00:20:54 +03:00
|
|
|
return dom::KeyboardEvent_Binding::DOM_VK_KANJI;
|
2015-02-19 09:50:19 +03:00
|
|
|
case KEY_NAME_INDEX_Escape:
|
2018-06-26 00:20:54 +03:00
|
|
|
return dom::KeyboardEvent_Binding::DOM_VK_ESCAPE;
|
2015-02-19 09:50:19 +03:00
|
|
|
case KEY_NAME_INDEX_Convert:
|
2018-06-26 00:20:54 +03:00
|
|
|
return dom::KeyboardEvent_Binding::DOM_VK_CONVERT;
|
2015-02-19 09:50:19 +03:00
|
|
|
case KEY_NAME_INDEX_NonConvert:
|
2018-06-26 00:20:54 +03:00
|
|
|
return dom::KeyboardEvent_Binding::DOM_VK_NONCONVERT;
|
2015-02-19 09:50:19 +03:00
|
|
|
case KEY_NAME_INDEX_Accept:
|
2018-06-26 00:20:54 +03:00
|
|
|
return dom::KeyboardEvent_Binding::DOM_VK_ACCEPT;
|
2015-02-19 09:50:19 +03:00
|
|
|
case KEY_NAME_INDEX_ModeChange:
|
2018-06-26 00:20:54 +03:00
|
|
|
return dom::KeyboardEvent_Binding::DOM_VK_MODECHANGE;
|
2015-02-19 09:50:19 +03:00
|
|
|
case KEY_NAME_INDEX_PageUp:
|
2018-06-26 00:20:54 +03:00
|
|
|
return dom::KeyboardEvent_Binding::DOM_VK_PAGE_UP;
|
2015-02-19 09:50:19 +03:00
|
|
|
case KEY_NAME_INDEX_PageDown:
|
2018-06-26 00:20:54 +03:00
|
|
|
return dom::KeyboardEvent_Binding::DOM_VK_PAGE_DOWN;
|
2015-02-19 09:50:19 +03:00
|
|
|
case KEY_NAME_INDEX_End:
|
2018-06-26 00:20:54 +03:00
|
|
|
return dom::KeyboardEvent_Binding::DOM_VK_END;
|
2015-02-19 09:50:19 +03:00
|
|
|
case KEY_NAME_INDEX_Home:
|
2018-06-26 00:20:54 +03:00
|
|
|
return dom::KeyboardEvent_Binding::DOM_VK_HOME;
|
2015-02-19 09:50:19 +03:00
|
|
|
case KEY_NAME_INDEX_ArrowLeft:
|
2018-06-26 00:20:54 +03:00
|
|
|
return dom::KeyboardEvent_Binding::DOM_VK_LEFT;
|
2015-02-19 09:50:19 +03:00
|
|
|
case KEY_NAME_INDEX_ArrowUp:
|
2018-06-26 00:20:54 +03:00
|
|
|
return dom::KeyboardEvent_Binding::DOM_VK_UP;
|
2015-02-19 09:50:19 +03:00
|
|
|
case KEY_NAME_INDEX_ArrowRight:
|
2018-06-26 00:20:54 +03:00
|
|
|
return dom::KeyboardEvent_Binding::DOM_VK_RIGHT;
|
2015-02-19 09:50:19 +03:00
|
|
|
case KEY_NAME_INDEX_ArrowDown:
|
2018-06-26 00:20:54 +03:00
|
|
|
return dom::KeyboardEvent_Binding::DOM_VK_DOWN;
|
2015-02-19 09:50:19 +03:00
|
|
|
case KEY_NAME_INDEX_Select:
|
2018-06-26 00:20:54 +03:00
|
|
|
return dom::KeyboardEvent_Binding::DOM_VK_SELECT;
|
2015-02-19 09:50:19 +03:00
|
|
|
case KEY_NAME_INDEX_Print:
|
2018-06-26 00:20:54 +03:00
|
|
|
return dom::KeyboardEvent_Binding::DOM_VK_PRINT;
|
2015-02-19 09:50:19 +03:00
|
|
|
case KEY_NAME_INDEX_Execute:
|
2018-06-26 00:20:54 +03:00
|
|
|
return dom::KeyboardEvent_Binding::DOM_VK_EXECUTE;
|
2015-02-19 09:50:19 +03:00
|
|
|
case KEY_NAME_INDEX_PrintScreen:
|
2018-06-26 00:20:54 +03:00
|
|
|
return dom::KeyboardEvent_Binding::DOM_VK_PRINTSCREEN;
|
2015-02-19 09:50:19 +03:00
|
|
|
case KEY_NAME_INDEX_Insert:
|
2018-06-26 00:20:54 +03:00
|
|
|
return dom::KeyboardEvent_Binding::DOM_VK_INSERT;
|
2015-02-19 09:50:19 +03:00
|
|
|
case KEY_NAME_INDEX_Delete:
|
2018-06-26 00:20:54 +03:00
|
|
|
return dom::KeyboardEvent_Binding::DOM_VK_DELETE;
|
2015-02-19 09:50:19 +03:00
|
|
|
case KEY_NAME_INDEX_OS:
|
|
|
|
// case KEY_NAME_INDEX_Super:
|
|
|
|
// case KEY_NAME_INDEX_Hyper:
|
2018-06-26 00:20:54 +03:00
|
|
|
return dom::KeyboardEvent_Binding::DOM_VK_WIN;
|
2015-02-19 09:50:19 +03:00
|
|
|
case KEY_NAME_INDEX_ContextMenu:
|
2018-06-26 00:20:54 +03:00
|
|
|
return dom::KeyboardEvent_Binding::DOM_VK_CONTEXT_MENU;
|
2015-02-19 09:50:19 +03:00
|
|
|
case KEY_NAME_INDEX_Standby:
|
2018-06-26 00:20:54 +03:00
|
|
|
return dom::KeyboardEvent_Binding::DOM_VK_SLEEP;
|
2015-02-19 09:50:19 +03:00
|
|
|
case KEY_NAME_INDEX_F1:
|
2018-06-26 00:20:54 +03:00
|
|
|
return dom::KeyboardEvent_Binding::DOM_VK_F1;
|
2015-02-19 09:50:19 +03:00
|
|
|
case KEY_NAME_INDEX_F2:
|
2018-06-26 00:20:54 +03:00
|
|
|
return dom::KeyboardEvent_Binding::DOM_VK_F2;
|
2015-02-19 09:50:19 +03:00
|
|
|
case KEY_NAME_INDEX_F3:
|
2018-06-26 00:20:54 +03:00
|
|
|
return dom::KeyboardEvent_Binding::DOM_VK_F3;
|
2015-02-19 09:50:19 +03:00
|
|
|
case KEY_NAME_INDEX_F4:
|
2018-06-26 00:20:54 +03:00
|
|
|
return dom::KeyboardEvent_Binding::DOM_VK_F4;
|
2015-02-19 09:50:19 +03:00
|
|
|
case KEY_NAME_INDEX_F5:
|
2018-06-26 00:20:54 +03:00
|
|
|
return dom::KeyboardEvent_Binding::DOM_VK_F5;
|
2015-02-19 09:50:19 +03:00
|
|
|
case KEY_NAME_INDEX_F6:
|
2018-06-26 00:20:54 +03:00
|
|
|
return dom::KeyboardEvent_Binding::DOM_VK_F6;
|
2015-02-19 09:50:19 +03:00
|
|
|
case KEY_NAME_INDEX_F7:
|
2018-06-26 00:20:54 +03:00
|
|
|
return dom::KeyboardEvent_Binding::DOM_VK_F7;
|
2015-02-19 09:50:19 +03:00
|
|
|
case KEY_NAME_INDEX_F8:
|
2018-06-26 00:20:54 +03:00
|
|
|
return dom::KeyboardEvent_Binding::DOM_VK_F8;
|
2015-02-19 09:50:19 +03:00
|
|
|
case KEY_NAME_INDEX_F9:
|
2018-06-26 00:20:54 +03:00
|
|
|
return dom::KeyboardEvent_Binding::DOM_VK_F9;
|
2015-02-19 09:50:19 +03:00
|
|
|
case KEY_NAME_INDEX_F10:
|
2018-06-26 00:20:54 +03:00
|
|
|
return dom::KeyboardEvent_Binding::DOM_VK_F10;
|
2015-02-19 09:50:19 +03:00
|
|
|
case KEY_NAME_INDEX_F11:
|
2018-06-26 00:20:54 +03:00
|
|
|
return dom::KeyboardEvent_Binding::DOM_VK_F11;
|
2015-02-19 09:50:19 +03:00
|
|
|
case KEY_NAME_INDEX_F12:
|
2018-06-26 00:20:54 +03:00
|
|
|
return dom::KeyboardEvent_Binding::DOM_VK_F12;
|
2015-02-19 09:50:19 +03:00
|
|
|
case KEY_NAME_INDEX_F13:
|
2018-06-26 00:20:54 +03:00
|
|
|
return dom::KeyboardEvent_Binding::DOM_VK_F13;
|
2015-02-19 09:50:19 +03:00
|
|
|
case KEY_NAME_INDEX_F14:
|
2018-06-26 00:20:54 +03:00
|
|
|
return dom::KeyboardEvent_Binding::DOM_VK_F14;
|
2015-02-19 09:50:19 +03:00
|
|
|
case KEY_NAME_INDEX_F15:
|
2018-06-26 00:20:54 +03:00
|
|
|
return dom::KeyboardEvent_Binding::DOM_VK_F15;
|
2015-02-19 09:50:19 +03:00
|
|
|
case KEY_NAME_INDEX_F16:
|
2018-06-26 00:20:54 +03:00
|
|
|
return dom::KeyboardEvent_Binding::DOM_VK_F16;
|
2015-02-19 09:50:19 +03:00
|
|
|
case KEY_NAME_INDEX_F17:
|
2018-06-26 00:20:54 +03:00
|
|
|
return dom::KeyboardEvent_Binding::DOM_VK_F17;
|
2015-02-19 09:50:19 +03:00
|
|
|
case KEY_NAME_INDEX_F18:
|
2018-06-26 00:20:54 +03:00
|
|
|
return dom::KeyboardEvent_Binding::DOM_VK_F18;
|
2015-02-19 09:50:19 +03:00
|
|
|
case KEY_NAME_INDEX_F19:
|
2018-06-26 00:20:54 +03:00
|
|
|
return dom::KeyboardEvent_Binding::DOM_VK_F19;
|
2015-02-19 09:50:19 +03:00
|
|
|
case KEY_NAME_INDEX_F20:
|
2018-06-26 00:20:54 +03:00
|
|
|
return dom::KeyboardEvent_Binding::DOM_VK_F20;
|
2015-02-19 09:50:19 +03:00
|
|
|
case KEY_NAME_INDEX_F21:
|
2018-06-26 00:20:54 +03:00
|
|
|
return dom::KeyboardEvent_Binding::DOM_VK_F21;
|
2015-02-19 09:50:19 +03:00
|
|
|
case KEY_NAME_INDEX_F22:
|
2018-06-26 00:20:54 +03:00
|
|
|
return dom::KeyboardEvent_Binding::DOM_VK_F22;
|
2015-02-19 09:50:19 +03:00
|
|
|
case KEY_NAME_INDEX_F23:
|
2018-06-26 00:20:54 +03:00
|
|
|
return dom::KeyboardEvent_Binding::DOM_VK_F23;
|
2015-02-19 09:50:19 +03:00
|
|
|
case KEY_NAME_INDEX_F24:
|
2018-06-26 00:20:54 +03:00
|
|
|
return dom::KeyboardEvent_Binding::DOM_VK_F24;
|
2015-02-19 09:50:19 +03:00
|
|
|
case KEY_NAME_INDEX_NumLock:
|
2018-06-26 00:20:54 +03:00
|
|
|
return dom::KeyboardEvent_Binding::DOM_VK_NUM_LOCK;
|
2015-02-19 09:50:19 +03:00
|
|
|
case KEY_NAME_INDEX_ScrollLock:
|
2018-06-26 00:20:54 +03:00
|
|
|
return dom::KeyboardEvent_Binding::DOM_VK_SCROLL_LOCK;
|
2016-05-20 18:57:18 +03:00
|
|
|
case KEY_NAME_INDEX_AudioVolumeMute:
|
2018-06-26 00:20:54 +03:00
|
|
|
return dom::KeyboardEvent_Binding::DOM_VK_VOLUME_MUTE;
|
2016-05-20 18:52:03 +03:00
|
|
|
case KEY_NAME_INDEX_AudioVolumeDown:
|
2018-06-26 00:20:54 +03:00
|
|
|
return dom::KeyboardEvent_Binding::DOM_VK_VOLUME_DOWN;
|
2016-05-20 18:55:48 +03:00
|
|
|
case KEY_NAME_INDEX_AudioVolumeUp:
|
2018-06-26 00:20:54 +03:00
|
|
|
return dom::KeyboardEvent_Binding::DOM_VK_VOLUME_UP;
|
2015-02-19 09:50:19 +03:00
|
|
|
case KEY_NAME_INDEX_Meta:
|
2018-06-26 00:20:54 +03:00
|
|
|
return dom::KeyboardEvent_Binding::DOM_VK_META;
|
2015-02-19 09:50:19 +03:00
|
|
|
case KEY_NAME_INDEX_AltGraph:
|
2018-06-26 00:20:54 +03:00
|
|
|
return dom::KeyboardEvent_Binding::DOM_VK_ALTGR;
|
Bug 1446253 - Make EventUtils.synthesizeComposition() dispatch keydown and keyup event in default r=smaug
We'll start to dispatch keydown event and keyup event even during composition.
So, for testing those events won't break our UI, we should make
EventUtils.synhtesizeComposition() and EventUtils.synthesizeCompositionChange()
dispatch keydown event and keyup event even if callers don't specify keyboard
event explicitly.
Typically, "keydown" event is marked as "processed by IME", i.e., keyCode
value is set to DOM_VK_PROCESSKEY and key is set to "Process", with our
widget which handles native IME and key input. On the other hand, "keyup"
is NOT marked as so.
Therefore, this patch makes TextInputProcessor emulates this behavior without
any new special flags. And for making possible to emulate special cases,
this patch adds two flags to nsITextInputProcessor. One is
KEY_DONT_MARK_KEYDOWN_AS_PROCESSED. The other is KEY_MARK_KEYUP_AS_PROCESSED.
Unfortunately, those flags have opposite meaning but this must be better than
making necessary to one flag for emulating usual keydown/keyup events.
Finally, this makes some tests specify better keyboard information to
synthesizeComposition() and synthesizeCompositionChange() to emulate
actual keyboard events during composition.
MozReview-Commit-ID: ItYaXILkNQE
--HG--
extra : rebase_source : e50cc77c1efbc12686d7ea334d41926c7392b30d
2018-03-16 16:35:07 +03:00
|
|
|
case KEY_NAME_INDEX_Process:
|
2018-06-26 00:20:54 +03:00
|
|
|
return dom::KeyboardEvent_Binding::DOM_VK_PROCESSKEY;
|
2015-02-19 09:50:19 +03:00
|
|
|
case KEY_NAME_INDEX_Attn:
|
2018-06-26 00:20:54 +03:00
|
|
|
return dom::KeyboardEvent_Binding::DOM_VK_ATTN;
|
2015-02-19 09:50:19 +03:00
|
|
|
case KEY_NAME_INDEX_CrSel:
|
2018-06-26 00:20:54 +03:00
|
|
|
return dom::KeyboardEvent_Binding::DOM_VK_CRSEL;
|
2015-02-19 09:50:19 +03:00
|
|
|
case KEY_NAME_INDEX_ExSel:
|
2018-06-26 00:20:54 +03:00
|
|
|
return dom::KeyboardEvent_Binding::DOM_VK_EXSEL;
|
2015-02-19 09:50:19 +03:00
|
|
|
case KEY_NAME_INDEX_EraseEof:
|
2018-06-26 00:20:54 +03:00
|
|
|
return dom::KeyboardEvent_Binding::DOM_VK_EREOF;
|
2015-02-19 09:50:19 +03:00
|
|
|
case KEY_NAME_INDEX_Play:
|
2018-06-26 00:20:54 +03:00
|
|
|
return dom::KeyboardEvent_Binding::DOM_VK_PLAY;
|
2015-02-19 09:50:19 +03:00
|
|
|
case KEY_NAME_INDEX_ZoomToggle:
|
|
|
|
case KEY_NAME_INDEX_ZoomIn:
|
|
|
|
case KEY_NAME_INDEX_ZoomOut:
|
2018-06-26 00:20:54 +03:00
|
|
|
return dom::KeyboardEvent_Binding::DOM_VK_ZOOM;
|
2015-02-19 09:50:19 +03:00
|
|
|
default:
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-10-03 12:21:47 +03:00
|
|
|
/* static */ CodeNameIndex
|
|
|
|
WidgetKeyboardEvent::ComputeCodeNameIndexFromKeyNameIndex(
|
|
|
|
KeyNameIndex aKeyNameIndex, const Maybe<uint32_t>& aLocation) {
|
|
|
|
if (aLocation.isSome() &&
|
|
|
|
aLocation.value() ==
|
|
|
|
dom::KeyboardEvent_Binding::DOM_KEY_LOCATION_NUMPAD) {
|
|
|
|
// On macOS, NumLock is not supported. Therefore, this handles
|
|
|
|
// control key values except "Enter" only on non-macOS platforms.
|
|
|
|
switch (aKeyNameIndex) {
|
|
|
|
#ifndef XP_MACOSX
|
|
|
|
case KEY_NAME_INDEX_Insert:
|
|
|
|
return CODE_NAME_INDEX_Numpad0;
|
|
|
|
case KEY_NAME_INDEX_End:
|
|
|
|
return CODE_NAME_INDEX_Numpad1;
|
|
|
|
case KEY_NAME_INDEX_ArrowDown:
|
|
|
|
return CODE_NAME_INDEX_Numpad2;
|
|
|
|
case KEY_NAME_INDEX_PageDown:
|
|
|
|
return CODE_NAME_INDEX_Numpad3;
|
|
|
|
case KEY_NAME_INDEX_ArrowLeft:
|
|
|
|
return CODE_NAME_INDEX_Numpad4;
|
|
|
|
case KEY_NAME_INDEX_Clear:
|
|
|
|
// FYI: "Clear" on macOS should be DOM_KEY_LOCATION_STANDARD.
|
|
|
|
return CODE_NAME_INDEX_Numpad5;
|
|
|
|
case KEY_NAME_INDEX_ArrowRight:
|
|
|
|
return CODE_NAME_INDEX_Numpad6;
|
|
|
|
case KEY_NAME_INDEX_Home:
|
|
|
|
return CODE_NAME_INDEX_Numpad7;
|
|
|
|
case KEY_NAME_INDEX_ArrowUp:
|
|
|
|
return CODE_NAME_INDEX_Numpad8;
|
|
|
|
case KEY_NAME_INDEX_PageUp:
|
|
|
|
return CODE_NAME_INDEX_Numpad9;
|
|
|
|
case KEY_NAME_INDEX_Delete:
|
|
|
|
return CODE_NAME_INDEX_NumpadDecimal;
|
|
|
|
#endif // #ifndef XP_MACOSX
|
|
|
|
case KEY_NAME_INDEX_Enter:
|
|
|
|
return CODE_NAME_INDEX_NumpadEnter;
|
|
|
|
default:
|
|
|
|
return CODE_NAME_INDEX_UNKNOWN;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (WidgetKeyboardEvent::IsLeftOrRightModiferKeyNameIndex(aKeyNameIndex)) {
|
|
|
|
if (aLocation.isSome() &&
|
|
|
|
(aLocation.value() !=
|
|
|
|
dom::KeyboardEvent_Binding::DOM_KEY_LOCATION_LEFT &&
|
|
|
|
aLocation.value() !=
|
|
|
|
dom::KeyboardEvent_Binding::DOM_KEY_LOCATION_RIGHT)) {
|
|
|
|
return CODE_NAME_INDEX_UNKNOWN;
|
|
|
|
}
|
|
|
|
bool isRight =
|
|
|
|
aLocation.isSome() &&
|
|
|
|
aLocation.value() == dom::KeyboardEvent_Binding::DOM_KEY_LOCATION_RIGHT;
|
|
|
|
switch (aKeyNameIndex) {
|
|
|
|
case KEY_NAME_INDEX_Alt:
|
|
|
|
return isRight ? CODE_NAME_INDEX_AltRight : CODE_NAME_INDEX_AltLeft;
|
|
|
|
case KEY_NAME_INDEX_Control:
|
|
|
|
return isRight ? CODE_NAME_INDEX_ControlRight
|
|
|
|
: CODE_NAME_INDEX_ControlLeft;
|
|
|
|
case KEY_NAME_INDEX_Shift:
|
|
|
|
return isRight ? CODE_NAME_INDEX_ShiftRight : CODE_NAME_INDEX_ShiftLeft;
|
|
|
|
#if defined(XP_WIN)
|
|
|
|
case KEY_NAME_INDEX_Meta:
|
|
|
|
return CODE_NAME_INDEX_UNKNOWN;
|
|
|
|
case KEY_NAME_INDEX_OS: // win key.
|
|
|
|
return isRight ? CODE_NAME_INDEX_OSRight : CODE_NAME_INDEX_OSLeft;
|
|
|
|
#elif defined(XP_MACOSX) || defined(ANDROID)
|
|
|
|
case KEY_NAME_INDEX_Meta: // command key.
|
|
|
|
return isRight ? CODE_NAME_INDEX_OSRight : CODE_NAME_INDEX_OSLeft;
|
|
|
|
case KEY_NAME_INDEX_OS:
|
|
|
|
return CODE_NAME_INDEX_UNKNOWN;
|
|
|
|
#else
|
|
|
|
case KEY_NAME_INDEX_Meta: // Alt + Shift.
|
|
|
|
return isRight ? CODE_NAME_INDEX_AltRight : CODE_NAME_INDEX_AltLeft;
|
|
|
|
case KEY_NAME_INDEX_OS: // Super/Hyper key.
|
|
|
|
return isRight ? CODE_NAME_INDEX_OSRight : CODE_NAME_INDEX_OSLeft;
|
|
|
|
#endif
|
|
|
|
default:
|
|
|
|
return CODE_NAME_INDEX_UNKNOWN;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (aLocation.isSome() &&
|
|
|
|
aLocation.value() !=
|
|
|
|
dom::KeyboardEvent_Binding::DOM_KEY_LOCATION_STANDARD) {
|
|
|
|
return CODE_NAME_INDEX_UNKNOWN;
|
|
|
|
}
|
|
|
|
|
|
|
|
switch (aKeyNameIndex) {
|
|
|
|
// Standard section:
|
|
|
|
case KEY_NAME_INDEX_Escape:
|
|
|
|
return CODE_NAME_INDEX_Escape;
|
|
|
|
case KEY_NAME_INDEX_Tab:
|
|
|
|
return CODE_NAME_INDEX_Tab;
|
|
|
|
case KEY_NAME_INDEX_CapsLock:
|
|
|
|
return CODE_NAME_INDEX_CapsLock;
|
|
|
|
case KEY_NAME_INDEX_ContextMenu:
|
|
|
|
return CODE_NAME_INDEX_ContextMenu;
|
|
|
|
case KEY_NAME_INDEX_Backspace:
|
|
|
|
return CODE_NAME_INDEX_Backspace;
|
|
|
|
case KEY_NAME_INDEX_Enter:
|
|
|
|
return CODE_NAME_INDEX_Enter;
|
|
|
|
#ifdef XP_MACOSX
|
|
|
|
// Although, macOS does not fire native key event of "Fn" key, we support
|
|
|
|
// Fn key event if it's sent by other apps directly.
|
|
|
|
case KEY_NAME_INDEX_Fn:
|
|
|
|
return CODE_NAME_INDEX_Fn;
|
|
|
|
#endif // #ifdef
|
|
|
|
|
|
|
|
// Arrow Pad section:
|
|
|
|
case KEY_NAME_INDEX_ArrowLeft:
|
|
|
|
return CODE_NAME_INDEX_ArrowLeft;
|
|
|
|
case KEY_NAME_INDEX_ArrowUp:
|
|
|
|
return CODE_NAME_INDEX_ArrowUp;
|
|
|
|
case KEY_NAME_INDEX_ArrowDown:
|
|
|
|
return CODE_NAME_INDEX_ArrowDown;
|
|
|
|
case KEY_NAME_INDEX_ArrowRight:
|
|
|
|
return CODE_NAME_INDEX_ArrowRight;
|
|
|
|
|
|
|
|
// Control Pad section:
|
|
|
|
#ifndef XP_MACOSX
|
|
|
|
case KEY_NAME_INDEX_Insert:
|
|
|
|
return CODE_NAME_INDEX_Insert;
|
|
|
|
#else
|
|
|
|
case KEY_NAME_INDEX_Help:
|
|
|
|
return CODE_NAME_INDEX_Help;
|
|
|
|
#endif // #ifndef XP_MACOSX #else
|
|
|
|
case KEY_NAME_INDEX_Delete:
|
|
|
|
return CODE_NAME_INDEX_Delete;
|
|
|
|
case KEY_NAME_INDEX_Home:
|
|
|
|
return CODE_NAME_INDEX_Home;
|
|
|
|
case KEY_NAME_INDEX_End:
|
|
|
|
return CODE_NAME_INDEX_End;
|
|
|
|
case KEY_NAME_INDEX_PageUp:
|
|
|
|
return CODE_NAME_INDEX_PageUp;
|
|
|
|
case KEY_NAME_INDEX_PageDown:
|
|
|
|
return CODE_NAME_INDEX_PageDown;
|
|
|
|
|
|
|
|
// Function keys:
|
|
|
|
case KEY_NAME_INDEX_F1:
|
|
|
|
return CODE_NAME_INDEX_F1;
|
|
|
|
case KEY_NAME_INDEX_F2:
|
|
|
|
return CODE_NAME_INDEX_F2;
|
|
|
|
case KEY_NAME_INDEX_F3:
|
|
|
|
return CODE_NAME_INDEX_F3;
|
|
|
|
case KEY_NAME_INDEX_F4:
|
|
|
|
return CODE_NAME_INDEX_F4;
|
|
|
|
case KEY_NAME_INDEX_F5:
|
|
|
|
return CODE_NAME_INDEX_F5;
|
|
|
|
case KEY_NAME_INDEX_F6:
|
|
|
|
return CODE_NAME_INDEX_F6;
|
|
|
|
case KEY_NAME_INDEX_F7:
|
|
|
|
return CODE_NAME_INDEX_F7;
|
|
|
|
case KEY_NAME_INDEX_F8:
|
|
|
|
return CODE_NAME_INDEX_F8;
|
|
|
|
case KEY_NAME_INDEX_F9:
|
|
|
|
return CODE_NAME_INDEX_F9;
|
|
|
|
case KEY_NAME_INDEX_F10:
|
|
|
|
return CODE_NAME_INDEX_F10;
|
|
|
|
case KEY_NAME_INDEX_F11:
|
|
|
|
return CODE_NAME_INDEX_F11;
|
|
|
|
case KEY_NAME_INDEX_F12:
|
|
|
|
return CODE_NAME_INDEX_F12;
|
|
|
|
case KEY_NAME_INDEX_F13:
|
|
|
|
return CODE_NAME_INDEX_F13;
|
|
|
|
case KEY_NAME_INDEX_F14:
|
|
|
|
return CODE_NAME_INDEX_F14;
|
|
|
|
case KEY_NAME_INDEX_F15:
|
|
|
|
return CODE_NAME_INDEX_F15;
|
|
|
|
case KEY_NAME_INDEX_F16:
|
|
|
|
return CODE_NAME_INDEX_F16;
|
|
|
|
case KEY_NAME_INDEX_F17:
|
|
|
|
return CODE_NAME_INDEX_F17;
|
|
|
|
case KEY_NAME_INDEX_F18:
|
|
|
|
return CODE_NAME_INDEX_F18;
|
|
|
|
case KEY_NAME_INDEX_F19:
|
|
|
|
return CODE_NAME_INDEX_F19;
|
|
|
|
case KEY_NAME_INDEX_F20:
|
|
|
|
return CODE_NAME_INDEX_F20;
|
|
|
|
#ifndef XP_MACOSX
|
|
|
|
case KEY_NAME_INDEX_F21:
|
|
|
|
return CODE_NAME_INDEX_F21;
|
|
|
|
case KEY_NAME_INDEX_F22:
|
|
|
|
return CODE_NAME_INDEX_F22;
|
|
|
|
case KEY_NAME_INDEX_F23:
|
|
|
|
return CODE_NAME_INDEX_F23;
|
|
|
|
case KEY_NAME_INDEX_F24:
|
|
|
|
return CODE_NAME_INDEX_F24;
|
|
|
|
case KEY_NAME_INDEX_Pause:
|
|
|
|
return CODE_NAME_INDEX_Pause;
|
|
|
|
case KEY_NAME_INDEX_PrintScreen:
|
|
|
|
return CODE_NAME_INDEX_PrintScreen;
|
|
|
|
case KEY_NAME_INDEX_ScrollLock:
|
|
|
|
return CODE_NAME_INDEX_ScrollLock;
|
|
|
|
#endif // #ifndef XP_MACOSX
|
|
|
|
|
|
|
|
// NumLock key:
|
|
|
|
#ifndef XP_MACOSX
|
|
|
|
case KEY_NAME_INDEX_NumLock:
|
|
|
|
return CODE_NAME_INDEX_NumLock;
|
|
|
|
#else
|
|
|
|
case KEY_NAME_INDEX_Clear:
|
|
|
|
return CODE_NAME_INDEX_NumLock;
|
|
|
|
#endif // #ifndef XP_MACOSX #else
|
|
|
|
|
|
|
|
// Media keys:
|
|
|
|
case KEY_NAME_INDEX_AudioVolumeDown:
|
|
|
|
return CODE_NAME_INDEX_VolumeDown;
|
|
|
|
case KEY_NAME_INDEX_AudioVolumeMute:
|
|
|
|
return CODE_NAME_INDEX_VolumeMute;
|
|
|
|
case KEY_NAME_INDEX_AudioVolumeUp:
|
|
|
|
return CODE_NAME_INDEX_VolumeUp;
|
|
|
|
#ifndef XP_MACOSX
|
|
|
|
case KEY_NAME_INDEX_BrowserBack:
|
|
|
|
return CODE_NAME_INDEX_BrowserBack;
|
|
|
|
case KEY_NAME_INDEX_BrowserFavorites:
|
|
|
|
return CODE_NAME_INDEX_BrowserFavorites;
|
|
|
|
case KEY_NAME_INDEX_BrowserForward:
|
|
|
|
return CODE_NAME_INDEX_BrowserForward;
|
|
|
|
case KEY_NAME_INDEX_BrowserRefresh:
|
|
|
|
return CODE_NAME_INDEX_BrowserRefresh;
|
|
|
|
case KEY_NAME_INDEX_BrowserSearch:
|
|
|
|
return CODE_NAME_INDEX_BrowserSearch;
|
|
|
|
case KEY_NAME_INDEX_BrowserStop:
|
|
|
|
return CODE_NAME_INDEX_BrowserStop;
|
|
|
|
case KEY_NAME_INDEX_MediaPlayPause:
|
|
|
|
return CODE_NAME_INDEX_MediaPlayPause;
|
|
|
|
case KEY_NAME_INDEX_MediaStop:
|
|
|
|
return CODE_NAME_INDEX_MediaStop;
|
|
|
|
case KEY_NAME_INDEX_MediaTrackNext:
|
|
|
|
return CODE_NAME_INDEX_MediaTrackNext;
|
|
|
|
case KEY_NAME_INDEX_MediaTrackPrevious:
|
|
|
|
return CODE_NAME_INDEX_MediaTrackPrevious;
|
|
|
|
case KEY_NAME_INDEX_LaunchApplication1:
|
|
|
|
return CODE_NAME_INDEX_LaunchApp1;
|
|
|
|
#endif // #ifndef XP_MACOSX
|
|
|
|
|
|
|
|
// Only Windows and GTK supports the following multimedia keys.
|
|
|
|
#if defined(XP_WIN) || defined(MOZ_WIDGET_GTK)
|
|
|
|
case KEY_NAME_INDEX_BrowserHome:
|
|
|
|
return CODE_NAME_INDEX_BrowserHome;
|
|
|
|
case KEY_NAME_INDEX_LaunchApplication2:
|
|
|
|
return CODE_NAME_INDEX_LaunchApp2;
|
|
|
|
#endif // #if defined(XP_WIN) || defined(MOZ_WIDGET_GTK)
|
|
|
|
|
|
|
|
// Only GTK and Android supports the following multimedia keys.
|
|
|
|
#if defined(MOZ_WIDGET_GTK) || defined(ANDROID)
|
|
|
|
case KEY_NAME_INDEX_Eject:
|
|
|
|
return CODE_NAME_INDEX_Eject;
|
|
|
|
case KEY_NAME_INDEX_WakeUp:
|
|
|
|
return CODE_NAME_INDEX_WakeUp;
|
|
|
|
#endif // #if defined(MOZ_WIDGET_GTK) || defined(ANDROID)
|
|
|
|
|
|
|
|
// Only Windows does not support Help key (and macOS handled above).
|
|
|
|
#if !defined(XP_WIN) && !defined(XP_MACOSX)
|
|
|
|
case KEY_NAME_INDEX_Help:
|
|
|
|
return CODE_NAME_INDEX_Help;
|
|
|
|
#endif // #if !defined(XP_WIN) && !defined(XP_MACOSX)
|
|
|
|
|
|
|
|
// IME specific keys:
|
|
|
|
#ifdef XP_WIN
|
|
|
|
case KEY_NAME_INDEX_Convert:
|
|
|
|
return CODE_NAME_INDEX_Convert;
|
|
|
|
case KEY_NAME_INDEX_NonConvert:
|
|
|
|
return CODE_NAME_INDEX_NonConvert;
|
|
|
|
case KEY_NAME_INDEX_Alphanumeric:
|
|
|
|
return CODE_NAME_INDEX_CapsLock;
|
|
|
|
case KEY_NAME_INDEX_KanaMode:
|
|
|
|
case KEY_NAME_INDEX_Romaji:
|
|
|
|
case KEY_NAME_INDEX_Katakana:
|
|
|
|
case KEY_NAME_INDEX_Hiragana:
|
|
|
|
return CODE_NAME_INDEX_KanaMode;
|
|
|
|
case KEY_NAME_INDEX_Hankaku:
|
|
|
|
case KEY_NAME_INDEX_Zenkaku:
|
|
|
|
case KEY_NAME_INDEX_KanjiMode:
|
|
|
|
return CODE_NAME_INDEX_Backquote;
|
|
|
|
case KEY_NAME_INDEX_HanjaMode:
|
|
|
|
return CODE_NAME_INDEX_Lang2;
|
|
|
|
case KEY_NAME_INDEX_HangulMode:
|
|
|
|
return CODE_NAME_INDEX_Lang1;
|
|
|
|
#endif // #ifdef XP_WIN
|
|
|
|
|
|
|
|
#ifdef MOZ_WIDGET_GTK
|
|
|
|
case KEY_NAME_INDEX_Convert:
|
|
|
|
return CODE_NAME_INDEX_Convert;
|
|
|
|
case KEY_NAME_INDEX_NonConvert:
|
|
|
|
return CODE_NAME_INDEX_NonConvert;
|
|
|
|
case KEY_NAME_INDEX_Alphanumeric:
|
|
|
|
return CODE_NAME_INDEX_CapsLock;
|
|
|
|
case KEY_NAME_INDEX_HiraganaKatakana:
|
|
|
|
return CODE_NAME_INDEX_KanaMode;
|
|
|
|
case KEY_NAME_INDEX_ZenkakuHankaku:
|
|
|
|
return CODE_NAME_INDEX_Backquote;
|
|
|
|
#endif // #ifdef MOZ_WIDGET_GTK
|
|
|
|
|
|
|
|
#ifdef ANDROID
|
|
|
|
case KEY_NAME_INDEX_Convert:
|
|
|
|
return CODE_NAME_INDEX_Convert;
|
|
|
|
case KEY_NAME_INDEX_NonConvert:
|
|
|
|
return CODE_NAME_INDEX_NonConvert;
|
|
|
|
case KEY_NAME_INDEX_HiraganaKatakana:
|
|
|
|
return CODE_NAME_INDEX_KanaMode;
|
|
|
|
case KEY_NAME_INDEX_ZenkakuHankaku:
|
|
|
|
return CODE_NAME_INDEX_Backquote;
|
|
|
|
case KEY_NAME_INDEX_Eisu:
|
|
|
|
return CODE_NAME_INDEX_Lang2;
|
|
|
|
case KEY_NAME_INDEX_KanjiMode:
|
|
|
|
return CODE_NAME_INDEX_Lang1;
|
|
|
|
#endif // #ifdef ANDROID
|
|
|
|
|
|
|
|
#ifdef XP_MACOSX
|
|
|
|
case KEY_NAME_INDEX_Eisu:
|
|
|
|
return CODE_NAME_INDEX_Lang2;
|
|
|
|
case KEY_NAME_INDEX_KanjiMode:
|
|
|
|
return CODE_NAME_INDEX_Lang1;
|
|
|
|
#endif // #ifdef XP_MACOSX
|
|
|
|
|
|
|
|
default:
|
|
|
|
return CODE_NAME_INDEX_UNKNOWN;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-02-19 09:50:19 +03:00
|
|
|
/* static */ Modifier WidgetKeyboardEvent::GetModifierForKeyName(
|
|
|
|
KeyNameIndex aKeyNameIndex) {
|
|
|
|
switch (aKeyNameIndex) {
|
|
|
|
case KEY_NAME_INDEX_Alt:
|
|
|
|
return MODIFIER_ALT;
|
|
|
|
case KEY_NAME_INDEX_AltGraph:
|
|
|
|
return MODIFIER_ALTGRAPH;
|
|
|
|
case KEY_NAME_INDEX_CapsLock:
|
|
|
|
return MODIFIER_CAPSLOCK;
|
|
|
|
case KEY_NAME_INDEX_Control:
|
|
|
|
return MODIFIER_CONTROL;
|
|
|
|
case KEY_NAME_INDEX_Fn:
|
|
|
|
return MODIFIER_FN;
|
|
|
|
case KEY_NAME_INDEX_FnLock:
|
|
|
|
return MODIFIER_FNLOCK;
|
|
|
|
// case KEY_NAME_INDEX_Hyper:
|
|
|
|
case KEY_NAME_INDEX_Meta:
|
|
|
|
return MODIFIER_META;
|
|
|
|
case KEY_NAME_INDEX_NumLock:
|
|
|
|
return MODIFIER_NUMLOCK;
|
|
|
|
case KEY_NAME_INDEX_OS:
|
|
|
|
return MODIFIER_OS;
|
|
|
|
case KEY_NAME_INDEX_ScrollLock:
|
|
|
|
return MODIFIER_SCROLLLOCK;
|
|
|
|
case KEY_NAME_INDEX_Shift:
|
|
|
|
return MODIFIER_SHIFT;
|
|
|
|
// case KEY_NAME_INDEX_Super:
|
|
|
|
case KEY_NAME_INDEX_Symbol:
|
|
|
|
return MODIFIER_SYMBOL;
|
|
|
|
case KEY_NAME_INDEX_SymbolLock:
|
|
|
|
return MODIFIER_SYMBOLLOCK;
|
|
|
|
default:
|
|
|
|
return MODIFIER_NONE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* static */ bool WidgetKeyboardEvent::IsLockableModifier(
|
|
|
|
KeyNameIndex aKeyNameIndex) {
|
|
|
|
switch (aKeyNameIndex) {
|
|
|
|
case KEY_NAME_INDEX_CapsLock:
|
|
|
|
case KEY_NAME_INDEX_FnLock:
|
|
|
|
case KEY_NAME_INDEX_NumLock:
|
|
|
|
case KEY_NAME_INDEX_ScrollLock:
|
|
|
|
case KEY_NAME_INDEX_SymbolLock:
|
|
|
|
return true;
|
|
|
|
default:
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-09-24 14:04:16 +04:00
|
|
|
} // namespace mozilla
|