| Index: third_party/WebKit/Source/modules/gamepad/NavigatorGamepad.cpp
|
| diff --git a/third_party/WebKit/Source/modules/gamepad/NavigatorGamepad.cpp b/third_party/WebKit/Source/modules/gamepad/NavigatorGamepad.cpp
|
| index 5735dc4deff19eb40905159fa36ab1793a7c6323..a5b74047443658e8b615745eeb3474d3868bd73d 100644
|
| --- a/third_party/WebKit/Source/modules/gamepad/NavigatorGamepad.cpp
|
| +++ b/third_party/WebKit/Source/modules/gamepad/NavigatorGamepad.cpp
|
| @@ -106,15 +106,14 @@
|
| visitor->trace(m_pendingEvents);
|
| visitor->trace(m_dispatchOneEventRunner);
|
| Supplement<Navigator>::trace(visitor);
|
| - ContextLifecycleObserver::trace(visitor);
|
| + DOMWindowProperty::trace(visitor);
|
| PlatformEventController::trace(visitor);
|
| }
|
|
|
| bool NavigatorGamepad::startUpdatingIfAttached()
|
| {
|
| - Document* document = static_cast<Document*>(getExecutionContext());
|
| // The frame must be attached to start updating.
|
| - if (document && document->frame()) {
|
| + if (frame() && frame()->host()) {
|
| startUpdating();
|
| return true;
|
| }
|
| @@ -124,14 +123,14 @@
|
| void NavigatorGamepad::didUpdateData()
|
| {
|
| // We should stop listening once we detached.
|
| - Document* document = static_cast<Document*>(getExecutionContext());
|
| - DCHECK(document->frame());
|
| - DCHECK(document->frame()->domWindow());
|
| + ASSERT(frame());
|
| + ASSERT(frame()->domWindow());
|
|
|
| // We register to the dispatcher before sampling gamepads so we need to check if we actually have an event listener.
|
| if (!m_hasEventListener)
|
| return;
|
|
|
| + Document* document = frame()->domWindow()->document();
|
| if (document->activeDOMObjectsAreStopped() || document->activeDOMObjectsAreSuspended())
|
| return;
|
|
|
| @@ -152,21 +151,20 @@
|
|
|
| void NavigatorGamepad::dispatchOneEvent()
|
| {
|
| - Document* document = static_cast<Document*>(getExecutionContext());
|
| - DCHECK(document->frame());
|
| - DCHECK(document->frame()->domWindow());
|
| - DCHECK(!m_pendingEvents.isEmpty());
|
| + ASSERT(frame());
|
| + ASSERT(frame()->domWindow());
|
| + ASSERT(!m_pendingEvents.isEmpty());
|
|
|
| Gamepad* gamepad = m_pendingEvents.takeFirst();
|
| const AtomicString& eventName = gamepad->connected() ? EventTypeNames::gamepadconnected : EventTypeNames::gamepaddisconnected;
|
| - document->frame()->domWindow()->dispatchEvent(GamepadEvent::create(eventName, false, true, gamepad));
|
| + frame()->domWindow()->dispatchEvent(GamepadEvent::create(eventName, false, true, gamepad));
|
|
|
| if (!m_pendingEvents.isEmpty())
|
| m_dispatchOneEventRunner->runAsync();
|
| }
|
|
|
| NavigatorGamepad::NavigatorGamepad(LocalFrame* frame)
|
| - : ContextLifecycleObserver(frame->document())
|
| + : DOMWindowProperty(frame)
|
| , PlatformEventController(frame ? frame->page() : 0)
|
| , m_dispatchOneEventRunner(AsyncMethodRunner<NavigatorGamepad>::create(this, &NavigatorGamepad::dispatchOneEvent))
|
| {
|
| @@ -183,9 +181,16 @@
|
| return "NavigatorGamepad";
|
| }
|
|
|
| -void NavigatorGamepad::contextDestroyed()
|
| +void NavigatorGamepad::willDestroyGlobalObjectInFrame()
|
| {
|
| stopUpdating();
|
| + DOMWindowProperty::willDestroyGlobalObjectInFrame();
|
| +}
|
| +
|
| +void NavigatorGamepad::willDetachGlobalObjectFromFrame()
|
| +{
|
| + stopUpdating();
|
| + DOMWindowProperty::willDetachGlobalObjectFromFrame();
|
| }
|
|
|
| void NavigatorGamepad::registerWithDispatcher()
|
| @@ -258,7 +263,7 @@
|
| GamepadList* oldGamepads = m_gamepads.release();
|
| gamepads();
|
| GamepadList* newGamepads = m_gamepads.get();
|
| - DCHECK(newGamepads);
|
| + ASSERT(newGamepads);
|
|
|
| for (unsigned i = 0; i < WebGamepads::itemsLengthCap; ++i) {
|
| Gamepad* oldGamepad = oldGamepads ? oldGamepads->item(i) : 0;
|
|
|