Index: third_party/WebKit/Source/modules/vr/VRDisplay.cpp |
diff --git a/third_party/WebKit/Source/modules/vr/VRDisplay.cpp b/third_party/WebKit/Source/modules/vr/VRDisplay.cpp |
index 553622a0dfa064f16522cfd8694dc7834f1abb48..55570f8f3b9e280804584310048828ea30b1305a 100644 |
--- a/third_party/WebKit/Source/modules/vr/VRDisplay.cpp |
+++ b/third_party/WebKit/Source/modules/vr/VRDisplay.cpp |
@@ -9,6 +9,7 @@ |
#include "core/dom/FrameRequestCallback.h" |
#include "core/dom/ScriptedAnimationController.h" |
#include "core/dom/TaskRunnerHelper.h" |
+#include "core/frame/Frame.h" |
#include "core/frame/FrameView.h" |
#include "core/frame/ImageBitmap.h" |
#include "core/frame/UseCounter.h" |
@@ -104,8 +105,36 @@ void VRDisplay::Update(const device::mojom::blink::VRDisplayInfoPtr& display) { |
} |
} |
+bool VRDisplay::IsPresentationFocused() { |
+ if (!navigator_vr_) |
+ return false; |
+ |
+ if (navigator_vr_->IsFocused()) |
+ return true; |
+ |
+ auto doc = navigator_vr_->GetDocument(); |
+ if (!doc) |
+ return false; |
+ |
+ // Check if this is an embedded iframe without focus. If a local parent is |
+ // focused, continue presenting. |
+ |
+ Frame* frame = doc->GetFrame(); |
+ for (; frame; frame = frame->Tree().Parent()) { |
+ if (!frame->IsLocalFrame()) |
+ break; |
+ auto frame_doc = ToLocalFrame(frame)->GetDocument(); |
+ if (frame_doc && frame_doc->hasFocus()) { |
+ DVLOG(3) << __FUNCTION__ << ": a parent frame is focused"; |
+ return true; |
+ } |
+ } |
+ |
+ return false; |
+} |
+ |
bool VRDisplay::getFrameData(VRFrameData* frame_data) { |
- if (!navigator_vr_->IsFocused() || !frame_pose_ || display_blurred_) |
+ if (!IsPresentationFocused() || !frame_pose_ || display_blurred_) |
return false; |
if (!frame_data) |
@@ -747,7 +776,11 @@ void VRDisplay::OnVSync(device::mojom::blink::VRPosePtr pose, |
} |
void VRDisplay::ConnectVSyncProvider() { |
- if (!navigator_vr_->IsFocused() || vr_v_sync_provider_.is_bound()) |
+ DVLOG(1) << __FUNCTION__ |
+ << ": IsPresentationFocused()=" << IsPresentationFocused() |
+ << " vr_v_sync_provider_.is_bound()=" |
+ << vr_v_sync_provider_.is_bound(); |
+ if (!IsPresentationFocused() || vr_v_sync_provider_.is_bound()) |
return; |
display_->GetVRVSyncProvider(mojo::MakeRequest(&vr_v_sync_provider_)); |
vr_v_sync_provider_.set_connection_error_handler(ConvertToBaseCallback( |