2015-05-03 22:32:37 +03:00
|
|
|
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
|
|
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
|
2012-05-21 15:12:37 +04:00
|
|
|
/* 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/. */
|
2004-08-20 22:09:19 +04:00
|
|
|
|
2014-02-27 14:51:13 +04:00
|
|
|
#include "mozilla/dom/KeyboardEvent.h"
|
2013-09-25 15:21:19 +04:00
|
|
|
#include "mozilla/TextEvents.h"
|
2014-02-27 14:51:13 +04:00
|
|
|
#include "prtime.h"
|
2004-08-20 22:09:19 +04:00
|
|
|
|
2014-02-27 14:51:13 +04:00
|
|
|
namespace mozilla {
|
|
|
|
namespace dom {
|
2013-10-01 11:22:58 +04:00
|
|
|
|
2014-02-27 14:51:13 +04:00
|
|
|
KeyboardEvent::KeyboardEvent(EventTarget* aOwner,
|
|
|
|
nsPresContext* aPresContext,
|
|
|
|
WidgetKeyboardEvent* aEvent)
|
2014-02-28 18:58:43 +04:00
|
|
|
: UIEvent(aOwner, aPresContext,
|
2015-08-26 15:56:59 +03:00
|
|
|
aEvent ? aEvent :
|
2015-08-29 02:58:26 +03:00
|
|
|
new WidgetKeyboardEvent(false, eVoidEvent, nullptr))
|
2014-04-14 10:37:47 +04:00
|
|
|
, mInitializedByCtor(false)
|
2014-11-03 10:05:32 +03:00
|
|
|
, mInitializedWhichValue(0)
|
2004-08-20 22:09:19 +04:00
|
|
|
{
|
|
|
|
if (aEvent) {
|
2011-10-17 18:59:28 +04:00
|
|
|
mEventIsInternal = false;
|
2004-08-20 22:09:19 +04:00
|
|
|
}
|
|
|
|
else {
|
2011-10-17 18:59:28 +04:00
|
|
|
mEventIsInternal = true;
|
2016-03-28 07:29:42 +03:00
|
|
|
mEvent->mTime = PR_Now();
|
2013-10-29 08:14:42 +04:00
|
|
|
mEvent->AsKeyboardEvent()->mKeyNameIndex = KEY_NAME_INDEX_USE_STRING;
|
2004-08-20 22:09:19 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-02-28 18:58:43 +04:00
|
|
|
NS_IMPL_ADDREF_INHERITED(KeyboardEvent, UIEvent)
|
|
|
|
NS_IMPL_RELEASE_INHERITED(KeyboardEvent, UIEvent)
|
2004-08-20 22:09:19 +04:00
|
|
|
|
2014-02-27 14:51:13 +04:00
|
|
|
NS_INTERFACE_MAP_BEGIN(KeyboardEvent)
|
2004-08-20 22:09:19 +04:00
|
|
|
NS_INTERFACE_MAP_ENTRY(nsIDOMKeyEvent)
|
2014-02-28 18:58:43 +04:00
|
|
|
NS_INTERFACE_MAP_END_INHERITING(UIEvent)
|
2004-08-20 22:09:19 +04:00
|
|
|
|
2013-10-18 10:10:26 +04:00
|
|
|
bool
|
2014-02-27 14:51:13 +04:00
|
|
|
KeyboardEvent::AltKey()
|
2013-10-18 10:10:26 +04:00
|
|
|
{
|
|
|
|
return mEvent->AsKeyboardEvent()->IsAlt();
|
|
|
|
}
|
|
|
|
|
2004-08-20 22:09:19 +04:00
|
|
|
NS_IMETHODIMP
|
2014-02-27 14:51:13 +04:00
|
|
|
KeyboardEvent::GetAltKey(bool* aIsDown)
|
2004-08-20 22:09:19 +04:00
|
|
|
{
|
|
|
|
NS_ENSURE_ARG_POINTER(aIsDown);
|
2013-04-21 03:48:55 +04:00
|
|
|
*aIsDown = AltKey();
|
2004-08-20 22:09:19 +04:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2013-10-18 10:10:26 +04:00
|
|
|
bool
|
2014-02-27 14:51:13 +04:00
|
|
|
KeyboardEvent::CtrlKey()
|
2013-10-18 10:10:26 +04:00
|
|
|
{
|
|
|
|
return mEvent->AsKeyboardEvent()->IsControl();
|
|
|
|
}
|
|
|
|
|
2004-08-20 22:09:19 +04:00
|
|
|
NS_IMETHODIMP
|
2014-02-27 14:51:13 +04:00
|
|
|
KeyboardEvent::GetCtrlKey(bool* aIsDown)
|
2004-08-20 22:09:19 +04:00
|
|
|
{
|
|
|
|
NS_ENSURE_ARG_POINTER(aIsDown);
|
2013-04-21 03:48:55 +04:00
|
|
|
*aIsDown = CtrlKey();
|
2004-08-20 22:09:19 +04:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2013-10-18 10:10:26 +04:00
|
|
|
bool
|
2014-02-27 14:51:13 +04:00
|
|
|
KeyboardEvent::ShiftKey()
|
2013-10-18 10:10:26 +04:00
|
|
|
{
|
|
|
|
return mEvent->AsKeyboardEvent()->IsShift();
|
|
|
|
}
|
|
|
|
|
2004-08-20 22:09:19 +04:00
|
|
|
NS_IMETHODIMP
|
2014-02-27 14:51:13 +04:00
|
|
|
KeyboardEvent::GetShiftKey(bool* aIsDown)
|
2004-08-20 22:09:19 +04:00
|
|
|
{
|
|
|
|
NS_ENSURE_ARG_POINTER(aIsDown);
|
2013-04-21 03:48:55 +04:00
|
|
|
*aIsDown = ShiftKey();
|
2004-08-20 22:09:19 +04:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2013-10-18 10:10:26 +04:00
|
|
|
bool
|
2014-02-27 14:51:13 +04:00
|
|
|
KeyboardEvent::MetaKey()
|
2013-10-18 10:10:26 +04:00
|
|
|
{
|
|
|
|
return mEvent->AsKeyboardEvent()->IsMeta();
|
|
|
|
}
|
|
|
|
|
2004-08-20 22:09:19 +04:00
|
|
|
NS_IMETHODIMP
|
2014-02-27 14:51:13 +04:00
|
|
|
KeyboardEvent::GetMetaKey(bool* aIsDown)
|
2004-08-20 22:09:19 +04:00
|
|
|
{
|
|
|
|
NS_ENSURE_ARG_POINTER(aIsDown);
|
2013-04-21 03:48:55 +04:00
|
|
|
*aIsDown = MetaKey();
|
2004-08-20 22:09:19 +04:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2013-11-07 15:17:32 +04:00
|
|
|
bool
|
2014-02-27 14:51:13 +04:00
|
|
|
KeyboardEvent::Repeat()
|
2013-11-07 15:17:32 +04:00
|
|
|
{
|
|
|
|
return mEvent->AsKeyboardEvent()->mIsRepeat;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2014-02-27 14:51:13 +04:00
|
|
|
KeyboardEvent::GetRepeat(bool* aIsRepeat)
|
2013-11-07 15:17:32 +04:00
|
|
|
{
|
|
|
|
NS_ENSURE_ARG_POINTER(aIsRepeat);
|
|
|
|
*aIsRepeat = Repeat();
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2014-04-10 11:11:36 +04:00
|
|
|
bool
|
|
|
|
KeyboardEvent::IsComposing()
|
|
|
|
{
|
|
|
|
return mEvent->AsKeyboardEvent()->mIsComposing;
|
|
|
|
}
|
|
|
|
|
2012-04-25 07:00:02 +04:00
|
|
|
NS_IMETHODIMP
|
2014-02-27 14:51:13 +04:00
|
|
|
KeyboardEvent::GetModifierState(const nsAString& aKey,
|
|
|
|
bool* aState)
|
2012-04-25 07:00:02 +04:00
|
|
|
{
|
|
|
|
NS_ENSURE_ARG_POINTER(aState);
|
|
|
|
|
2013-04-21 03:48:55 +04:00
|
|
|
*aState = GetModifierState(aKey);
|
2012-04-25 07:00:02 +04:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2013-04-24 07:49:46 +04:00
|
|
|
NS_IMETHODIMP
|
2014-02-27 14:51:13 +04:00
|
|
|
KeyboardEvent::GetKey(nsAString& aKeyName)
|
2013-04-24 07:49:46 +04:00
|
|
|
{
|
2014-12-30 04:47:53 +03:00
|
|
|
mEvent->AsKeyboardEvent()->GetDOMKeyName(aKeyName);
|
2013-04-24 07:49:46 +04:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2014-05-25 06:08:58 +04:00
|
|
|
void
|
|
|
|
KeyboardEvent::GetCode(nsAString& aCodeName)
|
|
|
|
{
|
|
|
|
mEvent->AsKeyboardEvent()->GetDOMCodeName(aCodeName);
|
|
|
|
}
|
|
|
|
|
2016-03-15 08:46:29 +03:00
|
|
|
void KeyboardEvent::GetInitDict(KeyboardEventInit& aParam)
|
|
|
|
{
|
|
|
|
GetKey(aParam.mKey);
|
|
|
|
GetCode(aParam.mCode);
|
|
|
|
aParam.mLocation = Location();
|
|
|
|
aParam.mRepeat = Repeat();
|
|
|
|
aParam.mIsComposing = IsComposing();
|
|
|
|
|
|
|
|
// legacy attributes
|
|
|
|
aParam.mKeyCode = KeyCode();
|
|
|
|
aParam.mCharCode = CharCode();
|
|
|
|
aParam.mWhich = Which();
|
|
|
|
|
|
|
|
// modifiers from EventModifierInit
|
|
|
|
aParam.mCtrlKey = CtrlKey();
|
|
|
|
aParam.mShiftKey = ShiftKey();
|
|
|
|
aParam.mAltKey = AltKey();
|
|
|
|
aParam.mMetaKey = MetaKey();
|
|
|
|
|
|
|
|
WidgetKeyboardEvent* internalEvent = mEvent->AsKeyboardEvent();
|
|
|
|
aParam.mModifierAltGraph = internalEvent->IsAltGraph();
|
|
|
|
aParam.mModifierCapsLock = internalEvent->IsCapsLocked();
|
|
|
|
aParam.mModifierFn = internalEvent->IsFn();
|
|
|
|
aParam.mModifierFnLock = internalEvent->IsFnLocked();
|
|
|
|
aParam.mModifierNumLock = internalEvent->IsNumLocked();
|
|
|
|
aParam.mModifierOS = internalEvent->IsOS();
|
|
|
|
aParam.mModifierScrollLock = internalEvent->IsScrollLocked();
|
|
|
|
aParam.mModifierSymbol = internalEvent->IsSymbol();
|
|
|
|
aParam.mModifierSymbolLock = internalEvent->IsSymbolLocked();
|
|
|
|
|
|
|
|
// EventInit
|
|
|
|
aParam.mBubbles = internalEvent->mFlags.mBubbles;
|
|
|
|
aParam.mCancelable = internalEvent->mFlags.mCancelable;
|
|
|
|
}
|
|
|
|
|
2004-08-20 22:09:19 +04:00
|
|
|
NS_IMETHODIMP
|
2014-02-27 14:51:13 +04:00
|
|
|
KeyboardEvent::GetCharCode(uint32_t* aCharCode)
|
2004-08-20 22:09:19 +04:00
|
|
|
{
|
|
|
|
NS_ENSURE_ARG_POINTER(aCharCode);
|
2013-04-21 03:48:55 +04:00
|
|
|
*aCharCode = CharCode();
|
|
|
|
return NS_OK;
|
|
|
|
}
|
2004-08-20 22:09:19 +04:00
|
|
|
|
2013-04-21 03:48:55 +04:00
|
|
|
uint32_t
|
2014-02-27 14:51:13 +04:00
|
|
|
KeyboardEvent::CharCode()
|
2013-04-21 03:48:55 +04:00
|
|
|
{
|
2014-04-14 10:37:47 +04:00
|
|
|
// If this event is initialized with ctor, we shouldn't check event type.
|
|
|
|
if (mInitializedByCtor) {
|
2016-05-13 10:06:18 +03:00
|
|
|
return mEvent->AsKeyboardEvent()->mCharCode;
|
2014-04-14 10:37:47 +04:00
|
|
|
}
|
|
|
|
|
2015-08-22 04:34:51 +03:00
|
|
|
switch (mEvent->mMessage) {
|
2015-08-29 02:58:27 +03:00
|
|
|
case eBeforeKeyDown:
|
2015-08-29 02:58:27 +03:00
|
|
|
case eKeyDown:
|
2016-04-22 19:22:49 +03:00
|
|
|
case eKeyDownOnPlugin:
|
2015-08-29 02:58:28 +03:00
|
|
|
case eAfterKeyDown:
|
2015-08-29 02:58:28 +03:00
|
|
|
case eBeforeKeyUp:
|
2015-08-29 02:58:27 +03:00
|
|
|
case eKeyUp:
|
2016-04-22 19:22:49 +03:00
|
|
|
case eKeyUpOnPlugin:
|
2015-08-29 02:58:28 +03:00
|
|
|
case eAfterKeyUp:
|
2013-04-21 03:48:55 +04:00
|
|
|
return 0;
|
2015-08-29 02:58:27 +03:00
|
|
|
case eKeyPress:
|
2016-05-11 15:56:42 +03:00
|
|
|
case eAccessKeyNotFound:
|
2016-05-13 10:06:18 +03:00
|
|
|
return mEvent->AsKeyboardEvent()->mCharCode;
|
2015-08-26 15:56:59 +03:00
|
|
|
default:
|
|
|
|
break;
|
2004-08-20 22:09:19 +04:00
|
|
|
}
|
2013-04-21 03:48:55 +04:00
|
|
|
return 0;
|
2004-08-20 22:09:19 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2014-02-27 14:51:13 +04:00
|
|
|
KeyboardEvent::GetKeyCode(uint32_t* aKeyCode)
|
2004-08-20 22:09:19 +04:00
|
|
|
{
|
|
|
|
NS_ENSURE_ARG_POINTER(aKeyCode);
|
2013-04-21 03:48:55 +04:00
|
|
|
*aKeyCode = KeyCode();
|
|
|
|
return NS_OK;
|
|
|
|
}
|
2004-08-20 22:09:19 +04:00
|
|
|
|
2013-04-21 03:48:55 +04:00
|
|
|
uint32_t
|
2014-02-27 14:51:13 +04:00
|
|
|
KeyboardEvent::KeyCode()
|
2013-04-21 03:48:55 +04:00
|
|
|
{
|
2014-04-14 10:37:47 +04:00
|
|
|
// If this event is initialized with ctor, we shouldn't check event type.
|
|
|
|
if (mInitializedByCtor) {
|
2016-05-12 11:13:49 +03:00
|
|
|
return mEvent->AsKeyboardEvent()->mKeyCode;
|
2014-04-14 10:37:47 +04:00
|
|
|
}
|
|
|
|
|
2014-11-03 10:05:32 +03:00
|
|
|
if (mEvent->HasKeyEventMessage()) {
|
2016-05-12 11:13:49 +03:00
|
|
|
return mEvent->AsKeyboardEvent()->mKeyCode;
|
2004-08-20 22:09:19 +04:00
|
|
|
}
|
2013-04-21 03:48:55 +04:00
|
|
|
return 0;
|
2004-08-20 22:09:19 +04:00
|
|
|
}
|
|
|
|
|
2013-04-21 03:48:55 +04:00
|
|
|
uint32_t
|
2014-02-27 14:51:13 +04:00
|
|
|
KeyboardEvent::Which()
|
2013-04-21 03:48:55 +04:00
|
|
|
{
|
2014-04-14 10:37:47 +04:00
|
|
|
// If this event is initialized with ctor, which can have independent value.
|
|
|
|
if (mInitializedByCtor) {
|
2014-11-03 10:05:32 +03:00
|
|
|
return mInitializedWhichValue;
|
2014-04-14 10:37:47 +04:00
|
|
|
}
|
|
|
|
|
2015-08-22 04:34:51 +03:00
|
|
|
switch (mEvent->mMessage) {
|
2015-08-29 02:58:27 +03:00
|
|
|
case eBeforeKeyDown:
|
2015-08-29 02:58:27 +03:00
|
|
|
case eKeyDown:
|
2016-04-22 19:22:49 +03:00
|
|
|
case eKeyDownOnPlugin:
|
2015-08-29 02:58:28 +03:00
|
|
|
case eAfterKeyDown:
|
2015-08-29 02:58:28 +03:00
|
|
|
case eBeforeKeyUp:
|
2015-08-29 02:58:27 +03:00
|
|
|
case eKeyUp:
|
2016-04-22 19:22:49 +03:00
|
|
|
case eKeyUpOnPlugin:
|
2015-08-29 02:58:28 +03:00
|
|
|
case eAfterKeyUp:
|
2013-04-21 03:48:55 +04:00
|
|
|
return KeyCode();
|
2015-08-29 02:58:27 +03:00
|
|
|
case eKeyPress:
|
2004-08-20 22:09:19 +04:00
|
|
|
//Special case for 4xp bug 62878. Try to make value of which
|
|
|
|
//more closely mirror the values that 4.x gave for RETURN and BACKSPACE
|
|
|
|
{
|
2016-05-12 11:13:49 +03:00
|
|
|
uint32_t keyCode = mEvent->AsKeyboardEvent()->mKeyCode;
|
2004-08-20 22:09:19 +04:00
|
|
|
if (keyCode == NS_VK_RETURN || keyCode == NS_VK_BACK) {
|
2013-04-21 03:48:55 +04:00
|
|
|
return keyCode;
|
2004-08-20 22:09:19 +04:00
|
|
|
}
|
2013-04-21 03:48:55 +04:00
|
|
|
return CharCode();
|
2004-08-20 22:09:19 +04:00
|
|
|
}
|
2015-08-26 15:56:59 +03:00
|
|
|
default:
|
|
|
|
break;
|
2004-08-20 22:09:19 +04:00
|
|
|
}
|
|
|
|
|
2013-04-21 03:48:55 +04:00
|
|
|
return 0;
|
2004-08-20 22:09:19 +04:00
|
|
|
}
|
|
|
|
|
2012-05-03 12:35:01 +04:00
|
|
|
NS_IMETHODIMP
|
2014-02-27 14:51:13 +04:00
|
|
|
KeyboardEvent::GetLocation(uint32_t* aLocation)
|
2012-05-03 12:35:01 +04:00
|
|
|
{
|
|
|
|
NS_ENSURE_ARG_POINTER(aLocation);
|
|
|
|
|
2013-04-21 03:48:55 +04:00
|
|
|
*aLocation = Location();
|
2012-05-03 12:35:01 +04:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2013-10-18 10:10:24 +04:00
|
|
|
uint32_t
|
2014-02-27 14:51:13 +04:00
|
|
|
KeyboardEvent::Location()
|
2013-10-18 10:10:24 +04:00
|
|
|
{
|
2016-05-12 12:17:22 +03:00
|
|
|
return mEvent->AsKeyboardEvent()->mLocation;
|
2013-10-18 10:10:24 +04:00
|
|
|
}
|
|
|
|
|
2014-04-14 10:37:47 +04:00
|
|
|
// static
|
|
|
|
already_AddRefed<KeyboardEvent>
|
|
|
|
KeyboardEvent::Constructor(const GlobalObject& aGlobal,
|
|
|
|
const nsAString& aType,
|
|
|
|
const KeyboardEventInit& aParam,
|
|
|
|
ErrorResult& aRv)
|
|
|
|
{
|
|
|
|
nsCOMPtr<EventTarget> target = do_QueryInterface(aGlobal.GetAsSupports());
|
2015-10-18 08:24:48 +03:00
|
|
|
RefPtr<KeyboardEvent> newEvent =
|
2014-04-14 10:37:47 +04:00
|
|
|
new KeyboardEvent(target, nullptr, nullptr);
|
2014-11-03 10:05:32 +03:00
|
|
|
newEvent->InitWithKeyboardEventInit(target, aType, aParam, aRv);
|
|
|
|
|
|
|
|
return newEvent.forget();
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
KeyboardEvent::InitWithKeyboardEventInit(EventTarget* aOwner,
|
|
|
|
const nsAString& aType,
|
|
|
|
const KeyboardEventInit& aParam,
|
|
|
|
ErrorResult& aRv)
|
|
|
|
{
|
|
|
|
bool trusted = Init(aOwner);
|
2016-01-30 20:05:36 +03:00
|
|
|
InitKeyEvent(aType, aParam.mBubbles, aParam.mCancelable,
|
|
|
|
aParam.mView, false, false, false, false,
|
|
|
|
aParam.mKeyCode, aParam.mCharCode);
|
2015-04-13 10:16:13 +03:00
|
|
|
InitModifiers(aParam);
|
2014-11-03 10:05:32 +03:00
|
|
|
SetTrusted(trusted);
|
|
|
|
mDetail = aParam.mDetail;
|
|
|
|
mInitializedByCtor = true;
|
|
|
|
mInitializedWhichValue = aParam.mWhich;
|
|
|
|
|
|
|
|
WidgetKeyboardEvent* internalEvent = mEvent->AsKeyboardEvent();
|
2016-05-12 12:17:22 +03:00
|
|
|
internalEvent->mLocation = aParam.mLocation;
|
2014-04-14 10:37:47 +04:00
|
|
|
internalEvent->mIsRepeat = aParam.mRepeat;
|
|
|
|
internalEvent->mIsComposing = aParam.mIsComposing;
|
2015-02-19 09:50:19 +03:00
|
|
|
internalEvent->mKeyNameIndex =
|
|
|
|
WidgetKeyboardEvent::GetKeyNameIndex(aParam.mKey);
|
|
|
|
if (internalEvent->mKeyNameIndex == KEY_NAME_INDEX_USE_STRING) {
|
|
|
|
internalEvent->mKeyValue = aParam.mKey;
|
|
|
|
}
|
|
|
|
internalEvent->mCodeNameIndex =
|
|
|
|
WidgetKeyboardEvent::GetCodeNameIndex(aParam.mCode);
|
|
|
|
if (internalEvent->mCodeNameIndex == CODE_NAME_INDEX_USE_STRING) {
|
|
|
|
internalEvent->mCodeValue = aParam.mCode;
|
|
|
|
}
|
2014-04-14 10:37:47 +04:00
|
|
|
}
|
|
|
|
|
2004-08-20 22:09:19 +04:00
|
|
|
NS_IMETHODIMP
|
2014-02-27 14:51:13 +04:00
|
|
|
KeyboardEvent::InitKeyEvent(const nsAString& aType,
|
|
|
|
bool aCanBubble,
|
|
|
|
bool aCancelable,
|
2016-01-30 20:05:36 +03:00
|
|
|
mozIDOMWindow* aView,
|
2014-02-27 14:51:13 +04:00
|
|
|
bool aCtrlKey,
|
|
|
|
bool aAltKey,
|
|
|
|
bool aShiftKey,
|
|
|
|
bool aMetaKey,
|
|
|
|
uint32_t aKeyCode,
|
|
|
|
uint32_t aCharCode)
|
2004-08-20 22:09:19 +04:00
|
|
|
{
|
2016-10-30 22:30:06 +03:00
|
|
|
NS_ENSURE_TRUE(!mEvent->mFlags.mIsBeingDispatched, NS_OK);
|
|
|
|
|
2016-01-30 20:05:36 +03:00
|
|
|
UIEvent::InitUIEvent(aType, aCanBubble, aCancelable, aView, 0);
|
2004-08-20 22:09:19 +04:00
|
|
|
|
2013-10-18 10:10:24 +04:00
|
|
|
WidgetKeyboardEvent* keyEvent = mEvent->AsKeyboardEvent();
|
2012-04-25 07:00:02 +04:00
|
|
|
keyEvent->InitBasicModifiers(aCtrlKey, aAltKey, aShiftKey, aMetaKey);
|
2016-05-12 11:13:49 +03:00
|
|
|
keyEvent->mKeyCode = aKeyCode;
|
2016-05-13 10:06:18 +03:00
|
|
|
keyEvent->mCharCode = aCharCode;
|
2004-08-20 22:09:19 +04:00
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2014-02-27 14:51:13 +04:00
|
|
|
} // namespace dom
|
|
|
|
} // namespace mozilla
|
|
|
|
|
|
|
|
using namespace mozilla;
|
|
|
|
using namespace mozilla::dom;
|
|
|
|
|
2015-08-12 14:39:31 +03:00
|
|
|
already_AddRefed<KeyboardEvent>
|
|
|
|
NS_NewDOMKeyboardEvent(EventTarget* aOwner,
|
2014-02-27 14:51:13 +04:00
|
|
|
nsPresContext* aPresContext,
|
|
|
|
WidgetKeyboardEvent* aEvent)
|
2004-08-20 22:09:19 +04:00
|
|
|
{
|
2015-10-18 08:24:48 +03:00
|
|
|
RefPtr<KeyboardEvent> it = new KeyboardEvent(aOwner, aPresContext, aEvent);
|
2015-08-12 14:39:31 +03:00
|
|
|
return it.forget();
|
2004-08-20 22:09:19 +04:00
|
|
|
}
|