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)
|
2014-02-28 18:58:43 +04:00
|
|
|
: UIEvent(aOwner, aPresContext,
|
|
|
|
aEvent ? aEvent : new WidgetInputEvent(false, 0, nullptr))
|
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;
|
2006-05-23 00:37:32 +04:00
|
|
|
mEvent->time = PR_Now();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
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
|
|
|
|
2014-02-28 18:58:42 +04:00
|
|
|
NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION_INHERITED(XULCommandEvent)
|
2006-05-23 00:37:32 +04:00
|
|
|
NS_INTERFACE_MAP_ENTRY(nsIDOMXULCommandEvent)
|
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();
|
|
|
|
}
|
|
|
|
|
2006-05-23 00:37:32 +04:00
|
|
|
NS_IMETHODIMP
|
2014-02-28 18:58:42 +04:00
|
|
|
XULCommandEvent::GetAltKey(bool* aIsDown)
|
2006-05-23 00:37:32 +04:00
|
|
|
{
|
|
|
|
NS_ENSURE_ARG_POINTER(aIsDown);
|
2013-03-28 18:19:10 +04:00
|
|
|
*aIsDown = AltKey();
|
2006-05-23 00:37:32 +04:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2013-10-18 10:10:26 +04:00
|
|
|
bool
|
2014-02-28 18:58:42 +04:00
|
|
|
XULCommandEvent::CtrlKey()
|
2013-10-18 10:10:26 +04:00
|
|
|
{
|
|
|
|
return mEvent->AsInputEvent()->IsControl();
|
|
|
|
}
|
|
|
|
|
2006-05-23 00:37:32 +04:00
|
|
|
NS_IMETHODIMP
|
2014-02-28 18:58:42 +04:00
|
|
|
XULCommandEvent::GetCtrlKey(bool* aIsDown)
|
2006-05-23 00:37:32 +04:00
|
|
|
{
|
|
|
|
NS_ENSURE_ARG_POINTER(aIsDown);
|
2013-03-28 18:19:10 +04:00
|
|
|
*aIsDown = CtrlKey();
|
2006-05-23 00:37:32 +04:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2013-10-18 10:10:26 +04:00
|
|
|
bool
|
2014-02-28 18:58:42 +04:00
|
|
|
XULCommandEvent::ShiftKey()
|
2013-10-18 10:10:26 +04:00
|
|
|
{
|
|
|
|
return mEvent->AsInputEvent()->IsShift();
|
|
|
|
}
|
|
|
|
|
2006-05-23 00:37:32 +04:00
|
|
|
NS_IMETHODIMP
|
2014-02-28 18:58:42 +04:00
|
|
|
XULCommandEvent::GetShiftKey(bool* aIsDown)
|
2006-05-23 00:37:32 +04:00
|
|
|
{
|
|
|
|
NS_ENSURE_ARG_POINTER(aIsDown);
|
2013-03-28 18:19:10 +04:00
|
|
|
*aIsDown = ShiftKey();
|
2006-05-23 00:37:32 +04:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2013-10-18 10:10:26 +04:00
|
|
|
bool
|
2014-02-28 18:58:42 +04:00
|
|
|
XULCommandEvent::MetaKey()
|
2013-10-18 10:10:26 +04:00
|
|
|
{
|
|
|
|
return mEvent->AsInputEvent()->IsMeta();
|
|
|
|
}
|
|
|
|
|
2006-05-23 00:37:32 +04:00
|
|
|
NS_IMETHODIMP
|
2014-02-28 18:58:42 +04:00
|
|
|
XULCommandEvent::GetMetaKey(bool* aIsDown)
|
2006-05-23 00:37:32 +04:00
|
|
|
{
|
|
|
|
NS_ENSURE_ARG_POINTER(aIsDown);
|
2013-03-28 18:19:10 +04:00
|
|
|
*aIsDown = MetaKey();
|
2006-05-23 00:37:32 +04:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2014-02-28 18:58:42 +04:00
|
|
|
XULCommandEvent::GetSourceEvent(nsIDOMEvent** aSourceEvent)
|
2006-05-23 00:37:32 +04:00
|
|
|
{
|
|
|
|
NS_ENSURE_ARG_POINTER(aSourceEvent);
|
2014-03-15 23:00:15 +04:00
|
|
|
nsCOMPtr<nsIDOMEvent> event = GetSourceEvent();
|
|
|
|
event.forget(aSourceEvent);
|
2006-05-23 00:37:32 +04:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2014-02-28 18:58:42 +04:00
|
|
|
XULCommandEvent::InitCommandEvent(const nsAString& aType,
|
|
|
|
bool aCanBubble,
|
|
|
|
bool aCancelable,
|
|
|
|
nsIDOMWindow* aView,
|
|
|
|
int32_t aDetail,
|
|
|
|
bool aCtrlKey,
|
|
|
|
bool aAltKey,
|
|
|
|
bool aShiftKey,
|
|
|
|
bool aMetaKey,
|
|
|
|
nsIDOMEvent* aSourceEvent)
|
2006-05-23 00:37:32 +04:00
|
|
|
{
|
2014-02-28 18:58:43 +04:00
|
|
|
nsresult rv = UIEvent::InitUIEvent(aType, aCanBubble, aCancelable,
|
|
|
|
aView, aDetail);
|
2006-05-23 00:37:32 +04:00
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
|
|
|
|
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;
|
2006-05-23 00:37:32 +04:00
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
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
|
|
|
|
2014-02-28 18:58:42 +04:00
|
|
|
nsresult
|
|
|
|
NS_NewDOMXULCommandEvent(nsIDOMEvent** aInstancePtrResult,
|
|
|
|
EventTarget* aOwner,
|
|
|
|
nsPresContext* aPresContext,
|
|
|
|
WidgetInputEvent* aEvent)
|
2006-05-23 00:37:32 +04:00
|
|
|
{
|
2014-02-28 18:58:42 +04:00
|
|
|
XULCommandEvent* it = new XULCommandEvent(aOwner, aPresContext, aEvent);
|
2014-03-18 00:00:11 +04:00
|
|
|
NS_ADDREF(it);
|
|
|
|
*aInstancePtrResult = static_cast<Event*>(it);
|
|
|
|
return NS_OK;
|
2006-05-23 00:37:32 +04:00
|
|
|
}
|