2006-12-01 11:09:53 +00:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
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-12-01 11:09:53 +00:00
|
|
|
|
|
|
|
#include "nsDOMCommandEvent.h"
|
2013-07-03 15:56:26 +00:00
|
|
|
#include "prtime.h"
|
2013-09-25 11:21:20 +00:00
|
|
|
#include "mozilla/MiscEvents.h"
|
2006-12-01 11:09:53 +00:00
|
|
|
|
2013-09-27 06:20:54 +00:00
|
|
|
using namespace mozilla;
|
|
|
|
|
2013-03-09 11:34:29 +00:00
|
|
|
nsDOMCommandEvent::nsDOMCommandEvent(mozilla::dom::EventTarget* aOwner,
|
|
|
|
nsPresContext* aPresContext,
|
2013-09-27 06:20:54 +00:00
|
|
|
WidgetCommandEvent* aEvent)
|
2013-03-09 11:34:29 +00:00
|
|
|
: nsDOMEvent(aOwner, aPresContext, aEvent ? aEvent :
|
2013-09-27 06:20:54 +00:00
|
|
|
new WidgetCommandEvent(false, nullptr, nullptr, nullptr))
|
2006-12-01 11:09:53 +00:00
|
|
|
{
|
|
|
|
mEvent->time = PR_Now();
|
|
|
|
if (aEvent) {
|
2011-10-17 14:59:28 +00:00
|
|
|
mEventIsInternal = false;
|
2006-12-01 11:09:53 +00:00
|
|
|
} else {
|
2011-10-17 14:59:28 +00:00
|
|
|
mEventIsInternal = true;
|
2006-12-01 11:09:53 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_INTERFACE_MAP_BEGIN(nsDOMCommandEvent)
|
|
|
|
NS_INTERFACE_MAP_ENTRY(nsIDOMCommandEvent)
|
|
|
|
NS_INTERFACE_MAP_END_INHERITING(nsDOMEvent)
|
|
|
|
|
|
|
|
NS_IMPL_ADDREF_INHERITED(nsDOMCommandEvent, nsDOMEvent)
|
|
|
|
NS_IMPL_RELEASE_INHERITED(nsDOMCommandEvent, nsDOMEvent)
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsDOMCommandEvent::GetCommand(nsAString& aCommand)
|
|
|
|
{
|
2013-10-18 06:10:23 +00:00
|
|
|
nsIAtom* command = mEvent->AsCommandEvent()->command;
|
2006-12-01 11:09:53 +00:00
|
|
|
if (command) {
|
|
|
|
command->ToString(aCommand);
|
|
|
|
} else {
|
|
|
|
aCommand.Truncate();
|
|
|
|
}
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsDOMCommandEvent::InitCommandEvent(const nsAString& aTypeArg,
|
2011-09-29 06:19:26 +00:00
|
|
|
bool aCanBubbleArg,
|
|
|
|
bool aCancelableArg,
|
2006-12-01 11:09:53 +00:00
|
|
|
const nsAString& aCommand)
|
|
|
|
{
|
|
|
|
nsresult rv = nsDOMEvent::InitEvent(aTypeArg, aCanBubbleArg, aCancelableArg);
|
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
|
|
|
|
2013-10-18 06:10:23 +00:00
|
|
|
mEvent->AsCommandEvent()->command = do_GetAtom(aCommand);
|
2006-12-01 11:09:53 +00:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsresult NS_NewDOMCommandEvent(nsIDOMEvent** aInstancePtrResult,
|
2013-03-09 11:34:29 +00:00
|
|
|
mozilla::dom::EventTarget* aOwner,
|
2006-12-01 11:09:53 +00:00
|
|
|
nsPresContext* aPresContext,
|
2013-09-27 06:20:54 +00:00
|
|
|
WidgetCommandEvent* aEvent)
|
2006-12-01 11:09:53 +00:00
|
|
|
{
|
2013-03-09 11:34:29 +00:00
|
|
|
nsDOMCommandEvent* it = new nsDOMCommandEvent(aOwner, aPresContext, aEvent);
|
2006-12-01 11:09:53 +00:00
|
|
|
|
|
|
|
return CallQueryInterface(it, aInstancePtrResult);
|
|
|
|
}
|