mirror of
https://github.com/roytam1/palemoon27.git
synced 2026-05-26 14:18:48 +00:00
c975675694
- Bug 1198459 - Update telemetry data based on the use of the forced enable pref. r=felipe (f33f0efc9a) - Bug 1234210 - Restrict updates for accessibility.lastLoadDate to shutdown. r=trevor (5e484eb7ba) - Bug 1231517 - part 3, Add ZoomToRect function to nsIWidget classes r=kats (57496a18cd) - Bug 1229393 - Ensure that all the touch points from the original touch go to APZCCallbackHelper::SendSetTargetAPZCNotification. r=botond (45ce1737ac) - Bug 1174323 part 1 - Add nsDOMWindowUtils::SendNativeMouseMove and EventUtils.sendNativeMouseMove. r=smaug (527439f71b) - Bug 1180351 - Enable pointerlock tests on Windows and Linux. r=smaug (833fac9ba9) - Bug 1180351 - Followup: Disable pointerlock tests on Windows for frequently failing tests. r=turning off tests (02525d24f4) - Bug 1174323 part 2 - Use native mouse move to improve robustness of screenClientXYConst subtest. r=smaug (7e3fb884d3) - Bug 1231517 - part 4, Add ZoomToFocusedInput function to nsDOMWindowUtils r=kats (a1f3e3b4fd) - Bug 1153156 part.1 Move nsBaseWidget::OverrideSystemMouseScrollSpeed() to WidgetWheelEvent r=smaug, sr=smaug (8a95d65d55) - bug 726265 don't activate ELAN swipe hack unless ScanCode is zero r=heycam (477a5ce06a) - Bug 1235686 part.1 MouseScrollHandler should refresh the cache of system settings at handling wheel messages if the pref doesn't allow to cache system settings r=jimm (6cae8d2b07) - Bug 1235686 part.2 Don't refresh the cache of system settings at handling wheel messages if the scroll amout values are initialized with prefs r=jimm (ead872b6bf) - Bug 1235686 part.3 Don't trust system settings cache if SynTP of Synaptics is installed r=jimm (d56a034a42) - Bug 1235686 part.4 Don't trust system settings cache if Apoint of Alps is installed r=jimm (85cb23e185) - Bug 1153156 part.2 Make WidgetWheelEvent store if overriding system scroll speed is allowed and it shouldn't be allowed if scroll speed isn't system default settings on Windows r=smaug+jimm (3d5fc255db) - Bug 1153156 part.3 Don't allow to override system scroll speed if the wheel event causes too fast scroll r=smaug+jimm (21e10640ac) - Bug 1236750 - Rename ViewTransform to AsyncTransform. r=kats (1ccd8af262) - Bug 1226826 - Record if painted displayport updates were due to repaints from the relevant layer tree or not. r=botond (e28315ec88) - Bug 1228641. Add a initializer_list constructor to nsTArray. r=froydnj (448f69f610) - Bug 962243 - Gtest for being able to pan after lifting a finger from a pinch. r=botond (a1687f190c) - Bug 1031443 - Allow panning in the pinching state even if zooming is disabled;r=botond (aacb1a28bd) - Bug 1231504 - Move some prefs from b2g.js to all.js. r=botond (c9801602ba) - Bug 1092128 - Ensure the tests for touch action disabled actually disable touch action. r=botond (ec3fae4568) - Bug 1014691 - Get TestAsyncPanZoomController to compile in its new location. r=kats (9dd104c6fd) - Bug 1240244 - Split APZ gtests into several files. r=kats (0ce8bd4f80) - Bug 1235994 - Add a flag to wheel events to track if they may have momentum following them. r=mstange (d5b2099244) - Bug 1153156 part.4 Make APZC system scroll speed overriding aware r=mstange (f9d49eb79c) - Bug 1233118 - implement IAccessible2_3::selectionRanges, r=yzen (d85fe6cf64) - bug 1235965 - null check mDoc in AccessibleWrap::Shutdown() r=davidb (cb775e5c00) - Bug 1130096 - Convert embedding/components/find/ to Gecko style. r=mccr8 (83d043e841) - Bug 1164473 - Resolve issue when touches stop working after pen was activated. r=jimm (16ce68b032) - Bug 1171712 - Implement separated InkColletor and InkCollectorEvent classes. r=smaug, r=jimm (8000e742b8) - bug 1198656 interpret null ConvolverNode mBuffer as a buffer of zerosr=padenot (339e1f9904) - bug 930257 finish Oscillator on processing last non-null block r=padenot (2719eee12b) - Bug 1240411: P1. Clean up webaudio headers. r=cpearce (f169dc2789) - Bug 1219711 - Don't rely on timer interval in fake audio track. r=jesup (f140fd848a) - Bug 1223655 - Only check for track end if track exists in MediaEngineDefaultAudioSource. r=jesup (3055b4529f) - Bug 1223655 - Also don't check time of data end if track has ended. r=jesup (bbdf7c5be5) - Bug 1223655 - Fix opt build bustage on a CLOSED TREE. r=bustage (d546f4ba0b) - Bug 1164463 followup: Add missing 'override' keyword to MediaEngineDefault::Shutdown(). rs=ehsan (33bf959d84) - Bug 1240411: P2. Clean up webrtc headers. r=jesup (73c2bdf22d) - Bug 1240411: P4. Clean up readers headers. r=cpearce (748d2bf9e8) - Bug 1232527 - Remove GMPVideoDecoderTrialCreator and friends. r=jwwang (e0decf270f) - Bug 1240411: P5. Clean up GMP headers. r=cpearce (0336b7fd9c) - Bug 1240252: Add missing "mozilla::" namespace prefix before usage of type LayoutDeviceIntRegion, to fix local build bustage. r=njn (54d5a4a553) - Bug 1245241 - part 1 - Close Shmem file handles after mapping them when possible to reduce exhaustion issues. r=billm (631c2b6da5)
810 lines
23 KiB
C++
810 lines
23 KiB
C++
/* -*- 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/. */
|
|
|
|
#include "mozilla/BasicEvents.h"
|
|
#include "mozilla/ContentEvents.h"
|
|
#include "mozilla/InternalMutationEvent.h"
|
|
#include "mozilla/MiscEvents.h"
|
|
#include "mozilla/MouseEvents.h"
|
|
#include "mozilla/Preferences.h"
|
|
#include "mozilla/TextEvents.h"
|
|
#include "mozilla/TouchEvents.h"
|
|
|
|
namespace mozilla {
|
|
|
|
/******************************************************************************
|
|
* 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";
|
|
}
|
|
}
|
|
|
|
/******************************************************************************
|
|
* 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
|
|
|
|
/******************************************************************************
|
|
* mozilla::WidgetEvent
|
|
*
|
|
* Event struct type checking methods.
|
|
******************************************************************************/
|
|
|
|
bool
|
|
WidgetEvent::IsQueryContentEvent() const
|
|
{
|
|
return mClass == eQueryContentEventClass;
|
|
}
|
|
|
|
bool
|
|
WidgetEvent::IsSelectionEvent() const
|
|
{
|
|
return mClass == eSelectionEventClass;
|
|
}
|
|
|
|
bool
|
|
WidgetEvent::IsContentCommandEvent() const
|
|
{
|
|
return mClass == eContentCommandEventClass;
|
|
}
|
|
|
|
bool
|
|
WidgetEvent::IsNativeEventDelivererForPlugin() const
|
|
{
|
|
return mClass == ePluginEventClass;
|
|
}
|
|
|
|
|
|
/******************************************************************************
|
|
* mozilla::WidgetEvent
|
|
*
|
|
* Event message checking methods.
|
|
******************************************************************************/
|
|
|
|
bool
|
|
WidgetEvent::HasMouseEventMessage() const
|
|
{
|
|
switch (mMessage) {
|
|
case eMouseDown:
|
|
case eMouseUp:
|
|
case eMouseClick:
|
|
case eMouseDoubleClick:
|
|
case eMouseEnterIntoWidget:
|
|
case eMouseExitFromWidget:
|
|
case eMouseActivate:
|
|
case eMouseOver:
|
|
case eMouseOut:
|
|
case eMouseHitTest:
|
|
case eMouseMove:
|
|
return true;
|
|
default:
|
|
return false;
|
|
}
|
|
}
|
|
|
|
bool
|
|
WidgetEvent::HasDragEventMessage() const
|
|
{
|
|
switch (mMessage) {
|
|
case eDragEnter:
|
|
case eDragOver:
|
|
case eDragExit:
|
|
case eLegacyDragDrop:
|
|
case eLegacyDragGesture:
|
|
case eDrag:
|
|
case eDragEnd:
|
|
case eDragStart:
|
|
case eDrop:
|
|
case eDragLeave:
|
|
return true;
|
|
default:
|
|
return false;
|
|
}
|
|
}
|
|
|
|
bool
|
|
WidgetEvent::HasKeyEventMessage() const
|
|
{
|
|
switch (mMessage) {
|
|
case eKeyDown:
|
|
case eKeyPress:
|
|
case eKeyUp:
|
|
case eBeforeKeyDown:
|
|
case eBeforeKeyUp:
|
|
case eAfterKeyDown:
|
|
case eAfterKeyUp:
|
|
return true;
|
|
default:
|
|
return false;
|
|
}
|
|
}
|
|
|
|
bool
|
|
WidgetEvent::HasIMEEventMessage() const
|
|
{
|
|
switch (mMessage) {
|
|
case eCompositionStart:
|
|
case eCompositionEnd:
|
|
case eCompositionUpdate:
|
|
case eCompositionChange:
|
|
case eCompositionCommitAsIs:
|
|
case eCompositionCommit:
|
|
return true;
|
|
default:
|
|
return false;
|
|
}
|
|
}
|
|
|
|
bool
|
|
WidgetEvent::HasPluginActivationEventMessage() const
|
|
{
|
|
return mMessage == ePluginActivate ||
|
|
mMessage == ePluginFocus;
|
|
}
|
|
|
|
/******************************************************************************
|
|
* mozilla::WidgetEvent
|
|
*
|
|
* Specific event checking methods.
|
|
******************************************************************************/
|
|
|
|
bool
|
|
WidgetEvent::IsRetargetedNativeEventDelivererForPlugin() const
|
|
{
|
|
const WidgetPluginEvent* pluginEvent = AsPluginEvent();
|
|
return pluginEvent && pluginEvent->retargetToFocusedDocument;
|
|
}
|
|
|
|
bool
|
|
WidgetEvent::IsNonRetargetedNativeEventDelivererForPlugin() const
|
|
{
|
|
const WidgetPluginEvent* pluginEvent = AsPluginEvent();
|
|
return pluginEvent && !pluginEvent->retargetToFocusedDocument;
|
|
}
|
|
|
|
bool
|
|
WidgetEvent::IsIMERelatedEvent() const
|
|
{
|
|
return HasIMEEventMessage() || IsQueryContentEvent() || IsSelectionEvent();
|
|
}
|
|
|
|
bool
|
|
WidgetEvent::IsUsingCoordinates() const
|
|
{
|
|
const WidgetMouseEvent* mouseEvent = AsMouseEvent();
|
|
if (mouseEvent) {
|
|
return !mouseEvent->IsContextMenuKeyEvent();
|
|
}
|
|
return !HasKeyEventMessage() && !IsIMERelatedEvent() &&
|
|
!HasPluginActivationEventMessage() &&
|
|
!IsNativeEventDelivererForPlugin() &&
|
|
!IsContentCommandEvent();
|
|
}
|
|
|
|
bool
|
|
WidgetEvent::IsTargetedAtFocusedWindow() const
|
|
{
|
|
const WidgetMouseEvent* mouseEvent = AsMouseEvent();
|
|
if (mouseEvent) {
|
|
return mouseEvent->IsContextMenuKeyEvent();
|
|
}
|
|
return HasKeyEventMessage() || IsIMERelatedEvent() ||
|
|
IsContentCommandEvent() ||
|
|
IsRetargetedNativeEventDelivererForPlugin();
|
|
}
|
|
|
|
bool
|
|
WidgetEvent::IsTargetedAtFocusedContent() const
|
|
{
|
|
const WidgetMouseEvent* mouseEvent = AsMouseEvent();
|
|
if (mouseEvent) {
|
|
return mouseEvent->IsContextMenuKeyEvent();
|
|
}
|
|
return HasKeyEventMessage() || IsIMERelatedEvent() ||
|
|
IsRetargetedNativeEventDelivererForPlugin();
|
|
}
|
|
|
|
bool
|
|
WidgetEvent::IsAllowedToDispatchDOMEvent() const
|
|
{
|
|
switch (mClass) {
|
|
case eMouseEventClass:
|
|
case ePointerEventClass:
|
|
// We want synthesized mouse moves to cause mouseover and mouseout
|
|
// DOM events (EventStateManager::PreHandleEvent), but not mousemove
|
|
// DOM events.
|
|
// Synthesized button up events also do not cause DOM events because they
|
|
// do not have a reliable refPoint.
|
|
return AsMouseEvent()->reason == WidgetMouseEvent::eReal;
|
|
|
|
case eWheelEventClass: {
|
|
// wheel event whose all delta values are zero by user pref applied, it
|
|
// shouldn't cause a DOM event.
|
|
const WidgetWheelEvent* wheelEvent = AsWheelEvent();
|
|
return wheelEvent->deltaX != 0.0 || wheelEvent->deltaY != 0.0 ||
|
|
wheelEvent->deltaZ != 0.0;
|
|
}
|
|
|
|
// Following events are handled in EventStateManager, so, we don't need to
|
|
// dispatch DOM event for them into the DOM tree.
|
|
case eQueryContentEventClass:
|
|
case eSelectionEventClass:
|
|
case eContentCommandEventClass:
|
|
return false;
|
|
|
|
default:
|
|
return true;
|
|
}
|
|
}
|
|
|
|
/******************************************************************************
|
|
* mozilla::WidgetInputEvent
|
|
******************************************************************************/
|
|
|
|
/* static */
|
|
Modifier
|
|
WidgetInputEvent::GetModifier(const nsAString& aDOMKeyName)
|
|
{
|
|
if (aDOMKeyName.EqualsLiteral("Accel")) {
|
|
return AccelModifier();
|
|
}
|
|
KeyNameIndex keyNameIndex = WidgetKeyboardEvent::GetKeyNameIndex(aDOMKeyName);
|
|
return WidgetKeyboardEvent::GetModifierForKeyName(keyNameIndex);
|
|
}
|
|
|
|
/* static */
|
|
Modifier
|
|
WidgetInputEvent::AccelModifier()
|
|
{
|
|
static Modifier sAccelModifier = MODIFIER_NONE;
|
|
if (sAccelModifier == MODIFIER_NONE) {
|
|
switch (Preferences::GetInt("ui.key.accelKey", 0)) {
|
|
case nsIDOMKeyEvent::DOM_VK_META:
|
|
sAccelModifier = MODIFIER_META;
|
|
break;
|
|
case nsIDOMKeyEvent::DOM_VK_WIN:
|
|
sAccelModifier = MODIFIER_OS;
|
|
break;
|
|
case nsIDOMKeyEvent::DOM_VK_ALT:
|
|
sAccelModifier = MODIFIER_ALT;
|
|
break;
|
|
case nsIDOMKeyEvent::DOM_VK_CONTROL:
|
|
sAccelModifier = MODIFIER_CONTROL;
|
|
break;
|
|
default:
|
|
#ifdef XP_MACOSX
|
|
sAccelModifier = MODIFIER_META;
|
|
#else
|
|
sAccelModifier = MODIFIER_CONTROL;
|
|
#endif
|
|
break;
|
|
}
|
|
}
|
|
return sAccelModifier;
|
|
}
|
|
|
|
/******************************************************************************
|
|
* mozilla::WidgetWheelEvent (MouseEvents.h)
|
|
******************************************************************************/
|
|
|
|
bool WidgetWheelEvent::sInitialized = false;
|
|
bool WidgetWheelEvent::sIsSystemScrollSpeedOverrideEnabled = false;
|
|
int32_t WidgetWheelEvent::sOverrideFactorX = 0;
|
|
int32_t WidgetWheelEvent::sOverrideFactorY = 0;
|
|
|
|
/* static */ void
|
|
WidgetWheelEvent::Initialize()
|
|
{
|
|
if (sInitialized) {
|
|
return;
|
|
}
|
|
|
|
Preferences::AddBoolVarCache(&sIsSystemScrollSpeedOverrideEnabled,
|
|
"mousewheel.system_scroll_override_on_root_content.enabled", false);
|
|
Preferences::AddIntVarCache(&sOverrideFactorX,
|
|
"mousewheel.system_scroll_override_on_root_content.horizontal.factor", 0);
|
|
Preferences::AddIntVarCache(&sOverrideFactorY,
|
|
"mousewheel.system_scroll_override_on_root_content.vertical.factor", 0);
|
|
sInitialized = true;
|
|
}
|
|
|
|
/* static */ double
|
|
WidgetWheelEvent::ComputeOverriddenDelta(double aDelta, bool aIsForVertical)
|
|
{
|
|
Initialize();
|
|
if (!sIsSystemScrollSpeedOverrideEnabled) {
|
|
return aDelta;
|
|
}
|
|
int32_t intFactor = aIsForVertical ? sOverrideFactorY : sOverrideFactorX;
|
|
// 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
|
|
{
|
|
if (!mAllowToOverrideSystemScrollSpeed) {
|
|
return deltaX;
|
|
}
|
|
return ComputeOverriddenDelta(deltaX, false);
|
|
}
|
|
|
|
double
|
|
WidgetWheelEvent::OverriddenDeltaY() const
|
|
{
|
|
if (!mAllowToOverrideSystemScrollSpeed) {
|
|
return deltaY;
|
|
}
|
|
return ComputeOverriddenDelta(deltaY, true);
|
|
}
|
|
|
|
/******************************************************************************
|
|
* mozilla::WidgetKeyboardEvent (TextEvents.h)
|
|
******************************************************************************/
|
|
|
|
#define NS_DEFINE_KEYNAME(aCPPName, aDOMKeyName) MOZ_UTF16(aDOMKeyName),
|
|
const char16_t* WidgetKeyboardEvent::kKeyNames[] = {
|
|
#include "mozilla/KeyNameList.h"
|
|
};
|
|
#undef NS_DEFINE_KEYNAME
|
|
|
|
#define NS_DEFINE_PHYSICAL_KEY_CODE_NAME(aCPPName, aDOMCodeName) \
|
|
MOZ_UTF16(aDOMCodeName),
|
|
const char16_t* WidgetKeyboardEvent::kCodeNames[] = {
|
|
#include "mozilla/PhysicalKeyCodeNameList.h"
|
|
};
|
|
#undef NS_DEFINE_PHYSICAL_KEY_CODE_NAME
|
|
|
|
WidgetKeyboardEvent::KeyNameIndexHashtable*
|
|
WidgetKeyboardEvent::sKeyNameIndexHashtable = nullptr;
|
|
WidgetKeyboardEvent::CodeNameIndexHashtable*
|
|
WidgetKeyboardEvent::sCodeNameIndexHashtable = nullptr;
|
|
|
|
bool
|
|
WidgetKeyboardEvent::ShouldCauseKeypressEvents() const
|
|
{
|
|
// Currently, we don't dispatch keypress events of modifier keys.
|
|
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:
|
|
case KEY_NAME_INDEX_FnLock:
|
|
// 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:
|
|
case KEY_NAME_INDEX_SymbolLock:
|
|
return false;
|
|
default:
|
|
return true;
|
|
}
|
|
}
|
|
|
|
/* static */ void
|
|
WidgetKeyboardEvent::Shutdown()
|
|
{
|
|
delete sKeyNameIndexHashtable;
|
|
sKeyNameIndexHashtable = nullptr;
|
|
delete sCodeNameIndexHashtable;
|
|
sCodeNameIndexHashtable = nullptr;
|
|
}
|
|
|
|
/* static */ void
|
|
WidgetKeyboardEvent::GetDOMKeyName(KeyNameIndex aKeyNameIndex,
|
|
nsAString& aKeyName)
|
|
{
|
|
if (aKeyNameIndex >= KEY_NAME_INDEX_USE_STRING) {
|
|
aKeyName.Truncate();
|
|
return;
|
|
}
|
|
|
|
MOZ_RELEASE_ASSERT(static_cast<size_t>(aKeyNameIndex) <
|
|
ArrayLength(kKeyNames),
|
|
"Illegal key enumeration value");
|
|
aKeyName = kKeyNames[aKeyNameIndex];
|
|
}
|
|
|
|
/* 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];
|
|
}
|
|
|
|
/* 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;
|
|
}
|
|
|
|
/* static */ const char*
|
|
WidgetKeyboardEvent::GetCommandStr(Command aCommand)
|
|
{
|
|
#define NS_DEFINE_COMMAND(aName, aCommandStr) , #aCommandStr
|
|
static const char* kCommands[] = {
|
|
"" // CommandDoNothing
|
|
#include "mozilla/CommandList.h"
|
|
};
|
|
#undef NS_DEFINE_COMMAND
|
|
|
|
MOZ_RELEASE_ASSERT(static_cast<size_t>(aCommand) < ArrayLength(kCommands),
|
|
"Illegal command enumeration value");
|
|
return kCommands[aCommand];
|
|
}
|
|
|
|
/* 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:
|
|
return nsIDOMKeyEvent::DOM_KEY_LOCATION_LEFT;
|
|
case CODE_NAME_INDEX_AltRight:
|
|
case CODE_NAME_INDEX_ControlRight:
|
|
case CODE_NAME_INDEX_OSRight:
|
|
case CODE_NAME_INDEX_ShiftRight:
|
|
return nsIDOMKeyEvent::DOM_KEY_LOCATION_RIGHT;
|
|
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:
|
|
case CODE_NAME_INDEX_NumpadClear:
|
|
case CODE_NAME_INDEX_NumpadClearEntry:
|
|
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:
|
|
case CODE_NAME_INDEX_NumpadMemoryAdd:
|
|
case CODE_NAME_INDEX_NumpadMemoryClear:
|
|
case CODE_NAME_INDEX_NumpadMemoryRecall:
|
|
case CODE_NAME_INDEX_NumpadMemoryStore:
|
|
case CODE_NAME_INDEX_NumpadMemorySubtract:
|
|
case CODE_NAME_INDEX_NumpadMultiply:
|
|
case CODE_NAME_INDEX_NumpadParenLeft:
|
|
case CODE_NAME_INDEX_NumpadParenRight:
|
|
case CODE_NAME_INDEX_NumpadSubtract:
|
|
return nsIDOMKeyEvent::DOM_KEY_LOCATION_NUMPAD;
|
|
default:
|
|
return nsIDOMKeyEvent::DOM_KEY_LOCATION_STANDARD;
|
|
}
|
|
}
|
|
|
|
/* static */ uint32_t
|
|
WidgetKeyboardEvent::ComputeKeyCodeFromKeyNameIndex(KeyNameIndex aKeyNameIndex)
|
|
{
|
|
switch (aKeyNameIndex) {
|
|
case KEY_NAME_INDEX_Cancel:
|
|
return nsIDOMKeyEvent::DOM_VK_CANCEL;
|
|
case KEY_NAME_INDEX_Help:
|
|
return nsIDOMKeyEvent::DOM_VK_HELP;
|
|
case KEY_NAME_INDEX_Backspace:
|
|
return nsIDOMKeyEvent::DOM_VK_BACK_SPACE;
|
|
case KEY_NAME_INDEX_Tab:
|
|
return nsIDOMKeyEvent::DOM_VK_TAB;
|
|
case KEY_NAME_INDEX_Clear:
|
|
return nsIDOMKeyEvent::DOM_VK_CLEAR;
|
|
case KEY_NAME_INDEX_Enter:
|
|
return nsIDOMKeyEvent::DOM_VK_RETURN;
|
|
case KEY_NAME_INDEX_Shift:
|
|
return nsIDOMKeyEvent::DOM_VK_SHIFT;
|
|
case KEY_NAME_INDEX_Control:
|
|
return nsIDOMKeyEvent::DOM_VK_CONTROL;
|
|
case KEY_NAME_INDEX_Alt:
|
|
return nsIDOMKeyEvent::DOM_VK_ALT;
|
|
case KEY_NAME_INDEX_Pause:
|
|
return nsIDOMKeyEvent::DOM_VK_PAUSE;
|
|
case KEY_NAME_INDEX_CapsLock:
|
|
return nsIDOMKeyEvent::DOM_VK_CAPS_LOCK;
|
|
case KEY_NAME_INDEX_Hiragana:
|
|
case KEY_NAME_INDEX_Katakana:
|
|
case KEY_NAME_INDEX_HiraganaKatakana:
|
|
case KEY_NAME_INDEX_KanaMode:
|
|
return nsIDOMKeyEvent::DOM_VK_KANA;
|
|
case KEY_NAME_INDEX_HangulMode:
|
|
return nsIDOMKeyEvent::DOM_VK_HANGUL;
|
|
case KEY_NAME_INDEX_Eisu:
|
|
return nsIDOMKeyEvent::DOM_VK_EISU;
|
|
case KEY_NAME_INDEX_JunjaMode:
|
|
return nsIDOMKeyEvent::DOM_VK_JUNJA;
|
|
case KEY_NAME_INDEX_FinalMode:
|
|
return nsIDOMKeyEvent::DOM_VK_FINAL;
|
|
case KEY_NAME_INDEX_HanjaMode:
|
|
return nsIDOMKeyEvent::DOM_VK_HANJA;
|
|
case KEY_NAME_INDEX_KanjiMode:
|
|
return nsIDOMKeyEvent::DOM_VK_KANJI;
|
|
case KEY_NAME_INDEX_Escape:
|
|
return nsIDOMKeyEvent::DOM_VK_ESCAPE;
|
|
case KEY_NAME_INDEX_Convert:
|
|
return nsIDOMKeyEvent::DOM_VK_CONVERT;
|
|
case KEY_NAME_INDEX_NonConvert:
|
|
return nsIDOMKeyEvent::DOM_VK_NONCONVERT;
|
|
case KEY_NAME_INDEX_Accept:
|
|
return nsIDOMKeyEvent::DOM_VK_ACCEPT;
|
|
case KEY_NAME_INDEX_ModeChange:
|
|
return nsIDOMKeyEvent::DOM_VK_MODECHANGE;
|
|
case KEY_NAME_INDEX_PageUp:
|
|
return nsIDOMKeyEvent::DOM_VK_PAGE_UP;
|
|
case KEY_NAME_INDEX_PageDown:
|
|
return nsIDOMKeyEvent::DOM_VK_PAGE_DOWN;
|
|
case KEY_NAME_INDEX_End:
|
|
return nsIDOMKeyEvent::DOM_VK_END;
|
|
case KEY_NAME_INDEX_Home:
|
|
return nsIDOMKeyEvent::DOM_VK_HOME;
|
|
case KEY_NAME_INDEX_ArrowLeft:
|
|
return nsIDOMKeyEvent::DOM_VK_LEFT;
|
|
case KEY_NAME_INDEX_ArrowUp:
|
|
return nsIDOMKeyEvent::DOM_VK_UP;
|
|
case KEY_NAME_INDEX_ArrowRight:
|
|
return nsIDOMKeyEvent::DOM_VK_RIGHT;
|
|
case KEY_NAME_INDEX_ArrowDown:
|
|
return nsIDOMKeyEvent::DOM_VK_DOWN;
|
|
case KEY_NAME_INDEX_Select:
|
|
return nsIDOMKeyEvent::DOM_VK_SELECT;
|
|
case KEY_NAME_INDEX_Print:
|
|
return nsIDOMKeyEvent::DOM_VK_PRINT;
|
|
case KEY_NAME_INDEX_Execute:
|
|
return nsIDOMKeyEvent::DOM_VK_EXECUTE;
|
|
case KEY_NAME_INDEX_PrintScreen:
|
|
return nsIDOMKeyEvent::DOM_VK_PRINTSCREEN;
|
|
case KEY_NAME_INDEX_Insert:
|
|
return nsIDOMKeyEvent::DOM_VK_INSERT;
|
|
case KEY_NAME_INDEX_Delete:
|
|
return nsIDOMKeyEvent::DOM_VK_DELETE;
|
|
case KEY_NAME_INDEX_OS:
|
|
// case KEY_NAME_INDEX_Super:
|
|
// case KEY_NAME_INDEX_Hyper:
|
|
return nsIDOMKeyEvent::DOM_VK_WIN;
|
|
case KEY_NAME_INDEX_ContextMenu:
|
|
return nsIDOMKeyEvent::DOM_VK_CONTEXT_MENU;
|
|
case KEY_NAME_INDEX_Standby:
|
|
return nsIDOMKeyEvent::DOM_VK_SLEEP;
|
|
case KEY_NAME_INDEX_F1:
|
|
return nsIDOMKeyEvent::DOM_VK_F1;
|
|
case KEY_NAME_INDEX_F2:
|
|
return nsIDOMKeyEvent::DOM_VK_F2;
|
|
case KEY_NAME_INDEX_F3:
|
|
return nsIDOMKeyEvent::DOM_VK_F3;
|
|
case KEY_NAME_INDEX_F4:
|
|
return nsIDOMKeyEvent::DOM_VK_F4;
|
|
case KEY_NAME_INDEX_F5:
|
|
return nsIDOMKeyEvent::DOM_VK_F5;
|
|
case KEY_NAME_INDEX_F6:
|
|
return nsIDOMKeyEvent::DOM_VK_F6;
|
|
case KEY_NAME_INDEX_F7:
|
|
return nsIDOMKeyEvent::DOM_VK_F7;
|
|
case KEY_NAME_INDEX_F8:
|
|
return nsIDOMKeyEvent::DOM_VK_F8;
|
|
case KEY_NAME_INDEX_F9:
|
|
return nsIDOMKeyEvent::DOM_VK_F9;
|
|
case KEY_NAME_INDEX_F10:
|
|
return nsIDOMKeyEvent::DOM_VK_F10;
|
|
case KEY_NAME_INDEX_F11:
|
|
return nsIDOMKeyEvent::DOM_VK_F11;
|
|
case KEY_NAME_INDEX_F12:
|
|
return nsIDOMKeyEvent::DOM_VK_F12;
|
|
case KEY_NAME_INDEX_F13:
|
|
return nsIDOMKeyEvent::DOM_VK_F13;
|
|
case KEY_NAME_INDEX_F14:
|
|
return nsIDOMKeyEvent::DOM_VK_F14;
|
|
case KEY_NAME_INDEX_F15:
|
|
return nsIDOMKeyEvent::DOM_VK_F15;
|
|
case KEY_NAME_INDEX_F16:
|
|
return nsIDOMKeyEvent::DOM_VK_F16;
|
|
case KEY_NAME_INDEX_F17:
|
|
return nsIDOMKeyEvent::DOM_VK_F17;
|
|
case KEY_NAME_INDEX_F18:
|
|
return nsIDOMKeyEvent::DOM_VK_F18;
|
|
case KEY_NAME_INDEX_F19:
|
|
return nsIDOMKeyEvent::DOM_VK_F19;
|
|
case KEY_NAME_INDEX_F20:
|
|
return nsIDOMKeyEvent::DOM_VK_F20;
|
|
case KEY_NAME_INDEX_F21:
|
|
return nsIDOMKeyEvent::DOM_VK_F21;
|
|
case KEY_NAME_INDEX_F22:
|
|
return nsIDOMKeyEvent::DOM_VK_F22;
|
|
case KEY_NAME_INDEX_F23:
|
|
return nsIDOMKeyEvent::DOM_VK_F23;
|
|
case KEY_NAME_INDEX_F24:
|
|
return nsIDOMKeyEvent::DOM_VK_F24;
|
|
case KEY_NAME_INDEX_NumLock:
|
|
return nsIDOMKeyEvent::DOM_VK_NUM_LOCK;
|
|
case KEY_NAME_INDEX_ScrollLock:
|
|
return nsIDOMKeyEvent::DOM_VK_SCROLL_LOCK;
|
|
case KEY_NAME_INDEX_VolumeMute:
|
|
return nsIDOMKeyEvent::DOM_VK_VOLUME_MUTE;
|
|
case KEY_NAME_INDEX_VolumeDown:
|
|
return nsIDOMKeyEvent::DOM_VK_VOLUME_DOWN;
|
|
case KEY_NAME_INDEX_VolumeUp:
|
|
return nsIDOMKeyEvent::DOM_VK_VOLUME_UP;
|
|
case KEY_NAME_INDEX_Meta:
|
|
return nsIDOMKeyEvent::DOM_VK_META;
|
|
case KEY_NAME_INDEX_AltGraph:
|
|
return nsIDOMKeyEvent::DOM_VK_ALTGR;
|
|
case KEY_NAME_INDEX_Attn:
|
|
return nsIDOMKeyEvent::DOM_VK_ATTN;
|
|
case KEY_NAME_INDEX_CrSel:
|
|
return nsIDOMKeyEvent::DOM_VK_CRSEL;
|
|
case KEY_NAME_INDEX_ExSel:
|
|
return nsIDOMKeyEvent::DOM_VK_EXSEL;
|
|
case KEY_NAME_INDEX_EraseEof:
|
|
return nsIDOMKeyEvent::DOM_VK_EREOF;
|
|
case KEY_NAME_INDEX_Play:
|
|
return nsIDOMKeyEvent::DOM_VK_PLAY;
|
|
case KEY_NAME_INDEX_ZoomToggle:
|
|
case KEY_NAME_INDEX_ZoomIn:
|
|
case KEY_NAME_INDEX_ZoomOut:
|
|
return nsIDOMKeyEvent::DOM_VK_ZOOM;
|
|
default:
|
|
return 0;
|
|
}
|
|
}
|
|
|
|
/* 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;
|
|
}
|
|
}
|
|
|
|
} // namespace mozilla
|