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

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

Issue 2668003003: Provide WebVR pose data only to the focused frame. (Closed)
Patch Set: Update to correct copyright notice? Created 3 years, 11 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 c29f8405d094d66596dc02b21e17045db4c89ae0..11bae92a6288a7673326addf76704f4dbc526e47 100644
--- a/third_party/WebKit/Source/modules/vr/NavigatorVR.cpp
+++ b/third_party/WebKit/Source/modules/vr/NavigatorVR.cpp
@@ -13,6 +13,7 @@
#include "core/frame/LocalFrame.h"
#include "core/frame/Navigator.h"
#include "core/frame/UseCounter.h"
+#include "core/page/FocusController.h"
#include "core/page/Page.h"
#include "modules/vr/VRController.h"
#include "modules/vr/VRDisplay.h"
@@ -76,6 +77,8 @@ VRController* NavigatorVR::controller() {
if (!m_controller) {
m_controller = new VRController(this);
+ m_controller->setListeningForActivate(m_listeningForActivate);
+ m_controller->focusChanged(m_focused);
}
return m_controller;
@@ -89,13 +92,14 @@ 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()) {
+ : Supplement<Navigator>(navigator) {
navigator.frame()->domWindow()->registerEventListenerObserver(this);
+ navigator.frame()->page()->focusController().registerFocusChangedObserver(
+ this);
+ focusedFrameChanged();
}
NavigatorVR::~NavigatorVR() {}
@@ -121,19 +125,30 @@ void NavigatorVR::dispatchVRGestureEvent(VRDisplayEvent* event) {
window->dispatchEvent(event);
}
-void NavigatorVR::pageVisibilityChanged() {
- if (!page())
+void NavigatorVR::focusedFrameChanged() {
jbroman 2017/02/02 16:07:20 nit: This condition might be clearer factored out
mthiesse 2017/02/02 17:52:18 Done.
+ if (supplementable() && supplementable()->frame() &&
+ supplementable()->frame()->page() &&
+ supplementable()->frame()->document() &&
+ supplementable()->frame()->page()->focusController().isDocumentFocused(
jbroman 2017/02/02 16:07:20 Do you really want isDocumentFocused? This will re
mthiesse 2017/02/02 17:52:18 Hmm I think you're right, and isDocumentFocused wa
+ *supplementable()->frame()->document())) {
+ if (!m_focused && m_controller) {
+ m_controller->setListeningForActivate(m_listeningForActivate);
+ m_controller->focusChanged(true);
+ }
+ m_focused = true;
return;
- if (m_controller) {
- m_controller->setListeningForActivate(page()->isPageVisible() &&
- m_listeningForActivate);
}
+ if (m_focused && m_controller) {
+ m_controller->setListeningForActivate(false);
+ m_controller->focusChanged(false);
+ }
+ m_focused = false;
}
void NavigatorVR::didAddEventListener(LocalDOMWindow* window,
const AtomicString& eventType) {
if (eventType == EventTypeNames::vrdisplayactivate) {
- controller()->setListeningForActivate(true);
+ controller()->setListeningForActivate(m_focused);
m_listeningForActivate = true;
} else if (eventType == EventTypeNames::vrdisplayconnect) {
// If the page is listening for connection events make sure we've created a

Powered by Google App Engine
This is Rietveld 408576698