Bug 1470930: Use enums for passing arguments for event dispatch. r=smaug
authorEmilio Cobos Álvarez <emilio@crisal.io>
Mon, 25 Jun 2018 18:23:50 +0200
changeset 481568 508445453d966b9f4dd32e353529b9b9b0a80885
parent 481567 71186bdcca2133c88a8421d5adb16b55ff01a534
child 481569 ebbddded329210e131e2efa54ba4e14e125acd84
push id1815
push userffxbld-merge
push dateMon, 15 Oct 2018 10:40:45 +0000
treeherdermozilla-release@18d4c09e9378 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssmaug
bugs1470930
milestone63.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 1470930: Use enums for passing arguments for event dispatch. r=smaug MozReview-Commit-ID: DsNuF7GAflJ
dom/base/EventSource.cpp
dom/base/PostMessageEvent.cpp
dom/base/Selection.cpp
dom/base/SelectionChangeListener.cpp
dom/base/nsContentSink.cpp
dom/base/nsContentUtils.cpp
dom/base/nsContentUtils.h
dom/base/nsDOMDataChannel.cpp
dom/base/nsDocument.cpp
dom/base/nsFocusManager.cpp
dom/base/nsFrameLoader.cpp
dom/base/nsGlobalWindowInner.cpp
dom/base/nsGlobalWindowOuter.cpp
dom/base/nsImageLoadingContent.cpp
dom/base/nsObjectLoadingContent.cpp
dom/canvas/WebGLContext.cpp
dom/events/AsyncEventDispatcher.cpp
dom/events/AsyncEventDispatcher.h
dom/events/Event.cpp
dom/events/Event.h
dom/events/EventStateManager.cpp
dom/events/MessageEvent.cpp
dom/events/MessageEvent.h
dom/events/WheelHandlingHelper.cpp
dom/html/HTMLDetailsElement.cpp
dom/html/HTMLDialogElement.cpp
dom/html/HTMLFormElement.cpp
dom/html/HTMLInputElement.cpp
dom/html/HTMLLinkElement.cpp
dom/html/HTMLMediaElement.cpp
dom/html/HTMLMetaElement.cpp
dom/html/HTMLSlotElement.cpp
dom/html/HTMLTextAreaElement.cpp
dom/html/HTMLTrackElement.cpp
dom/html/ImageDocument.cpp
dom/html/nsIConstraintValidation.cpp
dom/html/nsTextEditorState.cpp
dom/ipc/TabParent.cpp
dom/media/BackgroundVideoDecodingPermissionObserver.cpp
dom/media/MediaTrackList.cpp
dom/media/eme/MediaEncryptedEvent.cpp
dom/media/eme/MediaKeyError.cpp
dom/media/eme/MediaKeySession.cpp
dom/media/webaudio/AudioContext.cpp
dom/media/webaudio/AudioProcessingEvent.h
dom/messagechannel/MessagePort.cpp
dom/permission/PermissionStatus.cpp
dom/plugins/base/nsPluginInstanceOwner.cpp
dom/presentation/PresentationConnection.cpp
dom/script/ScriptElement.cpp
dom/script/ScriptLoader.cpp
dom/script/ScriptTrace.cpp
dom/websocket/WebSocket.cpp
dom/workers/MessageEventRunnable.cpp
dom/workers/RuntimeService.cpp
dom/workers/WorkerDebugger.cpp
dom/xul/XULDocument.cpp
dom/xul/nsXULElement.cpp
gfx/layers/apz/util/APZCCallbackHelper.cpp
layout/base/nsDocumentViewer.cpp
layout/forms/nsComboboxControlFrame.cpp
layout/forms/nsFileControlFrame.cpp
layout/forms/nsListControlFrame.cpp
layout/generic/nsFrame.cpp
layout/generic/nsGfxScrollFrame.cpp
layout/generic/nsVideoFrame.cpp
layout/printing/nsPrintJob.cpp
layout/style/FontFaceSet.cpp
layout/style/Loader.cpp
layout/xul/tree/nsTreeSelection.cpp
uriloader/prefetch/nsPrefetchService.cpp
widget/EventForwards.h
xpfe/appshell/nsWebShellWindow.cpp
--- a/dom/base/EventSource.cpp
+++ b/dom/base/EventSource.cpp
@@ -1513,18 +1513,19 @@ EventSourceImpl::DispatchAllMessageEvent
     }
 
     // create an event that uses the MessageEvent interface,
     // which does not bubble, is not cancelable, and has no default action
 
     RefPtr<MessageEvent> event = new MessageEvent(mEventSource, nullptr,
                                                   nullptr);
 
-    event->InitMessageEvent(nullptr, message->mEventName, false, false, jsData,
-                            mOrigin, message->mLastEventID, nullptr,
+    event->InitMessageEvent(nullptr, message->mEventName, CanBubble::eNo,
+                            Cancelable::eNo, jsData, mOrigin,
+                            message->mLastEventID, nullptr,
                             Sequence<OwningNonNull<MessagePort>>());
     event->SetTrusted(true);
 
     IgnoredErrorResult err;
     mEventSource->DispatchEvent(*event, err);
     if (err.Failed()) {
       NS_WARNING("Failed to dispatch the message event!!!");
       return;
--- a/dom/base/PostMessageEvent.cpp
+++ b/dom/base/PostMessageEvent.cpp
@@ -155,17 +155,17 @@ PostMessageEvent::Run()
 
   Sequence<OwningNonNull<MessagePort>> ports;
   if (!TakeTransferredPortsAsSequence(ports)) {
     DispatchError(cx, targetWindow, eventTarget);
     return NS_OK;
   }
 
   event->InitMessageEvent(nullptr, NS_LITERAL_STRING("message"),
-                          false /*non-bubbling */, false /*cancelable */,
+                          CanBubble::eNo, Cancelable::eNo,
                           messageData, mCallerOrigin,
                           EmptyString(), source, ports);
 
   Dispatch(targetWindow, event);
   return NS_OK;
 }
 
 void
--- a/dom/base/Selection.cpp
+++ b/dom/base/Selection.cpp
@@ -1033,17 +1033,18 @@ Selection::AddItem(nsRange* aItem, int32
             // event.
             dispatchEvent = false;
           }
         }
 
         if (dispatchEvent) {
           nsContentUtils::DispatchTrustedEvent(GetParentObject(), target,
                                                NS_LITERAL_STRING("selectstart"),
-                                               true, true, &defaultAction);
+                                               CanBubble::eYes, Cancelable::eYes,
+                                               &defaultAction);
 
           if (!defaultAction) {
             return NS_OK;
           }
 
           // As we just dispatched an event to the DOM, something could have
           // changed under our feet. Re-generate the rangesToAdd array, and ensure
           // that the range we are about to add is still valid.
--- a/dom/base/SelectionChangeListener.cpp
+++ b/dom/base/SelectionChangeListener.cpp
@@ -151,29 +151,29 @@ SelectionChangeListener::NotifySelection
 
     // If we didn't get a target before, we can instead fire the event at the document.
     if (!target) {
       target = aDoc;
     }
 
     if (target) {
       RefPtr<AsyncEventDispatcher> asyncDispatcher =
-        new AsyncEventDispatcher(target, eSelectionChange, false);
+        new AsyncEventDispatcher(target, eSelectionChange, CanBubble::eNo);
       asyncDispatcher->PostDOMEvent();
     }
   } else {
     if (const nsFrameSelection* fs = aSel->GetFrameSelection()) {
       if (nsCOMPtr<nsIContent> root = fs->GetLimiter()) {
         if (root->IsInNativeAnonymousSubtree()) {
           return NS_OK;
         }
       }
     }
 
     if (aDoc) {
       RefPtr<AsyncEventDispatcher> asyncDispatcher =
-        new AsyncEventDispatcher(aDoc, eSelectionChange, false);
+        new AsyncEventDispatcher(aDoc, eSelectionChange, CanBubble::eNo);
       asyncDispatcher->PostDOMEvent();
     }
   }
 
   return NS_OK;
 }
--- a/dom/base/nsContentSink.cpp
+++ b/dom/base/nsContentSink.cpp
@@ -1658,17 +1658,17 @@ nsContentSink::NotifyDocElementCreated(n
   if (observerService) {
     observerService->
       NotifyObservers(aDoc, "document-element-inserted",
                       EmptyString().get());
   }
 
   nsContentUtils::DispatchChromeEvent(aDoc, aDoc,
                                       NS_LITERAL_STRING("DOMDocElementInserted"),
-                                      true, false);
+                                      CanBubble::eYes, Cancelable::eNo);
 }
 
 NS_IMETHODIMP
 nsContentSink::GetName(nsACString& aName)
 {
   aName.AssignASCII("nsContentSink_timer");
   return NS_OK;
 }
--- a/dom/base/nsContentUtils.cpp
+++ b/dom/base/nsContentUtils.cpp
@@ -4418,132 +4418,145 @@ nsContentUtils::GetEventMessageAndAtomFo
   // ...and then call this method recursively to get the message and atom from
   // now updated sStringEventTable.
   return GetEventMessageAndAtomForListener(aName, aOnName);
 }
 
 static
 nsresult GetEventAndTarget(nsIDocument* aDoc, nsISupports* aTarget,
                            const nsAString& aEventName,
-                           bool aCanBubble, bool aCancelable,
-                           bool aTrusted, Event** aEvent,
+                           CanBubble aCanBubble,
+                           Cancelable aCancelable,
+                           Trusted aTrusted,
+                           Event** aEvent,
                            EventTarget** aTargetOut)
 {
   nsCOMPtr<EventTarget> target(do_QueryInterface(aTarget));
   NS_ENSURE_TRUE(aDoc && target, NS_ERROR_INVALID_ARG);
 
   ErrorResult err;
   RefPtr<Event> event = aDoc->CreateEvent(NS_LITERAL_STRING("Events"),
                                           CallerType::System, err);
   if (NS_WARN_IF(err.Failed())) {
     return err.StealNSResult();
   }
 
   event->InitEvent(aEventName, aCanBubble, aCancelable);
-  event->SetTrusted(aTrusted);
+  event->SetTrusted(aTrusted == Trusted::eYes);
 
   event->SetTarget(target);
 
   event.forget(aEvent);
   target.forget(aTargetOut);
   return NS_OK;
 }
 
 // static
 nsresult
 nsContentUtils::DispatchTrustedEvent(nsIDocument* aDoc, nsISupports* aTarget,
                                      const nsAString& aEventName,
-                                     bool aCanBubble, bool aCancelable,
+                                     CanBubble aCanBubble,
+                                     Cancelable aCancelable,
                                      bool* aDefaultAction)
 {
   return DispatchEvent(aDoc, aTarget, aEventName, aCanBubble, aCancelable,
-                       true, aDefaultAction);
+                       Trusted::eYes, aDefaultAction);
 }
 
 // static
 nsresult
 nsContentUtils::DispatchUntrustedEvent(nsIDocument* aDoc, nsISupports* aTarget,
                                        const nsAString& aEventName,
-                                       bool aCanBubble, bool aCancelable,
+                                       CanBubble aCanBubble,
+                                       Cancelable aCancelable,
                                        bool* aDefaultAction)
 {
   return DispatchEvent(aDoc, aTarget, aEventName, aCanBubble, aCancelable,
-                       false, aDefaultAction);
+                       Trusted::eNo, aDefaultAction);
 }
 
 // static
 nsresult
 nsContentUtils::DispatchEvent(nsIDocument* aDoc, nsISupports* aTarget,
                               const nsAString& aEventName,
-                              bool aCanBubble, bool aCancelable,
-                              bool aTrusted, bool* aDefaultAction,
-                              bool aOnlyChromeDispatch)
+                              CanBubble aCanBubble,
+                              Cancelable aCancelable,
+                              Trusted aTrusted,
+                              bool* aDefaultAction,
+                              ChromeOnlyDispatch aOnlyChromeDispatch)
 {
   RefPtr<Event> event;
   nsCOMPtr<EventTarget> target;
   nsresult rv = GetEventAndTarget(aDoc, aTarget, aEventName, aCanBubble,
                                   aCancelable, aTrusted, getter_AddRefs(event),
                                   getter_AddRefs(target));
   NS_ENSURE_SUCCESS(rv, rv);
-  event->WidgetEventPtr()->mFlags.mOnlyChromeDispatch = aOnlyChromeDispatch;
+  event->WidgetEventPtr()->mFlags.mOnlyChromeDispatch =
+    aOnlyChromeDispatch == ChromeOnlyDispatch::eYes;
 
   ErrorResult err;
   bool doDefault = target->DispatchEvent(*event, CallerType::System, err);
   if (aDefaultAction) {
     *aDefaultAction = doDefault;
   }
   return err.StealNSResult();
 }
 
 // static
 nsresult
 nsContentUtils::DispatchEvent(nsIDocument* aDoc, nsISupports* aTarget,
                               WidgetEvent& aEvent,
                               EventMessage aEventMessage,
-                              bool aCanBubble, bool aCancelable,
-                              bool aTrusted, bool *aDefaultAction,
-                              bool aOnlyChromeDispatch)
-{
-  MOZ_ASSERT_IF(aOnlyChromeDispatch, aTrusted);
+                              CanBubble aCanBubble,
+                              Cancelable aCancelable,
+                              Trusted aTrusted,
+                              bool* aDefaultAction,
+                              ChromeOnlyDispatch aOnlyChromeDispatch)
+{
+  MOZ_ASSERT_IF(aOnlyChromeDispatch == ChromeOnlyDispatch::eYes,
+                aTrusted == Trusted::eYes);
 
   nsCOMPtr<EventTarget> target(do_QueryInterface(aTarget));
 
   aEvent.mTime = PR_Now();
 
   aEvent.mSpecifiedEventType = GetEventTypeFromMessage(aEventMessage);
   aEvent.SetDefaultComposed();
   aEvent.SetDefaultComposedInNativeAnonymousContent();
 
-  aEvent.mFlags.mBubbles = aCanBubble;
-  aEvent.mFlags.mCancelable = aCancelable;
-  aEvent.mFlags.mOnlyChromeDispatch = aOnlyChromeDispatch;
+  aEvent.mFlags.mBubbles = aCanBubble == CanBubble::eYes;
+  aEvent.mFlags.mCancelable = aCancelable == Cancelable::eYes;
+  aEvent.mFlags.mOnlyChromeDispatch =
+    aOnlyChromeDispatch == ChromeOnlyDispatch::eYes;
 
   aEvent.mTarget = target;
 
   nsEventStatus status = nsEventStatus_eIgnore;
   nsresult rv = EventDispatcher::DispatchDOMEvent(target, &aEvent, nullptr,
                                                   nullptr, &status);
   if (aDefaultAction) {
     *aDefaultAction = (status != nsEventStatus_eConsumeNoDefault);
   }
   return rv;
 }
 
 nsresult
 nsContentUtils::DispatchChromeEvent(nsIDocument *aDoc,
                                     nsISupports *aTarget,
                                     const nsAString& aEventName,
-                                    bool aCanBubble, bool aCancelable,
+                                    CanBubble aCanBubble,
+                                    Cancelable aCancelable,
                                     bool* aDefaultAction)
 {
 
   RefPtr<Event> event;
   nsCOMPtr<EventTarget> target;
   nsresult rv = GetEventAndTarget(aDoc, aTarget, aEventName, aCanBubble,
-                                  aCancelable, true, getter_AddRefs(event),
+                                  aCancelable, Trusted::eYes,
+                                  getter_AddRefs(event),
                                   getter_AddRefs(target));
   NS_ENSURE_SUCCESS(rv, rv);
 
   NS_ASSERTION(aDoc, "GetEventAndTarget lied?");
   if (!aDoc->GetWindow())
     return NS_ERROR_INVALID_ARG;
 
   EventTarget* piTarget = aDoc->GetWindow()->GetParentTarget();
@@ -4567,28 +4580,29 @@ nsContentUtils::DispatchFocusChromeEvent
 
   nsCOMPtr<nsIDocument> doc = aWindow->GetExtantDoc();
   if (!doc) {
     return NS_ERROR_FAILURE;
   }
 
   return DispatchChromeEvent(doc, aWindow,
                              NS_LITERAL_STRING("DOMWindowFocus"),
-                             true, true);
+                             CanBubble::eYes, Cancelable::eYes);
 }
 
 nsresult
 nsContentUtils::DispatchEventOnlyToChrome(nsIDocument* aDoc,
                                           nsISupports* aTarget,
                                           const nsAString& aEventName,
-                                          bool aCanBubble, bool aCancelable,
+                                          CanBubble aCanBubble,
+                                          Cancelable aCancelable,
                                           bool* aDefaultAction)
 {
   return DispatchEvent(aDoc, aTarget, aEventName, aCanBubble, aCancelable,
-                       true, aDefaultAction, true);
+                       Trusted::eYes, aDefaultAction, ChromeOnlyDispatch::eYes);
 }
 
 /* static */
 Element*
 nsContentUtils::MatchElementId(nsIContent *aContent, const nsAtom* aId)
 {
   for (nsIContent* cur = aContent;
        cur;
--- a/dom/base/nsContentUtils.h
+++ b/dom/base/nsContentUtils.h
@@ -195,17 +195,22 @@ struct EventNameMapping
 
 typedef bool (*CallOnRemoteChildFunction) (mozilla::dom::TabParent* aTabParent,
                                            void* aArg);
 
 class nsContentUtils
 {
   friend class nsAutoScriptBlockerSuppressNodeRemoved;
   typedef mozilla::dom::Element Element;
+  typedef mozilla::Cancelable Cancelable;
+  typedef mozilla::CanBubble CanBubble;
+  typedef mozilla::ChromeOnlyDispatch ChromeOnlyDispatch;
+  typedef mozilla::EventMessage EventMessage;
   typedef mozilla::TimeDuration TimeDuration;
+  typedef mozilla::Trusted Trusted;
 
 public:
   static nsresult Init();
 
   // Strip off "wyciwyg://n/" part of a URL. aURI must have "wyciwyg" scheme.
   static nsresult RemoveWyciwygScheme(nsIURI* aURI, nsIURI** aReturn);
 
   static bool     IsCallerChrome();
@@ -1344,44 +1349,45 @@ public:
    * @param aCanBubble     Whether the event can bubble.
    * @param aCancelable    Is the event cancelable.
    * @param aDefaultAction Set to true if default action should be taken,
    *                       see EventTarget::DispatchEvent.
    */
   static nsresult DispatchTrustedEvent(nsIDocument* aDoc,
                                        nsISupports* aTarget,
                                        const nsAString& aEventName,
-                                       bool aCanBubble,
-                                       bool aCancelable,
-                                       bool *aDefaultAction = nullptr);
+                                       CanBubble,
+                                       Cancelable,
+                                       bool* aDefaultAction = nullptr);
 
   /**
    * This method creates and dispatches a trusted event using an event message.
    * @param aDoc           The document which will be used to create the event.
    * @param aTarget        The target of the event, should be QIable to
    *                       EventTarget.
    * @param aEventMessage  The event message.
    * @param aCanBubble     Whether the event can bubble.
    * @param aCancelable    Is the event cancelable.
    * @param aDefaultAction Set to true if default action should be taken,
    *                       see EventTarget::DispatchEvent.
    */
   template <class WidgetEventType>
-  static nsresult DispatchTrustedEvent(nsIDocument* aDoc,
-                                       nsISupports* aTarget,
-                                       mozilla::EventMessage aEventMessage,
-                                       bool aCanBubble,
-                                       bool aCancelable,
-                                       bool *aDefaultAction = nullptr,
-                                       bool aOnlyChromeDispatch = false)
+  static nsresult DispatchTrustedEvent(
+    nsIDocument* aDoc,
+    nsISupports* aTarget,
+    EventMessage aEventMessage,
+    CanBubble aCanBubble,
+    Cancelable aCancelable,
+    bool* aDefaultAction = nullptr,
+    ChromeOnlyDispatch aOnlyChromeDispatch = ChromeOnlyDispatch::eNo)
   {
     WidgetEventType event(true, aEventMessage);
     MOZ_ASSERT(GetEventClassIDFromMessage(aEventMessage) == event.mClass);
     return DispatchEvent(aDoc, aTarget, event, aEventMessage,
-                         aCanBubble, aCancelable, true,
+                         aCanBubble, aCancelable, Trusted::eYes,
                          aDefaultAction, aOnlyChromeDispatch);
   }
 
   /**
    * This method creates and dispatches a untrusted event.
    * Works only with events which can be created by calling
    * nsIDocument::CreateEvent() with parameter "Events".
    * @param aDoc           The document which will be used to create the event.
@@ -1391,45 +1397,46 @@ public:
    * @param aCanBubble     Whether the event can bubble.
    * @param aCancelable    Is the event cancelable.
    * @param aDefaultAction Set to true if default action should be taken,
    *                       see EventTarget::DispatchEvent.
    */
   static nsresult DispatchUntrustedEvent(nsIDocument* aDoc,
                                          nsISupports* aTarget,
                                          const nsAString& aEventName,
-                                         bool aCanBubble,
-                                         bool aCancelable,
-                                         bool *aDefaultAction = nullptr);
+                                         CanBubble,
+                                         Cancelable,
+                                         bool* aDefaultAction = nullptr);
 
 
   /**
    * This method creates and dispatches a untrusted event using an event message.
    * @param aDoc           The document which will be used to create the event.
    * @param aTarget        The target of the event, should be QIable to
    *                       EventTarget.
    * @param aEventMessage  The event message.
    * @param aCanBubble     Whether the event can bubble.
    * @param aCancelable    Is the event cancelable.
    * @param aDefaultAction Set to true if default action should be taken,
    *                       see EventTarget::DispatchEvent.
    */
   template <class WidgetEventType>
-  static nsresult DispatchUntrustedEvent(nsIDocument* aDoc,
-                                         nsISupports* aTarget,
-                                         mozilla::EventMessage aEventMessage,
-                                         bool aCanBubble,
-                                         bool aCancelable,
-                                         bool *aDefaultAction = nullptr,
-                                         bool aOnlyChromeDispatch = false)
+  static nsresult DispatchUntrustedEvent(
+    nsIDocument* aDoc,
+    nsISupports* aTarget,
+    EventMessage aEventMessage,
+    CanBubble aCanBubble,
+    Cancelable aCancelable,
+    bool* aDefaultAction = nullptr,
+    ChromeOnlyDispatch aOnlyChromeDispatch = ChromeOnlyDispatch::eNo)
   {
     WidgetEventType event(false, aEventMessage);
     MOZ_ASSERT(GetEventClassIDFromMessage(aEventMessage) == event.mClass);
     return DispatchEvent(aDoc, aTarget, event, aEventMessage,
-                         aCanBubble, aCancelable, false,
+                         aCanBubble, aCancelable, Trusted::eNo,
                          aDefaultAction, aOnlyChromeDispatch);
   }
 
   /**
    * This method creates and dispatches a trusted event to the chrome
    * event handler (the parent object of the DOM Window in the event target
    * chain). Note, chrome event handler is used even if aTarget is a chrome
    * object. Use DispatchEventOnlyToChrome if the normal event dispatching is
@@ -1444,19 +1451,19 @@ public:
    * @param aCanBubble     Whether the event can bubble.
    * @param aCancelable    Is the event cancelable.
    * @param aDefaultAction Set to true if default action should be taken,
    *                       see EventTarget::DispatchEvent.
    */
   static nsresult DispatchChromeEvent(nsIDocument* aDoc,
                                       nsISupports* aTarget,
                                       const nsAString& aEventName,
-                                      bool aCanBubble,
-                                      bool aCancelable,
-                                      bool *aDefaultAction = nullptr);
+                                      CanBubble,
+                                      Cancelable,
+                                      bool* aDefaultAction = nullptr);
 
   /**
    * Helper function for dispatching a "DOMWindowFocus" event to
    * the chrome event handler of the given DOM Window. This has the effect
    * of focusing the corresponding tab and bringing the browser window
    * to the foreground.
    */
   static nsresult DispatchFocusChromeEvent(nsPIDOMWindowOuter* aWindow);
@@ -1477,19 +1484,19 @@ public:
    * @param aCanBubble     Whether the event can bubble.
    * @param aCancelable    Is the event cancelable.
    * @param aDefaultAction Set to true if default action should be taken,
    *                       see EventTarget::DispatchEvent.
    */
   static nsresult DispatchEventOnlyToChrome(nsIDocument* aDoc,
                                             nsISupports* aTarget,
                                             const nsAString& aEventName,
-                                            bool aCanBubble,
-                                            bool aCancelable,
-                                            bool *aDefaultAction = nullptr);
+                                            CanBubble,
+                                            Cancelable,
+                                            bool* aDefaultAction = nullptr);
 
   /**
    * Determines if an event attribute name (such as onclick) is valid for
    * a given element type. Types are from the EventNameType enumeration
    * defined above.
    *
    * @param aName the event name to look up
    * @param aType the type of content
@@ -1498,23 +1505,23 @@ public:
 
   /**
    * Return the event message for the event with the given name. The name is
    * the event name with the 'on' prefix. Returns eUnidentifiedEvent if the
    * event doesn't match a known event name.
    *
    * @param aName the event name to look up
    */
-  static mozilla::EventMessage GetEventMessage(nsAtom* aName);
+  static EventMessage GetEventMessage(nsAtom* aName);
 
   /**
    * Returns the EventMessage and nsAtom to be used for event listener
    * registration.
    */
-  static mozilla::EventMessage
+  static EventMessage
   GetEventMessageAndAtomForListener(const nsAString& aName, nsAtom** aOnName);
 
   /**
    * Return the EventClassID for the event with the given name. The name is the
    * event name *without* the 'on' prefix. Returns eBasicEventClass if the event
    * is not known to be of any particular event class.
    *
    * @param aName the event name to look up
@@ -1526,18 +1533,18 @@ public:
    * The name is the event name *without* the 'on' prefix.
    * Returns eUnidentifiedEvent on the aEventID if the
    * event doesn't match a known event name in the category.
    *
    * @param aName the event name to look up
    * @param aEventClassID only return event id for aEventClassID
    */
   static nsAtom* GetEventMessageAndAtom(const nsAString& aName,
-                                         mozilla::EventClassID aEventClassID,
-                                         mozilla::EventMessage* aEventMessage);
+                                        mozilla::EventClassID aEventClassID,
+                                        EventMessage* aEventMessage);
 
   /**
    * Used only during traversal of the XPCOM graph by the cycle
    * collector: push a pointer to the listener manager onto the
    * children deque, if it exists. Do nothing if there is no listener
    * manager.
    *
    * Crucially: does not perform any refcounting operations.
@@ -3273,45 +3280,45 @@ private:
   static nsresult WrapNative(JSContext *cx, nsISupports *native,
                              nsWrapperCache *cache, const nsIID* aIID,
                              JS::MutableHandle<JS::Value> vp,
                              bool aAllowWrapping);
 
   static nsresult DispatchEvent(nsIDocument* aDoc,
                                 nsISupports* aTarget,
                                 const nsAString& aEventName,
-                                bool aCanBubble,
-                                bool aCancelable,
-                                bool aTrusted,
-                                bool *aDefaultAction = nullptr,
-                                bool aOnlyChromeDispatch = false);
+                                CanBubble,
+                                Cancelable,
+                                Trusted,
+                                bool* aDefaultAction = nullptr,
+                                ChromeOnlyDispatch = ChromeOnlyDispatch::eNo);
 
   static nsresult DispatchEvent(nsIDocument* aDoc,
                                 nsISupports* aTarget,
                                 mozilla::WidgetEvent& aWidgetEvent,
-                                mozilla::EventMessage aEventMessage,
-                                bool aCanBubble,
-                                bool aCancelable,
-                                bool aTrusted,
-                                bool *aDefaultAction = nullptr,
-                                bool aOnlyChromeDispatch = false);
+                                EventMessage aEventMessage,
+                                CanBubble,
+                                Cancelable,
+                                Trusted,
+                                bool* aDefaultAction = nullptr,
+                                ChromeOnlyDispatch = ChromeOnlyDispatch::eNo);
 
   static void InitializeModifierStrings();
 
   static void DropFragmentParsers();
 
   static bool MatchClassNames(mozilla::dom::Element* aElement,
                               int32_t aNamespaceID,
                               nsAtom* aAtom, void* aData);
   static void DestroyClassNameArray(void* aData);
   static void* AllocClassMatchingInfo(nsINode* aRootNode,
                                       const nsString* aClasses);
 
   static mozilla::EventClassID
-  GetEventClassIDFromMessage(mozilla::EventMessage aEventMessage);
+  GetEventClassIDFromMessage(EventMessage aEventMessage);
 
   // Fills in aInfo with the tokens from the supplied autocomplete attribute.
   static AutocompleteAttrState InternalSerializeAutocompleteAttribute(const nsAttrValue* aAttrVal,
                                                                       mozilla::dom::AutocompleteInfo& aInfo,
                                                                       bool aGrantAllValidValue = false);
 
   static bool CallOnAllRemoteChildren(mozilla::dom::MessageBroadcaster* aManager,
                                       CallOnRemoteChildFunction aCallback,
--- a/dom/base/nsDOMDataChannel.cpp
+++ b/dom/base/nsDOMDataChannel.cpp
@@ -335,19 +335,19 @@ nsDOMDataChannel::DoOnMessageAvailable(c
     JSString* jsString = JS_NewUCStringCopyN(cx, utf16data.get(), utf16data.Length());
     NS_ENSURE_TRUE(jsString, NS_ERROR_FAILURE);
 
     jsData.setString(jsString);
   }
 
   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->InitMessageEvent(nullptr, NS_LITERAL_STRING("message"), CanBubble::eNo,
+                          Cancelable::eNo, jsData, mOrigin, EmptyString(),
+                          nullptr, Sequence<OwningNonNull<MessagePort>>());
   event->SetTrusted(true);
 
   LOG(("%p(%p): %s - Dispatching\n",this,(void*)mDataChannel,__FUNCTION__));
   ErrorResult err;
   DispatchEvent(*event, err);
   if (err.Failed()) {
     NS_WARNING("Failed to dispatch the message event!!!");
   }
@@ -377,17 +377,17 @@ nsDOMDataChannel::OnSimpleEvent(nsISuppo
 
   nsresult rv = CheckInnerWindowCorrectness();
   if (NS_FAILED(rv)) {
     return NS_OK;
   }
 
   RefPtr<Event> event = NS_NewDOMEvent(this, nullptr, nullptr);
 
-  event->InitEvent(aName, false, false);
+  event->InitEvent(aName, CanBubble::eNo, Cancelable::eNo);
   event->SetTrusted(true);
 
   ErrorResult err;
   DispatchEvent(*event, err);
   return err.StealNSResult();
 }
 
 nsresult
--- a/dom/base/nsDocument.cpp
+++ b/dom/base/nsDocument.cpp
@@ -4132,23 +4132,23 @@ nsIDocument::AddStyleSheetToStyleSets(St
 #define DO_STYLESHEET_NOTIFICATION(className, type, memberName, argName)      \
   do {                                                                        \
     className##Init init;                                                     \
     init.mBubbles = true;                                                     \
     init.mCancelable = true;                                                  \
     init.mStylesheet = aSheet;                                                \
     init.memberName = argName;                                                \
                                                                               \
-    RefPtr<className> event =                                               \
+    RefPtr<className> event =                                                 \
       className::Constructor(this, NS_LITERAL_STRING(type), init);            \
     event->SetTrusted(true);                                                  \
     event->SetTarget(this);                                                   \
-    RefPtr<AsyncEventDispatcher> asyncDispatcher =                          \
+    RefPtr<AsyncEventDispatcher> asyncDispatcher =                            \
       new AsyncEventDispatcher(this, event);                                  \
-    asyncDispatcher->mOnlyChromeDispatch = true;                              \
+    asyncDispatcher->mOnlyChromeDispatch = ChromeOnlyDispatch::eYes;           \
     asyncDispatcher->PostDOMEvent();                                          \
   } while (0);
 
 void
 nsIDocument::NotifyStyleSheetAdded(StyleSheet* aSheet, bool aDocumentSheet)
 {
   if (StyleSheetChangeEventsEnabled()) {
     DO_STYLESHEET_NOTIFICATION(StyleSheetChangeEvent,
@@ -4962,17 +4962,17 @@ nsIDocument::DispatchContentLoadedEvents
                         nullptr);
   }
 
   // Fire a DOM event notifying listeners that this document has been
   // loaded (excluding images and other loads initiated by this
   // document).
   nsContentUtils::DispatchTrustedEvent(this, this,
                                        NS_LITERAL_STRING("DOMContentLoaded"),
-                                       true, false);
+                                       CanBubble::eYes, Cancelable::eNo);
 
   if (MayStartLayout()) {
     MaybeResolveReadyForIdle();
   }
 
   RefPtr<TimelineConsumers> timelines = TimelineConsumers::Get();
   nsIDocShell* docShell = this->GetDocShell();
 
@@ -5041,17 +5041,17 @@ nsIDocument::DispatchContentLoadedEvents
   }
 
   // If the document has a manifest attribute, fire a MozApplicationManifest
   // event.
   Element* root = GetRootElement();
   if (root && root->HasAttr(kNameSpaceID_None, nsGkAtoms::manifest)) {
     nsContentUtils::DispatchChromeEvent(this, this,
                                         NS_LITERAL_STRING("MozApplicationManifest"),
-                                        true, true);
+                                        CanBubble::eYes, Cancelable::eYes);
   }
 
   nsPIDOMWindowInner* inner = GetInnerWindow();
   if (inner) {
     inner->NoteDOMContentLoaded();
   }
 
   // TODO
@@ -6291,17 +6291,17 @@ nsIDocument::DoNotifyPossibleTitleChange
         docShellWin->SetTitle(title);
       }
     }
   }
 
   // Fire a DOM event for the title change.
   nsContentUtils::DispatchChromeEvent(this, static_cast<nsIDocument*>(this),
                                       NS_LITERAL_STRING("DOMTitleChanged"),
-                                      true, true);
+                                      CanBubble::eYes, Cancelable::eYes);
 }
 
 already_AddRefed<BoxObject>
 nsIDocument::GetBoxObjectFor(Element* aElement, ErrorResult& aRv)
 {
   if (!aElement) {
     aRv.Throw(NS_ERROR_UNEXPECTED);
     return nullptr;
@@ -8179,18 +8179,18 @@ nsDocument::UnblockOnload(bool aFireSync
       // image, we need to know when all of the SVG document's resources are
       // done loading, in a way comparable to |window.onload|. We fire this
       // event to indicate that the SVG should be considered fully loaded.
       // Because scripting is disabled on SVG-as-image documents, this event
       // is not accessible to content authors. (See bug 837315.)
       RefPtr<AsyncEventDispatcher> asyncDispatcher =
         new AsyncEventDispatcher(this,
                                  NS_LITERAL_STRING("MozSVGAsImageDocumentLoad"),
-                                 false,
-                                 false);
+                                 CanBubble::eNo,
+                                 ChromeOnlyDispatch::eNo);
       asyncDispatcher->PostDOMEvent();
     }
   }
 }
 
 class nsUnblockOnloadEvent : public Runnable {
 public:
   explicit nsUnblockOnloadEvent(nsIDocument* aDoc)
@@ -8721,18 +8721,20 @@ nsIDocument::SetReadyStateInternal(Ready
   // At the time of loading start, we don't have timing object, record time.
   if (READYSTATE_LOADING == rs) {
     mLoadingTimeStamp = mozilla::TimeStamp::Now();
   }
 
   RecordNavigationTiming(rs);
 
   RefPtr<AsyncEventDispatcher> asyncDispatcher =
-    new AsyncEventDispatcher(this, NS_LITERAL_STRING("readystatechange"),
-                             false, false);
+    new AsyncEventDispatcher(this,
+                             NS_LITERAL_STRING("readystatechange"),
+                             CanBubble::eNo,
+                             ChromeOnlyDispatch::eNo);
   asyncDispatcher->RunDOMEventWhenSafe();
 }
 
 void
 nsIDocument::GetReadyState(nsAString& aReadyState) const
 {
   switch(mReadyState) {
   case READYSTATE_LOADING :
@@ -10277,18 +10279,17 @@ nsIDocument::ExitFullscreen()
 }
 
 static void
 AskWindowToExitFullscreen(nsIDocument* aDoc)
 {
   if (XRE_GetProcessType() == GeckoProcessType_Content) {
     nsContentUtils::DispatchEventOnlyToChrome(
       aDoc, ToSupports(aDoc), NS_LITERAL_STRING("MozDOMFullscreen:Exit"),
-      /* Bubbles */ true, /* Cancelable */ false,
-      /* DefaultAction */ nullptr);
+      CanBubble::eYes, Cancelable::eNo, /* DefaultAction */ nullptr);
   } else {
     if (nsPIDOMWindowOuter* win = aDoc->GetWindow()) {
       win->SetFullscreenInternal(FullscreenReason::ForFullscreenAPI, false);
     }
   }
 }
 
 class nsCallExitFullscreen : public Runnable
@@ -10387,17 +10388,17 @@ public:
   {
     // Dispatch MozDOMFullscreen:Exited to the last document in
     // the list since we want this event to follow the same path
     // MozDOMFullscreen:Entered dispatched.
     nsIDocument* lastDocument = mDocuments[mDocuments.Length() - 1];
     nsContentUtils::DispatchEventOnlyToChrome(
       lastDocument, ToSupports(lastDocument),
       NS_LITERAL_STRING("MozDOMFullscreen:Exited"),
-      /* Bubbles */ true, /* Cancelable */ false, /* DefaultAction */ nullptr);
+      CanBubble::eYes, Cancelable::eNo, /* DefaultAction */ nullptr);
     // Ensure the window exits fullscreen.
     if (nsPIDOMWindowOuter* win = mDocuments[0]->GetWindow()) {
       win->SetFullscreenInternal(FullscreenReason::ForForceExitFullscreen, false);
     }
     return NS_OK;
   }
 
 private:
@@ -10604,18 +10605,18 @@ nsIDocument::AsyncRequestFullScreen(Uniq
 }
 
 void
 nsIDocument::DispatchFullscreenError(const char* aMessage)
 {
   RefPtr<AsyncEventDispatcher> asyncDispatcher =
     new AsyncEventDispatcher(this,
                              NS_LITERAL_STRING("fullscreenerror"),
-                             true,
-                             false);
+                             CanBubble::eYes,
+                             ChromeOnlyDispatch::eNo);
   asyncDispatcher->PostDOMEvent();
   nsContentUtils::ReportToConsole(nsIScriptError::warningFlag,
                                   NS_LITERAL_CSTRING("DOM"), this,
                                   nsContentUtils::eDOM_PROPERTIES,
                                   aMessage);
 }
 
 static void
@@ -11077,17 +11078,17 @@ nsIDocument::RequestFullScreen(UniquePtr
   }
 
   PendingFullscreenRequestList::Add(std::move(aRequest));
   if (XRE_GetProcessType() == GeckoProcessType_Content) {
     // If we are not the top level process, dispatch an event to make
     // our parent process go fullscreen first.
     nsContentUtils::DispatchEventOnlyToChrome(
       this, ToSupports(this), NS_LITERAL_STRING("MozDOMFullscreen:Request"),
-      /* Bubbles */ true, /* Cancelable */ false, /* DefaultAction */ nullptr);
+      CanBubble::eYes, Cancelable::eNo, /* DefaultAction */ nullptr);
   } else {
     // Make the window fullscreen.
     rootWin->SetFullscreenInternal(FullscreenReason::ForFullscreenAPI, true);
   }
 }
 
 /* static */ bool
 nsIDocument::HandlePendingFullscreenRequests(nsIDocument* aDoc)
@@ -11185,17 +11186,17 @@ nsIDocument::ApplyFullscreen(const Fulls
   // If it is the first entry of the fullscreen, trigger an event so
   // that the UI can response to this change, e.g. hide chrome, or
   // notifying parent process to enter fullscreen. Note that chrome
   // code may also want to listen to MozDOMFullscreen:NewOrigin event
   // to pop up warning UI.
   if (!previousFullscreenDoc) {
     nsContentUtils::DispatchEventOnlyToChrome(
       this, ToSupports(elem), NS_LITERAL_STRING("MozDOMFullscreen:Entered"),
-      /* Bubbles */ true, /* Cancelable */ false, /* DefaultAction */ nullptr);
+      CanBubble::eYes, Cancelable::eNo, /* DefaultAction */ nullptr);
   }
 
   // The origin which is fullscreen gets changed. Trigger an event so
   // that the chrome knows to pop up a warning UI. Note that
   // previousFullscreenDoc == nullptr upon first entry, so we always
   // take this path on the first entry. Also note that, in a multi-
   // process browser, the code in content process is responsible for
   // sending message with the origin to its parent, and the parent
@@ -11233,33 +11234,33 @@ DispatchPointerLockChange(nsIDocument* a
 {
   if (!aTarget) {
     return;
   }
 
   RefPtr<AsyncEventDispatcher> asyncDispatcher =
     new AsyncEventDispatcher(aTarget,
                              NS_LITERAL_STRING("pointerlockchange"),
-                             true,
-                             false);
+                             CanBubble::eYes,
+                             ChromeOnlyDispatch::eNo);
   asyncDispatcher->PostDOMEvent();
 }
 
 static void
 DispatchPointerLockError(nsIDocument* aTarget, const char* aMessage)
 {
   if (!aTarget) {
     return;
   }
 
   RefPtr<AsyncEventDispatcher> asyncDispatcher =
     new AsyncEventDispatcher(aTarget,
                              NS_LITERAL_STRING("pointerlockerror"),
-                             true,
-                             false);
+                             CanBubble::eYes,
+                             ChromeOnlyDispatch::eNo);
   asyncDispatcher->PostDOMEvent();
   nsContentUtils::ReportToConsole(nsIScriptError::warningFlag,
                                   NS_LITERAL_CSTRING("DOM"), aTarget,
                                   nsContentUtils::eDOM_PROPERTIES,
                                   aMessage);
 }
 
 class PointerLockRequest final : public Runnable
@@ -11405,17 +11406,17 @@ PointerLockRequest::Run()
   if (error) {
     DispatchPointerLockError(d, error);
     return NS_OK;
   }
 
   ChangePointerLockedElement(e, d, nullptr);
   nsContentUtils::DispatchEventOnlyToChrome(
     doc, ToSupports(e), NS_LITERAL_STRING("MozDOMPointerLock:Entered"),
-    /* Bubbles */ true, /* Cancelable */ false, /* DefaultAction */ nullptr);
+    CanBubble::eYes, Cancelable::eNo, /* DefaultAction */ nullptr);
   return NS_OK;
 }
 
 void
 nsIDocument::RequestPointerLock(Element* aElement, CallerType aCallerType)
 {
   NS_ASSERTION(aElement,
     "Must pass non-null element to nsDocument::RequestPointerLock");
@@ -11511,30 +11512,31 @@ nsIDocument::UnlockPointer(nsIDocument* 
 
   nsCOMPtr<Element> pointerLockedElement =
     do_QueryReferent(EventStateManager::sPointerLockedElement);
   ChangePointerLockedElement(nullptr, pointerLockedDoc, pointerLockedElement);
 
   RefPtr<AsyncEventDispatcher> asyncDispatcher =
     new AsyncEventDispatcher(pointerLockedElement,
                              NS_LITERAL_STRING("MozDOMPointerLock:Exited"),
-                             true, true);
+                             CanBubble::eYes,
+                             ChromeOnlyDispatch::eYes);
   asyncDispatcher->RunDOMEventWhenSafe();
 }
 
 void
 nsIDocument::UpdateVisibilityState()
 {
   dom::VisibilityState oldState = mVisibilityState;
   mVisibilityState = ComputeVisibilityState();
   if (oldState != mVisibilityState) {
     nsContentUtils::DispatchTrustedEvent(this, static_cast<nsIDocument*>(this),
                                          NS_LITERAL_STRING("visibilitychange"),
-                                         /* bubbles = */ true,
-                                         /* cancelable = */ false);
+                                         CanBubble::eYes,
+                                         Cancelable::eNo);
     EnumerateActivityObservers(NotifyActivityChanged, nullptr);
   }
 
   if (mVisibilityState == dom::VisibilityState::Visible) {
     MaybeActiveMediaComponents();
   }
 }
 
--- a/dom/base/nsFocusManager.cpp
+++ b/dom/base/nsFocusManager.cpp
@@ -1184,17 +1184,19 @@ nsFocusManager::ActivateOrDeactivate(nsP
 
   // Send the activate event.
   if (aWindow->GetExtantDoc()) {
     nsContentUtils::DispatchEventOnlyToChrome(aWindow->GetExtantDoc(),
                                               aWindow->GetCurrentInnerWindow(),
                                               aActive ?
                                                 NS_LITERAL_STRING("activate") :
                                                 NS_LITERAL_STRING("deactivate"),
-                                              true, true, nullptr);
+                                              CanBubble::eYes,
+                                              Cancelable::eYes,
+                                              nullptr);
   }
 
   // Look for any remote child frames, iterate over them and send the activation notification.
   nsContentUtils::CallOnAllRemoteChildren(aWindow, ActivateOrDeactivateChild,
                                           (void *)aActive);
 }
 
 void
--- a/dom/base/nsFrameLoader.cpp
+++ b/dom/base/nsFrameLoader.cpp
@@ -296,20 +296,21 @@ nsFrameLoader::LoadFrame(bool aOriginalS
 }
 
 void
 nsFrameLoader::FireErrorEvent()
 {
   if (!mOwnerContent) {
     return;
   }
-  RefPtr<AsyncEventDispatcher > loadBlockingAsyncDispatcher =
+  RefPtr<AsyncEventDispatcher> loadBlockingAsyncDispatcher =
     new LoadBlockingAsyncEventDispatcher(mOwnerContent,
                                          NS_LITERAL_STRING("error"),
-                                         false, false);
+                                         CanBubble::eNo,
+                                         ChromeOnlyDispatch::eNo);
   loadBlockingAsyncDispatcher->PostDOMEvent();
 }
 
 nsresult
 nsFrameLoader::LoadURI(nsIURI* aURI, bool aOriginalSrc)
 {
   return LoadURI(aURI, nullptr, aOriginalSrc);
 }
--- a/dom/base/nsGlobalWindowInner.cpp
+++ b/dom/base/nsGlobalWindowInner.cpp
@@ -5215,18 +5215,18 @@ nsGlobalWindowInner::FireOfflineStatusEv
   if (mWasOffline) {
     name.AssignLiteral("offline");
   } else {
     name.AssignLiteral("online");
   }
   nsContentUtils::DispatchTrustedEvent(mDoc,
                                        static_cast<EventTarget*>(this),
                                        name,
-                                       false,
-                                       false);
+                                       CanBubble::eNo,
+                                       Cancelable::eNo);
 }
 
 class NotifyIdleObserverRunnable : public Runnable
 {
 public:
   NotifyIdleObserverRunnable(nsIIdleObserver* aIdleObserver,
                              uint32_t aTimeInS,
                              bool aCallOnidle,
--- a/dom/base/nsGlobalWindowOuter.cpp
+++ b/dom/base/nsGlobalWindowOuter.cpp
@@ -2064,18 +2064,18 @@ void
 nsGlobalWindowOuter::DispatchDOMWindowCreated()
 {
   if (!mDoc) {
     return;
   }
 
   // Fire DOMWindowCreated at chrome event listeners
   nsContentUtils::DispatchChromeEvent(mDoc, mDoc, NS_LITERAL_STRING("DOMWindowCreated"),
-                                      true /* bubbles */,
-                                      false /* not cancellable */);
+                                      CanBubble::eYes,
+                                      Cancelable::eNo);
 
   nsCOMPtr<nsIObserverService> observerService =
     mozilla::services::GetObserverService();
 
   // The event dispatching could possibly cause docshell destory, and
   // consequently cause mDoc to be set to nullptr by DropOuterWindowDocs(),
   // so check it again here.
   if (observerService && mDoc) {
@@ -3767,17 +3767,18 @@ nsGlobalWindowOuter::GetChildWindow(cons
   return child ? child->GetWindow() : nullptr;
 }
 
 bool
 nsGlobalWindowOuter::DispatchCustomEvent(const nsAString& aEventName)
 {
   bool defaultActionEnabled = true;
   nsContentUtils::DispatchTrustedEvent(mDoc, ToSupports(this), aEventName,
-                                       true, true, &defaultActionEnabled);
+                                       CanBubble::eYes, Cancelable::eYes,
+                                       &defaultActionEnabled);
 
   return defaultActionEnabled;
 }
 
 bool
 nsGlobalWindowOuter::DispatchResizeEvent(const CSSIntSize& aSize)
 {
   ErrorResult res;
--- a/dom/base/nsImageLoadingContent.cpp
+++ b/dom/base/nsImageLoadingContent.cpp
@@ -1251,17 +1251,20 @@ nsImageLoadingContent::FireEvent(const n
 
   // We have to fire the event asynchronously so that we won't go into infinite
   // loops in cases when onLoad handlers reset the src and the new src is in
   // cache.
 
   nsCOMPtr<nsINode> thisNode = do_QueryInterface(static_cast<nsIImageLoadingContent*>(this));
 
   RefPtr<AsyncEventDispatcher> loadBlockingAsyncDispatcher =
-    new LoadBlockingAsyncEventDispatcher(thisNode, aEventType, false, false);
+    new LoadBlockingAsyncEventDispatcher(thisNode,
+                                         aEventType,
+                                         CanBubble::eNo,
+                                         ChromeOnlyDispatch::eNo);
   loadBlockingAsyncDispatcher->PostDOMEvent();
 
   if (aIsCancelable) {
     mPendingEvent = loadBlockingAsyncDispatcher;
   }
 
   return NS_OK;
 }
--- a/dom/base/nsObjectLoadingContent.cpp
+++ b/dom/base/nsObjectLoadingContent.cpp
@@ -302,17 +302,18 @@ private:
 
 NS_IMETHODIMP
 nsSimplePluginEvent::Run()
 {
   if (mDocument && mDocument->IsActive()) {
     LOG(("OBJLC [%p]: nsSimplePluginEvent firing event \"%s\"", mTarget.get(),
          NS_ConvertUTF16toUTF8(mEvent).get()));
     nsContentUtils::DispatchTrustedEvent(mDocument, mTarget,
-                                         mEvent, true, true);
+                                         mEvent, CanBubble::eYes,
+                                         Cancelable::eYes);
   }
   return NS_OK;
 }
 
 /**
  * A task for firing PluginCrashed DOM Events.
  */
 class nsPluginCrashedEvent : public Runnable {
@@ -3779,17 +3780,18 @@ nsObjectLoadingContent::MaybeFireErrorEv
   nsCOMPtr<nsIContent> thisContent =
     do_QueryInterface(static_cast<nsIImageLoadingContent*>(this));
   // Queue a task to fire an error event if we're an <object> element.  The
   // queueing is important, since then we don't have to worry about reentry.
   if (thisContent->IsHTMLElement(nsGkAtoms::object)) {
     RefPtr<AsyncEventDispatcher> loadBlockingAsyncDispatcher =
       new LoadBlockingAsyncEventDispatcher(thisContent,
                                            NS_LITERAL_STRING("error"),
-                                           false, false);
+                                           CanBubble::eNo,
+                                           ChromeOnlyDispatch::eNo);
     loadBlockingAsyncDispatcher->PostDOMEvent();
   }
 }
 
 bool
 nsObjectLoadingContent::BlockEmbedOrObjectContentLoading()
 {
   nsCOMPtr<nsIContent> thisContent =
--- a/dom/canvas/WebGLContext.cpp
+++ b/dom/canvas/WebGLContext.cpp
@@ -1773,18 +1773,18 @@ WebGLContext::UpdateContextLossStatus()
 
         // Fall through.
     }
 
     if (mContextStatus == ContextLostAwaitingEvent) {
         // The context has been lost and we haven't yet triggered the
         // callback, so do that now.
         const auto kEventName = NS_LITERAL_STRING("webglcontextlost");
-        const bool kCanBubble = true;
-        const bool kIsCancelable = true;
+        const auto kCanBubble = CanBubble::eYes;
+        const auto kIsCancelable = Cancelable::eYes;
         bool useDefaultHandler;
 
         if (mCanvasElement) {
             nsContentUtils::DispatchTrustedEvent(
                 mCanvasElement->OwnerDoc(),
                 static_cast<nsIContent*>(mCanvasElement),
                 kEventName,
                 kCanBubble,
@@ -1852,21 +1852,23 @@ WebGLContext::UpdateContextLossStatus()
         // Revival!
         mContextStatus = ContextNotLost;
 
         if (mCanvasElement) {
             nsContentUtils::DispatchTrustedEvent(
                 mCanvasElement->OwnerDoc(),
                 static_cast<nsIContent*>(mCanvasElement),
                 NS_LITERAL_STRING("webglcontextrestored"),
-                true,
-                true);
+                CanBubble::eYes,
+                Cancelable::eYes);
         } else {
             RefPtr<Event> event = new Event(mOffscreenCanvas, nullptr, nullptr);
-            event->InitEvent(NS_LITERAL_STRING("webglcontextrestored"), true, true);
+            event->InitEvent(NS_LITERAL_STRING("webglcontextrestored"),
+                             CanBubble::eYes,
+                             Cancelable::eYes);
             event->SetTrusted(true);
             mOffscreenCanvas->DispatchEvent(*event);
         }
 
         mEmitContextLostErrorOnce = true;
         return;
     }
 }
--- a/dom/events/AsyncEventDispatcher.cpp
+++ b/dom/events/AsyncEventDispatcher.cpp
@@ -46,27 +46,26 @@ AsyncEventDispatcher::Run()
     MOZ_ASSERT(node);
     if (!node->IsInComposedDoc()) {
       return NS_OK;
     }
   }
   mTarget->AsyncEventRunning(this);
   if (mEventMessage != eUnidentifiedEvent) {
     return nsContentUtils::DispatchTrustedEvent<WidgetEvent>
-      (node->OwnerDoc(), mTarget, mEventMessage, mBubbles,
-       false /* aCancelable */, nullptr /* aDefaultAction */,
-       mOnlyChromeDispatch);
+      (node->OwnerDoc(), mTarget, mEventMessage, mCanBubble,
+       Cancelable::eNo, nullptr /* aDefaultAction */, mOnlyChromeDispatch);
   }
   RefPtr<Event> event = mEvent;
   if (!event) {
     event = NS_NewDOMEvent(mTarget, nullptr, nullptr);
-    event->InitEvent(mEventType, mBubbles, false);
+    event->InitEvent(mEventType, mCanBubble, Cancelable::eNo);
     event->SetTrusted(true);
   }
-  if (mOnlyChromeDispatch) {
+  if (mOnlyChromeDispatch == ChromeOnlyDispatch::eYes) {
     MOZ_ASSERT(event->IsTrusted());
     event->WidgetEventPtr()->mFlags.mOnlyChromeDispatch = true;
   }
   mTarget->DispatchEvent(*event);
   return NS_OK;
 }
 
 nsresult
--- a/dom/events/AsyncEventDispatcher.h
+++ b/dom/events/AsyncEventDispatcher.h
@@ -3,16 +3,17 @@
 /* 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/. */
 
 #ifndef mozilla_AsyncEventDispatcher_h_
 #define mozilla_AsyncEventDispatcher_h_
 
 #include "mozilla/Attributes.h"
+#include "mozilla/EventForwards.h"
 #include "mozilla/RefPtr.h"
 #include "mozilla/dom/Event.h"
 #include "nsCOMPtr.h"
 #include "nsIDocument.h"
 #include "nsString.h"
 #include "nsThreadUtils.h"
 
 class nsINode;
@@ -32,63 +33,65 @@ public:
   /**
    * If aOnlyChromeDispatch is true, the event is dispatched to only
    * chrome node. In that case, if aTarget is already a chrome node,
    * the event is dispatched to it, otherwise the dispatch path starts
    * at the first chrome ancestor of that target.
    */
   AsyncEventDispatcher(nsINode* aTarget,
                        const nsAString& aEventType,
-                       bool aBubbles,
-                       bool aOnlyChromeDispatch)
+                       CanBubble aCanBubble,
+                       ChromeOnlyDispatch aOnlyChromeDispatch)
     : CancelableRunnable("AsyncEventDispatcher")
     , mTarget(aTarget)
     , mEventType(aEventType)
     , mEventMessage(eUnidentifiedEvent)
-    , mBubbles(aBubbles)
+    , mCanBubble(aCanBubble)
     , mOnlyChromeDispatch(aOnlyChromeDispatch)
   {
   }
 
   /**
    * If aOnlyChromeDispatch is true, the event is dispatched to only
    * chrome node. In that case, if aTarget is already a chrome node,
    * the event is dispatched to it, otherwise the dispatch path starts
    * at the first chrome ancestor of that target.
    */
   AsyncEventDispatcher(nsINode* aTarget,
                        mozilla::EventMessage aEventMessage,
-                       bool aBubbles, bool aOnlyChromeDispatch)
+                       CanBubble aCanBubble,
+                       ChromeOnlyDispatch aOnlyChromeDispatch)
     : CancelableRunnable("AsyncEventDispatcher")
     , mTarget(aTarget)
     , mEventMessage(aEventMessage)
-    , mBubbles(aBubbles)
+    , mCanBubble(aCanBubble)
     , mOnlyChromeDispatch(aOnlyChromeDispatch)
   {
     mEventType.SetIsVoid(true);
     MOZ_ASSERT(mEventMessage != eUnidentifiedEvent);
   }
 
-  AsyncEventDispatcher(dom::EventTarget* aTarget, const nsAString& aEventType,
-                       bool aBubbles)
+  AsyncEventDispatcher(dom::EventTarget* aTarget,
+                       const nsAString& aEventType,
+                       CanBubble aCanBubble)
     : CancelableRunnable("AsyncEventDispatcher")
     , mTarget(aTarget)
     , mEventType(aEventType)
     , mEventMessage(eUnidentifiedEvent)
-    , mBubbles(aBubbles)
+    , mCanBubble(aCanBubble)
   {
   }
 
   AsyncEventDispatcher(dom::EventTarget* aTarget,
                        mozilla::EventMessage aEventMessage,
-                       bool aBubbles)
+                       CanBubble aCanBubble)
     : CancelableRunnable("AsyncEventDispatcher")
     , mTarget(aTarget)
     , mEventMessage(aEventMessage)
-    , mBubbles(aBubbles)
+    , mCanBubble(aCanBubble)
   {
     mEventType.SetIsVoid(true);
     MOZ_ASSERT(mEventMessage != eUnidentifiedEvent);
   }
 
   AsyncEventDispatcher(dom::EventTarget* aTarget, dom::Event* aEvent)
     : CancelableRunnable("AsyncEventDispatcher")
     , mTarget(aTarget)
@@ -110,31 +113,34 @@ public:
   void RequireNodeInDocument();
 
   nsCOMPtr<dom::EventTarget> mTarget;
   RefPtr<dom::Event> mEvent;
   // If mEventType is set, mEventMessage will be eUnidentifiedEvent.
   // If mEventMessage is set, mEventType will be void.
   // They can never both be set at the same time.
   nsString              mEventType;
-  mozilla::EventMessage mEventMessage;
-  bool                  mBubbles = false;
-  bool                  mOnlyChromeDispatch = false;
+  EventMessage          mEventMessage;
+  CanBubble             mCanBubble = CanBubble::eNo;
+  ChromeOnlyDispatch    mOnlyChromeDispatch = ChromeOnlyDispatch::eNo;
   bool                  mCanceled = false;
   bool                  mCheckStillInDoc = false;
 };
 
 class LoadBlockingAsyncEventDispatcher final : public AsyncEventDispatcher
 {
 public:
   LoadBlockingAsyncEventDispatcher(nsINode* aEventNode,
                                    const nsAString& aEventType,
-                                   bool aBubbles, bool aDispatchChromeOnly)
-    : AsyncEventDispatcher(aEventNode, aEventType,
-                           aBubbles, aDispatchChromeOnly)
+                                   CanBubble aBubbles,
+                                   ChromeOnlyDispatch aDispatchChromeOnly)
+    : AsyncEventDispatcher(aEventNode,
+                           aEventType,
+                           aBubbles,
+                           aDispatchChromeOnly)
     , mBlockedDoc(aEventNode->OwnerDoc())
   {
     if (mBlockedDoc) {
       mBlockedDoc->BlockOnload();
     }
   }
 
   LoadBlockingAsyncEventDispatcher(nsINode* aEventNode, dom::Event* aEvent)
--- a/dom/events/Event.cpp
+++ b/dom/events/Event.cpp
@@ -488,33 +488,33 @@ Event::EnsureWebAccessibleRelatedTarget(
       relatedTarget = relatedTarget->GetTargetForDOMEvent();
     }
   }
   return relatedTarget.forget();
 }
 
 void
 Event::InitEvent(const nsAString& aEventTypeArg,
-                 bool aCanBubbleArg,
-                 bool aCancelableArg)
+                 mozilla::CanBubble aCanBubbleArg,
+                 mozilla::Cancelable aCancelableArg)
 {
   // Make sure this event isn't already being dispatched.
   NS_ENSURE_TRUE_VOID(!mEvent->mFlags.mIsBeingDispatched);
 
   if (IsTrusted()) {
     // Ensure the caller is permitted to dispatch trusted DOM events.
     if (!nsContentUtils::ThreadsafeIsCallerChrome()) {
       SetTrusted(false);
     }
   }
 
   SetEventType(aEventTypeArg);
 
-  mEvent->mFlags.mBubbles = aCanBubbleArg;
-  mEvent->mFlags.mCancelable = aCancelableArg;
+  mEvent->mFlags.mBubbles = aCanBubbleArg == CanBubble::eYes;
+  mEvent->mFlags.mCancelable = aCancelableArg == Cancelable::eYes;
 
   mEvent->mFlags.mDefaultPrevented = false;
   mEvent->mFlags.mDefaultPreventedByContent = false;
   mEvent->mFlags.mDefaultPreventedByChrome = false;
   mEvent->mFlags.mPropagationStopped = false;
   mEvent->mFlags.mImmediatePropagationStopped = false;
 
   // Clearing the old targets, so that the event is targeted correctly when
--- a/dom/events/Event.h
+++ b/dom/events/Event.h
@@ -143,18 +143,28 @@ public:
 
   // CustomEvent has a non-autogeneratable initCustomEvent.
   virtual CustomEvent* AsCustomEvent()
   {
     return nullptr;
   }
 
   void InitEvent(const nsAString& aEventTypeArg,
-                 bool aCanBubbleArg,
-                 bool aCancelableArg);
+                 bool aCanBubble,
+                 bool aCancelable)
+  {
+    InitEvent(aEventTypeArg,
+              aCanBubble ? CanBubble::eYes : CanBubble::eNo,
+              aCancelable ? Cancelable::eYes : Cancelable::eNo);
+  }
+
+  void InitEvent(const nsAString& aEventTypeArg,
+                 mozilla::CanBubble,
+                 mozilla::Cancelable);
+
   void SetTarget(EventTarget* aTarget);
   virtual void DuplicatePrivateData();
   bool IsDispatchStopped();
   WidgetEvent* WidgetEventPtr();
   virtual void Serialize(IPC::Message* aMsg, bool aSerializeInterfaceType);
   virtual bool Deserialize(const IPC::Message* aMsg, PickleIterator* aIter);
   void SetOwner(EventTarget* aOwner);
   void StopCrossProcessForwarding();
--- a/dom/events/EventStateManager.cpp
+++ b/dom/events/EventStateManager.cpp
@@ -2286,17 +2286,17 @@ EventStateManager::DoScrollZoom(nsIFrame
       EnsureDocument(mPresContext);
       if (Preferences::GetBool("browser.zoom.full") || content->OwnerDoc()->IsSyntheticDocument()) {
         ChangeFullZoom(change);
       } else {
         ChangeTextSize(change);
       }
       nsContentUtils::DispatchChromeEvent(mDocument, static_cast<nsIDocument*>(mDocument),
                                           NS_LITERAL_STRING("ZoomChangeUsingMouseWheel"),
-                                          true, true);
+                                          CanBubble::eYes, Cancelable::eYes);
     }
 }
 
 static nsIFrame*
 GetParentFrameToScroll(nsIFrame* aFrame)
 {
   if (!aFrame)
     return nullptr;
--- a/dom/events/MessageEvent.cpp
+++ b/dom/events/MessageEvent.cpp
@@ -140,17 +140,18 @@ MessageEvent::Constructor(EventTarget* a
 
   event->mPorts.AppendElements(aParam.mPorts);
 
   return event.forget();
 }
 
 void
 MessageEvent::InitMessageEvent(JSContext* aCx, const nsAString& aType,
-                               bool aCanBubble, bool aCancelable,
+                               mozilla::CanBubble aCanBubble,
+                               mozilla::Cancelable aCancelable,
                                JS::Handle<JS::Value> aData,
                                const nsAString& aOrigin,
                                const nsAString& aLastEventId,
                                const Nullable<WindowProxyOrMessagePortOrServiceWorker>& aSource,
                                const Sequence<OwningNonNull<MessagePort>>& aPorts)
 {
   NS_ENSURE_TRUE_VOID(!mEvent->mFlags.mIsBeingDispatched);
 
--- a/dom/events/MessageEvent.h
+++ b/dom/events/MessageEvent.h
@@ -53,18 +53,34 @@ public:
               const MessageEventInit& aEventInit,
               ErrorResult& aRv);
 
   static already_AddRefed<MessageEvent>
   Constructor(EventTarget* aEventTarget,
               const nsAString& aType,
               const MessageEventInit& aEventInit);
 
-  void InitMessageEvent(JSContext* aCx, const nsAString& aType, bool aCanBubble,
-                        bool aCancelable, JS::Handle<JS::Value> aData,
+  void InitMessageEvent(JSContext* aCx, const nsAString& aType,
+                        bool aCanBubble, bool aCancelable,
+                        JS::Handle<JS::Value> aData,
+                        const nsAString& aOrigin, const nsAString& aLastEventId,
+                        const Nullable<WindowProxyOrMessagePortOrServiceWorker>& aSource,
+                        const Sequence<OwningNonNull<MessagePort>>& aPorts)
+  {
+    InitMessageEvent(aCx, aType,
+                     aCanBubble ? CanBubble::eYes : CanBubble::eNo,
+                     aCancelable ? Cancelable::eYes : Cancelable::eNo,
+                     aData,
+                     aOrigin, aLastEventId,
+                     aSource, aPorts);
+  }
+
+  void InitMessageEvent(JSContext* aCx, const nsAString& aType,
+                        mozilla::CanBubble, mozilla::Cancelable,
+                        JS::Handle<JS::Value> aData,
                         const nsAString& aOrigin, const nsAString& aLastEventId,
                         const Nullable<WindowProxyOrMessagePortOrServiceWorker>& aSource,
                         const Sequence<OwningNonNull<MessagePort>>& aPorts);
 
 protected:
   ~MessageEvent();
 
 private:
--- a/dom/events/WheelHandlingHelper.cpp
+++ b/dom/events/WheelHandlingHelper.cpp
@@ -313,17 +313,17 @@ WheelTransaction::OnFailToScrollTarget()
   MOZ_ASSERT(sTargetFrame, "We don't have mouse scrolling transaction");
 
   if (Prefs::sTestMouseScroll) {
     // This event is used for automated tests, see bug 442774.
     nsContentUtils::DispatchTrustedEvent(
                       sTargetFrame->GetContent()->OwnerDoc(),
                       sTargetFrame->GetContent(),
                       NS_LITERAL_STRING("MozMouseScrollFailed"),
-                      true, true);
+                      CanBubble::eYes, Cancelable::eYes);
   }
   // The target frame might be destroyed in the event handler, at that time,
   // we need to finish the current transaction
   if (!sTargetFrame) {
     EndTransaction();
   }
 }
 
@@ -342,17 +342,17 @@ WheelTransaction::OnTimeout(nsITimer* aT
   MayEndTransaction();
 
   if (Prefs::sTestMouseScroll) {
     // This event is used for automated tests, see bug 442774.
     nsContentUtils::DispatchTrustedEvent(
                       frame->GetContent()->OwnerDoc(),
                       frame->GetContent(),
                       NS_LITERAL_STRING("MozMouseScrollTransactionTimeout"),
-                      true, true);
+                      CanBubble::eYes, Cancelable::eYes);
   }
 }
 
 /* static */ void
 WheelTransaction::SetTimeout()
 {
   if (!sTimer) {
     sTimer = NS_NewTimer().take();
--- a/dom/html/HTMLDetailsElement.cpp
+++ b/dom/html/HTMLDetailsElement.cpp
@@ -53,17 +53,19 @@ HTMLDetailsElement::BeforeSetAttr(int32_
     bool setOpen = aValue != nullptr;
     if (Open() != setOpen) {
       if (mToggleEventDispatcher) {
         mToggleEventDispatcher->Cancel();
       }
       // According to the html spec, a 'toggle' event is a simple event which
       // does not bubble.
       mToggleEventDispatcher =
-        new AsyncEventDispatcher(this, NS_LITERAL_STRING("toggle"), false);
+        new AsyncEventDispatcher(this,
+                                 NS_LITERAL_STRING("toggle"),
+                                 CanBubble::eNo);
       mToggleEventDispatcher->PostDOMEvent();
     }
   }
 
   return nsGenericHTMLElement::BeforeSetAttr(aNameSpaceID, aName, aValue,
                                              aNotify);
 }
 
--- a/dom/html/HTMLDialogElement.cpp
+++ b/dom/html/HTMLDialogElement.cpp
@@ -53,17 +53,17 @@ HTMLDialogElement::Close(const mozilla::
   }
   if (aReturnValue.WasPassed()) {
     SetReturnValue(aReturnValue.Value());
   }
   ErrorResult ignored;
   SetOpen(false, ignored);
   ignored.SuppressException();
   RefPtr<AsyncEventDispatcher> eventDispatcher =
-    new AsyncEventDispatcher(this, NS_LITERAL_STRING("close"), false);
+    new AsyncEventDispatcher(this, NS_LITERAL_STRING("close"), CanBubble::eNo);
   eventDispatcher->PostDOMEvent();
 }
 
 void
 HTMLDialogElement::Show()
 {
   if (Open()) {
     return;
--- a/dom/html/HTMLFormElement.cpp
+++ b/dom/html/HTMLFormElement.cpp
@@ -1136,18 +1136,20 @@ void
 HTMLFormElement::PostPasswordEvent()
 {
   // Don't fire another add event if we have a pending add event.
   if (mFormPasswordEventDispatcher.get()) {
     return;
   }
 
   mFormPasswordEventDispatcher =
-    new AsyncEventDispatcher(this, NS_LITERAL_STRING("DOMFormHasPassword"),
-                             true, true);
+    new AsyncEventDispatcher(this,
+                             NS_LITERAL_STRING("DOMFormHasPassword"),
+                             CanBubble::eYes,
+                             ChromeOnlyDispatch::eYes);
   mFormPasswordEventDispatcher->PostDOMEvent();
 }
 
 namespace {
 
 struct FormComparator
 {
   Element* const mChild;
@@ -1866,17 +1868,18 @@ HTMLFormElement::CheckFormValidity(nsIMu
     nsCOMPtr<nsIConstraintValidation> cvElmt = do_QueryObject(sortedControls[i]);
     if (cvElmt && cvElmt->IsCandidateForConstraintValidation() &&
         !cvElmt->IsValid()) {
       ret = false;
       bool defaultAction = true;
       nsContentUtils::DispatchTrustedEvent(sortedControls[i]->OwnerDoc(),
                                            static_cast<nsIContent*>(sortedControls[i]),
                                            NS_LITERAL_STRING("invalid"),
-                                           false, true, &defaultAction);
+                                           CanBubble::eNo, Cancelable::eYes,
+                                           &defaultAction);
 
       // Add all unhandled invalid controls to aInvalidElements if the caller
       // requested them.
       if (defaultAction && aInvalidElements) {
         aInvalidElements->AppendElement(ToSupports(sortedControls[i]));
       }
     }
   }
--- a/dom/html/HTMLInputElement.cpp
+++ b/dom/html/HTMLInputElement.cpp
@@ -252,24 +252,26 @@ public:
   }
 
   nsresult
   DispatchEvents()
   {
     nsresult rv = NS_OK;
     rv = nsContentUtils::DispatchTrustedEvent(mInputElement->OwnerDoc(),
                                               static_cast<Element*>(mInputElement.get()),
-                                              NS_LITERAL_STRING("input"), true,
-                                              false);
+                                              NS_LITERAL_STRING("input"),
+                                              CanBubble::eYes,
+                                              Cancelable::eNo);
     NS_WARNING_ASSERTION(NS_SUCCEEDED(rv), "DispatchTrustedEvent failed");
 
     rv = nsContentUtils::DispatchTrustedEvent(mInputElement->OwnerDoc(),
                                               static_cast<Element*>(mInputElement.get()),
-                                              NS_LITERAL_STRING("change"), true,
-                                              false);
+                                              NS_LITERAL_STRING("change"),
+                                              CanBubble::eYes,
+                                              Cancelable::eNo);
 
     return rv;
   }
 
 private:
   RefPtr<HTMLInputElement> mInputElement;
 };
 
@@ -631,18 +633,19 @@ nsColorPickerShownCallback::UpdateIntern
       valueChanged = true;
     }
   }
 
   if (valueChanged) {
     mValueChanged = true;
     return nsContentUtils::DispatchTrustedEvent(mInput->OwnerDoc(),
                                                 static_cast<Element*>(mInput.get()),
-                                                NS_LITERAL_STRING("input"), true,
-                                                false);
+                                                NS_LITERAL_STRING("input"),
+                                                CanBubble::eYes,
+                                                Cancelable::eNo);
   }
 
   return NS_OK;
 }
 
 NS_IMETHODIMP
 nsColorPickerShownCallback::Update(const nsAString& aColor)
 {
@@ -665,18 +668,19 @@ nsColorPickerShownCallback::Done(const n
 
   if (!aColor.IsEmpty()) {
     UpdateInternal(aColor, false);
   }
 
   if (mValueChanged) {
     rv = nsContentUtils::DispatchTrustedEvent(mInput->OwnerDoc(),
                                               static_cast<Element*>(mInput.get()),
-                                              NS_LITERAL_STRING("change"), true,
-                                              false);
+                                              NS_LITERAL_STRING("change"),
+                                              CanBubble::eYes,
+                                              Cancelable::eNo);
   }
 
   return rv;
 }
 
 NS_IMPL_ISUPPORTS(nsColorPickerShownCallback, nsIColorPickerShownCallback)
 
 bool
@@ -2249,44 +2253,46 @@ HTMLInputElement::OpenDateTimePicker(con
   if (NS_WARN_IF(!IsDateTimeInputType(mType))) {
     return;
   }
 
   mDateTimeInputBoxValue = new DateTimeValue(aInitialValue);
   nsContentUtils::DispatchChromeEvent(OwnerDoc(),
                                       static_cast<Element*>(this),
                                       NS_LITERAL_STRING("MozOpenDateTimePicker"),
-                                      true, true);
+                                      CanBubble::eYes,
+                                      Cancelable::eYes);
 }
 
 void
 HTMLInputElement::UpdateDateTimePicker(const DateTimeValue& aValue)
 {
   if (NS_WARN_IF(!IsDateTimeInputType(mType))) {
     return;
   }
 
   mDateTimeInputBoxValue = new DateTimeValue(aValue);
   nsContentUtils::DispatchChromeEvent(OwnerDoc(),
                                       static_cast<Element*>(this),
                                       NS_LITERAL_STRING("MozUpdateDateTimePicker"),
-                                      true, true);
+                                      CanBubble::eYes,
+                                      Cancelable::eYes);
 }
 
 void
 HTMLInputElement::CloseDateTimePicker()
 {
   if (NS_WARN_IF(!IsDateTimeInputType(mType))) {
     return;
   }
 
   nsContentUtils::DispatchChromeEvent(OwnerDoc(),
                                       static_cast<Element*>(this),
                                       NS_LITERAL_STRING("MozCloseDateTimePicker"),
-                                      true, true);
+                                      CanBubble::eYes, Cancelable::eYes);
 }
 
 void
 HTMLInputElement::SetFocusState(bool aIsFocused)
 {
   if (NS_WARN_IF(!IsDateTimeInputType(mType))) {
     return;
   }
@@ -2360,20 +2366,23 @@ HTMLInputElement::SetUserInput(const nsA
 
   nsresult rv =
     SetValueInternal(aValue,
       nsTextEditorState::eSetValue_BySetUserInput |
       nsTextEditorState::eSetValue_Notify|
       nsTextEditorState::eSetValue_MoveCursorToEndIfValueChanged);
   NS_ENSURE_SUCCESS_VOID(rv);
 
+  // FIXME: We're inconsistent about whether "input" events are cancelable or
+  // not.
   nsContentUtils::DispatchTrustedEvent(OwnerDoc(),
                                        static_cast<Element*>(this),
-                                       NS_LITERAL_STRING("input"), true,
-                                       true);
+                                       NS_LITERAL_STRING("input"),
+                                       CanBubble::eYes,
+                                       Cancelable::eYes);
 
   // If this element is not currently focused, it won't receive a change event for this
   // update through the normal channels. So fire a change event immediately, instead.
   if (!ShouldBlur(this)) {
     FireChangeEventIfNeeded();
   }
 }
 
@@ -2690,18 +2699,19 @@ HTMLInputElement::FireChangeEventIfNeede
   if (!MayFireChangeOnBlur() || mFocusedValue.Equals(value)) {
     return;
   }
 
   // Dispatch the change event.
   mFocusedValue = value;
   nsContentUtils::DispatchTrustedEvent(OwnerDoc(),
                                        static_cast<nsIContent*>(this),
-                                       NS_LITERAL_STRING("change"), true,
-                                       false);
+                                       NS_LITERAL_STRING("change"),
+                                       CanBubble::eYes,
+                                       Cancelable::eNo);
 }
 
 FileList*
 HTMLInputElement::GetFiles()
 {
   if (mType != NS_FORM_INPUT_FILE) {
     return nullptr;
   }
@@ -3748,17 +3758,20 @@ HTMLInputElement::CancelRangeThumbDrag(b
     // is small, so we should be fine here.)
     SetValueInternal(val, nsTextEditorState::eSetValue_BySetUserInput |
                           nsTextEditorState::eSetValue_Notify);
     nsRangeFrame* frame = do_QueryFrame(GetPrimaryFrame());
     if (frame) {
       frame->UpdateForValueChange();
     }
     RefPtr<AsyncEventDispatcher> asyncDispatcher =
-      new AsyncEventDispatcher(this, NS_LITERAL_STRING("input"), true, false);
+      new AsyncEventDispatcher(this,
+                               NS_LITERAL_STRING("input"),
+                               CanBubble::eYes,
+                               ChromeOnlyDispatch::eNo);
     asyncDispatcher->RunDOMEventWhenSafe();
   }
 }
 
 void
 HTMLInputElement::SetValueOfRangeForUserEvent(Decimal aValue)
 {
   MOZ_ASSERT(aValue.isFinite());
@@ -3774,18 +3787,19 @@ HTMLInputElement::SetValueOfRangeForUser
   nsRangeFrame* frame = do_QueryFrame(GetPrimaryFrame());
   if (frame) {
     frame->UpdateForValueChange();
   }
 
   if (GetValueAsDecimal() != oldValue) {
     nsContentUtils::DispatchTrustedEvent(OwnerDoc(),
                                          static_cast<Element*>(this),
-                                         NS_LITERAL_STRING("input"), true,
-                                         false);
+                                         NS_LITERAL_STRING("input"),
+                                         CanBubble::eYes,
+                                         Cancelable::eNo);
   }
 }
 
 void
 HTMLInputElement::StartNumberControlSpinnerSpin()
 {
   MOZ_ASSERT(!mNumberControlSpinnerIsSpinning);
 
@@ -3872,18 +3886,19 @@ HTMLInputElement::StepNumberControlForUs
   mInputType->ConvertNumberToString(newValue, newVal);
   // TODO: What should we do if SetValueInternal fails?  (The allocation
   // is small, so we should be fine here.)
   SetValueInternal(newVal, nsTextEditorState::eSetValue_BySetUserInput |
                            nsTextEditorState::eSetValue_Notify);
 
   nsContentUtils::DispatchTrustedEvent(OwnerDoc(),
                                        static_cast<Element*>(this),
-                                       NS_LITERAL_STRING("input"), true,
-                                       false);
+                                       NS_LITERAL_STRING("input"),
+                                       CanBubble::eYes,
+                                       Cancelable::eNo);
 }
 
 static bool
 SelectTextFieldOnFocus()
 {
   if (!gSelectTextFieldOnFocus) {
     int32_t selectTextfieldsOnKeyFocus = -1;
     nsresult rv =
@@ -4084,21 +4099,21 @@ HTMLInputElement::PostHandleEvent(EventC
           !!(aVisitor.mItemFlags & NS_ORIGINAL_INDETERMINATE_VALUE);
         SetIndeterminateInternal(originalIndeterminateValue, false);
         DoSetChecked(originalCheckedValue, true, true);
       }
     } else {
       // Fire input event and then change event.
       nsContentUtils::DispatchTrustedEvent<InternalEditorInputEvent>
         (OwnerDoc(), static_cast<Element*>(this),
-         eEditorInput, true, false);
+         eEditorInput, CanBubble::eYes, Cancelable::eNo);
 
       nsContentUtils::DispatchTrustedEvent<WidgetEvent>
         (OwnerDoc(), static_cast<Element*>(this),
-         eFormChange, true, false);
+         eFormChange, CanBubble::eYes, Cancelable::eNo);
 #ifdef ACCESSIBILITY
       // Fire an event to notify accessibility
       if (mType == NS_FORM_INPUT_CHECKBOX) {
         FireEventForAccessibility(this, aVisitor.mPresContext,
                                   eFormCheckboxStateChange);
       } else {
         FireEventForAccessibility(this, aVisitor.mPresContext,
                                   eFormRadioStateChange);
@@ -4641,18 +4656,18 @@ HTMLInputElement::BindToTree(nsIDocument
   // And now make sure our state is up to date
   UpdateState(false);
 
   if (mType == NS_FORM_INPUT_PASSWORD) {
     if (IsInComposedDoc()) {
       AsyncEventDispatcher* dispatcher =
         new AsyncEventDispatcher(this,
                                  NS_LITERAL_STRING("DOMInputPasswordAdded"),
-                                 true,
-                                 true);
+                                 CanBubble::eYes,
+                                 ChromeOnlyDispatch::eYes);
       dispatcher->PostDOMEvent();
     }
 
 #ifdef EARLY_BETA_OR_EARLIER
     Telemetry::Accumulate(Telemetry::PWMGR_PASSWORD_INPUT_IN_FORM, !!mForm);
 #endif
   }
 
@@ -4830,18 +4845,18 @@ HTMLInputElement::HandleTypeChange(uint8
                 mSrcTriggeringPrincipal);
     }
   }
 
   if (mType == NS_FORM_INPUT_PASSWORD && IsInComposedDoc()) {
     AsyncEventDispatcher* dispatcher =
       new AsyncEventDispatcher(this,
                                NS_LITERAL_STRING("DOMInputPasswordAdded"),
-                               true,
-                               true);
+                               CanBubble::eYes,
+                               ChromeOnlyDispatch::eYes);
     dispatcher->PostDOMEvent();
   }
 }
 
 void
 HTMLInputElement::SanitizeValue(nsAString& aValue)
 {
   NS_ASSERTION(mDoneCreating, "The element creation should be finished!");
@@ -6000,17 +6015,18 @@ HTMLInputElement::SetSelectionDirection(
 #ifdef ACCESSIBILITY
 /*static*/ nsresult
 FireEventForAccessibility(HTMLInputElement* aTarget,
                           nsPresContext* aPresContext,
                           EventMessage aEventMessage)
 {
   Element* element = static_cast<Element*>(aTarget);
   return nsContentUtils::DispatchTrustedEvent<WidgetEvent>
-    (element->OwnerDoc(), element, aEventMessage, true, true);
+    (element->OwnerDoc(), element, aEventMessage,
+     CanBubble::eYes, Cancelable::eYes);
 }
 #endif
 
 void
 HTMLInputElement::UpdateApzAwareFlag()
 {
 #if !defined(ANDROID) && !defined(XP_MACOSX)
   if ((mType == NS_FORM_INPUT_NUMBER) || (mType == NS_FORM_INPUT_RANGE)) {
--- a/dom/html/HTMLLinkElement.cpp
+++ b/dom/html/HTMLLinkElement.cpp
@@ -239,17 +239,20 @@ HTMLLinkElement::CreateAndDispatchEvent(
 
   if (!nsContentUtils::HasNonEmptyAttr(this, kNameSpaceID_None,
                                        nsGkAtoms::rev) &&
       FindAttrValueIn(kNameSpaceID_None, nsGkAtoms::rel,
                       strings, eIgnoreCase) != ATTR_VALUE_NO_MATCH)
     return;
 
   RefPtr<AsyncEventDispatcher> asyncDispatcher =
-    new AsyncEventDispatcher(this, aEventName, true, true);
+    new AsyncEventDispatcher(this,
+                             aEventName,
+                             CanBubble::eYes,
+                             ChromeOnlyDispatch::eYes);
   // Always run async in order to avoid running script when the content
   // sink isn't expecting it.
   asyncDispatcher->PostDOMEvent();
 }
 
 nsresult
 HTMLLinkElement::BeforeSetAttr(int32_t aNameSpaceID, nsAtom* aName,
                                const nsAttrValueOrString* aValue, bool aNotify)
--- a/dom/html/HTMLMediaElement.cpp
+++ b/dom/html/HTMLMediaElement.cpp
@@ -359,17 +359,18 @@ public:
   NS_IMETHOD Run() override
   {
     // Silently cancel if our load has been cancelled.
     if (IsCancelled())
       return NS_OK;
     LOG_EVENT(LogLevel::Debug,
               ("%p Dispatching simple event source error", mElement.get()));
     return nsContentUtils::DispatchTrustedEvent(
-      mElement->OwnerDoc(), mSource, NS_LITERAL_STRING("error"), false, false);
+      mElement->OwnerDoc(), mSource, NS_LITERAL_STRING("error"),
+      CanBubble::eNo, Cancelable::eNo);
   }
 };
 
 /**
  * This listener observes the first video frame to arrive with a non-empty size,
  * and calls HTMLMediaElement::UpdateInitialMediaSize() with that size.
  */
 class HTMLMediaElement::StreamSizeListener
@@ -1429,18 +1430,17 @@ public:
     if (mOwner->Paused()) {
       return;
     }
 
     nsContentUtils::DispatchTrustedEvent(
       mOwner->OwnerDoc(),
       static_cast<nsIContent*>(mOwner),
       NS_LITERAL_STRING("OpenMediaWithExternalApp"),
-      true,
-      true);
+      CanBubble::eYes, Cancelable::eYes);
   }
 
   RefPtr<MediaError> mError;
 
 private:
   bool IsValidErrorCode(const uint16_t& aErrorCode) const
   {
     return (aErrorCode == MEDIA_ERR_DECODE || aErrorCode == MEDIA_ERR_NETWORK ||
@@ -6303,17 +6303,19 @@ HTMLMediaElement::DispatchEvent(const ns
   // Save events that occur while in the bfcache. These will be dispatched
   // if the page comes out of the bfcache.
   if (mEventDeliveryPaused) {
     mPendingEvents.AppendElement(aName);
     return NS_OK;
   }
 
   return nsContentUtils::DispatchTrustedEvent(
-    OwnerDoc(), static_cast<nsIContent*>(this), aName, false, false);
+    OwnerDoc(), static_cast<nsIContent*>(this), aName,
+    CanBubble::eNo,
+    Cancelable::eNo);
 }
 
 void
 HTMLMediaElement::DispatchAsyncEvent(const nsAString& aName)
 {
   LOG_EVENT(LogLevel::Debug,
             ("%p Queuing event %s", this, NS_ConvertUTF16toUTF8(aName).get()));
   DDLOG(DDLogCategory::Event,
@@ -6951,22 +6953,23 @@ HTMLMediaElement::UpdateAudioChannelPlay
   }
 }
 
 bool
 HTMLMediaElement::IsAllowedToPlay()
 {
   if (!AutoplayPolicy::IsMediaElementAllowedToPlay(WrapNotNull(this))) {
 #if defined(MOZ_WIDGET_ANDROID)
+    // FIXME: This should be chrome-only.
     nsContentUtils::DispatchTrustedEvent(
       OwnerDoc(),
       static_cast<nsIContent*>(this),
       NS_LITERAL_STRING("MozAutoplayMediaBlocked"),
-      false,
-      false);
+      CanBubble::eNo,
+      Cancelable::eNo);
 #endif
     LOG(LogLevel::Debug,
         ("%p %s AutoplayPolicy blocked autoplay.", this, __func__));
     return false;
   }
 
   LOG(LogLevel::Debug,
       ("%p %s AutoplayPolicy did not block autoplay.", this, __func__));
--- a/dom/html/HTMLMetaElement.cpp
+++ b/dom/html/HTMLMetaElement.cpp
@@ -151,17 +151,20 @@ HTMLMetaElement::UnbindFromTree(bool aDe
 void
 HTMLMetaElement::CreateAndDispatchEvent(nsIDocument* aDoc,
                                         const nsAString& aEventName)
 {
   if (!aDoc)
     return;
 
   RefPtr<AsyncEventDispatcher> asyncDispatcher =
-    new AsyncEventDispatcher(this, aEventName, true, true);
+    new AsyncEventDispatcher(this,
+                             aEventName,
+                             CanBubble::eYes,
+                             ChromeOnlyDispatch::eYes);
   asyncDispatcher->RunDOMEventWhenSafe();
 }
 
 JSObject*
 HTMLMetaElement::WrapNode(JSContext* aCx, JS::Handle<JSObject*> aGivenProto)
 {
   return HTMLMetaElementBinding::Wrap(aCx, this, aGivenProto);
 }
--- a/dom/html/HTMLSlotElement.cpp
+++ b/dom/html/HTMLSlotElement.cpp
@@ -233,18 +233,19 @@ HTMLSlotElement::EnqueueSlotChangeEvent(
   docGroup->SignalSlotChange(*this);
 }
 
 void
 HTMLSlotElement::FireSlotChangeEvent()
 {
   nsContentUtils::DispatchTrustedEvent(OwnerDoc(),
                                        static_cast<nsIContent*>(this),
-                                       NS_LITERAL_STRING("slotchange"), true,
-                                       false);
+                                       NS_LITERAL_STRING("slotchange"),
+                                       CanBubble::eYes,
+                                       Cancelable::eNo);
 }
 
 JSObject*
 HTMLSlotElement::WrapNode(JSContext* aCx, JS::Handle<JSObject*> aGivenProto)
 {
   return HTMLSlotElementBinding::Wrap(aCx, this, aGivenProto);
 }
 
--- a/dom/html/HTMLTextAreaElement.cpp
+++ b/dom/html/HTMLTextAreaElement.cpp
@@ -547,18 +547,19 @@ HTMLTextAreaElement::FireChangeEventIfNe
   if (mFocusedValue.Equals(value)) {
     return;
   }
 
   // Dispatch the change event.
   mFocusedValue = value;
   nsContentUtils::DispatchTrustedEvent(OwnerDoc(),
                                        static_cast<nsIContent*>(this),
-                                       NS_LITERAL_STRING("change"), true,
-                                       false);
+                                       NS_LITERAL_STRING("change"),
+                                       CanBubble::eYes,
+                                       Cancelable::eNo);
 }
 
 nsresult
 HTMLTextAreaElement::PostHandleEvent(EventChainPostVisitor& aVisitor)
 {
   if (aVisitor.mEvent->mMessage == eFormSelect) {
     mHandlingSelect = false;
   }
--- a/dom/html/HTMLTrackElement.cpp
+++ b/dom/html/HTMLTrackElement.cpp
@@ -449,17 +449,17 @@ HTMLTrackElement::DispatchTrackRunnable(
 void
 HTMLTrackElement::DispatchTrustedEvent(const nsAString& aName)
 {
   nsIDocument* doc = OwnerDoc();
   if (!doc) {
     return;
   }
   nsContentUtils::DispatchTrustedEvent(doc, static_cast<nsIContent*>(this),
-                                       aName, false, false);
+                                       aName, CanBubble::eNo, Cancelable::eNo);
 }
 
 void
 HTMLTrackElement::DropChannel()
 {
   mChannel = nullptr;
 }
 
--- a/dom/html/ImageDocument.cpp
+++ b/dom/html/ImageDocument.cpp
@@ -138,17 +138,17 @@ ImageListener::OnStartRequest(nsIRequest
 }
 
 NS_IMETHODIMP
 ImageListener::OnStopRequest(nsIRequest* aRequest, nsISupports* aCtxt, nsresult aStatus)
 {
   ImageDocument* imgDoc = static_cast<ImageDocument*>(mDocument.get());
   nsContentUtils::DispatchChromeEvent(imgDoc, static_cast<nsIDocument*>(imgDoc),
                                       NS_LITERAL_STRING("ImageContentLoaded"),
-                                      true, true);
+                                      CanBubble::eYes, Cancelable::eYes);
   return MediaDocumentStreamListener::OnStopRequest(aRequest, aCtxt, aStatus);
 }
 
 ImageDocument::ImageDocument()
   : MediaDocument()
   , mVisibleWidth(0.0)
   , mVisibleHeight(0.0)
   , mImageWidth(0)
--- a/dom/html/nsIConstraintValidation.cpp
+++ b/dom/html/nsIConstraintValidation.cpp
@@ -102,19 +102,21 @@ nsIConstraintValidation::CheckValidity()
 {
   if (!IsCandidateForConstraintValidation() || IsValid()) {
     return true;
   }
 
   nsCOMPtr<nsIContent> content = do_QueryInterface(this);
   NS_ASSERTION(content, "This class should be inherited by HTML elements only!");
 
-  nsContentUtils::DispatchTrustedEvent(content->OwnerDoc(), content,
+  nsContentUtils::DispatchTrustedEvent(content->OwnerDoc(),
+                                       content,
                                        NS_LITERAL_STRING("invalid"),
-                                       false, true);
+                                       CanBubble::eNo,
+                                       Cancelable::eYes);
   return false;
 }
 
 nsresult
 nsIConstraintValidation::CheckValidity(bool* aValidity)
 {
   NS_ENSURE_ARG_POINTER(aValidity);
 
@@ -131,17 +133,19 @@ nsIConstraintValidation::ReportValidity(
   }
 
   nsCOMPtr<nsIContent> content = do_QueryInterface(this);
   MOZ_ASSERT(content, "This class should be inherited by HTML elements only!");
 
   bool defaultAction = true;
   nsContentUtils::DispatchTrustedEvent(content->OwnerDoc(), content,
                                        NS_LITERAL_STRING("invalid"),
-                                       false, true, &defaultAction);
+                                       CanBubble::eNo,
+                                       Cancelable::eYes,
+                                       &defaultAction);
   if (!defaultAction) {
     return false;
   }
 
   nsCOMPtr<nsIObserverService> service =
     mozilla::services::GetObserverService();
   if (!service) {
     NS_WARNING("No observer service available!");
--- a/dom/html/nsTextEditorState.cpp
+++ b/dom/html/nsTextEditorState.cpp
@@ -1719,17 +1719,20 @@ nsTextEditorState::SetSelectionRange(uin
     // fixing that...
     changed = true;
   }
 
   if (changed) {
     // It sure would be nice if we had an existing Element* or so to work with.
     nsCOMPtr<nsINode> node = do_QueryInterface(mTextCtrlElement);
     RefPtr<AsyncEventDispatcher> asyncDispatcher =
-      new AsyncEventDispatcher(node, NS_LITERAL_STRING("select"), true, false);
+      new AsyncEventDispatcher(node,
+                               NS_LITERAL_STRING("select"),
+                               CanBubble::eYes,
+                               ChromeOnlyDispatch::eNo);
     asyncDispatcher->PostDOMEvent();
   }
 
   if (NS_FAILED(rv)) {
     aRv.Throw(rv);
   }
 }
 
--- a/dom/ipc/TabParent.cpp
+++ b/dom/ipc/TabParent.cpp
@@ -465,21 +465,23 @@ TabParent::ActorDestroy(ActorDestroyReas
         // It's possible that the frameloader owner has already moved on
         // and created a new frameloader. If so, we don't fire the event,
         // since the frameloader owner has clearly moved on.
         if (currentFrameLoader == frameLoader) {
           MessageChannel* channel = GetIPCChannel();
           if (channel && !channel->DoBuildIDsMatch()) {
             nsContentUtils::DispatchTrustedEvent(
               frameElement->OwnerDoc(), frameElement,
-              NS_LITERAL_STRING("oop-browser-buildid-mismatch"), true, true);
+              NS_LITERAL_STRING("oop-browser-buildid-mismatch"),
+              CanBubble::eYes, Cancelable::eYes);
           } else {
             nsContentUtils::DispatchTrustedEvent(
               frameElement->OwnerDoc(), frameElement,
-              NS_LITERAL_STRING("oop-browser-crashed"), true, true);
+              NS_LITERAL_STRING("oop-browser-crashed"),
+              CanBubble::eYes, Cancelable::eYes);
           }
         }
       }
     }
 
     mFrameLoader = nullptr;
   }
 
--- a/dom/media/BackgroundVideoDecodingPermissionObserver.cpp
+++ b/dom/media/BackgroundVideoDecodingPermissionObserver.cpp
@@ -108,34 +108,34 @@ BackgroundVideoDecodingPermissionObserve
   nsIDocument* doc = GetOwnerDoc();
   if (!doc) {
     return;
   }
 
   RefPtr<AsyncEventDispatcher> asyncDispatcher =
     new AsyncEventDispatcher(doc,
                              NS_LITERAL_STRING("UnselectedTabHover:Enable"),
-                             /* Bubbles */ true,
-                             /* OnlyChromeDispatch */ true);
+                             CanBubble::eYes,
+                             ChromeOnlyDispatch::eYes);
   asyncDispatcher->PostDOMEvent();
 }
 
 void
 BackgroundVideoDecodingPermissionObserver::DisableEvent() const
 {
   nsIDocument* doc = GetOwnerDoc();
   if (!doc) {
     return;
   }
 
   RefPtr<AsyncEventDispatcher> asyncDispatcher =
     new AsyncEventDispatcher(doc,
                              NS_LITERAL_STRING("UnselectedTabHover:Disable"),
-                             /* Bubbles */ true,
-                             /* OnlyChromeDispatch */ true);
+                             CanBubble::eYes,
+                             ChromeOnlyDispatch::eYes);
   asyncDispatcher->PostDOMEvent();
 }
 
 already_AddRefed<nsPIDOMWindowOuter>
 BackgroundVideoDecodingPermissionObserver::GetOwnerWindow() const
 {
   nsIDocument* doc = GetOwnerDoc();
   if (!doc) {
--- a/dom/media/MediaTrackList.cpp
+++ b/dom/media/MediaTrackList.cpp
@@ -139,17 +139,19 @@ MediaTrackList::EmptyTracks()
   }
   mTracks.Clear();
 }
 
 void
 MediaTrackList::CreateAndDispatchChangeEvent()
 {
   RefPtr<AsyncEventDispatcher> asyncDispatcher =
-    new AsyncEventDispatcher(this, NS_LITERAL_STRING("change"), false);
+    new AsyncEventDispatcher(this,
+                             NS_LITERAL_STRING("change"),
+                             CanBubble::eNo);
   asyncDispatcher->PostDOMEvent();
 }
 
 void
 MediaTrackList::CreateAndDispatchTrackEventRunner(MediaTrack* aTrack,
                                                   const nsAString& aEventName)
 {
   TrackEventInit eventInit;
--- a/dom/media/eme/MediaEncryptedEvent.cpp
+++ b/dom/media/eme/MediaEncryptedEvent.cpp
@@ -51,28 +51,28 @@ MediaEncryptedEvent::WrapObjectInternal(
 {
   return MediaEncryptedEventBinding::Wrap(aCx, this, aGivenProto);
 }
 
 already_AddRefed<MediaEncryptedEvent>
 MediaEncryptedEvent::Constructor(EventTarget* aOwner)
 {
   RefPtr<MediaEncryptedEvent> e = new MediaEncryptedEvent(aOwner);
-  e->InitEvent(NS_LITERAL_STRING("encrypted"), false, false);
+  e->InitEvent(NS_LITERAL_STRING("encrypted"), CanBubble::eNo, Cancelable::eNo);
   e->SetTrusted(true);
   return e.forget();
 }
 
 already_AddRefed<MediaEncryptedEvent>
 MediaEncryptedEvent::Constructor(EventTarget* aOwner,
                                  const nsAString& aInitDataType,
                                  const nsTArray<uint8_t>& aInitData)
 {
   RefPtr<MediaEncryptedEvent> e = new MediaEncryptedEvent(aOwner);
-  e->InitEvent(NS_LITERAL_STRING("encrypted"), false, false);
+  e->InitEvent(NS_LITERAL_STRING("encrypted"), CanBubble::eNo, Cancelable::eNo);
   e->mInitDataType = aInitDataType;
   e->mRawInitData = aInitData;
   e->SetTrusted(true);
   return e.forget();
 }
 
 already_AddRefed<MediaEncryptedEvent>
 MediaEncryptedEvent::Constructor(const GlobalObject& aGlobal,
--- a/dom/media/eme/MediaKeyError.cpp
+++ b/dom/media/eme/MediaKeyError.cpp
@@ -10,17 +10,17 @@
 
 namespace mozilla {
 namespace dom {
 
 MediaKeyError::MediaKeyError(EventTarget* aOwner, uint32_t aSystemCode)
   : Event(aOwner, nullptr, nullptr)
   , mSystemCode(aSystemCode)
 {
-  InitEvent(NS_LITERAL_STRING("error"), false, false);
+  InitEvent(NS_LITERAL_STRING("error"), CanBubble::eNo, Cancelable::eNo);
 }
 
 MediaKeyError::~MediaKeyError()
 {
 }
 
 uint32_t
 MediaKeyError::SystemCode() const
--- a/dom/media/eme/MediaKeySession.cpp
+++ b/dom/media/eme/MediaKeySession.cpp
@@ -602,17 +602,19 @@ MediaKeySession::DispatchKeyStatusesChan
 {
   if (IsClosed()) {
     return;
   }
 
   UpdateKeyStatusMap();
 
   RefPtr<AsyncEventDispatcher> asyncDispatcher =
-    new AsyncEventDispatcher(this, NS_LITERAL_STRING("keystatuseschange"), false);
+    new AsyncEventDispatcher(this,
+                             NS_LITERAL_STRING("keystatuseschange"),
+                             CanBubble::eNo);
   asyncDispatcher->PostDOMEvent();
 }
 
 uint32_t
 MediaKeySession::Token() const
 {
   return mToken;
 }
--- a/dom/media/webaudio/AudioContext.cpp
+++ b/dom/media/webaudio/AudioContext.cpp
@@ -836,17 +836,17 @@ public:
     nsIDocument* doc = parent->GetExtantDoc();
     if (!doc) {
       return NS_ERROR_FAILURE;
     }
 
     return nsContentUtils::DispatchTrustedEvent(doc,
                                 static_cast<DOMEventTargetHelper*>(mAudioContext),
                                 NS_LITERAL_STRING("statechange"),
-                                false, false);
+                                CanBubble::eNo, Cancelable::eNo);
   }
 
 private:
   RefPtr<AudioContext> mAudioContext;
 };
 
 
 void
--- a/dom/media/webaudio/AudioProcessingEvent.h
+++ b/dom/media/webaudio/AudioProcessingEvent.h
@@ -26,17 +26,17 @@ public:
 
   JSObject* WrapObjectInternal(JSContext* aCx, JS::Handle<JSObject*> aGivenProto) override;
 
   using Event::InitEvent;
   void InitEvent(AudioBuffer* aInputBuffer,
                  uint32_t aNumberOfInputChannels,
                  double aPlaybackTime)
   {
-    InitEvent(NS_LITERAL_STRING("audioprocess"), false, false);
+    InitEvent(NS_LITERAL_STRING("audioprocess"), CanBubble::eNo, Cancelable::eNo);
     mInputBuffer = aInputBuffer;
     mNumberOfInputChannels = aNumberOfInputChannels;
     mPlaybackTime = aPlaybackTime;
   }
 
   double PlaybackTime() const
   {
     return mPlaybackTime;
--- a/dom/messagechannel/MessagePort.cpp
+++ b/dom/messagechannel/MessagePort.cpp
@@ -146,18 +146,17 @@ private:
 
     Sequence<OwningNonNull<MessagePort>> ports;
     if (!mData->TakeTransferredPortsAsSequence(ports)) {
       mPort->DispatchError();
       return NS_ERROR_OUT_OF_MEMORY;
     }
 
     event->InitMessageEvent(nullptr, NS_LITERAL_STRING("message"),
-                            false /* non-bubbling */,
-                            false /* cancelable */, value, EmptyString(),
+                            CanBubble::eNo, Cancelable::eNo, value, EmptyString(),
                             EmptyString(), nullptr, ports);
     event->SetTrusted(true);
 
     mPort->DispatchEvent(*event);
 
     return NS_OK;
   }
 
--- a/dom/permission/PermissionStatus.cpp
+++ b/dom/permission/PermissionStatus.cpp
@@ -115,15 +115,15 @@ PermissionStatus::GetPrincipal() const
 
 void
 PermissionStatus::PermissionChanged()
 {
   auto oldState = mState;
   UpdateState();
   if (mState != oldState) {
     RefPtr<AsyncEventDispatcher> eventDispatcher =
-      new AsyncEventDispatcher(this, NS_LITERAL_STRING("change"), false);
+      new AsyncEventDispatcher(this, NS_LITERAL_STRING("change"), CanBubble::eNo);
     eventDispatcher->PostDOMEvent();
   }
 }
 
 } // namespace dom
 } // namespace mozilla
--- a/dom/plugins/base/nsPluginInstanceOwner.cpp
+++ b/dom/plugins/base/nsPluginInstanceOwner.cpp
@@ -118,17 +118,17 @@ public:
     mFinished(aFinished)
   {
   }
 
   NS_IMETHOD Run() override
   {
     nsContentUtils::DispatchTrustedEvent(mContent->OwnerDoc(), mContent,
         mFinished ? NS_LITERAL_STRING("MozPaintWaitFinished") : NS_LITERAL_STRING("MozPaintWait"),
-        true, true);
+        CanBubble::eYes, Cancelable::eYes);
     return NS_OK;
   }
 
 private:
   nsCOMPtr<nsIContent> mContent;
   bool                 mFinished;
 };
 
@@ -1998,17 +1998,17 @@ TranslateToNPCocoaEvent(WidgetGUIEvent* 
 
 void nsPluginInstanceOwner::PerformDelayedBlurs()
 {
   nsCOMPtr<nsIContent> content = do_QueryReferent(mContent);
   nsCOMPtr<EventTarget> windowRoot = content->OwnerDoc()->GetWindow()->GetTopWindowRoot();
   nsContentUtils::DispatchTrustedEvent(content->OwnerDoc(),
                                        windowRoot,
                                        NS_LITERAL_STRING("MozPerformDelayedBlur"),
-                                       false, false, nullptr);
+                                       CanBuble::No, Cancelable::eNo, nullptr);
 }
 
 #endif
 
 nsEventStatus nsPluginInstanceOwner::ProcessEvent(const WidgetGUIEvent& anEvent)
 {
   nsEventStatus rv = nsEventStatus_eIgnore;
 
--- a/dom/presentation/PresentationConnection.cpp
+++ b/dom/presentation/PresentationConnection.cpp
@@ -458,17 +458,19 @@ PresentationConnection::ProcessStateChan
     case PresentationConnectionState::Connecting:
       return NS_OK;
     case PresentationConnectionState::Connected: {
       if (nsContentUtils::ShouldResistFingerprinting()) {
         return NS_OK;
       }
 
       RefPtr<AsyncEventDispatcher> asyncDispatcher =
-        new AsyncEventDispatcher(this, NS_LITERAL_STRING("connect"), false);
+        new AsyncEventDispatcher(this,
+                                 NS_LITERAL_STRING("connect"),
+                                 CanBubble::eNo);
       return asyncDispatcher->PostDOMEvent();
     }
     case PresentationConnectionState::Closed: {
       PresentationConnectionClosedReason reason =
         PresentationConnectionClosedReason::Closed;
 
       nsString errorMsg;
       if (NS_FAILED(aReason)) {
@@ -489,17 +491,19 @@ PresentationConnection::ProcessStateChan
         NS_WARN_IF(NS_FAILED(DispatchConnectionCloseEvent(reason, errorMsg)));
 
       return RemoveFromLoadGroup();
     }
     case PresentationConnectionState::Terminated: {
       if (!nsContentUtils::ShouldResistFingerprinting()) {
         // Ensure onterminate event is fired.
         RefPtr<AsyncEventDispatcher> asyncDispatcher =
-          new AsyncEventDispatcher(this, NS_LITERAL_STRING("terminate"), false);
+          new AsyncEventDispatcher(this,
+                                   NS_LITERAL_STRING("terminate"),
+                                   CanBubble::eNo);
         Unused << NS_WARN_IF(NS_FAILED(asyncDispatcher->PostDOMEvent()));
       }
 
       nsCOMPtr<nsIPresentationService> service =
         do_GetService(PRESENTATION_SERVICE_CONTRACTID);
       if (NS_WARN_IF(!service)) {
         return NS_ERROR_NOT_AVAILABLE;
       }
@@ -639,17 +643,17 @@ PresentationConnection::DispatchMessageE
   if (NS_WARN_IF(NS_FAILED(rv))) {
     return rv;
   }
 
   RefPtr<MessageEvent> messageEvent = new MessageEvent(this, nullptr, nullptr);
 
   messageEvent->InitMessageEvent(nullptr,
                                  NS_LITERAL_STRING("message"),
-                                 false, false, aData, origin,
+                                 CanBubble::eNo, Cancelable::eNo, aData, origin,
                                  EmptyString(), nullptr,
                                  Sequence<OwningNonNull<MessagePort>>());
   messageEvent->SetTrusted(true);
 
   RefPtr<AsyncEventDispatcher> asyncDispatcher =
     new AsyncEventDispatcher(this, messageEvent);
   return asyncDispatcher->PostDOMEvent();
 }
--- a/dom/script/ScriptElement.cpp
+++ b/dom/script/ScriptElement.cpp
@@ -43,18 +43,18 @@ ScriptElement::ScriptAvailable(nsresult 
 ScriptElement::FireErrorEvent()
 {
   nsCOMPtr<nsIContent> cont =
     do_QueryInterface((nsIScriptElement*) this);
 
   return nsContentUtils::DispatchTrustedEvent(cont->OwnerDoc(),
                                               cont,
                                               NS_LITERAL_STRING("error"),
-                                              false /* bubbles */,
-                                              false /* cancelable */);
+                                              CanBubble::eNo,
+                                              Cancelable::eNo);
 }
 
 NS_IMETHODIMP
 ScriptElement::ScriptEvaluated(nsresult aResult,
                                nsIScriptElement* aElement,
                                bool aIsInline)
 {
   nsresult rv = NS_OK;
--- a/dom/script/ScriptLoader.cpp
+++ b/dom/script/ScriptLoader.cpp
@@ -1955,17 +1955,17 @@ ScriptLoader::ProcessRequest(ScriptLoadR
   }
 
   nsPIDOMWindowInner* pwin = mDocument->GetInnerWindow();
   bool runScript = !!pwin;
   if (runScript) {
     nsContentUtils::DispatchTrustedEvent(scriptElem->OwnerDoc(),
                                          scriptElem,
                                          NS_LITERAL_STRING("beforescriptexecute"),
-                                         true, true, &runScript);
+                                         CanBubble::eYes, Cancelable::eYes, &runScript);
   }
 
   // Inner window could have gone away after firing beforescriptexecute
   pwin = mDocument->GetInnerWindow();
   if (!pwin) {
     runScript = false;
   }
 
@@ -1977,17 +1977,17 @@ ScriptLoader::ProcessRequest(ScriptLoadR
     rv = EvaluateScript(aRequest);
     if (doc) {
       doc->DecrementIgnoreDestructiveWritesCounter();
     }
 
     nsContentUtils::DispatchTrustedEvent(scriptElem->OwnerDoc(),
                                          scriptElem,
                                          NS_LITERAL_STRING("afterscriptexecute"),
-                                         true, false);
+                                         CanBubble::eYes, Cancelable::eNo);
   }
 
   FireScriptEvaluated(rv, aRequest);
 
   aRequest->mElement->EndEvaluating();
 
   if (parserCreated) {
     mCurrentParserInsertedScript = oldParserInsertedScript;
--- a/dom/script/ScriptTrace.cpp
+++ b/dom/script/ScriptTrace.cpp
@@ -27,15 +27,18 @@ TestingDispatchEvent(nsIScriptElement* a
   }
 
   nsCOMPtr<nsINode> target(do_QueryInterface(aScriptElement));
   if (!target) {
     return NS_OK;
   }
 
   RefPtr<AsyncEventDispatcher> dispatcher =
-    new AsyncEventDispatcher(target, aEventType, true, false);
+    new AsyncEventDispatcher(target,
+                             aEventType,
+                             CanBubble::eYes,
+                             ChromeOnlyDispatch::eNo);
   return dispatcher->PostDOMEvent();
 }
 
 } // script namespace
 } // dom namespace
 } // mozilla namespace
--- a/dom/websocket/WebSocket.cpp
+++ b/dom/websocket/WebSocket.cpp
@@ -2019,18 +2019,19 @@ WebSocket::CreateAndDispatchMessageEvent
                                              mImpl->mInnerWindowID,
                                              aData, messageType);
 
   // create an event that uses the MessageEvent interface,
   // which does not bubble, is not cancelable, and has no default action
 
   RefPtr<MessageEvent> event = new MessageEvent(this, nullptr, nullptr);
 
-  event->InitMessageEvent(nullptr, MESSAGE_EVENT_STRING, false, false,
-                          jsData, mImpl->mUTF16Origin, EmptyString(), nullptr,
+  event->InitMessageEvent(nullptr, MESSAGE_EVENT_STRING, CanBubble::eNo,
+                          Cancelable::eNo, jsData, mImpl->mUTF16Origin,
+                          EmptyString(), nullptr,
                           Sequence<OwningNonNull<MessagePort>>());
   event->SetTrusted(true);
 
   ErrorResult err;
   DispatchEvent(*event, err);
   return err.StealNSResult();
 }
 
--- a/dom/workers/MessageEventRunnable.cpp
+++ b/dom/workers/MessageEventRunnable.cpp
@@ -84,18 +84,18 @@ MessageEventRunnable::DispatchDOMEvent(J
   if (!TakeTransferredPortsAsSequence(ports)) {
     DispatchError(aCx, aTarget);
     return false;
   }
 
   RefPtr<MessageEvent> event = new MessageEvent(aTarget, nullptr, nullptr);
   event->InitMessageEvent(nullptr,
                           NS_LITERAL_STRING("message"),
-                          false /* non-bubbling */,
-                          false /* cancelable */,
+                          CanBubble::eNo,
+                          Cancelable::eNo,
                           messageData,
                           EmptyString(),
                           EmptyString(),
                           nullptr,
                           ports);
 
   event->SetTrusted(true);
 
--- a/dom/workers/RuntimeService.cpp
+++ b/dom/workers/RuntimeService.cpp
@@ -2365,17 +2365,19 @@ RuntimeService::CreateSharedWorkerFromLo
 
   RefPtr<SharedWorker> sharedWorker = new SharedWorker(window, workerPrivate,
                                                        channel->Port1());
 
   if (!shouldAttachToWorkerPrivate) {
     // We're done here.  Just queue up our error event and return our
     // dead-on-arrival SharedWorker.
     RefPtr<AsyncEventDispatcher> errorEvent =
-      new AsyncEventDispatcher(sharedWorker, NS_LITERAL_STRING("error"), false);
+      new AsyncEventDispatcher(sharedWorker,
+                               NS_LITERAL_STRING("error"),
+                               CanBubble::eNo);
     errorEvent->PostDOMEvent();
     sharedWorker.forget(aSharedWorker);
     return NS_OK;
   }
 
   if (!workerPrivate->RegisterSharedWorker(sharedWorker, channel->Port2())) {
     NS_WARNING("Worker is unreachable, this shouldn't happen!");
     sharedWorker->Close();
--- a/dom/workers/WorkerDebugger.cpp
+++ b/dom/workers/WorkerDebugger.cpp
@@ -53,18 +53,18 @@ private:
       return false;
     }
     JS::Rooted<JS::Value> data(aCx, JS::StringValue(message));
 
     RefPtr<MessageEvent> event = new MessageEvent(globalScope, nullptr,
                                                   nullptr);
     event->InitMessageEvent(nullptr,
                             NS_LITERAL_STRING("message"),
-                            false, // canBubble
-                            true, // cancelable
+                            CanBubble::eNo,
+                            Cancelable::eYes,
                             data,
                             EmptyString(),
                             EmptyString(),
                             nullptr,
                             Sequence<OwningNonNull<MessagePort>>());
     event->SetTrusted(true);
 
     globalScope->DispatchEvent(*event);
--- a/dom/xul/XULDocument.cpp
+++ b/dom/xul/XULDocument.cpp
@@ -2644,18 +2644,18 @@ XULDocument::DoneWalking()
         mDocumentLoaded = true;
 
         NotifyPossibleTitleChange(false);
 
         nsContentUtils::DispatchTrustedEvent(
             this,
             static_cast<nsIDocument*>(this),
             NS_LITERAL_STRING("MozBeforeInitialXULLayout"),
-            true,
-            false);
+            CanBubble::eYes,
+            Cancelable::eNo);
 
         // Before starting layout, check whether we're a toplevel chrome
         // window.  If we are, setup some state so that we don't have to restyle
         // the whole tree after StartLayout.
         if (nsCOMPtr<nsIXULWindow> win = GetXULWindowIfToplevelChrome()) {
             // We're the chrome document!
             win->BeforeStartLayout();
         }
--- a/dom/xul/nsXULElement.cpp
+++ b/dom/xul/nsXULElement.cpp
@@ -906,18 +906,18 @@ nsXULElement::RemoveChildNode(nsIContent
         }
     }
 
     nsIDocument* doc;
     if (fireSelectionHandler && (doc = GetComposedDoc())) {
       nsContentUtils::DispatchTrustedEvent(doc,
                                            static_cast<nsIContent*>(this),
                                            NS_LITERAL_STRING("select"),
-                                           false,
-                                           true);
+                                           CanBubble::eNo,
+                                           Cancelable::eYes);
     }
 }
 
 void
 nsXULElement::UnregisterAccessKey(const nsAString& aOldValue)
 {
     // If someone changes the accesskey, unregister the old one
     //
@@ -1393,17 +1393,17 @@ nsXULElement::LoadSrc()
         frameLoader = nsFrameLoader::Create(this, opener, false);
         slots->mFrameLoaderOrOpener = ToSupports(frameLoader);
         if (NS_WARN_IF(!frameLoader)) {
             return;
         }
 
         (new AsyncEventDispatcher(this,
                                   NS_LITERAL_STRING("XULFrameLoaderCreated"),
-                                  /* aBubbles */ true))->RunDOMEventWhenSafe();
+                                  CanBubble::eYes))->RunDOMEventWhenSafe();
     }
 
     frameLoader->LoadFrame(false);
 }
 
 already_AddRefed<nsFrameLoader>
 nsXULElement::GetFrameLoader()
 {
--- a/gfx/layers/apz/util/APZCCallbackHelper.cpp
+++ b/gfx/layers/apz/util/APZCCallbackHelper.cpp
@@ -857,17 +857,18 @@ APZCCallbackHelper::NotifyMozMouseScroll
   nsCOMPtr<nsIDocument> ownerDoc = targetContent->OwnerDoc();
   if (!ownerDoc) {
     return;
   }
 
   nsContentUtils::DispatchTrustedEvent(
     ownerDoc, targetContent,
     aEvent,
-    true, true);
+    CanBubble::eYes,
+    Cancelable::eYes);
 }
 
 void
 APZCCallbackHelper::NotifyFlushComplete(nsIPresShell* aShell)
 {
   MOZ_ASSERT(NS_IsMainThread());
   // In some cases, flushing the APZ state to the main thread doesn't actually
   // trigger a flush and repaint (this is an intentional optimization - the stuff
--- a/layout/base/nsDocumentViewer.cpp
+++ b/layout/base/nsDocumentViewer.cpp
@@ -526,17 +526,20 @@ public:
 private:
   void DispatchEventToWindowTree(const nsAString& aEvent)
   {
     nsCOMArray<nsIDocument> targets;
     CollectDocuments(mTop, &targets);
     for (int32_t i = 0; i < targets.Count(); ++i) {
       nsIDocument* d = targets[i];
       nsContentUtils::DispatchTrustedEvent(d, d->GetWindow(),
-                                           aEvent, false, false, nullptr);
+                                           aEvent,
+                                           CanBubble::eNo,
+                                           Cancelable::eNo,
+                                           nullptr);
     }
   }
 
   static bool CollectDocuments(nsIDocument* aDocument, void* aData)
   {
     if (aDocument) {
       static_cast<nsCOMArray<nsIDocument>*>(aData)->AppendObject(aDocument);
       aDocument->EnumerateSubDocuments(CollectDocuments, aData);
@@ -3050,17 +3053,17 @@ nsDocumentViewer::SetTextZoom(float aTex
 
   // And do the external resources
   mDocument->EnumerateExternalResources(SetExtResourceTextZoom, &ZoomInfo);
 
   // Dispatch TextZoomChange event only if text zoom value has changed.
   if (textZoomChange) {
     nsContentUtils::DispatchChromeEvent(mDocument, static_cast<nsIDocument*>(mDocument),
                                         NS_LITERAL_STRING("TextZoomChange"),
-                                        true, true);
+                                        CanBubble::eYes, Cancelable::eYes);
   }
 
   return NS_OK;
 }
 
 NS_IMETHODIMP
 nsDocumentViewer::GetTextZoom(float* aTextZoom)
 {
@@ -3170,17 +3173,17 @@ nsDocumentViewer::SetFullZoom(float aFul
 
   // And do the external resources
   mDocument->EnumerateExternalResources(SetExtResourceFullZoom, &ZoomInfo);
 
   // Dispatch FullZoomChange event only if fullzoom value really was been changed
   if (fullZoomChange) {
     nsContentUtils::DispatchChromeEvent(mDocument, static_cast<nsIDocument*>(mDocument),
                                         NS_LITERAL_STRING("FullZoomChange"),
-                                        true, true);
+                                        CanBubble::eYes, Cancelable::eYes);
   }
 
   return NS_OK;
 }
 
 NS_IMETHODIMP
 nsDocumentViewer::GetFullZoom(float* aFullZoom)
 {
--- a/layout/forms/nsComboboxControlFrame.cpp
+++ b/layout/forms/nsComboboxControlFrame.cpp
@@ -1673,18 +1673,18 @@ nsComboboxControlFrame::OnOptionSelected
 
   return NS_OK;
 }
 
 void nsComboboxControlFrame::FireValueChangeEvent()
 {
   // Fire ValueChange event to indicate data value of combo box has changed
   nsContentUtils::AddScriptRunner(
-    new AsyncEventDispatcher(mContent, NS_LITERAL_STRING("ValueChange"), true,
-                             false));
+    new AsyncEventDispatcher(mContent, NS_LITERAL_STRING("ValueChange"),
+                             CanBubble::eYes, ChromeOnlyDispatch::eNo));
 }
 
 void
 nsComboboxControlFrame::OnContentReset()
 {
   if (mListControlFrame) {
     mListControlFrame->OnContentReset();
   }
--- a/layout/forms/nsFileControlFrame.cpp
+++ b/layout/forms/nsFileControlFrame.cpp
@@ -323,22 +323,24 @@ nsFileControlFrame::DnDListener::HandleE
       }
       // Normal DnD
       else {
         inputElement->SetFiles(fileList, true);
       }
 
       nsContentUtils::DispatchTrustedEvent(inputElement->OwnerDoc(),
                                            static_cast<nsINode*>(inputElement),
-                                           NS_LITERAL_STRING("input"), true,
-                                           false);
+                                           NS_LITERAL_STRING("input"),
+                                           CanBubble::eYes,
+                                           Cancelable::eNo);
       nsContentUtils::DispatchTrustedEvent(inputElement->OwnerDoc(),
                                            static_cast<nsINode*>(inputElement),
-                                           NS_LITERAL_STRING("change"), true,
-                                           false);
+                                           NS_LITERAL_STRING("change"),
+                                           CanBubble::eYes,
+                                           Cancelable::eNo);
     }
   }
 
   return NS_OK;
 }
 
 nsresult
 nsFileControlFrame::DnDListener::GetBlobImplForWebkitDirectory(FileList* aFileList,
--- a/layout/forms/nsListControlFrame.cpp
+++ b/layout/forms/nsListControlFrame.cpp
@@ -153,18 +153,19 @@ nsListControlFrame::DestroyFrom(nsIFrame
   mContent->RemoveSystemEventListener(NS_LITERAL_STRING("mouseup"),
                                       mEventListener, false);
   mContent->RemoveSystemEventListener(NS_LITERAL_STRING("mousemove"),
                                       mEventListener, false);
 
   if (ShouldFireDropDownEvent()) {
     nsContentUtils::AddScriptRunner(
       new AsyncEventDispatcher(mContent,
-                               NS_LITERAL_STRING("mozhidedropdown"), true,
-                               true));
+                               NS_LITERAL_STRING("mozhidedropdown"),
+                               CanBubble::eYes,
+                               ChromeOnlyDispatch::eYes));
   }
 
   nsCheckboxRadioFrame::RegUnRegAccessKey(static_cast<nsIFrame*>(this), false);
   nsHTMLScrollFrame::DestroyFrom(aDestructRoot, aPostDestroyData);
 }
 
 void
 nsListControlFrame::BuildDisplayList(nsDisplayListBuilder*   aBuilder,
@@ -1382,22 +1383,24 @@ nsListControlFrame::FireOnInputAndOnChan
     if (index == GetSelectedIndex()) {
       return;
     }
   }
 
   nsCOMPtr<nsIContent> content = mContent;
   // Dispatch the input event.
   nsContentUtils::DispatchTrustedEvent(content->OwnerDoc(), content,
-                                       NS_LITERAL_STRING("input"), true,
-                                       false);
+                                       NS_LITERAL_STRING("input"),
+                                       CanBubble::eYes,
+                                       Cancelable::eNo);
   // Dispatch the change event.
   nsContentUtils::DispatchTrustedEvent(content->OwnerDoc(), content,
-                                       NS_LITERAL_STRING("change"), true,
-                                       false);
+                                       NS_LITERAL_STRING("change"),
+                                       CanBubble::eYes,
+                                       Cancelable::eNo);
 }
 
 NS_IMETHODIMP
 nsListControlFrame::OnSetSelectedIndex(int32_t aOldIndex, int32_t aNewIndex)
 {
   if (mComboboxFrame) {
     // UpdateRecentIndex with NS_SKIP_NOTIFY_INDEX, so that we won't fire an onchange
     // event for this setting of selectedIndex.
@@ -1780,17 +1783,18 @@ FireShowDropDownEvent(nsIContent* aConte
     nsString eventName;
     if (aShow) {
       eventName = aIsSourceTouchEvent ? NS_LITERAL_STRING("mozshowdropdown-sourcetouch") :
                                         NS_LITERAL_STRING("mozshowdropdown");
     } else {
       eventName = NS_LITERAL_STRING("mozhidedropdown");
     }
     nsContentUtils::DispatchChromeEvent(aContent->OwnerDoc(), aContent,
-                                        eventName, true, false);
+                                        eventName, CanBubble::eYes,
+                                        Cancelable::eNo);
     return true;
   }
 
   return false;
 }
 
 nsresult
 nsListControlFrame::MouseDown(dom::Event* aMouseEvent)
--- a/layout/generic/nsFrame.cpp
+++ b/layout/generic/nsFrame.cpp
@@ -3865,17 +3865,20 @@ nsFrame::GetContentForEvent(WidgetEvent*
 
 void
 nsFrame::FireDOMEvent(const nsAString& aDOMEventName, nsIContent *aContent)
 {
   nsIContent* target = aContent ? aContent : GetContent();
 
   if (target) {
     RefPtr<AsyncEventDispatcher> asyncDispatcher =
-      new AsyncEventDispatcher(target, aDOMEventName, true, false);
+      new AsyncEventDispatcher(target,
+                               aDOMEventName,
+                               CanBubble::eYes,
+                               ChromeOnlyDispatch::eNo);
     DebugOnly<nsresult> rv = asyncDispatcher->PostDOMEvent();
     NS_ASSERTION(NS_SUCCEEDED(rv), "AsyncEventDispatcher failed to dispatch");
   }
 }
 
 nsresult
 nsFrame::HandleEvent(nsPresContext* aPresContext,
                      WidgetGUIEvent* aEvent,
--- a/layout/generic/nsGfxScrollFrame.cpp
+++ b/layout/generic/nsGfxScrollFrame.cpp
@@ -4532,18 +4532,18 @@ ScrollFrameHelper::FireScrollEndEvent()
   MOZ_ASSERT(mOuter->GetContent());
   MOZ_ASSERT(mScrollEndEvent);
   mScrollEndEvent->Revoke();
   mScrollEndEvent = nullptr;
 
   nsContentUtils::DispatchEventOnlyToChrome(mOuter->GetContent()->OwnerDoc(),
                                             mOuter->GetContent(),
                                             NS_LITERAL_STRING("scrollend"),
-                                            true /* aCanBubble */,
-                                            false /* aCancelable */);
+                                            CanBubble::eYes,
+                                            Cancelable::eNo);
 }
 
 void
 ScrollFrameHelper::ReloadChildFrames()
 {
   mScrolledFrame = nullptr;
   mHScrollbarBox = nullptr;
   mVScrollbarBox = nullptr;
--- a/layout/generic/nsVideoFrame.cpp
+++ b/layout/generic/nsVideoFrame.cpp
@@ -264,17 +264,17 @@ public:
   explicit DispatchResizeToControls(nsIContent* aContent)
     : mozilla::Runnable("DispatchResizeToControls")
     , mContent(aContent)
   {
   }
   NS_IMETHOD Run() override {
     nsContentUtils::DispatchTrustedEvent(mContent->OwnerDoc(), mContent,
                                          NS_LITERAL_STRING("resizevideocontrols"),
-                                         false, false);
+                                         CanBubble::eNo, Cancelable::eNo);
     return NS_OK;
   }
   nsCOMPtr<nsIContent> mContent;
 };
 
 void
 nsVideoFrame::Reflow(nsPresContext* aPresContext,
                      ReflowOutput& aMetrics,
--- a/layout/printing/nsPrintJob.cpp
+++ b/layout/printing/nsPrintJob.cpp
@@ -1636,17 +1636,17 @@ nsPrintJob::FirePrintingErrorEvent(nsres
   JS::Rooted<JS::Value> detail(cx,
     JS::NumberValue(static_cast<double>(aPrintError)));
   event->InitCustomEvent(cx, NS_LITERAL_STRING("PrintingError"), false, false,
                          detail);
   event->SetTrusted(true);
 
   RefPtr<AsyncEventDispatcher> asyncDispatcher =
     new AsyncEventDispatcher(doc, event);
-  asyncDispatcher->mOnlyChromeDispatch = true;
+  asyncDispatcher->mOnlyChromeDispatch = ChromeOnlyDispatch::eYes;
   asyncDispatcher->RunDOMEventWhenSafe();
 
   // Inform any progress listeners of the Error.
   if (mPrt) {
     // Note that nsPrintData::DoOnStatusChange() will call some listeners.
     // So, mPrt can be cleared or recreated.
     RefPtr<nsPrintData> printData = mPrt;
     printData->DoOnStatusChange(aPrintError);
@@ -1987,18 +1987,19 @@ nsPrintJob::ReflowDocList(const UniquePt
 void
 nsPrintJob::FirePrintPreviewUpdateEvent()
 {
   // Dispatch the event only while in PrintPreview. When printing, there is no
   // listener bound to this event and therefore no need to dispatch it.
   if (mIsDoingPrintPreview && !mIsDoingPrinting) {
     nsCOMPtr<nsIContentViewer> cv = do_QueryInterface(mDocViewerPrint);
     (new AsyncEventDispatcher(
-       cv->GetDocument(), NS_LITERAL_STRING("printPreviewUpdate"), true, true)
-    )->RunDOMEventWhenSafe();
+       cv->GetDocument(), NS_LITERAL_STRING("printPreviewUpdate"),
+       CanBubble::eYes, ChromeOnlyDispatch::eYes
+    ))->RunDOMEventWhenSafe();
   }
 }
 
 nsresult
 nsPrintJob::InitPrintDocConstruction(bool aHandleError)
 {
   nsresult rv;
   // Guarantee that mPrt->mPrintObject won't be deleted.  It's owned by mPrt.
--- a/layout/style/FontFaceSet.cpp
+++ b/layout/style/FontFaceSet.cpp
@@ -1684,17 +1684,17 @@ FontFaceSet::DispatchLoadingEventAndRepl
     // refcounting.  (Also, the Promise object creation must be done on
     // the main thread.)
     set->AppendTask(
       PostTraversalTask::DispatchLoadingEventAndReplaceReadyPromise(this));
     return;
   }
 
   (new AsyncEventDispatcher(this, NS_LITERAL_STRING("loading"),
-                            false))->PostDOMEvent();
+                            CanBubble::eNo))->PostDOMEvent();
 
   if (PrefEnabled()) {
     if (mReady &&
         mReady->State() != Promise::PromiseState::Pending) {
       if (GetParentObject()) {
         ErrorResult rv;
         mReady = Promise::Create(GetParentObject(), rv);
       }
--- a/layout/style/Loader.cpp
+++ b/layout/style/Loader.cpp
@@ -317,17 +317,17 @@ SheetLoadData::FireLoadEvent(nsIThreadIn
   nsCOMPtr<nsINode> node = do_QueryInterface(mOwningElement);
   NS_ASSERTION(node, "How did that happen???");
 
   nsContentUtils::DispatchTrustedEvent(node->OwnerDoc(),
                                        node,
                                        mLoadFailed ?
                                          NS_LITERAL_STRING("error") :
                                          NS_LITERAL_STRING("load"),
-                                       false, false);
+                                       CanBubble::eNo, Cancelable::eNo);
 
   // And unblock onload
   mLoader->UnblockOnload(true);
 }
 
 void
 SheetLoadData::ScheduleLoadEventIfNeeded()
 {
@@ -1984,17 +1984,18 @@ Loader::LoadStyleLink(const SheetInfo& a
     // implement that via nsDataDocumentContentPolicy, which doesn't have a good
     // way to communicate back to us that _it_ is the thing that blocked the
     // load.
     if (aInfo.mContent && !mDocument->IsLoadedAsData()) {
       // Fire an async error event on it.
       RefPtr<AsyncEventDispatcher> loadBlockingAsyncDispatcher =
         new LoadBlockingAsyncEventDispatcher(aInfo.mContent,
                                              NS_LITERAL_STRING("error"),
-                                             false, false);
+                                             CanBubble::eNo,
+                                             ChromeOnlyDispatch::eNo);
       loadBlockingAsyncDispatcher->PostDOMEvent();
     }
     return Err(rv);
   }
 
   StyleSheetState state;
   RefPtr<StyleSheet> sheet;
   auto isAlternate = IsAlternateSheet(aInfo.mTitle, aInfo.mHasAlternateRel);
--- a/layout/xul/tree/nsTreeSelection.cpp
+++ b/layout/xul/tree/nsTreeSelection.cpp
@@ -647,17 +647,17 @@ NS_IMETHODIMP nsTreeSelection::SetCurren
 
   NS_NAMED_LITERAL_STRING(DOMMenuItemActive, "DOMMenuItemActive");
   NS_NAMED_LITERAL_STRING(DOMMenuItemInactive, "DOMMenuItemInactive");
 
   RefPtr<AsyncEventDispatcher> asyncDispatcher =
     new AsyncEventDispatcher(treeElt,
                              (aIndex != -1 ? DOMMenuItemActive :
                                              DOMMenuItemInactive),
-                             true, false);
+                             CanBubble::eYes, ChromeOnlyDispatch::eNo);
   return asyncDispatcher->PostDOMEvent();
 }
 
 NS_IMETHODIMP nsTreeSelection::GetCurrentColumn(nsTreeColumn** aCurrentColumn)
 {
   NS_IF_ADDREF(*aCurrentColumn = mCurrentColumn);
   return NS_OK;
 }
@@ -830,17 +830,18 @@ nsTreeSelection::FireOnSelectHandler()
   NS_ASSERTION(boxObject, "no box object!");
   if (!boxObject)
      return NS_ERROR_UNEXPECTED;
   RefPtr<dom::Element> elt;
   boxObject->GetElement(getter_AddRefs(elt));
   NS_ENSURE_STATE(elt);
 
   RefPtr<AsyncEventDispatcher> asyncDispatcher =
-    new AsyncEventDispatcher(elt, NS_LITERAL_STRING("select"), true, false);
+    new AsyncEventDispatcher(elt, NS_LITERAL_STRING("select"),
+                             CanBubble::eYes, ChromeOnlyDispatch::eNo);
   asyncDispatcher->RunDOMEventWhenSafe();
   return NS_OK;
 }
 
 void
 nsTreeSelection::SelectCallback(nsITimer *aTimer, void *aClosure)
 {
   RefPtr<nsTreeSelection> self = static_cast<nsTreeSelection*>(aClosure);
--- a/uriloader/prefetch/nsPrefetchService.cpp
+++ b/uriloader/prefetch/nsPrefetchService.cpp
@@ -527,17 +527,17 @@ nsPrefetchService::DispatchEvent(nsPrefe
         // We don't dispatch synchronously since |node| might be in a DocGroup
         // that we're not allowed to touch. (Our network request happens in the
         // DocGroup of one of the mSources nodes--not necessarily this one).
         RefPtr<AsyncEventDispatcher> dispatcher =
           new AsyncEventDispatcher(domNode,
                                    aSuccess ?
                                     NS_LITERAL_STRING("load") :
                                     NS_LITERAL_STRING("error"),
-                                   /* aCanBubble = */ false);
+                                   CanBubble::eNo);
         dispatcher->RequireNodeInDocument();
         dispatcher->PostDOMEvent();
       }
     }
 }
 
 //-----------------------------------------------------------------------------
 // nsPrefetchService <private>
@@ -726,21 +726,20 @@ nsPrefetchService::Preload(nsIURI *aURI,
     // or possibly nsIRequest::loadFlags to determine if this URI should be
     // prefetched.
     //
 
     if (aPolicyType == nsIContentPolicy::TYPE_INVALID) {
         nsCOMPtr<nsINode> domNode = do_QueryInterface(aSource);
         if (domNode && domNode->IsInComposedDoc()) {
             RefPtr<AsyncEventDispatcher> asyncDispatcher =
-                new AsyncEventDispatcher(//domNode->OwnerDoc(),
-                                         domNode,
+                new AsyncEventDispatcher(domNode,
                                          NS_LITERAL_STRING("error"),
-                                         /* aCanBubble = */ false,
-                                         /* aCancelable = */ false);
+                                         CanBubble::eNo,
+                                         ChromeOnlyDispatch::eNo);
             asyncDispatcher->RunDOMEventWhenSafe();
         }
         return NS_OK;
     }
 
     //
     // Check whether it is being preloaded.
     //
@@ -773,18 +772,18 @@ nsPrefetchService::Preload(nsIURI *aURI,
     if (NS_SUCCEEDED(rv)) {
         mCurrentNodes.AppendElement(enqueuedNode);
     } else {
         nsCOMPtr<nsINode> domNode = do_QueryInterface(aSource);
         if (domNode && domNode->IsInComposedDoc()) {
             RefPtr<AsyncEventDispatcher> asyncDispatcher =
                 new AsyncEventDispatcher(domNode,
                                          NS_LITERAL_STRING("error"),
-                                         /* aCanBubble = */ false,
-                                         /* aCancelable = */ false);
+                                         CanBubble::eNo,
+                                         ChromeOnlyDispatch::eNo);
             asyncDispatcher->RunDOMEventWhenSafe();
         }
     }
     return NS_OK;
 }
 
 nsresult
 nsPrefetchService::Prefetch(nsIURI *aURI,
--- a/widget/EventForwards.h
+++ b/widget/EventForwards.h
@@ -28,16 +28,40 @@ enum nsEventStatus
   // The event is consumed, but do default processing
   nsEventStatus_eConsumeDoDefault,
   // Value is not for use, only for serialization
   nsEventStatus_eSentinel
 };
 
 namespace mozilla {
 
+enum class CanBubble
+{
+  eYes,
+  eNo
+};
+
+enum class Cancelable
+{
+  eYes,
+  eNo
+};
+
+enum class ChromeOnlyDispatch
+{
+  eYes,
+  eNo
+};
+
+enum class Trusted
+{
+  eYes,
+  eNo
+};
+
 /**
  * Event messages
  */
 
 typedef uint16_t EventMessageType;
 
 enum EventMessage : EventMessageType
 {
--- a/xpfe/appshell/nsWebShellWindow.cpp
+++ b/xpfe/appshell/nsWebShellWindow.cpp
@@ -278,17 +278,17 @@ nsWebShellWindow::WindowMoved(nsIWidget*
   }
 
   // Notify all tabs that the widget moved.
   if (mDocShell && mDocShell->GetWindow()) {
     nsCOMPtr<EventTarget> eventTarget = mDocShell->GetWindow()->GetTopWindowRoot();
     nsContentUtils::DispatchChromeEvent(mDocShell->GetDocument(),
                                         eventTarget,
                                         NS_LITERAL_STRING("MozUpdateWindowPos"),
-                                        false, false, nullptr);
+                                        CanBubble::eNo, Cancelable::eNo, nullptr);
   }
 
   // Persist position, but not immediately, in case this OS is firing
   // repeated move events as the user drags the window
   SetPersistenceTimer(PAD_POSITION);
   return false;
 }