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
|
|
|
|
2012-07-01 16:45:59 -07:00
|
|
|
#include "nsDOMClassInfoID.h"
|
2007-03-22 10:30:00 -07:00
|
|
|
#include "nsDOMXULCommandEvent.h"
|
|
|
|
|
|
|
|
nsDOMXULCommandEvent::nsDOMXULCommandEvent(nsPresContext* aPresContext,
|
2009-06-30 00:56:40 -07:00
|
|
|
nsInputEvent* aEvent)
|
2007-03-22 10:30:00 -07:00
|
|
|
: nsDOMUIEvent(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();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-06-30 00:56:40 -07:00
|
|
|
NS_IMPL_CYCLE_COLLECTION_CLASS(nsDOMXULCommandEvent)
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
NS_IMPL_ADDREF_INHERITED(nsDOMXULCommandEvent, nsDOMUIEvent)
|
|
|
|
NS_IMPL_RELEASE_INHERITED(nsDOMXULCommandEvent, nsDOMUIEvent)
|
|
|
|
|
2009-06-30 00:56:40 -07:00
|
|
|
NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN_INHERITED(nsDOMXULCommandEvent,
|
|
|
|
nsDOMUIEvent)
|
|
|
|
NS_IMPL_CYCLE_COLLECTION_UNLINK_NSCOMPTR(mSourceEvent)
|
|
|
|
NS_IMPL_CYCLE_COLLECTION_UNLINK_END
|
|
|
|
|
|
|
|
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_INHERITED(nsDOMXULCommandEvent,
|
|
|
|
nsDOMUIEvent)
|
|
|
|
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_NSCOMPTR(mSourceEvent)
|
|
|
|
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END
|
|
|
|
|
2010-01-12 05:08:43 -08:00
|
|
|
DOMCI_DATA(XULCommandEvent, nsDOMXULCommandEvent)
|
|
|
|
|
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)
|
2010-03-17 08:09:05 -07:00
|
|
|
NS_DOM_INTERFACE_MAP_ENTRY_CLASSINFO(XULCommandEvent)
|
2007-03-22 10:30:00 -07:00
|
|
|
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);
|
2012-04-24 20:00:02 -07:00
|
|
|
*aIsDown = Event()->IsAlt();
|
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);
|
2012-04-24 20:00:02 -07:00
|
|
|
*aIsDown = Event()->IsControl();
|
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);
|
2012-04-24 20:00:02 -07:00
|
|
|
*aIsDown = Event()->IsShift();
|
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);
|
2012-04-24 20:00:02 -07:00
|
|
|
*aIsDown = Event()->IsMeta();
|
2007-03-22 10:30:00 -07:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsDOMXULCommandEvent::GetSourceEvent(nsIDOMEvent** aSourceEvent)
|
|
|
|
{
|
|
|
|
NS_ENSURE_ARG_POINTER(aSourceEvent);
|
2009-06-30 00:56:40 -07:00
|
|
|
NS_IF_ADDREF(*aSourceEvent = mSourceEvent);
|
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,
|
2007-03-22 10:30:00 -07:00
|
|
|
PRInt32 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,
|
|
|
|
nsPresContext* aPresContext,
|
2009-06-30 00:56:40 -07:00
|
|
|
nsInputEvent *aEvent)
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
|
|
|
nsDOMXULCommandEvent* it = new nsDOMXULCommandEvent(aPresContext, aEvent);
|
|
|
|
return CallQueryInterface(it, aInstancePtrResult);
|
|
|
|
}
|