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

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

Issue 2668003003: Provide WebVR pose data only to the focused frame. (Closed)
Patch Set: Address comments Created 3 years, 10 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/vr/NavigatorVR.cpp
diff --git a/third_party/WebKit/Source/modules/vr/NavigatorVR.cpp b/third_party/WebKit/Source/modules/vr/NavigatorVR.cpp
index 076b64f97ce91586aaa57f9bb66de94042215eba..9afab6780516d62c816cc3c292538588cb1a6a1d 100644
--- a/third_party/WebKit/Source/modules/vr/NavigatorVR.cpp
+++ b/third_party/WebKit/Source/modules/vr/NavigatorVR.cpp
@@ -77,6 +77,8 @@ VRController* NavigatorVR::controller() {
if (!m_controller) {
m_controller = new VRController(this);
+ m_controller->setListeningForActivate(m_focused && m_listeningForActivate);
+ m_controller->focusChanged();
}
return m_controller;
@@ -90,13 +92,13 @@ Document* NavigatorVR::document() {
DEFINE_TRACE(NavigatorVR) {
visitor->trace(m_controller);
Supplement<Navigator>::trace(visitor);
- PageVisibilityObserver::trace(visitor);
}
NavigatorVR::NavigatorVR(Navigator& navigator)
: Supplement<Navigator>(navigator),
- PageVisibilityObserver(navigator.frame()->page()) {
+ FocusChangedObserver(navigator.frame()->page()) {
navigator.frame()->domWindow()->registerEventListenerObserver(this);
+ focusedFrameChanged();
}
NavigatorVR::~NavigatorVR() {}
@@ -122,12 +124,14 @@ void NavigatorVR::dispatchVRGestureEvent(VRDisplayEvent* event) {
window->dispatchEvent(event);
}
-void NavigatorVR::pageVisibilityChanged() {
- if (!page())
+void NavigatorVR::focusedFrameChanged() {
+ bool focused = isFrameFocused(supplementable()->frame());
+ if (focused == m_focused)
return;
+ m_focused = focused;
if (m_controller) {
- m_controller->setListeningForActivate(page()->isPageVisible() &&
- m_listeningForActivate);
+ m_controller->setListeningForActivate(m_listeningForActivate && focused);
+ m_controller->focusChanged();
}
}
@@ -138,8 +142,8 @@ void NavigatorVR::didAddEventListener(LocalDOMWindow* window,
if (eventType == EventTypeNames::vrdisplayactivate &&
supplementable()->frame() && supplementable()->frame()->document() &&
Fullscreen::fullscreenEnabled(*supplementable()->frame()->document())) {
- controller()->setListeningForActivate(true);
m_listeningForActivate = true;
+ controller()->setListeningForActivate(m_focused);
} 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.
@@ -151,8 +155,8 @@ void NavigatorVR::didRemoveEventListener(LocalDOMWindow* window,
const AtomicString& eventType) {
if (eventType == EventTypeNames::vrdisplayactivate &&
!window->hasEventListeners(EventTypeNames::vrdisplayactivate)) {
- controller()->setListeningForActivate(false);
m_listeningForActivate = false;
+ controller()->setListeningForActivate(false);
}
}
« no previous file with comments | « third_party/WebKit/Source/modules/vr/NavigatorVR.h ('k') | third_party/WebKit/Source/modules/vr/VRController.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698