1/*
2 * Copyright (C) 2005, 2007 Apple Inc. All rights reserved.
3 * Copyright (C) 2006 Jon Shier (jshier@iastate.edu)
4 *
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Library General Public
7 * License as published by the Free Software Foundation; either
8 * version 2 of the License, or (at your option) any later version.
9 *
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13 * Library General Public License for more details.
14 *
15 * You should have received a copy of the GNU Library General Public License
16 * along with this library; see the file COPYING.LIB.  If not, write to
17 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
18 * Boston, MA 02110-1301, USA.
19 *
20 */
21
22#ifndef EventNames_h
23#define EventNames_h
24
25#include "EventInterfaces.h"
26#include "EventTargetInterfaces.h"
27#include "ThreadGlobalData.h"
28#include <wtf/text/AtomicString.h>
29
30namespace WebCore {
31
32#define DOM_EVENT_NAMES_FOR_EACH(macro) \
33    \
34    macro(abort) \
35    macro(beforecopy) \
36    macro(beforecut) \
37    macro(beforeload) \
38    macro(beforepaste) \
39    macro(beforeunload) \
40    macro(blocked) \
41    macro(blur) \
42    macro(cached) \
43    macro(change) \
44    macro(chargingchange) \
45    macro(chargingtimechange) \
46    macro(checking) \
47    macro(click) \
48    macro(close) \
49    macro(complete) \
50    macro(compositionend) \
51    macro(compositionstart) \
52    macro(compositionupdate) \
53    macro(connect) \
54    macro(contextmenu) \
55    macro(copy) \
56    macro(cut) \
57    macro(dblclick) \
58    macro(devicemotion) \
59    macro(deviceorientation) \
60    macro(dischargingtimechange) \
61    macro(display) \
62    macro(downloading) \
63    macro(drag) \
64    macro(dragend) \
65    macro(dragenter) \
66    macro(dragleave) \
67    macro(dragover) \
68    macro(dragstart) \
69    macro(drop) \
70    macro(error) \
71    macro(focus) \
72    macro(focusin) \
73    macro(focusout) \
74    macro(gesturetap) \
75    macro(gesturetapdown) \
76    macro(gesturescrollstart) \
77    macro(gesturescrollend) \
78    macro(gesturescrollupdate) \
79    macro(hashchange) \
80    macro(input) \
81    macro(invalid) \
82    macro(keydown) \
83    macro(keypress) \
84    macro(keyup) \
85    macro(levelchange) \
86    macro(load) \
87    macro(loading) \
88    macro(loadingdone) \
89    macro(loadstart) \
90    macro(message) \
91    macro(mousedown) \
92    macro(mouseenter) \
93    macro(mouseleave) \
94    macro(mousemove) \
95    macro(mouseout) \
96    macro(mouseover) \
97    macro(mouseup) \
98    macro(mousewheel) \
99    macro(noupdate) \
100    macro(obsolete) \
101    macro(offline) \
102    macro(online) \
103    macro(open) \
104    macro(overflowchanged) \
105    macro(pagehide) \
106    macro(pageshow) \
107    macro(paste) \
108    macro(popstate) \
109    macro(readystatechange) \
110    macro(reset) \
111    macro(resize) \
112    macro(scroll) \
113    macro(search) \
114    macro(select) \
115    macro(selectstart) \
116    macro(selectionchange) \
117    macro(storage) \
118    macro(submit) \
119    macro(textInput) \
120    macro(unload) \
121    macro(updateready) \
122    macro(upgradeneeded) \
123    macro(versionchange) \
124    macro(visibilitychange) \
125    macro(write) \
126    macro(writeend) \
127    macro(writestart) \
128    macro(zoom) \
129    \
130    macro(DOMActivate) \
131    macro(DOMFocusIn) \
132    macro(DOMFocusOut) \
133    macro(DOMCharacterDataModified) \
134    macro(DOMNodeInserted) \
135    macro(DOMNodeInsertedIntoDocument) \
136    macro(DOMNodeRemoved) \
137    macro(DOMNodeRemovedFromDocument) \
138    macro(DOMSubtreeModified) \
139    macro(DOMContentLoaded) \
140    \
141    macro(webkitBeforeTextInserted) \
142    macro(webkitEditableContentChanged) \
143    \
144    macro(canplay) \
145    macro(canplaythrough) \
146    macro(durationchange) \
147    macro(emptied) \
148    macro(ended) \
149    macro(loadeddata) \
150    macro(loadedmetadata) \
151    macro(pause) \
152    macro(play) \
153    macro(playing) \
154    macro(ratechange) \
155    macro(seeked) \
156    macro(seeking) \
157    macro(timeupdate) \
158    macro(volumechange) \
159    macro(waiting) \
160    \
161    macro(addtrack) \
162    macro(cuechange) \
163    macro(enter) \
164    macro(exit) \
165    \
166    macro(webkitbeginfullscreen) \
167    macro(webkitendfullscreen) \
168    \
169    macro(webkitaddsourcebuffer) \
170    macro(webkitremovesourcebuffer) \
171    macro(webkitsourceopen) \
172    macro(webkitsourceended) \
173    macro(webkitsourceclose) \
174    \
175    macro(webkitkeyadded) \
176    macro(webkitkeyerror) \
177    macro(webkitkeymessage) \
178    macro(webkitneedkey) \
179    \
180    macro(progress) \
181    macro(stalled) \
182    macro(suspend) \
183    \
184    macro(webkitAnimationEnd) \
185    macro(webkitAnimationStart) \
186    macro(webkitAnimationIteration) \
187    \
188    macro(webkitTransitionEnd) \
189    macro(transitionend) \
190    \
191    macro(orientationchange) \
192    \
193    macro(timeout) \
194    \
195    macro(touchstart) \
196    macro(touchmove) \
197    macro(touchend) \
198    macro(touchcancel) \
199    \
200    macro(success) \
201    \
202    macro(loadend) \
203    \
204    macro(webkitfullscreenchange) \
205    macro(webkitfullscreenerror) \
206    \
207    macro(webkitspeechchange) \
208    \
209    macro(audiostart) \
210    macro(soundstart) \
211    macro(speechstart) \
212    macro(speechend) \
213    macro(soundend) \
214    macro(audioend) \
215    macro(result) \
216    macro(nomatch) \
217    macro(start) \
218    macro(end) \
219    macro(mark) \
220    macro(boundary) \
221    macro(resume) \
222    \
223    macro(webglcontextlost) \
224    macro(webglcontextrestored) \
225    macro(webglcontextcreationerror) \
226    \
227    macro(audioprocess) \
228    \
229    macro(connecting) \
230    macro(addstream) \
231    macro(removestream) \
232    macro(signalingstatechange) \
233    macro(removetrack) \
234    macro(mute) \
235    macro(unmute) \
236    macro(iceconnectionstatechange) \
237    macro(icecandidate) \
238    macro(negotiationneeded) \
239    macro(datachannel) \
240    macro(tonechange) \
241    \
242    macro(show) \
243    \
244    macro(webkitpointerlockchange) \
245    macro(webkitpointerlockerror) \
246    \
247    macro(webkitregionlayoutupdate) \
248    \
249    macro(webkitnetworkinfochange) \
250    \
251    macro(webkitresourcetimingbufferfull) \
252    \
253    macro(webkitdeviceproximity) \
254    \
255    macro(securitypolicyviolation) \
256    \
257
258// end of DOM_EVENT_NAMES_FOR_EACH
259
260    class EventNames {
261        WTF_MAKE_NONCOPYABLE(EventNames); WTF_MAKE_FAST_ALLOCATED;
262        int dummy; // Needed to make initialization macro work.
263        // Private to prevent accidental call to EventNames() instead of eventNames()
264        EventNames();
265        friend class ThreadGlobalData;
266
267    public:
268        #define DOM_EVENT_NAMES_DECLARE(name) AtomicString name##Event;
269        DOM_EVENT_NAMES_FOR_EACH(DOM_EVENT_NAMES_DECLARE)
270        #undef DOM_EVENT_NAMES_DECLARE
271
272        #define DOM_EVENT_INTERFACE_DECLARE(name) AtomicString interfaceFor##name;
273        DOM_EVENT_INTERFACES_FOR_EACH(DOM_EVENT_INTERFACE_DECLARE)
274        DOM_EVENT_TARGET_INTERFACES_FOR_EACH(DOM_EVENT_INTERFACE_DECLARE)
275        #undef DOM_EVENT_INTERFACE_DECLARE
276
277        inline bool isTouchEventType(const AtomicString& eventType) const
278        {
279            return eventType == touchstartEvent
280                || eventType == touchmoveEvent
281                || eventType == touchendEvent
282                || eventType == touchcancelEvent;
283        }
284
285        inline bool isGestureEventType(const AtomicString& eventType) const
286        {
287            return eventType == gesturetapEvent
288                || eventType == gesturetapdownEvent
289                || eventType == gesturescrollstartEvent
290                || eventType == gesturescrollendEvent
291                || eventType == gesturescrollupdateEvent;
292        }
293
294        Vector<AtomicString> touchEventNames() const
295        {
296            Vector<AtomicString> names;
297            names.reserveCapacity(4);
298            names.append(touchstartEvent);
299            names.append(touchmoveEvent);
300            names.append(touchendEvent);
301            names.append(touchcancelEvent);
302            return names;
303        }
304    };
305
306    inline EventNames& eventNames()
307    {
308        return threadGlobalData().eventNames();
309    }
310
311}
312
313#endif
314