1 : /* ***** BEGIN LICENSE BLOCK *****
2 : * Version: MPL 1.1/GPL 2.0/LGPL 2.1
3 : *
4 : * The contents of this file are subject to the Mozilla Public License Version
5 : * 1.1 (the "License"); you may not use this file except in compliance with
6 : * the License. You may obtain a copy of the License at
7 : * http://www.mozilla.org/MPL/
8 : *
9 : * Software distributed under the License is distributed on an "AS IS" basis,
10 : * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
11 : * for the specific language governing rights and limitations under the
12 : * License.
13 : *
14 : * The Original Code is mozilla.org code.
15 : *
16 : * The Initial Developer of the Original Code is
17 : * Doug Turner <dougt@dougt.org>
18 : * Portions created by the Initial Developer are Copyright (C) 2009
19 : * the Initial Developer. All Rights Reserved.
20 : *
21 : * Contributor(s):
22 : *
23 : * Alternatively, the contents of this file may be used under the terms of
24 : * either the GNU General Public License Version 2 or later (the "GPL"), or
25 : * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
26 : * in which case the provisions of the GPL or the LGPL are applicable instead
27 : * of those above. If you wish to allow use of your version of this file only
28 : * under the terms of either the GPL or the LGPL, and not to allow others to
29 : * use your version of this file under the terms of the MPL, indicate your
30 : * decision by deleting the provisions above and replace them with the notice
31 : * and other provisions required by the GPL or the LGPL. If you do not delete
32 : * the provisions above, a recipient may use your version of this file under
33 : * the terms of any one of the MPL, the GPL or the LGPL.
34 : *
35 : * ***** END LICENSE BLOCK ***** */
36 :
37 : #include "nsDOMDeviceOrientationEvent.h"
38 : #include "nsContentUtils.h"
39 :
40 0 : NS_IMPL_ADDREF_INHERITED(nsDOMDeviceOrientationEvent, nsDOMEvent)
41 0 : NS_IMPL_RELEASE_INHERITED(nsDOMDeviceOrientationEvent, nsDOMEvent)
42 :
43 : DOMCI_DATA(DeviceOrientationEvent, nsDOMDeviceOrientationEvent)
44 :
45 0 : NS_INTERFACE_MAP_BEGIN(nsDOMDeviceOrientationEvent)
46 0 : NS_INTERFACE_MAP_ENTRY(nsIDOMDeviceOrientationEvent)
47 0 : NS_DOM_INTERFACE_MAP_ENTRY_CLASSINFO(DeviceOrientationEvent)
48 0 : NS_INTERFACE_MAP_END_INHERITING(nsDOMEvent)
49 :
50 0 : NS_IMETHODIMP nsDOMDeviceOrientationEvent::InitDeviceOrientationEvent(const nsAString & aEventTypeArg,
51 : bool aCanBubbleArg,
52 : bool aCancelableArg,
53 : double aAlpha,
54 : double aBeta,
55 : double aGamma,
56 : bool aAbsolute)
57 : {
58 0 : nsresult rv = nsDOMEvent::InitEvent(aEventTypeArg, aCanBubbleArg, aCancelableArg);
59 0 : NS_ENSURE_SUCCESS(rv, rv);
60 :
61 0 : mAlpha = aAlpha;
62 0 : mBeta = aBeta;
63 0 : mGamma = aGamma;
64 0 : mAbsolute = aAbsolute;
65 :
66 0 : return NS_OK;
67 : }
68 :
69 0 : NS_IMETHODIMP nsDOMDeviceOrientationEvent::GetAlpha(double *aAlpha)
70 : {
71 0 : NS_ENSURE_ARG_POINTER(aAlpha);
72 :
73 0 : *aAlpha = mAlpha;
74 0 : return NS_OK;
75 : }
76 :
77 0 : NS_IMETHODIMP nsDOMDeviceOrientationEvent::GetBeta(double *aBeta)
78 : {
79 0 : NS_ENSURE_ARG_POINTER(aBeta);
80 :
81 0 : *aBeta = mBeta;
82 0 : return NS_OK;
83 : }
84 :
85 0 : NS_IMETHODIMP nsDOMDeviceOrientationEvent::GetGamma(double *aGamma)
86 : {
87 0 : NS_ENSURE_ARG_POINTER(aGamma);
88 :
89 0 : *aGamma = mGamma;
90 0 : return NS_OK;
91 : }
92 :
93 0 : NS_IMETHODIMP nsDOMDeviceOrientationEvent::GetAbsolute(bool *aAbsolute)
94 : {
95 0 : NS_ENSURE_ARG_POINTER(aAbsolute);
96 :
97 0 : *aAbsolute = mAbsolute;
98 0 : return NS_OK;
99 : }
100 :
101 0 : nsresult NS_NewDOMDeviceOrientationEvent(nsIDOMEvent** aInstancePtrResult,
102 : nsPresContext* aPresContext,
103 : nsEvent *aEvent)
104 : {
105 0 : NS_ENSURE_ARG_POINTER(aInstancePtrResult);
106 :
107 0 : nsDOMDeviceOrientationEvent* it = new nsDOMDeviceOrientationEvent(aPresContext, aEvent);
108 0 : if (nsnull == it) {
109 0 : return NS_ERROR_OUT_OF_MEMORY;
110 : }
111 :
112 0 : return CallQueryInterface(it, aInstancePtrResult);
113 : }
|