Bug 1455055 part 6. Clean up HandleEvent implementations in dom. r=masayuki
authorBoris Zbarsky <bzbarsky@mit.edu>
Fri, 20 Apr 2018 00:49:30 -0400
changeset 414636 491b4ebcc48a57315d0e19b31e99d8a62f911f5e
parent 414635 3f6f6c68e211b11ade14bf6cddd38426c73c63b0
child 414637 966c8536f1bda8ea929e552ee3a3e79331a33bdf
push id102390
push userbzbarsky@mozilla.com
push dateFri, 20 Apr 2018 04:55:09 +0000
treeherdermozilla-inbound@36f208401c87 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmasayuki
bugs1455055
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 1455055 part 6. Clean up HandleEvent implementations in dom. r=masayuki MozReview-Commit-ID: Ht7HQEhVS8E
dom/base/Navigator.cpp
dom/base/ScreenOrientation.cpp
dom/base/nsContentPermissionHelper.cpp
dom/events/JSEventHandler.cpp
dom/html/ImageDocument.cpp
dom/html/nsTextEditorState.cpp
dom/ipc/TabChild.cpp
dom/ipc/TabMessageUtils.h
dom/ipc/TabParent.cpp
dom/ipc/TelemetryScrollProbe.cpp
dom/ipc/TelemetryScrollProbe.h
dom/plugins/base/nsPluginInstanceOwner.cpp
dom/plugins/base/nsPluginInstanceOwner.h
dom/power/WakeLock.cpp
dom/smil/nsSMILTimeValueSpec.cpp
dom/smil/nsSMILTimeValueSpec.h
dom/webauthn/WebAuthnManagerBase.cpp
dom/xhr/XMLHttpRequestWorker.cpp
dom/xul/nsXULPopupListener.cpp
--- a/dom/base/Navigator.cpp
+++ b/dom/base/Navigator.cpp
@@ -700,17 +700,17 @@ MayVibrate(nsIDocument* doc) {
   // Hidden documents cannot start or stop a vibration.
   return (doc && !doc->Hidden());
 }
 
 NS_IMETHODIMP
 VibrateWindowListener::HandleEvent(Event* aEvent)
 {
   nsCOMPtr<nsIDocument> doc =
-    do_QueryInterface(aEvent->InternalDOMEvent()->GetTarget());
+    do_QueryInterface(aEvent->GetTarget());
 
   if (!MayVibrate(doc)) {
     // It's important that we call CancelVibrate(), not Vibrate() with an
     // empty list, because Vibrate() will fail if we're no longer focused, but
     // CancelVibrate() will succeed, so long as nobody else has started a new
     // vibration pattern.
     nsCOMPtr<nsPIDOMWindowInner> window = do_QueryReferent(mWindow);
     hal::CancelVibrate(window);
--- a/dom/base/ScreenOrientation.cpp
+++ b/dom/base/ScreenOrientation.cpp
@@ -599,17 +599,17 @@ ScreenOrientation::ShouldResistFingerpri
 
 NS_IMPL_ISUPPORTS(ScreenOrientation::VisibleEventListener, nsIDOMEventListener)
 
 NS_IMETHODIMP
 ScreenOrientation::VisibleEventListener::HandleEvent(Event* aEvent)
 {
   // Document may have become visible, if the page is visible, run the steps
   // following the "now visible algorithm" as specified.
-  nsCOMPtr<EventTarget> target = aEvent->InternalDOMEvent()->GetCurrentTarget();
+  nsCOMPtr<EventTarget> target = aEvent->GetCurrentTarget();
   MOZ_ASSERT(target);
 
   nsCOMPtr<nsIDocument> doc = do_QueryInterface(target);
   if (!doc || doc->Hidden()) {
     return NS_OK;
   }
 
   auto* win = nsGlobalWindowInner::Cast(doc->GetInnerWindow());
@@ -660,17 +660,17 @@ ScreenOrientation::FullScreenEventListen
 {
 #ifdef DEBUG
   nsAutoString eventType;
   aEvent->GetType(eventType);
 
   MOZ_ASSERT(eventType.EqualsLiteral("fullscreenchange"));
 #endif
 
-  nsCOMPtr<EventTarget> target = aEvent->InternalDOMEvent()->GetCurrentTarget();
+  nsCOMPtr<EventTarget> target = aEvent->GetCurrentTarget();
   MOZ_ASSERT(target);
 
   nsCOMPtr<nsIDocument> doc = do_QueryInterface(target);
   MOZ_ASSERT(doc);
 
   // We have to make sure that the event we got is the event sent when
   // fullscreen is disabled because we could get one when fullscreen
   // got enabled if the lock call is done at the same moment.
--- a/dom/base/nsContentPermissionHelper.cpp
+++ b/dom/base/nsContentPermissionHelper.cpp
@@ -76,18 +76,17 @@ NS_IMETHODIMP
 VisibilityChangeListener::HandleEvent(Event* aEvent)
 {
   nsAutoString type;
   aEvent->GetType(type);
   if (!type.EqualsLiteral(kVisibilityChange)) {
     return NS_ERROR_FAILURE;
   }
 
-  nsCOMPtr<nsIDocument> doc =
-    do_QueryInterface(aEvent->InternalDOMEvent()->GetTarget());
+  nsCOMPtr<nsIDocument> doc = do_QueryInterface(aEvent->GetTarget());
   MOZ_ASSERT(doc);
 
   if (mCallback) {
     mCallback->NotifyVisibility(!doc->Hidden());
   }
 
   return NS_OK;
 }
--- a/dom/events/JSEventHandler.cpp
+++ b/dom/events/JSEventHandler.cpp
@@ -114,18 +114,17 @@ nsresult
 JSEventHandler::HandleEvent(Event* aEvent)
 {
   nsCOMPtr<EventTarget> target = do_QueryInterface(mTarget);
   if (!target || !mTypedHandler.HasEventHandler() ||
       !GetTypedEventHandler().Ptr()->CallbackPreserveColor()) {
     return NS_ERROR_FAILURE;
   }
 
-  Event* event = aEvent->InternalDOMEvent();
-  bool isMainThread = event->IsMainThreadEvent();
+  bool isMainThread = aEvent->IsMainThreadEvent();
   bool isChromeHandler =
     isMainThread ?
       nsContentUtils::ObjectPrincipal(
         GetTypedEventHandler().Ptr()->CallbackPreserveColor()) ==
         nsContentUtils::GetSystemPrincipal() :
       mozilla::dom::IsCurrentThreadRunningChromeWorker();
 
   if (mTypedHandler.Type() == TypedEventHandler::eOnError) {
@@ -134,70 +133,70 @@ JSEventHandler::HandleEvent(Event* aEven
     nsString errorMsg, file;
     EventOrString msgOrEvent;
     Optional<nsAString> fileName;
     Optional<uint32_t> lineNumber;
     Optional<uint32_t> columnNumber;
     Optional<JS::Handle<JS::Value>> error;
 
     NS_ENSURE_TRUE(aEvent, NS_ERROR_UNEXPECTED);
-    ErrorEvent* scriptEvent = aEvent->InternalDOMEvent()->AsErrorEvent();
+    ErrorEvent* scriptEvent = aEvent->AsErrorEvent();
     if (scriptEvent) {
       scriptEvent->GetMessage(errorMsg);
       msgOrEvent.SetAsString().ShareOrDependUpon(errorMsg);
 
       scriptEvent->GetFilename(file);
       fileName = &file;
 
       lineNumber.Construct();
       lineNumber.Value() = scriptEvent->Lineno();
 
       columnNumber.Construct();
       columnNumber.Value() = scriptEvent->Colno();
 
       error.Construct(RootingCx());
       scriptEvent->GetError(&error.Value());
     } else {
-      msgOrEvent.SetAsEvent() = aEvent->InternalDOMEvent();
+      msgOrEvent.SetAsEvent() = aEvent;
     }
 
     RefPtr<OnErrorEventHandlerNonNull> handler =
       mTypedHandler.OnErrorEventHandler();
     ErrorResult rv;
     JS::Rooted<JS::Value> retval(RootingCx());
     handler->Call(mTarget, msgOrEvent, fileName, lineNumber,
                   columnNumber, error, &retval, rv);
     if (rv.Failed()) {
       return rv.StealNSResult();
     }
 
     if (retval.isBoolean() &&
         retval.toBoolean() == bool(scriptEvent)) {
-      event->PreventDefaultInternal(isChromeHandler);
+      aEvent->PreventDefaultInternal(isChromeHandler);
     }
     return NS_OK;
   }
 
   if (mTypedHandler.Type() == TypedEventHandler::eOnBeforeUnload) {
     MOZ_ASSERT(mEventName == nsGkAtoms::onbeforeunload);
 
     RefPtr<OnBeforeUnloadEventHandlerNonNull> handler =
       mTypedHandler.OnBeforeUnloadEventHandler();
     ErrorResult rv;
     nsString retval;
-    handler->Call(mTarget, *(aEvent->InternalDOMEvent()), retval, rv);
+    handler->Call(mTarget, *aEvent, retval, rv);
     if (rv.Failed()) {
       return rv.StealNSResult();
     }
 
-    BeforeUnloadEvent* beforeUnload = event->AsBeforeUnloadEvent();
+    BeforeUnloadEvent* beforeUnload = aEvent->AsBeforeUnloadEvent();
     NS_ENSURE_STATE(beforeUnload);
 
     if (!DOMStringIsNull(retval)) {
-      event->PreventDefaultInternal(isChromeHandler);
+      aEvent->PreventDefaultInternal(isChromeHandler);
 
       nsAutoString text;
       beforeUnload->GetReturnValue(text);
 
       // Set the text in the beforeUnload event as long as it wasn't
       // already set (through event.returnValue, which takes
       // precedence over a value returned from a JS function in IE)
       if (text.IsEmpty()) {
@@ -207,24 +206,24 @@ JSEventHandler::HandleEvent(Event* aEven
 
     return NS_OK;
   }
 
   MOZ_ASSERT(mTypedHandler.Type() == TypedEventHandler::eNormal);
   ErrorResult rv;
   RefPtr<EventHandlerNonNull> handler = mTypedHandler.NormalEventHandler();
   JS::Rooted<JS::Value> retval(RootingCx());
-  handler->Call(mTarget, *(aEvent->InternalDOMEvent()), &retval, rv);
+  handler->Call(mTarget, *aEvent, &retval, rv);
   if (rv.Failed()) {
     return rv.StealNSResult();
   }
 
   // If the handler returned false, then prevent default.
   if (retval.isBoolean() && !retval.toBoolean()) {
-    event->PreventDefaultInternal(isChromeHandler);
+    aEvent->PreventDefaultInternal(isChromeHandler);
   }
 
   return NS_OK;
 }
 
 } // namespace mozilla
 
 using namespace mozilla;
--- a/dom/html/ImageDocument.cpp
+++ b/dom/html/ImageDocument.cpp
@@ -639,17 +639,17 @@ ImageDocument::HandleEvent(Event* aEvent
   if (eventType.EqualsLiteral("resize")) {
     CheckOverflowing(false);
   }
   else if (eventType.EqualsLiteral("click") && mClickResizingEnabled) {
     ResetZoomLevel();
     mShouldResize = true;
     if (mImageIsResized) {
       int32_t x = 0, y = 0;
-      MouseEvent* event = aEvent->InternalDOMEvent()->AsMouseEvent();
+      MouseEvent* event = aEvent->AsMouseEvent();
       if (event) {
         RefPtr<HTMLImageElement> img =
           HTMLImageElement::FromNode(mImageContent);
         x = event->ClientX() - img->OffsetLeft();
         y = event->ClientY() - img->OffsetTop();
       }
       mShouldResize = false;
       RestoreImageTo(x, y);
--- a/dom/html/nsTextEditorState.cpp
+++ b/dom/html/nsTextEditorState.cpp
@@ -922,27 +922,21 @@ DoCommandCallback(Command aCommand, void
   if (commandEnabled) {
     controller->DoCommand(commandStr);
   }
 }
 
 NS_IMETHODIMP
 TextInputListener::HandleEvent(Event* aEvent)
 {
-  bool defaultPrevented = false;
-  nsresult rv = aEvent->GetDefaultPrevented(&defaultPrevented);
-  NS_ENSURE_SUCCESS(rv, rv);
-  if (defaultPrevented) {
+  if (aEvent->DefaultPrevented()) {
     return NS_OK;
   }
 
-  bool isTrusted = false;
-  rv = aEvent->GetIsTrusted(&isTrusted);
-  NS_ENSURE_SUCCESS(rv, rv);
-  if (!isTrusted) {
+  if (!aEvent->IsTrusted()) {
     return NS_OK;
   }
 
   WidgetKeyboardEvent* keyEvent =
     aEvent->WidgetEventPtr()->AsKeyboardEvent();
   if (!keyEvent) {
     return NS_ERROR_UNEXPECTED;
   }
--- a/dom/ipc/TabChild.cpp
+++ b/dom/ipc/TabChild.cpp
@@ -280,17 +280,17 @@ TabChildBase::ProcessUpdateFrame(const F
     FrameMetrics newMetrics = aFrameMetrics;
     APZCCallbackHelper::UpdateRootFrame(newMetrics);
 }
 
 NS_IMETHODIMP
 ContentListener::HandleEvent(Event* aEvent)
 {
   RemoteDOMEvent remoteEvent;
-  remoteEvent.mEvent = do_QueryInterface(aEvent);
+  remoteEvent.mEvent = aEvent;
   NS_ENSURE_STATE(remoteEvent.mEvent);
   mTabChild->SendEvent(remoteEvent);
   return NS_OK;
 }
 
 class TabChild::DelayedDeleteRunnable final
   : public Runnable
   , public nsIRunnablePriority
--- a/dom/ipc/TabMessageUtils.h
+++ b/dom/ipc/TabMessageUtils.h
@@ -3,27 +3,30 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #ifndef TABMESSAGE_UTILS_H
 #define TABMESSAGE_UTILS_H
 
 #include "ipc/IPCMessageUtils.h"
+#include "mozilla/RefPtr.h"
+#include "mozilla/dom/Event.h"
 #include "nsExceptionHandler.h"
-#include "nsIDOMEvent.h"
 #include "nsPIDOMWindow.h"
 #include "nsCOMPtr.h"
 
 namespace mozilla {
 namespace dom {
+class Event;
+
 struct RemoteDOMEvent
 {
   // Make sure to set the owner after deserializing.
-  nsCOMPtr<nsIDOMEvent> mEvent;
+  RefPtr<Event> mEvent;
 };
 
 bool ReadRemoteEvent(const IPC::Message* aMsg, PickleIterator* aIter,
                      mozilla::dom::RemoteDOMEvent* aResult);
 
 typedef CrashReporter::ThreadId NativeThreadId;
 
 } // namespace dom
--- a/dom/ipc/TabParent.cpp
+++ b/dom/ipc/TabParent.cpp
@@ -566,25 +566,25 @@ TabParent::RecvDropLinks(nsTArray<nsStri
     browser->DropLinks(aLinks.Length(), links.get(), triggeringPrincipal);
   }
   return IPC_OK();
 }
 
 mozilla::ipc::IPCResult
 TabParent::RecvEvent(const RemoteDOMEvent& aEvent)
 {
-  nsCOMPtr<nsIDOMEvent> event = do_QueryInterface(aEvent.mEvent);
+  RefPtr<Event> event = aEvent.mEvent;
   NS_ENSURE_TRUE(event, IPC_OK());
 
   nsCOMPtr<mozilla::dom::EventTarget> target = do_QueryInterface(mFrameElement);
   NS_ENSURE_TRUE(target, IPC_OK());
 
   event->SetOwner(target);
 
-  target->DispatchEvent(*event->InternalDOMEvent());
+  target->DispatchEvent(*event);
   return IPC_OK();
 }
 
 bool
 TabParent::SendLoadRemoteScript(const nsString& aURL,
                                 const bool& aRunInGlobalScope)
 {
   if (mCreatingWindow) {
--- a/dom/ipc/TelemetryScrollProbe.cpp
+++ b/dom/ipc/TelemetryScrollProbe.cpp
@@ -49,24 +49,23 @@ TelemetryScrollProbe::GetPresShell() con
   nsCOMPtr<nsIPresShell> result;
   if (nsCOMPtr<nsIDocument> doc = GetDocument()) {
     result = doc->GetShell();
   }
   return result.forget();
 }
 
 bool
-TelemetryScrollProbe::ShouldIgnore(nsIDOMEvent* aEvent) const
+TelemetryScrollProbe::ShouldIgnore(Event* aEvent) const
 {
-  nsCOMPtr<nsIDOMEventTarget> target;
-  aEvent->GetTarget(getter_AddRefs(target));
-  nsCOMPtr<nsIDocument> targetDocument = do_QueryInterface(target);
   RefPtr<nsIDocument> document = GetDocument();
 
-  return !document || targetDocument != document || nsContentUtils::IsSystemPrincipal(document->NodePrincipal());
+  return !document ||
+         aEvent->GetTarget() != document ||
+         nsContentUtils::IsSystemPrincipal(document->NodePrincipal());
 }
 
 NS_IMPL_ISUPPORTS(TelemetryScrollProbe, nsIDOMEventListener)
 
 NS_IMETHODIMP
 TelemetryScrollProbe::HandleEvent(Event* aEvent)
 {
   RefPtr<nsIPresShell> presShell = GetPresShell();
--- a/dom/ipc/TelemetryScrollProbe.h
+++ b/dom/ipc/TelemetryScrollProbe.h
@@ -5,23 +5,23 @@
  * You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #ifndef mozilla_dom_TelemetryScrollProbe_h
 #define mozilla_dom_TelemetryScrollProbe_h
 
 #include "nsIDOMEventListener.h"
 
 class nsIDocument;
-class nsIDOMEvent;
 class nsIPresShell;
 class nsIWebNavigation;
 
 namespace mozilla {
 namespace dom {
 
+class Event;
 class TabChildGlobal;
 
 /*
  * A class for implementing a telemetry scroll probe, listens to
  * pagehide events in a frame script context and records the
  * max scroll y, and amount of vertical scrolling that ocurred.
  * for more information see bug 1340904
  */
@@ -38,17 +38,17 @@ private:
       : mWebNav(aWebNav)
   { }
   ~TelemetryScrollProbe() {}
 
   already_AddRefed<nsIWebNavigation> GetWebNavigation() const;
   already_AddRefed<nsIDocument> GetDocument() const;
   already_AddRefed<nsIPresShell> GetPresShell() const;
 
-  bool ShouldIgnore(nsIDOMEvent* aEvent) const;
+  bool ShouldIgnore(Event* aEvent) const;
 
   nsWeakPtr mWebNav;
 };
 
 } // namespace dom
 } // namespace mozilla
 
 #endif // mozilla_dom_TelemetryScrollProbe_h
--- a/dom/plugins/base/nsPluginInstanceOwner.cpp
+++ b/dom/plugins/base/nsPluginInstanceOwner.cpp
@@ -1391,22 +1391,23 @@ nsPluginInstanceOwner::GetEventloopNesti
   // we make sure we always tear the plugin down eventually.
   if (!currentLevel) {
     currentLevel++;
   }
 
   return currentLevel;
 }
 
-nsresult nsPluginInstanceOwner::DispatchFocusToPlugin(nsIDOMEvent* aFocusEvent)
+nsresult nsPluginInstanceOwner::DispatchFocusToPlugin(Event* aFocusEvent)
 {
 #ifndef XP_MACOSX
   if (!mPluginWindow || (mPluginWindow->type == NPWindowTypeWindow)) {
     // continue only for cases without child window
-    return aFocusEvent->PreventDefault(); // consume event
+    aFocusEvent->PreventDefault(); // consume event
+    return NS_OK;
   }
 #endif
 
   WidgetEvent* theEvent = aFocusEvent->WidgetEventPtr();
   if (theEvent) {
     WidgetGUIEvent focusEvent(theEvent->IsTrusted(), theEvent->mMessage,
                               nullptr);
     nsEventStatus rv = ProcessEvent(focusEvent);
@@ -1414,17 +1415,17 @@ nsresult nsPluginInstanceOwner::Dispatch
       aFocusEvent->PreventDefault();
       aFocusEvent->StopPropagation();
     }
   }
 
   return NS_OK;
 }
 
-nsresult nsPluginInstanceOwner::ProcessKeyPress(nsIDOMEvent* aKeyEvent)
+nsresult nsPluginInstanceOwner::ProcessKeyPress(Event* aKeyEvent)
 {
 #ifdef XP_MACOSX
   return DispatchKeyToPlugin(aKeyEvent);
 #else
   if (SendNativeEvents())
     DispatchKeyToPlugin(aKeyEvent);
 
   if (mInstance) {
@@ -1432,21 +1433,23 @@ nsresult nsPluginInstanceOwner::ProcessK
     // Not actually sending keypress to the plugin, since we didn't before.
     aKeyEvent->PreventDefault();
     aKeyEvent->StopPropagation();
   }
   return NS_OK;
 #endif
 }
 
-nsresult nsPluginInstanceOwner::DispatchKeyToPlugin(nsIDOMEvent* aKeyEvent)
+nsresult nsPluginInstanceOwner::DispatchKeyToPlugin(Event* aKeyEvent)
 {
 #if !defined(XP_MACOSX)
-  if (!mPluginWindow || (mPluginWindow->type == NPWindowTypeWindow))
-    return aKeyEvent->PreventDefault(); // consume event
+  if (!mPluginWindow || (mPluginWindow->type == NPWindowTypeWindow)) {
+    aKeyEvent->PreventDefault(); // consume event
+    return NS_OK;
+  }
   // continue only for cases without child window
 #endif
 
   if (mInstance) {
     WidgetKeyboardEvent* keyEvent =
       aKeyEvent->WidgetEventPtr()->AsKeyboardEvent();
     if (keyEvent && keyEvent->mClass == eKeyboardEventClass) {
       nsEventStatus rv = ProcessEvent(*keyEvent);
@@ -1456,21 +1459,23 @@ nsresult nsPluginInstanceOwner::Dispatch
       }
     }
   }
 
   return NS_OK;
 }
 
 nsresult
-nsPluginInstanceOwner::ProcessMouseDown(nsIDOMEvent* aMouseEvent)
+nsPluginInstanceOwner::ProcessMouseDown(Event* aMouseEvent)
 {
 #if !defined(XP_MACOSX)
-  if (!mPluginWindow || (mPluginWindow->type == NPWindowTypeWindow))
-    return aMouseEvent->PreventDefault(); // consume event
+  if (!mPluginWindow || (mPluginWindow->type == NPWindowTypeWindow)) {
+    aMouseEvent->PreventDefault(); // consume event
+    return NS_OK;
+  }
   // continue only for cases without child window
 #endif
 
   // if the plugin is windowless, we need to set focus ourselves
   // otherwise, we might not get key events
   if (mPluginFrame && mPluginWindow &&
       mPluginWindow->type == NPWindowTypeDrawable) {
 
@@ -1482,29 +1487,32 @@ nsPluginInstanceOwner::ProcessMouseDown(
   }
 
   WidgetMouseEvent* mouseEvent =
     aMouseEvent->WidgetEventPtr()->AsMouseEvent();
   if (mouseEvent && mouseEvent->mClass == eMouseEventClass) {
     mLastMouseDownButtonType = mouseEvent->button;
     nsEventStatus rv = ProcessEvent(*mouseEvent);
     if (nsEventStatus_eConsumeNoDefault == rv) {
-      return aMouseEvent->PreventDefault(); // consume event
+      aMouseEvent->PreventDefault(); // consume event
+      return NS_OK;
     }
   }
 
   return NS_OK;
 }
 
-nsresult nsPluginInstanceOwner::DispatchMouseToPlugin(nsIDOMEvent* aMouseEvent,
+nsresult nsPluginInstanceOwner::DispatchMouseToPlugin(Event* aMouseEvent,
                                                       bool aAllowPropagate)
 {
 #if !defined(XP_MACOSX)
-  if (!mPluginWindow || (mPluginWindow->type == NPWindowTypeWindow))
-    return aMouseEvent->PreventDefault(); // consume event
+  if (!mPluginWindow || (mPluginWindow->type == NPWindowTypeWindow)) {
+    aMouseEvent->PreventDefault(); // consume event
+    return NS_OK;
+  }
   // continue only for cases without child window
 #endif
   // don't send mouse events if we are hidden
   if (!mWidgetVisible)
     return NS_OK;
 
   WidgetMouseEvent* mouseEvent =
     aMouseEvent->WidgetEventPtr()->AsMouseEvent();
@@ -1608,17 +1616,17 @@ nsPluginInstanceOwner::HandleNoConsumedC
     mSentStartComposition = true;
   }
 
   CallDefaultProc(aCompositionEvent);
 }
 #endif
 
 nsresult
-nsPluginInstanceOwner::DispatchCompositionToPlugin(nsIDOMEvent* aEvent)
+nsPluginInstanceOwner::DispatchCompositionToPlugin(Event* aEvent)
 {
 #ifdef XP_WIN
   if (!mPluginWindow) {
     // CompositionEvent isn't cancellable.  So it is unnecessary to call
     // PreventDefaults() to consume event
     return NS_OK;
   }
   WidgetCompositionEvent* compositionEvent =
@@ -1758,17 +1766,17 @@ nsPluginInstanceOwner::HandleEvent(Event
     return ProcessKeyPress(aEvent);
   }
   if (eventType.EqualsLiteral("compositionstart") ||
       eventType.EqualsLiteral("compositionend") ||
       eventType.EqualsLiteral("text")) {
     return DispatchCompositionToPlugin(aEvent);
   }
 
-  DragEvent* dragEvent = aEvent->InternalDOMEvent()->AsDragEvent();
+  DragEvent* dragEvent = aEvent->AsDragEvent();
   if (dragEvent && mInstance) {
     WidgetEvent* ievent = aEvent->WidgetEventPtr();
     if (ievent && ievent->IsTrusted() &&
         ievent->mMessage != eDragEnter && ievent->mMessage != eDragOver) {
       aEvent->PreventDefault();
     }
 
     // Let the plugin handle drag events.
--- a/dom/plugins/base/nsPluginInstanceOwner.h
+++ b/dom/plugins/base/nsPluginInstanceOwner.h
@@ -32,16 +32,17 @@ class nsDisplayListBuilder;
 
 #if defined(MOZ_X11)
 class gfxContext;
 #endif
 
 namespace mozilla {
 class TextComposition;
 namespace dom {
+class Event;
 struct MozPluginParameter;
 } // namespace dom
 namespace widget {
 class PuppetWidget;
 } // namespace widget
 } // namespace mozilla
 
 using mozilla::widget::PuppetWidget;
@@ -94,18 +95,18 @@ public:
    * @param aDOMElement - resulting DOM element
    * @result - NS_OK if this operation was successful
    */
   NS_IMETHOD GetDOMElement(nsIDOMElement* * aResult);
 
   // nsIDOMEventListener interfaces
   NS_DECL_NSIDOMEVENTLISTENER
 
-  nsresult ProcessMouseDown(nsIDOMEvent* aKeyEvent);
-  nsresult ProcessKeyPress(nsIDOMEvent* aKeyEvent);
+  nsresult ProcessMouseDown(mozilla::dom::Event* aMouseEvent);
+  nsresult ProcessKeyPress(mozilla::dom::Event* aKeyEvent);
   nsresult Destroy();
 
 #ifdef XP_WIN
   void Paint(const RECT& aDirty, HDC aDC);
 #elif defined(XP_MACOSX)
   void Paint(const gfxRect& aDirtyRect, CGContextRef cgContext);
   void RenderCoreAnimation(CGContextRef aCGContext, int aWidth, int aHeight);
   void DoCocoaEventDrawRect(const gfxRect& aDrawRect, CGContextRef cgContext);
@@ -339,21 +340,21 @@ private:
   // We hack around this by always returning true if we've ever
   // returned true.
   bool mUseAsyncRendering;
 #endif
 
   // pointer to wrapper for nsIDOMContextMenuListener
   RefPtr<nsPluginDOMContextMenuListener> mCXMenuListener;
 
-  nsresult DispatchKeyToPlugin(nsIDOMEvent* aKeyEvent);
-  nsresult DispatchMouseToPlugin(nsIDOMEvent* aMouseEvent,
+  nsresult DispatchKeyToPlugin(mozilla::dom::Event* aKeyEvent);
+  nsresult DispatchMouseToPlugin(mozilla::dom::Event* aMouseEvent,
                                  bool aAllowPropagate = false);
-  nsresult DispatchFocusToPlugin(nsIDOMEvent* aFocusEvent);
-  nsresult DispatchCompositionToPlugin(nsIDOMEvent* aEvent);
+  nsresult DispatchFocusToPlugin(mozilla::dom::Event* aFocusEvent);
+  nsresult DispatchCompositionToPlugin(mozilla::dom::Event* aEvent);
 
 #ifdef XP_WIN
   void CallDefaultProc(const mozilla::WidgetGUIEvent* aEvent);
 #endif
 
 #ifdef XP_MACOSX
   static NPBool ConvertPointPuppet(PuppetWidget *widget, nsPluginFrame* pluginFrame,
                             double sourceX, double sourceY, NPCoordinateSpace sourceSpace,
--- a/dom/power/WakeLock.cpp
+++ b/dom/power/WakeLock.cpp
@@ -224,18 +224,17 @@ WakeLock::GetTopic(nsAString &aTopic)
 
 NS_IMETHODIMP
 WakeLock::HandleEvent(Event *aEvent)
 {
   nsAutoString type;
   aEvent->GetType(type);
 
   if (type.EqualsLiteral("visibilitychange")) {
-    nsCOMPtr<nsIDocument> doc =
-      do_QueryInterface(aEvent->InternalDOMEvent()->GetTarget());
+    nsCOMPtr<nsIDocument> doc = do_QueryInterface(aEvent->GetTarget());
     NS_ENSURE_STATE(doc);
 
     bool oldHidden = mHidden;
     mHidden = doc->Hidden();
 
     if (mLocked && oldHidden != mHidden) {
       hal::ModifyWakeLock(mTopic,
                           hal::WAKE_LOCK_NO_CHANGE,
--- a/dom/smil/nsSMILTimeValueSpec.cpp
+++ b/dom/smil/nsSMILTimeValueSpec.cpp
@@ -365,19 +365,19 @@ nsSMILTimeValueSpec::HandleEvent(Event* 
   }
 
   RefPtr<nsSMILInstanceTime> newInstance =
     new nsSMILInstanceTime(newTime, nsSMILInstanceTime::SOURCE_EVENT);
   mOwner->AddInstanceTime(newInstance, mIsBegin);
 }
 
 bool
-nsSMILTimeValueSpec::CheckRepeatEventDetail(nsIDOMEvent *aEvent)
+nsSMILTimeValueSpec::CheckRepeatEventDetail(Event *aEvent)
 {
-  TimeEvent* timeEvent = aEvent->InternalDOMEvent()->AsTimeEvent();
+  TimeEvent* timeEvent = aEvent->AsTimeEvent();
   if (!timeEvent) {
     NS_WARNING("Received a repeat event that was not a DOMTimeEvent");
     return false;
   }
 
   int32_t detail = timeEvent->Detail();
   return detail > 0 && (uint32_t)detail == mParams.mRepeatIteration;
 }
--- a/dom/smil/nsSMILTimeValueSpec.h
+++ b/dom/smil/nsSMILTimeValueSpec.h
@@ -71,17 +71,17 @@ public:
 protected:
   void UpdateReferencedElement(Element* aFrom, Element* aTo);
   void UnregisterFromReferencedElement(Element* aElement);
   nsSMILTimedElement* GetTimedElement(Element* aElement);
   bool IsWhitelistedEvent();
   void RegisterEventListener(Element* aElement);
   void UnregisterEventListener(Element* aElement);
   void HandleEvent(Event* aEvent);
-  bool CheckRepeatEventDetail(nsIDOMEvent* aEvent);
+  bool CheckRepeatEventDetail(Event* aEvent);
   nsSMILTimeValue ConvertBetweenTimeContainers(const nsSMILTimeValue& aSrcTime,
                                       const nsSMILTimeContainer* aSrcContainer);
   bool ApplyOffset(nsSMILTimeValue& aTime) const;
 
   nsSMILTimedElement*           mOwner;
   bool                          mIsBegin; // Indicates if *we* are a begin spec,
                                           // not to be confused with
                                           // mParams.mSyncBegin which indicates
--- a/dom/webauthn/WebAuthnManagerBase.cpp
+++ b/dom/webauthn/WebAuthnManagerBase.cpp
@@ -128,18 +128,17 @@ WebAuthnManagerBase::HandleEvent(Event* 
   aEvent->GetType(type);
   if (!type.Equals(kDeactivateEvent) && !type.Equals(kVisibilityChange)) {
     return NS_ERROR_FAILURE;
   }
 
   // The "deactivate" event on the root window has no
   // "current inner window" and thus GetTarget() is always null.
   if (type.Equals(kVisibilityChange)) {
-    nsCOMPtr<nsIDocument> doc =
-      do_QueryInterface(aEvent->InternalDOMEvent()->GetTarget());
+    nsCOMPtr<nsIDocument> doc = do_QueryInterface(aEvent->GetTarget());
     if (NS_WARN_IF(!doc) || !doc->Hidden()) {
       return NS_OK;
     }
 
     nsGlobalWindowInner* win = nsGlobalWindowInner::Cast(doc->GetInnerWindow());
     if (NS_WARN_IF(!win) || !win->IsTopInnerWindow()) {
       return NS_OK;
     }
--- a/dom/xhr/XMLHttpRequestWorker.cpp
+++ b/dom/xhr/XMLHttpRequestWorker.cpp
@@ -988,24 +988,18 @@ Proxy::HandleEvent(Event* aEvent)
   }
 
   nsString type;
   if (NS_FAILED(aEvent->GetType(type))) {
     NS_WARNING("Failed to get event type!");
     return NS_ERROR_FAILURE;
   }
 
-  nsCOMPtr<nsIDOMEventTarget> target;
-  if (NS_FAILED(aEvent->GetTarget(getter_AddRefs(target)))) {
-    NS_WARNING("Failed to get target!");
-    return NS_ERROR_FAILURE;
-  }
-
-  bool isUploadTarget = mXHR != target;
-  ProgressEvent* progressEvent = aEvent->InternalDOMEvent()->AsProgressEvent();
+  bool isUploadTarget = mXHR != aEvent->GetTarget();
+  ProgressEvent* progressEvent = aEvent->AsProgressEvent();
 
   if (mInOpen && type.EqualsASCII(sEventStrings[STRING_readystatechange])) {
     if (mXHR->ReadyState() == 1) {
       mInnerEventStreamId++;
     }
   }
 
   {
--- a/dom/xul/nsXULPopupListener.cpp
+++ b/dom/xul/nsXULPopupListener.cpp
@@ -97,17 +97,17 @@ nsXULPopupListener::HandleEvent(Event* a
 {
   nsAutoString eventType;
   aEvent->GetType(eventType);
 
   if(!((eventType.EqualsLiteral("mousedown") && !mIsContext) ||
        (eventType.EqualsLiteral("contextmenu") && mIsContext)))
     return NS_OK;
 
-  MouseEvent* mouseEvent = aEvent->InternalDOMEvent()->AsMouseEvent();
+  MouseEvent* mouseEvent = aEvent->AsMouseEvent();
   if (!mouseEvent) {
     //non-ui event passed in.  bad things.
     return NS_OK;
   }
 
   // Get the node that was clicked on.
   EventTarget* target = mouseEvent->GetTarget();
   nsCOMPtr<nsIDOMNode> targetNode = do_QueryInterface(target);