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
|
|
|
{
|
2016-03-28 07:29:42 +03:00
|
|
|
mEvent->mTime = PR_Now();
|
2006-12-01 14:09:53 +03:00
|
|
|
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
|
|
|
{
|
2016-05-12 07:28:31 +03:00
|
|
|
nsIAtom* command = mEvent->AsCommandEvent()->mCommand;
|
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
|
|
|
{
|
2016-10-30 22:30:06 +03:00
|
|
|
NS_ENSURE_TRUE(!mEvent->mFlags.mIsBeingDispatched, NS_OK);
|
|
|
|
|
2015-11-13 03:09:42 +03:00
|
|
|
Event::InitEvent(aTypeArg, aCanBubbleArg, aCancelableArg);
|
2006-12-01 14:09:53 +03:00
|
|
|
|
2016-05-12 07:28:31 +03:00
|
|
|
mEvent->AsCommandEvent()->mCommand = NS_Atomize(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
|
|
|
}
|