Bug 1449631 part 7. Remove nsIDOMEventTarget::GetTargetFor* methods. r=smaug
authorBoris Zbarsky <bzbarsky@mit.edu>
Thu, 05 Apr 2018 13:42:41 -0400
changeset 411929 433dba4e710415a040ca047a5f0cbcb94eeaf2d0
parent 411928 caa5bef6848122d106ad47fc7b2bf104d2d8ce3d
child 411930 15546aaa4d0999765a7f278058614d08082a4558
push id101783
push userbzbarsky@mozilla.com
push dateThu, 05 Apr 2018 17:44:01 +0000
treeherdermozilla-inbound@d32c2aed2886 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssmaug
bugs1449631
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 1449631 part 7. Remove nsIDOMEventTarget::GetTargetFor* methods. r=smaug MozReview-Commit-ID: AIzDo67mTDf
dom/base/nsGlobalWindowInner.cpp
dom/base/nsGlobalWindowInner.h
dom/base/nsGlobalWindowOuter.cpp
dom/base/nsGlobalWindowOuter.h
dom/base/nsINode.cpp
dom/base/nsWindowRoot.cpp
dom/events/DOMEventTargetHelper.cpp
dom/events/EventTarget.h
dom/interfaces/events/nsIDOMEventTarget.idl
widget/WidgetEventImpl.cpp
--- a/dom/base/nsGlobalWindowInner.cpp
+++ b/dom/base/nsGlobalWindowInner.cpp
@@ -1942,22 +1942,16 @@ nsGlobalWindowInner::UpdateParentTarget(
 }
 
 EventTarget*
 nsGlobalWindowInner::GetTargetForDOMEvent()
 {
   return GetOuterWindowInternal();
 }
 
-EventTarget*
-nsGlobalWindowInner::GetTargetForEventTargetChain()
-{
-  return this;
-}
-
 nsresult
 nsGlobalWindowInner::GetEventTargetParent(EventChainPreVisitor& aVisitor)
 {
   EventMessage msg = aVisitor.mEvent->mMessage;
 
   aVisitor.mCanHandle = true;
   aVisitor.mForceContentDispatch = true; //FIXME! Bug 329119
   if (msg == eResize && aVisitor.mEvent->IsTrusted()) {
--- a/dom/base/nsGlobalWindowInner.h
+++ b/dom/base/nsGlobalWindowInner.h
@@ -328,16 +328,18 @@ public:
                                 mozilla::dom::EventListener* aListener,
                                 const mozilla::dom::AddEventListenerOptionsOrBoolean& aOptions,
                                 const mozilla::dom::Nullable<bool>& aWantsUntrusted,
                                 mozilla::ErrorResult& aRv) override;
   virtual nsPIDOMWindowOuter* GetOwnerGlobalForBindings() override;
 
   virtual nsIGlobalObject* GetOwnerGlobal() const override;
 
+  EventTarget* GetTargetForDOMEvent() override;
+  
   using mozilla::dom::EventTarget::DispatchEvent;
   bool DispatchEvent(mozilla::dom::Event& aEvent,
                      mozilla::dom::CallerType aCallerType,
                      mozilla::ErrorResult& aRv) override;
 
   nsresult PostHandleEvent(mozilla::EventChainPostVisitor& aVisitor) override;
 
   // nsPIDOMWindow
--- a/dom/base/nsGlobalWindowOuter.cpp
+++ b/dom/base/nsGlobalWindowOuter.cpp
@@ -2327,22 +2327,16 @@ nsGlobalWindowOuter::UpdateParentTarget(
   if (!eventTarget) {
     eventTarget = mChromeEventHandler;
   }
 
   mParentTarget = eventTarget;
 }
 
 EventTarget*
-nsGlobalWindowOuter::GetTargetForDOMEvent()
-{
-  return GetOuterWindowInternal();
-}
-
-EventTarget*
 nsGlobalWindowOuter::GetTargetForEventTargetChain()
 {
   return GetCurrentInnerWindowInternal();
 }
 
 nsresult
 nsGlobalWindowOuter::GetEventTargetParent(EventChainPreVisitor& aVisitor)
 {
--- a/dom/base/nsGlobalWindowOuter.h
+++ b/dom/base/nsGlobalWindowOuter.h
@@ -285,16 +285,18 @@ public:
                                 mozilla::dom::EventListener* aListener,
                                 const mozilla::dom::AddEventListenerOptionsOrBoolean& aOptions,
                                 const mozilla::dom::Nullable<bool>& aWantsUntrusted,
                                 mozilla::ErrorResult& aRv) override;
   virtual nsPIDOMWindowOuter* GetOwnerGlobalForBindings() override;
 
   virtual nsIGlobalObject* GetOwnerGlobal() const override;
 
+  EventTarget* GetTargetForEventTargetChain() override;
+  
   using mozilla::dom::EventTarget::DispatchEvent;
   bool DispatchEvent(mozilla::dom::Event& aEvent,
                      mozilla::dom::CallerType aCallerType,
                      mozilla::ErrorResult& aRv) override;
 
   nsresult PostHandleEvent(mozilla::EventChainPostVisitor& aVisitor) override;
 
   // nsPIDOMWindow
--- a/dom/base/nsINode.cpp
+++ b/dom/base/nsINode.cpp
@@ -1011,18 +1011,16 @@ nsINode::LookupNamespaceURI(const nsAStr
   Element *element = GetNameSpaceElement();
   if (!element ||
       NS_FAILED(element->LookupNamespaceURIInternal(aNamespacePrefix,
                                                     aNamespaceURI))) {
     SetDOMStringToNull(aNamespaceURI);
   }
 }
 
-NS_IMPL_DOMTARGET_DEFAULTS(nsINode)
-
 NS_IMETHODIMP
 nsINode::AddEventListener(const nsAString& aType,
                           nsIDOMEventListener *aListener,
                           bool aUseCapture,
                           bool aWantsUntrusted,
                           uint8_t aOptionalArgc)
 {
   NS_ASSERTION(!aWantsUntrusted || aOptionalArgc > 1,
--- a/dom/base/nsWindowRoot.cpp
+++ b/dom/base/nsWindowRoot.cpp
@@ -65,18 +65,16 @@ NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(
   NS_INTERFACE_MAP_ENTRY(nsPIWindowRoot)
   NS_INTERFACE_MAP_ENTRY(nsIDOMEventTarget)
   NS_INTERFACE_MAP_ENTRY(mozilla::dom::EventTarget)
 NS_INTERFACE_MAP_END
 
 NS_IMPL_CYCLE_COLLECTING_ADDREF(nsWindowRoot)
 NS_IMPL_CYCLE_COLLECTING_RELEASE(nsWindowRoot)
 
-NS_IMPL_DOMTARGET_DEFAULTS(nsWindowRoot)
-
 bool
 nsWindowRoot::DispatchEvent(Event& aEvent, CallerType aCallerType,
                             ErrorResult& aRv)
 {
   nsEventStatus status = nsEventStatus_eIgnore;
   nsresult rv =  EventDispatcher::DispatchDOMEvent(
     static_cast<EventTarget*>(this), nullptr, &aEvent, nullptr, &status);
   bool retval = !aEvent.DefaultPrevented(aCallerType);
--- a/dom/events/DOMEventTargetHelper.cpp
+++ b/dom/events/DOMEventTargetHelper.cpp
@@ -80,18 +80,16 @@ NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(
   NS_INTERFACE_MAP_ENTRY(dom::EventTarget)
   NS_INTERFACE_MAP_ENTRY(DOMEventTargetHelper)
 NS_INTERFACE_MAP_END
 
 NS_IMPL_CYCLE_COLLECTING_ADDREF(DOMEventTargetHelper)
 NS_IMPL_CYCLE_COLLECTING_RELEASE_WITH_LAST_RELEASE(DOMEventTargetHelper,
                                                    LastRelease())
 
-NS_IMPL_DOMTARGET_DEFAULTS(DOMEventTargetHelper)
-
 DOMEventTargetHelper::~DOMEventTargetHelper()
 {
   if (mParentObject) {
     mParentObject->RemoveEventTargetObject(this);
   }
   if (mListenerManager) {
     mListenerManager->Disconnect();
   }
--- a/dom/events/EventTarget.h
+++ b/dom/events/EventTarget.h
@@ -75,16 +75,38 @@ public:
    * RemoveSystemEventListener() should be used if you have used
    * AddSystemEventListener().
    */
   void RemoveSystemEventListener(const nsAString& aType,
                                  nsIDOMEventListener* aListener,
                                  bool aUseCapture);
 
   /**
+   * Returns the EventTarget object which should be used as the target
+   * of DOMEvents.
+   * Usually |this| is returned, but for example Window (inner windw) returns
+   * the WindowProxy (outer window).
+   */
+  virtual EventTarget* GetTargetForDOMEvent()
+  {
+    return this;
+  };
+
+  /**
+   * Returns the EventTarget object which should be used as the target
+   * of the event and when constructing event target chain.
+   * Usually |this| is returned, but for example WindowProxy (outer window) returns
+   * the Window (inner window).
+   */
+  virtual EventTarget* GetTargetForEventTargetChain()
+  {
+    return this;
+  }
+
+  /**
    * The most general DispatchEvent method.  This is the one the bindings call.
    */
   virtual bool DispatchEvent(Event& aEvent, CallerType aCallerType,
                              ErrorResult& aRv) = 0;
 
   /**
    * A version of DispatchEvent you can use if you really don't care whether it
    * succeeds or not and whether default is prevented or not.
--- a/dom/interfaces/events/nsIDOMEventTarget.idl
+++ b/dom/interfaces/events/nsIDOMEventTarget.idl
@@ -133,32 +133,16 @@ interface nsIDOMEventTarget : nsISupport
                                   bool aWantsUntrusted)
   {
     return AddSystemEventListener(aType, aListener, aUseCapture,
                                   aWantsUntrusted, 2);
   }
 %}
 
   /**
-   * Returns the nsIDOMEventTarget object which should be used as the target
-   * of DOMEvents.
-   * Usually |this| is returned, but for example global object returns
-   * the outer object.
-   */
-   [notxpcom, nostdcall] EventTargetPtr GetTargetForDOMEvent();
-
-  /**
-   * Returns the nsIDOMEventTarget object which should be used as the target
-   * of the event and when constructing event target chain.
-   * Usually |this| is returned, but for example global object returns
-   * the inner object.
-   */
-   [notxpcom, nostdcall] EventTargetPtr GetTargetForEventTargetChain();
-
-  /**
    * Called before the capture phase of the event flow.
    * This is used to create the event target chain and implementations
    * should set the necessary members of EventChainPreVisitor.
    * At least aVisitor.mCanHandle must be set,
    * usually also aVisitor.mParentTarget if mCanHandle is PR_TRUE.
    * First one tells that this object can handle the aVisitor.mEvent event and
    * the latter one is the possible parent object for the event target chain.
    * @see EventDispatcher.h for more documentation about aVisitor.
@@ -166,16 +150,8 @@ interface nsIDOMEventTarget : nsISupport
    * @param aVisitor the visitor object which is used to create the
    *                 event target chain for event dispatching.
    *
    * @note Only EventDispatcher should call this method.
    */
   [noscript, nostdcall]
   void GetEventTargetParent(in EventChainPreVisitorRef aVisitor);
 };
-
-%{C++
-
-#define NS_IMPL_DOMTARGET_DEFAULTS(_class) \
-mozilla::dom::EventTarget* _class::GetTargetForDOMEvent() { return this; } \
-mozilla::dom::EventTarget* _class::GetTargetForEventTargetChain() { return this; }
-
-%}
--- a/widget/WidgetEventImpl.cpp
+++ b/widget/WidgetEventImpl.cpp
@@ -521,17 +521,17 @@ WidgetEvent::IsBlockedForFingerprintingR
 
 /******************************************************************************
  * mozilla::WidgetEvent
  *
  * Misc methods.
  ******************************************************************************/
 
 static dom::EventTarget*
-GetTargetForDOMEvent(nsIDOMEventTarget* aTarget)
+GetTargetForDOMEvent(dom::EventTarget* aTarget)
 {
   return aTarget ? aTarget->GetTargetForDOMEvent() : nullptr;
 }
 
 dom::EventTarget*
 WidgetEvent::GetDOMEventTarget() const
 {
   return GetTargetForDOMEvent(mTarget);