| Index: Source/modules/gamepad/NavigatorGamepad.cpp
|
| diff --git a/Source/modules/gamepad/NavigatorGamepad.cpp b/Source/modules/gamepad/NavigatorGamepad.cpp
|
| index 118aa9453277b573f4789196923a55c8ee597910..c68f061fff5d0497122022d45368e78d7ee3adae 100644
|
| --- a/Source/modules/gamepad/NavigatorGamepad.cpp
|
| +++ b/Source/modules/gamepad/NavigatorGamepad.cpp
|
| @@ -97,11 +97,8 @@ GamepadList* NavigatorGamepad::gamepads()
|
| {
|
| if (!m_gamepads)
|
| m_gamepads = GamepadList::create();
|
| - if (frame() && frame()->host()) {
|
| - // The frame must be attached to start updating.
|
| - startUpdating();
|
| + if (startUpdatingIfAttached())
|
| sampleGamepads<Gamepad>(m_gamepads.get());
|
| - }
|
| return m_gamepads.get();
|
| }
|
|
|
| @@ -115,6 +112,16 @@ void NavigatorGamepad::trace(Visitor* visitor)
|
| DOMWindowLifecycleObserver::trace(visitor);
|
| }
|
|
|
| +bool NavigatorGamepad::startUpdatingIfAttached()
|
| +{
|
| + // The frame must be attached to start updating.
|
| + if (frame() && frame()->host()) {
|
| + startUpdating();
|
| + return true;
|
| + }
|
| + return false;
|
| +}
|
| +
|
| void NavigatorGamepad::didUpdateData()
|
| {
|
| // We should stop listening once we detached.
|
| @@ -214,7 +221,7 @@ void NavigatorGamepad::didAddEventListener(LocalDOMWindow*, const AtomicString&
|
| {
|
| if (isGamepadEvent(eventType)) {
|
| if (page() && page()->visibilityState() == PageVisibilityStateVisible)
|
| - startUpdating();
|
| + startUpdatingIfAttached();
|
| m_hasEventListener = true;
|
| }
|
| }
|
| @@ -245,7 +252,7 @@ void NavigatorGamepad::pageVisibilityChanged()
|
| // Inform the embedder whether it needs to provide gamepad data for us.
|
| bool visible = page()->visibilityState() == PageVisibilityStateVisible;
|
| if (visible && (m_hasEventListener || m_gamepads))
|
| - startUpdating();
|
| + startUpdatingIfAttached();
|
| else
|
| stopUpdating();
|
|
|
|
|