| 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 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 66 into->set(i, gamepad); | 66 into->set(i, gamepad); |
| 67 } else { | 67 } else { |
| 68 into->set(i, 0); | 68 into->set(i, 0); |
| 69 } | 69 } |
| 70 } | 70 } |
| 71 } | 71 } |
| 72 | 72 |
| 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 nullptr; |
| 77 Navigator& navigator = *document.frame()->domWindow()->navigator(); | 77 Navigator* navigator = document.frame()->domWindow()->navigator(); |
| 78 return &from(navigator); | 78 if (!navigator) |
| 79 return nullptr; |
| 80 return &from(*navigator); |
| 79 } | 81 } |
| 80 | 82 |
| 81 NavigatorGamepad& NavigatorGamepad::from(Navigator& navigator) | 83 NavigatorGamepad& NavigatorGamepad::from(Navigator& navigator) |
| 82 { | 84 { |
| 83 NavigatorGamepad* supplement = static_cast<NavigatorGamepad*>(HeapSupplement
<Navigator>::from(navigator, supplementName())); | 85 NavigatorGamepad* supplement = static_cast<NavigatorGamepad*>(HeapSupplement
<Navigator>::from(navigator, supplementName())); |
| 84 if (!supplement) { | 86 if (!supplement) { |
| 85 supplement = new NavigatorGamepad(navigator.frame()); | 87 supplement = new NavigatorGamepad(navigator.frame()); |
| 86 provideTo(navigator, supplementName(), supplement); | 88 provideTo(navigator, supplementName(), supplement); |
| 87 } | 89 } |
| 88 return *supplement; | 90 return *supplement; |
| (...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 279 if (connectedGamepadChanged || (!oldWasConnected && newIsConnected)) { | 281 if (connectedGamepadChanged || (!oldWasConnected && newIsConnected)) { |
| 280 m_pendingEvents.append(newGamepad); | 282 m_pendingEvents.append(newGamepad); |
| 281 } | 283 } |
| 282 } | 284 } |
| 283 | 285 |
| 284 if (!m_pendingEvents.isEmpty()) | 286 if (!m_pendingEvents.isEmpty()) |
| 285 m_dispatchOneEventRunner.runAsync(); | 287 m_dispatchOneEventRunner.runAsync(); |
| 286 } | 288 } |
| 287 | 289 |
| 288 } // namespace blink | 290 } // namespace blink |
| OLD | NEW |