Bug 1446711 part 7. Switch the nsIDOMMouseEvent::MOZ_SOURCE_* constants over to MouseEventBinding. r=qdot
authorBoris Zbarsky <bzbarsky@mit.edu>
Tue, 20 Mar 2018 00:16:06 -0400
changeset 462482 3073cf6d1124f9427bd8fb71f1a6478202a6baa6
parent 462481 1e34d0184ad6b98dc6c4038430cec7caee6141c8
child 462483 7a1e55aa1a6b3bacede832a123c29b7ae68fd3c3
push id9165
push userasasaki@mozilla.com
push dateThu, 26 Apr 2018 21:04:54 +0000
treeherdermozilla-beta@064c3804de2e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersqdot
bugs1446711
milestone61.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 1446711 part 7. Switch the nsIDOMMouseEvent::MOZ_SOURCE_* constants over to MouseEventBinding. r=qdot We can't include MouseEventBinding.h in MouseEvents.h because that produces this include loop: MouseEventBinding.h -> UIEventBinding.h -> nsGlobalWindow.h -> nsGlobalWindowInner.h -> nsRefreshDriver.h -> AnimationEventDispatcher.h -> AnimationComparator.h -> Animation.h -> EffectCompositor.h -> PseudoElementHashEntry.h -> Element.h -> PointerEventHandler.h -> MouseEvents.h -> MouseEventBinding.h MozReview-Commit-ID: 6FNksGil7uD
accessible/base/nsCoreUtils.cpp
accessible/jsat/PointerAdapter.jsm
devtools/server/actors/emulation/touch-simulator.js
dom/base/Element.cpp
dom/base/nsContentUtils.cpp
dom/base/nsContentUtils.h
dom/base/test/test_domwindowutils.html
dom/events/DragEvent.cpp
dom/events/EventStateManager.cpp
dom/events/IMEStateManager.cpp
dom/events/MouseEvent.cpp
dom/events/MouseScrollEvent.cpp
dom/events/PointerEvent.cpp
dom/events/PointerEventHandler.cpp
dom/events/PointerEventHandler.h
dom/events/SimpleGestureEvent.cpp
dom/events/WheelEvent.cpp
dom/events/test/pointerevents/test_bug1285128.html
dom/events/test/pointerevents/test_bug1303704.html
dom/events/test/pointerevents/test_bug1315862.html
dom/events/test/pointerevents/test_bug1323158.html
dom/events/test/test_bug547996-1.html
dom/events/test/test_bug547996-2.xhtml
dom/html/HTMLLabelElement.cpp
dom/html/nsGenericHTMLElement.cpp
dom/interfaces/events/nsIDOMMouseEvent.idl
dom/ipc/TabChild.cpp
dom/tests/browser/browser_focus_steal_from_chrome_during_mousedown.js
dom/xul/nsXULElement.cpp
dom/xul/nsXULPopupListener.cpp
gfx/layers/apz/src/APZCTreeManager.cpp
gfx/layers/apz/util/APZCCallbackHelper.cpp
gfx/layers/apz/util/APZEventState.cpp
layout/base/AccessibleCaretEventHub.cpp
layout/base/AccessibleCaretManager.cpp
layout/base/AccessibleCaretManager.h
layout/base/PositionedEventTargeting.cpp
layout/base/tests/bug977003_inner_5.html
layout/base/tests/test_event_target_iframe_oop.html
layout/base/tests/test_event_target_radius.html
layout/forms/nsListControlFrame.cpp
layout/xul/nsButtonBoxFrame.cpp
layout/xul/nsResizerFrame.cpp
layout/xul/nsTitleBarFrame.cpp
testing/marionette/event.js
testing/mochitest/tests/SimpleTest/EventUtils.js
toolkit/content/tests/widgets/tree_shared.js
widget/InputData.cpp
widget/MouseEvents.h
widget/android/nsWindow.cpp
widget/cocoa/nsChildView.mm
widget/nsBaseDragService.cpp
widget/uikit/nsWindow.mm
widget/windows/WinPointerEvents.cpp
widget/windows/WinUtils.cpp
widget/windows/WinUtils.h
widget/windows/nsWindow.cpp
widget/windows/nsWindow.h
--- a/accessible/base/nsCoreUtils.cpp
+++ b/accessible/base/nsCoreUtils.cpp
@@ -32,16 +32,17 @@
 #include "nsGkAtoms.h"
 
 #include "nsComponentManagerUtils.h"
 
 #include "nsITreeBoxObject.h"
 #include "nsITreeColumns.h"
 #include "mozilla/dom/Element.h"
 #include "mozilla/dom/HTMLLabelElement.h"
+#include "mozilla/dom/MouseEventBinding.h"
 
 using namespace mozilla;
 
 ////////////////////////////////////////////////////////////////////////////////
 // nsCoreUtils
 ////////////////////////////////////////////////////////////////////////////////
 
 bool
@@ -138,17 +139,17 @@ nsCoreUtils::DispatchMouseEvent(EventMes
   WidgetMouseEvent event(true, aMessage, aRootWidget,
                          WidgetMouseEvent::eReal, WidgetMouseEvent::eNormal);
 
   event.mRefPoint = LayoutDeviceIntPoint(aX, aY);
 
   event.mClickCount = 1;
   event.button = WidgetMouseEvent::eLeftButton;
   event.mTime = PR_IntervalNow();
-  event.inputSource = nsIDOMMouseEvent::MOZ_SOURCE_UNKNOWN;
+  event.inputSource = dom::MouseEventBinding::MOZ_SOURCE_UNKNOWN;
 
   nsEventStatus status = nsEventStatus_eIgnore;
   aPresShell->HandleEventWithTarget(&event, aFrame, aContent, &status);
 }
 
 void
 nsCoreUtils::DispatchTouchEvent(EventMessage aMessage, int32_t aX, int32_t aY,
                                 nsIContent* aContent, nsIFrame* aFrame,
--- a/accessible/jsat/PointerAdapter.jsm
+++ b/accessible/jsat/PointerAdapter.jsm
@@ -84,17 +84,20 @@ var PointerRelay = { // jshint ignore:li
     }
   },
 
   handleEvent: function PointerRelay_handleEvent(aEvent) {
     // Don't bother with chrome mouse events.
     if (Utils.MozBuildApp === "browser" && aEvent.view.top.isChromeWindow) {
       return;
     }
-    if (aEvent.mozInputSource === Ci.nsIDOMMouseEvent.MOZ_SOURCE_UNKNOWN ||
+    // aEvent might not be a mouse event here at all; don't do the
+    // mozInputSource check unless it is.
+    if (("mozInputSource" in aEvent &&
+         aEvent.mozInputSource === aEvent.MOZ_SOURCE_UNKNOWN) ||
         aEvent.isSynthesized) {
       // Ignore events that are scripted or clicks from the a11y API.
       return;
     }
 
     let changedTouches = aEvent.changedTouches || [{
       identifier: MOUSE_ID,
       screenX: aEvent.screenX,
--- a/devtools/server/actors/emulation/touch-simulator.js
+++ b/devtools/server/actors/emulation/touch-simulator.js
@@ -111,17 +111,17 @@ TouchSimulator.prototype = {
                                 touches, targetTouches, changedTouches);
       sysFrame.dispatchEvent(touchEvent);
       return;
     }
 
     // Ignore all but real mouse event coming from physical mouse
     // (especially ignore mouse event being dispatched from a touch event)
     if (evt.button ||
-        evt.mozInputSource != Ci.nsIDOMMouseEvent.MOZ_SOURCE_MOUSE ||
+        evt.mozInputSource != evt.MOZ_SOURCE_MOUSE ||
         evt.isSynthesized) {
       return;
     }
 
     let eventTarget = this.target;
     let type = "";
     switch (evt.type) {
       case "mouseenter":
@@ -218,17 +218,17 @@ TouchSimulator.prototype = {
     }
   },
 
   fireMouseEvent(type, evt) {
     let content = this.getContent(evt.target);
     let utils = content.QueryInterface(Ci.nsIInterfaceRequestor)
                        .getInterface(Ci.nsIDOMWindowUtils);
     utils.sendMouseEvent(type, evt.clientX, evt.clientY, 0, 1, 0, true, 0,
-                         Ci.nsIDOMMouseEvent.MOZ_SOURCE_TOUCH);
+                         evt.MOZ_SOURCE_TOUCH);
   },
 
   sendContextMenu({ target, clientX, clientY, screenX, screenY }) {
     let view = target.ownerGlobal;
     let { MouseEvent } = view;
     let evt = new MouseEvent("contextmenu", {
       bubbles: true,
       cancelable: true,
--- a/dom/base/Element.cpp
+++ b/dom/base/Element.cpp
@@ -137,20 +137,21 @@
 
 #include "nsStyledElement.h"
 #include "nsXBLService.h"
 #include "nsITextControlElement.h"
 #include "nsITextControlFrame.h"
 #include "nsISupportsImpl.h"
 #include "mozilla/dom/CSSPseudoElement.h"
 #include "mozilla/dom/DocumentFragment.h"
+#include "mozilla/dom/ElementBinding.h"
 #include "mozilla/dom/KeyframeEffect.h"
 #include "mozilla/dom/KeyframeEffectBinding.h"
+#include "mozilla/dom/MouseEventBinding.h"
 #include "mozilla/dom/WindowBinding.h"
-#include "mozilla/dom/ElementBinding.h"
 #include "mozilla/dom/VRDisplay.h"
 #include "mozilla/IntegerPrintfMacros.h"
 #include "mozilla/Preferences.h"
 #include "nsComputedDOMStyle.h"
 #include "nsDOMStringMap.h"
 #include "DOMIntersectionObserver.h"
 
 #include "nsISpeculativeConnect.h"
@@ -2293,17 +2294,17 @@ Element::DispatchClickEvent(nsPresContex
   WidgetMouseEvent* sourceMouseEvent = aSourceEvent->AsMouseEvent();
   if (sourceMouseEvent) {
     clickCount = sourceMouseEvent->mClickCount;
     pressure = sourceMouseEvent->pressure;
     pointerId = sourceMouseEvent->pointerId;
     inputSource = sourceMouseEvent->inputSource;
   } else if (aSourceEvent->mClass == eKeyboardEventClass) {
     event.mFlags.mIsPositionless = true;
-    inputSource = nsIDOMMouseEvent::MOZ_SOURCE_KEYBOARD;
+    inputSource = MouseEventBinding::MOZ_SOURCE_KEYBOARD;
   }
   event.pressure = pressure;
   event.mClickCount = clickCount;
   event.pointerId = pointerId;
   event.inputSource = inputSource;
   event.mModifiers = aSourceEvent->mModifiers;
   if (aExtraEventFlags) {
     // Be careful not to overwrite existing flags!
--- a/dom/base/nsContentUtils.cpp
+++ b/dom/base/nsContentUtils.cpp
@@ -47,16 +47,17 @@
 #include "mozilla/dom/ElementInlines.h"
 #include "mozilla/dom/Event.h"
 #include "mozilla/dom/FileSystemSecurity.h"
 #include "mozilla/dom/FileBlobImpl.h"
 #include "mozilla/dom/HTMLInputElement.h"
 #include "mozilla/dom/HTMLSlotElement.h"
 #include "mozilla/dom/HTMLTemplateElement.h"
 #include "mozilla/dom/IDTracker.h"
+#include "mozilla/dom/MouseEventBinding.h"
 #include "mozilla/dom/KeyboardEventBinding.h"
 #include "mozilla/dom/IPCBlobUtils.h"
 #include "mozilla/dom/NodeBinding.h"
 #include "mozilla/dom/Promise.h"
 #include "mozilla/dom/ScriptSettings.h"
 #include "mozilla/dom/TabParent.h"
 #include "mozilla/dom/TouchEvent.h"
 #include "mozilla/dom/ShadowRoot.h"
@@ -8689,18 +8690,18 @@ nsContentUtils::SendMouseEvent(const nsC
     msg = eContextMenu;
     contextMenuKey = (aButton == 0);
   } else if (aType.EqualsLiteral("MozMouseHittest")) {
     msg = eMouseHitTest;
   } else {
     return NS_ERROR_FAILURE;
   }
 
-  if (aInputSourceArg == nsIDOMMouseEvent::MOZ_SOURCE_UNKNOWN) {
-    aInputSourceArg = nsIDOMMouseEvent::MOZ_SOURCE_MOUSE;
+  if (aInputSourceArg == MouseEventBinding::MOZ_SOURCE_UNKNOWN) {
+    aInputSourceArg = MouseEventBinding::MOZ_SOURCE_MOUSE;
   }
 
   WidgetMouseEvent event(true, msg, widget,
                          aIsWidgetEventSynthesized ?
                            WidgetMouseEvent::eSynthesized :
                            WidgetMouseEvent::eReal,
                          contextMenuKey ? WidgetMouseEvent::eContextMenuKey :
                                           WidgetMouseEvent::eNormal);
--- a/dom/base/nsContentUtils.h
+++ b/dom/base/nsContentUtils.h
@@ -39,17 +39,16 @@
 #include "mozilla/intl/WordBreaker.h"
 #include "mozilla/net/ReferrerPolicy.h"
 #include "mozilla/Logging.h"
 #include "mozilla/NotNull.h"
 #include "mozilla/Maybe.h"
 #include "mozilla/RangeBoundary.h"
 #include "nsIContentPolicy.h"
 #include "nsIDocument.h"
-#include "nsIDOMMouseEvent.h"
 #include "nsPIDOMWindow.h"
 #include "nsRFPService.h"
 
 #if defined(XP_WIN)
 // Undefine LoadImage to prevent naming conflict with Windows.
 #undef LoadImage
 #endif
 
@@ -2120,17 +2119,19 @@ public:
   static nsresult DispatchXULCommand(nsIContent* aTarget,
                                      bool aTrusted,
                                      nsIDOMEvent* aSourceEvent = nullptr,
                                      nsIPresShell* aShell = nullptr,
                                      bool aCtrl = false,
                                      bool aAlt = false,
                                      bool aShift = false,
                                      bool aMeta = false,
-                                     uint16_t inputSource = nsIDOMMouseEvent::MOZ_SOURCE_UNKNOWN);
+                                     // Including MouseEventBinding here leads
+                                     // to incude loops, unfortunately.
+                                     uint16_t inputSource = 0 /* MouseEventBinding::MOZ_SOURCE_UNKNOWN */);
 
   static bool CheckMayLoad(nsIPrincipal* aPrincipal, nsIChannel* aChannel, bool aAllowIfInheritsPrincipal);
 
   /**
    * The method checks whether the caller can access native anonymous content.
    * If there is no JS in the stack or privileged JS is running, this
    * method returns true, otherwise false.
    */
--- a/dom/base/test/test_domwindowutils.html
+++ b/dom/base/test/test_domwindowutils.html
@@ -23,31 +23,31 @@ function test_sendMouseEventDefaults() {
     ok((evt.clientX <= x+2) && (evt.clientX >= x-2), "check x");
     ok((evt.clientY <= y+2) && (evt.clientY >= y-2), "check y");
     is(evt.button, button, "check button");
     is(evt.detail, clickCount, "check click count");
     is(evt.getModifierState("Shift"), true, "check modifiers");
 
     // Default value for optionals
     is(evt.mozPressure, 0, "check pressure");
-    is(evt.mozInputSource, SpecialPowers.Ci.nsIDOMMouseEvent.MOZ_SOURCE_MOUSE, "check input source");
+    is(evt.mozInputSource, MouseEvent.MOZ_SOURCE_MOUSE, "check input source");
     is(evt.isSynthesized, undefined, "check isSynthesized is undefined in content");
     is(SpecialPowers.wrap(evt).isSynthesized, true, "check isSynthesized is true from chrome");
     SimpleTest.executeSoon(next);
   }, {once: true});
 
   // Only pass mandatory arguments and check default values
   utils.sendMouseEvent("mousedown", x, y, button, clickCount, modifiers);
 }
 
 function test_sendMouseEventOptionals() {
   var x = 1, y = 2, button = 1, clickCount = 3,
       modifiers = SpecialPowers.Ci.nsIDOMNSEvent.SHIFT_MASK,
       pressure = 0.5,
-      source = SpecialPowers.Ci.nsIDOMMouseEvent.MOZ_SOURCE_KEYBOARD;
+      source = MouseEvent.MOZ_SOURCE_KEYBOARD;
 
   window.addEventListener("mouseup", function(evt) {
     is(evt.mozInputSource, source, "explicit input source is valid");
     is(SpecialPowers.wrap(evt).isSynthesized, false, "we can dispatch event that don't look synthesized");
     SimpleTest.executeSoon(next);
   }, {once: true});
 
   // Check explicit value for optional args
--- a/dom/events/DragEvent.cpp
+++ b/dom/events/DragEvent.cpp
@@ -1,15 +1,16 @@
 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
 /* vim: set ts=8 sts=2 et sw=2 tw=80: */
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "mozilla/dom/DragEvent.h"
+#include "mozilla/dom/MouseEventBinding.h"
 #include "mozilla/MouseEvents.h"
 #include "nsContentUtils.h"
 #include "prtime.h"
 
 namespace mozilla {
 namespace dom {
 
 DragEvent::DragEvent(EventTarget* aOwner,
@@ -21,17 +22,17 @@ DragEvent::DragEvent(EventTarget* aOwner
 {
   if (aEvent) {
     mEventIsInternal = false;
   }
   else {
     mEventIsInternal = true;
     mEvent->mTime = PR_Now();
     mEvent->mRefPoint = LayoutDeviceIntPoint(0, 0);
-    mEvent->AsMouseEvent()->inputSource = nsIDOMMouseEvent::MOZ_SOURCE_UNKNOWN;
+    mEvent->AsMouseEvent()->inputSource = MouseEventBinding::MOZ_SOURCE_UNKNOWN;
   }
 }
 
 void
 DragEvent::InitDragEvent(const nsAString& aType,
                          bool aCanBubble,
                          bool aCancelable,
                          nsGlobalWindowInner* aView,
--- a/dom/events/EventStateManager.cpp
+++ b/dom/events/EventStateManager.cpp
@@ -13,16 +13,17 @@
 #include "mozilla/MathAlgorithms.h"
 #include "mozilla/MouseEvents.h"
 #include "mozilla/TextComposition.h"
 #include "mozilla/TextEvents.h"
 #include "mozilla/TouchEvents.h"
 #include "mozilla/dom/ContentChild.h"
 #include "mozilla/dom/DragEvent.h"
 #include "mozilla/dom/Event.h"
+#include "mozilla/dom/MouseEventBinding.h"
 #include "mozilla/dom/TabChild.h"
 #include "mozilla/dom/TabParent.h"
 #include "mozilla/dom/UIEvent.h"
 #include "mozilla/dom/WheelEventBinding.h"
 
 #include "ContentEventHandler.h"
 #include "IMEContentObserver.h"
 #include "WheelHandlingHelper.h"
@@ -1887,17 +1888,17 @@ EventStateManager::GenerateDragGesture(n
       // get the widget from the target frame
       WidgetDragEvent startEvent(aEvent->IsTrusted(), eDragStart, widget);
       FillInEventFromGestureDown(&startEvent);
 
       startEvent.mDataTransfer = dataTransfer;
       if (aEvent->AsMouseEvent()) {
         startEvent.inputSource = aEvent->AsMouseEvent()->inputSource;
       } else if (aEvent->AsTouchEvent()) {
-        startEvent.inputSource = nsIDOMMouseEvent::MOZ_SOURCE_TOUCH;
+        startEvent.inputSource = MouseEventBinding::MOZ_SOURCE_TOUCH;
       } else {
         MOZ_ASSERT(false);
       }
 
       // Dispatch to the DOM. By setting mCurrentTarget we are faking
       // out the ESM and telling it that the current target frame is
       // actually where the mouseDown occurred, otherwise it will use
       // the frame the mouse is currently over which may or may not be
@@ -3216,17 +3217,17 @@ EventStateManager::PostHandleEvent(nsPre
           // focus to be shifted from the caret position instead of the root.
           if (newFocus) {
             // use the mouse flag and the noscroll flag so that the content
             // doesn't unexpectedly scroll when clicking an element that is
             // only half visible
             uint32_t flags = nsIFocusManager::FLAG_BYMOUSE |
                              nsIFocusManager::FLAG_NOSCROLL;
             // If this was a touch-generated event, pass that information:
-            if (mouseEvent->inputSource == nsIDOMMouseEvent::MOZ_SOURCE_TOUCH) {
+            if (mouseEvent->inputSource == MouseEventBinding::MOZ_SOURCE_TOUCH) {
               flags |= nsIFocusManager::FLAG_BYTOUCH;
             }
             nsCOMPtr<nsIDOMElement> newFocusElement = do_QueryInterface(newFocus);
             fm->SetFocus(newFocusElement, flags);
           }
           else if (!suppressBlur) {
             // clear the focus within the frame and then set it as the
             // focused frame
@@ -3296,17 +3297,17 @@ EventStateManager::PostHandleEvent(nsPre
   case ePointerUp: {
     WidgetPointerEvent* pointerEvent = aEvent->AsPointerEvent();
     MOZ_ASSERT(pointerEvent);
     // Implicitly releasing capture for given pointer. ePointerLostCapture
     // should be send after ePointerUp or ePointerCancel.
     PointerEventHandler::ImplicitlyReleasePointerCapture(pointerEvent);
 
     if (pointerEvent->mMessage == ePointerCancel ||
-        pointerEvent->inputSource == nsIDOMMouseEvent::MOZ_SOURCE_TOUCH) {
+        pointerEvent->inputSource == MouseEventBinding::MOZ_SOURCE_TOUCH) {
       // After pointercancel, pointer becomes invalid so we can remove relevant
       // helper from table. Regarding pointerup with non-hoverable device, the
       // pointer also becomes invalid. Hoverable (mouse/pen) pointers are valid
       // all the time (not only between down/up).
       GenerateMouseEnterExit(pointerEvent);
       mPointersEnterLeaveHelper.Remove(pointerEvent->pointerId);
     }
     break;
--- a/dom/events/IMEStateManager.cpp
+++ b/dom/events/IMEStateManager.cpp
@@ -14,26 +14,26 @@
 #include "mozilla/EventStates.h"
 #include "mozilla/MouseEvents.h"
 #include "mozilla/Preferences.h"
 #include "mozilla/Services.h"
 #include "mozilla/TextComposition.h"
 #include "mozilla/TextEvents.h"
 #include "mozilla/Unused.h"
 #include "mozilla/dom/HTMLFormElement.h"
+#include "mozilla/dom/MouseEventBinding.h"
 #include "mozilla/dom/TabParent.h"
 
 #include "HTMLInputElement.h"
 #include "IMEContentObserver.h"
 
 #include "nsCOMPtr.h"
 #include "nsContentUtils.h"
 #include "nsIContent.h"
 #include "nsIDocument.h"
-#include "nsIDOMMouseEvent.h"
 #include "nsIForm.h"
 #include "nsIFormControl.h"
 #include "nsINode.h"
 #include "nsIObserverService.h"
 #include "nsIPresShell.h"
 #include "nsISelection.h"
 #include "nsISupports.h"
 #include "nsPresContext.h"
@@ -840,17 +840,17 @@ IMEStateManager::OnClickInEditor(nsPresC
   if (aMouseEvent->mClickCount != 1) {
     MOZ_LOG(sISMLog, LogLevel::Debug,
       ("  OnClickInEditor(), "
        "the mouse event isn't a single click event"));
     return; // should notify only first click event.
   }
 
   InputContextAction::Cause cause =
-    aMouseEvent->inputSource == nsIDOMMouseEvent::MOZ_SOURCE_TOUCH ?
+    aMouseEvent->inputSource == MouseEventBinding::MOZ_SOURCE_TOUCH ?
       InputContextAction::CAUSE_TOUCH : InputContextAction::CAUSE_MOUSE;
 
   InputContextAction action(cause, InputContextAction::FOCUS_NOT_CHANGED);
   IMEState newState = GetNewIMEState(aPresContext, aContent);
   SetIMEState(newState, aPresContext, aContent, widget, action, sOrigin);
 }
 
 // static
--- a/dom/events/MouseEvent.cpp
+++ b/dom/events/MouseEvent.cpp
@@ -28,17 +28,17 @@ MouseEvent::MouseEvent(EventTarget* aOwn
   WidgetMouseEvent* mouseEvent = mEvent->AsMouseEvent();
   if (aEvent) {
     mEventIsInternal = false;
   }
   else {
     mEventIsInternal = true;
     mEvent->mTime = PR_Now();
     mEvent->mRefPoint = LayoutDeviceIntPoint(0, 0);
-    mouseEvent->inputSource = nsIDOMMouseEvent::MOZ_SOURCE_UNKNOWN;
+    mouseEvent->inputSource = MouseEventBinding::MOZ_SOURCE_UNKNOWN;
   }
 
   if (mouseEvent) {
     MOZ_ASSERT(mouseEvent->mReason != WidgetMouseEvent::eSynthesized,
                "Don't dispatch DOM events from synthesized mouse events");
     mDetail = mouseEvent->mClickCount;
   }
 }
--- a/dom/events/MouseScrollEvent.cpp
+++ b/dom/events/MouseScrollEvent.cpp
@@ -1,15 +1,16 @@
 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
 /* vim: set ts=8 sts=2 et sw=2 tw=80: */
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "mozilla/dom/MouseScrollEvent.h"
+#include "mozilla/dom/MouseEventBinding.h"
 #include "mozilla/MouseEvents.h"
 #include "prtime.h"
 
 namespace mozilla {
 namespace dom {
 
 MouseScrollEvent::MouseScrollEvent(EventTarget* aOwner,
                                    nsPresContext* aPresContext,
@@ -20,17 +21,17 @@ MouseScrollEvent::MouseScrollEvent(Event
 {
   if (aEvent) {
     mEventIsInternal = false;
   } else {
     mEventIsInternal = true;
     mEvent->mTime = PR_Now();
     mEvent->mRefPoint = LayoutDeviceIntPoint(0, 0);
     static_cast<WidgetMouseEventBase*>(mEvent)->inputSource =
-      nsIDOMMouseEvent::MOZ_SOURCE_UNKNOWN;
+      MouseEventBinding::MOZ_SOURCE_UNKNOWN;
   }
 
   mDetail = mEvent->AsMouseScrollEvent()->mDelta;
 }
 
 void
 MouseScrollEvent::InitMouseScrollEvent(const nsAString& aType,
                                        bool aCanBubble,
--- a/dom/events/PointerEvent.cpp
+++ b/dom/events/PointerEvent.cpp
@@ -1,16 +1,17 @@
 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
 /* vim: set ts=8 sts=2 et sw=2 tw=80: */
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
  *
  * Portions Copyright 2013 Microsoft Open Technologies, Inc. */
 
+#include "mozilla/dom/MouseEventBinding.h"
 #include "mozilla/dom/PointerEvent.h"
 #include "mozilla/dom/PointerEventBinding.h"
 #include "mozilla/MouseEvents.h"
 #include "prtime.h"
 
 namespace mozilla {
 namespace dom {
 
@@ -26,17 +27,17 @@ PointerEvent::PointerEvent(EventTarget* 
 
   WidgetMouseEvent* mouseEvent = mEvent->AsMouseEvent();
   if (aEvent) {
     mEventIsInternal = false;
   } else {
     mEventIsInternal = true;
     mEvent->mTime = PR_Now();
     mEvent->mRefPoint = LayoutDeviceIntPoint(0, 0);
-    mouseEvent->inputSource = nsIDOMMouseEvent::MOZ_SOURCE_UNKNOWN;
+    mouseEvent->inputSource = MouseEventBinding::MOZ_SOURCE_UNKNOWN;
   }
   // 5.2 Pointer Event types, for all pointer events, |detail| attribute SHOULD
   // be 0.
   mDetail = 0;
 }
 
 JSObject*
 PointerEvent::WrapObjectInternal(JSContext* aCx,
@@ -44,39 +45,39 @@ PointerEvent::WrapObjectInternal(JSConte
 {
   return PointerEventBinding::Wrap(aCx, this, aGivenProto);
 }
 
 static uint16_t
 ConvertStringToPointerType(const nsAString& aPointerTypeArg)
 {
   if (aPointerTypeArg.EqualsLiteral("mouse")) {
-    return nsIDOMMouseEvent::MOZ_SOURCE_MOUSE;
+    return MouseEventBinding::MOZ_SOURCE_MOUSE;
   }
   if (aPointerTypeArg.EqualsLiteral("pen")) {
-    return nsIDOMMouseEvent::MOZ_SOURCE_PEN;
+    return MouseEventBinding::MOZ_SOURCE_PEN;
   }
   if (aPointerTypeArg.EqualsLiteral("touch")) {
-    return nsIDOMMouseEvent::MOZ_SOURCE_TOUCH;
+    return MouseEventBinding::MOZ_SOURCE_TOUCH;
   }
 
-  return nsIDOMMouseEvent::MOZ_SOURCE_UNKNOWN;
+  return MouseEventBinding::MOZ_SOURCE_UNKNOWN;
 }
 
 void
 ConvertPointerTypeToString(uint16_t aPointerTypeSrc, nsAString& aPointerTypeDest)
 {
   switch (aPointerTypeSrc) {
-    case nsIDOMMouseEvent::MOZ_SOURCE_MOUSE:
+    case MouseEventBinding::MOZ_SOURCE_MOUSE:
       aPointerTypeDest.AssignLiteral("mouse");
       break;
-    case nsIDOMMouseEvent::MOZ_SOURCE_PEN:
+    case MouseEventBinding::MOZ_SOURCE_PEN:
       aPointerTypeDest.AssignLiteral("pen");
       break;
-    case nsIDOMMouseEvent::MOZ_SOURCE_TOUCH:
+    case MouseEventBinding::MOZ_SOURCE_TOUCH:
       aPointerTypeDest.AssignLiteral("touch");
       break;
     default:
       aPointerTypeDest.Truncate();
       break;
   }
 }
 
--- a/dom/events/PointerEventHandler.cpp
+++ b/dom/events/PointerEventHandler.cpp
@@ -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/. */
 
 #include "PointerEventHandler.h"
 #include "nsIFrame.h"
 #include "PointerEvent.h"
 #include "mozilla/PresShell.h"
+#include "mozilla/dom/MouseEventBinding.h"
 
 namespace mozilla {
 
 using namespace dom;
 
 static bool sPointerEventEnabled = true;
 static bool sPointerEventImplicitCapture = false;
 
@@ -110,17 +111,17 @@ PointerEventHandler::UpdateActivePointer
     break;
   case ePointerCancel:
     // pointercancel means a pointer is unlikely to continue to produce pointer
     // events. In that case, we should turn off active state or remove the
     // pointer from active pointers.
   case ePointerUp:
     // In this case we remove information about pointer or turn off active state
     if (WidgetPointerEvent* pointerEvent = aEvent->AsPointerEvent()) {
-      if(pointerEvent->inputSource != nsIDOMMouseEvent::MOZ_SOURCE_TOUCH) {
+      if(pointerEvent->inputSource != MouseEventBinding::MOZ_SOURCE_TOUCH) {
         sActivePointersIds->Put(pointerEvent->pointerId,
                                 new PointerInfo(false,
                                                 pointerEvent->inputSource,
                                                 pointerEvent->mIsPrimary));
       } else {
         sActivePointersIds->Remove(pointerEvent->pointerId);
       }
     }
@@ -135,17 +136,17 @@ PointerEventHandler::UpdateActivePointer
   }
 }
 
 /* static */ void
 PointerEventHandler::SetPointerCaptureById(uint32_t aPointerId,
                                            nsIContent* aContent)
 {
   MOZ_ASSERT(aContent);
-  if (nsIDOMMouseEvent::MOZ_SOURCE_MOUSE == GetPointerType(aPointerId)) {
+  if (MouseEventBinding::MOZ_SOURCE_MOUSE == GetPointerType(aPointerId)) {
     nsIPresShell::SetCapturingContent(aContent, CAPTURE_PREVENTDRAG);
   }
 
   PointerCaptureInfo* pointerCaptureInfo = GetPointerCaptureInfo(aPointerId);
   if (pointerCaptureInfo) {
     pointerCaptureInfo->mPendingContent = aContent;
   } else {
     sPointerCaptureList->Put(aPointerId, new PointerCaptureInfo(aContent));
@@ -160,17 +161,17 @@ PointerEventHandler::GetPointerCaptureIn
   return pointerCaptureInfo;
 }
 
 /* static */ void
 PointerEventHandler::ReleasePointerCaptureById(uint32_t aPointerId)
 {
   PointerCaptureInfo* pointerCaptureInfo = GetPointerCaptureInfo(aPointerId);
   if (pointerCaptureInfo && pointerCaptureInfo->mPendingContent) {
-    if (nsIDOMMouseEvent::MOZ_SOURCE_MOUSE == GetPointerType(aPointerId)) {
+    if (MouseEventBinding::MOZ_SOURCE_MOUSE == GetPointerType(aPointerId)) {
       nsIPresShell::SetCapturingContent(nullptr, CAPTURE_PREVENTDRAG);
     }
     pointerCaptureInfo->mPendingContent = nullptr;
   }
 }
 
 /* static */ void
 PointerEventHandler::ReleaseAllPointerCapture()
@@ -289,17 +290,17 @@ PointerEventHandler::ImplicitlyCapturePo
   MOZ_ASSERT(aEvent->mMessage == ePointerDown);
   if (!aFrame || !IsPointerEventEnabled() ||
       !IsPointerEventImplicitCaptureForTouchEnabled()) {
     return;
   }
   WidgetPointerEvent* pointerEvent = aEvent->AsPointerEvent();
   NS_WARNING_ASSERTION(pointerEvent,
                        "Call ImplicitlyCapturePointer with non-pointer event");
-  if (pointerEvent->inputSource != nsIDOMMouseEvent::MOZ_SOURCE_TOUCH) {
+  if (pointerEvent->inputSource != MouseEventBinding::MOZ_SOURCE_TOUCH) {
     // We only implicitly capture the pointer for touch device.
     return;
   }
   nsCOMPtr<nsIContent> target;
   aFrame->GetContentForEvent(aEvent, getter_AddRefs(target));
   while (target && !target->IsElement()) {
     target = target->GetParent();
   }
@@ -466,17 +467,17 @@ PointerEventHandler::InitPointerEventFro
   aPointerEvent->mHeight = aTouch->RadiusY(CallerType::System);
   aPointerEvent->tiltX = aTouch->tiltX;
   aPointerEvent->tiltY = aTouch->tiltY;
   aPointerEvent->mTime = aTouchEvent->mTime;
   aPointerEvent->mTimeStamp = aTouchEvent->mTimeStamp;
   aPointerEvent->mFlags = aTouchEvent->mFlags;
   aPointerEvent->button = button;
   aPointerEvent->buttons = buttons;
-  aPointerEvent->inputSource = nsIDOMMouseEvent::MOZ_SOURCE_TOUCH;
+  aPointerEvent->inputSource = MouseEventBinding::MOZ_SOURCE_TOUCH;
 }
 
 /* static */ void
 PointerEventHandler::DispatchPointerFromMouseOrTouch(
                        PresShell* aShell,
                        nsIFrame* aFrame,
                        nsIContent* aContent,
                        WidgetGUIEvent* aEvent,
@@ -599,17 +600,17 @@ PointerEventHandler::DispatchPointerFrom
 
 /* static */ uint16_t
 PointerEventHandler::GetPointerType(uint32_t aPointerId)
 {
   PointerInfo* pointerInfo = nullptr;
   if (sActivePointersIds->Get(aPointerId, &pointerInfo) && pointerInfo) {
     return pointerInfo->mPointerType;
   }
-  return nsIDOMMouseEvent::MOZ_SOURCE_UNKNOWN;
+  return MouseEventBinding::MOZ_SOURCE_UNKNOWN;
 }
 
 /* static */ bool
 PointerEventHandler::GetPointerPrimaryState(uint32_t aPointerId)
 {
   PointerInfo* pointerInfo = nullptr;
   if (sActivePointersIds->Get(aPointerId, &pointerInfo) && pointerInfo) {
     return pointerInfo->mPrimaryState;
--- a/dom/events/PointerEventHandler.h
+++ b/dom/events/PointerEventHandler.h
@@ -167,17 +167,17 @@ public:
     return aEvent->mMessage == eTouchStart || aEvent->mMessage == eTouchMove ||
            aEvent->mMessage == eTouchEnd || aEvent->mMessage == eTouchCancel ||
            aEvent->mMessage == eTouchPointerCancel;
   }
 
 private:
   // GetPointerType returns pointer type like mouse, pen or touch for pointer
   // event with pointerId. The return value must be one of
-  // nsIDOMMouseEvent::MOZ_SOURCE_*
+  // MouseEventBinding::MOZ_SOURCE_*
   static uint16_t GetPointerType(uint32_t aPointerId);
 
   // GetPointerPrimaryState returns state of attribute isPrimary for pointer
   // event with pointerId
   static bool GetPointerPrimaryState(uint32_t aPointerId);
 
   static void DispatchGotOrLostPointerCaptureEvent(
                 bool aIsGotCapture,
--- a/dom/events/SimpleGestureEvent.cpp
+++ b/dom/events/SimpleGestureEvent.cpp
@@ -1,14 +1,15 @@
 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
 /* vim: set ts=8 sts=2 et sw=2 tw=80: */
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
+#include "mozilla/dom/MouseEventBinding.h"
 #include "mozilla/dom/SimpleGestureEvent.h"
 #include "mozilla/TouchEvents.h"
 #include "prtime.h"
 
 namespace mozilla {
 namespace dom {
 
 SimpleGestureEvent::SimpleGestureEvent(EventTarget* aOwner,
@@ -24,17 +25,17 @@ SimpleGestureEvent::SimpleGestureEvent(E
 
   if (aEvent) {
     mEventIsInternal = false;
   } else {
     mEventIsInternal = true;
     mEvent->mTime = PR_Now();
     mEvent->mRefPoint = LayoutDeviceIntPoint(0, 0);
     static_cast<WidgetMouseEventBase*>(mEvent)->inputSource =
-      nsIDOMMouseEvent::MOZ_SOURCE_UNKNOWN;
+      MouseEventBinding::MOZ_SOURCE_UNKNOWN;
   }
 }
 
 uint32_t
 SimpleGestureEvent::AllowedDirections() const
 {
   return mEvent->AsSimpleGestureEvent()->mAllowedDirections;
 }
--- a/dom/events/WheelEvent.cpp
+++ b/dom/events/WheelEvent.cpp
@@ -1,14 +1,15 @@
 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
 /* vim: set ts=8 sts=2 et sw=2 tw=80: */
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this file,
  * You can obtain one at http://mozilla.org/MPL/2.0/. */
 
+#include "mozilla/dom/MouseEventBinding.h"
 #include "mozilla/dom/WheelEvent.h"
 #include "mozilla/MouseEvents.h"
 #include "prtime.h"
 
 namespace mozilla {
 namespace dom {
 
 WheelEvent::WheelEvent(EventTarget* aOwner,
@@ -27,17 +28,17 @@ WheelEvent::WheelEvent(EventTarget* aOwn
     // it might be changed by changing zoom or something.
     if (aWheelEvent->mDeltaMode == WheelEventBinding::DOM_DELTA_PIXEL) {
       mAppUnitsPerDevPixel = aPresContext->AppUnitsPerDevPixel();
     }
   } else {
     mEventIsInternal = true;
     mEvent->mTime = PR_Now();
     mEvent->mRefPoint = LayoutDeviceIntPoint(0, 0);
-    mEvent->AsWheelEvent()->inputSource = nsIDOMMouseEvent::MOZ_SOURCE_UNKNOWN;
+    mEvent->AsWheelEvent()->inputSource = MouseEventBinding::MOZ_SOURCE_UNKNOWN;
   }
 }
 
 void
 WheelEvent::InitWheelEvent(const nsAString& aType,
                            bool aCanBubble,
                            bool aCancelable,
                            nsGlobalWindowInner* aView,
--- a/dom/events/test/pointerevents/test_bug1285128.html
+++ b/dom/events/test/pointerevents/test_bug1285128.html
@@ -33,17 +33,17 @@ function runTests() {
   });
 
   target1.addEventListener("mouseup", () => {
     ok(!receivedPointerEvents, "synthesized mousemove should not trigger any pointer events");
     SimpleTest.finish();
   });
 
   synthesizeMouseAtCenter(target0, { type: "mousemove",
-                                     inputSource: SpecialPowers.Ci.nsIDOMMouseEvent.MOZ_SOURCE_MOUSE,
+                                     inputSource: MouseEvent.MOZ_SOURCE_MOUSE,
                                      isWidgetEventSynthesized: true });
   synthesizeMouseAtCenter(target1, { type: "mousedown" });
   synthesizeMouseAtCenter(target1, { type: "mouseup" });
 }
 
 SimpleTest.waitForFocus(() => {
   SpecialPowers.pushPrefEnv({"set": [["dom.w3c_pointer_events.enabled", true]]}, runTests);
 });
--- a/dom/events/test/pointerevents/test_bug1303704.html
+++ b/dom/events/test/pointerevents/test_bug1303704.html
@@ -35,21 +35,21 @@ function runTests() {
   });
 
   link1.addEventListener("click", (e) => {
     e.preventDefault();
     SimpleTest.finish();
   });
 
   synthesizeMouseAtCenter(link1, { type: "mousedown",
-                                   inputSource: SpecialPowers.Ci.nsIDOMMouseEvent.MOZ_SOURCE_MOUSE });
+                                   inputSource: MouseEvent.MOZ_SOURCE_MOUSE });
   synthesizeMouseAtCenter(link1, { type: "mousemove",
-                                   inputSource: SpecialPowers.Ci.nsIDOMMouseEvent.MOZ_SOURCE_MOUSE });
+                                   inputSource: MouseEvent.MOZ_SOURCE_MOUSE });
   synthesizeMouseAtCenter(link1, { type: "mouseup",
-                                   inputSource: SpecialPowers.Ci.nsIDOMMouseEvent.MOZ_SOURCE_MOUSE });
+                                   inputSource: MouseEvent.MOZ_SOURCE_MOUSE });
 }
 
 SimpleTest.waitForFocus(() => {
   SpecialPowers.pushPrefEnv({"set": [["dom.w3c_pointer_events.enabled", true]]}, runTests);
 });
 
 </script>
 </body>
--- a/dom/events/test/pointerevents/test_bug1315862.html
+++ b/dom/events/test/pointerevents/test_bug1315862.html
@@ -43,17 +43,17 @@ function runTests() {
   });
   target.addEventListener("pointerdown", (e) => {
     target.setPointerCapture(e.pointerId);
   });
   target.addEventListener("pointerup", () => {
     is(receivePointerEvents, false, "Shouldn't dispatch pointer events in the system group");
     SimpleTest.finish();
   });
-  let source = SpecialPowers.Ci.nsIDOMMouseEvent.MOZ_SOURCE_MOUSE;
+  let source = MouseEvent.MOZ_SOURCE_MOUSE;
   synthesizeMouse(target, 5, 5, { type: "mousemove", inputSource: source },
                   iframe.contentWindow);
   synthesizeMouse(target, 5, 5, { type: "mousedown", inputSource: source },
                   iframe.contentWindow);
   synthesizeMouse(target, 5, 5, { type: "mousemove", inputSource: source },
                   iframe.contentWindow);
   synthesizeMouse(target, 5, 5, { type: "mouseup", inputSource: source },
                   iframe.contentWindow);
--- a/dom/events/test/pointerevents/test_bug1323158.html
+++ b/dom/events/test/pointerevents/test_bug1323158.html
@@ -62,17 +62,17 @@ function runTests() {
     }, {once: true});
   });
   target0.addEventListener("pointerdown", (e) => {
     target1.setPointerCapture(e.pointerId);
   });
   done.addEventListener("mouseup", () => {
     SimpleTest.finish();
   });
-  let source = SpecialPowers.Ci.nsIDOMMouseEvent.MOZ_SOURCE_MOUSE;
+  let source = MouseEvent.MOZ_SOURCE_MOUSE;
   synthesizeMouse(target0, 5, 5, { type: "mousemove", inputSource: source },
                   iframe.contentWindow);
   synthesizeMouse(target0, 5, 5, { type: "mousedown", inputSource: source },
                   iframe.contentWindow);
   synthesizeMouse(target0, 5, 5, { type: "mousemove", inputSource: source },
                   iframe.contentWindow);
   synthesizeMouse(target0, 5, 5, { type: "mouseup", inputSource: source },
                   iframe.contentWindow);
--- a/dom/events/test/test_bug547996-1.html
+++ b/dom/events/test/test_bug547996-1.html
@@ -21,18 +21,18 @@ https://bugzilla.mozilla.org/show_bug.cg
 /* mouseEvent.mozInputSource attribute */
 
 function prepareListener(eventName, expectedValue) {
   return function(event) {
     is(event.mozInputSource, expectedValue, "Correct .mozInputSource value in " + eventName);
   };
 }
 
-const INPUT_SOURCE_UNKNOWN = SpecialPowers.Ci.nsIDOMMouseEvent.MOZ_SOURCE_UNKNOWN;
-const INPUT_SOURCE_KEYBOARD = SpecialPowers.Ci.nsIDOMMouseEvent.MOZ_SOURCE_KEYBOARD;
+const INPUT_SOURCE_UNKNOWN = MouseEvent.MOZ_SOURCE_UNKNOWN;
+const INPUT_SOURCE_KEYBOARD = MouseEvent.MOZ_SOURCE_KEYBOARD;
 
 function doTest() {
   var eventNames = [
     "mousedown",
     "mouseup",
     "click",
     "dblclick",
     "contextmenu",
--- a/dom/events/test/test_bug547996-2.xhtml
+++ b/dom/events/test/test_bug547996-2.xhtml
@@ -24,23 +24,23 @@ var expectedInputSource = null;
 
 function check(event) {
   is(event.mozInputSource, expectedInputSource, ".mozInputSource");
 }
 
 function doTest() {
   setup();
 
-  expectedInputSource = SpecialPowers.Ci.nsIDOMMouseEvent.MOZ_SOURCE_KEYBOARD;
+  expectedInputSource = MouseEvent.MOZ_SOURCE_KEYBOARD;
   testKeyboard();
 
-  expectedInputSource = SpecialPowers.Ci.nsIDOMMouseEvent.MOZ_SOURCE_MOUSE;
+  expectedInputSource = MouseEvent.MOZ_SOURCE_MOUSE;
   testMouse();
 
-  expectedInputSource = SpecialPowers.Ci.nsIDOMMouseEvent.MOZ_SOURCE_UNKNOWN;
+  expectedInputSource = MouseEvent.MOZ_SOURCE_UNKNOWN;
   testScriptedClicks();
 
   cleanup();
   SimpleTest.finish();
 }
 
 function testKeyboard() {
 
--- a/dom/html/HTMLLabelElement.cpp
+++ b/dom/html/HTMLLabelElement.cpp
@@ -6,19 +6,19 @@
 
 /**
  * Implementation of HTML <label> elements.
  */
 #include "HTMLLabelElement.h"
 #include "mozilla/EventDispatcher.h"
 #include "mozilla/MouseEvents.h"
 #include "mozilla/dom/HTMLLabelElementBinding.h"
+#include "mozilla/dom/MouseEventBinding.h"
 #include "nsFocusManager.h"
 #include "nsContentUtils.h"
-#include "nsIDOMMouseEvent.h"
 #include "nsQueryObject.h"
 #include "mozilla/dom/ShadowRoot.h"
 
 // construction, destruction
 
 NS_IMPL_NS_NEW_HTML_ELEMENT(Label)
 
 namespace mozilla {
@@ -152,18 +152,18 @@ HTMLLabelElement::PostHandleEvent(EventC
               // be selected only when focused via a key or when the navigation
               // flag is used and we want to select the text on label clicks as
               // well.
               // If the label has been clicked by the user, we also want to
               // pass FLAG_BYMOUSE so that we get correct focus ring behavior,
               // but we don't want to pass FLAG_BYMOUSE if this click event was
               // caused by the user pressing an accesskey.
               nsCOMPtr<nsIDOMElement> elem = do_QueryInterface(content);
-              bool byMouse = (mouseEvent->inputSource != nsIDOMMouseEvent::MOZ_SOURCE_KEYBOARD);
-              bool byTouch = (mouseEvent->inputSource == nsIDOMMouseEvent::MOZ_SOURCE_TOUCH);
+              bool byMouse = (mouseEvent->inputSource != MouseEventBinding::MOZ_SOURCE_KEYBOARD);
+              bool byTouch = (mouseEvent->inputSource == MouseEventBinding::MOZ_SOURCE_TOUCH);
               fm->SetFocus(elem, nsIFocusManager::FLAG_BYMOVEFOCUS |
                                  (byMouse ? nsIFocusManager::FLAG_BYMOUSE : 0) |
                                  (byTouch ? nsIFocusManager::FLAG_BYTOUCH : 0));
             }
           }
           // Dispatch a new click event to |content|
           //    (For compatibility with IE, we do only left click.  If
           //    we wanted to interpret the HTML spec very narrowly, we
@@ -204,17 +204,17 @@ HTMLLabelElement::PerformAccesskey(bool 
     nsPresContext *presContext = GetPresContext(eForUncomposedDoc);
     if (!presContext) {
       return false;
     }
 
     // Click on it if the users prefs indicate to do so.
     WidgetMouseEvent event(aIsTrustedEvent, eMouseClick,
                            nullptr, WidgetMouseEvent::eReal);
-    event.inputSource = nsIDOMMouseEvent::MOZ_SOURCE_KEYBOARD;
+    event.inputSource = MouseEventBinding::MOZ_SOURCE_KEYBOARD;
 
     nsAutoPopupStatePusher popupStatePusher(aIsTrustedEvent ?
                                             openAllowed : openAbused);
 
     EventDispatcher::Dispatch(static_cast<nsIContent*>(this), presContext,
                               &event);
   }
 
--- a/dom/html/nsGenericHTMLElement.cpp
+++ b/dom/html/nsGenericHTMLElement.cpp
@@ -89,16 +89,17 @@
 #include "mozilla/BloomFilter.h"
 #include "mozilla/dom/ScriptLoader.h"
 
 #include "nsVariant.h"
 #include "nsDOMTokenList.h"
 #include "nsThreadUtils.h"
 #include "nsTextFragment.h"
 #include "mozilla/dom/BindingUtils.h"
+#include "mozilla/dom/MouseEventBinding.h"
 #include "mozilla/dom/TouchEvent.h"
 #include "mozilla/ErrorResult.h"
 #include "nsHTMLDocument.h"
 #include "nsGlobalWindow.h"
 #include "mozilla/dom/HTMLBodyElement.h"
 #include "imgIContainer.h"
 #include "nsComputedDOMStyle.h"
 #include "mozilla/StyleSetHandle.h"
@@ -2492,17 +2493,17 @@ nsGenericHTMLElement::Click(CallerType a
   }
 
   SetHandlingClick();
 
   // Mark this event trusted if Click() is called from system code.
   WidgetMouseEvent event(aCallerType == CallerType::System,
                          eMouseClick, nullptr, WidgetMouseEvent::eReal);
   event.mFlags.mIsPositionless = true;
-  event.inputSource = nsIDOMMouseEvent::MOZ_SOURCE_UNKNOWN;
+  event.inputSource = MouseEventBinding::MOZ_SOURCE_UNKNOWN;
 
   EventDispatcher::Dispatch(static_cast<nsIContent*>(this), context, &event);
 
   ClearHandlingClick();
 }
 
 bool
 nsGenericHTMLElement::IsHTMLFocusable(bool aWithMouse,
@@ -2615,17 +2616,17 @@ nsGenericHTMLElement::PerformAccesskey(b
 
 nsresult
 nsGenericHTMLElement::DispatchSimulatedClick(nsGenericHTMLElement* aElement,
                                              bool aIsTrusted,
                                              nsPresContext* aPresContext)
 {
   WidgetMouseEvent event(aIsTrusted, eMouseClick, nullptr,
                          WidgetMouseEvent::eReal);
-  event.inputSource = nsIDOMMouseEvent::MOZ_SOURCE_KEYBOARD;
+  event.inputSource = MouseEventBinding::MOZ_SOURCE_KEYBOARD;
   event.mFlags.mIsPositionless = true;
   return EventDispatcher::Dispatch(ToSupports(aElement), aPresContext, &event);
 }
 
 already_AddRefed<TextEditor>
 nsGenericHTMLElement::GetAssociatedEditor()
 {
   // If contenteditable is ever implemented, it might need to do something different here?
--- a/dom/interfaces/events/nsIDOMMouseEvent.idl
+++ b/dom/interfaces/events/nsIDOMMouseEvent.idl
@@ -11,16 +11,9 @@
  *
  * For more information on this interface please see
  * http://www.w3.org/TR/DOM-Level-2-Events/
  */
 
 [builtinclass, uuid(5bdab8d8-7933-4c5c-b6d1-ab34481237f7)]
 interface nsIDOMMouseEvent : nsIDOMUIEvent
 {
-  const unsigned short    MOZ_SOURCE_UNKNOWN    = 0;
-  const unsigned short    MOZ_SOURCE_MOUSE      = 1;
-  const unsigned short    MOZ_SOURCE_PEN        = 2;
-  const unsigned short    MOZ_SOURCE_ERASER     = 3;
-  const unsigned short    MOZ_SOURCE_CURSOR     = 4;
-  const unsigned short    MOZ_SOURCE_TOUCH      = 5;
-  const unsigned short    MOZ_SOURCE_KEYBOARD   = 6;
 };
--- a/dom/ipc/TabChild.cpp
+++ b/dom/ipc/TabChild.cpp
@@ -16,16 +16,17 @@
 #include "ContentChild.h"
 #include "TabParent.h"
 #include "mozilla/Preferences.h"
 #include "mozilla/BrowserElementParent.h"
 #include "mozilla/ClearOnShutdown.h"
 #include "mozilla/EventListenerManager.h"
 #include "mozilla/dom/DataTransfer.h"
 #include "mozilla/dom/indexedDB/PIndexedDBPermissionRequestChild.h"
+#include "mozilla/dom/MouseEventBinding.h"
 #include "mozilla/dom/PaymentRequestChild.h"
 #include "mozilla/dom/TelemetryScrollProbe.h"
 #include "mozilla/IMEStateManager.h"
 #include "mozilla/ipc/URIUtils.h"
 #include "mozilla/layers/APZChild.h"
 #include "mozilla/layers/APZCCallbackHelper.h"
 #include "mozilla/layers/APZCTreeManagerChild.h"
 #include "mozilla/layers/APZEventState.h"
@@ -1536,17 +1537,17 @@ TabChild::RecvMouseEvent(const nsString&
                          const int32_t&  aButton,
                          const int32_t&  aClickCount,
                          const int32_t&  aModifiers,
                          const bool&     aIgnoreRootScrollFrame)
 {
   APZCCallbackHelper::DispatchMouseEvent(GetPresShell(), aType,
                                          CSSPoint(aX, aY), aButton, aClickCount,
                                          aModifiers, aIgnoreRootScrollFrame,
-                                         nsIDOMMouseEvent::MOZ_SOURCE_UNKNOWN,
+                                         MouseEventBinding::MOZ_SOURCE_UNKNOWN,
                                          0 /* Use the default value here. */);
   return IPC_OK();
 }
 
 void
 TabChild::ProcessPendingCoalescedMouseDataAndDispatchEvents()
 {
   if (!mCoalesceMouseMoveEvents || !mCoalescedMouseEventFlusher) {
--- a/dom/tests/browser/browser_focus_steal_from_chrome_during_mousedown.js
+++ b/dom/tests/browser/browser_focus_steal_from_chrome_during_mousedown.js
@@ -20,17 +20,17 @@ add_task(async function test() {
     // Set focus to a chrome element before synthesizing a mouse down event.
     document.getElementById("urlbar").focus();
 
     is(fm.focusedElement, document.getElementById("urlbar").inputField,
        "Failed to move focus to search bar: button=" + button);
 
     // Synthesize mouse down event on browser object over the button, such that
     // the event propagates through both processes.
-    EventUtils.synthesizeMouse(tab.linkedBrowser, 20, 20, { "button": button }, null);
+    EventUtils.synthesizeMouse(tab.linkedBrowser, 20, 20, { "button": button });
 
     isnot(fm.focusedElement, document.getElementById("urlbar").inputField,
        "Failed to move focus away from search bar: button=" + button);
 
     await ContentTask.spawn(tab.linkedBrowser, button, async function (button) {
       let fm = Cc["@mozilla.org/focus-manager;1"].
           getService(Ci.nsIFocusManager);
 
--- a/dom/xul/nsXULElement.cpp
+++ b/dom/xul/nsXULElement.cpp
@@ -86,16 +86,17 @@
 #include "mozAutoDocUpdate.h"
 #include "nsCCUncollectableMarker.h"
 #include "nsICSSDeclaration.h"
 #include "nsLayoutUtils.h"
 
 #include "mozilla/dom/XULElementBinding.h"
 #include "mozilla/dom/BoxObject.h"
 #include "mozilla/dom/HTMLIFrameElement.h"
+#include "mozilla/dom/MouseEventBinding.h"
 #include "mozilla/dom/MutationEventBinding.h"
 #include "mozilla/dom/XULCommandEvent.h"
 
 using namespace mozilla;
 using namespace mozilla::dom;
 
 #ifdef XUL_PROTOTYPE_ATTRIBUTE_METERING
 uint32_t             nsXULPrototypeAttribute::gNumElements;
@@ -610,17 +611,17 @@ nsXULElement::PerformAccesskey(bool aKey
               // Return true if the element became focused.
               nsPIDOMWindowOuter* window = OwnerDoc()->GetWindow();
               focused = (window && window->GetFocusedNode());
             }
           }
         }
         if (aKeyCausesActivation &&
             !content->IsAnyOfXULElements(nsGkAtoms::textbox, nsGkAtoms::menulist)) {
-          elm->ClickWithInputSource(nsIDOMMouseEvent::MOZ_SOURCE_KEYBOARD, aIsTrustedEvent);
+          elm->ClickWithInputSource(MouseEventBinding::MOZ_SOURCE_KEYBOARD, aIsTrustedEvent);
         }
     } else {
         return content->PerformAccesskey(aKeyCausesActivation, aIsTrustedEvent);
     }
 
     return focused;
 }
 
@@ -1354,17 +1355,17 @@ nsXULElement::DispatchXULCommand(const E
     NS_ENSURE_STATE(doc);
     RefPtr<Element> commandElt = doc->GetElementById(aCommand);
     if (commandElt) {
         // Create a new command event to dispatch to the element
         // pointed to by the command attribute. The new event's
         // sourceEvent will be the original command event that we're
         // handling.
         nsCOMPtr<nsIDOMEvent> domEvent = aVisitor.mDOMEvent;
-        uint16_t inputSource = nsIDOMMouseEvent::MOZ_SOURCE_UNKNOWN;
+        uint16_t inputSource = MouseEventBinding::MOZ_SOURCE_UNKNOWN;
         while (domEvent) {
             Event* event = domEvent->InternalDOMEvent();
             NS_ENSURE_STATE(!SameCOMIdentity(event->GetOriginalTarget(),
                                              commandElt));
             RefPtr<XULCommandEvent> commandEvent = event->AsXULCommandEvent();
             if (commandEvent) {
                 domEvent = commandEvent->GetSourceEvent();
                 inputSource = commandEvent->InputSource();
@@ -1657,17 +1658,17 @@ nsXULElement::GetParentTree(nsIDOMXULMul
     }
 
     return NS_OK;
 }
 
 void
 nsXULElement::Click(CallerType aCallerType)
 {
-  ClickWithInputSource(nsIDOMMouseEvent::MOZ_SOURCE_UNKNOWN,
+  ClickWithInputSource(MouseEventBinding::MOZ_SOURCE_UNKNOWN,
                        aCallerType == CallerType::System);
 }
 
 void
 nsXULElement::ClickWithInputSource(uint16_t aInputSource, bool aIsTrustedEvent)
 {
     if (BoolAttrIsTrue(nsGkAtoms::disabled))
         return;
--- a/dom/xul/nsXULPopupListener.cpp
+++ b/dom/xul/nsXULPopupListener.cpp
@@ -25,16 +25,17 @@
 #include "nsIObjectLoadingContent.h"
 #include "mozilla/EventStateManager.h"
 #include "mozilla/EventStates.h"
 #include "mozilla/Preferences.h"
 #include "mozilla/dom/Event.h" // for nsIDOMEvent::InternalDOMEvent()
 #include "mozilla/dom/EventTarget.h"
 #include "mozilla/dom/FragmentOrElement.h"
 #include "mozilla/dom/MouseEvent.h"
+#include "mozilla/dom/MouseEventBinding.h"
 
 // for event firing in context menus
 #include "nsPresContext.h"
 #include "nsIPresShell.h"
 #include "nsFocusManager.h"
 #include "nsPIDOMWindow.h"
 #include "nsViewManager.h"
 #include "nsError.h"
@@ -187,17 +188,17 @@ nsXULPopupListener::HandleEvent(nsIDOMEv
     if (targetContent &&
         targetContent->IsAnyOfXULElements(nsGkAtoms::menu, nsGkAtoms::menuitem))
       return NS_OK;
   }
 
   if (mIsContext) {
 #ifndef NS_CONTEXT_MENU_IS_MOUSEUP
     uint16_t inputSource = mouseEvent->MozInputSource();
-    bool isTouch = inputSource == nsIDOMMouseEvent::MOZ_SOURCE_TOUCH;
+    bool isTouch = inputSource == MouseEventBinding::MOZ_SOURCE_TOUCH;
     // If the context menu launches on mousedown,
     // we have to fire focus on the content we clicked on
     FireFocusOnTargetContent(targetNode, isTouch);
 #endif
   }
   else {
     // Only open popups when the left mouse button is down.
     if (mouseEvent->Button() != 0) {
--- a/gfx/layers/apz/src/APZCTreeManager.cpp
+++ b/gfx/layers/apz/src/APZCTreeManager.cpp
@@ -10,16 +10,17 @@
 #include "AsyncPanZoomController.h"
 #include "Compositor.h"                 // for Compositor
 #include "DragTracker.h"                // for DragTracker
 #include "gfxPrefs.h"                   // for gfxPrefs
 #include "HitTestingTreeNode.h"         // for HitTestingTreeNode
 #include "InputBlockState.h"            // for InputBlockState
 #include "InputData.h"                  // for InputData, etc
 #include "Layers.h"                     // for Layer, etc
+#include "mozilla/dom/MouseEventBinding.h" // for MouseEvent constants
 #include "mozilla/dom/Touch.h"          // for Touch
 #include "mozilla/gfx/gfxVars.h"        // for gfxVars
 #include "mozilla/gfx/GPUParent.h"      // for GPUParent
 #include "mozilla/gfx/Logging.h"        // for gfx::TreeLog
 #include "mozilla/gfx/Point.h"          // for Point
 #include "mozilla/layers/APZThreadUtils.h"  // for AssertOnControllerThread, etc
 #include "mozilla/layers/AsyncCompositionManager.h" // for ViewTransform
 #include "mozilla/layers/AsyncDragMetrics.h" // for AsyncDragMetrics
@@ -1691,17 +1692,17 @@ APZCTreeManager::ProcessTouchInputForScr
   MOZ_ASSERT(mRetainedTouchIdentifier == -1);
   MOZ_ASSERT(mApzcForInputBlock);
   MOZ_ASSERT(aTouchInput.mTouches.Length() == 1);
 
   // Synthesize a mouse event based on the touch event, so that we can
   // reuse code in InputQueue and APZC for handling scrollbar mouse-drags.
   MouseInput mouseInput{MultiTouchTypeToMouseType(aTouchInput.mType),
                         MouseInput::LEFT_BUTTON,
-                        nsIDOMMouseEvent::MOZ_SOURCE_TOUCH,
+                        dom::MouseEventBinding::MOZ_SOURCE_TOUCH,
                         WidgetMouseEvent::eLeftButtonFlag,
                         aTouchInput.mTouches[0].mScreenPoint,
                         aTouchInput.mTime,
                         aTouchInput.mTimeStamp,
                         aTouchInput.modifiers};
   mouseInput.mHandledByAPZ = true;
 
   // The value of |targetConfirmed| passed to InputQueue::ReceiveInputEvent()
--- a/gfx/layers/apz/util/APZCCallbackHelper.cpp
+++ b/gfx/layers/apz/util/APZCCallbackHelper.cpp
@@ -6,16 +6,17 @@
 
 #include "APZCCallbackHelper.h"
 
 #include "TouchActionHelper.h"
 #include "gfxPlatform.h" // For gfxPlatform::UseTiling
 #include "gfxPrefs.h"
 #include "LayersLogging.h"  // For Stringify
 #include "mozilla/dom/Element.h"
+#include "mozilla/dom/MouseEventBinding.h"
 #include "mozilla/dom/TabParent.h"
 #include "mozilla/IntegerPrintfMacros.h"
 #include "mozilla/layers/LayerTransactionChild.h"
 #include "mozilla/layers/ShadowLayers.h"
 #include "mozilla/layers/WebRenderLayerManager.h"
 #include "mozilla/layers/WebRenderBridgeChild.h"
 #include "mozilla/TouchEvents.h"
 #include "nsContentUtils.h"
@@ -512,17 +513,17 @@ APZCCallbackHelper::DispatchSynthesizedM
   MOZ_ASSERT(aMsg == eMouseMove || aMsg == eMouseDown ||
              aMsg == eMouseUp || aMsg == eMouseLongTap);
 
   WidgetMouseEvent event(true, aMsg, aWidget,
                          WidgetMouseEvent::eReal, WidgetMouseEvent::eNormal);
   event.mRefPoint = LayoutDeviceIntPoint::Truncate(aRefPoint.x, aRefPoint.y);
   event.mTime = aTime;
   event.button = WidgetMouseEvent::eLeftButton;
-  event.inputSource = nsIDOMMouseEvent::MOZ_SOURCE_TOUCH;
+  event.inputSource = dom::MouseEventBinding::MOZ_SOURCE_TOUCH;
   if (aMsg == eMouseLongTap) {
     event.mFlags.mOnlyChromeDispatch = true;
   }
   event.mIgnoreRootScrollFrame = true;
   if (aMsg != eMouseMove) {
     event.mClickCount = aClickCount;
   }
   event.mModifiers = aModifiers;
--- a/gfx/layers/apz/util/APZEventState.cpp
+++ b/gfx/layers/apz/util/APZEventState.cpp
@@ -6,37 +6,36 @@
 
 #include "APZEventState.h"
 
 #include "ActiveElementManager.h"
 #include "APZCCallbackHelper.h"
 #include "gfxPrefs.h"
 #include "LayersLogging.h"
 #include "mozilla/BasicEvents.h"
+#include "mozilla/dom/MouseEventBinding.h"
 #include "mozilla/dom/TabChild.h"
 #include "mozilla/dom/TabGroup.h"
 #include "mozilla/IntegerPrintfMacros.h"
 #include "mozilla/Move.h"
 #include "mozilla/Preferences.h"
 #include "mozilla/TouchEvents.h"
 #include "mozilla/layers/APZCCallbackHelper.h"
 #include "nsCOMPtr.h"
 #include "nsDocShell.h"
-#include "nsIDOMMouseEvent.h"
 #include "nsIDOMWindowUtils.h"
 #include "nsINamed.h"
 #include "nsIScrollableFrame.h"
 #include "nsIScrollbarMediator.h"
 #include "nsITimer.h"
 #include "nsIWeakReferenceUtils.h"
 #include "nsIWidget.h"
 #include "nsLayoutUtils.h"
 #include "nsQueryFrame.h"
 #include "TouchManager.h"
-#include "nsIDOMMouseEvent.h"
 #include "nsLayoutUtils.h"
 #include "nsIScrollableFrame.h"
 #include "nsIScrollbarMediator.h"
 #include "mozilla/TouchEvents.h"
 #include "mozilla/widget/nsAutoRollup.h"
 
 #define APZES_LOG(...)
 // #define APZES_LOG(...) printf_stderr("APZES: " __VA_ARGS__)
@@ -237,17 +236,17 @@ APZEventState::FireContextmenuEvents(con
 {
   // Converting the modifiers to DOM format for the DispatchMouseEvent call
   // is the most useless thing ever because nsDOMWindowUtils::SendMouseEvent
   // just converts them back to widget format, but that API has many callers,
   // including in JS code, so it's not trivial to change.
   bool eventHandled =
       APZCCallbackHelper::DispatchMouseEvent(aPresShell, NS_LITERAL_STRING("contextmenu"),
                          aPoint, 2, 1, WidgetModifiersToDOMModifiers(aModifiers), true,
-                         nsIDOMMouseEvent::MOZ_SOURCE_TOUCH,
+                         dom::MouseEventBinding::MOZ_SOURCE_TOUCH,
                          0 /* Use the default value here. */);
 
   APZES_LOG("Contextmenu event handled: %d\n", eventHandled);
   if (eventHandled) {
     // If the contextmenu event was handled then we're showing a contextmenu,
     // and so we should remove any activation
     mActiveElementManager->ClearActivation();
 #ifndef XP_WIN
--- a/layout/base/AccessibleCaretEventHub.cpp
+++ b/layout/base/AccessibleCaretEventHub.cpp
@@ -10,16 +10,17 @@
 #include "AccessibleCaretManager.h"
 #include "Layers.h"
 #include "gfxPrefs.h"
 #include "mozilla/AutoRestore.h"
 #include "mozilla/MouseEvents.h"
 #include "mozilla/TextEvents.h"
 #include "mozilla/TouchEvents.h"
 #include "mozilla/Preferences.h"
+#include "mozilla/dom/MouseEventBinding.h"
 #include "nsCanvasFrame.h"
 #include "nsDocShell.h"
 #include "nsFocusManager.h"
 #include "nsFrameSelection.h"
 #include "nsITimer.h"
 #include "nsPresContext.h"
 
 namespace mozilla {
@@ -532,17 +533,17 @@ AccessibleCaretEventHub::HandleTouchEven
 
   nsEventStatus rv = nsEventStatus_eIgnore;
 
   int32_t id =
     (mActiveTouchId == kInvalidTouchId ? aEvent->mTouches[0]->Identifier()
                                        : mActiveTouchId);
   nsPoint point = GetTouchEventPosition(aEvent, id);
 
-  mManager->SetLastInputSource(nsIDOMMouseEvent::MOZ_SOURCE_TOUCH);
+  mManager->SetLastInputSource(MouseEventBinding::MOZ_SOURCE_TOUCH);
 
   switch (aEvent->mMessage) {
     case eTouchStart:
       AC_LOGV("Before eTouchStart, state: %s", mState->Name());
       rv = mState->OnPress(this, point, id, eTouchEventClass);
       AC_LOGV("After eTouchStart, state: %s, consume: %d", mState->Name(), rv);
       break;
 
@@ -568,17 +569,17 @@ AccessibleCaretEventHub::HandleTouchEven
   }
 
   return rv;
 }
 
 nsEventStatus
 AccessibleCaretEventHub::HandleKeyboardEvent(WidgetKeyboardEvent* aEvent)
 {
-  mManager->SetLastInputSource(nsIDOMMouseEvent::MOZ_SOURCE_KEYBOARD);
+  mManager->SetLastInputSource(MouseEventBinding::MOZ_SOURCE_KEYBOARD);
 
   switch (aEvent->mMessage) {
     case eKeyUp:
       AC_LOGV("eKeyUp, state: %s", mState->Name());
       mManager->OnKeyboardEvent();
       break;
 
     case eKeyDown:
--- a/layout/base/AccessibleCaretManager.cpp
+++ b/layout/base/AccessibleCaretManager.cpp
@@ -6,16 +6,17 @@
 
 #include "AccessibleCaretManager.h"
 
 #include "AccessibleCaret.h"
 #include "AccessibleCaretEventHub.h"
 #include "AccessibleCaretLogger.h"
 #include "mozilla/AsyncEventDispatcher.h"
 #include "mozilla/dom/Element.h"
+#include "mozilla/dom/MouseEventBinding.h"
 #include "mozilla/dom/NodeFilterBinding.h"
 #include "mozilla/dom/Selection.h"
 #include "mozilla/dom/TreeWalker.h"
 #include "mozilla/IMEStateManager.h"
 #include "mozilla/IntegerPrintfMacros.h"
 #include "mozilla/Preferences.h"
 #include "nsCaret.h"
 #include "nsContainerFrame.h"
@@ -186,25 +187,25 @@ AccessibleCaretManager::OnSelectionChang
   if (aReason & (nsISelectionListener::COLLAPSETOSTART_REASON |
                  nsISelectionListener::COLLAPSETOEND_REASON)) {
     HideCarets();
     return NS_OK;
   }
 
   // For mouse input we don't want to show the carets.
   if (sHideCaretsForMouseInput &&
-      mLastInputSource == nsIDOMMouseEvent::MOZ_SOURCE_MOUSE) {
+      mLastInputSource == MouseEventBinding::MOZ_SOURCE_MOUSE) {
     HideCarets();
     return NS_OK;
   }
 
   // When we want to hide the carets for mouse input, hide them for select
   // all action fired by keyboard as well.
   if (sHideCaretsForMouseInput &&
-      mLastInputSource == nsIDOMMouseEvent::MOZ_SOURCE_KEYBOARD &&
+      mLastInputSource == MouseEventBinding::MOZ_SOURCE_KEYBOARD &&
       (aReason & nsISelectionListener::SELECTALL_REASON)) {
     HideCarets();
     return NS_OK;
   }
 
   UpdateCarets();
   return NS_OK;
 }
@@ -687,17 +688,17 @@ AccessibleCaretManager::OnScrollEnd()
       // If the caret is hidden (Appearance::None) due to blur, no
       // need to update it.
       return;
     }
   }
 
   // For mouse input we don't want to show the carets.
   if (sHideCaretsForMouseInput &&
-      mLastInputSource == nsIDOMMouseEvent::MOZ_SOURCE_MOUSE) {
+      mLastInputSource == MouseEventBinding::MOZ_SOURCE_MOUSE) {
     AC_LOG("%s: HideCarets()", __FUNCTION__);
     HideCarets();
     return;
   }
 
   AC_LOG("%s: UpdateCarets()", __FUNCTION__);
   UpdateCarets();
 }
--- a/layout/base/AccessibleCaretManager.h
+++ b/layout/base/AccessibleCaretManager.h
@@ -5,23 +5,23 @@
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #ifndef AccessibleCaretManager_h
 #define AccessibleCaretManager_h
 
 #include "AccessibleCaret.h"
 
 #include "mozilla/dom/CaretStateChangedEvent.h"
+#include "mozilla/dom/MouseEventBinding.h"
 #include "mozilla/EnumSet.h"
 #include "mozilla/EventForwards.h"
 #include "mozilla/RefPtr.h"
 #include "mozilla/UniquePtr.h"
 #include "nsCOMPtr.h"
 #include "nsCoord.h"
-#include "nsIDOMMouseEvent.h"
 #include "nsIFrame.h"
 #include "nsISelectionListener.h"
 
 class nsFrameSelection;
 class nsIContent;
 class nsIPresShell;
 struct nsPoint;
 
@@ -316,17 +316,17 @@ protected:
                                  AccessibleCaret::Appearance::None;
   AccessibleCaret::Appearance mSecondCaretAppearanceOnScrollStart =
                                  AccessibleCaret::Appearance::None;
 
   // The last input source that the event hub saw. We use this to decide whether
   // or not show the carets when the selection is updated, as we want to hide
   // the carets for mouse-triggered selection changes but show them for other
   // input types such as touch.
-  uint16_t mLastInputSource = nsIDOMMouseEvent::MOZ_SOURCE_UNKNOWN;
+  uint16_t mLastInputSource = dom::MouseEventBinding::MOZ_SOURCE_UNKNOWN;
 
   // Set to true in OnScrollStart() and set to false in OnScrollEnd().
   bool mIsScrollStarted = false;
 
   // Whether we're flushing layout, used for sanity-checking.
   bool mFlushingLayout = false;
 
   static const int32_t kAutoScrollTimerDelay = 30;
--- a/layout/base/PositionedEventTargeting.cpp
+++ b/layout/base/PositionedEventTargeting.cpp
@@ -5,16 +5,17 @@
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "PositionedEventTargeting.h"
 
 #include "mozilla/EventListenerManager.h"
 #include "mozilla/EventStates.h"
 #include "mozilla/MouseEvents.h"
 #include "mozilla/Preferences.h"
+#include "mozilla/dom/MouseEventBinding.h"
 #include "nsLayoutUtils.h"
 #include "nsGkAtoms.h"
 #include "nsFontMetrics.h"
 #include "nsPrintfCString.h"
 #include "mozilla/dom/Element.h"
 #include "nsRegion.h"
 #include "nsDeviceContext.h"
 #include "nsIContentInlines.h"
@@ -572,17 +573,17 @@ FindFrameTargetedByInputEvent(WidgetGUIE
     }
   }
 
   // Do not modify targeting for actual mouse hardware; only for mouse
   // events generated by touch-screen hardware.
   if (aEvent->mClass == eMouseEventClass &&
       prefs->mTouchOnly &&
       aEvent->AsMouseEvent()->inputSource !=
-        nsIDOMMouseEvent::MOZ_SOURCE_TOUCH) {
+        MouseEventBinding::MOZ_SOURCE_TOUCH) {
     PET_LOG("Mouse input event is not from a touch source\n");
     return target;
   }
 
   // If the exact target is non-null, only consider candidate targets in the same
   // document as the exact target. Otherwise, if an ancestor document has
   // a mouse event handler for example, targets that are !GetClickableAncestor can
   // never be targeted --- something nsSubDocumentFrame in an ancestor document
--- a/layout/base/tests/bug977003_inner_5.html
+++ b/layout/base/tests/bug977003_inner_5.html
@@ -79,19 +79,19 @@ https://bugzilla.mozilla.org/show_bug.cg
       target.addEventListener("pointerdown",          TargetDownHandler);
       listener.addEventListener("gotpointercapture",  ListenerGotPCHandler);
       listener.addEventListener("lostpointercapture", ListenerLostPCHandler);
       listener.addEventListener("pointerover",        ListenerOverHandler);
       listener.addEventListener("pointermove",        ListenerMoveHandler);
       listener.addEventListener("pointerup",          ListenerHandler);
       listener.addEventListener("pointerout",         ListenerHandler);
       var rect = target.getBoundingClientRect();
-      synthesizeMouse(target, rect.width/2, rect.height/2, {type: "mousedown", isPrimary: true, inputSource: SpecialPowers.Ci.nsIDOMMouseEvent.MOZ_SOURCE_TOUCH});
-      synthesizeMouse(target, rect.width/2, rect.height/2, {type: "mousemove", isPrimary: true, inputSource: SpecialPowers.Ci.nsIDOMMouseEvent.MOZ_SOURCE_TOUCH});
-      synthesizeMouse(target, rect.width/2, rect.height/2, {type: "mouseup",   isPrimary: true, inputSource: SpecialPowers.Ci.nsIDOMMouseEvent.MOZ_SOURCE_TOUCH});
+      synthesizeMouse(target, rect.width/2, rect.height/2, {type: "mousedown", isPrimary: true, inputSource: MouseEvent.MOZ_SOURCE_TOUCH});
+      synthesizeMouse(target, rect.width/2, rect.height/2, {type: "mousemove", isPrimary: true, inputSource: MouseEvent.MOZ_SOURCE_TOUCH});
+      synthesizeMouse(target, rect.width/2, rect.height/2, {type: "mouseup",   isPrimary: true, inputSource: MouseEvent.MOZ_SOURCE_TOUCH});
       finishTest();
     }
     function finishTest() {
       parent.is(test_down_target,     true, "Part 5: pointerdown event should be received by target");
       parent.is(test_got_listener,    true, "Part 5: listener should receive gotpointercapture event");
       parent.is(test_got_type,     "touch", "Part 5: gotpointercapture event should have pointerType touch");
       parent.is(test_got_primary,     true, "Part 5: gotpointercapture event should have isPrimary as true");
       parent.is(test_lost_listener,   true, "Part 5: listener should receive lostpointercapture event");
--- a/layout/base/tests/test_event_target_iframe_oop.html
+++ b/layout/base/tests/test_event_target_iframe_oop.html
@@ -147,24 +147,24 @@ function execTest() {
   document.addEventListener('mousedown', handleEvent);
 
   // In the following, the coordinates are relative to the iframe
 
   // First, we check that tapping onto the 'dialer' correctly triggers the
   // dialer.
   testMouseClick("dialer", 20, 1, "dialer", "correct hit on dialer with mouse input");
   testMouseClick("dialer", 20, 1, "dialer", "correct hit on dialer with touch input", {
-    inputSource: SpecialPowers.Ci.nsIDOMMouseEvent.MOZ_SOURCE_TOUCH
+    inputSource: MouseEvent.MOZ_SOURCE_TOUCH
   });
 
   // Now this is it: we tap inside 'apps', but very close to the border between
   // 'apps' and 'dialer'. Without the fix from this bug, this test will fail.
   testMouseClick("apps", 20, 1, "apps", "apps <iframe mozbrowser remote> hit for mouse input");
   testMouseClick("apps", 20, 1, "apps", "apps <iframe mozbrowser remote> hit for touch input", {
-    inputSource: SpecialPowers.Ci.nsIDOMMouseEvent.MOZ_SOURCE_TOUCH
+    inputSource: MouseEvent.MOZ_SOURCE_TOUCH
   });
 
   // Show small red spots of where the click happened
   // showDebug();
 
   endTest();
 }
 
--- a/layout/base/tests/test_event_target_radius.html
+++ b/layout/base/tests/test_event_target_radius.html
@@ -128,20 +128,20 @@ function runTest() {
 
   // When inputSource.touchOnly is true, mouse input is not retargeted.
   SpecialPowers.pushPrefEnv({"set": [["ui.mouse.radius.inputSource.touchOnly", true]]}, test2);
 }
 
 function test2() {
   testMouseClick("t", 100 + 11*mm, 10, "body", "disabled for mouse input");
   testMouseClick("t", 100 + 11*mm, 10, "t", "enabled for touch input", {
-    inputSource: SpecialPowers.Ci.nsIDOMMouseEvent.MOZ_SOURCE_TOUCH
+    inputSource: MouseEvent.MOZ_SOURCE_TOUCH
   });
   testMouseClick("t", 100 + 13*mm, 10, "body", "basic functionality for touch", {
-    inputSource: SpecialPowers.Ci.nsIDOMMouseEvent.MOZ_SOURCE_TOUCH
+    inputSource: MouseEvent.MOZ_SOURCE_TOUCH
   });
   SpecialPowers.pushPrefEnv({"set": [["ui.mouse.radius.inputSource.touchOnly", false]]}, test3);
 }
 
 function test3() {
   setShowing("t", false);
 
   // Now test the criteria we use to determine which elements are hittable
@@ -240,26 +240,26 @@ function test3() {
   setShowing("t7", false);
   setShowing("t7_over", false);
 
   // Check that contenteditable elements are considered clickable for fluffing.
   setShowing("t8", true);
   var rect = document.getElementById("t8").getBoundingClientRect();
   testMouseClick("t8", rect.left + 1, rect.top + 1, "t8", "content editable enabled for mouse input");
   testMouseClick("t8", rect.left + 1, rect.top + 1, "t8", "content editable enabled for touch input", {
-    inputSource: SpecialPowers.Ci.nsIDOMMouseEvent.MOZ_SOURCE_TOUCH
+    inputSource: MouseEvent.MOZ_SOURCE_TOUCH
   });
   setShowing("t8", false);
 
   // Check that elements are touchable
   setShowing("t9", true);
   var rect = document.getElementById("t9").getBoundingClientRect();
   testMouseClick("t9", rect.left + 1, rect.top + 1, "t9", "div enabled with mouse input");
   testMouseClick("t9", rect.left + 1, rect.top + 1, "t9", "div enabled with touch input", {
-    inputSource: SpecialPowers.Ci.nsIDOMMouseEvent.MOZ_SOURCE_TOUCH
+    inputSource: MouseEvent.MOZ_SOURCE_TOUCH
   });
   setShowing("t9", false);
 
   setShowing("t10_over", true);
   setShowing("t10_left", true);
   setShowing("t10_right", true);
   setShowing("t10_top", true);
   setShowing("t10_bottom", true);
--- a/layout/forms/nsListControlFrame.cpp
+++ b/layout/forms/nsListControlFrame.cpp
@@ -21,16 +21,17 @@
 #include "nsLayoutUtils.h"
 #include "nsDisplayList.h"
 #include "nsContentUtils.h"
 #include "mozilla/Attributes.h"
 #include "mozilla/dom/HTMLOptGroupElement.h"
 #include "mozilla/dom/HTMLOptionsCollection.h"
 #include "mozilla/dom/HTMLSelectElement.h"
 #include "mozilla/dom/MouseEvent.h"
+#include "mozilla/dom/MouseEventBinding.h"
 #include "mozilla/EventStateManager.h"
 #include "mozilla/EventStates.h"
 #include "mozilla/LookAndFeel.h"
 #include "mozilla/MouseEvents.h"
 #include "mozilla/Preferences.h"
 #include "mozilla/TextEvents.h"
 #include <algorithm>
 
@@ -1850,17 +1851,17 @@ nsListControlFrame::MouseDown(nsIDOMEven
         nsCOMPtr<nsIContent> econtent = do_QueryInterface(etarget);
         HTMLOptionElement* option = HTMLOptionElement::FromContentOrNull(econtent);
         if (option) {
           return NS_OK;
         }
       }
 
       uint16_t inputSource = mouseEvent->MozInputSource();
-      bool isSourceTouchEvent = inputSource == nsIDOMMouseEvent::MOZ_SOURCE_TOUCH;
+      bool isSourceTouchEvent = inputSource == MouseEventBinding::MOZ_SOURCE_TOUCH;
       if (FireShowDropDownEvent(mContent, !mComboboxFrame->IsDroppedDownOrHasParentPopup(),
                                 isSourceTouchEvent)) {
         return NS_OK;
       }
 
       if (!IgnoreMouseEventForSelection(aMouseEvent)) {
         return NS_OK;
       }
--- a/layout/xul/nsButtonBoxFrame.cpp
+++ b/layout/xul/nsButtonBoxFrame.cpp
@@ -12,16 +12,17 @@
 #include "nsGkAtoms.h"
 #include "nsNameSpaceManager.h"
 #include "nsPresContext.h"
 #include "nsIPresShell.h"
 #include "nsIDOMElement.h"
 #include "nsDisplayList.h"
 #include "nsContentUtils.h"
 #include "mozilla/dom/Element.h"
+#include "mozilla/dom/MouseEventBinding.h"
 #include "mozilla/EventStateManager.h"
 #include "mozilla/EventStates.h"
 #include "mozilla/MouseEvents.h"
 #include "mozilla/TextEvents.h"
 
 using namespace mozilla;
 
 
@@ -205,17 +206,17 @@ nsButtonBoxFrame::DoMouseClick(WidgetGUI
                                          nsGkAtoms::_true, eCaseMatters))
     return;
 
   // Execute the oncommand event handler.
   bool isShift = false;
   bool isControl = false;
   bool isAlt = false;
   bool isMeta = false;
-  uint16_t inputSource = nsIDOMMouseEvent::MOZ_SOURCE_UNKNOWN;
+  uint16_t inputSource = MouseEventBinding::MOZ_SOURCE_UNKNOWN;
 
   if(aEvent) {
     WidgetInputEvent* inputEvent = aEvent->AsInputEvent();
     isShift = inputEvent->IsShift();
     isControl = inputEvent->IsControl();
     isAlt = inputEvent->IsAlt();
     isMeta = inputEvent->IsMeta();
 
--- a/layout/xul/nsResizerFrame.cpp
+++ b/layout/xul/nsResizerFrame.cpp
@@ -20,16 +20,17 @@
 #include "nsIDocShellTreeOwner.h"
 #include "nsIBaseWindow.h"
 #include "nsPIDOMWindow.h"
 #include "mozilla/MouseEvents.h"
 #include "nsContentUtils.h"
 #include "nsMenuPopupFrame.h"
 #include "nsIScreenManager.h"
 #include "mozilla/dom/Element.h"
+#include "mozilla/dom/MouseEventBinding.h"
 #include "nsError.h"
 #include "nsICSSDeclaration.h"
 #include "nsStyledElement.h"
 #include <algorithm>
 
 using namespace mozilla;
 
 //
@@ -535,17 +536,17 @@ nsResizerFrame::GetDirection()
 void
 nsResizerFrame::MouseClicked(WidgetMouseEvent* aEvent)
 {
   bool isTrusted = false;
   bool isShift = false;
   bool isControl = false;
   bool isAlt = false;
   bool isMeta = false;
-  uint16_t inputSource = nsIDOMMouseEvent::MOZ_SOURCE_UNKNOWN;
+  uint16_t inputSource = MouseEventBinding::MOZ_SOURCE_UNKNOWN;
 
   if(aEvent) {
     isShift = aEvent->IsShift();
     isControl = aEvent->IsControl();
     isAlt = aEvent->IsAlt();
     isMeta = aEvent->IsMeta();
     inputSource = aEvent->inputSource;
   }
--- a/layout/xul/nsTitleBarFrame.cpp
+++ b/layout/xul/nsTitleBarFrame.cpp
@@ -13,16 +13,17 @@
 #include "nsIWidget.h"
 #include "nsMenuPopupFrame.h"
 #include "nsPresContext.h"
 #include "nsIDocShell.h"
 #include "nsPIDOMWindow.h"
 #include "nsDisplayList.h"
 #include "nsContentUtils.h"
 #include "mozilla/MouseEvents.h"
+#include "mozilla/dom/MouseEventBinding.h"
 
 using namespace mozilla;
 
 //
 // NS_NewTitleBarFrame
 //
 // Creates a new TitleBar frame and returns it
 //
@@ -168,17 +169,17 @@ nsTitleBarFrame::HandleEvent(nsPresConte
 void
 nsTitleBarFrame::MouseClicked(WidgetMouseEvent* aEvent)
 {
   bool isTrusted = false;
   bool isShift = false;
   bool isControl = false;
   bool isAlt = false;
   bool isMeta = false;
-  uint16_t inputSource = nsIDOMMouseEvent::MOZ_SOURCE_UNKNOWN;
+  uint16_t inputSource = dom::MouseEventBinding::MOZ_SOURCE_UNKNOWN;
 
   if(aEvent) {
     isShift = aEvent->IsShift();
     isControl = aEvent->IsControl();
     isAlt = aEvent->IsAlt();
     isMeta = aEvent->IsMeta();
     inputSource = aEvent->inputSource;
   }
--- a/testing/marionette/event.js
+++ b/testing/marionette/event.js
@@ -260,30 +260,30 @@ event.synthesizeMouse = function(
  * @param {number} left
  *     CSS pixels from the left document margin.
  * @param {number} top
  *     CSS pixels from the top document margin.
  * @param {Object.<string, ?>} opts
  *     Object which may contain the properties "shiftKey", "ctrlKey",
  *     "altKey", "metaKey", "accessKey", "clickCount", "button", and
  *     "type".
- * @param {Window=} window
+ * @param {Window=} win
  *     Window object.  Defaults to the current window.
  */
 event.synthesizeMouseAtPoint = function(
-    left, top, opts, window = undefined) {
+    left, top, opts, win = window) {
 
-  let domutils = getDOMWindowUtils(window);
+  let domutils = getDOMWindowUtils(win);
 
   let button = opts.button || 0;
   let clickCount = opts.clickCount || 1;
   let modifiers = event.parseModifiers_(opts);
   let pressure = ("pressure" in opts) ? opts.pressure : 0;
   let inputSource = ("inputSource" in opts) ? opts.inputSource :
-      Ci.nsIDOMMouseEvent.MOZ_SOURCE_MOUSE;
+      win.MouseEvent.MOZ_SOURCE_MOUSE;
   let isDOMEventSynthesized =
       ("isSynthesized" in opts) ? opts.isSynthesized : true;
   let isWidgetEventSynthesized;
   if ("isWidgetEventSynthesized" in opts) {
     isWidgetEventSynthesized = opts.isWidgetEventSynthesized;
   } else {
     isWidgetEventSynthesized = false;
   }
--- a/testing/mochitest/tests/SimpleTest/EventUtils.js
+++ b/testing/mochitest/tests/SimpleTest/EventUtils.js
@@ -100,16 +100,29 @@ function _EU_isAndroid(aWindow = window)
     try {
       return aWindow.navigator.userAgent.includes("Android");
     } catch (ex) {}
   }
   return navigator.userAgent.includes("Android");
 }
 
 function _EU_maybeWrap(o) {
+  // We're used in some contexts where there is no SpecialPowers and also in
+  // some where it exists but has no wrap() method.  And this is somewhat
+  // independent of whether window.Components is a thing...
+  var haveWrap = false;
+  try {
+    haveWrap = SpecialPowers.wrap != undefined;
+  } catch (e) {
+    // Just leave it false.
+  }
+  if (!haveWrap) {
+    // Not much we can do here.
+    return o;
+  }
   var c = Object.getOwnPropertyDescriptor(window, 'Components');
   return c.value && !c.writable ? o : SpecialPowers.wrap(o);
 }
 
 function _EU_maybeUnwrap(o) {
   var c = Object.getOwnPropertyDescriptor(window, 'Components');
   return c.value && !c.writable ? o : SpecialPowers.unwrap(o);
 }
@@ -413,25 +426,28 @@ function synthesizeMouseAtPoint(left, to
   var defaultPrevented = false;
 
   if (utils) {
     var button = computeButton(aEvent);
     var clickCount = aEvent.clickCount || 1;
     var modifiers = _parseModifiers(aEvent, aWindow);
     var pressure = ("pressure" in aEvent) ? aEvent.pressure : 0;
 
+    // aWindow might be cross-origin from us.
+    var MouseEvent = _EU_maybeWrap(aWindow).MouseEvent;
+
     // Default source to mouse.
     var inputSource = ("inputSource" in aEvent) ? aEvent.inputSource :
-                                                  _EU_Ci.nsIDOMMouseEvent.MOZ_SOURCE_MOUSE;
+                                                  MouseEvent.MOZ_SOURCE_MOUSE;
     // Compute a pointerId if needed.
     var id;
     if ("id" in aEvent) {
       id = aEvent.id;
     } else {
-      var isFromPen = inputSource === _EU_Ci.nsIDOMMouseEvent.MOZ_SOURCE_PEN;
+      var isFromPen = inputSource === MouseEvent.MOZ_SOURCE_PEN;
       id = isFromPen ? utils.DEFAULT_PEN_POINTER_ID :
                        utils.DEFAULT_MOUSE_POINTER_ID;
     }
 
     var isDOMEventSynthesized =
       ("isSynthesized" in aEvent) ? aEvent.isSynthesized : true;
     var isWidgetEventSynthesized =
       ("isWidgetEventSynthesized" in aEvent) ? aEvent.isWidgetEventSynthesized : false;
--- a/toolkit/content/tests/widgets/tree_shared.js
+++ b/toolkit/content/tests/widgets/tree_shared.js
@@ -1294,30 +1294,30 @@ function mouseClickOnColumnHeader(aColum
   var columnHeaderRect = columnHeader.getBoundingClientRect();
   var columnWidth = columnHeaderRect.right - columnHeaderRect.left;
   // For multiple click we send separate click events, with increasing
   // clickCount.  This simulates the common behavior of multiple clicks.
   for (let i = 1; i <= aClickCount; i++) {
     // Target the middle of the column header.
     synthesizeMouse(columnHeader, columnWidth / 2, 3,
                     { button: aButton,
-                      clickCount: i }, null);
+                      clickCount: i });
   }
 }
 
 function mouseDblClickOnCell(tree, row, column, testname) {
   // select the row we will edit
   var selection = tree.view.selection;
   selection.select(row);
   tree.treeBoxObject.ensureRowIsVisible(row);
 
   // get cell coordinates
   var rect = tree.treeBoxObject.getCoordsForCellItem(row, column, "text");
 
-  synthesizeMouse(tree.body, rect.x, rect.y, { clickCount: 2 }, null);
+  synthesizeMouse(tree.body, rect.x, rect.y, { clickCount: 2 });
 }
 
 function compareArrays(arr1, arr2) {
   if (arr1.length != arr2.length)
     return false;
 
   for (let i = 0; i < arr1.length; i++) {
     if (arr1[i] != arr2[i])
--- a/widget/InputData.cpp
+++ b/widget/InputData.cpp
@@ -1,15 +1,16 @@
 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "InputData.h"
 
+#include "mozilla/dom/MouseEventBinding.h"
 #include "mozilla/dom/Touch.h"
 #include "mozilla/dom/WheelEventBinding.h"
 #include "mozilla/TextEvents.h"
 #include "nsContentUtils.h"
 #include "nsDebug.h"
 #include "nsThreadUtils.h"
 #include "mozilla/MouseEvents.h"
 #include "mozilla/TouchEvents.h"
@@ -267,17 +268,17 @@ MultiTouchInput::ToWidgetMouseEvent(nsIW
                          WidgetMouseEvent::eReal, WidgetMouseEvent::eNormal);
 
   const SingleTouchData& firstTouch = mTouches[0];
   event.mRefPoint.x = firstTouch.mScreenPoint.x;
   event.mRefPoint.y = firstTouch.mScreenPoint.y;
 
   event.mTime = mTime;
   event.button = WidgetMouseEvent::eLeftButton;
-  event.inputSource = nsIDOMMouseEvent::MOZ_SOURCE_TOUCH;
+  event.inputSource = MouseEventBinding::MOZ_SOURCE_TOUCH;
   event.mModifiers = modifiers;
   event.mFlags.mHandledByAPZ = mHandledByAPZ;
   event.mFocusSequenceNumber = mFocusSequenceNumber;
 
   if (mouseEventMessage != eMouseMove) {
     event.mClickCount = 1;
   }
 
--- a/widget/MouseEvents.h
+++ b/widget/MouseEvents.h
@@ -7,17 +7,16 @@
 #define mozilla_MouseEvents_h__
 
 #include <stdint.h>
 
 #include "mozilla/BasicEvents.h"
 #include "mozilla/MathAlgorithms.h"
 #include "mozilla/dom/DataTransfer.h"
 #include "nsCOMPtr.h"
-#include "nsIDOMMouseEvent.h"
 
 /******************************************************************************
  * nsDragDropEventStatus
  ******************************************************************************/
 
 enum nsDragDropEventStatus
 {  
   // The event is a enter
@@ -119,28 +118,32 @@ private:
   friend class dom::PBrowserChild;
 
 protected:
   WidgetMouseEventBase()
     : button(0)
     , buttons(0)
     , pressure(0)
     , hitCluster(false)
-    , inputSource(nsIDOMMouseEvent::MOZ_SOURCE_MOUSE)
+    // Including MouseEventBinding.h here leads to an include loop, so
+    // we have to hardcode MouseEventBinding::MOZ_SOURCE_MOUSE.
+    , inputSource(/* MouseEventBinding::MOZ_SOURCE_MOUSE = */ 1)
   {
   }
 
   WidgetMouseEventBase(bool aIsTrusted, EventMessage aMessage,
                        nsIWidget* aWidget, EventClassID aEventClassID)
     : WidgetInputEvent(aIsTrusted, aMessage, aWidget, aEventClassID)
     , button(0)
     , buttons(0)
     , pressure(0)
     , hitCluster(false)
-    , inputSource(nsIDOMMouseEvent::MOZ_SOURCE_MOUSE)
+    // Including MouseEventBinding.h here leads to an include loop, so
+    // we have to hardcode MouseEventBinding::MOZ_SOURCE_MOUSE.
+    , inputSource(/* MouseEventBinding::MOZ_SOURCE_MOUSE = */ 1)
  {
  }
 
 public:
   virtual WidgetMouseEventBase* AsMouseEventBase() override { return this; }
 
   virtual WidgetEvent* Duplicate() const override
   {
@@ -175,17 +178,17 @@ public:
   // This is set at any mouse event, don't be confused with |button|.
   int16_t buttons;
 
   // Finger or touch pressure of event. It ranges between 0.0 and 1.0.
   float pressure;
   // Touch near a cluster of links (true)
   bool hitCluster;
 
-  // Possible values at nsIDOMMouseEvent
+  // Possible values a in MouseEvent
   uint16_t inputSource;
 
   // ID of the canvas HitRegion
   nsString region;
 
   bool IsLeftButtonPressed() const { return !!(buttons & eLeftButtonFlag); }
   bool IsRightButtonPressed() const { return !!(buttons & eRightButtonFlag); }
   bool IsMiddleButtonPressed() const { return !!(buttons & eMiddleButtonFlag); }
--- a/widget/android/nsWindow.cpp
+++ b/widget/android/nsWindow.cpp
@@ -13,16 +13,17 @@
 #include "mozilla/MiscEvents.h"
 #include "mozilla/MouseEvents.h"
 #include "mozilla/TouchEvents.h"
 #include "mozilla/TypeTraits.h"
 #include "mozilla/WeakPtr.h"
 
 #include "mozilla/dom/ContentParent.h"
 #include "mozilla/dom/ContentChild.h"
+#include "mozilla/dom/MouseEventBinding.h"
 #include "mozilla/Unused.h"
 #include "mozilla/Preferences.h"
 #include "mozilla/layers/RenderTrace.h"
 #include <algorithm>
 
 using mozilla::dom::ContentParent;
 using mozilla::dom::ContentChild;
 using mozilla::Unused;
@@ -596,17 +597,17 @@ public:
         }
 
         if (mouseType == MouseInput::MOUSE_NONE) {
             return false;
         }
 
         ScreenPoint origin = ScreenPoint(aX, aY);
 
-        MouseInput input(mouseType, buttonType, nsIDOMMouseEvent::MOZ_SOURCE_MOUSE, ConvertButtons(buttons), origin, aTime, GetEventTimeStamp(aTime), GetModifiers(aMetaState));
+        MouseInput input(mouseType, buttonType, MouseEventBinding::MOZ_SOURCE_MOUSE, ConvertButtons(buttons), origin, aTime, GetEventTimeStamp(aTime), GetModifiers(aMetaState));
 
         ScrollableLayerGuid guid;
         uint64_t blockId;
         nsEventStatus status = controller->InputBridge()->ReceiveInputEvent(input, &guid, &blockId);
 
         if (status == nsEventStatus_eConsumeNoDefault) {
             return true;
         }
@@ -2009,17 +2010,17 @@ nsWindow::DispatchHitTest(const WidgetTo
         // Since touch events don't get retargeted by PositionedEventTargeting.cpp
         // code on Fennec, we dispatch a dummy mouse event that *does* get
         // retargeted. The Fennec browser.js code can use this to activate the
         // highlight element in case the this touchstart is the start of a tap.
         WidgetMouseEvent hittest(true, eMouseHitTest, this,
                                  WidgetMouseEvent::eReal);
         hittest.mRefPoint = aEvent.mTouches[0]->mRefPoint;
         hittest.mIgnoreRootScrollFrame = true;
-        hittest.inputSource = nsIDOMMouseEvent::MOZ_SOURCE_TOUCH;
+        hittest.inputSource = MouseEventBinding::MOZ_SOURCE_TOUCH;
         nsEventStatus status;
         DispatchEvent(&hittest, status);
 
         if (mAPZEventState && hittest.hitCluster) {
             mAPZEventState->ProcessClusterHit();
         }
     }
 }
--- a/widget/cocoa/nsChildView.mm
+++ b/widget/cocoa/nsChildView.mm
@@ -13,16 +13,17 @@
 #include "nsChildView.h"
 #include "nsCocoaWindow.h"
 
 #include "mozilla/MiscEvents.h"
 #include "mozilla/MouseEvents.h"
 #include "mozilla/TextEvents.h"
 #include "mozilla/TouchEvents.h"
 #include "mozilla/dom/DataTransfer.h"
+#include "mozilla/dom/MouseEventBinding.h"
 #include "mozilla/dom/SimpleGestureEventBinding.h"
 #include "mozilla/dom/WheelEventBinding.h"
 
 #include "nsArrayUtils.h"
 #include "nsExceptionHandler.h"
 #include "nsObjCExceptions.h"
 #include "nsCOMPtr.h"
 #include "nsThreadUtils.h"
@@ -5293,17 +5294,17 @@ GetIntegerDeltaForEvent(NSEvent* aEvent)
   if (!aOutGeckoEvent || !sIsTabletPointerActivated) {
     return;
   }
   if ([aPointerEvent type] != NSMouseMoved) {
     aOutGeckoEvent->pressure = [aPointerEvent pressure];
     MOZ_ASSERT(aOutGeckoEvent->pressure >= 0.0 &&
                aOutGeckoEvent->pressure <= 1.0);
   }
-  aOutGeckoEvent->inputSource = nsIDOMMouseEvent::MOZ_SOURCE_PEN;
+  aOutGeckoEvent->inputSource = dom::MouseEventBinding::MOZ_SOURCE_PEN;
   aOutGeckoEvent->tiltX = lround([aPointerEvent tilt].x * 90);
   aOutGeckoEvent->tiltY = lround([aPointerEvent tilt].y * 90);
   aOutGeckoEvent->tangentialPressure = [aPointerEvent tangentialPressure];
   // Make sure the twist value is in the range of 0-359.
   int32_t twist = fmod([aPointerEvent rotation], 360);
   aOutGeckoEvent->twist = twist >= 0 ? twist : twist + 360;
   NS_OBJC_END_TRY_ABORT_BLOCK;
 }
--- a/widget/nsBaseDragService.cpp
+++ b/widget/nsBaseDragService.cpp
@@ -32,16 +32,17 @@
 #include "nsMenuPopupFrame.h"
 #include "SVGImageContext.h"
 #include "mozilla/MouseEvents.h"
 #include "mozilla/Preferences.h"
 #include "mozilla/dom/BindingDeclarations.h"
 #include "mozilla/dom/DataTransferItemList.h"
 #include "mozilla/dom/DataTransfer.h"
 #include "mozilla/dom/DragEvent.h"
+#include "mozilla/dom/MouseEventBinding.h"
 #include "mozilla/gfx/2D.h"
 #include "mozilla/Unused.h"
 #include "nsFrameLoader.h"
 #include "TabParent.h"
 
 #include "gfxContext.h"
 #include "gfxPlatform.h"
 #include <algorithm>
@@ -55,17 +56,17 @@ using namespace mozilla::image;
 
 nsBaseDragService::nsBaseDragService()
   : mCanDrop(false), mOnlyChromeDrop(false), mDoingDrag(false),
     mHasImage(false), mUserCancelled(false),
     mDragEventDispatchedToChildProcess(false),
     mDragAction(DRAGDROP_ACTION_NONE),
     mDragActionFromChildProcess(DRAGDROP_ACTION_UNINITIALIZED), mTargetSize(0,0),
     mContentPolicyType(nsIContentPolicy::TYPE_OTHER),
-    mSuppressLevel(0), mInputSource(nsIDOMMouseEvent::MOZ_SOURCE_MOUSE)
+    mSuppressLevel(0), mInputSource(MouseEventBinding::MOZ_SOURCE_MOUSE)
 {
 }
 
 nsBaseDragService::~nsBaseDragService() = default;
 
 NS_IMPL_ISUPPORTS(nsBaseDragService, nsIDragService, nsIDragSession)
 
 //---------------------------------------------------------
@@ -473,17 +474,17 @@ nsBaseDragService::EndDragSession(bool a
   mDataTransfer = nullptr;
   mHasImage = false;
   mUserCancelled = false;
   mDragPopup = nullptr;
   mImage = nullptr;
   mImageOffset = CSSIntPoint();
   mScreenPosition = CSSIntPoint();
   mEndDragPoint = LayoutDeviceIntPoint(0, 0);
-  mInputSource = nsIDOMMouseEvent::MOZ_SOURCE_MOUSE;
+  mInputSource = MouseEventBinding::MOZ_SOURCE_MOUSE;
 
   return NS_OK;
 }
 
 void
 nsBaseDragService::DiscardInternalTransferData()
 {
   if (mDataTransfer && mSourceNode) {
--- a/widget/uikit/nsWindow.mm
+++ b/widget/uikit/nsWindow.mm
@@ -29,16 +29,17 @@
 #include "gfxContext.h"
 #include "nsRegion.h"
 #include "Layers.h"
 #include "nsTArray.h"
 
 #include "mozilla/BasicEvents.h"
 #include "mozilla/TouchEvents.h"
 #include "mozilla/Unused.h"
+#include "mozilla/dom/MouseEventBinding.h"
 
 #include "GeckoProfiler.h"
 
 using namespace mozilla;
 using namespace mozilla::dom;
 using namespace mozilla::layers;
 
 #define ALOG(args...) fprintf(stderr, args); fprintf(stderr, "\n")
@@ -142,17 +143,17 @@ private:
 {
     WidgetMouseEvent event(true, aType, aWindow,
                            WidgetMouseEvent::eReal, WidgetMouseEvent::eNormal);
 
     event.mRefPoint = aPoint;
     event.mClickCount = 1;
     event.button = WidgetMouseEvent::eLeftButton;
     event.mTime = PR_IntervalNow();
-    event.inputSource = nsIDOMMouseEvent::MOZ_SOURCE_UNKNOWN;
+    event.inputSource = MouseEventBinding::MOZ_SOURCE_UNKNOWN;
 
     nsEventStatus status;
     aWindow->DispatchEvent(&event, status);
 }
 
 - (void)handleTap:(UITapGestureRecognizer *)sender
 {
     if (sender.state == UIGestureRecognizerStateEnded) {
--- a/widget/windows/WinPointerEvents.cpp
+++ b/widget/windows/WinPointerEvents.cpp
@@ -6,16 +6,17 @@
 /*
  * WinPointerEvents - Helper functions to retrieve PointerEvent's attributes
  */
 
 #include "nscore.h"
 #include "WinPointerEvents.h"
 #include "mozilla/MouseEvents.h"
 #include "mozilla/WindowsVersion.h"
+#include "mozilla/dom/MouseEventBinding.h"
 
 using namespace mozilla;
 using namespace mozilla::widget;
 
 const wchar_t WinPointerEvents::kPointerLibraryName[] =  L"user32.dll";
 HMODULE WinPointerEvents::sLibraryHandle = nullptr;
 WinPointerEvents::GetPointerTypePtr WinPointerEvents::getPointerType = nullptr;
 WinPointerEvents::GetPointerInfoPtr WinPointerEvents::getPointerInfo = nullptr;
@@ -153,17 +154,17 @@ WinPointerEvents::ShouldFirePointerEvent
   MOZ_ASSERT(sLibraryHandle && sPointerEventEnabled);
   return sFirePointerEventsByWinPointerMessages;
 }
 
 WinPointerInfo*
 WinPointerEvents::GetCachedPointerInfo(UINT aMsg, WPARAM aWParam)
 {
   if (!sLibraryHandle || !sPointerEventEnabled ||
-      MOUSE_INPUT_SOURCE() != nsIDOMMouseEvent::MOZ_SOURCE_PEN ||
+      MOUSE_INPUT_SOURCE() != dom::MouseEventBinding::MOZ_SOURCE_PEN ||
       ShouldFirePointerEventByWinPointerMessages()) {
     return nullptr;
   }
   switch (aMsg) {
   case WM_LBUTTONDOWN:
   case WM_MBUTTONDOWN:
   case WM_RBUTTONDOWN:
     return &mPenPointerDownInfo;
--- a/widget/windows/WinUtils.cpp
+++ b/widget/windows/WinUtils.cpp
@@ -11,16 +11,17 @@
 
 #include "gfxPlatform.h"
 #include "gfxUtils.h"
 #include "nsWindow.h"
 #include "nsWindowDefs.h"
 #include "KeyboardLayout.h"
 #include "nsIDOMMouseEvent.h"
 #include "mozilla/ArrayUtils.h"
+#include "mozilla/dom/MouseEventBinding.h"
 #include "mozilla/gfx/2D.h"
 #include "mozilla/gfx/DataSurfaceHelpers.h"
 #include "mozilla/HangMonitor.h"
 #include "mozilla/Preferences.h"
 #include "mozilla/RefPtr.h"
 #include "mozilla/WindowsVersion.h"
 #include "mozilla/Unused.h"
 #include "nsIContentPolicy.h"
@@ -1073,21 +1074,22 @@ WinUtils::GetNativeMessage(UINT aInterna
       return aInternalMessage;
   }
 }
 
 /* static */
 uint16_t
 WinUtils::GetMouseInputSource()
 {
-  int32_t inputSource = nsIDOMMouseEvent::MOZ_SOURCE_MOUSE;
+  int32_t inputSource = dom::MouseEventBinding::MOZ_SOURCE_MOUSE;
   LPARAM lParamExtraInfo = ::GetMessageExtraInfo();
   if ((lParamExtraInfo & TABLET_INK_SIGNATURE) == TABLET_INK_CHECK) {
     inputSource = (lParamExtraInfo & TABLET_INK_TOUCH) ?
-      nsIDOMMouseEvent::MOZ_SOURCE_TOUCH : nsIDOMMouseEvent::MOZ_SOURCE_PEN;
+      dom::MouseEventBinding::MOZ_SOURCE_TOUCH :
+      dom::MouseEventBinding::MOZ_SOURCE_PEN;
   }
   return static_cast<uint16_t>(inputSource);
 }
 
 /* static */
 uint16_t
 WinUtils::GetMousePointerID()
 {
--- a/widget/windows/WinUtils.h
+++ b/widget/windows/WinUtils.h
@@ -389,17 +389,17 @@ public:
   /**
    * GetNativeMessage() converts an internal message to a native message.
    * If aInternalMessage is a native message, returns the native message itself.
    */
   static UINT GetNativeMessage(UINT aInternalMessage);
 
   /**
    * GetMouseInputSource() returns a pointing device information.  The value is
-   * one of nsIDOMMouseEvent::MOZ_SOURCE_*.  This method MUST be called during
+   * one of MouseEventBinding::MOZ_SOURCE_*.  This method MUST be called during
    * mouse message handling.
    */
   static uint16_t GetMouseInputSource();
 
   /**
    * Windows also fires mouse window messages for pens and touches, so we should
    * retrieve their pointer ID on receiving mouse events as well. Please refer to
    * https://msdn.microsoft.com/en-us/library/windows/desktop/ms703320(v=vs.85).aspx
--- a/widget/windows/nsWindow.cpp
+++ b/widget/windows/nsWindow.cpp
@@ -121,16 +121,17 @@
 #include "Layers.h"
 #include "nsPrintfCString.h"
 #include "mozilla/Preferences.h"
 #include "nsISound.h"
 #include "SystemTimeConverter.h"
 #include "WinTaskbar.h"
 #include "WidgetUtils.h"
 #include "nsIWidgetListener.h"
+#include "mozilla/dom/MouseEventBinding.h"
 #include "mozilla/dom/Touch.h"
 #include "mozilla/gfx/2D.h"
 #include "nsToolkitCompsCID.h"
 #include "nsIAppStartup.h"
 #include "mozilla/WindowsVersion.h"
 #include "mozilla/TextEvents.h" // For WidgetKeyboardEvent
 #include "mozilla/TextEventDispatcherListener.h"
 #include "mozilla/widget/nsAutoRollup.h"
@@ -4313,17 +4314,17 @@ bool nsWindow::TouchEventShouldStartDrag
 
   // In chrome UI, allow touchdownstartsdrag attributes
   // to cause any touchdown event to trigger a drag.
   if (aEventMessage == eMouseDown) {
     WidgetMouseEvent hittest(true, eMouseHitTest, this,
                              WidgetMouseEvent::eReal);
     hittest.mRefPoint = aEventPoint;
     hittest.mIgnoreRootScrollFrame = true;
-    hittest.inputSource = nsIDOMMouseEvent::MOZ_SOURCE_TOUCH;
+    hittest.inputSource = MouseEventBinding::MOZ_SOURCE_TOUCH;
     DispatchInputEvent(&hittest);
 
     EventTarget* target = hittest.GetDOMEventTarget();
     if (target) {
       nsCOMPtr<nsIContent> node = do_QueryInterface(target);
 
       // Check if the element or any parent element has the
       // attribute we're looking for.
@@ -4417,17 +4418,17 @@ nsWindow::DispatchMouseEvent(EventMessag
     }
   }
 
   uint32_t pointerId = aPointerInfo ? aPointerInfo->pointerId :
                                       MOUSE_POINTERID();
 
   // Since it is unclear whether a user will use the digitizer,
   // Postpone initialization until first PEN message will be found.
-  if (nsIDOMMouseEvent::MOZ_SOURCE_PEN == aInputSource
+  if (MouseEventBinding::MOZ_SOURCE_PEN == aInputSource
       // Messages should be only at topLevel window.
       && nsWindowType::eWindowType_toplevel == mWindowType
       // Currently this scheme is used only when pointer events is enabled.
       && gfxPrefs::PointerEventsEnabled() && InkCollector::sInkCollector) {
     InkCollector::sInkCollector->SetTarget(mWnd);
     InkCollector::sInkCollector->SetPointerId(pointerId);
   }
 
@@ -5660,29 +5661,29 @@ nsWindow::ProcessMessage(UINT msg, WPARA
       LPARAM pos = lParamToClient(::GetMessagePos());
       MOZ_ASSERT(InkCollector::sInkCollector);
       uint16_t pointerId = InkCollector::sInkCollector->GetPointerId();
       if (pointerId != 0) {
         WinPointerInfo pointerInfo;
         pointerInfo.pointerId = pointerId;
         DispatchMouseEvent(eMouseExitFromWidget, wParam, pos, false,
                            WidgetMouseEvent::eLeftButton,
-                           nsIDOMMouseEvent::MOZ_SOURCE_PEN, &pointerInfo);
+                           MouseEventBinding::MOZ_SOURCE_PEN, &pointerInfo);
         InkCollector::sInkCollector->ClearTarget();
         InkCollector::sInkCollector->ClearPointerId();
       }
     }
     break;
 
     case WM_CONTEXTMENU:
     {
       // If the context menu is brought up by a touch long-press, then
       // the APZ code is responsible for dealing with this, so we don't
       // need to do anything.
-      if (mTouchWindow && MOUSE_INPUT_SOURCE() == nsIDOMMouseEvent::MOZ_SOURCE_TOUCH) {
+      if (mTouchWindow && MOUSE_INPUT_SOURCE() == MouseEventBinding::MOZ_SOURCE_TOUCH) {
         MOZ_ASSERT(mAPZC); // since mTouchWindow is true, APZ must be enabled
         result = true;
         break;
       }
 
       // if the context menu is brought up from the keyboard, |lParam|
       // will be -1.
       LPARAM pos;
@@ -7016,17 +7017,17 @@ bool nsWindow::OnGesture(WPARAM wParam, 
     WidgetWheelEvent wheelEvent(true, eWheel, this);
 
     ModifierKeyState modifierKeyState;
     modifierKeyState.InitInputEvent(wheelEvent);
 
     wheelEvent.button      = 0;
     wheelEvent.mTime       = ::GetMessageTime();
     wheelEvent.mTimeStamp  = GetMessageTimeStamp(wheelEvent.mTime);
-    wheelEvent.inputSource = nsIDOMMouseEvent::MOZ_SOURCE_TOUCH;
+    wheelEvent.inputSource = MouseEventBinding::MOZ_SOURCE_TOUCH;
 
     bool endFeedback = true;
 
     if (mGesture.PanDeltaToPixelScroll(wheelEvent)) {
       DispatchEvent(&wheelEvent, status);
     }
 
     if (mDisplayPanFeedback) {
@@ -7053,17 +7054,17 @@ bool nsWindow::OnGesture(WPARAM wParam, 
   }
   
   // Polish up and send off the new event
   ModifierKeyState modifierKeyState;
   modifierKeyState.InitInputEvent(event);
   event.button    = 0;
   event.mTime     = ::GetMessageTime();
   event.mTimeStamp = GetMessageTimeStamp(event.mTime);
-  event.inputSource = nsIDOMMouseEvent::MOZ_SOURCE_TOUCH;
+  event.inputSource = MouseEventBinding::MOZ_SOURCE_TOUCH;
 
   nsEventStatus status;
   DispatchEvent(&event, status);
   if (status == nsEventStatus_eIgnore) {
     return false; // Ignored, fall through
   }
 
   // Only close this if we process and return true.
@@ -7935,17 +7936,17 @@ nsWindow::DealWithPopups(HWND aWnd, UINT
     case WM_LBUTTONDOWN:
     case WM_RBUTTONDOWN:
     case WM_MBUTTONDOWN:
     case WM_NCLBUTTONDOWN:
     case WM_NCRBUTTONDOWN:
     case WM_NCMBUTTONDOWN:
       if (nativeMessage != WM_TOUCH &&
           IsTouchSupportEnabled(aWnd) &&
-          MOUSE_INPUT_SOURCE() == nsIDOMMouseEvent::MOZ_SOURCE_TOUCH) {
+          MOUSE_INPUT_SOURCE() == MouseEventBinding::MOZ_SOURCE_TOUCH) {
         // If any of these mouse events are really compatibility events that
         // Windows is sending for touch inputs, then don't allow them to dismiss
         // popups when APZ is enabled (instead we do the dismissing as part of
         // WM_TOUCH handling which is more correct).
         // If we don't do this, then when the user lifts their finger after a
         // long-press, the WM_RBUTTONDOWN compatibility event that Windows sends
         // us will dismiss the contextmenu popup that we displayed as part of
         // handling the long-tap-up.
@@ -8467,17 +8468,17 @@ bool nsWindow::OnPointerEvents(UINT msg,
                    WidgetMouseEvent::eNoButtonFlag;
   WinPointerInfo pointerInfo(pointerId, penInfo.tiltX, penInfo.tiltY, pressure,
                              buttons);
 
   // The aLParam of WM_POINTER* is the screen location. Convert it to client
   // location
   LPARAM newLParam = lParamToClient(aLParam);
   DispatchMouseEvent(message, aWParam, newLParam, false, button,
-                     nsIDOMMouseEvent::MOZ_SOURCE_PEN, &pointerInfo);
+                     MouseEventBinding::MOZ_SOURCE_PEN, &pointerInfo);
   // Consume WM_POINTER* to stop Windows fires WM_*BUTTONDOWN / WM_*BUTTONUP
   // WM_MOUSEMOVE.
   return true;
 }
 
 void
 nsWindow::GetCompositorWidgetInitData(mozilla::widget::CompositorWidgetInitData* aInitData)
 {
--- a/widget/windows/nsWindow.h
+++ b/widget/windows/nsWindow.h
@@ -25,16 +25,17 @@
 #include "cairo.h"
 #include "nsITimer.h"
 #include "nsRegion.h"
 #include "mozilla/EventForwards.h"
 #include "mozilla/Maybe.h"
 #include "mozilla/MouseEvents.h"
 #include "mozilla/TimeStamp.h"
 #include "mozilla/webrender/WebRenderTypes.h"
+#include "mozilla/dom/MouseEventBinding.h"
 #include "nsMargin.h"
 #include "nsRegionFwd.h"
 
 #include "nsWinGesture.h"
 #include "WinPointerEvents.h"
 #include "WinUtils.h"
 #include "WindowHook.h"
 #include "TaskbarWindowPreview.h"
@@ -229,17 +230,17 @@ public:
   virtual bool            DispatchMouseEvent(
                             mozilla::EventMessage aEventMessage,
                             WPARAM wParam,
                             LPARAM lParam,
                             bool aIsContextMenuKey = false,
                             int16_t aButton =
                               mozilla::WidgetMouseEvent::eLeftButton,
                             uint16_t aInputSource =
-                              nsIDOMMouseEvent::MOZ_SOURCE_MOUSE,
+                              mozilla::dom::MouseEventBinding::MOZ_SOURCE_MOUSE,
                             WinPointerInfo* aPointerInfo = nullptr);
   virtual bool            DispatchWindowEvent(mozilla::WidgetGUIEvent* aEvent,
                                               nsEventStatus& aStatus);
   void                    DispatchPendingEvents();
   bool                    DispatchPluginEvent(UINT aMessage,
                                               WPARAM aWParam,
                                               LPARAM aLParam,
                                               bool aDispatchPendingEvents);