| 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 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 73 NavigatorGamepad* NavigatorGamepad::from(Document& document) | 73 NavigatorGamepad* NavigatorGamepad::from(Document& document) |
| 74 { | 74 { |
| 75 if (!document.frame() || !document.frame()->domWindow()) | 75 if (!document.frame() || !document.frame()->domWindow()) |
| 76 return 0; | 76 return 0; |
| 77 Navigator& navigator = *document.frame()->domWindow()->navigator(); | 77 Navigator& navigator = *document.frame()->domWindow()->navigator(); |
| 78 return &from(navigator); | 78 return &from(navigator); |
| 79 } | 79 } |
| 80 | 80 |
| 81 NavigatorGamepad& NavigatorGamepad::from(Navigator& navigator) | 81 NavigatorGamepad& NavigatorGamepad::from(Navigator& navigator) |
| 82 { | 82 { |
| 83 NavigatorGamepad* supplement = static_cast<NavigatorGamepad*>(WillBeHeapSupp
lement<Navigator>::from(navigator, supplementName())); | 83 NavigatorGamepad* supplement = static_cast<NavigatorGamepad*>(HeapSupplement
<Navigator>::from(navigator, supplementName())); |
| 84 if (!supplement) { | 84 if (!supplement) { |
| 85 supplement = new NavigatorGamepad(navigator.frame()); | 85 supplement = new NavigatorGamepad(navigator.frame()); |
| 86 provideTo(navigator, supplementName(), adoptPtrWillBeNoop(supplement)); | 86 provideTo(navigator, supplementName(), supplement); |
| 87 } | 87 } |
| 88 return *supplement; | 88 return *supplement; |
| 89 } | 89 } |
| 90 | 90 |
| 91 GamepadList* NavigatorGamepad::getGamepads(Navigator& navigator) | 91 GamepadList* NavigatorGamepad::getGamepads(Navigator& navigator) |
| 92 { | 92 { |
| 93 return NavigatorGamepad::from(navigator).gamepads(); | 93 return NavigatorGamepad::from(navigator).gamepads(); |
| 94 } | 94 } |
| 95 | 95 |
| 96 GamepadList* NavigatorGamepad::gamepads() | 96 GamepadList* NavigatorGamepad::gamepads() |
| 97 { | 97 { |
| 98 if (!m_gamepads) | 98 if (!m_gamepads) |
| 99 m_gamepads = GamepadList::create(); | 99 m_gamepads = GamepadList::create(); |
| 100 if (startUpdatingIfAttached()) | 100 if (startUpdatingIfAttached()) |
| 101 sampleGamepads<Gamepad>(m_gamepads.get()); | 101 sampleGamepads<Gamepad>(m_gamepads.get()); |
| 102 return m_gamepads.get(); | 102 return m_gamepads.get(); |
| 103 } | 103 } |
| 104 | 104 |
| 105 DEFINE_TRACE(NavigatorGamepad) | 105 DEFINE_TRACE(NavigatorGamepad) |
| 106 { | 106 { |
| 107 visitor->trace(m_gamepads); | 107 visitor->trace(m_gamepads); |
| 108 visitor->trace(m_pendingEvents); | 108 visitor->trace(m_pendingEvents); |
| 109 WillBeHeapSupplement<Navigator>::trace(visitor); | 109 HeapSupplement<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 Loading... |
| 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 |
| OLD | NEW |