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

Side by Side Diff: third_party/WebKit/Source/modules/vr/VRDisplay.cpp

Issue 2754133002: Remove gesture token from vrdisplayactivate (Closed)
Patch Set: Created 3 years, 9 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 unified diff | Download patch
« no previous file with comments | « third_party/WebKit/Source/modules/vr/VRDisplay.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "modules/vr/VRDisplay.h" 5 #include "modules/vr/VRDisplay.h"
6 6
7 #include "core/css/StylePropertySet.h" 7 #include "core/css/StylePropertySet.h"
8 #include "core/dom/DOMException.h" 8 #include "core/dom/DOMException.h"
9 #include "core/dom/DocumentUserGestureToken.h"
10 #include "core/dom/FrameRequestCallback.h" 9 #include "core/dom/FrameRequestCallback.h"
11 #include "core/dom/Fullscreen.h" 10 #include "core/dom/Fullscreen.h"
12 #include "core/dom/ScriptedAnimationController.h" 11 #include "core/dom/ScriptedAnimationController.h"
13 #include "core/dom/TaskRunnerHelper.h" 12 #include "core/dom/TaskRunnerHelper.h"
14 #include "core/frame/UseCounter.h" 13 #include "core/frame/UseCounter.h"
15 #include "core/inspector/ConsoleMessage.h" 14 #include "core/inspector/ConsoleMessage.h"
16 #include "core/loader/DocumentLoader.h" 15 #include "core/loader/DocumentLoader.h"
17 #include "gpu/command_buffer/client/gles2_interface.h" 16 #include "gpu/command_buffer/client/gles2_interface.h"
18 #include "modules/EventTargetModules.h" 17 #include "modules/EventTargetModules.h"
19 #include "modules/vr/NavigatorVR.h" 18 #include "modules/vr/NavigatorVR.h"
(...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after
224 ReportPresentationResult(PresentationResult::VRDisplayCannotPresent); 223 ReportPresentationResult(PresentationResult::VRDisplayCannotPresent);
225 return promise; 224 return promise;
226 } 225 }
227 226
228 bool firstPresent = !m_isPresenting; 227 bool firstPresent = !m_isPresenting;
229 228
230 // Initiating VR presentation is only allowed in response to a user gesture. 229 // Initiating VR presentation is only allowed in response to a user gesture.
231 // If the VRDisplay is already presenting, however, repeated calls are 230 // If the VRDisplay is already presenting, however, repeated calls are
232 // allowed outside a user gesture so that the presented content may be 231 // allowed outside a user gesture so that the presented content may be
233 // updated. 232 // updated.
234 if (firstPresent && !UserGestureIndicator::utilizeUserGesture()) { 233 if (firstPresent && !UserGestureIndicator::utilizeUserGesture() &&
234 !m_inDisplayActivate) {
235 DOMException* exception = DOMException::create( 235 DOMException* exception = DOMException::create(
236 InvalidStateError, "API can only be initiated by a user gesture."); 236 InvalidStateError, "API can only be initiated by a user gesture.");
237 resolver->reject(exception); 237 resolver->reject(exception);
238 ReportPresentationResult(PresentationResult::NotInitiatedByUserGesture); 238 ReportPresentationResult(PresentationResult::NotInitiatedByUserGesture);
239 return promise; 239 return promise;
240 } 240 }
241 241
242 // TODO(mthiesse): Remove fullscreen requirement for presentation. See 242 // TODO(mthiesse): Remove fullscreen requirement for presentation. See
243 // crbug.com/687369 243 // crbug.com/687369
244 Document* doc = this->document(); 244 Document* doc = this->document();
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after
373 373
374 resolver->resolve(); 374 resolver->resolve();
375 375
376 stopPresenting(); 376 stopPresenting();
377 377
378 return promise; 378 return promise;
379 } 379 }
380 380
381 void VRDisplay::beginPresent() { 381 void VRDisplay::beginPresent() {
382 Document* doc = this->document(); 382 Document* doc = this->document();
383 std::unique_ptr<UserGestureIndicator> gestureIndicator;
384 if (m_capabilities->hasExternalDisplay()) { 383 if (m_capabilities->hasExternalDisplay()) {
385 forceExitPresent(); 384 forceExitPresent();
386 DOMException* exception = DOMException::create( 385 DOMException* exception = DOMException::create(
387 InvalidStateError, 386 InvalidStateError,
388 "VR Presentation not implemented for this VRDisplay."); 387 "VR Presentation not implemented for this VRDisplay.");
389 while (!m_pendingPresentResolvers.isEmpty()) { 388 while (!m_pendingPresentResolvers.isEmpty()) {
390 ScriptPromiseResolver* resolver = m_pendingPresentResolvers.takeFirst(); 389 ScriptPromiseResolver* resolver = m_pendingPresentResolvers.takeFirst();
391 resolver->reject(exception); 390 resolver->reject(exception);
392 } 391 }
393 ReportPresentationResult( 392 ReportPresentationResult(
(...skipping 265 matching lines...) Expand 10 before | Expand all | Expand 10 after
659 OnPresentChange(); 658 OnPresentChange();
660 } 659 }
661 660
662 m_renderingContext = nullptr; 661 m_renderingContext = nullptr;
663 m_contextGL = nullptr; 662 m_contextGL = nullptr;
664 } 663 }
665 664
666 void VRDisplay::OnActivate(device::mojom::blink::VRDisplayEventReason reason) { 665 void VRDisplay::OnActivate(device::mojom::blink::VRDisplayEventReason reason) {
667 if (!m_navigatorVR->isFocused() || m_displayBlurred) 666 if (!m_navigatorVR->isFocused() || m_displayBlurred)
668 return; 667 return;
669 m_navigatorVR->dispatchVRGestureEvent(VRDisplayEvent::create( 668 AutoReset<bool> activating(&m_inDisplayActivate, true);
669 m_navigatorVR->dispatchVREvent(VRDisplayEvent::create(
670 EventTypeNames::vrdisplayactivate, true, false, this, reason)); 670 EventTypeNames::vrdisplayactivate, true, false, this, reason));
671 } 671 }
672 672
673 void VRDisplay::OnDeactivate( 673 void VRDisplay::OnDeactivate(
674 device::mojom::blink::VRDisplayEventReason reason) { 674 device::mojom::blink::VRDisplayEventReason reason) {
675 m_navigatorVR->enqueueVREvent(VRDisplayEvent::create( 675 m_navigatorVR->enqueueVREvent(VRDisplayEvent::create(
676 EventTypeNames::vrdisplaydeactivate, true, false, this, reason)); 676 EventTypeNames::vrdisplaydeactivate, true, false, this, reason));
677 } 677 }
678 678
679 void VRDisplay::OnVSync(device::mojom::blink::VRPosePtr pose, 679 void VRDisplay::OnVSync(device::mojom::blink::VRPosePtr pose,
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after
807 visitor->trace(m_stageParameters); 807 visitor->trace(m_stageParameters);
808 visitor->trace(m_eyeParametersLeft); 808 visitor->trace(m_eyeParametersLeft);
809 visitor->trace(m_eyeParametersRight); 809 visitor->trace(m_eyeParametersRight);
810 visitor->trace(m_layer); 810 visitor->trace(m_layer);
811 visitor->trace(m_renderingContext); 811 visitor->trace(m_renderingContext);
812 visitor->trace(m_scriptedAnimationController); 812 visitor->trace(m_scriptedAnimationController);
813 visitor->trace(m_pendingPresentResolvers); 813 visitor->trace(m_pendingPresentResolvers);
814 } 814 }
815 815
816 } // namespace blink 816 } // namespace blink
OLDNEW
« 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