2007-03-22 10:30:00 -07:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
|
|
/* vim:set ts=2 sw=2 sts=2 et cindent: */
|
2012-05-21 04:12:37 -07: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/. */
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
#include "nsDOMXULCommandEvent.h"
|
2013-07-03 08:56:26 -07:00
|
|
|
#include "prtime.h"
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2013-03-09 03:34:29 -08:00
|
|
|
nsDOMXULCommandEvent::nsDOMXULCommandEvent(mozilla::dom::EventTarget* aOwner,
|
|
|
|
nsPresContext* aPresContext,
|
2009-06-30 00:56:40 -07:00
|
|
|
nsInputEvent* aEvent)
|
2013-03-09 03:34:29 -08:00
|
|
|
: nsDOMUIEvent(aOwner, aPresContext,
|
2012-07-30 07:20:58 -07:00
|
|
|
aEvent ? aEvent : new nsInputEvent(false, 0, nullptr))
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
|
|
|
if (aEvent) {
|
2011-10-17 07:59:28 -07:00
|
|
|
mEventIsInternal = false;
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
else {
|
2011-10-17 07:59:28 -07:00
|
|
|
mEventIsInternal = true;
|
2007-03-22 10:30:00 -07:00
|
|
|
mEvent->time = PR_Now();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMPL_ADDREF_INHERITED(nsDOMXULCommandEvent, nsDOMUIEvent)
|
|
|
|
NS_IMPL_RELEASE_INHERITED(nsDOMXULCommandEvent, nsDOMUIEvent)
|
|
|
|
|
2013-05-21 16:23:53 -07:00
|
|
|
NS_IMPL_CYCLE_COLLECTION_INHERITED_1(nsDOMXULCommandEvent, nsDOMUIEvent,
|
|
|
|
mSourceEvent)
|
2009-06-30 00:56:40 -07:00
|
|
|
|
|
|
|
NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION_INHERITED(nsDOMXULCommandEvent)
|
2007-03-22 10:30:00 -07:00
|
|
|
NS_INTERFACE_MAP_ENTRY(nsIDOMXULCommandEvent)
|
|
|
|
NS_INTERFACE_MAP_END_INHERITING(nsDOMUIEvent)
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2011-09-28 23:19:26 -07:00
|
|
|
nsDOMXULCommandEvent::GetAltKey(bool* aIsDown)
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
|
|
|
NS_ENSURE_ARG_POINTER(aIsDown);
|
2013-03-28 07:19:10 -07:00
|
|
|
*aIsDown = AltKey();
|
2007-03-22 10:30:00 -07:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2011-09-28 23:19:26 -07:00
|
|
|
nsDOMXULCommandEvent::GetCtrlKey(bool* aIsDown)
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
|
|
|
NS_ENSURE_ARG_POINTER(aIsDown);
|
2013-03-28 07:19:10 -07:00
|
|
|
*aIsDown = CtrlKey();
|
2007-03-22 10:30:00 -07:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2011-09-28 23:19:26 -07:00
|
|
|
nsDOMXULCommandEvent::GetShiftKey(bool* aIsDown)
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
|
|
|
NS_ENSURE_ARG_POINTER(aIsDown);
|
2013-03-28 07:19:10 -07:00
|
|
|
*aIsDown = ShiftKey();
|
2007-03-22 10:30:00 -07:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2011-09-28 23:19:26 -07:00
|
|
|
nsDOMXULCommandEvent::GetMetaKey(bool* aIsDown)
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
|
|
|
NS_ENSURE_ARG_POINTER(aIsDown);
|
2013-03-28 07:19:10 -07:00
|
|
|
*aIsDown = MetaKey();
|
2007-03-22 10:30:00 -07:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsDOMXULCommandEvent::GetSourceEvent(nsIDOMEvent** aSourceEvent)
|
|
|
|
{
|
|
|
|
NS_ENSURE_ARG_POINTER(aSourceEvent);
|
2013-03-28 07:19:10 -07:00
|
|
|
*aSourceEvent = GetSourceEvent().get();
|
2007-03-22 10:30:00 -07:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsDOMXULCommandEvent::InitCommandEvent(const nsAString& aType,
|
2011-09-28 23:19:26 -07:00
|
|
|
bool aCanBubble, bool aCancelable,
|
2011-04-23 23:54:25 -07:00
|
|
|
nsIDOMWindow* aView,
|
2012-08-22 08:56:38 -07:00
|
|
|
int32_t aDetail,
|
2011-09-28 23:19:26 -07:00
|
|
|
bool aCtrlKey, bool aAltKey,
|
|
|
|
bool aShiftKey, bool aMetaKey,
|
2007-03-22 10:30:00 -07:00
|
|
|
nsIDOMEvent* aSourceEvent)
|
|
|
|
{
|
|
|
|
nsresult rv = nsDOMUIEvent::InitUIEvent(aType, aCanBubble, aCancelable,
|
|
|
|
aView, aDetail);
|
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
|
|
|
|
2012-04-24 20:00:02 -07:00
|
|
|
Event()->InitBasicModifiers(aCtrlKey, aAltKey, aShiftKey, aMetaKey);
|
2009-06-30 00:56:40 -07:00
|
|
|
mSourceEvent = aSourceEvent;
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
nsresult NS_NewDOMXULCommandEvent(nsIDOMEvent** aInstancePtrResult,
|
2013-03-09 03:34:29 -08:00
|
|
|
mozilla::dom::EventTarget* aOwner,
|
2007-03-22 10:30:00 -07:00
|
|
|
nsPresContext* aPresContext,
|
2009-06-30 00:56:40 -07:00
|
|
|
nsInputEvent *aEvent)
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
2013-03-09 03:34:29 -08:00
|
|
|
nsDOMXULCommandEvent* it =
|
|
|
|
new nsDOMXULCommandEvent(aOwner, aPresContext, aEvent);
|
2007-03-22 10:30:00 -07:00
|
|
|
return CallQueryInterface(it, aInstancePtrResult);
|
|
|
|
}
|