2 * Copyright (C) 2005, 2007, 2015 Apple Inc. All rights reserved.
3 * Copyright (C) 2006 Jon Shier (jshier@iastate.edu)
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.
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.
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.
24 #include "ThreadGlobalData.h"
27 #include <wtf/text/AtomicString.h>
31 #if !defined(ADDITIONAL_DOM_EVENT_NAMES_FOR_EACH)
32 #define ADDITIONAL_DOM_EVENT_NAMES_FOR_EACH(macro)
35 #define DOM_EVENT_NAMES_FOR_EACH(macro) \
36 ADDITIONAL_DOM_EVENT_NAMES_FOR_EACH(macro) \
38 macro(DOMCharacterDataModified) \
39 macro(DOMContentLoaded) \
42 macro(DOMNodeInserted) \
43 macro(DOMNodeInsertedIntoDocument) \
44 macro(DOMNodeRemoved) \
45 macro(DOMNodeRemovedFromDocument) \
46 macro(DOMSubtreeModified) \
48 macro(accessiblecontextmenu) \
49 macro(accessibleclick) \
50 macro(accessibledecrement) \
51 macro(accessibledismiss) \
52 macro(accessiblefocus) \
53 macro(accessibleincrement) \
54 macro(accessiblescrollintoview) \
55 macro(accessiblesetvalue) \
56 macro(accessibleselect) \
59 macro(addsourcebuffer) \
62 macro(animationcancel) \
64 macro(animationiteration) \
65 macro(animationstart) \
70 macro(autocompleteerror) \
81 macro(bufferedamountlow) \
85 macro(canplaythrough) \
87 macro(chargingchange) \
88 macro(chargingtimechange) \
93 macro(compositionend) \
94 macro(compositionstart) \
95 macro(compositionupdate) \
97 macro(connectionstatechange) \
100 macro(controllerchange) \
104 macro(dataavailable) \
107 macro(devicechange) \
108 macro(devicemotion) \
109 macro(deviceorientation) \
110 macro(dischargingtimechange) \
119 macro(durationchange) \
133 macro(gamepadconnected) \
134 macro(gamepaddisconnected) \
135 macro(gesturechange) \
137 macro(gesturescrollend) \
138 macro(gesturescrollstart) \
139 macro(gesturescrollupdate) \
140 macro(gesturestart) \
142 macro(gesturetapdown) \
144 macro(icecandidate) \
145 macro(iceconnectionstatechange) \
146 macro(icegatheringstatechange) \
153 macro(keystatuseschange) \
155 macro(languagechange) \
159 macro(loadedmetadata) \
163 macro(loadingerror) \
166 macro(merchantvalidation) \
168 macro(messageerror) \
178 macro(negotiationneeded) \
186 macro(orientationchange) \
187 macro(overconstrained) \
188 macro(overflowchanged) \
193 macro(payerdetailchange) \
194 macro(paymentauthorized) \
195 macro(paymentmethodchange) \
196 macro(paymentmethodselected) \
199 macro(pointerlockchange) \
200 macro(pointerlockerror) \
201 macro(pointercancel) \
206 macro(previoustrack) \
209 macro(readystatechange) \
210 macro(rejectionhandled) \
211 macro(removesourcebuffer) \
212 macro(removestream) \
216 macro(resourcetimingbufferfull) \
221 macro(securitypolicyviolation) \
225 macro(selectionchange) \
227 macro(shippingaddresschange) \
228 macro(shippingcontactselected) \
229 macro(shippingmethodselected) \
230 macro(shippingoptionchange) \
232 macro(signalingstatechange) \
257 macro(touchforcechange) \
261 macro(transitioncancel) \
262 macro(transitionend) \
263 macro(transitionrun) \
264 macro(transitionstart) \
265 macro(unhandledrejection) \
273 macro(upgradeneeded) \
274 macro(validatemerchant) \
275 macro(versionchange) \
276 macro(visibilitychange) \
277 macro(volumechange) \
278 macro(vrdisplayactivate) \
279 macro(vrdisplayblur) \
280 macro(vrdisplayconnect) \
281 macro(vrdisplaydeactivate) \
282 macro(vrdisplaydisconnect) \
283 macro(vrdisplayfocus) \
284 macro(vrdisplaypresentchange) \
286 macro(waitingforkey) \
287 macro(webglcontextchanged) \
288 macro(webglcontextcreationerror) \
289 macro(webglcontextlost) \
290 macro(webglcontextrestored) \
291 macro(webkitAnimationEnd) \
292 macro(webkitAnimationIteration) \
293 macro(webkitAnimationStart) \
294 macro(webkitBeforeTextInserted) \
295 macro(webkitEditableContentChanged) \
296 macro(webkitTransitionEnd) \
297 macro(webkitbeginfullscreen) \
298 macro(webkitcurrentplaybacktargetiswirelesschanged) \
299 macro(webkitendfullscreen) \
300 macro(webkitfullscreenchange) \
301 macro(webkitfullscreenerror) \
302 macro(webkitkeyadded) \
303 macro(webkitkeyerror) \
304 macro(webkitkeymessage) \
305 macro(webkitmouseforcechanged) \
306 macro(webkitmouseforcedown) \
307 macro(webkitmouseforcewillbegin) \
308 macro(webkitmouseforceup) \
309 macro(webkitneedkey) \
310 macro(webkitnetworkinfochange) \
311 macro(webkitplaybacktargetavailabilitychanged) \
312 macro(webkitpresentationmodechanged) \
313 macro(webkitregionoversetchange) \
314 macro(webkitremovesourcebuffer) \
315 macro(webkitsourceclose) \
316 macro(webkitsourceended) \
317 macro(webkitsourceopen) \
318 macro(webkitspeechchange) \
319 macro(webkitwillrevealbottom) \
320 macro(webkitwillrevealleft) \
321 macro(webkitwillrevealright) \
322 macro(webkitwillrevealtop) \
328 // end of DOM_EVENT_NAMES_FOR_EACH
331 WTF_MAKE_NONCOPYABLE(EventNames); WTF_MAKE_FAST_ALLOCATED;
334 #define DOM_EVENT_NAMES_DECLARE(name) const AtomicString name##Event;
335 DOM_EVENT_NAMES_FOR_EACH(DOM_EVENT_NAMES_DECLARE)
336 #undef DOM_EVENT_NAMES_DECLARE
338 // FIXME: The friend declaration to std::make_unique below does not work in windows port.
340 // template<class T, class... Args>
341 // friend typename std::_Unique_if<T>::_Single_object std::make_unique(Args&&...);
343 // This create function should be deleted later and is only for keeping EventNames as private.
344 // std::make_unique should be used instead.
346 template<class... Args>
347 static std::unique_ptr<EventNames> create(Args&&... args)
349 return std::unique_ptr<EventNames>(new EventNames(std::forward<Args>(args)...));
352 // FIXME: Inelegant to call these both event names and event types.
353 // We should choose one term and stick to it.
354 bool isWheelEventType(const AtomicString& eventType) const;
355 bool isGestureEventType(const AtomicString& eventType) const;
356 bool isTouchEventType(const AtomicString& eventType) const;
357 bool isTouchScrollBlockingEventType(const AtomicString& eventType) const;
359 bool isGamepadEventType(const AtomicString& eventType) const;
362 std::array<std::reference_wrapper<const AtomicString>, 5> touchEventNames() const;
363 std::array<std::reference_wrapper<const AtomicString>, 3> gestureEventNames() const;
366 EventNames(); // Private to prevent accidental call to EventNames() instead of eventNames().
367 friend class ThreadGlobalData; // Allow ThreadGlobalData to create the per-thread EventNames object.
369 int dummy; // Needed to make initialization macro work.
372 const EventNames& eventNames();
374 inline const EventNames& eventNames()
376 return threadGlobalData().eventNames();
379 inline bool EventNames::isGestureEventType(const AtomicString& eventType) const
381 return eventType == gesturestartEvent || eventType == gesturechangeEvent || eventType == gestureendEvent;
384 inline bool EventNames::isTouchScrollBlockingEventType(const AtomicString& eventType) const
386 return eventType == touchstartEvent
387 || eventType == touchmoveEvent;
390 inline bool EventNames::isTouchEventType(const AtomicString& eventType) const
392 return eventType == touchstartEvent
393 || eventType == touchmoveEvent
394 || eventType == touchendEvent
395 || eventType == touchcancelEvent
396 || eventType == touchforcechangeEvent;
399 inline bool EventNames::isWheelEventType(const AtomicString& eventType) const
401 return eventType == wheelEvent
402 || eventType == mousewheelEvent;
405 inline std::array<std::reference_wrapper<const AtomicString>, 5> EventNames::touchEventNames() const
407 return { { touchstartEvent, touchmoveEvent, touchendEvent, touchcancelEvent, touchforcechangeEvent } };
410 inline std::array<std::reference_wrapper<const AtomicString>, 3> EventNames::gestureEventNames() const
412 return { { gesturestartEvent, gesturechangeEvent, gestureendEvent } };
417 inline bool EventNames::isGamepadEventType(const AtomicString& eventType) const
419 return eventType == gamepadconnectedEvent
420 || eventType == gamepaddisconnectedEvent;
425 } // namespace WebCore