[Bug 857884] Use dom::EventTarget more instead of nsIDOMEventTarget Part 6 r=Ms2ger
authorDavid Zbarsky <dzbarsky@gmail.com>
Fri, 19 Apr 2013 00:48:02 -0400
changeset 140242 f53ad2a10ff8bcdd821c51e5e3082eb56dc2fbb4
parent 140241 ec91252c57d2fcf3edc550fd35bb4bebbb4de981
child 140243 e57ac5581703ccfa76c5a95af5f8bceef5ac7a79
push id2579
push userakeybl@mozilla.com
push dateMon, 24 Jun 2013 18:52:47 +0000
treeherdermozilla-beta@b69b7de8a05a [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersMs2ger
bugs857884
milestone23.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 857884] Use dom::EventTarget more instead of nsIDOMEventTarget Part 6 r=Ms2ger
accessible/src/base/DocManager.cpp
content/base/src/WebSocket.cpp
content/base/src/nsCCUncollectableMarker.cpp
content/base/src/nsDOMFileReader.cpp
content/base/src/nsInProcessTabChildGlobal.cpp
content/events/src/nsDOMEvent.cpp
content/events/src/nsDOMTouchEvent.cpp
content/html/content/src/HTMLInputElement.cpp
content/html/content/src/HTMLInputElement.h
dom/base/nsWindowRoot.cpp
dom/bluetooth/BluetoothAdapter.h
dom/bluetooth/BluetoothDevice.h
dom/icc/src/IccManager.cpp
dom/icc/src/IccManager.h
dom/icc/src/StkCommandEvent.h
dom/indexedDB/AsyncConnectionHelper.cpp
dom/indexedDB/OpenDatabaseHelper.cpp
dom/indexedDB/ipc/IndexedDBChild.cpp
dom/indexedDB/ipc/IndexedDBParent.cpp
dom/ipc/TabChild.cpp
dom/network/src/MobileConnection.h
dom/system/nsDeviceSensors.cpp
dom/system/nsDeviceSensors.h
dom/telephony/Telephony.h
dom/telephony/TelephonyCall.h
extensions/widgetutils/src/nsWidgetUtils.cpp
layout/base/nsPresContext.cpp
layout/forms/nsComboboxControlFrame.cpp
layout/forms/nsFileControlFrame.cpp
layout/forms/nsListControlFrame.cpp
layout/forms/nsTextControlFrame.cpp
layout/generic/nsImageMap.cpp
layout/generic/nsObjectFrame.cpp
layout/mathml/nsMathMLmactionFrame.cpp
layout/printing/nsPrintEngine.cpp
layout/xul/base/src/nsListBoxBodyFrame.cpp
layout/xul/base/src/nsMenuBarFrame.cpp
layout/xul/base/src/nsMenuBarFrame.h
layout/xul/base/src/nsMenuBarListener.h
layout/xul/base/src/nsMenuPopupFrame.h
layout/xul/base/src/nsSliderFrame.cpp
layout/xul/base/src/nsSplitterFrame.cpp
layout/xul/base/src/nsXULTooltipListener.cpp
toolkit/components/satchel/nsFormFillController.cpp
toolkit/components/satchel/nsFormFillController.h
--- a/accessible/src/base/DocManager.cpp
+++ b/accessible/src/base/DocManager.cpp
@@ -20,24 +20,24 @@
 
 #include "nsCURILoader.h"
 #include "nsDocShellLoadTypes.h"
 #include "nsDOMEvent.h"
 #include "nsIChannel.h"
 #include "nsIContentViewer.h"
 #include "nsIDOMDocument.h"
 #include "nsEventListenerManager.h"
-#include "nsIDOMEventTarget.h"
 #include "nsIDOMWindow.h"
 #include "nsIInterfaceRequestorUtils.h"
 #include "nsIWebNavigation.h"
 #include "nsServiceManagerUtils.h"
 
 using namespace mozilla;
 using namespace mozilla::a11y;
+using namespace mozilla::dom;
 
 ////////////////////////////////////////////////////////////////////////////////
 // DocManager
 ////////////////////////////////////////////////////////////////////////////////
 
 ////////////////////////////////////////////////////////////////////////////////
 // DocManager public
 
@@ -321,18 +321,18 @@ DocManager::HandleDOMDocumentLoad(nsIDoc
 
   docAcc->NotifyOfLoad(aLoadEventType);
 }
 
 void
 DocManager::AddListeners(nsIDocument* aDocument,
                          bool aAddDOMContentLoadedListener)
 {
-  nsPIDOMWindow *window = aDocument->GetWindow();
-  nsIDOMEventTarget *target = window->GetChromeEventHandler();
+  nsPIDOMWindow* window = aDocument->GetWindow();
+  EventTarget* target = window->GetChromeEventHandler();
   nsEventListenerManager* elm = target->GetListenerManager(true);
   elm->AddEventListenerByType(this, NS_LITERAL_STRING("pagehide"),
                               dom::TrustedEventsAtCapture());
 
 #ifdef A11Y_LOG
   if (logging::IsEnabled(logging::eDocCreate))
     logging::Text("added 'pagehide' listener");
 #endif
@@ -349,17 +349,17 @@ DocManager::AddListeners(nsIDocument* aD
 
 void
 DocManager::RemoveListeners(nsIDocument* aDocument)
 {
   nsPIDOMWindow* window = aDocument->GetWindow();
   if (!window)
     return;
 
-  nsIDOMEventTarget* target = window->GetChromeEventHandler();
+  EventTarget* target = window->GetChromeEventHandler();
   nsEventListenerManager* elm = target->GetListenerManager(true);
   elm->RemoveEventListenerByType(this, NS_LITERAL_STRING("pagehide"),
                                  dom::TrustedEventsAtCapture());
 
   elm->RemoveEventListenerByType(this, NS_LITERAL_STRING("DOMContentLoaded"),
                                  dom::TrustedEventsAtCapture());
 }
 
--- a/content/base/src/WebSocket.cpp
+++ b/content/base/src/WebSocket.cpp
@@ -1094,30 +1094,30 @@ WebSocket::UpdateMustKeepAlive()
       {
         shouldKeepAlive = false;
       }
     }
   }
 
   if (mKeepingAlive && !shouldKeepAlive) {
     mKeepingAlive = false;
-    static_cast<nsIDOMEventTarget*>(this)->Release();
+    static_cast<EventTarget*>(this)->Release();
   } else if (!mKeepingAlive && shouldKeepAlive) {
     mKeepingAlive = true;
-    static_cast<nsIDOMEventTarget*>(this)->AddRef();
+    static_cast<EventTarget*>(this)->AddRef();
   }
 }
 
 void
 WebSocket::DontKeepAliveAnyMore()
 {
   NS_ABORT_IF_FALSE(NS_IsMainThread(), "Not running on main thread");
   if (mKeepingAlive) {
     mKeepingAlive = false;
-    static_cast<nsIDOMEventTarget*>(this)->Release();
+    static_cast<EventTarget*>(this)->Release();
   }
   mCheckMustKeepAlive = false;
 }
 
 nsresult
 WebSocket::UpdateURI()
 {
   // Check for Redirections
--- a/content/base/src/nsCCUncollectableMarker.cpp
+++ b/content/base/src/nsCCUncollectableMarker.cpp
@@ -130,17 +130,17 @@ MarkMessageManagers()
       strongTabMM = nullptr;
       tabMM->MarkForCC();
       //XXX hack warning, but works, since we know that
       //    callback is frameloader.
       mozilla::dom::ipc::MessageManagerCallback* cb =
         static_cast<nsFrameMessageManager*>(tabMM)->GetCallback();
       if (cb) {
         nsFrameLoader* fl = static_cast<nsFrameLoader*>(cb);
-        nsIDOMEventTarget* et = fl->GetTabChildGlobalAsEventTarget();
+        EventTarget* et = fl->GetTabChildGlobalAsEventTarget();
         if (!et) {
           continue;
         }
         static_cast<nsInProcessTabChildGlobal*>(et)->MarkForCC();
         nsEventListenerManager* elm = et->GetListenerManager(false);
         if (elm) {
           elm->MarkForCC();
         }
--- a/content/base/src/nsDOMFileReader.cpp
+++ b/content/base/src/nsDOMFileReader.cpp
@@ -90,26 +90,26 @@ NS_IMPL_EVENT_HANDLER(nsDOMFileReader, l
 NS_IMPL_FORWARD_EVENT_HANDLER(nsDOMFileReader, abort, FileIOObject)
 NS_IMPL_FORWARD_EVENT_HANDLER(nsDOMFileReader, progress, FileIOObject)
 NS_IMPL_FORWARD_EVENT_HANDLER(nsDOMFileReader, error, FileIOObject)
 
 void
 nsDOMFileReader::RootResultArrayBuffer()
 {
   nsContentUtils::PreserveWrapper(
-    static_cast<nsIDOMEventTarget*>(
+    static_cast<EventTarget*>(
       static_cast<nsDOMEventTargetHelper*>(this)), this);
 }
 
 //nsDOMFileReader constructors/initializers
 
 nsDOMFileReader::nsDOMFileReader()
   : mFileData(nullptr),
     mDataLen(0), mDataFormat(FILE_AS_BINARY),
-    mResultArrayBuffer(nullptr)     
+    mResultArrayBuffer(nullptr)
 {
   nsLayoutStatics::AddRef();
   SetDOMStringToNull(mResult);
   SetIsDOMBinding();
 }
 
 nsDOMFileReader::~nsDOMFileReader()
 {
--- a/content/base/src/nsInProcessTabChildGlobal.cpp
+++ b/content/base/src/nsInProcessTabChildGlobal.cpp
@@ -241,20 +241,19 @@ nsInProcessTabChildGlobal::DelayedDiscon
   mChromeMessageManager = nullptr;
   if (mMessageManager) {
     static_cast<nsFrameMessageManager*>(mMessageManager.get())->Disconnect();
     mMessageManager = nullptr;
   }
   if (mListenerManager) {
     mListenerManager->Disconnect();
   }
-  
+
   if (!mLoadingScript) {
-    nsContentUtils::ReleaseWrapper(static_cast<nsIDOMEventTarget*>(this),
-                                   this);
+    nsContentUtils::ReleaseWrapper(static_cast<EventTarget*>(this), this);
     if (mCx) {
       DestroyCx();
     }
   } else {
     mDelayedDisconnect = true;
   }
 }
 
@@ -304,18 +303,17 @@ nsInProcessTabChildGlobal::InitTabChildG
   id.AssignLiteral("inProcessTabChildGlobal");
   nsIURI* uri = mOwner->OwnerDoc()->GetDocumentURI();
   if (uri) {
     nsAutoCString u;
     uri->GetSpec(u);
     id.AppendLiteral("?ownedBy=");
     id.Append(u);
   }
-  nsISupports* scopeSupports =
-    NS_ISUPPORTS_CAST(nsIDOMEventTarget*, this);
+  nsISupports* scopeSupports = NS_ISUPPORTS_CAST(EventTarget*, this);
   NS_ENSURE_STATE(InitTabChildGlobalInternal(scopeSupports, id));
   return NS_OK;
 }
 
 class nsAsyncScriptLoad : public nsRunnable
 {
 public:
   nsAsyncScriptLoad(nsInProcessTabChildGlobal* aTabChild, const nsAString& aURL)
--- a/content/events/src/nsDOMEvent.cpp
+++ b/content/events/src/nsDOMEvent.cpp
@@ -455,17 +455,17 @@ nsDOMEvent::StopImmediatePropagation()
 {
   mEvent->mFlags.mPropagationStopped = true;
   mEvent->mFlags.mImmediatePropagationStopped = true;
   return NS_OK;
 }
 
 static nsIDocument* GetDocumentForReport(nsEvent* aEvent)
 {
-  nsIDOMEventTarget* target = aEvent->currentTarget;
+  EventTarget* target = aEvent->currentTarget;
   if (nsCOMPtr<nsINode> node = do_QueryInterface(target)) {
     return node->OwnerDoc();
   }
 
   if (nsCOMPtr<nsPIDOMWindow> window = do_QueryInterface(target)) {
     return window->GetExtantDoc();
   }
 
--- a/content/events/src/nsDOMTouchEvent.cpp
+++ b/content/events/src/nsDOMTouchEvent.cpp
@@ -9,16 +9,17 @@
 #include "nsIClassInfo.h"
 #include "nsIXPCScriptable.h"
 #include "nsContentUtils.h"
 #include "mozilla/Preferences.h"
 #include "nsPresContext.h"
 #include "mozilla/dom/Touch.h"
 
 using namespace mozilla;
+using namespace mozilla::dom;
 
 // TouchList
 nsDOMTouchList::nsDOMTouchList(nsTArray<nsCOMPtr<nsIDOMTouch> > &aTouches)
 {
   mPoints.AppendElements(aTouches);
   nsJSContext::LikelyShortLivingObjectCreated();
 }
 
@@ -190,17 +191,17 @@ nsDOMTouchEvent::GetTargetTouches(nsIDOM
   nsTArray<nsCOMPtr<nsIDOMTouch> > targetTouches;
   nsTouchEvent* touchEvent = static_cast<nsTouchEvent*>(mEvent);
   const nsTArray<nsCOMPtr<nsIDOMTouch> >& touches = touchEvent->touches;
   for (uint32_t i = 0; i < touches.Length(); ++i) {
     // for touchend/cancel events, don't append to the target list if this is a
     // touch that is ending
     if ((mEvent->message != NS_TOUCH_END &&
          mEvent->message != NS_TOUCH_CANCEL) || !touches[i]->mChanged) {
-      nsIDOMEventTarget* targetPtr = touches[i]->GetTarget();
+      EventTarget* targetPtr = touches[i]->GetTarget();
       if (targetPtr == mEvent->originalTarget) {
         targetTouches.AppendElement(touches[i]);
       }
     }
   }
   mTargetTouches = new nsDOMTouchList(targetTouches);
   return CallQueryInterface(mTargetTouches, aTargetTouches);
 }
--- a/content/html/content/src/HTMLInputElement.cpp
+++ b/content/html/content/src/HTMLInputElement.cpp
@@ -2780,17 +2780,17 @@ IsLTR(Element* aElement)
   if (frame) {
     return frame->StyleVisibility()->mDirection == NS_STYLE_DIRECTION_LTR;
   }
   // at least for HTML, directionality is exclusively LTR or RTL
   return aElement->GetDirectionality() == eDir_LTR;
 }
 
 bool
-HTMLInputElement::ShouldPreventDOMActivateDispatch(nsIDOMEventTarget* aOriginalTarget)
+HTMLInputElement::ShouldPreventDOMActivateDispatch(EventTarget* aOriginalTarget)
 {
   /*
    * For the moment, there is only one situation where we actually want to
    * prevent firing a DOMActivate event:
    *  - we are a <input type='file'> that just got a click event,
    *  - the event was targeted to our button which should have sent a
    *    DOMActivate event.
    */
--- a/content/html/content/src/HTMLInputElement.h
+++ b/content/html/content/src/HTMLInputElement.h
@@ -1065,17 +1065,17 @@ protected:
            aType == NS_FORM_INPUT_TIME;
   }
 
   /**
    * Returns true if the element should prevent dispatching another DOMActivate.
    * This is used in situations where the anonymous subtree should already have
    * sent a DOMActivate and prevents firing more than once.
    */
-  bool ShouldPreventDOMActivateDispatch(nsIDOMEventTarget* aOriginalTarget);
+  bool ShouldPreventDOMActivateDispatch(EventTarget* aOriginalTarget);
 
   nsCOMPtr<nsIControllers> mControllers;
 
   /*
    * In mInputData, the mState field is used if IsSingleLineTextControl returns
    * true and mValue is used otherwise.  We have to be careful when handling it
    * on a type change.
    *
--- a/dom/base/nsWindowRoot.cpp
+++ b/dom/base/nsWindowRoot.cpp
@@ -73,28 +73,28 @@ nsWindowRoot::RemoveEventListener(const 
 
 NS_IMPL_REMOVE_SYSTEM_EVENT_LISTENER(nsWindowRoot)
 
 NS_IMETHODIMP
 nsWindowRoot::DispatchEvent(nsIDOMEvent* aEvt, bool *aRetVal)
 {
   nsEventStatus status = nsEventStatus_eIgnore;
   nsresult rv =  nsEventDispatcher::DispatchDOMEvent(
-    static_cast<nsIDOMEventTarget*>(this), nullptr, aEvt, nullptr, &status);
+    static_cast<EventTarget*>(this), nullptr, aEvt, nullptr, &status);
   *aRetVal = (status != nsEventStatus_eConsumeNoDefault);
   return rv;
 }
 
 nsresult
 nsWindowRoot::DispatchDOMEvent(nsEvent* aEvent,
                                nsIDOMEvent* aDOMEvent,
                                nsPresContext* aPresContext,
                                nsEventStatus* aEventStatus)
 {
-  return nsEventDispatcher::DispatchDOMEvent(static_cast<nsIDOMEventTarget*>(this),
+  return nsEventDispatcher::DispatchDOMEvent(static_cast<EventTarget*>(this),
                                              aEvent, aDOMEvent,
                                              aPresContext, aEventStatus);
 }
 
 NS_IMETHODIMP
 nsWindowRoot::AddEventListener(const nsAString& aType,
                                nsIDOMEventListener *aListener,
                                bool aUseCapture, bool aWantsUntrusted,
@@ -144,17 +144,17 @@ nsWindowRoot::AddSystemEventListener(con
                                    aWantsUntrusted);
 }
 
 nsEventListenerManager*
 nsWindowRoot::GetListenerManager(bool aCreateIfNotFound)
 {
   if (!mListenerManager && aCreateIfNotFound) {
     mListenerManager =
-      new nsEventListenerManager(static_cast<nsIDOMEventTarget*>(this));
+      new nsEventListenerManager(static_cast<EventTarget*>(this));
   }
 
   return mListenerManager;
 }
 
 nsIScriptContext*
 nsWindowRoot::GetContextForEventHandlers(nsresult* aRv)
 {
--- a/dom/bluetooth/BluetoothAdapter.h
+++ b/dom/bluetooth/BluetoothAdapter.h
@@ -36,33 +36,26 @@ public:
   NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS_INHERITED(BluetoothAdapter,
                                                          nsDOMEventTargetHelper)
 
   static already_AddRefed<BluetoothAdapter>
   Create(nsPIDOMWindow* aOwner, const BluetoothValue& aValue);
 
   void Notify(const BluetoothSignal& aParam);
 
-  nsIDOMEventTarget*
-  ToIDOMEventTarget() const
+  nsISupports*
+  ToISupports()
   {
-    return static_cast<nsDOMEventTargetHelper*>(
-      const_cast<BluetoothAdapter*>(this));
-  }
-
-  nsISupports*
-  ToISupports() const
-  {
-    return ToIDOMEventTarget();
+    return static_cast<EventTarget*>(this);
   }
 
   void Unroot();
   virtual void SetPropertyByValue(const BluetoothNamedValue& aValue);  
 private:
-  
+
   BluetoothAdapter(nsPIDOMWindow* aOwner, const BluetoothValue& aValue);
   ~BluetoothAdapter();
 
   void Root();
   nsresult StartStopDiscovery(bool aStart, nsIDOMDOMRequest** aRequest);
   nsresult PairUnpair(bool aPair,
                       nsIDOMBluetoothDevice* aDevice,
                       nsIDOMDOMRequest** aRequest);
--- a/dom/bluetooth/BluetoothDevice.h
+++ b/dom/bluetooth/BluetoothDevice.h
@@ -37,38 +37,31 @@ public:
                                                          nsDOMEventTargetHelper)
 
   static already_AddRefed<BluetoothDevice>
   Create(nsPIDOMWindow* aOwner, const nsAString& aAdapterPath,
          const BluetoothValue& aValue);
 
   void Notify(const BluetoothSignal& aParam);
 
-  nsIDOMEventTarget*
-  ToIDOMEventTarget() const
+  nsISupports*
+  ToISupports()
   {
-    return static_cast<nsDOMEventTargetHelper*>(
-      const_cast<BluetoothDevice*>(this));
-  }
-
-  nsISupports*
-  ToISupports() const
-  {
-    return ToIDOMEventTarget();
+    return static_cast<EventTarget*>(this);
   }
 
   void SetPropertyByValue(const BluetoothNamedValue& aValue);
 
   void Unroot();
 private:
   BluetoothDevice(nsPIDOMWindow* aOwner, const nsAString& aAdapterPath,
                   const BluetoothValue& aValue);
   ~BluetoothDevice();
   void Root();
-  
+
   JSObject* mJsUuids;
   JSObject* mJsServices;
 
   nsString mAdapterPath;
   nsString mAddress;
   nsString mName;
   nsString mIcon;
   uint32_t mClass;
--- a/dom/icc/src/IccManager.cpp
+++ b/dom/icc/src/IccManager.cpp
@@ -176,16 +176,16 @@ NS_IMPL_EVENT_HANDLER(IccManager, stkses
 // nsIIccListener
 
 NS_IMETHODIMP
 IccManager::NotifyStkCommand(const nsAString& aMessage)
 {
   nsRefPtr<StkCommandEvent> event = StkCommandEvent::Create(this, aMessage);
   NS_ASSERTION(event, "This should never fail!");
 
-  return event->Dispatch(ToIDOMEventTarget(), NS_LITERAL_STRING("stkcommand"));
+  return event->Dispatch(this, NS_LITERAL_STRING("stkcommand"));
 }
 
 NS_IMETHODIMP
 IccManager::NotifyStkSessionEnd()
 {
   return DispatchTrustedEvent(NS_LITERAL_STRING("stksessionend"));
 }
--- a/dom/icc/src/IccManager.h
+++ b/dom/icc/src/IccManager.h
@@ -35,22 +35,15 @@ public:
   IccManager();
 
   void Init(nsPIDOMWindow *aWindow);
   void Shutdown();
 
 private:
   nsCOMPtr<nsIIccProvider> mProvider;
   nsRefPtr<Listener> mListener;
-
-  nsIDOMEventTarget*
-  ToIDOMEventTarget() const
-  {
-    return static_cast<nsDOMEventTargetHelper*>(
-           const_cast<IccManager*>(this));
-  }
 };
 
 } // namespace icc
 } // namespace dom
 } // namespace mozilla
 
 #endif // mozilla_dom_icc_IccManager_h
--- a/dom/icc/src/StkCommandEvent.h
+++ b/dom/icc/src/StkCommandEvent.h
@@ -19,20 +19,20 @@ class StkCommandEvent : public nsDOMEven
 
 public:
   NS_DECL_ISUPPORTS_INHERITED
   NS_FORWARD_TO_NSDOMEVENT
   NS_DECL_NSIDOMMOZSTKCOMMANDEVENT
   NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(StkCommandEvent, nsDOMEvent)
 
   static already_AddRefed<StkCommandEvent>
-  Create(mozilla::dom::EventTarget* aOwner, const nsAString& aMessage);
+  Create(EventTarget* aOwner, const nsAString& aMessage);
 
   nsresult
-  Dispatch(nsIDOMEventTarget* aTarget, const nsAString& aEventType)
+  Dispatch(EventTarget* aTarget, const nsAString& aEventType)
   {
     NS_ASSERTION(aTarget, "Null pointer!");
     NS_ASSERTION(!aEventType.IsEmpty(), "Empty event type!");
 
     nsresult rv = InitEvent(aEventType, false, false);
     NS_ENSURE_SUCCESS(rv, rv);
 
     SetTrusted(true);
--- a/dom/indexedDB/AsyncConnectionHelper.cpp
+++ b/dom/indexedDB/AsyncConnectionHelper.cpp
@@ -97,17 +97,17 @@ HelperBase::~HelperBase()
     mRequest.forget(&request);
 
     if (request) {
       nsCOMPtr<nsIThread> mainThread;
       NS_GetMainThread(getter_AddRefs(mainThread));
       NS_WARN_IF_FALSE(mainThread, "Couldn't get the main thread!");
 
       if (mainThread) {
-        NS_ProxyRelease(mainThread, static_cast<nsIDOMEventTarget*>(request));
+        NS_ProxyRelease(mainThread, static_cast<EventTarget*>(request));
       }
     }
   }
 }
 
 nsresult
 HelperBase::WrapNative(JSContext* aCx,
                        nsISupports* aNative,
--- a/dom/indexedDB/OpenDatabaseHelper.cpp
+++ b/dom/indexedDB/OpenDatabaseHelper.cpp
@@ -20,16 +20,17 @@
 #include "Client.h"
 #include "nsIBFCacheEntry.h"
 #include "IDBEvents.h"
 #include "IDBFactory.h"
 #include "IndexedDatabaseManager.h"
 #include <algorithm>
 
 using namespace mozilla;
+using namespace mozilla::dom;
 USING_INDEXEDDB_NAMESPACE
 USING_QUOTA_NAMESPACE
 
 namespace {
 
 // If JS_STRUCTURED_CLONE_VERSION changes then we need to update our major
 // schema version.
 MOZ_STATIC_ASSERT(JS_STRUCTURED_CLONE_VERSION == 2,
@@ -2242,17 +2243,17 @@ OpenDatabaseHelper::GetSuccessResult(JSC
                                      jsval* aVal)
 {
   // Be careful not to load the database twice.
   if (!mDatabase) {
     nsresult rv = EnsureSuccessResult();
     NS_ENSURE_SUCCESS(rv, rv);
   }
 
-  return WrapNative(aCx, NS_ISUPPORTS_CAST(nsIDOMEventTarget*, mDatabase),
+  return WrapNative(aCx, NS_ISUPPORTS_CAST(EventTarget*, mDatabase),
                     aVal);
 }
 
 nsresult
 OpenDatabaseHelper::NotifySetVersionFinished()
 {
   NS_ASSERTION(NS_IsMainThread(), "Wrong thread");
   NS_ASSERTION(mState = eSetVersionPending, "How did we get here?");
@@ -2377,17 +2378,17 @@ SetVersionHelper::GetSuccessResult(JSCon
 {
   DatabaseInfo* info = mDatabase->Info();
   info->version = mRequestedVersion;
 
   NS_ASSERTION(mTransaction, "Better have a transaction!");
 
   mOpenRequest->SetTransaction(mTransaction);
 
-  return WrapNative(aCx, NS_ISUPPORTS_CAST(nsIDOMEventTarget*, mDatabase),
+  return WrapNative(aCx, NS_ISUPPORTS_CAST(EventTarget*, mDatabase),
                     aVal);
 }
 
 nsresult
 SetVersionHelper::OnExclusiveAccessAcquired()
 {
   nsresult rv = DispatchToTransactionPool();
   NS_ENSURE_SUCCESS(rv, rv);
--- a/dom/indexedDB/ipc/IndexedDBChild.cpp
+++ b/dom/indexedDB/ipc/IndexedDBChild.cpp
@@ -1291,17 +1291,17 @@ IPCOpenDatabaseHelper::DoDatabaseWork(mo
 {
   MOZ_NOT_REACHED("Don't call me!");
   return NS_ERROR_FAILURE;
 }
 
 nsresult
 IPCOpenDatabaseHelper::GetSuccessResult(JSContext* aCx, jsval* aVal)
 {
-  return WrapNative(aCx, NS_ISUPPORTS_CAST(nsIDOMEventTarget*, mDatabase),
+  return WrapNative(aCx, NS_ISUPPORTS_CAST(EventTarget*, mDatabase),
                     aVal);
 }
 
 nsresult
 IPCSetVersionHelper::UnpackResponseFromParentProcess(
                                             const ResponseValue& aResponseValue)
 {
   NS_NOTREACHED("Should never get here!");
@@ -1330,17 +1330,17 @@ IPCSetVersionHelper::CreateSuccessEvent(
                                                     mRequestedVersion);
 }
 
 nsresult
 IPCSetVersionHelper::GetSuccessResult(JSContext* aCx, jsval* aVal)
 {
   mOpenRequest->SetTransaction(mTransaction);
 
-  return WrapNative(aCx, NS_ISUPPORTS_CAST(nsIDOMEventTarget*, mDatabase),
+  return WrapNative(aCx, NS_ISUPPORTS_CAST(EventTarget*, mDatabase),
                     aVal);
 }
 
 nsresult
 IPCDeleteDatabaseHelper::UnpackResponseFromParentProcess(
                                             const ResponseValue& aResponseValue)
 {
   MOZ_NOT_REACHED("Don't call me!");
--- a/dom/indexedDB/ipc/IndexedDBParent.cpp
+++ b/dom/indexedDB/ipc/IndexedDBParent.cpp
@@ -252,32 +252,30 @@ IndexedDBDatabaseParent::~IndexedDBDatab
 }
 
 nsresult
 IndexedDBDatabaseParent::SetOpenRequest(IDBOpenDBRequest* aRequest)
 {
   MOZ_ASSERT(aRequest);
   MOZ_ASSERT(!mOpenRequest);
 
-  nsIDOMEventTarget* target = static_cast<nsIDOMEventTarget*>(aRequest);
-
-  nsresult rv = target->AddEventListener(NS_LITERAL_STRING(SUCCESS_EVT_STR),
-                                         mEventListener, false);
+  nsresult rv = aRequest->EventTarget::AddEventListener(NS_LITERAL_STRING(SUCCESS_EVT_STR),
+                                                        mEventListener, false);
+  NS_ENSURE_SUCCESS(rv, rv);
+
+  rv = aRequest->EventTarget::AddEventListener(NS_LITERAL_STRING(ERROR_EVT_STR),
+                                               mEventListener, false);
   NS_ENSURE_SUCCESS(rv, rv);
 
-  rv = target->AddEventListener(NS_LITERAL_STRING(ERROR_EVT_STR),
-                                mEventListener, false);
+  rv = aRequest->EventTarget::AddEventListener(NS_LITERAL_STRING(BLOCKED_EVT_STR),
+                                               mEventListener, false);
   NS_ENSURE_SUCCESS(rv, rv);
 
-  rv = target->AddEventListener(NS_LITERAL_STRING(BLOCKED_EVT_STR),
-                                mEventListener, false);
-  NS_ENSURE_SUCCESS(rv, rv);
-
-  rv = target->AddEventListener(NS_LITERAL_STRING(UPGRADENEEDED_EVT_STR),
-                                mEventListener, false);
+  rv = aRequest->EventTarget::AddEventListener(NS_LITERAL_STRING(UPGRADENEEDED_EVT_STR),
+                                               mEventListener, false);
   NS_ENSURE_SUCCESS(rv, rv);
 
   mOpenRequest = aRequest;
   return NS_OK;
 }
 
 nsresult
 IndexedDBDatabaseParent::HandleEvent(nsIDOMEvent* aEvent)
@@ -291,26 +289,26 @@ IndexedDBDatabaseParent::HandleEvent(nsI
 
   nsString type;
   nsresult rv = aEvent->GetType(type);
   NS_ENSURE_SUCCESS(rv, rv);
 
   nsCOMPtr<EventTarget> target = aEvent->InternalDOMEvent()->GetTarget();
 
   if (mDatabase &&
-      SameCOMIdentity(target, NS_ISUPPORTS_CAST(nsIDOMEventTarget*,
+      SameCOMIdentity(target, NS_ISUPPORTS_CAST(EventTarget*,
                                                 mDatabase))) {
     rv = HandleDatabaseEvent(aEvent, type);
     NS_ENSURE_SUCCESS(rv, rv);
 
     return NS_OK;
   }
 
   if (mOpenRequest &&
-      SameCOMIdentity(target, NS_ISUPPORTS_CAST(nsIDOMEventTarget*,
+      SameCOMIdentity(target, NS_ISUPPORTS_CAST(EventTarget*,
                                                 mOpenRequest))) {
     rv = HandleRequestEvent(aEvent, type);
     NS_ENSURE_SUCCESS(rv, rv);
 
     return NS_OK;
   }
 
   MOZ_NOT_REACHED("Unexpected message!");
@@ -433,18 +431,18 @@ IndexedDBDatabaseParent::HandleRequestEv
       objectStoreInfos.AppendElement(*osInfo);
     }
   }
 
   if (aType.EqualsLiteral(SUCCESS_EVT_STR)) {
     nsRefPtr<IDBOpenDBRequest> request;
     mOpenRequest.swap(request);
 
-    nsIDOMEventTarget* target =
-      static_cast<nsIDOMEventTarget*>(databaseConcrete);
+    EventTarget* target =
+      static_cast<EventTarget*>(databaseConcrete);
 
 #ifdef DEBUG
     {
       nsresult rvDEBUG =
         target->AddEventListener(NS_LITERAL_STRING(ERROR_EVT_STR),
                                  mEventListener, false);
       NS_WARN_IF_FALSE(NS_SUCCEEDED(rvDEBUG), "Failed to add error listener!");
     }
@@ -667,17 +665,17 @@ IndexedDBTransactionParent::~IndexedDBTr
 }
 
 nsresult
 IndexedDBTransactionParent::SetTransaction(IDBTransaction* aTransaction)
 {
   MOZ_ASSERT(aTransaction);
   MOZ_ASSERT(!mTransaction);
 
-  nsIDOMEventTarget* target = static_cast<nsIDOMEventTarget*>(aTransaction);
+  EventTarget* target = static_cast<EventTarget*>(aTransaction);
 
   NS_NAMED_LITERAL_STRING(complete, COMPLETE_EVT_STR);
   nsresult rv = target->AddEventListener(complete, mEventListener, false);
   NS_ENSURE_SUCCESS(rv, rv);
 
   rv = target->AddEventListener(NS_LITERAL_STRING(ABORT_EVT_STR),
                                 mEventListener, false);
   NS_ENSURE_SUCCESS(rv, rv);
@@ -709,17 +707,17 @@ IndexedDBTransactionParent::HandleEvent(
 
   if (type.EqualsLiteral(COMPLETE_EVT_STR)) {
     params = CompleteResult();
   }
   else if (type.EqualsLiteral(ABORT_EVT_STR)) {
 #ifdef DEBUG
     {
       nsCOMPtr<EventTarget> target = aEvent->InternalDOMEvent()->GetTarget();
-      MOZ_ASSERT(SameCOMIdentity(target, NS_ISUPPORTS_CAST(nsIDOMEventTarget*,
+      MOZ_ASSERT(SameCOMIdentity(target, NS_ISUPPORTS_CAST(EventTarget*,
                                                            mTransaction)));
     }
 #endif
     params = AbortResult(mTransaction->GetAbortCode());
   }
   else {
     NS_WARNING("Unknown message type!");
     return NS_ERROR_UNEXPECTED;
@@ -2175,17 +2173,17 @@ IndexedDBDeleteDatabaseRequestParent::Ha
 
 nsresult
 IndexedDBDeleteDatabaseRequestParent::SetOpenRequest(
                                                  IDBOpenDBRequest* aOpenRequest)
 {
   MOZ_ASSERT(aOpenRequest);
   MOZ_ASSERT(!mOpenRequest);
 
-  nsIDOMEventTarget* target = static_cast<nsIDOMEventTarget*>(aOpenRequest);
+  EventTarget* target = static_cast<EventTarget*>(aOpenRequest);
 
   nsresult rv = target->AddEventListener(NS_LITERAL_STRING(SUCCESS_EVT_STR),
                                          mEventListener, false);
   NS_ENSURE_SUCCESS(rv, rv);
 
   rv = target->AddEventListener(NS_LITERAL_STRING(ERROR_EVT_STR),
                                 mEventListener, false);
   NS_ENSURE_SUCCESS(rv, rv);
--- a/dom/ipc/TabChild.cpp
+++ b/dom/ipc/TabChild.cpp
@@ -1413,17 +1413,17 @@ TabChild::DispatchMessageManagerMessage(
         cloneData.mDataLength = buffer.nbytes();
     }
 
     nsFrameScriptCx cx(static_cast<nsIWebBrowserChrome*>(this), this);
     // Let the BrowserElementScrolling helper (if it exists) for this
     // content manipulate the frame state.
     nsRefPtr<nsFrameMessageManager> mm =
       static_cast<nsFrameMessageManager*>(mTabChildGlobal->mMessageManager.get());
-    mm->ReceiveMessage(static_cast<nsIDOMEventTarget*>(mTabChildGlobal),
+    mm->ReceiveMessage(static_cast<EventTarget*>(mTabChildGlobal),
                        aMessageName, false, &cloneData, nullptr, nullptr);
 }
 
 static void
 ScrollWindowTo(nsIDOMWindow* aWindow, const mozilla::gfx::Point& aPoint)
 {
     nsGlobalWindow* window = static_cast<nsGlobalWindow*>(aWindow);
     nsIScrollableFrame* sf = window->GetScrollFrame();
@@ -1951,17 +1951,17 @@ bool
 TabChild::RecvAsyncMessage(const nsString& aMessage,
                            const ClonedMessageData& aData)
 {
   if (mTabChildGlobal) {
     nsFrameScriptCx cx(static_cast<nsIWebBrowserChrome*>(this), this);
     StructuredCloneData cloneData = UnpackClonedMessageDataForChild(aData);
     nsRefPtr<nsFrameMessageManager> mm =
       static_cast<nsFrameMessageManager*>(mTabChildGlobal->mMessageManager.get());
-    mm->ReceiveMessage(static_cast<nsIDOMEventTarget*>(mTabChildGlobal),
+    mm->ReceiveMessage(static_cast<EventTarget*>(mTabChildGlobal),
                        aMessage, false, &cloneData, nullptr, nullptr);
   }
   return true;
 }
 
 class UnloadScriptEvent : public nsRunnable
 {
 public:
@@ -2049,17 +2049,17 @@ TabChild::InitTabChildGlobal(FrameScript
     NS_ENSURE_TRUE(window, false);
     nsCOMPtr<EventTarget> chromeHandler =
       do_QueryInterface(window->GetChromeEventHandler());
     NS_ENSURE_TRUE(chromeHandler, false);
 
     nsRefPtr<TabChildGlobal> scope = new TabChildGlobal(this);
     mTabChildGlobal = scope;
 
-    nsISupports* scopeSupports = NS_ISUPPORTS_CAST(nsIDOMEventTarget*, scope);
+    nsISupports* scopeSupports = NS_ISUPPORTS_CAST(EventTarget*, scope);
 
     NS_NAMED_LITERAL_CSTRING(globalId, "outOfProcessTabChildGlobal");
     NS_ENSURE_TRUE(InitTabChildGlobalInternal(scopeSupports, globalId), false);
 
     scope->Init();
 
     nsCOMPtr<nsPIWindowRoot> root = do_QueryInterface(chromeHandler);
     NS_ENSURE_TRUE(root, false);
--- a/dom/network/src/MobileConnection.h
+++ b/dom/network/src/MobileConnection.h
@@ -46,22 +46,15 @@ public:
 
   NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(MobileConnection,
                                            nsDOMEventTargetHelper)
 
 private:
   nsCOMPtr<nsIMobileConnectionProvider> mProvider;
   nsRefPtr<Listener> mListener;
   nsRefPtr<icc::IccManager> mIccManager;
-
-  nsIDOMEventTarget*
-  ToIDOMEventTarget() const
-  {
-    return static_cast<nsDOMEventTargetHelper*>(
-           const_cast<MobileConnection*>(this));
-  }
 };
 
 } // namespace network
 } // namespace dom
 } // namespace mozilla
 
 #endif // mozilla_dom_network_MobileConnection_h
--- a/dom/system/nsDeviceSensors.cpp
+++ b/dom/system/nsDeviceSensors.cpp
@@ -16,16 +16,17 @@
 #include "nsIServiceManager.h"
 #include "nsIServiceManager.h"
 #include "GeneratedEvents.h"
 #include "mozilla/Preferences.h"
 #include "mozilla/Attributes.h"
 #include "nsIPermissionManager.h"
 
 using namespace mozilla;
+using namespace mozilla::dom;
 using namespace hal;
 
 #undef near
 
 // also see sDefaultSensorHint in mobile/android/base/GeckoAppShell.java
 #define DEFAULT_SENSOR_POLL 100
 
 static const nsTArray<nsIDOMWindow*>::index_type NoIndex =
@@ -212,18 +213,18 @@ nsDeviceSensors::Notify(const mozilla::h
         continue;
     }
 
     nsCOMPtr<nsIDOMDocument> domdoc;
     windowListeners[i]->GetDocument(getter_AddRefs(domdoc));
 
     if (domdoc) {
       nsCOMPtr<mozilla::dom::EventTarget> target = do_QueryInterface(windowListeners[i]);
-      if (type == nsIDeviceSensorData::TYPE_ACCELERATION || 
-        type == nsIDeviceSensorData::TYPE_LINEAR_ACCELERATION || 
+      if (type == nsIDeviceSensorData::TYPE_ACCELERATION ||
+        type == nsIDeviceSensorData::TYPE_LINEAR_ACCELERATION ||
         type == nsIDeviceSensorData::TYPE_GYROSCOPE)
         FireDOMMotionEvent(domdoc, target, type, x, y, z);
       else if (type == nsIDeviceSensorData::TYPE_ORIENTATION)
         FireDOMOrientationEvent(domdoc, target, x, y, z);
       else if (type == nsIDeviceSensorData::TYPE_PROXIMITY)
         FireDOMProximityEvent(target, x, y, z);
       else if (type == nsIDeviceSensorData::TYPE_LIGHT)
         FireDOMLightEvent(target, x);
@@ -300,18 +301,18 @@ nsDeviceSensors::FireDOMUserProximityEve
 
   event->SetTrusted(true);
 
   bool defaultActionEnabled;
   aTarget->DispatchEvent(event, &defaultActionEnabled);
 }
 
 void
-nsDeviceSensors::FireDOMOrientationEvent(nsIDOMDocument *domdoc,
-                                         nsIDOMEventTarget *target,
+nsDeviceSensors::FireDOMOrientationEvent(nsIDOMDocument* domdoc,
+                                         EventTarget* target,
                                          double alpha,
                                          double beta,
                                          double gamma)
 {
   nsCOMPtr<nsIDOMEvent> event;
   bool defaultActionEnabled = true;
   domdoc->CreateEvent(NS_LITERAL_STRING("DeviceOrientationEvent"), getter_AddRefs(event));
 
@@ -325,28 +326,29 @@ nsDeviceSensors::FireDOMOrientationEvent
                                  true,
                                  false,
                                  alpha,
                                  beta,
                                  gamma,
                                  true);
 
   event->SetTrusted(true);
-  
+
   target->DispatchEvent(event, &defaultActionEnabled);
 }
 
 
 void
 nsDeviceSensors::FireDOMMotionEvent(nsIDOMDocument *domdoc,
-                                   nsIDOMEventTarget *target,
-                                   uint32_t type,
-                                   double x,
-                                   double y,
-                                   double z) {
+                                    EventTarget* target,
+                                    uint32_t type,
+                                    double x,
+                                    double y,
+                                    double z)
+{
   // Attempt to coalesce events
   bool fireEvent = TimeStamp::Now() > mLastDOMMotionEventTime + TimeDuration::FromMilliseconds(DEFAULT_SENSOR_POLL);
 
   switch (type) {
   case nsIDeviceSensorData::TYPE_LINEAR_ACCELERATION:
     mLastAcceleration = new nsDOMDeviceAcceleration(x, y, z);
     break;
   case nsIDeviceSensorData::TYPE_ACCELERATION:
--- a/dom/system/nsDeviceSensors.h
+++ b/dom/system/nsDeviceSensors.h
@@ -24,16 +24,22 @@
 #define NS_DEVICE_SENSORS_CID \
 { 0xecba5203, 0x77da, 0x465a, \
 { 0x86, 0x5e, 0x78, 0xb7, 0xaf, 0x10, 0xd8, 0xf7 } }
 
 #define NS_DEVICE_SENSORS_CONTRACTID "@mozilla.org/devicesensors;1"
 
 class nsIDOMWindow;
 
+namespace mozilla {
+namespace dom {
+class EventTarget;
+}
+}
+
 class nsDeviceSensors : public nsIDeviceSensors, public mozilla::hal::ISensorObserver
 {
 public:
   NS_DECL_ISUPPORTS
   NS_DECL_NSIDEVICESENSORS
 
   nsDeviceSensors();
 
@@ -51,24 +57,24 @@ private:
   void FireDOMProximityEvent(mozilla::dom::EventTarget* aTarget,
                              double aValue,
                              double aMin,
                              double aMax);
 
   void FireDOMUserProximityEvent(mozilla::dom::EventTarget* aTarget,
                                  bool aNear);
 
-  void FireDOMOrientationEvent(class nsIDOMDocument *domDoc, 
-                               class nsIDOMEventTarget *target,
+  void FireDOMOrientationEvent(class nsIDOMDocument *domDoc,
+                               mozilla::dom::EventTarget* target,
                                double alpha,
                                double beta,
                                double gamma);
 
-  void FireDOMMotionEvent(class nsIDOMDocument *domDoc, 
-                          class nsIDOMEventTarget *target,
+  void FireDOMMotionEvent(class nsIDOMDocument *domDoc,
+                          mozilla::dom::EventTarget* target,
                           uint32_t type,
                           double x,
                           double y,
                           double z);
 
   bool mEnabled;
 
   inline bool IsSensorEnabled(uint32_t aType) {
--- a/dom/telephony/Telephony.h
+++ b/dom/telephony/Telephony.h
@@ -50,27 +50,20 @@ public:
   NS_REALLY_FORWARD_NSIDOMEVENTTARGET(nsDOMEventTargetHelper)
   NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS_INHERITED(
                                                    Telephony,
                                                    nsDOMEventTargetHelper)
 
   static already_AddRefed<Telephony>
   Create(nsPIDOMWindow* aOwner, nsITelephonyProvider* aProvider);
 
-  nsIDOMEventTarget*
-  ToIDOMEventTarget() const
+  nsISupports*
+  ToISupports()
   {
-    return static_cast<nsDOMEventTargetHelper*>(
-             const_cast<Telephony*>(this));
-  }
-
-  nsISupports*
-  ToISupports() const
-  {
-    return ToIDOMEventTarget();
+    return static_cast<EventTarget*>(this);
   }
 
   void
   AddCall(TelephonyCall* aCall)
   {
     NS_ASSERTION(!mCalls.Contains(aCall), "Already know about this one!");
     mCalls.AppendElement(aCall);
     mCallsArray = nullptr;
--- a/dom/telephony/TelephonyCall.h
+++ b/dom/telephony/TelephonyCall.h
@@ -35,27 +35,20 @@ public:
   NS_REALLY_FORWARD_NSIDOMEVENTTARGET(nsDOMEventTargetHelper)
   NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(TelephonyCall,
                                            nsDOMEventTargetHelper)
 
   static already_AddRefed<TelephonyCall>
   Create(Telephony* aTelephony, const nsAString& aNumber, uint16_t aCallState,
          uint32_t aCallIndex = kOutgoingPlaceholderCallIndex);
 
-  nsIDOMEventTarget*
-  ToIDOMEventTarget() const
+  nsISupports*
+  ToISupports()
   {
-    return static_cast<nsDOMEventTargetHelper*>(
-             const_cast<TelephonyCall*>(this));
-  }
-
-  nsISupports*
-  ToISupports() const
-  {
-    return ToIDOMEventTarget();
+    return static_cast<EventTarget*>(this);
   }
 
   void
   ChangeState(uint16_t aCallState)
   {
     ChangeStateInternal(aCallState, true);
   }
 
--- a/extensions/widgetutils/src/nsWidgetUtils.cpp
+++ b/extensions/widgetutils/src/nsWidgetUtils.cpp
@@ -22,17 +22,16 @@
 #include "nsIWebProgressListener.h"
 #include "nsIWindowWatcher.h"
 #include "nsNetUtil.h"
 #include "nsRect.h"
 #include "nsStringGlue.h"
 #include "nsWeakReference.h"
 #include "nsIWebBrowser.h"
 #include "nsIObserverService.h"
-#include "nsIDOMEventTarget.h"
 #include "nsPIDOMWindow.h"
 #include "nsIDOMWindow.h"
 #include "nsIDOMCompositionListener.h"
 #include "nsIDOMTextListener.h"
 #include "nsIDOMMouseEvent.h"
 #include "nsIDOMWheelEvent.h"
 #include "nsView.h"
 #include "nsGUIEvent.h"
@@ -72,17 +71,17 @@ public:
   NS_DECL_ISUPPORTS
   NS_DECL_NSIDOMEVENTLISTENER
   NS_DECL_NSIOBSERVER 
   NS_DECL_NSICONTENTPOLICY
 
 private:
   nsresult Init(void);
   void RemoveWindowListeners(nsIDOMWindow *aDOMWin);
-  void GetChromeEventHandler(nsIDOMWindow *aDOMWin, nsIDOMEventTarget **aChromeTarget);
+  EventTarget* GetChromeEventHandler(nsIDOMWindow *aDOMWin);
   void AttachWindowListeners(nsIDOMWindow *aDOMWin);
   bool IsXULNode(nsIDOMNode *aNode, uint32_t *aType = 0);
   nsresult GetDOMWindowByNode(nsIDOMNode *aNode, nsIDOMWindow * *aDOMWindow);
   nsresult UpdateFromEvent(nsIDOMEvent *aDOMEvent);
   nsresult MouseDown(nsIDOMEvent* aDOMEvent);
   nsresult MouseUp(nsIDOMEvent* aDOMEvent);
   nsresult MouseMove(nsIDOMEvent* aDOMEvent);
 
@@ -123,30 +122,29 @@ nsWidgetUtils::UpdateFromEvent(nsIDOMEve
   mouseEvent->GetScreenX(&g_lastX);
   mouseEvent->GetScreenY(&g_lastY);
 
   nsCOMPtr<nsIDOMWindow> mWindow;
   nsCOMPtr<nsIDOMNode> mNode;
   nsCOMPtr<nsIDOMNode> mOrigNode;
 
   uint32_t type = 0;
+  nsDOMEvent* event = aDOMEvent->InternalDOMEvent();
   bool isXul = false;
   {
-    nsCOMPtr<nsIDOMEventTarget> eventOrigTarget;
-    aDOMEvent->GetOriginalTarget(getter_AddRefs(eventOrigTarget));
+    nsCOMPtr<EventTarget> eventOrigTarget = event->GetOriginalTarget();
     if (eventOrigTarget)
       mOrigNode = do_QueryInterface(eventOrigTarget);
     isXul = IsXULNode(mOrigNode, &type);
 
   }
   if (isXul)
     return NS_ERROR_FAILURE;
 
-  nsCOMPtr<nsIDOMEventTarget> eventTarget;
-  aDOMEvent->GetTarget(getter_AddRefs(eventTarget));
+  nsCOMPtr<EventTarget> eventTarget = event->GetTarget();
   if (eventTarget)
     mNode = do_QueryInterface(eventTarget);
 
   if (!mNode)
     return NS_OK;
 
   GetDOMWindowByNode(mNode, getter_AddRefs(mWindow));
   if (!mWindow)
@@ -359,35 +357,28 @@ nsWidgetUtils::GetDOMWindowByNode(nsIDOM
   nsCOMPtr<nsIDOMWindow> window;
   rv = nodeDoc->GetDefaultView(getter_AddRefs(window));
   NS_ENSURE_SUCCESS(rv, rv);
   NS_ENSURE_TRUE(window, NS_ERROR_NULL_POINTER);
   window.forget(aDOMWindow);
   return rv;
 }
 
-void
-nsWidgetUtils::GetChromeEventHandler(nsIDOMWindow *aDOMWin,
-                                     nsIDOMEventTarget **aChromeTarget)
+EventTarget*
+nsWidgetUtils::GetChromeEventHandler(nsIDOMWindow* aDOMWin)
 {
-    nsCOMPtr<nsPIDOMWindow> privateDOMWindow(do_QueryInterface(aDOMWin));
-    nsIDOMEventTarget* chromeEventHandler = nullptr;
-    if (privateDOMWindow) {
-        chromeEventHandler = privateDOMWindow->GetChromeEventHandler();
-    }
-
-    NS_IF_ADDREF(*aChromeTarget = chromeEventHandler);
+  nsCOMPtr<nsPIDOMWindow> privateDOMWindow = do_QueryInterface(aDOMWin);
+  return privateDOMWindow ? privateDOMWindow->GetChromeEventHandler() : nullptr;
 }
 
 void
 nsWidgetUtils::RemoveWindowListeners(nsIDOMWindow *aDOMWin)
 {
     nsresult rv;
-    nsCOMPtr<nsIDOMEventTarget> chromeEventHandler;
-    GetChromeEventHandler(aDOMWin, getter_AddRefs(chromeEventHandler));
+    EventTarget* chromeEventHandler = GetChromeEventHandler(aDOMWin);
     if (!chromeEventHandler) {
         return;
     }
 
     // Use capturing, otherwise the normal find next will get activated when ours should
 
     // Remove DOM Text listener for IME text events
     chromeEventHandler->RemoveEventListener(NS_LITERAL_STRING("mousedown"),
@@ -397,18 +388,17 @@ nsWidgetUtils::RemoveWindowListeners(nsI
     chromeEventHandler->RemoveEventListener(NS_LITERAL_STRING("mousemove"),
                                             this, false);
 }
 
 void
 nsWidgetUtils::AttachWindowListeners(nsIDOMWindow *aDOMWin)
 {
     nsresult rv;
-    nsCOMPtr<nsIDOMEventTarget> chromeEventHandler;
-    GetChromeEventHandler(aDOMWin, getter_AddRefs(chromeEventHandler));
+    EventHandler* chromeEventHandler = GetChromeEventHandler(aDOMWin);
     if (!chromeEventHandler) {
         return;
     }
 
     // Use capturing, otherwise the normal find next will get activated when ours should
 
     // Attach menu listeners, this will help us ignore keystrokes meant for menus
     chromeEventHandler->AddEventListener(NS_LITERAL_STRING("mousedown"), this,
--- a/layout/base/nsPresContext.cpp
+++ b/layout/base/nsPresContext.cpp
@@ -51,17 +51,16 @@
 #include "gfxUserFontSet.h"
 #include "gfxPlatform.h"
 #include "nsCSSRules.h"
 #include "nsFontFaceLoader.h"
 #include "nsEventListenerManager.h"
 #include "nsStyleStructInlines.h"
 #include "nsIAppShell.h"
 #include "prenv.h"
-#include "nsIDOMEventTarget.h"
 #include "nsObjectFrame.h"
 #include "nsTransitionManager.h"
 #include "nsAnimationManager.h"
 #include "mozilla/dom/Element.h"
 #include "nsIMessageManager.h"
 #include "FrameLayerBuilder.h"
 #include "nsDOMMediaQueryList.h"
 #include "nsSMILAnimationController.h"
@@ -2131,17 +2130,17 @@ MayHavePaintEventListenerSubdocumentCall
 static bool
 MayHavePaintEventListener(nsPIDOMWindow* aInnerWindow)
 {
   if (!aInnerWindow)
     return false;
   if (aInnerWindow->HasPaintEventListeners())
     return true;
 
-  nsIDOMEventTarget* parentTarget = aInnerWindow->GetParentTarget();
+  EventTarget* parentTarget = aInnerWindow->GetParentTarget();
   if (!parentTarget)
     return false;
 
   nsEventListenerManager* manager = nullptr;
   if ((manager = parentTarget->GetListenerManager(false)) &&
       manager->MayHavePaintEventListener()) {
     return true;
   }
@@ -2161,17 +2160,17 @@ MayHavePaintEventListener(nsPIDOMWindow*
   if (node)
     return MayHavePaintEventListener(node->OwnerDoc()->GetInnerWindow());
 
   nsCOMPtr<nsPIDOMWindow> window = do_QueryInterface(parentTarget);
   if (window)
     return MayHavePaintEventListener(window);
 
   nsCOMPtr<nsPIWindowRoot> root = do_QueryInterface(parentTarget);
-  nsIDOMEventTarget* tabChildGlobal;
+  EventTarget* tabChildGlobal;
   return root &&
          (tabChildGlobal = root->GetParentTarget()) &&
          (manager = tabChildGlobal->GetListenerManager(false)) &&
          manager->MayHavePaintEventListener();
 }
 
 bool
 nsPresContext::MayHavePaintEventListener()
--- a/layout/forms/nsComboboxControlFrame.cpp
+++ b/layout/forms/nsComboboxControlFrame.cpp
@@ -1,16 +1,15 @@
 /* -*- 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 "nsCOMPtr.h"
 #include "nsReadableUtils.h"
 #include "nsComboboxControlFrame.h"
-#include "nsIDOMEventTarget.h"
 #include "nsFocusManager.h"
 #include "nsFormControlFrame.h"
 #include "nsFrameManager.h"
 #include "nsGfxButtonControlFrame.h"
 #include "nsGkAtoms.h"
 #include "nsCSSAnonBoxes.h"
 #include "nsHTMLParts.h"
 #include "nsIFormControl.h"
--- a/layout/forms/nsFileControlFrame.cpp
+++ b/layout/forms/nsFileControlFrame.cpp
@@ -21,17 +21,16 @@
 #include "nsIDocument.h"
 #include "nsIPresShell.h"
 #include "nsXPCOM.h"
 #include "nsISupportsPrimitives.h"
 #include "nsPIDOMWindow.h"
 #include "nsIFilePicker.h"
 #include "nsIDOMMouseEvent.h"
 #include "nsINodeInfo.h"
-#include "nsIDOMEventTarget.h"
 #include "nsIFile.h"
 #include "mozilla/dom/HTMLInputElement.h"
 #include "nsNodeInfoManager.h"
 #include "nsContentCreatorFunctions.h"
 #include "nsContentUtils.h"
 #include "nsDisplayList.h"
 #include "nsEventListenerManager.h"
 
--- a/layout/forms/nsListControlFrame.cpp
+++ b/layout/forms/nsListControlFrame.cpp
@@ -17,17 +17,16 @@
 #include "nsIDOMHTMLSelectElement.h"
 #include "nsIDOMHTMLOptionElement.h"
 #include "nsComboboxControlFrame.h"
 #include "nsViewManager.h"
 #include "nsIDOMHTMLOptGroupElement.h"
 #include "nsWidgetsCID.h"
 #include "nsIPresShell.h"
 #include "nsHTMLParts.h"
-#include "nsIDOMEventTarget.h"
 #include "nsEventDispatcher.h"
 #include "nsEventStateManager.h"
 #include "nsEventListenerManager.h"
 #include "nsIDOMKeyEvent.h"
 #include "nsIDOMMouseEvent.h"
 #include "nsXPCOM.h"
 #include "nsISupportsPrimitives.h"
 #include "nsIComponentManager.h"
--- a/layout/forms/nsTextControlFrame.cpp
+++ b/layout/forms/nsTextControlFrame.cpp
@@ -43,17 +43,16 @@
 #include "nsIDOMHTMLInputElement.h"
 #include "nsIDOMElement.h"
 #include "nsIDOMHTMLElement.h"
 #include "nsIPresShell.h"
 
 #include "nsBoxLayoutState.h"
 #include <algorithm>
 //for keylistener for "return" check
-#include "nsIDOMEventTarget.h"
 #include "nsIDocument.h" //observe documents to send onchangenotifications
 #include "nsIStyleSheet.h"//observe documents to send onchangenotifications
 #include "nsIStyleRule.h"//observe documents to send onchangenotifications
 #include "nsIDOMEventListener.h"//observe documents to send onchangenotifications
 #include "nsGUIEvent.h"
 
 #include "nsIDOMCharacterData.h" //for selection setting helper func
 #include "nsIDOMNodeList.h" //for selection setting helper func
--- a/layout/generic/nsImageMap.cpp
+++ b/layout/generic/nsImageMap.cpp
@@ -15,17 +15,16 @@
 #include "nsIURL.h"
 #include "nsIServiceManager.h"
 #include "nsNetUtil.h"
 #include "nsTextFragment.h"
 #include "mozilla/dom/Element.h"
 #include "nsIDocument.h"
 #include "nsINameSpaceManager.h"
 #include "nsGkAtoms.h"
-#include "nsIDOMEventTarget.h"
 #include "nsIPresShell.h"
 #include "nsImageFrame.h"
 #include "nsCoord.h"
 #include "nsIConsoleService.h"
 #include "nsIScriptError.h"
 #include "nsIStringBundle.h"
 #include "nsContentUtils.h"
 
--- a/layout/generic/nsObjectFrame.cpp
+++ b/layout/generic/nsObjectFrame.cpp
@@ -38,17 +38,16 @@
 #include "nsDocShellCID.h"
 #include "nsIWebBrowserChrome.h"
 #include "nsIDOMElement.h"
 #include "nsIDOMNodeList.h"
 #include "nsIDOMHTMLObjectElement.h"
 #include "nsIDOMHTMLEmbedElement.h"
 #include "nsIDOMHTMLAppletElement.h"
 #include "nsIDOMWindow.h"
-#include "nsIDOMEventTarget.h"
 #include "nsIDocumentEncoder.h"
 #include "nsXPIDLString.h"
 #include "nsIDOMRange.h"
 #include "nsIPluginWidget.h"
 #include "nsGUIEvent.h"
 #include "nsRenderingContext.h"
 #include "npapi.h"
 #include "nsTransform2D.h"
--- a/layout/mathml/nsMathMLmactionFrame.cpp
+++ b/layout/mathml/nsMathMLmactionFrame.cpp
@@ -16,18 +16,16 @@
 #include "nsIDocShellTreeItem.h"
 #include "nsIDocShellTreeOwner.h"
 #include "nsIWebBrowserChrome.h"
 #include "nsIInterfaceRequestor.h"
 #include "nsIInterfaceRequestorUtils.h"
 #include "nsIDOMElement.h"
 #include "nsTextFragment.h"
 
-#include "nsIDOMEventTarget.h"
-
 #include "nsMathMLmactionFrame.h"
 #include "nsAutoPtr.h"
 #include "nsStyleSet.h"
 #include "nsDisplayList.h"
 
 //
 // <maction> -- bind actions to a subexpression - implementation
 //
--- a/layout/printing/nsPrintEngine.cpp
+++ b/layout/printing/nsPrintEngine.cpp
@@ -66,17 +66,16 @@ static const char kPrintingPromptService
 
 // Printing Timer
 #include "nsPagePrintTimer.h"
 
 // FrameSet
 #include "nsIDocument.h"
 
 // Focus
-#include "nsIDOMEventTarget.h"
 #include "nsISelectionController.h"
 
 // Misc
 #include "nsISupportsUtils.h"
 #include "nsIScriptContext.h"
 #include "nsIDOMDocument.h"
 #include "nsISelectionListener.h"
 #include "nsISelectionPrivate.h"
--- a/layout/xul/base/src/nsListBoxBodyFrame.cpp
+++ b/layout/xul/base/src/nsListBoxBodyFrame.cpp
@@ -9,17 +9,16 @@
 
 #include "nsCOMPtr.h"
 #include "nsGridRowGroupLayout.h"
 #include "nsIServiceManager.h"
 #include "nsGkAtoms.h"
 #include "nsIContent.h"
 #include "nsINameSpaceManager.h"
 #include "nsIDocument.h"
-#include "nsIDOMEventTarget.h"
 #include "nsIDOMMouseEvent.h"
 #include "nsIDOMElement.h"
 #include "nsIDOMNodeList.h"
 #include "nsCSSFrameConstructor.h"
 #include "nsIScrollableFrame.h"
 #include "nsScrollbarFrame.h"
 #include "nsView.h"
 #include "nsViewManager.h"
--- a/layout/xul/base/src/nsMenuBarFrame.cpp
+++ b/layout/xul/base/src/nsMenuBarFrame.cpp
@@ -7,17 +7,16 @@
 #include "nsIServiceManager.h"
 #include "nsIContent.h"
 #include "nsIAtom.h"
 #include "nsPresContext.h"
 #include "nsStyleContext.h"
 #include "nsCSSRendering.h"
 #include "nsINameSpaceManager.h"
 #include "nsIDocument.h"
-#include "nsIDOMEventTarget.h"
 #include "nsGkAtoms.h"
 #include "nsMenuFrame.h"
 #include "nsMenuPopupFrame.h"
 #include "nsGUIEvent.h"
 #include "nsUnicharUtils.h"
 #include "nsPIDOMWindow.h"
 #include "nsIInterfaceRequestorUtils.h"
 #include "nsCSSFrameConstructor.h"
--- a/layout/xul/base/src/nsMenuBarFrame.h
+++ b/layout/xul/base/src/nsMenuBarFrame.h
@@ -111,13 +111,13 @@ protected:
 
   // whether the menubar was made active via the keyboard.
   bool mActiveByKeyboard;
 
   // The current menu that is active (highlighted), which may not be open. This will
   // be null if no menu is active.
   nsMenuFrame* mCurrentMenu;
 
-  nsIDOMEventTarget* mTarget;
+  mozilla::dom::EventTarget* mTarget;
 
 }; // class nsMenuBarFrame
 
 #endif
--- a/layout/xul/base/src/nsMenuBarListener.h
+++ b/layout/xul/base/src/nsMenuBarListener.h
@@ -1,17 +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/. */
 #ifndef nsMenuBarListener_h__
 #define nsMenuBarListener_h__
 
 #include "nsIDOMEventListener.h"
-#include "nsIDOMEventTarget.h"
 
 // X.h defines KeyPress
 #ifdef KeyPress
 #undef KeyPress
 #endif
 
 class nsMenuBarFrame;
 class nsIDOMKeyEvent;
--- a/layout/xul/base/src/nsMenuPopupFrame.h
+++ b/layout/xul/base/src/nsMenuPopupFrame.h
@@ -10,17 +10,16 @@
 #ifndef nsMenuPopupFrame_h__
 #define nsMenuPopupFrame_h__
 
 #include "mozilla/Attributes.h"
 #include "nsIAtom.h"
 #include "nsGkAtoms.h"
 #include "nsCOMPtr.h"
 #include "nsMenuFrame.h"
-#include "nsIDOMEventTarget.h"
 
 #include "nsBoxFrame.h"
 #include "nsMenuParent.h"
 
 #include "nsITimer.h"
 
 class nsIWidget;
 
--- a/layout/xul/base/src/nsSliderFrame.cpp
+++ b/layout/xul/base/src/nsSliderFrame.cpp
@@ -16,17 +16,16 @@
 #include "nsIContent.h"
 #include "nsCOMPtr.h"
 #include "nsINameSpaceManager.h"
 #include "nsGkAtoms.h"
 #include "nsHTMLParts.h"
 #include "nsIPresShell.h"
 #include "nsCSSRendering.h"
 #include "nsEventListenerManager.h"
-#include "nsIDOMEventTarget.h"
 #include "nsIDOMMouseEvent.h"
 #include "nsScrollbarButtonFrame.h"
 #include "nsISliderListener.h"
 #include "nsIScrollbarMediator.h"
 #include "nsScrollbarFrame.h"
 #include "nsRepeatService.h"
 #include "nsBoxLayoutState.h"
 #include "nsSprocketLayout.h"
--- a/layout/xul/base/src/nsSplitterFrame.cpp
+++ b/layout/xul/base/src/nsSplitterFrame.cpp
@@ -14,17 +14,16 @@
 #include "nsGkAtoms.h"
 #include "nsIDOMElement.h"
 #include "nsIDOMXULElement.h"
 #include "nsPresContext.h"
 #include "nsRenderingContext.h"
 #include "nsIDocument.h"
 #include "nsINameSpaceManager.h"
 #include "nsScrollbarButtonFrame.h"
-#include "nsIDOMEventTarget.h"
 #include "nsIDOMEventListener.h"
 #include "nsIDOMMouseEvent.h"
 #include "nsIPresShell.h"
 #include "nsFrameList.h"
 #include "nsHTMLParts.h"
 #include "nsStyleContext.h"
 #include "nsBoxLayoutState.h"
 #include "nsIServiceManager.h"
--- a/layout/xul/base/src/nsXULTooltipListener.cpp
+++ b/layout/xul/base/src/nsXULTooltipListener.cpp
@@ -2,17 +2,16 @@
 /* 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 "nsXULTooltipListener.h"
 
 #include "nsDOMEvent.h"
 #include "nsIDOMMouseEvent.h"
-#include "nsIDOMEventTarget.h"
 #include "nsIDOMXULDocument.h"
 #include "nsIDOMXULElement.h"
 #include "nsIDocument.h"
 #include "nsGkAtoms.h"
 #include "nsIPopupBoxObject.h"
 #include "nsMenuPopupFrame.h"
 #include "nsIServiceManager.h"
 #include "nsIDragService.h"
--- a/toolkit/components/satchel/nsFormFillController.cpp
+++ b/toolkit/components/satchel/nsFormFillController.cpp
@@ -12,17 +12,16 @@
 #include "nsReadableUtils.h"
 #include "nsIServiceManager.h"
 #include "nsIInterfaceRequestor.h"
 #include "nsIInterfaceRequestorUtils.h"
 #include "nsIDocShellTreeItem.h"
 #include "nsPIDOMWindow.h"
 #include "nsIWebNavigation.h"
 #include "nsIContentViewer.h"
-#include "nsIDOMEventTarget.h"
 #include "nsIDOMKeyEvent.h"
 #include "nsIDOMDocument.h"
 #include "nsIDOMElement.h"
 #include "nsIFormControl.h"
 #include "nsIDocument.h"
 #include "nsIContent.h"
 #include "nsIPresShell.h"
 #include "nsRect.h"
@@ -30,16 +29,19 @@
 #include "nsILoginManager.h"
 #include "nsIDOMMouseEvent.h"
 #include "mozilla/ModuleUtils.h"
 #include "nsToolkitCompsCID.h"
 #include "nsEmbedCID.h"
 #include "nsIDOMNSEditableElement.h"
 #include "mozilla/dom/Element.h"
 #include "nsContentUtils.h"
+#include "nsDOMEvent.h"
+
+using namespace mozilla::dom;
 
 NS_IMPL_ISUPPORTS5(nsFormFillController,
                    nsIFormFillController,
                    nsIAutoCompleteInput,
                    nsIAutoCompleteSearch,
                    nsIDOMEventListener,
                    nsIMutationObserver)
 
@@ -538,17 +540,17 @@ nsFormFillController::OnTextEntered(bool
 
   event->InitEvent(NS_LITERAL_STRING("DOMAutoComplete"), true, true);
 
   // XXXjst: We mark this event as a trusted event, it's up to the
   // callers of this to ensure that it's only called from trusted
   // code.
   event->SetTrusted(true);
 
-  nsCOMPtr<nsIDOMEventTarget> targ = do_QueryInterface(mFocusedInput);
+  nsCOMPtr<EventTarget> targ = do_QueryInterface(mFocusedInput);
 
   bool defaultActionEnabled;
   targ->DispatchEvent(event, &defaultActionEnabled);
   *aPrevent = !defaultActionEnabled;
   return NS_OK;
 }
 
 NS_IMETHODIMP
@@ -750,31 +752,27 @@ nsFormFillController::HandleEvent(nsIDOM
     return NS_OK;
   }
   if (type.EqualsLiteral("contextmenu")) {
     if (mFocusedPopup)
       mFocusedPopup->ClosePopup();
     return NS_OK;
   }
   if (type.EqualsLiteral("pagehide")) {
-    nsCOMPtr<nsIDOMEventTarget> target;
-    aEvent->GetTarget(getter_AddRefs(target));
 
-    nsCOMPtr<nsIDOMDocument> domDoc = do_QueryInterface(target);
-    if (!domDoc)
+    nsCOMPtr<nsIDocument> doc = do_QueryInterface(
+      aEvent->InternalDOMEvent()->GetTarget());
+    if (!doc)
       return NS_OK;
 
     if (mFocusedInput) {
-      nsCOMPtr<nsIDOMDocument> inputDoc;
-      mFocusedInput->GetOwnerDocument(getter_AddRefs(inputDoc));
-      if (domDoc == inputDoc)
+      if (doc == mFocusedInputNode->OwnerDoc())
         StopControllingInput();
     }
 
-    nsCOMPtr<nsIDocument> doc = do_QueryInterface(domDoc);
     PwmgrInputsEnumData ed(this, doc);
     mPwmgrInputs.Enumerate(RemoveForDocumentEnumerator, &ed);
   }
 
   return NS_OK;
 }
 
 
@@ -792,21 +790,19 @@ nsFormFillController::RemoveForDocumentE
     return PL_DHASH_REMOVE;
   }
   return PL_DHASH_NEXT;
 }
 
 nsresult
 nsFormFillController::Focus(nsIDOMEvent* aEvent)
 {
-  nsCOMPtr<nsIDOMEventTarget> target;
-  aEvent->GetTarget(getter_AddRefs(target));
-
-  nsCOMPtr<nsIDOMHTMLInputElement> input = do_QueryInterface(target);
-  nsCOMPtr<nsINode> inputNode = do_QueryInterface(input); 
+  nsCOMPtr<nsIDOMHTMLInputElement> input = do_QueryInterface(
+    aEvent->InternalDOMEvent()->GetTarget());
+  nsCOMPtr<nsINode> inputNode = do_QueryInterface(input);
   if (!inputNode)
     return NS_OK;
 
   bool isReadOnly = false;
   input->GetReadOnly(&isReadOnly);
 
   bool autocomplete = nsContentUtils::IsAutocompleteEnabled(input);
 
@@ -904,19 +900,18 @@ nsFormFillController::KeyPress(nsIDOMEve
 
 nsresult
 nsFormFillController::MouseDown(nsIDOMEvent* aEvent)
 {
   nsCOMPtr<nsIDOMMouseEvent> mouseEvent(do_QueryInterface(aEvent));
   if (!mouseEvent)
     return NS_ERROR_FAILURE;
 
-  nsCOMPtr<nsIDOMEventTarget> target;
-  aEvent->GetTarget(getter_AddRefs(target));
-  nsCOMPtr<nsIDOMHTMLInputElement> targetInput = do_QueryInterface(target);
+  nsCOMPtr<nsIDOMHTMLInputElement> targetInput = do_QueryInterface(
+    aEvent->InternalDOMEvent()->GetTarget());
   if (!targetInput)
     return NS_OK;
 
   uint16_t button;
   mouseEvent->GetButton(&button);
   if (button != 0)
     return NS_OK;
 
@@ -951,17 +946,17 @@ nsFormFillController::MouseDown(nsIDOMEv
 
 void
 nsFormFillController::AddWindowListeners(nsIDOMWindow *aWindow)
 {
   if (!aWindow)
     return;
 
   nsCOMPtr<nsPIDOMWindow> privateDOMWindow(do_QueryInterface(aWindow));
-  nsIDOMEventTarget* target = nullptr;
+  EventTarget* target = nullptr;
   if (privateDOMWindow)
     target = privateDOMWindow->GetChromeEventHandler();
 
   if (!target)
     return;
 
   target->AddEventListener(NS_LITERAL_STRING("focus"), this,
                            true, false);
@@ -994,17 +989,17 @@ nsFormFillController::RemoveWindowListen
 
   nsCOMPtr<nsIDOMDocument> domDoc;
   aWindow->GetDocument(getter_AddRefs(domDoc));
   nsCOMPtr<nsIDocument> doc = do_QueryInterface(domDoc);
   PwmgrInputsEnumData ed(this, doc);
   mPwmgrInputs.Enumerate(RemoveForDocumentEnumerator, &ed);
 
   nsCOMPtr<nsPIDOMWindow> privateDOMWindow(do_QueryInterface(aWindow));
-  nsIDOMEventTarget* target = nullptr;
+  EventTarget* target = nullptr;
   if (privateDOMWindow)
     target = privateDOMWindow->GetChromeEventHandler();
 
   if (!target)
     return;
 
   target->RemoveEventListener(NS_LITERAL_STRING("focus"), this, true);
   target->RemoveEventListener(NS_LITERAL_STRING("blur"), this, true);
@@ -1014,35 +1009,29 @@ nsFormFillController::RemoveWindowListen
   target->RemoveEventListener(NS_LITERAL_STRING("compositionstart"), this,
                               true);
   target->RemoveEventListener(NS_LITERAL_STRING("compositionend"), this,
                               true);
   target->RemoveEventListener(NS_LITERAL_STRING("contextmenu"), this, true);
 }
 
 void
-nsFormFillController::AddKeyListener(nsIDOMHTMLInputElement *aInput)
+nsFormFillController::AddKeyListener(nsINode* aInput)
 {
-  if (!aInput)
-    return;
-
-  nsCOMPtr<nsIDOMEventTarget> target = do_QueryInterface(aInput);
-
-  target->AddEventListener(NS_LITERAL_STRING("keypress"), this,
+  aInput->AddEventListener(NS_LITERAL_STRING("keypress"), this,
                            true, false);
 }
 
 void
 nsFormFillController::RemoveKeyListener()
 {
-  if (!mFocusedInput)
+  if (!mFocusedInputNode)
     return;
 
-  nsCOMPtr<nsIDOMEventTarget> target = do_QueryInterface(mFocusedInput);
-  target->RemoveEventListener(NS_LITERAL_STRING("keypress"), this, true);
+  mFocusedInputNode->RemoveEventListener(NS_LITERAL_STRING("keypress"), this, true);
 }
 
 void
 nsFormFillController::StartControllingInput(nsIDOMHTMLInputElement *aInput)
 {
   // Make sure we're not still attached to an input
   StopControllingInput();
 
@@ -1055,18 +1044,18 @@ nsFormFillController::StartControllingIn
   // Cache the popup for the focused docShell
   mFocusedPopup = mPopups.SafeElementAt(index);
 
   nsCOMPtr<nsINode> node = do_QueryInterface(aInput);
   if (!node) {
     return;
   }
 
-  AddKeyListener(aInput);
-  
+  AddKeyListener(node);
+
   node->AddMutationObserverUnlessExists(this);
   mFocusedInputNode = node;
   mFocusedInput = aInput;
 
   nsCOMPtr<nsIDOMHTMLElement> list;
   mFocusedInput->GetList(getter_AddRefs(list));
   nsCOMPtr<nsINode> listNode = do_QueryInterface(list);
   if (listNode) {
--- a/toolkit/components/satchel/nsFormFillController.h
+++ b/toolkit/components/satchel/nsFormFillController.h
@@ -49,17 +49,17 @@ public:
 
   nsFormFillController();
   virtual ~nsFormFillController();
 
 protected:
   void AddWindowListeners(nsIDOMWindow *aWindow);
   void RemoveWindowListeners(nsIDOMWindow *aWindow);
 
-  void AddKeyListener(nsIDOMHTMLInputElement *aInput);
+  void AddKeyListener(nsINode* aInput);
   void RemoveKeyListener();
 
   void StartControllingInput(nsIDOMHTMLInputElement *aInput);
   void StopControllingInput();
 
   void RevalidateDataList();
   bool RowMatch(nsFormHistory *aHistory, uint32_t aIndex, const nsAString &aInputName, const nsAString &aInputValue);