1 : /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 : /* vim:set ts=2 sw=2 sts=2 et cindent: */
3 : /* ***** BEGIN LICENSE BLOCK *****
4 : * Version: MPL 1.1/GPL 2.0/LGPL 2.1
5 : *
6 : * The contents of this file are subject to the Mozilla Public License Version
7 : * 1.1 (the "License"); you may not use this file except in compliance with
8 : * the License. You may obtain a copy of the License at
9 : * http://www.mozilla.org/MPL/
10 : *
11 : * Software distributed under the License is distributed on an "AS IS" basis,
12 : * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
13 : * for the specific language governing rights and limitations under the
14 : * License.
15 : *
16 : * The Original Code is Gecko.
17 : *
18 : * The Initial Developer of the Original Code is Google Inc.
19 : * Portions created by the Initial Developer are Copyright (C) 2006
20 : * the Initial Developer. All Rights Reserved.
21 : *
22 : * Contributor(s):
23 : * Brian Ryner <bryner@brianryner.com>
24 : *
25 : * Alternatively, the contents of this file may be used under the terms of
26 : * either the GNU General Public License Version 2 or later (the "GPL"), or
27 : * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
28 : * in which case the provisions of the GPL or the LGPL are applicable instead
29 : * of those above. If you wish to allow use of your version of this file only
30 : * under the terms of either the GPL or the LGPL, and not to allow others to
31 : * use your version of this file under the terms of the MPL, indicate your
32 : * decision by deleting the provisions above and replace them with the notice
33 : * and other provisions required by the GPL or the LGPL. If you do not delete
34 : * the provisions above, a recipient may use your version of this file under
35 : * the terms of any one of the MPL, the GPL or the LGPL.
36 : *
37 : * ***** END LICENSE BLOCK ***** */
38 :
39 : #include "nsDOMXULCommandEvent.h"
40 : #include "nsContentUtils.h"
41 :
42 0 : nsDOMXULCommandEvent::nsDOMXULCommandEvent(nsPresContext* aPresContext,
43 : nsInputEvent* aEvent)
44 : : nsDOMUIEvent(aPresContext,
45 0 : aEvent ? aEvent : new nsInputEvent(false, 0, nsnull))
46 : {
47 0 : if (aEvent) {
48 0 : mEventIsInternal = false;
49 : }
50 : else {
51 0 : mEventIsInternal = true;
52 0 : mEvent->time = PR_Now();
53 : }
54 0 : }
55 :
56 1464 : NS_IMPL_CYCLE_COLLECTION_CLASS(nsDOMXULCommandEvent)
57 :
58 0 : NS_IMPL_ADDREF_INHERITED(nsDOMXULCommandEvent, nsDOMUIEvent)
59 0 : NS_IMPL_RELEASE_INHERITED(nsDOMXULCommandEvent, nsDOMUIEvent)
60 :
61 0 : NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN_INHERITED(nsDOMXULCommandEvent,
62 : nsDOMUIEvent)
63 0 : NS_IMPL_CYCLE_COLLECTION_UNLINK_NSCOMPTR(mSourceEvent)
64 0 : NS_IMPL_CYCLE_COLLECTION_UNLINK_END
65 :
66 0 : NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_INHERITED(nsDOMXULCommandEvent,
67 : nsDOMUIEvent)
68 0 : NS_IMPL_CYCLE_COLLECTION_TRAVERSE_NSCOMPTR(mSourceEvent)
69 0 : NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END
70 :
71 : DOMCI_DATA(XULCommandEvent, nsDOMXULCommandEvent)
72 :
73 0 : NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION_INHERITED(nsDOMXULCommandEvent)
74 0 : NS_INTERFACE_MAP_ENTRY(nsIDOMXULCommandEvent)
75 0 : NS_DOM_INTERFACE_MAP_ENTRY_CLASSINFO(XULCommandEvent)
76 0 : NS_INTERFACE_MAP_END_INHERITING(nsDOMUIEvent)
77 :
78 : NS_IMETHODIMP
79 0 : nsDOMXULCommandEvent::GetAltKey(bool* aIsDown)
80 : {
81 0 : NS_ENSURE_ARG_POINTER(aIsDown);
82 0 : *aIsDown = Event()->isAlt;
83 0 : return NS_OK;
84 : }
85 :
86 : NS_IMETHODIMP
87 0 : nsDOMXULCommandEvent::GetCtrlKey(bool* aIsDown)
88 : {
89 0 : NS_ENSURE_ARG_POINTER(aIsDown);
90 0 : *aIsDown = Event()->isControl;
91 0 : return NS_OK;
92 : }
93 :
94 : NS_IMETHODIMP
95 0 : nsDOMXULCommandEvent::GetShiftKey(bool* aIsDown)
96 : {
97 0 : NS_ENSURE_ARG_POINTER(aIsDown);
98 0 : *aIsDown = Event()->isShift;
99 0 : return NS_OK;
100 : }
101 :
102 : NS_IMETHODIMP
103 0 : nsDOMXULCommandEvent::GetMetaKey(bool* aIsDown)
104 : {
105 0 : NS_ENSURE_ARG_POINTER(aIsDown);
106 0 : *aIsDown = Event()->isMeta;
107 0 : return NS_OK;
108 : }
109 :
110 : NS_IMETHODIMP
111 0 : nsDOMXULCommandEvent::GetSourceEvent(nsIDOMEvent** aSourceEvent)
112 : {
113 0 : NS_ENSURE_ARG_POINTER(aSourceEvent);
114 0 : NS_IF_ADDREF(*aSourceEvent = mSourceEvent);
115 0 : return NS_OK;
116 : }
117 :
118 : NS_IMETHODIMP
119 0 : nsDOMXULCommandEvent::InitCommandEvent(const nsAString& aType,
120 : bool aCanBubble, bool aCancelable,
121 : nsIDOMWindow* aView,
122 : PRInt32 aDetail,
123 : bool aCtrlKey, bool aAltKey,
124 : bool aShiftKey, bool aMetaKey,
125 : nsIDOMEvent* aSourceEvent)
126 : {
127 : nsresult rv = nsDOMUIEvent::InitUIEvent(aType, aCanBubble, aCancelable,
128 0 : aView, aDetail);
129 0 : NS_ENSURE_SUCCESS(rv, rv);
130 :
131 0 : nsInputEvent *event = Event();
132 0 : event->isControl = aCtrlKey;
133 0 : event->isAlt = aAltKey;
134 0 : event->isShift = aShiftKey;
135 0 : event->isMeta = aMetaKey;
136 0 : mSourceEvent = aSourceEvent;
137 :
138 0 : return NS_OK;
139 : }
140 :
141 :
142 0 : nsresult NS_NewDOMXULCommandEvent(nsIDOMEvent** aInstancePtrResult,
143 : nsPresContext* aPresContext,
144 : nsInputEvent *aEvent)
145 : {
146 0 : nsDOMXULCommandEvent* it = new nsDOMXULCommandEvent(aPresContext, aEvent);
147 0 : return CallQueryInterface(it, aInstancePtrResult);
148 4392 : }
|