Work at SourceForge, help us to make it a better place! We have an immediate need for a Support Technician in our San Francisco or Denver office.

Close

[b9b36e]: content / events / src / nsDOMCommandEvent.cpp Maximize Restore History

Repo status: analyzing...

Download this file

nsDOMCommandEvent.cpp    74 lines (63 with data), 2.3 kB

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* 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/. */
#include "nsDOMCommandEvent.h"
nsDOMCommandEvent::nsDOMCommandEvent(mozilla::dom::EventTarget* aOwner,
nsPresContext* aPresContext,
nsCommandEvent* aEvent)
: nsDOMEvent(aOwner, aPresContext, aEvent ? aEvent :
new nsCommandEvent(false, nullptr, nullptr, nullptr))
{
mEvent->time = PR_Now();
if (aEvent) {
mEventIsInternal = false;
} else {
mEventIsInternal = true;
}
}
nsDOMCommandEvent::~nsDOMCommandEvent()
{
if (mEventIsInternal && mEvent->eventStructType == NS_COMMAND_EVENT) {
delete static_cast<nsCommandEvent*>(mEvent);
mEvent = nullptr;
}
}
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)
{
nsIAtom* command = static_cast<nsCommandEvent*>(mEvent)->command;
if (command) {
command->ToString(aCommand);
} else {
aCommand.Truncate();
}
return NS_OK;
}
NS_IMETHODIMP
nsDOMCommandEvent::InitCommandEvent(const nsAString& aTypeArg,
bool aCanBubbleArg,
bool aCancelableArg,
const nsAString& aCommand)
{
nsresult rv = nsDOMEvent::InitEvent(aTypeArg, aCanBubbleArg, aCancelableArg);
NS_ENSURE_SUCCESS(rv, rv);
static_cast<nsCommandEvent*>(mEvent)->command = do_GetAtom(aCommand);
return NS_OK;
}
nsresult NS_NewDOMCommandEvent(nsIDOMEvent** aInstancePtrResult,
mozilla::dom::EventTarget* aOwner,
nsPresContext* aPresContext,
nsCommandEvent* aEvent)
{
nsDOMCommandEvent* it = new nsDOMCommandEvent(aOwner, aPresContext, aEvent);
if (nullptr == it) {
return NS_ERROR_OUT_OF_MEMORY;
}
return CallQueryInterface(it, aInstancePtrResult);
}