Bug 1389460 - Remove @deprecated nsIDOMEventTarget.DispatchDOMEvent. r=smaug
☠☠ backed out by 46a6ae7634c7 ☠ ☠
authorMasatoshi Kimura <VYV03354@nifty.ne.jp>
Mon, 07 Aug 2017 02:28:52 +0900
changeset 423625 685802013f432de1fb288d37f3a2118b9d020bb1
parent 423624 b8a95a9bde767e6cdb01cabad0e5ba4050e91f8b
child 423626 51ecd7a311ef3ff1d47632226f7e7384ec947f98
push id7761
push userjlund@mozilla.com
push dateFri, 15 Sep 2017 00:19:52 +0000
treeherdermozilla-beta@c38455951db4 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssmaug
bugs1389460
milestone57.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 1389460 - Remove @deprecated nsIDOMEventTarget.DispatchDOMEvent. r=smaug MozReview-Commit-ID: E88DZK5sfwx
dom/base/EventSource.cpp
dom/base/WebSocket.cpp
dom/base/nsContentUtils.cpp
dom/base/nsDOMDataChannel.cpp
dom/base/nsGlobalWindow.cpp
dom/base/nsINode.cpp
dom/base/nsWindowRoot.cpp
dom/events/DOMEventTargetHelper.cpp
dom/file/FileReader.cpp
dom/interfaces/events/nsIDOMEventTarget.idl
dom/media/MediaRecorder.cpp
dom/notification/DesktopNotification.cpp
dom/notification/Notification.cpp
dom/payments/PaymentRequest.cpp
dom/performance/PerformanceMainThread.cpp
dom/workers/ServiceWorkerPrivate.cpp
dom/workers/WorkerPrivate.cpp
dom/xhr/XMLHttpRequestMainThread.cpp
dom/xhr/XMLHttpRequestWorker.cpp
xpfe/appshell/nsWebShellWindow.cpp
--- a/dom/base/EventSource.cpp
+++ b/dom/base/EventSource.cpp
@@ -1496,18 +1496,18 @@ EventSourceImpl::DispatchAllMessageEvent
     RefPtr<MessageEvent> event = new MessageEvent(mEventSource, nullptr,
                                                   nullptr);
 
     event->InitMessageEvent(nullptr, message->mEventName, false, false, jsData,
                             mOrigin, message->mLastEventID, nullptr,
                             Sequence<OwningNonNull<MessagePort>>());
     event->SetTrusted(true);
 
-    rv = mEventSource->DispatchDOMEvent(nullptr, static_cast<Event*>(event),
-                                        nullptr, nullptr);
+    bool dummy;
+    rv = mEventSource->DispatchEvent(static_cast<Event*>(event), &dummy);
     if (NS_FAILED(rv)) {
       NS_WARNING("Failed to dispatch the message event!!!");
       return;
     }
 
     mLastEventID.Assign(message->mLastEventID);
     if (IsClosed() || IsFrozen()) {
       return;
@@ -1935,17 +1935,18 @@ EventSource::~EventSource()
 
 nsresult
 EventSource::CreateAndDispatchSimpleEvent(const nsAString& aName)
 {
   RefPtr<Event> event = NS_NewDOMEvent(this, nullptr, nullptr);
   // it doesn't bubble, and it isn't cancelable
   event->InitEvent(aName, false, false);
   event->SetTrusted(true);
-  return DispatchDOMEvent(nullptr, event, nullptr, nullptr);
+  bool dummy;
+  return DispatchEvent(event, &dummy);
 }
 
 /* static */ already_AddRefed<EventSource>
 EventSource::Constructor(const GlobalObject& aGlobal, const nsAString& aURL,
                          const EventSourceInit& aEventSourceInitDict,
                          ErrorResult& aRv)
 {
   nsCOMPtr<nsPIDOMWindowInner> ownerWindow =
--- a/dom/base/WebSocket.cpp
+++ b/dom/base/WebSocket.cpp
@@ -1932,17 +1932,18 @@ WebSocket::CreateAndDispatchSimpleEvent(
   }
 
   RefPtr<Event> event = NS_NewDOMEvent(this, nullptr, nullptr);
 
   // it doesn't bubble, and it isn't cancelable
   event->InitEvent(aName, false, false);
   event->SetTrusted(true);
 
-  return DispatchDOMEvent(nullptr, event, nullptr, nullptr);
+  bool dummy;
+  return DispatchEvent(event, &dummy);
 }
 
 nsresult
 WebSocket::CreateAndDispatchMessageEvent(const nsACString& aData,
                                          bool aIsBinary)
 {
   MOZ_ASSERT(mImpl);
   AssertIsOnTargetThread();
@@ -2015,18 +2016,18 @@ WebSocket::CreateAndDispatchMessageEvent
 
   RefPtr<MessageEvent> event = new MessageEvent(this, nullptr, nullptr);
 
   event->InitMessageEvent(nullptr, MESSAGE_EVENT_STRING, false, false,
                           jsData, mImpl->mUTF16Origin, EmptyString(), nullptr,
                           Sequence<OwningNonNull<MessagePort>>());
   event->SetTrusted(true);
 
-  return DispatchDOMEvent(nullptr, static_cast<Event*>(event), nullptr,
-                          nullptr);
+  bool dummy;
+  return DispatchEvent(static_cast<Event*>(event), &dummy);
 }
 
 nsresult
 WebSocket::CreateAndDispatchCloseEvent(bool aWasClean,
                                        uint16_t aCode,
                                        const nsAString& aReason)
 {
   AssertIsOnTargetThread();
@@ -2050,17 +2051,18 @@ WebSocket::CreateAndDispatchCloseEvent(b
   init.mWasClean = aWasClean;
   init.mCode = aCode;
   init.mReason = aReason;
 
   RefPtr<CloseEvent> event =
     CloseEvent::Constructor(this, CLOSE_EVENT_STRING, init);
   event->SetTrusted(true);
 
-  return DispatchDOMEvent(nullptr, event, nullptr, nullptr);
+  bool dummy;
+  return DispatchEvent(event, &dummy);
 }
 
 nsresult
 WebSocketImpl::ParseURL(const nsAString& aURL)
 {
   AssertIsOnMainThread();
   NS_ENSURE_TRUE(!aURL.IsEmpty(), NS_ERROR_DOM_SYNTAX_ERR);
 
--- a/dom/base/nsContentUtils.cpp
+++ b/dom/base/nsContentUtils.cpp
@@ -4548,20 +4548,20 @@ nsContentUtils::DispatchChromeEvent(nsID
   NS_ASSERTION(aDoc, "GetEventAndTarget lied?");
   if (!aDoc->GetWindow())
     return NS_ERROR_INVALID_ARG;
 
   EventTarget* piTarget = aDoc->GetWindow()->GetParentTarget();
   if (!piTarget)
     return NS_ERROR_INVALID_ARG;
 
-  nsEventStatus status = nsEventStatus_eIgnore;
-  rv = piTarget->DispatchDOMEvent(nullptr, event, nullptr, &status);
+  bool defaultActionEnabled;
+  rv = piTarget->DispatchEvent(event, &defaultActionEnabled);
   if (aDefaultAction) {
-    *aDefaultAction = (status != nsEventStatus_eConsumeNoDefault);
+    *aDefaultAction = defaultActionEnabled;
   }
   return rv;
 }
 
 /* static */
 nsresult
 nsContentUtils::DispatchFocusChromeEvent(nsPIDOMWindowOuter* aWindow)
 {
--- a/dom/base/nsDOMDataChannel.cpp
+++ b/dom/base/nsDOMDataChannel.cpp
@@ -417,17 +417,18 @@ nsDOMDataChannel::DoOnMessageAvailable(c
   RefPtr<MessageEvent> event = new MessageEvent(this, nullptr, nullptr);
 
   event->InitMessageEvent(nullptr, NS_LITERAL_STRING("message"), false, false,
                           jsData, mOrigin, EmptyString(), nullptr,
                           Sequence<OwningNonNull<MessagePort>>());
   event->SetTrusted(true);
 
   LOG(("%p(%p): %s - Dispatching\n",this,(void*)mDataChannel,__FUNCTION__));
-  rv = DispatchDOMEvent(nullptr, static_cast<Event*>(event), nullptr, nullptr);
+  bool dummy;
+  rv = DispatchEvent(static_cast<Event*>(event), &dummy);
   if (NS_FAILED(rv)) {
     NS_WARNING("Failed to dispatch the message event!!!");
   }
   return rv;
 }
 
 nsresult
 nsDOMDataChannel::OnMessageAvailable(nsISupports* aContext,
@@ -455,17 +456,18 @@ nsDOMDataChannel::OnSimpleEvent(nsISuppo
     return NS_OK;
   }
 
   RefPtr<Event> event = NS_NewDOMEvent(this, nullptr, nullptr);
 
   event->InitEvent(aName, false, false);
   event->SetTrusted(true);
 
-  return DispatchDOMEvent(nullptr, event, nullptr, nullptr);
+  bool dummy;
+  return DispatchEvent(event, &dummy);
 }
 
 nsresult
 nsDOMDataChannel::OnChannelConnected(nsISupports* aContext)
 {
   LOG(("%p(%p): %s - Dispatching\n",this,(void*)mDataChannel,__FUNCTION__));
 
   return OnSimpleEvent(aContext, NS_LITERAL_STRING("open"));
--- a/dom/base/nsGlobalWindow.cpp
+++ b/dom/base/nsGlobalWindow.cpp
@@ -4010,27 +4010,16 @@ nsGlobalWindow::PostHandleEvent(EventCha
       DispatchVRDisplayActivate(autoActivateVRDisplayID,
                                 VRDisplayEventReason::Navigation);
     }
   }
 
   return NS_OK;
 }
 
-nsresult
-nsGlobalWindow::DispatchDOMEvent(WidgetEvent* aEvent,
-                                 nsIDOMEvent* aDOMEvent,
-                                 nsPresContext* aPresContext,
-                                 nsEventStatus* aEventStatus)
-{
-  return EventDispatcher::DispatchDOMEvent(static_cast<nsPIDOMWindow*>(this),
-                                           aEvent, aDOMEvent, aPresContext,
-                                           aEventStatus);
-}
-
 void
 nsGlobalWindow::PoisonOuterWindowProxy(JSObject *aObject)
 {
   MOZ_ASSERT(IsOuterWindow());
   if (aObject == GetWrapperMaybeDead()) {
     PoisonWrapper();
   }
 }
--- a/dom/base/nsINode.cpp
+++ b/dom/base/nsINode.cpp
@@ -1349,26 +1349,16 @@ nsINode::DispatchEvent(nsIDOMEvent *aEve
 }
 
 nsresult
 nsINode::PostHandleEvent(EventChainPostVisitor& /*aVisitor*/)
 {
   return NS_OK;
 }
 
-nsresult
-nsINode::DispatchDOMEvent(WidgetEvent* aEvent,
-                          nsIDOMEvent* aDOMEvent,
-                          nsPresContext* aPresContext,
-                          nsEventStatus* aEventStatus)
-{
-  return EventDispatcher::DispatchDOMEvent(this, aEvent, aDOMEvent,
-                                           aPresContext, aEventStatus);
-}
-
 EventListenerManager*
 nsINode::GetOrCreateListenerManager()
 {
   return nsContentUtils::GetListenerManagerForNode(this);
 }
 
 EventListenerManager*
 nsINode::GetExistingListenerManager() const
--- a/dom/base/nsWindowRoot.cpp
+++ b/dom/base/nsWindowRoot.cpp
@@ -89,27 +89,16 @@ nsWindowRoot::DispatchEvent(nsIDOMEvent*
 {
   nsEventStatus status = nsEventStatus_eIgnore;
   nsresult rv =  EventDispatcher::DispatchDOMEvent(
     static_cast<EventTarget*>(this), nullptr, aEvt, nullptr, &status);
   *aRetVal = (status != nsEventStatus_eConsumeNoDefault);
   return rv;
 }
 
-nsresult
-nsWindowRoot::DispatchDOMEvent(WidgetEvent* aEvent,
-                               nsIDOMEvent* aDOMEvent,
-                               nsPresContext* aPresContext,
-                               nsEventStatus* aEventStatus)
-{
-  return EventDispatcher::DispatchDOMEvent(static_cast<EventTarget*>(this),
-                                           aEvent, aDOMEvent,
-                                           aPresContext, aEventStatus);
-}
-
 NS_IMETHODIMP
 nsWindowRoot::AddEventListener(const nsAString& aType,
                                nsIDOMEventListener *aListener,
                                bool aUseCapture, bool aWantsUntrusted,
                                uint8_t aOptionalArgc)
 {
   NS_ASSERTION(!aWantsUntrusted || aOptionalArgc > 1,
                "Won't check if this is chrome, you want to set "
--- a/dom/events/DOMEventTargetHelper.cpp
+++ b/dom/events/DOMEventTargetHelper.cpp
@@ -339,26 +339,16 @@ DOMEventTargetHelper::GetEventTargetPare
 }
 
 nsresult
 DOMEventTargetHelper::PostHandleEvent(EventChainPostVisitor& aVisitor)
 {
   return NS_OK;
 }
 
-nsresult
-DOMEventTargetHelper::DispatchDOMEvent(WidgetEvent* aEvent,
-                                       nsIDOMEvent* aDOMEvent,
-                                       nsPresContext* aPresContext,
-                                       nsEventStatus* aEventStatus)
-{
-  return EventDispatcher::DispatchDOMEvent(this, aEvent, aDOMEvent,
-                                           aPresContext, aEventStatus);
-}
-
 EventListenerManager*
 DOMEventTargetHelper::GetOrCreateListenerManager()
 {
   if (!mListenerManager) {
     mListenerManager = new EventListenerManager(this);
   }
 
   return mListenerManager;
--- a/dom/file/FileReader.cpp
+++ b/dom/file/FileReader.cpp
@@ -614,17 +614,18 @@ FileReader::DispatchProgressEvent(const 
   } else {
     init.mLengthComputable = false;
     init.mTotal = 0;
   }
   RefPtr<ProgressEvent> event =
     ProgressEvent::Constructor(this, aType, init);
   event->SetTrusted(true);
 
-  return DispatchDOMEvent(nullptr, event, nullptr, nullptr);
+  bool dummy;
+  return DispatchEvent(event, &dummy);
 }
 
 // nsITimerCallback
 NS_IMETHODIMP
 FileReader::Notify(nsITimer* aTimer)
 {
   nsresult rv;
   mTimerIsActive = false;
--- a/dom/interfaces/events/nsIDOMEventTarget.idl
+++ b/dom/interfaces/events/nsIDOMEventTarget.idl
@@ -253,39 +253,16 @@ interface nsIDOMEventTarget : nsISupport
    *
    * @see EventDispatcher.h for documentation about aVisitor.
    * @note Only EventDispatcher should call this method.
    */
   [noscript, nostdcall]
   void PostHandleEvent(in EventChainPostVisitorRef aVisitor);
 
   /**
-   * Dispatch an event.
-   * @param aEvent the event that is being dispatched.
-   * @param aDOMEvent the event that is being dispatched, use if you want to
-   *                  dispatch nsIDOMEvent, not only WidgetEvent.
-   * @param aPresContext the current presentation context, can be nullptr.
-   * @param aEventStatus the status returned from the function, can be nullptr.
-   *
-   * @note If both aEvent and aDOMEvent are used, aEvent must be the internal
-   *       event of the aDOMEvent.
-   *
-   * If aDOMEvent is not nullptr (in which case aEvent can be nullptr) it is used
-   * for dispatching, otherwise aEvent is used.
-   *
-   * @deprecated This method is here just until all the callers outside Gecko
-   *             have been converted to use nsIDOMEventTarget::dispatchEvent.
-   */
-  [noscript, nostdcall]
-  void DispatchDOMEvent(in WidgetEventPtr aEvent,
-                        in nsIDOMEvent aDOMEvent,
-                        in nsPresContextPtr aPresContext,
-                        in nsEventStatusPtr aEventStatus);
-
-  /**
    * Get the script context in which the event handlers should be run.
    * May return null.
    * @note Caller *must* check the value of aRv.
    */
   [notxpcom, nostdcall]
   nsIScriptContext GetContextForEventHandlers(out nsresult aRv);
 };
 
--- a/dom/media/MediaRecorder.cpp
+++ b/dom/media/MediaRecorder.cpp
@@ -1358,33 +1358,35 @@ MediaRecorder::CreateAndDispatchBlobEven
   nsCOMPtr<nsIDOMBlob> blob = aBlob;
   init.mData = static_cast<Blob*>(blob.get());
 
   RefPtr<BlobEvent> event =
     BlobEvent::Constructor(this,
                            NS_LITERAL_STRING("dataavailable"),
                            init);
   event->SetTrusted(true);
-  return DispatchDOMEvent(nullptr, event, nullptr, nullptr);
+  bool dummy;
+  return DispatchEvent(event, &dummy);
 }
 
 void
 MediaRecorder::DispatchSimpleEvent(const nsAString & aStr)
 {
   MOZ_ASSERT(NS_IsMainThread(), "Not running on main thread");
   nsresult rv = CheckInnerWindowCorrectness();
   if (NS_FAILED(rv)) {
     return;
   }
 
   RefPtr<Event> event = NS_NewDOMEvent(this, nullptr, nullptr);
   event->InitEvent(aStr, false, false);
   event->SetTrusted(true);
 
-  rv = DispatchDOMEvent(nullptr, event, nullptr, nullptr);
+  bool dummy;
+  rv = DispatchEvent(event, &dummy);
   if (NS_FAILED(rv)) {
     NS_ERROR("Failed to dispatch the event!!!");
     return;
   }
 }
 
 void
 MediaRecorder::NotifyError(nsresult aRv)
@@ -1410,17 +1412,18 @@ MediaRecorder::NotifyError(nsresult aRv)
   init.mBubbles = false;
   init.mCancelable = false;
   init.mName = errorMsg;
 
   RefPtr<RecordErrorEvent> event =
     RecordErrorEvent::Constructor(this, NS_LITERAL_STRING("error"), init);
   event->SetTrusted(true);
 
-  rv = DispatchDOMEvent(nullptr, event, nullptr, nullptr);
+  bool dummy;
+  rv = DispatchEvent(event, &dummy);
   if (NS_FAILED(rv)) {
     NS_ERROR("Failed to dispatch the error event!!!");
   }
 }
 
 void
 MediaRecorder::RemoveSession(Session* aSession)
 {
--- a/dom/notification/DesktopNotification.cpp
+++ b/dom/notification/DesktopNotification.cpp
@@ -154,17 +154,18 @@ DesktopNotification::DispatchNotificatio
   if (NS_FAILED(CheckInnerWindowCorrectness())) {
     return;
   }
 
   RefPtr<Event> event = NS_NewDOMEvent(this, nullptr, nullptr);
   // it doesn't bubble, and it isn't cancelable
   event->InitEvent(aName, false, false);
   event->SetTrusted(true);
-  DispatchDOMEvent(nullptr, event, nullptr, nullptr);
+  bool dummy;
+  DispatchEvent(event, &dummy);
 }
 
 nsresult
 DesktopNotification::SetAllow(bool aAllow)
 {
   mAllow = aAllow;
 
   // if we have called Show() already, lets go ahead and post a notification
--- a/dom/notification/Notification.cpp
+++ b/dom/notification/Notification.cpp
@@ -1297,17 +1297,18 @@ Notification::DispatchNotificationClickE
                                    options,
                                    result);
   if (NS_WARN_IF(result.Failed())) {
     return false;
   }
 
   event->SetTrusted(true);
   WantsPopupControlCheck popupControlCheck(event);
-  target->DispatchDOMEvent(nullptr, event, nullptr, nullptr);
+  bool dummy;
+  target->DispatchEvent(event, &dummy);
   // We always return false since in case of dispatching on the serviceworker,
   // there is no well defined window to focus. The script may use the
   // Client.focus() API if it wishes.
   return false;
 }
 
 bool
 Notification::DispatchClickEvent()
--- a/dom/payments/PaymentRequest.cpp
+++ b/dom/payments/PaymentRequest.cpp
@@ -609,17 +609,18 @@ PaymentRequest::DispatchUpdateEvent(cons
   init.mBubbles = false;
   init.mCancelable = false;
 
   RefPtr<PaymentRequestUpdateEvent> event =
     PaymentRequestUpdateEvent::Constructor(this, aType, init);
   event->SetTrusted(true);
   event->SetRequest(this);
 
-  return DispatchDOMEvent(nullptr, event, nullptr, nullptr);
+  bool dummy;
+  return DispatchEvent(event, &dummy);
 }
 
 already_AddRefed<PaymentAddress>
 PaymentRequest::GetShippingAddress() const
 {
   RefPtr<PaymentAddress> address = mShippingAddress;
   return address.forget();
 }
--- a/dom/performance/PerformanceMainThread.cpp
+++ b/dom/performance/PerformanceMainThread.cpp
@@ -86,17 +86,18 @@ PerformanceMainThread::Timing()
 
 void
 PerformanceMainThread::DispatchBufferFullEvent()
 {
   RefPtr<Event> event = NS_NewDOMEvent(this, nullptr, nullptr);
   // it bubbles, and it isn't cancelable
   event->InitEvent(NS_LITERAL_STRING("resourcetimingbufferfull"), true, false);
   event->SetTrusted(true);
-  DispatchDOMEvent(nullptr, event, nullptr, nullptr);
+  bool dummy;
+  DispatchEvent(event, &dummy);
 }
 
 PerformanceNavigation*
 PerformanceMainThread::Navigation()
 {
   if (!mNavigation) {
     mNavigation = new PerformanceNavigation(this);
   }
--- a/dom/workers/ServiceWorkerPrivate.cpp
+++ b/dom/workers/ServiceWorkerPrivate.cpp
@@ -454,17 +454,18 @@ public:
       return NS_ERROR_FAILURE;
     }
 
     // This must always be set *before* dispatching the event, otherwise
     // waitUntil calls will fail.
     aEvent->SetKeepAliveHandler(keepAliveHandler);
 
     ErrorResult result;
-    result = aWorkerScope->DispatchDOMEvent(nullptr, aEvent, nullptr, nullptr);
+    bool dummy;
+    result = aWorkerScope->DispatchEvent(aEvent, &dummy);
     if (NS_WARN_IF(result.Failed())) {
       result.SuppressException();
       return NS_ERROR_FAILURE;
     }
 
     // [[ If e’s extend lifetime promises is empty, unset e’s extensions allowed
     //    flag and abort these steps. ]]
     keepAliveHandler->MaybeDone();
--- a/dom/workers/WorkerPrivate.cpp
+++ b/dom/workers/WorkerPrivate.cpp
@@ -565,18 +565,18 @@ private:
       return true;
     }
 
     RefPtr<Event> event =
       Event::Constructor(aWorkerPrivate, NS_LITERAL_STRING("error"),
                          EventInit());
     event->SetTrusted(true);
 
-    nsEventStatus status = nsEventStatus_eIgnore;
-    aWorkerPrivate->DispatchDOMEvent(nullptr, event, nullptr, &status);
+    bool dummy;
+    aWorkerPrivate->DispatchEvent(event, &dummy);
     return true;
   }
 };
 
 class CompileScriptRunnable final : public WorkerRunnable
 {
   nsString mScriptURL;
 
@@ -773,18 +773,18 @@ public:
                             EmptyString(),
                             EmptyString(),
                             nullptr,
                             ports);
     domEvent = do_QueryObject(event);
 
     domEvent->SetTrusted(true);
 
-    nsEventStatus dummy = nsEventStatus_eIgnore;
-    aTarget->DispatchDOMEvent(nullptr, domEvent, nullptr, &dummy);
+    bool dummy;
+    aTarget->DispatchEvent(domEvent, &dummy);
 
     return true;
   }
 
 private:
   virtual bool
   WorkerRun(JSContext* aCx, WorkerPrivate* aWorkerPrivate) override
   {
@@ -849,18 +849,18 @@ private:
                             data,
                             EmptyString(),
                             EmptyString(),
                             nullptr,
                             Sequence<OwningNonNull<MessagePort>>());
     event->SetTrusted(true);
 
     nsCOMPtr<nsIDOMEvent> domEvent = do_QueryObject(event);
-    nsEventStatus status = nsEventStatus_eIgnore;
-    globalScope->DispatchDOMEvent(nullptr, domEvent, nullptr, &status);
+    bool dummy;
+    globalScope->DispatchEvent(domEvent, &dummy);
     return true;
   }
 };
 
 class NotifyRunnable final : public WorkerControlRunnable
 {
   Status mStatus;
 
@@ -1032,20 +1032,20 @@ public:
       init.mCancelable = true;
       init.mBubbles = false;
 
       if (aTarget) {
         RefPtr<ErrorEvent> event =
           ErrorEvent::Constructor(aTarget, NS_LITERAL_STRING("error"), init);
         event->SetTrusted(true);
 
-        nsEventStatus status = nsEventStatus_eIgnore;
-        aTarget->DispatchDOMEvent(nullptr, event, nullptr, &status);
-
-        if (status == nsEventStatus_eConsumeNoDefault) {
+        bool defaultActionEnabled;
+        aTarget->DispatchEvent(event, &defaultActionEnabled);
+
+        if (!defaultActionEnabled) {
           return;
         }
       }
 
       // Now fire an event at the global object, but don't do that if the error
       // code is too much recursion and this is the same script threw the error.
       // XXXbz the interaction of this with worker errors seems kinda broken.
       // An overrecursion in the debugger or debugger sandbox will get turned
@@ -3620,17 +3620,18 @@ WorkerPrivate::OfflineStatusChangeEventI
     eventType.AssignLiteral("online");
   }
 
   RefPtr<Event> event = NS_NewDOMEvent(globalScope, nullptr, nullptr);
 
   event->InitEvent(eventType, false, false);
   event->SetTrusted(true);
 
-  globalScope->DispatchDOMEvent(nullptr, event, nullptr, nullptr);
+  bool dummy;
+  globalScope->DispatchEvent(event, &dummy);
 }
 
 template <class Derived>
 void
 WorkerPrivateParent<Derived>::MemoryPressure(bool aDummy)
 {
   AssertIsOnParentThread();
 
@@ -6977,18 +6978,18 @@ WorkerPrivate::ConnectMessagePort(JSCont
   RefPtr<MessageEvent> event =
     MessageEvent::Constructor(globalObject,
                               NS_LITERAL_STRING("connect"), init, rv);
 
   event->SetTrusted(true);
 
   nsCOMPtr<nsIDOMEvent> domEvent = do_QueryObject(event);
 
-  nsEventStatus dummy = nsEventStatus_eIgnore;
-  globalScope->DispatchDOMEvent(nullptr, domEvent, nullptr, &dummy);
+  bool dummy;
+  globalScope->DispatchEvent(domEvent, &dummy);
 
   return true;
 }
 
 WorkerGlobalScope*
 WorkerPrivate::GetOrCreateGlobalScope(JSContext* aCx)
 {
   AssertIsOnWorkerThread();
--- a/dom/xhr/XMLHttpRequestMainThread.cpp
+++ b/dom/xhr/XMLHttpRequestMainThread.cpp
@@ -1452,17 +1452,18 @@ XMLHttpRequestMainThread::DispatchOrStor
 
   if (mEventDispatchingSuspended) {
     PendingEvent* event = mPendingEvents.AppendElement();
     event->mTarget = aTarget;
     event->mEvent = aEvent;
     return;
   }
 
-  aTarget->DispatchDOMEvent(nullptr, aEvent, nullptr, nullptr);
+  bool dummy;
+  aTarget->DispatchEvent(aEvent, &dummy);
 }
 
 void
 XMLHttpRequestMainThread::SuspendEventDispatching()
 {
   MOZ_ASSERT(!mEventDispatchingSuspended);
   mEventDispatchingSuspended = true;
 }
@@ -1472,18 +1473,18 @@ XMLHttpRequestMainThread::ResumeEventDis
 {
   MOZ_ASSERT(mEventDispatchingSuspended);
   mEventDispatchingSuspended = false;
 
   nsTArray<PendingEvent> pendingEvents;
   pendingEvents.SwapElements(mPendingEvents);
 
   for (uint32_t i = 0; i < pendingEvents.Length(); ++i) {
-    pendingEvents[i].mTarget->
-      DispatchDOMEvent(nullptr, pendingEvents[i].mEvent, nullptr, nullptr);
+    bool dummy;
+    pendingEvents[i].mTarget->DispatchEvent(pendingEvents[i].mEvent, &dummy);
   }
 }
 
 already_AddRefed<nsIHttpChannel>
 XMLHttpRequestMainThread::GetCurrentHttpChannel()
 {
   nsCOMPtr<nsIHttpChannel> httpChannel = do_QueryInterface(mChannel);
   return httpChannel.forget();
--- a/dom/xhr/XMLHttpRequestWorker.cpp
+++ b/dom/xhr/XMLHttpRequestWorker.cpp
@@ -1350,17 +1350,18 @@ EventRunnable::WorkerRun(JSContext* aCx,
   }
 
   if (!event) {
     return false;
   }
 
   event->SetTrusted(true);
 
-  target->DispatchDOMEvent(nullptr, event, nullptr, nullptr);
+  bool dummy;
+  target->DispatchEvent(event, &dummy);
 
   // After firing the event set mResponse to JSVAL_NULL for chunked response
   // types.
   if (StringBeginsWith(mResponseType, NS_LITERAL_STRING("moz-chunked-"))) {
     xhr->NullResponseText();
   }
 
   return true;
@@ -1752,17 +1753,18 @@ XMLHttpRequestWorker::DispatchPrematureA
 
   if (!event) {
     aRv.Throw(NS_ERROR_FAILURE);
     return;
   }
 
   event->SetTrusted(true);
 
-  aTarget->DispatchDOMEvent(nullptr, event, nullptr, nullptr);
+  bool dummy;
+  aTarget->DispatchEvent(event, &dummy);
 }
 
 void
 XMLHttpRequestWorker::Unpin()
 {
   mWorkerPrivate->AssertIsOnWorkerThread();
 
   MOZ_ASSERT(mRooted, "Mismatched calls to Unpin!");
--- a/xpfe/appshell/nsWebShellWindow.cpp
+++ b/xpfe/appshell/nsWebShellWindow.cpp
@@ -63,16 +63,17 @@
 #include "nsIPresShell.h"
 #include "nsPresContext.h"
 
 #include "nsIBaseWindow.h"
 #include "nsIDocShellTreeItem.h"
 
 #include "mozilla/Attributes.h"
 #include "mozilla/DebugOnly.h"
+#include "mozilla/EventDispatcher.h"
 #include "mozilla/MouseEvents.h"
 
 #include "nsPIWindowRoot.h"
 
 #include "gfxPlatform.h"
 
 #ifdef XP_MACOSX
 #include "nsINativeMenuService.h"
@@ -328,17 +329,18 @@ nsWebShellWindow::RequestWindowClose(nsI
     MOZ_ASSERT(NS_SUCCEEDED(mDocShell->IsBeingDestroyed(&dying)) && dying,
                "No presShell, but window is not being destroyed");
   } else if (eventTarget) {
     RefPtr<nsPresContext> presContext = presShell->GetPresContext();
 
     nsEventStatus status = nsEventStatus_eIgnore;
     WidgetMouseEvent event(true, eClose, nullptr,
                            WidgetMouseEvent::eReal);
-    if (NS_SUCCEEDED(eventTarget->DispatchDOMEvent(&event, nullptr, presContext, &status)) &&
+    if (NS_SUCCEEDED(EventDispatcher::Dispatch(eventTarget, presContext,
+                                               &event, nullptr, &status)) &&
         status == nsEventStatus_eConsumeNoDefault)
       return false;
   }
 
   Destroy();
   return false;
 }
 
@@ -711,18 +713,18 @@ bool nsWebShellWindow::ExecuteCloseHandl
     if (contentViewer) {
       RefPtr<nsPresContext> presContext;
       contentViewer->GetPresContext(getter_AddRefs(presContext));
 
       nsEventStatus status = nsEventStatus_eIgnore;
       WidgetMouseEvent event(true, eClose, nullptr,
                              WidgetMouseEvent::eReal);
 
-      nsresult rv =
-        eventTarget->DispatchDOMEvent(&event, nullptr, presContext, &status);
+      nsresult rv = EventDispatcher::Dispatch(eventTarget, presContext,
+                                              &event, nullptr, &status);
       if (NS_SUCCEEDED(rv) && status == nsEventStatus_eConsumeNoDefault)
         return true;
       // else fall through and return false
     }
   }
 
   return false;
 } // ExecuteCloseHandler