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-12-01 14:09:53 +03:00
|
|
|
|
2014-02-26 09:23:57 +04:00
|
|
|
#include "mozilla/dom/CommandEvent.h"
|
2013-09-25 15:21:20 +04:00
|
|
|
#include "mozilla/MiscEvents.h"
|
2014-02-26 09:23:57 +04:00
|
|
|
#include "prtime.h"
|
2006-12-01 14:09:53 +03:00
|
|
|
|
2014-02-26 09:23:57 +04:00
|
|
|
namespace mozilla {
|
|
|
|
namespace dom {
|
2013-09-27 10:20:54 +04:00
|
|
|
|
2014-02-26 09:23:57 +04:00
|
|
|
CommandEvent::CommandEvent(EventTarget* aOwner,
|
|
|
|
nsPresContext* aPresContext,
|
|
|
|
WidgetCommandEvent* aEvent)
|
2014-03-05 04:37:43 +04:00
|
|
|
: Event(aOwner, aPresContext,
|
|
|
|
aEvent ? aEvent :
|
|
|
|
new WidgetCommandEvent(false, nullptr, nullptr, nullptr))
|
2006-12-01 14:09:53 +03:00
|
|
|
{
|
|
|
|
mEvent->time = PR_Now();
|
|
|
|
if (aEvent) {
|
2011-10-17 18:59:28 +04:00
|
|
|
mEventIsInternal = false;
|
2006-12-01 14:09:53 +03:00
|
|
|
} else {
|
2011-10-17 18:59:28 +04:00
|
|
|
mEventIsInternal = true;
|
2006-12-01 14:09:53 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-02-26 09:23:57 +04:00
|
|
|
NS_INTERFACE_MAP_BEGIN(CommandEvent)
|
2006-12-01 14:09:53 +03:00
|
|
|
NS_INTERFACE_MAP_ENTRY(nsIDOMCommandEvent)
|
2014-03-05 04:37:43 +04:00
|
|
|
NS_INTERFACE_MAP_END_INHERITING(Event)
|
2006-12-01 14:09:53 +03:00
|
|
|
|
2014-03-05 04:37:43 +04:00
|
|
|
NS_IMPL_ADDREF_INHERITED(CommandEvent, Event)
|
|
|
|
NS_IMPL_RELEASE_INHERITED(CommandEvent, Event)
|
2006-12-01 14:09:53 +03:00
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2014-02-26 09:23:57 +04:00
|
|
|
CommandEvent::GetCommand(nsAString& aCommand)
|
2006-12-01 14:09:53 +03:00
|
|
|
{
|
2013-10-18 10:10:23 +04:00
|
|
|
nsIAtom* command = mEvent->AsCommandEvent()->command;
|
2006-12-01 14:09:53 +03:00
|
|
|
if (command) {
|
|
|
|
command->ToString(aCommand);
|
|
|
|
} else {
|
|
|
|
aCommand.Truncate();
|
|
|
|
}
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2014-02-26 09:23:57 +04:00
|
|
|
CommandEvent::InitCommandEvent(const nsAString& aTypeArg,
|
|
|
|
bool aCanBubbleArg,
|
|
|
|
bool aCancelableArg,
|
|
|
|
const nsAString& aCommand)
|
2006-12-01 14:09:53 +03:00
|
|
|
{
|
2015-11-13 03:09:42 +03:00
|
|
|
Event::InitEvent(aTypeArg, aCanBubbleArg, aCancelableArg);
|
2006-12-01 14:09:53 +03:00
|
|
|
|
2013-10-18 10:10:23 +04:00
|
|
|
mEvent->AsCommandEvent()->command = do_GetAtom(aCommand);
|
2006-12-01 14:09:53 +03:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2014-02-26 09:23:57 +04:00
|
|
|
} // namespace dom
|
|
|
|
} // namespace mozilla
|
2006-12-01 14:09:53 +03:00
|
|
|
|
2014-02-26 09:23:57 +04:00
|
|
|
using namespace mozilla;
|
|
|
|
using namespace mozilla::dom;
|
|
|
|
|
2015-08-12 14:39:31 +03:00
|
|
|
already_AddRefed<CommandEvent>
|
|
|
|
NS_NewDOMCommandEvent(EventTarget* aOwner,
|
2014-02-26 09:23:57 +04:00
|
|
|
nsPresContext* aPresContext,
|
|
|
|
WidgetCommandEvent* aEvent)
|
|
|
|
{
|
2015-10-18 08:24:48 +03:00
|
|
|
RefPtr<CommandEvent> it =
|
2015-08-12 14:39:31 +03:00
|
|
|
new CommandEvent(aOwner, aPresContext, aEvent);
|
|
|
|
return it.forget();
|
2006-12-01 14:09:53 +03:00
|
|
|
}
|