Bug 458160 - Enable downloadable .otf fonts under Windows. r=roc, sr=vlad.
[wine-gecko.git] / dom / src / threads / nsDOMWorkerEvents.h
blob5faa6a5f45f4bb9d3984afbcfcf1c1e922c5175c
1 /* -*- Mode: c++; c-basic-offset: 4; indent-tabs-mode: nil; tab-width: 40 -*- */
2 /* ***** BEGIN LICENSE BLOCK *****
3 * Version: MPL 1.1/GPL 2.0/LGPL 2.1
5 * The contents of this file are subject to the Mozilla Public License Version
6 * 1.1 (the "License"); you may not use this file except in compliance with
7 * the License. You may obtain a copy of the License at
8 * http://www.mozilla.org/MPL/
10 * Software distributed under the License is distributed on an "AS IS" basis,
11 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
12 * for the specific language governing rights and limitations under the
13 * License.
15 * The Original Code is Web Workers.
17 * The Initial Developer of the Original Code is
18 * Mozilla Corporation.
19 * Portions created by the Initial Developer are Copyright (C) 2008
20 * the Initial Developer. All Rights Reserved.
22 * Contributor(s):
23 * Ben Turner <bent.mozilla@gmail.com> (Original Author)
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.
37 * ***** END LICENSE BLOCK ***** */
39 #ifndef __NSDOMWORKEREVENTS_H__
40 #define __NSDOMWORKEREVENTS_H__
42 #include "nsIClassInfo.h"
43 #include "nsIDOMEvent.h"
44 #include "nsIDOMEventTarget.h"
45 #include "nsIDOMProgressEvent.h"
46 #include "nsIDOMWorkers.h"
47 #include "nsIRunnable.h"
49 #include "jsapi.h"
50 #include "nsAutoJSValHolder.h"
51 #include "nsAutoPtr.h"
52 #include "nsCOMPtr.h"
53 #include "nsStringGlue.h"
55 #include "nsDOMWorkerMacros.h"
57 class nsDOMWorkerXHRProxy;
58 class nsIXMLHttpRequest;
59 class nsIXPConnectWrappedNative;
61 /* 4d5794d6-98ab-4a6b-ad5a-8ed1fa1d4839 */
62 #define NS_IDOMWORKERPRIVATEEVENT_IID \
63 { \
64 0x4d5794d6, \
65 0x98ab, \
66 0x4a6b, \
67 { 0xad, 0x5a, 0x8e, 0xd1, 0xfa, 0x1d, 0x48, 0x39 } \
70 class nsIDOMWorkerPrivateEvent : public nsIDOMEvent
72 public:
73 NS_DECLARE_STATIC_IID_ACCESSOR(NS_IDOMWORKERPRIVATEEVENT_IID)
74 virtual PRBool PreventDefaultCalled() = 0;
77 #define NS_FORWARD_NSIDOMEVENT_SPECIAL \
78 NS_IMETHOD GetType(nsAString& aType) \
79 { return mEvent->GetType(aType); } \
80 NS_IMETHOD GetTarget(nsIDOMEventTarget** aTarget) \
81 { return mEvent->GetTarget(aTarget); } \
82 NS_IMETHOD GetCurrentTarget(nsIDOMEventTarget** aCurrentTarget) \
83 { return mEvent->GetCurrentTarget(aCurrentTarget); } \
84 NS_IMETHOD GetEventPhase(PRUint16* aEventPhase) \
85 { return mEvent->GetEventPhase(aEventPhase); } \
86 NS_IMETHOD GetBubbles(PRBool* aBubbles) \
87 { return mEvent->GetBubbles(aBubbles); } \
88 NS_IMETHOD GetCancelable(PRBool* aCancelable) \
89 { return mEvent->GetCancelable(aCancelable); } \
90 NS_IMETHOD GetTimeStamp(DOMTimeStamp* aTimeStamp) \
91 { return mEvent->GetTimeStamp(aTimeStamp); } \
92 NS_IMETHOD StopPropagation() \
93 { return mEvent->StopPropagation(); }
95 #define NS_FORWARD_NSIDOMPROGRESSEVENT_SPECIAL \
96 NS_IMETHOD GetLengthComputable(PRBool* aLengthComputable) \
97 { return mProgressEvent->GetLengthComputable(aLengthComputable); } \
98 NS_IMETHOD GetLoaded(PRUint64* aLoaded) \
99 { return mProgressEvent->GetLoaded(aLoaded); } \
100 NS_IMETHOD GetTotal(PRUint64* aTotal) \
101 { return mProgressEvent->GetTotal(aTotal); }
103 #define NS_FORWARD_NSIWORKERMESSAGEEVENT_SPECIAL \
104 NS_IMETHOD GetData(nsAString& aData) \
105 { return mMessageEvent->GetData(aData); } \
106 NS_IMETHOD GetOrigin(nsAString& aOrigin) \
107 { return mMessageEvent->GetOrigin(aOrigin); } \
108 NS_IMETHOD GetSource(nsISupports** aSource) \
109 { return mMessageEvent->GetSource(aSource); }
111 class nsDOMWorkerPrivateEvent : public nsIDOMWorkerPrivateEvent,
112 public nsIDOMProgressEvent,
113 public nsIWorkerMessageEvent,
114 public nsIClassInfo
116 public:
117 NS_DECL_ISUPPORTS
118 NS_FORWARD_NSIDOMEVENT_SPECIAL
119 NS_FORWARD_NSIWORKERMESSAGEEVENT_SPECIAL
120 NS_FORWARD_NSIDOMPROGRESSEVENT_SPECIAL
121 NS_DECL_NSICLASSINFO
123 nsDOMWorkerPrivateEvent(nsIDOMEvent* aEvent);
125 NS_IMETHOD PreventDefault();
127 NS_IMETHOD InitEvent(const nsAString& aEventType,
128 PRBool aCanBubble,
129 PRBool aCancelable);
131 NS_IMETHOD InitProgressEvent(const nsAString& aTypeArg,
132 PRBool aCanBubbleArg,
133 PRBool aCancelableArg,
134 PRBool aLengthComputableArg,
135 PRUint64 aLoadedArg,
136 PRUint64 aTotalArg);
138 NS_IMETHOD InitMessageEvent(const nsAString& aTypeArg,
139 PRBool aCanBubbleArg,
140 PRBool aCancelableArg,
141 const nsAString& aDataArg,
142 const nsAString& aOriginArg,
143 nsISupports* aSourceArg);
145 virtual PRBool PreventDefaultCalled();
147 private:
148 nsCOMPtr<nsIDOMEvent> mEvent;
149 nsCOMPtr<nsIDOMProgressEvent> mProgressEvent;
150 nsCOMPtr<nsIWorkerMessageEvent> mMessageEvent;
151 PRBool mPreventDefaultCalled;
154 class nsDOMWorkerEvent : public nsIDOMEvent,
155 public nsIClassInfo
157 public:
158 NS_DECL_ISUPPORTS
159 NS_DECL_NSIDOMEVENT
160 NS_DECL_NSICLASSINFO
162 nsDOMWorkerEvent()
163 : mEventPhase(nsIDOMEvent::AT_TARGET), mTimeStamp(0), mBubbles(PR_FALSE),
164 mCancelable(PR_FALSE), mPreventDefaultCalled(PR_FALSE) { }
166 void SetTarget(nsIDOMEventTarget* aTarget) {
167 mTarget = aTarget;
170 protected:
171 virtual ~nsDOMWorkerEvent() { }
173 nsString mType;
174 nsCOMPtr<nsIDOMEventTarget> mTarget;
175 PRUint16 mEventPhase;
176 DOMTimeStamp mTimeStamp;
177 PRPackedBool mBubbles;
178 PRPackedBool mCancelable;
179 PRPackedBool mPreventDefaultCalled;
182 class nsDOMWorkerMessageEvent : public nsDOMWorkerEvent,
183 public nsIWorkerMessageEvent
185 public:
186 NS_DECL_ISUPPORTS_INHERITED
187 NS_FORWARD_NSIDOMEVENT(nsDOMWorkerEvent::)
188 NS_DECL_NSIWORKERMESSAGEEVENT
189 NS_DECL_NSICLASSINFO_GETINTERFACES
191 nsDOMWorkerMessageEvent()
192 : mIsJSON(PR_FALSE), mIsPrimitive(PR_FALSE) { }
194 void SetJSONData(PRBool aIsJSON, PRBool aIsPrimitive) {
195 mIsJSON = aIsJSON;
196 mIsPrimitive = aIsPrimitive;
199 protected:
200 nsString mData;
201 PRBool mIsJSON;
202 PRBool mIsPrimitive;
203 nsAutoJSValHolder mCachedJSVal;
205 nsString mOrigin;
206 nsCOMPtr<nsISupports> mSource;
209 class nsDOMWorkerProgressEvent : public nsDOMWorkerEvent,
210 public nsIDOMProgressEvent
212 public:
213 NS_DECL_ISUPPORTS_INHERITED
214 NS_FORWARD_NSIDOMEVENT(nsDOMWorkerEvent::)
215 NS_DECL_NSIDOMPROGRESSEVENT
216 NS_DECL_NSICLASSINFO_GETINTERFACES
218 nsDOMWorkerProgressEvent()
219 : mLoaded(0), mTotal(0), mLengthComputable(PR_FALSE) { }
221 protected:
222 PRUint64 mLoaded;
223 PRUint64 mTotal;
224 PRBool mLengthComputable;
227 class nsDOMWorkerXHRState
229 public:
230 nsDOMWorkerXHRState()
231 : responseTextResult(NS_OK), statusTextResult(NS_OK), status(NS_OK),
232 statusResult(NS_OK), readyState(0), readyStateResult(NS_OK) { }
234 NS_IMETHOD_(nsrefcnt) AddRef();
235 NS_IMETHOD_(nsrefcnt) Release();
237 nsString responseText;
238 nsresult responseTextResult;
240 nsCString statusText;
241 nsresult statusTextResult;
243 nsresult status;
244 nsresult statusResult;
246 PRInt32 readyState;
247 nsresult readyStateResult;
249 protected:
250 virtual ~nsDOMWorkerXHRState() { }
252 nsAutoRefCnt mRefCnt;
255 enum SnapshotChoice {
256 WANT_SNAPSHOT,
257 NO_SNAPSHOT
260 class nsDOMWorkerXHREvent : public nsDOMWorkerProgressEvent,
261 public nsIRunnable
263 friend class nsDOMWorkerXHRProxy;
265 public:
266 NS_DECL_ISUPPORTS_INHERITED
267 NS_DECL_NSIRUNNABLE
268 NS_DECL_NSICLASSINFO_GETINTERFACES
270 enum SnapshotChoice {
271 SNAPSHOT,
272 NO_SNAPSHOT
275 nsDOMWorkerXHREvent(nsDOMWorkerXHRProxy* aXHRProxy);
277 nsresult Init(PRUint32 aXHREventType,
278 const nsAString& aType,
279 nsIDOMEvent* aEvent,
280 SnapshotChoice = SNAPSHOT);
282 static void SnapshotXHRState(nsIXMLHttpRequest* aXHR,
283 nsDOMWorkerXHRState* aState);
285 already_AddRefed<nsDOMWorkerXHRState> ForgetState() {
286 return mState.forget();
289 protected:
290 nsDOMWorkerXHRState* GetState() {
291 return mState;
294 nsRefPtr<nsDOMWorkerXHRProxy> mXHRProxy;
295 nsCOMPtr<nsIXPConnectWrappedNative> mXHRWN;
296 nsRefPtr<nsDOMWorkerXHRState> mState;
297 PRUint32 mXHREventType;
298 PRInt32 mChannelID;
299 PRPackedBool mUploadEvent;
300 PRPackedBool mProgressEvent;
303 #endif /* __NSDOMWORKEREVENTS_H__ */