Bug 1429903 part 2. Stop using nsIDOMEventTarget in xpidl. r=mccr8
authorBoris Zbarsky <bzbarsky@mit.edu>
Fri, 20 Apr 2018 00:49:30 -0400
changeset 468268 706b6ff8ea85d0c8e6f51a46c96eb4897a21523c
parent 468267 8b18a3c2beafed5be581528fb3d8a04713d6ced3
child 468269 d03756b18579a4bd43e4123af683d1cbfe9660d7
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)
reviewersmccr8
bugs1429903
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 1429903 part 2. Stop using nsIDOMEventTarget in xpidl. r=mccr8 MozReview-Commit-ID: HQw7TyJUapY
accessible/base/nsAccessibilityService.cpp
browser/components/sessionstore/nsISessionStoreUtils.idl
browser/components/sessionstore/nsSessionStoreUtils.cpp
docshell/base/nsDocShell.cpp
docshell/base/nsIDocShell.idl
dom/base/nsDOMWindowUtils.cpp
dom/base/nsFrameLoader.cpp
dom/base/nsGlobalWindowOuter.cpp
dom/base/nsISlowScriptDebug.idl
dom/events/Event.cpp
dom/events/EventListenerService.cpp
dom/events/EventTarget.h
dom/events/nsIEventListenerService.idl
dom/interfaces/base/domstubs.idl
dom/interfaces/base/nsIDOMWindowUtils.idl
dom/interfaces/events/nsIDOMEvent.idl
dom/presentation/PresentationRequest.cpp
dom/presentation/PresentationService.cpp
dom/presentation/interfaces/nsIPresentationDevicePrompt.idl
dom/presentation/interfaces/nsIPresentationService.idl
dom/presentation/ipc/PresentationIPCService.cpp
dom/presentation/ipc/PresentationParent.cpp
--- a/accessible/base/nsAccessibilityService.cpp
+++ b/accessible/base/nsAccessibilityService.cpp
@@ -63,16 +63,17 @@
 #include "SVGGeometryFrame.h"
 #include "nsTreeBodyFrame.h"
 #include "nsTreeColumns.h"
 #include "nsTreeUtils.h"
 #include "nsXBLPrototypeBinding.h"
 #include "nsXBLBinding.h"
 #include "mozilla/ArrayUtils.h"
 #include "mozilla/dom/DOMStringList.h"
+#include "mozilla/dom/EventTarget.h"
 #include "mozilla/Preferences.h"
 #include "mozilla/Services.h"
 #include "nsDeckFrame.h"
 
 #ifdef MOZ_XUL
 #include "XULAlertAccessible.h"
 #include "XULColorPickerAccessible.h"
 #include "XULComboboxAccessible.h"
@@ -370,17 +371,17 @@ nsAccessibilityService::ListenersChanged
 {
   uint32_t targetCount;
   nsresult rv = aEventChanges->GetLength(&targetCount);
   NS_ENSURE_SUCCESS(rv, rv);
 
   for (uint32_t i = 0 ; i < targetCount ; i++) {
     nsCOMPtr<nsIEventListenerChange> change = do_QueryElementAt(aEventChanges, i);
 
-    nsCOMPtr<nsIDOMEventTarget> target;
+    RefPtr<EventTarget> target;
     change->GetTarget(getter_AddRefs(target));
     nsCOMPtr<nsIContent> node(do_QueryInterface(target));
     if (!node || !node->IsHTMLElement()) {
       continue;
     }
 
     uint32_t changeCount;
     change->GetCountOfEventListenerChangesAffectingAccessibility(&changeCount);
--- a/browser/components/sessionstore/nsISessionStoreUtils.idl
+++ b/browser/components/sessionstore/nsISessionStoreUtils.idl
@@ -1,16 +1,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 "nsISupports.idl"
 
 interface mozIDOMWindowProxy;
-interface nsIDOMEventTarget;
+webidl EventTarget;
 
 /**
  * A callback passed to nsISessionStoreUtils.forEachNonDynamicChildFrame().
  */
 [function, scriptable, uuid(8199ebf7-76c0-43d6-bcbe-913dd3de3ebf)]
 interface nsISessionStoreUtilsFrameCallback : nsISupports
 {
   /**
@@ -38,32 +38,30 @@ interface nsISessionStoreUtils : nsISupp
    * Takes the given listener, wraps it in a filter that filters out events from
    * dynamic docShells, and adds that filter as a listener for the given event
    * type on the given event target.  The listener that was added is returned
    * (as nsISupports) so that it can later be removed via
    * removeDynamicFrameFilteredListener.
    *
    * This is implemented as a native filter, rather than a JS-based one, for
    * performance reasons.
-   *
-   * Once bug 1444991 is fixed, this should start taking an EventTarget.
    */
   [implicit_jscontext]
-  nsISupports addDynamicFrameFilteredListener(in nsIDOMEventTarget target,
+  nsISupports addDynamicFrameFilteredListener(in EventTarget target,
                                               in AString type,
                                               in jsval listener,
                                               in boolean useCapture);
 
   /**
    * Remove the passed-in filtered listener from the given event target, if it's
    * currently a listener for the given event type there.  The 'listener'
    * argument must be something that was returned by
    * addDynamicFrameFilteredListener.
    *
    * This is needed, instead of the normal removeEventListener, because the
    * caller doesn't actually have something that WebIDL considers an
    * EventListener.
    */
-  void removeDynamicFrameFilteredListener(in nsIDOMEventTarget target,
+  void removeDynamicFrameFilteredListener(in EventTarget target,
                                           in AString type,
                                           in nsISupports listener,
                                           in boolean useCapture);
 };
--- a/browser/components/sessionstore/nsSessionStoreUtils.cpp
+++ b/browser/components/sessionstore/nsSessionStoreUtils.cpp
@@ -112,50 +112,48 @@ nsSessionStoreUtils::ForEachNonDynamicCh
 
     aCallback->HandleFrame(item->GetWindow(), childOffset);
   }
 
   return NS_OK;
 }
 
 NS_IMETHODIMP
-nsSessionStoreUtils::AddDynamicFrameFilteredListener(nsIDOMEventTarget* aTarget,
+nsSessionStoreUtils::AddDynamicFrameFilteredListener(EventTarget* aTarget,
                                                      const nsAString& aType,
                                                      JS::Handle<JS::Value> aListener,
                                                      bool aUseCapture,
                                                      JSContext* aCx,
                                                      nsISupports** aResult)
 {
   if (NS_WARN_IF(!aListener.isObject())) {
     return NS_ERROR_INVALID_ARG;
   }
 
-  nsCOMPtr<EventTarget> target = do_QueryInterface(aTarget);
-  NS_ENSURE_TRUE(target, NS_ERROR_NO_INTERFACE);
+  NS_ENSURE_TRUE(aTarget, NS_ERROR_NO_INTERFACE);
 
   JS::Rooted<JSObject*> obj(aCx, &aListener.toObject());
   RefPtr<EventListener> listener =
     new EventListener(aCx, obj, GetIncumbentGlobal());
 
   nsCOMPtr<nsIDOMEventListener> filter(new DynamicFrameEventFilter(listener));
 
-  nsresult rv = target->AddEventListener(aType, filter, aUseCapture);
+  nsresult rv = aTarget->AddEventListener(aType, filter, aUseCapture);
   NS_ENSURE_SUCCESS(rv, rv);
 
   filter.forget(aResult);
   return NS_OK;
 }
 
 NS_IMETHODIMP
-nsSessionStoreUtils::RemoveDynamicFrameFilteredListener(nsIDOMEventTarget* aTarget,
+nsSessionStoreUtils::RemoveDynamicFrameFilteredListener(EventTarget* aTarget,
                                                         const nsAString& aType,
                                                         nsISupports* aListener,
                                                         bool aUseCapture)
 {
-  nsCOMPtr<EventTarget> target = do_QueryInterface(aTarget);
-  NS_ENSURE_TRUE(target, NS_ERROR_NO_INTERFACE);
+  NS_ENSURE_TRUE(aTarget, NS_ERROR_NO_INTERFACE);
 
   nsCOMPtr<nsIDOMEventListener> listener = do_QueryInterface(aListener);
   NS_ENSURE_TRUE(listener, NS_ERROR_NO_INTERFACE);
 
-  target->RemoveEventListener(aType, listener, aUseCapture);
+  aTarget->RemoveEventListener(aType, listener, aUseCapture);
   return NS_OK;
 }
--- a/docshell/base/nsDocShell.cpp
+++ b/docshell/base/nsDocShell.cpp
@@ -1380,31 +1380,30 @@ nsDocShell::GetContentViewer(nsIContentV
   NS_ENSURE_ARG_POINTER(aContentViewer);
 
   *aContentViewer = mContentViewer;
   NS_IF_ADDREF(*aContentViewer);
   return NS_OK;
 }
 
 NS_IMETHODIMP
-nsDocShell::SetChromeEventHandler(nsIDOMEventTarget* aChromeEventHandler)
+nsDocShell::SetChromeEventHandler(EventTarget* aChromeEventHandler)
 {
   // Weak reference. Don't addref.
-  nsCOMPtr<EventTarget> handler = do_QueryInterface(aChromeEventHandler);
-  mChromeEventHandler = handler.get();
+  mChromeEventHandler = aChromeEventHandler;
 
   if (mScriptGlobal) {
     mScriptGlobal->SetChromeEventHandler(mChromeEventHandler);
   }
 
   return NS_OK;
 }
 
 NS_IMETHODIMP
-nsDocShell::GetChromeEventHandler(nsIDOMEventTarget** aChromeEventHandler)
+nsDocShell::GetChromeEventHandler(EventTarget** aChromeEventHandler)
 {
   NS_ENSURE_ARG_POINTER(aChromeEventHandler);
   nsCOMPtr<EventTarget> handler = mChromeEventHandler;
   handler.forget(aChromeEventHandler);
   return NS_OK;
 }
 
 NS_IMETHODIMP
--- a/docshell/base/nsIDocShell.idl
+++ b/docshell/base/nsIDocShell.idl
@@ -34,17 +34,16 @@ class ClientSource;
 [ptr] native nsIPresShell(nsIPresShell);
 [ref] native MaybeURI(mozilla::Maybe<nsCOMPtr<nsIURI>>);
 [ref] native Encoding(const mozilla::Encoding*);
       native UniqueClientSource(mozilla::UniquePtr<mozilla::dom::ClientSource>);
 
 interface nsIURI;
 interface nsIChannel;
 interface nsIContentViewer;
-interface nsIDOMEventTarget;
 interface nsIDocShellLoadInfo;
 interface nsIEditor;
 interface nsIEditingSession;
 interface nsISimpleEnumerator;
 interface nsIInputStream;
 interface nsIRequest;
 interface nsISHEntry;
 interface nsILayoutHistoryState;
@@ -58,16 +57,18 @@ interface nsIReflowObserver;
 interface nsIScrollObserver;
 interface nsITabParent;
 interface nsITabChild;
 interface nsICommandManager;
 interface nsICommandParams;
 interface nsILoadURIDelegate;
 native TabChildRef(already_AddRefed<nsITabChild>);
 
+webidl EventTarget;
+
 [scriptable, builtinclass, uuid(049234fe-da10-478b-bc5d-bc6f9a1ba63d)]
 interface nsIDocShell : nsIDocShellTreeItem
 {
   /**
    * Loads a given URI.  This will give priority to loading the requested URI
    * in the object implementing this interface.  If it can't be loaded here
    * however, the URL dispatcher will go through its normal process of content
    * loading.
@@ -281,17 +282,17 @@ interface nsIDocShell : nsIDocShellTreeI
    * change as the underlying content changes.
    */
   readonly attribute nsIContentViewer contentViewer;
 
   /**
    * This attribute allows chrome to tie in to handle DOM events that may
    * be of interest to chrome.
    */
-  attribute nsIDOMEventTarget chromeEventHandler;
+  attribute EventTarget chromeEventHandler;
 
   /**
    * This allows chrome to set a custom User agent on a specific docshell
    */
   attribute DOMString customUserAgent;
 
   /**
    * Whether CSS error reporting is enabled.
--- a/dom/base/nsDOMWindowUtils.cpp
+++ b/dom/base/nsDOMWindowUtils.cpp
@@ -3700,24 +3700,24 @@ nsDOMWindowUtils::GetPaintFlashing(bool*
   nsPresContext* presContext = GetPresContext();
   if (presContext) {
     *aRetVal = presContext->GetPaintFlashing();
   }
   return NS_OK;
 }
 
 NS_IMETHODIMP
-nsDOMWindowUtils::DispatchEventToChromeOnly(nsIDOMEventTarget* aTarget,
+nsDOMWindowUtils::DispatchEventToChromeOnly(EventTarget* aTarget,
                                             nsIDOMEvent* aEvent,
                                             bool* aRetVal)
 {
   *aRetVal = false;
   NS_ENSURE_STATE(aTarget && aEvent);
   aEvent->WidgetEventPtr()->mFlags.mOnlyChromeDispatch = true;
-  *aRetVal = EventTarget::From(aTarget)->
+  *aRetVal = aTarget->
     DispatchEvent(*aEvent->InternalDOMEvent(), CallerType::System, IgnoreErrors());
   return NS_OK;
 }
 
 NS_IMETHODIMP
 nsDOMWindowUtils::RequestCompositorProperty(const nsAString& property,
                                             float* aResult)
 {
--- a/dom/base/nsFrameLoader.cpp
+++ b/dom/base/nsFrameLoader.cpp
@@ -2049,23 +2049,23 @@ nsFrameLoader::MaybeCreateDocShell()
                            parentDocShell);
 
   if (mIsTopLevelContent) {
     mDocShell->SetCreatedDynamically(false);
   }
 
   // Make sure all shells have links back to the content element
   // in the nearest enclosing chrome shell.
-  nsCOMPtr<nsIDOMEventTarget> chromeEventHandler;
+  RefPtr<EventTarget> chromeEventHandler;
 
   if (parentType == nsIDocShellTreeItem::typeChrome) {
     // Our parent shell is a chrome shell. It is therefore our nearest
     // enclosing chrome shell.
 
-    chromeEventHandler = do_QueryInterface(mOwnerContent);
+    chromeEventHandler = mOwnerContent;
     NS_ASSERTION(chromeEventHandler,
                  "This mContent should implement this.");
   } else {
     // Our parent shell is a content shell. Get the chrome event
     // handler from it and use that for our shell as well.
 
     parentDocShell->GetChromeEventHandler(getter_AddRefs(chromeEventHandler));
   }
--- a/dom/base/nsGlobalWindowOuter.cpp
+++ b/dom/base/nsGlobalWindowOuter.cpp
@@ -12,16 +12,17 @@
 
 // Local Includes
 #include "Navigator.h"
 #include "nsContentSecurityManager.h"
 #include "nsScreen.h"
 #include "nsHistory.h"
 #include "nsDOMNavigationTiming.h"
 #include "nsIDOMStorageManager.h"
+#include "mozilla/dom/EventTarget.h"
 #include "mozilla/dom/LocalStorage.h"
 #include "mozilla/dom/Storage.h"
 #include "mozilla/dom/IdleRequest.h"
 #include "mozilla/dom/Performance.h"
 #include "mozilla/dom/StorageEvent.h"
 #include "mozilla/dom/StorageEventBinding.h"
 #include "mozilla/dom/StorageNotifierService.h"
 #include "mozilla/dom/StorageUtils.h"
@@ -2129,17 +2130,17 @@ nsGlobalWindowOuter::SetDocShell(nsIDocS
     !mIsChrome && GetScriptableTopInternal() == this;
 
   if (mFrames) {
     mFrames->SetDocShell(aDocShell);
   }
 
   // Get our enclosing chrome shell and retrieve its global window impl, so
   // that we can do some forwarding to the chrome document.
-  nsCOMPtr<nsIDOMEventTarget> chromeEventHandler;
+  RefPtr<EventTarget> chromeEventHandler;
   mDocShell->GetChromeEventHandler(getter_AddRefs(chromeEventHandler));
   mChromeEventHandler = do_QueryInterface(chromeEventHandler);
   if (!mChromeEventHandler) {
     // We have no chrome event handler. If we have a parent,
     // get our chrome event handler from the parent. If
     // we don't have a parent, then we need to make a new
     // window root object that will function as a chrome event
     // handler and receive all events that occur anywhere inside
--- a/dom/base/nsISlowScriptDebug.idl
+++ b/dom/base/nsISlowScriptDebug.idl
@@ -1,33 +1,34 @@
 /* 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 "nsISupports.idl"
 
 interface nsIDOMWindow;
-interface nsIDOMEventTarget;
+
+webidl EventTarget;
 
 [scriptable, function, uuid(f7dbb80c-5d1e-4fd9-b55c-a9ffda4a75b1)]
 interface nsISlowScriptDebugCallback : nsISupports
 {
   void handleSlowScriptDebug(in nsIDOMWindow aWindow);
 };
 
 [scriptable, function, uuid(b1c6ecd0-8fa4-11e4-b4a9-0800200c9a66)]
 interface nsISlowScriptDebuggerStartupCallback : nsISupports
 {
   void finishDebuggerStartup();
 };
 
 [scriptable, function, uuid(dbee14b0-8fa0-11e4-b4a9-0800200c9a66)]
 interface nsISlowScriptDebugRemoteCallback : nsISupports
 {
-  void handleSlowScriptDebug(in nsIDOMEventTarget aBrowser,
+  void handleSlowScriptDebug(in EventTarget aBrowser,
                              in nsISlowScriptDebuggerStartupCallback aCallback);
 };
 
 [scriptable, uuid(f75d4164-3aa7-4395-ba44-a5f95b2e8427)]
 interface nsISlowScriptDebug : nsISupports
 {
   attribute nsISlowScriptDebugCallback activationHandler;
   attribute nsISlowScriptDebugRemoteCallback remoteActivationHandler;
--- a/dom/events/Event.cpp
+++ b/dom/events/Event.cpp
@@ -587,19 +587,19 @@ Event::DuplicatePrivateData()
   mPresContext = nullptr;
   mEventIsInternal = true;
   mPrivateDataDuplicated = true;
 
   return NS_OK;
 }
 
 NS_IMETHODIMP
-Event::SetTarget(nsIDOMEventTarget* aTarget)
+Event::SetTarget(EventTarget* aTarget)
 {
-  mEvent->mTarget = do_QueryInterface(aTarget);
+  mEvent->mTarget = aTarget;
   return NS_OK;
 }
 
 NS_IMETHODIMP_(bool)
 Event::IsDispatchStopped()
 {
   return mEvent->PropagationStopped();
 }
--- a/dom/events/EventListenerService.cpp
+++ b/dom/events/EventListenerService.cpp
@@ -30,29 +30,29 @@ using namespace dom;
  ******************************************************************************/
 
 NS_IMPL_ISUPPORTS(EventListenerChange, nsIEventListenerChange)
 
 EventListenerChange::~EventListenerChange()
 {
 }
 
-EventListenerChange::EventListenerChange(dom::EventTarget* aTarget) :
+EventListenerChange::EventListenerChange(EventTarget* aTarget) :
   mTarget(aTarget)
 {
 }
 
 void
 EventListenerChange::AddChangedListenerName(nsAtom* aEventName)
 {
   mChangedListenerNames.AppendElement(aEventName);
 }
 
 NS_IMETHODIMP
-EventListenerChange::GetTarget(nsIDOMEventTarget** aTarget)
+EventListenerChange::GetTarget(EventTarget** aTarget)
 {
   NS_ENSURE_ARG_POINTER(aTarget);
   NS_ADDREF(*aTarget = mTarget);
   return NS_OK;
 }
 
 NS_IMETHODIMP
 EventListenerChange::GetCountOfEventListenerChangesAffectingAccessibility(
@@ -209,85 +209,81 @@ EventListenerService::EventListenerServi
 
 EventListenerService::~EventListenerService()
 {
   MOZ_ASSERT(sInstance == this);
   sInstance = nullptr;
 }
 
 NS_IMETHODIMP
-EventListenerService::GetListenerInfoFor(nsIDOMEventTarget* aEventTarget,
+EventListenerService::GetListenerInfoFor(EventTarget* aEventTarget,
                                          uint32_t* aCount,
                                          nsIEventListenerInfo*** aOutArray)
 {
   NS_ENSURE_ARG_POINTER(aEventTarget);
   *aCount = 0;
   *aOutArray = nullptr;
   nsCOMArray<nsIEventListenerInfo> listenerInfos;
 
-  nsCOMPtr<EventTarget> eventTarget = do_QueryInterface(aEventTarget);
-  NS_ENSURE_TRUE(eventTarget, NS_ERROR_NO_INTERFACE);
-
-  EventListenerManager* elm = eventTarget->GetExistingListenerManager();
+  EventListenerManager* elm = aEventTarget->GetExistingListenerManager();
   if (elm) {
     elm->GetListenerInfo(&listenerInfos);
   }
 
   int32_t count = listenerInfos.Count();
   if (count == 0) {
     return NS_OK;
   }
 
   listenerInfos.Forget(aOutArray);
   *aCount = count;
   return NS_OK;
 }
 
 NS_IMETHODIMP
-EventListenerService::GetEventTargetChainFor(nsIDOMEventTarget* aEventTarget,
+EventListenerService::GetEventTargetChainFor(EventTarget* aEventTarget,
                                              bool aComposed,
                                              uint32_t* aCount,
-                                             nsIDOMEventTarget*** aOutArray)
+                                             EventTarget*** aOutArray)
 {
   *aCount = 0;
   *aOutArray = nullptr;
   NS_ENSURE_ARG(aEventTarget);
   WidgetEvent event(true, eVoidEvent);
   event.SetComposed(aComposed);
   nsTArray<EventTarget*> targets;
   nsresult rv = EventDispatcher::Dispatch(aEventTarget, nullptr, &event,
                                           nullptr, nullptr, nullptr, &targets);
   NS_ENSURE_SUCCESS(rv, rv);
   int32_t count = targets.Length();
   if (count == 0) {
     return NS_OK;
   }
 
   *aOutArray =
-    static_cast<nsIDOMEventTarget**>(
-      moz_xmalloc(sizeof(nsIDOMEventTarget*) * count));
+    static_cast<EventTarget**>(
+      moz_xmalloc(sizeof(EventTarget*) * count));
   NS_ENSURE_TRUE(*aOutArray, NS_ERROR_OUT_OF_MEMORY);
 
   for (int32_t i = 0; i < count; ++i) {
     NS_ADDREF((*aOutArray)[i] = targets[i]);
   }
   *aCount = count;
 
   return NS_OK;
 }
 
 NS_IMETHODIMP
-EventListenerService::HasListenersFor(nsIDOMEventTarget* aEventTarget,
+EventListenerService::HasListenersFor(EventTarget* aEventTarget,
                                       const nsAString& aType,
                                       bool* aRetVal)
 {
-  nsCOMPtr<EventTarget> eventTarget = do_QueryInterface(aEventTarget);
-  NS_ENSURE_TRUE(eventTarget, NS_ERROR_NO_INTERFACE);
+  NS_ENSURE_TRUE(aEventTarget, NS_ERROR_UNEXPECTED);
 
-  EventListenerManager* elm = eventTarget->GetExistingListenerManager();
+  EventListenerManager* elm = aEventTarget->GetExistingListenerManager();
   *aRetVal = elm && elm->HasListenersFor(aType);
   return NS_OK;
 }
 
 static already_AddRefed<EventListener>
 ToEventListener(JSContext* aCx, JS::Handle<JS::Value> aValue)
 {
   if (NS_WARN_IF(!aValue.isObject())) {
@@ -296,113 +292,105 @@ ToEventListener(JSContext* aCx, JS::Hand
 
   JS::Rooted<JSObject*> obj(aCx, &aValue.toObject());
   RefPtr<EventListener> listener =
     new EventListener(aCx, obj, GetIncumbentGlobal());
   return listener.forget();
 }
 
 NS_IMETHODIMP
-EventListenerService::AddSystemEventListener(nsIDOMEventTarget *aTarget,
+EventListenerService::AddSystemEventListener(EventTarget *aTarget,
                                              const nsAString& aType,
                                              JS::Handle<JS::Value> aListener,
                                              bool aUseCapture,
                                              JSContext* aCx)
 {
   NS_PRECONDITION(aTarget, "Missing target");
 
-  nsCOMPtr<EventTarget> eventTarget = do_QueryInterface(aTarget);
-  NS_ENSURE_TRUE(eventTarget, NS_ERROR_NO_INTERFACE);
+  NS_ENSURE_TRUE(aTarget, NS_ERROR_UNEXPECTED);
 
   RefPtr<EventListener> listener = ToEventListener(aCx, aListener);
   if (!listener) {
     return NS_ERROR_UNEXPECTED;
   }
 
-  EventListenerManager* manager = eventTarget->GetOrCreateListenerManager();
+  EventListenerManager* manager = aTarget->GetOrCreateListenerManager();
   NS_ENSURE_STATE(manager);
 
   EventListenerFlags flags =
     aUseCapture ? TrustedEventsAtSystemGroupCapture() :
                   TrustedEventsAtSystemGroupBubble();
   manager->AddEventListenerByType(listener, aType, flags);
   return NS_OK;
 }
 
 NS_IMETHODIMP
-EventListenerService::RemoveSystemEventListener(nsIDOMEventTarget *aTarget,
+EventListenerService::RemoveSystemEventListener(EventTarget *aTarget,
                                                 const nsAString& aType,
                                                 JS::Handle<JS::Value> aListener,
                                                 bool aUseCapture,
                                                 JSContext* aCx)
 {
   NS_PRECONDITION(aTarget, "Missing target");
 
-  nsCOMPtr<EventTarget> eventTarget = do_QueryInterface(aTarget);
-  NS_ENSURE_TRUE(eventTarget, NS_ERROR_NO_INTERFACE);
+  NS_ENSURE_TRUE(aTarget, NS_ERROR_UNEXPECTED);
 
   RefPtr<EventListener> listener = ToEventListener(aCx, aListener);
   if (!listener) {
     return NS_ERROR_UNEXPECTED;
   }
 
-  EventListenerManager* manager = eventTarget->GetExistingListenerManager();
+  EventListenerManager* manager = aTarget->GetExistingListenerManager();
   if (manager) {
     EventListenerFlags flags =
       aUseCapture ? TrustedEventsAtSystemGroupCapture() :
                     TrustedEventsAtSystemGroupBubble();
     manager->RemoveEventListenerByType(listener, aType, flags);
   }
 
   return NS_OK;
 }
 
 NS_IMETHODIMP
-EventListenerService::AddListenerForAllEvents(nsIDOMEventTarget* aTarget,
+EventListenerService::AddListenerForAllEvents(EventTarget* aTarget,
                                               JS::Handle<JS::Value> aListener,
                                               bool aUseCapture,
                                               bool aWantsUntrusted,
                                               bool aSystemEventGroup,
                                               JSContext* aCx)
 {
   NS_ENSURE_STATE(aTarget);
 
-  nsCOMPtr<EventTarget> eventTarget = do_QueryInterface(aTarget);
-  NS_ENSURE_TRUE(eventTarget, NS_ERROR_NO_INTERFACE);
-
   RefPtr<EventListener> listener = ToEventListener(aCx, aListener);
   if (!listener) {
     return NS_ERROR_UNEXPECTED;
   }
 
-  EventListenerManager* manager = eventTarget->GetOrCreateListenerManager();
+  EventListenerManager* manager = aTarget->GetOrCreateListenerManager();
   NS_ENSURE_STATE(manager);
   manager->AddListenerForAllEvents(listener, aUseCapture, aWantsUntrusted,
                                    aSystemEventGroup);
   return NS_OK;
 }
 
 NS_IMETHODIMP
-EventListenerService::RemoveListenerForAllEvents(nsIDOMEventTarget* aTarget,
+EventListenerService::RemoveListenerForAllEvents(EventTarget* aTarget,
                                                  JS::Handle<JS::Value> aListener,
                                                  bool aUseCapture,
                                                  bool aSystemEventGroup,
                                                  JSContext* aCx)
 {
   NS_ENSURE_STATE(aTarget);
 
-  nsCOMPtr<EventTarget> eventTarget = do_QueryInterface(aTarget);
-  NS_ENSURE_TRUE(eventTarget, NS_ERROR_NO_INTERFACE);
-
   RefPtr<EventListener> listener = ToEventListener(aCx, aListener);
   if (!listener) {
     return NS_ERROR_UNEXPECTED;
   }
 
-  EventListenerManager* manager = eventTarget->GetExistingListenerManager();
+  EventListenerManager* manager = aTarget->GetExistingListenerManager();
   if (manager) {
     manager->RemoveListenerForAllEvents(listener, aUseCapture, aSystemEventGroup);
   }
   return NS_OK;
 }
 
 NS_IMETHODIMP
 EventListenerService::AddListenerChangeListener(nsIListenerChangeListener* aListener)
--- a/dom/events/EventTarget.h
+++ b/dom/events/EventTarget.h
@@ -40,21 +40,16 @@ class GlobalObject;
   { 0xb1, 0x3d, 0x67, 0xb9, 0x40, 0xfc, 0x82, 0xe4 } }
 
 class EventTarget : public nsIDOMEventTarget,
                     public nsWrapperCache
 {
 public:
   NS_DECLARE_STATIC_IID_ACCESSOR(NS_EVENTTARGET_IID)
 
-  static EventTarget* From(nsIDOMEventTarget* aTarget)
-  {
-    return static_cast<EventTarget*>(aTarget);
-  }
-
   // WebIDL API
   static already_AddRefed<EventTarget> Constructor(const GlobalObject& aGlobal,
                                                    ErrorResult& aRv);
   void AddEventListener(const nsAString& aType,
                         EventListener* aCallback,
                         const AddEventListenerOptionsOrBoolean& aOptions,
                         const Nullable<bool>& aWantsUntrusted,
                         ErrorResult& aRv);
--- a/dom/events/nsIEventListenerService.idl
+++ b/dom/events/nsIEventListenerService.idl
@@ -1,26 +1,27 @@
 /* -*- 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 "nsISupports.idl"
 
-interface nsIDOMEventTarget;
+webidl EventTarget;
+
 interface nsIArray;
 
 /**
  * Contains an event target along with a count of event listener changes
  * affecting accessibility.
  */
 [scriptable, uuid(07222b02-da12-4cf4-b2f7-761da007a8d8)]
 interface nsIEventListenerChange : nsISupports
 {
-  readonly attribute nsIDOMEventTarget target;
+  readonly attribute EventTarget target;
 
   [noscript]
   readonly attribute uint32_t countOfEventListenerChangesAffectingAccessibility;
 };
 
 [scriptable, function, uuid(aa7c95f6-d3b5-44b3-9597-1d9f19b9c5f2)]
 interface nsIListenerChangeListener : nsISupports
 {
@@ -60,68 +61,68 @@ interface nsIEventListenerInfo : nsISupp
 
 [scriptable, uuid(77aab5f7-213d-4db4-9f22-e46dfb774f15)]
 interface nsIEventListenerService : nsISupports
 {
   /**
    * Returns an array of nsIEventListenerInfo objects.
    * If aEventTarget doesn't have any listeners, this returns null.
    */
-  void getListenerInfoFor(in nsIDOMEventTarget aEventTarget,
+  void getListenerInfoFor(in EventTarget aEventTarget,
                           [optional] out unsigned long aCount,
                           [retval, array, size_is(aCount)] out
                             nsIEventListenerInfo aOutArray);
 
   /**
    * Returns an array of event targets.
    * aEventTarget will be at index 0.
    * The objects are the ones that would be used as DOMEvent.currentTarget while
    * dispatching an event to aEventTarget
    * @note Some events, especially 'load', may actually have a shorter
    *       event target chain than what this methods returns.
    */
-  void getEventTargetChainFor(in nsIDOMEventTarget aEventTarget,
+  void getEventTargetChainFor(in EventTarget aEventTarget,
                               in boolean composed,
                               [optional] out unsigned long aCount,
                               [retval, array, size_is(aCount)] out
-                                nsIDOMEventTarget aOutArray);
+                                EventTarget aOutArray);
 
   /**
    * Returns true if a event target has any listener for the given type.
    */
-  boolean hasListenersFor(in nsIDOMEventTarget aEventTarget,
+  boolean hasListenersFor(in EventTarget aEventTarget,
                           in DOMString aType);
 
   /**
    * Add a system-group eventlistener to a event target.
    */
   [implicit_jscontext]
-  void addSystemEventListener(in nsIDOMEventTarget target,
+  void addSystemEventListener(in EventTarget target,
                               in DOMString type,
                               in jsval listener,
                               in boolean useCapture);
 
   /**
    * Remove a system-group eventlistener from a event target.
    */
   [implicit_jscontext]
-  void removeSystemEventListener(in nsIDOMEventTarget target,
+  void removeSystemEventListener(in EventTarget target,
                                  in DOMString type,
                                  in jsval listener,
                                  in boolean useCapture);
 
   [implicit_jscontext]
-  void addListenerForAllEvents(in nsIDOMEventTarget target,
+  void addListenerForAllEvents(in EventTarget target,
                                in jsval listener,
                                [optional] in boolean aUseCapture,
                                [optional] in boolean aWantsUntrusted,
                                [optional] in boolean aSystemEventGroup);
 
   [implicit_jscontext]
-  void removeListenerForAllEvents(in nsIDOMEventTarget target,
+  void removeListenerForAllEvents(in EventTarget target,
                                   in jsval listener,
                                   [optional] in boolean aUseCapture,
                                   [optional] in boolean aSystemEventGroup);
 
   void addListenerChangeListener(in nsIListenerChangeListener aListener);
   void removeListenerChangeListener(in nsIListenerChangeListener aListener);
 };
 
--- a/dom/interfaces/base/domstubs.idl
+++ b/dom/interfaces/base/domstubs.idl
@@ -31,16 +31,15 @@ class DOMException;
 %}
 
 // Base
 interface nsIDOMWindow;
 interface nsIDOMWindowCollection;
 
 // Events
 interface nsIDOMEvent;
-interface nsIDOMEventTarget;
 interface nsIDOMEventListener;
 
 // HTML
 interface nsIDOMHTMLHeadElement;
 
 // Range
 interface nsIDOMRange;
--- a/dom/interfaces/base/nsIDOMWindowUtils.idl
+++ b/dom/interfaces/base/nsIDOMWindowUtils.idl
@@ -36,25 +36,25 @@ interface nsIDOMNodeList;
 interface nsIDOMElement;
 interface nsIDOMEvent;
 interface nsIPreloadedStyleSheet;
 interface nsITransferable;
 interface nsIQueryContentEventResult;
 interface nsIDOMWindow;
 interface nsIFile;
 interface nsIURI;
-interface nsIDOMEventTarget;
 interface nsIRunnable;
 interface nsITranslationNodeList;
 interface nsIJSRAIIHelper;
 interface nsIContentPermissionRequest;
 interface nsIObserver;
 interface nsIDOMStorage;
 
 webidl DOMRect;
+webidl EventTarget;
 
 [scriptable, uuid(4d6732ca-9da7-4176-b8a1-8dde15cd0bf9)]
 interface nsIDOMWindowUtils : nsISupports {
 
   /**
    * Image animation mode of the window. When this attribute's value
    * is changed, the implementation should set all images in the window
    * to the given value. That is, when set to kDontAnimMode, all images
@@ -941,17 +941,17 @@ interface nsIDOMWindowUtils : nsISupport
                                        in boolean aTrusted);
 
   /**
    * Sets WidgetEvent::mFlags::mOnlyChromeDispatch to true to ensure that
    * the event is propagated only to chrome.
    * Event's .target property will be aTarget.
    * Returns the same value as what EventTarget.dispatchEvent does.
    */
-  boolean dispatchEventToChromeOnly(in nsIDOMEventTarget aTarget,
+  boolean dispatchEventToChromeOnly(in EventTarget aTarget,
                                     in nsIDOMEvent aEvent);
 
   /**
    * Returns the real classname (possibly of the mostly-transparent security
    * wrapper) of aObj.
    */
   [implicit_jscontext] string getClassName(in jsval aObject);
 
--- a/dom/interfaces/events/nsIDOMEvent.idl
+++ b/dom/interfaces/events/nsIDOMEvent.idl
@@ -1,17 +1,15 @@
 /* -*- Mode: IDL; 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 "domstubs.idl"
 
-interface nsIDOMEventTarget;
-
 [ptr] native WidgetEvent(mozilla::WidgetEvent);
 [ptr] native DOMEventPtr(mozilla::dom::Event);
 [ptr] native IPCMessagePtr(IPC::Message);
 [ptr] native ConstIPCMessagePtr(const IPC::Message);
 [ptr] native PickleIterator(PickleIterator);
 [ptr] native EventTargetPtr(mozilla::dom::EventTarget);
 %{C++
 #ifdef ERROR
@@ -28,16 +26,18 @@ class PickleIterator;
 namespace mozilla {
 namespace dom {
 class Event;
 class EventTarget;
 } // namespace dom
 } // namespace mozilla
 %}
 
+webidl EventTarget;
+
 /**
  * The nsIDOMEvent interface is the primary datatype for all events in
  * the Document Object Model.
  *
  * For more information on this interface please see 
  * http://dev.w3.org/2006/webapi/DOM-Level-3-Events/html/DOM3-Events.html and
  * http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html
  */
@@ -170,17 +170,17 @@ interface nsIDOMEvent : nsISupports
   const long CONTROL_MASK = 0x00000002;
   const long SHIFT_MASK   = 0x00000004;
   const long META_MASK    = 0x00000008;
 
   readonly attribute boolean isTrusted;
   attribute boolean cancelBubble;
 
   [noscript] void duplicatePrivateData();
-  [noscript] void setTarget(in nsIDOMEventTarget aTarget);
+  [noscript] void setTarget(in EventTarget aTarget);
   [notxpcom] boolean IsDispatchStopped();
   [notxpcom] WidgetEvent WidgetEventPtr();
   [noscript,notxpcom] void SetTrusted(in boolean aTrusted);
   [notxpcom] void Serialize(in IPCMessagePtr aMsg,
                             in boolean aSerializeInterfaceType);
   [notxpcom] boolean Deserialize(in ConstIPCMessagePtr aMsg, in PickleIterator aIter);
   [noscript,notxpcom] void SetOwner(in EventTargetPtr aOwner);
   [notxpcom] DOMEventPtr InternalDOMEvent();
--- a/dom/presentation/PresentationRequest.cpp
+++ b/dom/presentation/PresentationRequest.cpp
@@ -226,18 +226,17 @@ PresentationRequest::StartWithDevice(con
   }
 
   presentation->SetStartSessionUnsettled(true);
 
   // Get xul:browser element in parent process or nsWindowRoot object in child
   // process. If it's in child process, the corresponding xul:browser element
   // will be obtained at PresentationRequestParent::DoRequest in its parent
   // process.
-  nsCOMPtr<nsIDOMEventTarget> handler =
-    do_QueryInterface(GetOwner()->GetChromeEventHandler());
+  nsCOMPtr<EventTarget> handler = GetOwner()->GetChromeEventHandler();
   nsCOMPtr<nsIPrincipal> principal = doc->NodePrincipal();
   nsCOMPtr<nsIPresentationServiceCallback> callback =
     new PresentationRequesterCallback(this, id, promise);
   nsCOMPtr<nsIPresentationTransportBuilderConstructor> constructor =
     PresentationTransportBuilderConstructor::Create();
   rv = service->StartSession(mUrls,
                              id,
                              origin,
--- a/dom/presentation/PresentationService.cpp
+++ b/dom/presentation/PresentationService.cpp
@@ -102,17 +102,17 @@ public:
   NS_DECL_ISUPPORTS
   NS_DECL_NSIPRESENTATIONDEVICEREQUEST
 
   PresentationDeviceRequest(
               const nsTArray<nsString>& aUrls,
               const nsAString& aId,
               const nsAString& aOrigin,
               uint64_t aWindowId,
-              nsIDOMEventTarget* aEventTarget,
+              EventTarget* aEventTarget,
               nsIPrincipal* aPrincipal,
               nsIPresentationServiceCallback* aCallback,
               nsIPresentationTransportBuilderConstructor* aBuilderConstructor);
 
 private:
   virtual ~PresentationDeviceRequest() = default;
   nsresult CreateSessionInfo(nsIPresentationDevice* aDevice,
                              const nsAString& aSelectedRequestUrl);
@@ -131,17 +131,17 @@ LazyLogModule gPresentationLog("Presenta
 
 NS_IMPL_ISUPPORTS(PresentationDeviceRequest, nsIPresentationDeviceRequest)
 
 PresentationDeviceRequest::PresentationDeviceRequest(
                const nsTArray<nsString>& aUrls,
                const nsAString& aId,
                const nsAString& aOrigin,
                uint64_t aWindowId,
-               nsIDOMEventTarget* aEventTarget,
+               EventTarget* aEventTarget,
                nsIPrincipal* aPrincipal,
                nsIPresentationServiceCallback* aCallback,
                nsIPresentationTransportBuilderConstructor* aBuilderConstructor)
   : mRequestUrls(aUrls)
   , mId(aId)
   , mOrigin(aOrigin)
   , mWindowId(aWindowId)
   , mChromeEventHandler(do_GetWeakReference(aEventTarget))
@@ -165,19 +165,19 @@ PresentationDeviceRequest::GetOrigin(nsA
 
 NS_IMETHODIMP
 PresentationDeviceRequest::GetRequestURLs(nsIArray** aUrls)
 {
   return ConvertURLArrayHelper(mRequestUrls, aUrls);
 }
 
 NS_IMETHODIMP
-PresentationDeviceRequest::GetChromeEventHandler(nsIDOMEventTarget** aChromeEventHandler)
+PresentationDeviceRequest::GetChromeEventHandler(EventTarget** aChromeEventHandler)
 {
-  nsCOMPtr<nsIDOMEventTarget> handler(do_QueryReferent(mChromeEventHandler));
+  RefPtr<EventTarget> handler(do_QueryReferent(mChromeEventHandler));
   handler.forget(aChromeEventHandler);
   return NS_OK;
 }
 
 NS_IMETHODIMP
 PresentationDeviceRequest::GetPrincipal(nsIPrincipal** aPrincipal)
 {
   nsCOMPtr<nsIPrincipal> principal(mPrincipal);
@@ -659,17 +659,17 @@ PresentationService::HandleReconnectRequ
 
 NS_IMETHODIMP
 PresentationService::StartSession(
                const nsTArray<nsString>& aUrls,
                const nsAString& aSessionId,
                const nsAString& aOrigin,
                const nsAString& aDeviceId,
                uint64_t aWindowId,
-               nsIDOMEventTarget* aEventTarget,
+               EventTarget* aEventTarget,
                nsIPrincipal* aPrincipal,
                nsIPresentationServiceCallback* aCallback,
                nsIPresentationTransportBuilderConstructor* aBuilderConstructor)
 {
   PRES_DEBUG("%s:id[%s]\n", __func__, NS_ConvertUTF16toUTF8(aSessionId).get());
 
   MOZ_ASSERT(NS_IsMainThread());
   MOZ_ASSERT(aCallback);
--- a/dom/presentation/interfaces/nsIPresentationDevicePrompt.idl
+++ b/dom/presentation/interfaces/nsIPresentationDevicePrompt.idl
@@ -1,19 +1,20 @@
 /* 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 "nsISupports.idl"
 
 interface nsIArray;
-interface nsIDOMEventTarget;
 interface nsIPresentationDevice;
 interface nsIPrincipal;
 
+webidl EventTarget;
+
 %{C++
 #define PRESENTATION_DEVICE_PROMPT_CONTRACTID "@mozilla.org/presentation-device/prompt;1"
 %}
 
 /*
  * The information and callbacks for device selection
  */
 [scriptable, uuid(b2aa7f6a-9448-446a-bba4-9c29638b0ed4)]
@@ -21,17 +22,17 @@ interface nsIPresentationDeviceRequest :
 {
   // The origin which initiate the request.
   readonly attribute DOMString origin;
 
   // The array of candidate URLs.
   readonly attribute nsIArray requestURLs;
 
   // The XUL browser element that the request was originated in.
-  readonly attribute nsIDOMEventTarget chromeEventHandler;
+  readonly attribute EventTarget chromeEventHandler;
 
   // The principal of the request.
   readonly attribute nsIPrincipal principal;
 
   /*
    * Callback after selecting a device
    * @param device The selected device.
    */
--- a/dom/presentation/interfaces/nsIPresentationService.idl
+++ b/dom/presentation/interfaces/nsIPresentationService.idl
@@ -1,23 +1,24 @@
 /* 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 "nsISupports.idl"
 
 interface nsIDOMBlob;
-interface nsIDOMEventTarget;
 interface nsIInputStream;
 interface nsIPresentationAvailabilityListener;
 interface nsIPresentationRespondingListener;
 interface nsIPresentationSessionListener;
 interface nsIPresentationTransportBuilderConstructor;
 interface nsIPrincipal;
 
+webidl EventTarget;
+
 %{C++
 #define PRESENTATION_SERVICE_CID \
   { 0x1d9bb10c, 0xc0ab, 0x4fe8, \
     { 0x9e, 0x4f, 0x40, 0x58, 0xb8, 0x51, 0x98, 0x32 } }
 #define PRESENTATION_SERVICE_CONTRACTID \
   "@mozilla.org/presentation/presentationservice;1"
 
 #include "nsStringFwd.h"
@@ -78,17 +79,17 @@ interface nsIPresentationService : nsISu
    *                  Otherwise, NotifyError() is called with a error message.
    * @param constructor: The constructor for creating a transport builder.
    */
   [noscript] void startSession(in URLArrayRef urls,
                                in DOMString sessionId,
                                in DOMString origin,
                                in DOMString deviceId,
                                in unsigned long long windowId,
-                               in nsIDOMEventTarget eventTarget,
+                               in EventTarget eventTarget,
                                in nsIPrincipal principal,
                                in nsIPresentationServiceCallback callback,
                                in nsIPresentationTransportBuilderConstructor constructor);
 
   /*
    * Send the message to the session.
    *
    * @param sessionId: An ID to identify presentation session.
--- a/dom/presentation/ipc/PresentationIPCService.cpp
+++ b/dom/presentation/ipc/PresentationIPCService.cpp
@@ -56,17 +56,17 @@ PresentationIPCService::~PresentationIPC
 
 NS_IMETHODIMP
 PresentationIPCService::StartSession(
                const nsTArray<nsString>& aUrls,
                const nsAString& aSessionId,
                const nsAString& aOrigin,
                const nsAString& aDeviceId,
                uint64_t aWindowId,
-               nsIDOMEventTarget* aEventTarget,
+               EventTarget* aEventTarget,
                nsIPrincipal* aPrincipal,
                nsIPresentationServiceCallback* aCallback,
                nsIPresentationTransportBuilderConstructor* aBuilderConstructor)
 {
   if (aWindowId != 0) {
     AddRespondingSessionId(aWindowId,
                            aSessionId,
                            nsIPresentationService::ROLE_CONTROLLER);
--- a/dom/presentation/ipc/PresentationParent.cpp
+++ b/dom/presentation/ipc/PresentationParent.cpp
@@ -402,22 +402,22 @@ PresentationRequestParent::ActorDestroy(
 
 nsresult
 PresentationRequestParent::DoRequest(const StartSessionRequest& aRequest)
 {
   MOZ_ASSERT(mService);
 
   mSessionId = aRequest.sessionId();
 
-  nsCOMPtr<nsIDOMEventTarget> eventTarget;
+  RefPtr<EventTarget> eventTarget;
   ContentProcessManager* cpm = ContentProcessManager::GetSingleton();
   RefPtr<TabParent> tp =
     cpm->GetTopLevelTabParentByProcessAndTabId(mChildId, aRequest.tabId());
   if (tp) {
-    eventTarget = do_QueryInterface(tp->GetOwnerElement());
+    eventTarget = tp->GetOwnerElement();
   }
 
   RefPtr<PresentationParent> parent = static_cast<PresentationParent*>(Manager());
   nsCOMPtr<nsIPresentationTransportBuilderConstructor> constructor =
     new PresentationTransportBuilderConstructorIPC(parent);
   return mService->StartSession(aRequest.urls(), aRequest.sessionId(),
                                 aRequest.origin(), aRequest.deviceId(),
                                 aRequest.windowId(), eventTarget,