Bug 1626812 - Dispatch XRSessionEvent end when exiting XRSession. r=kip
☠☠ backed out by c125833dc46a ☠ ☠
authorDaosheng Mu <daoshengmu@gmail.com>
Tue, 07 Apr 2020 21:26:46 +0000
changeset 522824 481325c44e806c01a24b1adb63f519ea383b4fc2
parent 522823 546b90fd16893acd681e1f1628d48254e0a38946
child 522825 b975de50682b1097d637427179f35c5d29b4e3e0
push id112323
push userdmu@mozilla.com
push dateTue, 07 Apr 2020 22:27:21 +0000
treeherderautoland@481325c44e80 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerskip
bugs1626812
milestone77.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1626812 - Dispatch XRSessionEvent end when exiting XRSession. r=kip Differential Revision: https://phabricator.services.mozilla.com/D69296
dom/vr/XRSession.cpp
--- a/dom/vr/XRSession.cpp
+++ b/dom/vr/XRSession.cpp
@@ -1,16 +1,17 @@
 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
 /* vim: set ts=8 sts=2 et sw=2 tw=80: */
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this file,
  * You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "mozilla/dom/XRSession.h"
 
+#include "mozilla/dom/XRSessionEvent.h"
 #include "mozilla/dom/DocumentInlines.h"
 #include "XRSystem.h"
 #include "XRRenderState.h"
 #include "XRBoundedReferenceSpace.h"
 #include "XRFrame.h"
 #include "XRNativeOrigin.h"
 #include "XRNativeOriginFixed.h"
 #include "XRNativeOriginViewer.h"
@@ -408,17 +409,26 @@ void XRSession::ExitPresentInternal() {
 
   if (mXRSystem) {
     mXRSystem->SessionEnded(this);
   }
 
   mDisplayPresentation = nullptr;
   if (!mEnded) {
     mEnded = true;
-    DispatchTrustedEvent(NS_LITERAL_STRING("end"));
+
+    XRSessionEventInit init;
+    init.mBubbles = false;
+    init.mCancelable = false;
+    init.mSession = this;
+    RefPtr<XRSessionEvent> event = XRSessionEvent::Constructor(this,
+      NS_LITERAL_STRING("end"), init);
+
+    event->SetTrusted(true);
+    this->DispatchEvent(*event);
   }
 }
 
 void XRSession::DisconnectFromOwner() {
   MOZ_ASSERT(NS_IsMainThread());
   Shutdown();
   DOMEventTargetHelper::DisconnectFromOwner();
 }