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/. */
|
2006-05-23 00:37:32 +04:00
|
|
|
|
2014-02-28 18:58:42 +04:00
|
|
|
#include "mozilla/dom/XULCommandEvent.h"
|
2013-07-03 19:56:26 +04:00
|
|
|
#include "prtime.h"
|
2006-05-23 00:37:32 +04:00
|
|
|
|
2014-02-28 18:58:42 +04:00
|
|
|
namespace mozilla {
|
|
|
|
namespace dom {
|
2013-10-01 11:23:02 +04:00
|
|
|
|
2014-02-28 18:58:42 +04:00
|
|
|
XULCommandEvent::XULCommandEvent(EventTarget* aOwner,
|
|
|
|
nsPresContext* aPresContext,
|
|
|
|
WidgetInputEvent* aEvent)
|
2018-04-13 16:01:28 +03:00
|
|
|
: UIEvent(aOwner, aPresContext,
|
|
|
|
aEvent ? aEvent :
|
|
|
|
new WidgetInputEvent(false, eVoidEvent, nullptr))
|
2018-06-14 22:26:29 +03:00
|
|
|
, mInputSource(0)
|
2006-05-23 00:37:32 +04:00
|
|
|
{
|
|
|
|
if (aEvent) {
|
2011-10-17 18:59:28 +04:00
|
|
|
mEventIsInternal = false;
|
2006-05-23 00:37:32 +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();
|
2006-05-23 00:37:32 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-02-28 18:58:43 +04:00
|
|
|
NS_IMPL_ADDREF_INHERITED(XULCommandEvent, UIEvent)
|
|
|
|
NS_IMPL_RELEASE_INHERITED(XULCommandEvent, UIEvent)
|
2006-05-23 00:37:32 +04:00
|
|
|
|
2014-04-25 20:49:00 +04:00
|
|
|
NS_IMPL_CYCLE_COLLECTION_INHERITED(XULCommandEvent, UIEvent,
|
|
|
|
mSourceEvent)
|
2009-06-30 11:56:40 +04:00
|
|
|
|
2017-08-30 02:02:48 +03:00
|
|
|
NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(XULCommandEvent)
|
2014-02-28 18:58:43 +04:00
|
|
|
NS_INTERFACE_MAP_END_INHERITING(UIEvent)
|
2006-05-23 00:37:32 +04:00
|
|
|
|
2013-10-18 10:10:26 +04:00
|
|
|
bool
|
2014-02-28 18:58:42 +04:00
|
|
|
XULCommandEvent::AltKey()
|
2013-10-18 10:10:26 +04:00
|
|
|
{
|
|
|
|
return mEvent->AsInputEvent()->IsAlt();
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
2014-02-28 18:58:42 +04:00
|
|
|
XULCommandEvent::CtrlKey()
|
2013-10-18 10:10:26 +04:00
|
|
|
{
|
|
|
|
return mEvent->AsInputEvent()->IsControl();
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
2014-02-28 18:58:42 +04:00
|
|
|
XULCommandEvent::ShiftKey()
|
2013-10-18 10:10:26 +04:00
|
|
|
{
|
|
|
|
return mEvent->AsInputEvent()->IsShift();
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
2014-02-28 18:58:42 +04:00
|
|
|
XULCommandEvent::MetaKey()
|
2013-10-18 10:10:26 +04:00
|
|
|
{
|
|
|
|
return mEvent->AsInputEvent()->IsMeta();
|
|
|
|
}
|
|
|
|
|
2017-07-20 18:45:56 +03:00
|
|
|
uint16_t
|
|
|
|
XULCommandEvent::InputSource()
|
|
|
|
{
|
|
|
|
return mInputSource;
|
|
|
|
}
|
|
|
|
|
2018-03-19 22:50:37 +03:00
|
|
|
void
|
2014-02-28 18:58:42 +04:00
|
|
|
XULCommandEvent::InitCommandEvent(const nsAString& aType,
|
|
|
|
bool aCanBubble,
|
|
|
|
bool aCancelable,
|
2018-03-19 22:50:37 +03:00
|
|
|
nsGlobalWindowInner* aView,
|
2014-02-28 18:58:42 +04:00
|
|
|
int32_t aDetail,
|
|
|
|
bool aCtrlKey,
|
|
|
|
bool aAltKey,
|
|
|
|
bool aShiftKey,
|
|
|
|
bool aMetaKey,
|
2018-03-19 22:50:37 +03:00
|
|
|
Event* aSourceEvent,
|
|
|
|
uint16_t aInputSource,
|
|
|
|
ErrorResult& aRv)
|
2006-05-23 00:37:32 +04:00
|
|
|
{
|
2018-03-19 22:50:37 +03:00
|
|
|
if (NS_WARN_IF(mEvent->mFlags.mIsBeingDispatched)) {
|
|
|
|
return;
|
|
|
|
}
|
2016-10-30 22:30:06 +03:00
|
|
|
|
2018-03-19 22:50:37 +03:00
|
|
|
UIEvent::InitUIEvent(aType, aCanBubble, aCancelable, aView, aDetail);
|
2006-05-23 00:37:32 +04:00
|
|
|
|
2013-10-18 10:10:26 +04:00
|
|
|
mEvent->AsInputEvent()->InitBasicModifiers(aCtrlKey, aAltKey,
|
|
|
|
aShiftKey, aMetaKey);
|
2009-06-30 11:56:40 +04:00
|
|
|
mSourceEvent = aSourceEvent;
|
2017-07-20 18:45:56 +03:00
|
|
|
mInputSource = aInputSource;
|
2006-05-23 00:37:32 +04:00
|
|
|
}
|
|
|
|
|
2014-02-28 18:58:42 +04:00
|
|
|
} // namespace dom
|
|
|
|
} // namespace mozilla
|
|
|
|
|
|
|
|
using namespace mozilla;
|
|
|
|
using namespace mozilla::dom;
|
2006-05-23 00:37:32 +04:00
|
|
|
|
2015-08-12 14:39:31 +03:00
|
|
|
already_AddRefed<XULCommandEvent>
|
|
|
|
NS_NewDOMXULCommandEvent(EventTarget* aOwner,
|
2014-02-28 18:58:42 +04:00
|
|
|
nsPresContext* aPresContext,
|
2017-07-06 15:00:35 +03:00
|
|
|
WidgetInputEvent* aEvent)
|
2006-05-23 00:37:32 +04:00
|
|
|
{
|
2015-10-18 08:24:48 +03:00
|
|
|
RefPtr<XULCommandEvent> it =
|
2015-08-12 14:39:31 +03:00
|
|
|
new XULCommandEvent(aOwner, aPresContext, aEvent);
|
|
|
|
return it.forget();
|
2006-05-23 00:37:32 +04:00
|
|
|
}
|