Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(8)

Side by Side Diff: Source/modules/gamepad/NavigatorGamepad.cpp

Issue 806993002: Removed deprecated navigator.webkitGetGamepads. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Missed one layout test expectations update Created 6 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « Source/modules/gamepad/NavigatorGamepad.h ('k') | Source/modules/gamepad/NavigatorGamepad.idl » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 16 matching lines...) Expand all
27 #include "modules/gamepad/NavigatorGamepad.h" 27 #include "modules/gamepad/NavigatorGamepad.h"
28 28
29 #include "core/dom/Document.h" 29 #include "core/dom/Document.h"
30 #include "core/frame/LocalDOMWindow.h" 30 #include "core/frame/LocalDOMWindow.h"
31 #include "core/frame/LocalFrame.h" 31 #include "core/frame/LocalFrame.h"
32 #include "core/frame/Navigator.h" 32 #include "core/frame/Navigator.h"
33 #include "core/page/Page.h" 33 #include "core/page/Page.h"
34 #include "modules/gamepad/GamepadDispatcher.h" 34 #include "modules/gamepad/GamepadDispatcher.h"
35 #include "modules/gamepad/GamepadEvent.h" 35 #include "modules/gamepad/GamepadEvent.h"
36 #include "modules/gamepad/GamepadList.h" 36 #include "modules/gamepad/GamepadList.h"
37 #include "modules/gamepad/WebKitGamepadList.h"
38 37
39 namespace blink { 38 namespace blink {
40 39
41 template<typename T> 40 template<typename T>
42 static void sampleGamepad(unsigned index, T& gamepad, const WebGamepad& webGamep ad) 41 static void sampleGamepad(unsigned index, T& gamepad, const WebGamepad& webGamep ad)
43 { 42 {
44 gamepad.setId(webGamepad.id); 43 gamepad.setId(webGamepad.id);
45 gamepad.setIndex(index); 44 gamepad.setIndex(index);
46 gamepad.setConnected(webGamepad.connected); 45 gamepad.setConnected(webGamepad.connected);
47 gamepad.setTimestamp(webGamepad.timestamp); 46 gamepad.setTimestamp(webGamepad.timestamp);
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
82 NavigatorGamepad& NavigatorGamepad::from(Navigator& navigator) 81 NavigatorGamepad& NavigatorGamepad::from(Navigator& navigator)
83 { 82 {
84 NavigatorGamepad* supplement = static_cast<NavigatorGamepad*>(WillBeHeapSupp lement<Navigator>::from(navigator, supplementName())); 83 NavigatorGamepad* supplement = static_cast<NavigatorGamepad*>(WillBeHeapSupp lement<Navigator>::from(navigator, supplementName()));
85 if (!supplement) { 84 if (!supplement) {
86 supplement = new NavigatorGamepad(navigator.frame()); 85 supplement = new NavigatorGamepad(navigator.frame());
87 provideTo(navigator, supplementName(), adoptPtrWillBeNoop(supplement)); 86 provideTo(navigator, supplementName(), adoptPtrWillBeNoop(supplement));
88 } 87 }
89 return *supplement; 88 return *supplement;
90 } 89 }
91 90
92 WebKitGamepadList* NavigatorGamepad::webkitGetGamepads(Navigator& navigator)
93 {
94 return NavigatorGamepad::from(navigator).webkitGamepads();
95 }
96
97 GamepadList* NavigatorGamepad::getGamepads(Navigator& navigator) 91 GamepadList* NavigatorGamepad::getGamepads(Navigator& navigator)
98 { 92 {
99 return NavigatorGamepad::from(navigator).gamepads(); 93 return NavigatorGamepad::from(navigator).gamepads();
100 } 94 }
101 95
102 WebKitGamepadList* NavigatorGamepad::webkitGamepads()
103 {
104 if (!m_webkitGamepads)
105 m_webkitGamepads = WebKitGamepadList::create();
106 if (window()) {
107 startUpdating();
108 sampleGamepads<WebKitGamepad>(m_webkitGamepads.get());
109 }
110 return m_webkitGamepads.get();
111 }
112
113 GamepadList* NavigatorGamepad::gamepads() 96 GamepadList* NavigatorGamepad::gamepads()
114 { 97 {
115 if (!m_gamepads) 98 if (!m_gamepads)
116 m_gamepads = GamepadList::create(); 99 m_gamepads = GamepadList::create();
117 if (window()) { 100 if (window()) {
118 startUpdating(); 101 startUpdating();
119 sampleGamepads<Gamepad>(m_gamepads.get()); 102 sampleGamepads<Gamepad>(m_gamepads.get());
120 } 103 }
121 return m_gamepads.get(); 104 return m_gamepads.get();
122 } 105 }
123 106
124 void NavigatorGamepad::trace(Visitor* visitor) 107 void NavigatorGamepad::trace(Visitor* visitor)
125 { 108 {
126 visitor->trace(m_gamepads); 109 visitor->trace(m_gamepads);
127 visitor->trace(m_webkitGamepads);
128 visitor->trace(m_pendingEvents); 110 visitor->trace(m_pendingEvents);
129 WillBeHeapSupplement<Navigator>::trace(visitor); 111 WillBeHeapSupplement<Navigator>::trace(visitor);
130 DOMWindowProperty::trace(visitor); 112 DOMWindowProperty::trace(visitor);
131 PlatformEventController::trace(visitor); 113 PlatformEventController::trace(visitor);
132 } 114 }
133 115
134 void NavigatorGamepad::didUpdateData() 116 void NavigatorGamepad::didUpdateData()
135 { 117 {
136 // We should stop listening once we detached. 118 // We should stop listening once we detached.
137 ASSERT(window()); 119 ASSERT(window());
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
250 { 232 {
251 m_hasEventListener = false; 233 m_hasEventListener = false;
252 m_dispatchOneEventRunner.stop(); 234 m_dispatchOneEventRunner.stop();
253 m_pendingEvents.clear(); 235 m_pendingEvents.clear();
254 } 236 }
255 237
256 void NavigatorGamepad::pageVisibilityChanged() 238 void NavigatorGamepad::pageVisibilityChanged()
257 { 239 {
258 // Inform the embedder whether it needs to provide gamepad data for us. 240 // Inform the embedder whether it needs to provide gamepad data for us.
259 bool visible = page()->visibilityState() == PageVisibilityStateVisible; 241 bool visible = page()->visibilityState() == PageVisibilityStateVisible;
260 if (visible && (m_hasEventListener || m_gamepads || m_webkitGamepads)) 242 if (visible && (m_hasEventListener || m_gamepads))
261 startUpdating(); 243 startUpdating();
262 else 244 else
263 stopUpdating(); 245 stopUpdating();
264 246
265 if (!visible || !m_hasEventListener) 247 if (!visible || !m_hasEventListener)
266 return; 248 return;
267 249
268 // Tell the page what has changed. m_gamepads contains the state before we b ecame hidden. 250 // Tell the page what has changed. m_gamepads contains the state before we b ecame hidden.
269 // We create a new snapshot and compare them. 251 // We create a new snapshot and compare them.
270 GamepadList* oldGamepads = m_gamepads.release(); 252 GamepadList* oldGamepads = m_gamepads.release();
(...skipping 14 matching lines...) Expand all
285 if (connectedGamepadChanged || (!oldWasConnected && newIsConnected)) { 267 if (connectedGamepadChanged || (!oldWasConnected && newIsConnected)) {
286 m_pendingEvents.append(newGamepad); 268 m_pendingEvents.append(newGamepad);
287 } 269 }
288 } 270 }
289 271
290 if (!m_pendingEvents.isEmpty()) 272 if (!m_pendingEvents.isEmpty())
291 m_dispatchOneEventRunner.runAsync(); 273 m_dispatchOneEventRunner.runAsync();
292 } 274 }
293 275
294 } // namespace blink 276 } // namespace blink
OLDNEW
« no previous file with comments | « Source/modules/gamepad/NavigatorGamepad.h ('k') | Source/modules/gamepad/NavigatorGamepad.idl » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698