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

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

Issue 2510873003: Clean up WebVR RequestPresent and make callback asynchronous. (Closed)
Patch Set: Created 4 years, 1 month 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
« device/vr/vr_display_impl.cc ('K') | « device/vr/vr_display_impl.cc ('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/VRDisplay.cpp
diff --git a/third_party/WebKit/Source/modules/vr/VRDisplay.cpp b/third_party/WebKit/Source/modules/vr/VRDisplay.cpp
index 5095591ba779b8a8d11fd83c476028c02176f23f..670c4013f8ec4132eb7b11f0ef26f6ee71ed6cec 100644
--- a/third_party/WebKit/Source/modules/vr/VRDisplay.cpp
+++ b/third_party/WebKit/Source/modules/vr/VRDisplay.cpp
@@ -5,6 +5,7 @@
#include "modules/vr/VRDisplay.h"
#include "core/dom/DOMException.h"
+#include "core/dom/DocumentUserGestureToken.h"
#include "core/dom/FrameRequestCallback.h"
#include "core/dom/Fullscreen.h"
#include "core/dom/ScriptedAnimationController.h"
@@ -335,18 +336,6 @@ ScriptPromise VRDisplay::requestPresent(ScriptState* scriptState,
return promise;
}
- if (!m_capabilities->hasExternalDisplay()) {
- // TODO: Need a proper VR compositor, but for the moment on mobile
- // we'll just make the canvas fullscreen so that VrShell can pick it
- // up through the standard (high latency) compositing path.
- Fullscreen::requestFullscreen(*m_layer.source(),
- Fullscreen::UnprefixedRequest);
-
- // Check to see if the canvas is still the current fullscreen
- // element once per second.
- m_fullscreenCheckTimer.startRepeating(1.0, BLINK_FROM_HERE);
- }
-
if (firstPresent) {
bool secureContext = scriptState->getExecutionContext()->isSecureContext();
if (!m_display) {
@@ -409,6 +398,8 @@ ScriptPromise VRDisplay::exitPresent(ScriptState* scriptState) {
}
void VRDisplay::beginPresent(ScriptPromiseResolver* resolver) {
+ Document* doc = m_navigatorVR->document();
+ std::unique_ptr<UserGestureIndicator> gestureIndicator;
if (m_capabilities->hasExternalDisplay()) {
forceExitPresent();
DOMException* exception = DOMException::create(
@@ -418,9 +409,25 @@ void VRDisplay::beginPresent(ScriptPromiseResolver* resolver) {
ReportPresentationResult(
PresentationResult::PresentationNotSupportedByDisplay);
return;
+ } else {
+ // TODO: Need a proper VR compositor, but for the moment on mobile
+ // we'll just make the canvas fullscreen so that VrShell can pick it
+ // up through the standard (high latency) compositing path.
+ if (doc) {
+ // Since the callback for requestPresent is asynchronous, we've lost our
+ // UserGestureToken, and need to create a new one to enter fullscreen.
+ gestureIndicator =
+ wrapUnique(new UserGestureIndicator(DocumentUserGestureToken::create(
+ doc, UserGestureToken::Status::PossiblyExistingGesture)));
+ }
+ Fullscreen::requestFullscreen(*m_layer.source(),
+ Fullscreen::UnprefixedRequest);
+
+ // Check to see if the canvas is still the current fullscreen
+ // element once per second.
+ m_fullscreenCheckTimer.startRepeating(1.0, BLINK_FROM_HERE);
}
- Document* doc = m_navigatorVR->document();
if (doc) {
Platform::current()->recordRapporURL("VR.WebVR.PresentSuccess",
WebURL(doc->url()));
« device/vr/vr_display_impl.cc ('K') | « device/vr/vr_display_impl.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698