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

Unified Diff: third_party/WebKit/Source/modules/vr/NavigatorVR.cpp

Issue 2539763004: Don't dispatch vrdisplayactivate event if the page that listens for it is invisible (Closed)
Patch Set: nit Created 4 years 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
« no previous file with comments | « third_party/WebKit/Source/modules/vr/NavigatorVR.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/Source/modules/vr/NavigatorVR.cpp
diff --git a/third_party/WebKit/Source/modules/vr/NavigatorVR.cpp b/third_party/WebKit/Source/modules/vr/NavigatorVR.cpp
index de32e5af44b98de1a8a58c3e5f703478dd00bb36..68a6c6b14e998fb4675a7cdbb3c4d9fc3735c9c4 100644
--- a/third_party/WebKit/Source/modules/vr/NavigatorVR.cpp
+++ b/third_party/WebKit/Source/modules/vr/NavigatorVR.cpp
@@ -92,9 +92,11 @@ DEFINE_TRACE(NavigatorVR) {
Supplement<Navigator>::trace(visitor);
DOMWindowProperty::trace(visitor);
+ PageVisibilityObserver::trace(visitor);
}
-NavigatorVR::NavigatorVR(LocalFrame* frame) : DOMWindowProperty(frame) {
+NavigatorVR::NavigatorVR(LocalFrame* frame)
+ : DOMWindowProperty(frame), PageVisibilityObserver(frame->page()) {
frame->localDOMWindow()->registerEventListenerObserver(this);
}
@@ -119,10 +121,20 @@ void NavigatorVR::dispatchVRGestureEvent(VRDisplayEvent* event) {
}
}
+void NavigatorVR::pageVisibilityChanged() {
+ if (!page())
+ return;
+ if (m_controller) {
+ m_controller->setListeningForActivate(page()->isPageVisible() &&
+ m_listeningForActivate);
+ }
+}
+
void NavigatorVR::didAddEventListener(LocalDOMWindow* window,
const AtomicString& eventType) {
if (eventType == EventTypeNames::vrdisplayactivate) {
controller()->setListeningForActivate(true);
+ m_listeningForActivate = true;
} else if (eventType == EventTypeNames::vrdisplayconnect) {
// If the page is listening for connection events make sure we've created a
// controller so that we'll be notified of new devices.
@@ -135,12 +147,14 @@ void NavigatorVR::didRemoveEventListener(LocalDOMWindow* window,
if (eventType == EventTypeNames::vrdisplayactivate &&
!window->hasEventListeners(EventTypeNames::vrdisplayactivate)) {
controller()->setListeningForActivate(false);
+ m_listeningForActivate = false;
}
}
void NavigatorVR::didRemoveAllEventListeners(LocalDOMWindow* window) {
if (m_controller) {
m_controller->setListeningForActivate(false);
+ m_listeningForActivate = false;
}
}
« no previous file with comments | « third_party/WebKit/Source/modules/vr/NavigatorVR.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698