Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(685)

Unified Diff: third_party/WebKit/Source/modules/gamepad/NavigatorGamepad.cpp

Issue 2138003002: Remove DOMWindowProperty::willDetachGlobalObjectFromFrame (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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 c4cd70d46a17a1d34221da80adeb0842dcc5d521..557e0b186c77d6996dcfc5ee5ceb36b2e3b9a025 100644
--- a/third_party/WebKit/Source/modules/gamepad/NavigatorGamepad.cpp
+++ b/third_party/WebKit/Source/modules/gamepad/NavigatorGamepad.cpp
@@ -107,15 +107,16 @@ DEFINE_TRACE(NavigatorGamepad)
visitor->trace(m_pendingEvents);
visitor->trace(m_dispatchOneEventRunner);
Supplement<Navigator>::trace(visitor);
- DOMWindowProperty::trace(visitor);
+ ContextLifecycleObserver::trace(visitor);
PlatformEventController::trace(visitor);
DOMWindowLifecycleObserver::trace(visitor);
}
bool NavigatorGamepad::startUpdatingIfAttached()
{
+ Document* document = static_cast<Document*>(getExecutionContext());
// The frame must be attached to start updating.
- if (frame() && frame()->host()) {
+ if (document && document->frame() && document->frame()->host()) {
dcheng 2016/07/11 13:38:20 I wonder if it's possible to have document->frame(
startUpdating();
return true;
}
@@ -125,14 +126,14 @@ bool NavigatorGamepad::startUpdatingIfAttached()
void NavigatorGamepad::didUpdateData()
{
// We should stop listening once we detached.
- ASSERT(frame());
- ASSERT(frame()->domWindow());
+ Document* document = static_cast<Document*>(getExecutionContext());
+ DCHECK(document->frame());
+ DCHECK(document->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;
@@ -153,20 +154,21 @@ void NavigatorGamepad::didUpdateData()
void NavigatorGamepad::dispatchOneEvent()
{
- ASSERT(frame());
- ASSERT(frame()->domWindow());
- ASSERT(!m_pendingEvents.isEmpty());
+ Document* document = static_cast<Document*>(getExecutionContext());
+ DCHECK(document->frame());
+ DCHECK(document->frame()->domWindow());
+ DCHECK(!m_pendingEvents.isEmpty());
Gamepad* gamepad = m_pendingEvents.takeFirst();
const AtomicString& eventName = gamepad->connected() ? EventTypeNames::gamepadconnected : EventTypeNames::gamepaddisconnected;
- frame()->domWindow()->dispatchEvent(GamepadEvent::create(eventName, false, true, gamepad));
+ document->frame()->domWindow()->dispatchEvent(GamepadEvent::create(eventName, false, true, gamepad));
if (!m_pendingEvents.isEmpty())
m_dispatchOneEventRunner->runAsync();
}
NavigatorGamepad::NavigatorGamepad(LocalFrame* frame)
- : DOMWindowProperty(frame)
+ : ContextLifecycleObserver(frame->document())
, PlatformEventController(frame ? frame->page() : 0)
, DOMWindowLifecycleObserver(frame ? frame->localDOMWindow() : 0)
, m_dispatchOneEventRunner(AsyncMethodRunner<NavigatorGamepad>::create(this, &NavigatorGamepad::dispatchOneEvent))
@@ -182,16 +184,9 @@ const char* NavigatorGamepad::supplementName()
return "NavigatorGamepad";
}
-void NavigatorGamepad::willDestroyGlobalObjectInFrame()
+void NavigatorGamepad::contextDestroyed()
{
stopUpdating();
- DOMWindowProperty::willDestroyGlobalObjectInFrame();
-}
-
-void NavigatorGamepad::willDetachGlobalObjectFromFrame()
-{
- stopUpdating();
- DOMWindowProperty::willDetachGlobalObjectFromFrame();
}
void NavigatorGamepad::registerWithDispatcher()
@@ -264,7 +259,7 @@ void NavigatorGamepad::pageVisibilityChanged()
GamepadList* oldGamepads = m_gamepads.release();
gamepads();
GamepadList* newGamepads = m_gamepads.get();
- ASSERT(newGamepads);
+ DCHECK(newGamepads);
for (unsigned i = 0; i < WebGamepads::itemsLengthCap; ++i) {
Gamepad* oldGamepad = oldGamepads ? oldGamepads->item(i) : 0;

Powered by Google App Engine
This is Rietveld 408576698