Bug 1626812 - Dispatch XRSessionEvent end when exiting XRSession. r=kip
authorDaosheng Mu <daoshengmu@gmail.com>
Wed, 08 Apr 2020 04:38:53 +0000
changeset 522883 e36621f6e5f9ce885db8dce8238d935a3ff911ec
parent 522882 33c92ceddf3989a00f40152c15e555989e48b704
child 522884 2eb50fc2758d55be52b229de4459693eb321048d
push id112351
push userdmu@mozilla.com
push dateWed, 08 Apr 2020 04:46:40 +0000
treeherderautoland@e36621f6e5f9 [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();
 }