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

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

Issue 2689563008: Fix WebVR does not properly stop presenting if requestPresent rejects. (Closed)
Patch Set: address comment 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
« no previous file with comments | « third_party/WebKit/Source/modules/vr/VRDisplay.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/VRDisplay.cpp
diff --git a/third_party/WebKit/Source/modules/vr/VRDisplay.cpp b/third_party/WebKit/Source/modules/vr/VRDisplay.cpp
index 0c6bc0ed5a89f78159ed2d4a30dfb87394962ac2..11ab5b1492fcfed302b5e14326125fbd7c55e089 100644
--- a/third_party/WebKit/Source/modules/vr/VRDisplay.cpp
+++ b/third_party/WebKit/Source/modules/vr/VRDisplay.cpp
@@ -365,7 +365,7 @@ ScriptPromise VRDisplay::exitPresent(ScriptState* scriptState) {
resolver->resolve();
- forceExitPresent();
+ stopPresenting();
return promise;
}
@@ -447,30 +447,12 @@ void VRDisplay::beginPresent() {
OnPresentChange();
}
+// Need to close service if exists and then free rendering context.
void VRDisplay::forceExitPresent() {
- if (m_isPresenting) {
- if (!m_capabilities->hasExternalDisplay()) {
- auto canvas = m_layer.source();
- Fullscreen::fullyExitFullscreen(canvas->document());
- m_fullscreenCheckTimer.stop();
- if (!m_fullscreenOrigWidth.isNull()) {
- canvas->setInlineStyleProperty(CSSPropertyWidth, m_fullscreenOrigWidth);
- m_fullscreenOrigWidth = String();
- }
- if (!m_fullscreenOrigHeight.isNull()) {
- canvas->setInlineStyleProperty(CSSPropertyWidth,
- m_fullscreenOrigHeight);
- m_fullscreenOrigHeight = String();
- }
- } else {
- // Can't get into this presentation mode, so nothing to do here.
- }
- m_isPresenting = false;
- OnPresentChange();
+ if (m_display) {
+ m_display->ExitPresent();
}
-
- m_renderingContext = nullptr;
- m_contextGL = nullptr;
+ stopPresenting();
}
void VRDisplay::updateLayerBounds() {
@@ -612,7 +594,7 @@ void VRDisplay::OnChanged(device::mojom::blink::VRDisplayInfoPtr display) {
}
void VRDisplay::OnExitPresent() {
- forceExitPresent();
+ stopPresenting();
}
void VRDisplay::onConnected() {
@@ -625,6 +607,32 @@ void VRDisplay::onDisconnected() {
EventTypeNames::vrdisplaydisconnect, true, false, this, "disconnect"));
}
+void VRDisplay::stopPresenting() {
+ if (m_isPresenting) {
+ if (!m_capabilities->hasExternalDisplay()) {
+ auto canvas = m_layer.source();
+ Fullscreen::fullyExitFullscreen(canvas->document());
+ m_fullscreenCheckTimer.stop();
+ if (!m_fullscreenOrigWidth.isNull()) {
+ canvas->setInlineStyleProperty(CSSPropertyWidth, m_fullscreenOrigWidth);
+ m_fullscreenOrigWidth = String();
+ }
+ if (!m_fullscreenOrigHeight.isNull()) {
+ canvas->setInlineStyleProperty(CSSPropertyWidth,
+ m_fullscreenOrigHeight);
+ m_fullscreenOrigHeight = String();
+ }
+ } else {
+ // Can't get into this presentation mode, so nothing to do here.
+ }
+ m_isPresenting = false;
+ OnPresentChange();
+ }
+
+ m_renderingContext = nullptr;
+ m_contextGL = nullptr;
+}
+
void VRDisplay::OnActivate(device::mojom::blink::VRDisplayEventReason reason) {
if (!m_navigatorVR->isFocused() || m_displayBlurred)
return;
« no previous file with comments | « third_party/WebKit/Source/modules/vr/VRDisplay.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698