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

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

Issue 1846913009: HeapSupplements are now just Supplements. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 8 months 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
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 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
72 NavigatorGamepad* NavigatorGamepad::from(Document& document) 72 NavigatorGamepad* NavigatorGamepad::from(Document& document)
73 { 73 {
74 if (!document.frame() || !document.frame()->domWindow()) 74 if (!document.frame() || !document.frame()->domWindow())
75 return 0; 75 return 0;
76 Navigator& navigator = *document.frame()->domWindow()->navigator(); 76 Navigator& navigator = *document.frame()->domWindow()->navigator();
77 return &from(navigator); 77 return &from(navigator);
78 } 78 }
79 79
80 NavigatorGamepad& NavigatorGamepad::from(Navigator& navigator) 80 NavigatorGamepad& NavigatorGamepad::from(Navigator& navigator)
81 { 81 {
82 NavigatorGamepad* supplement = static_cast<NavigatorGamepad*>(HeapSupplement <Navigator>::from(navigator, supplementName())); 82 NavigatorGamepad* supplement = static_cast<NavigatorGamepad*>(Supplement<Nav igator>::from(navigator, supplementName()));
83 if (!supplement) { 83 if (!supplement) {
84 supplement = new NavigatorGamepad(navigator.frame()); 84 supplement = new NavigatorGamepad(navigator.frame());
85 provideTo(navigator, supplementName(), supplement); 85 provideTo(navigator, supplementName(), supplement);
86 } 86 }
87 return *supplement; 87 return *supplement;
88 } 88 }
89 89
90 GamepadList* NavigatorGamepad::getGamepads(Navigator& navigator) 90 GamepadList* NavigatorGamepad::getGamepads(Navigator& navigator)
91 { 91 {
92 return NavigatorGamepad::from(navigator).gamepads(); 92 return NavigatorGamepad::from(navigator).gamepads();
93 } 93 }
94 94
95 GamepadList* NavigatorGamepad::gamepads() 95 GamepadList* NavigatorGamepad::gamepads()
96 { 96 {
97 if (!m_gamepads) 97 if (!m_gamepads)
98 m_gamepads = GamepadList::create(); 98 m_gamepads = GamepadList::create();
99 if (startUpdatingIfAttached()) 99 if (startUpdatingIfAttached())
100 sampleGamepads<Gamepad>(m_gamepads.get()); 100 sampleGamepads<Gamepad>(m_gamepads.get());
101 return m_gamepads.get(); 101 return m_gamepads.get();
102 } 102 }
103 103
104 DEFINE_TRACE(NavigatorGamepad) 104 DEFINE_TRACE(NavigatorGamepad)
105 { 105 {
106 visitor->trace(m_gamepads); 106 visitor->trace(m_gamepads);
107 visitor->trace(m_pendingEvents); 107 visitor->trace(m_pendingEvents);
108 visitor->trace(m_dispatchOneEventRunner); 108 visitor->trace(m_dispatchOneEventRunner);
109 HeapSupplement<Navigator>::trace(visitor); 109 Supplement<Navigator>::trace(visitor);
110 DOMWindowProperty::trace(visitor); 110 DOMWindowProperty::trace(visitor);
111 PlatformEventController::trace(visitor); 111 PlatformEventController::trace(visitor);
112 DOMWindowLifecycleObserver::trace(visitor); 112 DOMWindowLifecycleObserver::trace(visitor);
113 } 113 }
114 114
115 bool NavigatorGamepad::startUpdatingIfAttached() 115 bool NavigatorGamepad::startUpdatingIfAttached()
116 { 116 {
117 // The frame must be attached to start updating. 117 // The frame must be attached to start updating.
118 if (frame() && frame()->host()) { 118 if (frame() && frame()->host()) {
119 startUpdating(); 119 startUpdating();
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after
279 if (connectedGamepadChanged || (!oldWasConnected && newIsConnected)) { 279 if (connectedGamepadChanged || (!oldWasConnected && newIsConnected)) {
280 m_pendingEvents.append(newGamepad); 280 m_pendingEvents.append(newGamepad);
281 } 281 }
282 } 282 }
283 283
284 if (!m_pendingEvents.isEmpty()) 284 if (!m_pendingEvents.isEmpty())
285 m_dispatchOneEventRunner->runAsync(); 285 m_dispatchOneEventRunner->runAsync();
286 } 286 }
287 287
288 } // namespace blink 288 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698