2015-05-03 19:32:37 +00: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 11:12:37 +00: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-22 20:37:32 +00:00
|
|
|
|
2014-02-28 14:58:42 +00:00
|
|
|
#include "mozilla/dom/XULCommandEvent.h"
|
2013-07-03 15:56:26 +00:00
|
|
|
#include "prtime.h"
|
2006-05-22 20:37:32 +00:00
|
|
|
|
2014-02-28 14:58:42 +00:00
|
|
|
namespace mozilla {
|
|
|
|
namespace dom {
|
2013-10-01 07:23:02 +00:00
|
|
|
|
2014-02-28 14:58:42 +00:00
|
|
|
XULCommandEvent::XULCommandEvent(EventTarget* aOwner,
|
|
|
|
nsPresContext* aPresContext,
|
|
|
|
WidgetInputEvent* aEvent)
|
2014-02-28 14:58:43 +00:00
|
|
|
: UIEvent(aOwner, aPresContext,
|
2015-08-26 12:56:59 +00:00
|
|
|
aEvent ? aEvent :
|
2015-08-28 23:58:26 +00:00
|
|
|
new WidgetInputEvent(false, eVoidEvent, nullptr))
|
2006-05-22 20:37:32 +00:00
|
|
|
{
|
|
|
|
if (aEvent) {
|
2011-10-17 14:59:28 +00:00
|
|
|
mEventIsInternal = false;
|
2006-05-22 20:37:32 +00:00
|
|
|
}
|
|
|
|
else {
|
2011-10-17 14:59:28 +00:00
|
|
|
mEventIsInternal = true;
|
2016-03-28 04:29:42 +00:00
|
|
|
mEvent->mTime = PR_Now();
|
2006-05-22 20:37:32 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-02-28 14:58:43 +00:00
|
|
|
NS_IMPL_ADDREF_INHERITED(XULCommandEvent, UIEvent)
|
|
|
|
NS_IMPL_RELEASE_INHERITED(XULCommandEvent, UIEvent)
|
2006-05-22 20:37:32 +00:00
|
|
|
|
2014-04-25 16:49:00 +00:00
|
|
|
NS_IMPL_CYCLE_COLLECTION_INHERITED(XULCommandEvent, UIEvent,
|
|
|
|
mSourceEvent)
|
2009-06-30 07:56:40 +00:00
|
|
|
|
2014-02-28 14:58:42 +00:00
|
|
|
NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION_INHERITED(XULCommandEvent)
|
2006-05-22 20:37:32 +00:00
|
|
|
NS_INTERFACE_MAP_ENTRY(nsIDOMXULCommandEvent)
|
2014-02-28 14:58:43 +00:00
|
|
|
NS_INTERFACE_MAP_END_INHERITING(UIEvent)
|
2006-05-22 20:37:32 +00:00
|
|
|
|
2013-10-18 06:10:26 +00:00
|
|
|
bool
|
2014-02-28 14:58:42 +00:00
|
|
|
XULCommandEvent::AltKey()
|
2013-10-18 06:10:26 +00:00
|
|
|
{
|
|
|
|
return mEvent->AsInputEvent()->IsAlt();
|
|
|
|
}
|
|
|
|
|
2006-05-22 20:37:32 +00:00
|
|
|
NS_IMETHODIMP
|
2014-02-28 14:58:42 +00:00
|
|
|
XULCommandEvent::GetAltKey(bool* aIsDown)
|
2006-05-22 20:37:32 +00:00
|
|
|
{
|
|
|
|
NS_ENSURE_ARG_POINTER(aIsDown);
|
2013-03-28 14:19:10 +00:00
|
|
|
*aIsDown = AltKey();
|
2006-05-22 20:37:32 +00:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2013-10-18 06:10:26 +00:00
|
|
|
bool
|
2014-02-28 14:58:42 +00:00
|
|
|
XULCommandEvent::CtrlKey()
|
2013-10-18 06:10:26 +00:00
|
|
|
{
|
|
|
|
return mEvent->AsInputEvent()->IsControl();
|
|
|
|
}
|
|
|
|
|
2006-05-22 20:37:32 +00:00
|
|
|
NS_IMETHODIMP
|
2014-02-28 14:58:42 +00:00
|
|
|
XULCommandEvent::GetCtrlKey(bool* aIsDown)
|
2006-05-22 20:37:32 +00:00
|
|
|
{
|
|
|
|
NS_ENSURE_ARG_POINTER(aIsDown);
|
2013-03-28 14:19:10 +00:00
|
|
|
*aIsDown = CtrlKey();
|
2006-05-22 20:37:32 +00:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2013-10-18 06:10:26 +00:00
|
|
|
bool
|
2014-02-28 14:58:42 +00:00
|
|
|
XULCommandEvent::ShiftKey()
|
2013-10-18 06:10:26 +00:00
|
|
|
{
|
|
|
|
return mEvent->AsInputEvent()->IsShift();
|
|
|
|
}
|
|
|
|
|
2006-05-22 20:37:32 +00:00
|
|
|
NS_IMETHODIMP
|
2014-02-28 14:58:42 +00:00
|
|
|
XULCommandEvent::GetShiftKey(bool* aIsDown)
|
2006-05-22 20:37:32 +00:00
|
|
|
{
|
|
|
|
NS_ENSURE_ARG_POINTER(aIsDown);
|
2013-03-28 14:19:10 +00:00
|
|
|
*aIsDown = ShiftKey();
|
2006-05-22 20:37:32 +00:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2013-10-18 06:10:26 +00:00
|
|
|
bool
|
2014-02-28 14:58:42 +00:00
|
|
|
XULCommandEvent::MetaKey()
|
2013-10-18 06:10:26 +00:00
|
|
|
{
|
|
|
|
return mEvent->AsInputEvent()->IsMeta();
|
|
|
|
}
|
|
|
|
|
2006-05-22 20:37:32 +00:00
|
|
|
NS_IMETHODIMP
|
2014-02-28 14:58:42 +00:00
|
|
|
XULCommandEvent::GetMetaKey(bool* aIsDown)
|
2006-05-22 20:37:32 +00:00
|
|
|
{
|
|
|
|
NS_ENSURE_ARG_POINTER(aIsDown);
|
2013-03-28 14:19:10 +00:00
|
|
|
*aIsDown = MetaKey();
|
2006-05-22 20:37:32 +00:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2014-02-28 14:58:42 +00:00
|
|
|
XULCommandEvent::GetSourceEvent(nsIDOMEvent** aSourceEvent)
|
2006-05-22 20:37:32 +00:00
|
|
|
{
|
|
|
|
NS_ENSURE_ARG_POINTER(aSourceEvent);
|
2014-03-15 19:00:15 +00:00
|
|
|
nsCOMPtr<nsIDOMEvent> event = GetSourceEvent();
|
|
|
|
event.forget(aSourceEvent);
|
2006-05-22 20:37:32 +00:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2014-02-28 14:58:42 +00:00
|
|
|
XULCommandEvent::InitCommandEvent(const nsAString& aType,
|
|
|
|
bool aCanBubble,
|
|
|
|
bool aCancelable,
|
2016-01-30 17:05:36 +00:00
|
|
|
mozIDOMWindow* aView,
|
2014-02-28 14:58:42 +00:00
|
|
|
int32_t aDetail,
|
|
|
|
bool aCtrlKey,
|
|
|
|
bool aAltKey,
|
|
|
|
bool aShiftKey,
|
|
|
|
bool aMetaKey,
|
|
|
|
nsIDOMEvent* aSourceEvent)
|
2006-05-22 20:37:32 +00:00
|
|
|
{
|
2016-10-30 19:30:06 +00:00
|
|
|
NS_ENSURE_TRUE(!mEvent->mFlags.mIsBeingDispatched, NS_OK);
|
|
|
|
|
2016-01-30 17:05:36 +00:00
|
|
|
auto* view = nsGlobalWindow::Cast(nsPIDOMWindowInner::From(aView));
|
|
|
|
UIEvent::InitUIEvent(aType, aCanBubble, aCancelable, view, aDetail);
|
2006-05-22 20:37:32 +00:00
|
|
|
|
2013-10-18 06:10:26 +00:00
|
|
|
mEvent->AsInputEvent()->InitBasicModifiers(aCtrlKey, aAltKey,
|
|
|
|
aShiftKey, aMetaKey);
|
2009-06-30 07:56:40 +00:00
|
|
|
mSourceEvent = aSourceEvent;
|
2006-05-22 20:37:32 +00:00
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2014-02-28 14:58:42 +00:00
|
|
|
} // namespace dom
|
|
|
|
} // namespace mozilla
|
|
|
|
|
|
|
|
using namespace mozilla;
|
|
|
|
using namespace mozilla::dom;
|
2006-05-22 20:37:32 +00:00
|
|
|
|
2015-08-12 11:39:31 +00:00
|
|
|
already_AddRefed<XULCommandEvent>
|
|
|
|
NS_NewDOMXULCommandEvent(EventTarget* aOwner,
|
2014-02-28 14:58:42 +00:00
|
|
|
nsPresContext* aPresContext,
|
|
|
|
WidgetInputEvent* aEvent)
|
2006-05-22 20:37:32 +00:00
|
|
|
{
|
2015-10-18 05:24:48 +00:00
|
|
|
RefPtr<XULCommandEvent> it =
|
2015-08-12 11:39:31 +00:00
|
|
|
new XULCommandEvent(aOwner, aPresContext, aEvent);
|
|
|
|
return it.forget();
|
2006-05-22 20:37:32 +00:00
|
|
|
}
|