| 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 206 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 217 return false; | 217 return false; |
| 218 } | 218 } |
| 219 | 219 |
| 220 static bool isGamepadEvent(const AtomicString& eventType) | 220 static bool isGamepadEvent(const AtomicString& eventType) |
| 221 { | 221 { |
| 222 return eventType == EventTypeNames::gamepadconnected || eventType == EventTy
peNames::gamepaddisconnected; | 222 return eventType == EventTypeNames::gamepadconnected || eventType == EventTy
peNames::gamepaddisconnected; |
| 223 } | 223 } |
| 224 | 224 |
| 225 void NavigatorGamepad::didAddEventListener(LocalDOMWindow*, const AtomicString&
eventType) | 225 void NavigatorGamepad::didAddEventListener(LocalDOMWindow*, const AtomicString&
eventType) |
| 226 { | 226 { |
| 227 if (RuntimeEnabledFeatures::gamepadEnabled() && isGamepadEvent(eventType)) { | 227 if (isGamepadEvent(eventType)) { |
| 228 if (page() && page()->visibilityState() == PageVisibilityStateVisible) | 228 if (page() && page()->visibilityState() == PageVisibilityStateVisible) |
| 229 startUpdating(); | 229 startUpdating(); |
| 230 m_hasEventListener = true; | 230 m_hasEventListener = true; |
| 231 } | 231 } |
| 232 } | 232 } |
| 233 | 233 |
| 234 void NavigatorGamepad::didRemoveEventListener(LocalDOMWindow* window, const Atom
icString& eventType) | 234 void NavigatorGamepad::didRemoveEventListener(LocalDOMWindow* window, const Atom
icString& eventType) |
| 235 { | 235 { |
| 236 if (isGamepadEvent(eventType) | 236 if (isGamepadEvent(eventType) |
| 237 && !window->hasEventListeners(EventTypeNames::gamepadconnected) | 237 && !window->hasEventListeners(EventTypeNames::gamepadconnected) |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 284 if (connectedGamepadChanged || (!oldWasConnected && newIsConnected)) { | 284 if (connectedGamepadChanged || (!oldWasConnected && newIsConnected)) { |
| 285 m_pendingEvents.append(newGamepad); | 285 m_pendingEvents.append(newGamepad); |
| 286 } | 286 } |
| 287 } | 287 } |
| 288 | 288 |
| 289 if (!m_pendingEvents.isEmpty()) | 289 if (!m_pendingEvents.isEmpty()) |
| 290 m_dispatchOneEventRunner.runAsync(); | 290 m_dispatchOneEventRunner.runAsync(); |
| 291 } | 291 } |
| 292 | 292 |
| 293 } // namespace blink | 293 } // namespace blink |
| OLD | NEW |