OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2011, Google Inc. All rights reserved. | 2 * Copyright (C) 2011, Google Inc. All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions are met: | 5 * modification, are permitted provided that the following conditions are met: |
6 * | 6 * |
7 * 1. Redistributions of source code must retain the above copyright | 7 * 1. Redistributions of source code must retain the above copyright |
8 * notice, this list of conditions and the following disclaimer. | 8 * notice, this list of conditions and the following disclaimer. |
9 * 2. Redistributions in binary form must reproduce the above copyright | 9 * 2. Redistributions in binary form must reproduce the above copyright |
10 * notice, this list of conditions and the following disclaimer in the | 10 * notice, this list of conditions and the following disclaimer in the |
(...skipping 11 matching lines...) Expand all Loading... |
22 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH | 22 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH |
23 * DAMAGE. | 23 * DAMAGE. |
24 */ | 24 */ |
25 | 25 |
26 #ifndef NavigatorGamepad_h | 26 #ifndef NavigatorGamepad_h |
27 #define NavigatorGamepad_h | 27 #define NavigatorGamepad_h |
28 | 28 |
29 #include "core/frame/DOMWindowLifecycleObserver.h" | 29 #include "core/frame/DOMWindowLifecycleObserver.h" |
30 #include "core/frame/DOMWindowProperty.h" | 30 #include "core/frame/DOMWindowProperty.h" |
31 #include "core/frame/DeviceEventControllerBase.h" | 31 #include "core/frame/DeviceEventControllerBase.h" |
| 32 #include "platform/AsyncMethodRunner.h" |
32 #include "platform/Supplementable.h" | 33 #include "platform/Supplementable.h" |
33 #include "platform/heap/Handle.h" | 34 #include "platform/heap/Handle.h" |
34 #include "public/platform/WebGamepads.h" | 35 #include "public/platform/WebGamepads.h" |
35 | 36 |
36 namespace blink { | 37 namespace blink { |
37 class WebGamepad; | 38 class WebGamepad; |
38 class WebGamepads; | 39 class WebGamepads; |
39 } | 40 } |
40 | 41 |
41 namespace WebCore { | 42 namespace WebCore { |
42 | 43 |
43 class Document; | 44 class Document; |
| 45 class Gamepad; |
44 class GamepadList; | 46 class GamepadList; |
45 class Navigator; | 47 class Navigator; |
46 class WebKitGamepadList; | 48 class WebKitGamepadList; |
47 | 49 |
48 class NavigatorGamepad FINAL : public NoBaseWillBeGarbageCollectedFinalized<Navi
gatorGamepad>, public WillBeHeapSupplement<Navigator>, public DOMWindowProperty,
public DeviceEventControllerBase, public DOMWindowLifecycleObserver { | 50 class NavigatorGamepad FINAL : public NoBaseWillBeGarbageCollectedFinalized<Navi
gatorGamepad>, public WillBeHeapSupplement<Navigator>, public DOMWindowProperty,
public DeviceEventControllerBase, public DOMWindowLifecycleObserver { |
49 WILL_BE_USING_GARBAGE_COLLECTED_MIXIN(NavigatorGamepad); | 51 WILL_BE_USING_GARBAGE_COLLECTED_MIXIN(NavigatorGamepad); |
50 public: | 52 public: |
51 static NavigatorGamepad* from(Document&); | 53 static NavigatorGamepad* from(Document&); |
52 static NavigatorGamepad& from(Navigator&); | 54 static NavigatorGamepad& from(Navigator&); |
53 virtual ~NavigatorGamepad(); | 55 virtual ~NavigatorGamepad(); |
54 | 56 |
55 static WebKitGamepadList* webkitGetGamepads(Navigator&); | 57 static WebKitGamepadList* webkitGetGamepads(Navigator&); |
56 static GamepadList* getGamepads(Navigator&); | 58 static GamepadList* getGamepads(Navigator&); |
57 | 59 |
58 WebKitGamepadList* webkitGamepads(); | 60 WebKitGamepadList* webkitGamepads(); |
59 GamepadList* gamepads(); | 61 GamepadList* gamepads(); |
60 | 62 |
61 virtual void trace(Visitor*); | 63 virtual void trace(Visitor*); |
62 | 64 |
63 void didConnectOrDisconnectGamepad(unsigned index, const blink::WebGamepad&,
bool connected); | 65 void didConnectOrDisconnectGamepad(unsigned index, const blink::WebGamepad&,
bool connected); |
64 | 66 |
65 private: | 67 private: |
66 explicit NavigatorGamepad(LocalFrame*); | 68 explicit NavigatorGamepad(LocalFrame*); |
67 | 69 |
68 static const char* supplementName(); | 70 static const char* supplementName(); |
69 | 71 |
| 72 void dispatchOneEvent(); |
| 73 void didRemoveGamepadEventListeners(); |
| 74 |
70 // DOMWindowProperty | 75 // DOMWindowProperty |
71 virtual void willDestroyGlobalObjectInFrame() OVERRIDE; | 76 virtual void willDestroyGlobalObjectInFrame() OVERRIDE; |
72 virtual void willDetachGlobalObjectFromFrame() OVERRIDE; | 77 virtual void willDetachGlobalObjectFromFrame() OVERRIDE; |
73 | 78 |
74 // DeviceEventControllerBase | 79 // DeviceEventControllerBase |
75 virtual void registerWithDispatcher() OVERRIDE; | 80 virtual void registerWithDispatcher() OVERRIDE; |
76 virtual void unregisterWithDispatcher() OVERRIDE; | 81 virtual void unregisterWithDispatcher() OVERRIDE; |
77 virtual bool hasLastData() OVERRIDE; | 82 virtual bool hasLastData() OVERRIDE; |
78 virtual void didUpdateData() OVERRIDE; | 83 virtual void didUpdateData() OVERRIDE; |
79 virtual void pageVisibilityChanged() OVERRIDE; | 84 virtual void pageVisibilityChanged() OVERRIDE; |
80 | 85 |
81 // DOMWindowLifecycleObserver | 86 // DOMWindowLifecycleObserver |
82 virtual void didAddEventListener(LocalDOMWindow*, const AtomicString&) OVERR
IDE; | 87 virtual void didAddEventListener(LocalDOMWindow*, const AtomicString&) OVERR
IDE; |
83 virtual void didRemoveEventListener(LocalDOMWindow*, const AtomicString&) OV
ERRIDE; | 88 virtual void didRemoveEventListener(LocalDOMWindow*, const AtomicString&) OV
ERRIDE; |
84 virtual void didRemoveAllEventListeners(LocalDOMWindow*) OVERRIDE; | 89 virtual void didRemoveAllEventListeners(LocalDOMWindow*) OVERRIDE; |
85 | 90 |
86 PersistentWillBeMember<GamepadList> m_gamepads; | 91 PersistentWillBeMember<GamepadList> m_gamepads; |
87 PersistentWillBeMember<WebKitGamepadList> m_webkitGamepads; | 92 PersistentWillBeMember<WebKitGamepadList> m_webkitGamepads; |
| 93 PersistentHeapDequeWillBeHeapDeque<Member<Gamepad> > m_pendingEvents; |
| 94 AsyncMethodRunner<NavigatorGamepad> m_dispatchOneEventRunner; |
88 }; | 95 }; |
89 | 96 |
90 } // namespace WebCore | 97 } // namespace WebCore |
91 | 98 |
92 #endif // NavigatorGamepad_h | 99 #endif // NavigatorGamepad_h |
OLD | NEW |