From 88937275cc72ecede72183eed2740b609aaa7d96 Mon Sep 17 00:00:00 2001 From: Boris Zbarsky Date: Thu, 5 Apr 2018 13:42:42 -0400 Subject: [PATCH] Bug 1449631 part 9. Remove nsIDOMEventTarget::AddEventListener. r=smaug Also switch the XPCOM-y version of EventTarget::AddEventListner to a Nullable for aWantsUntrusted. The three-arg overload of AddEventListener in ContentFrameMessageManager was never called, so all the AddEventListener overloads there are not needed. MozReview-Commit-ID: 4IhqHmPVWzE --- accessible/generic/RootAccessible.cpp | 2 +- dom/base/ContentFrameMessageManager.h | 20 -------- dom/base/nsGlobalWindowInner.cpp | 35 +++++++------- dom/base/nsGlobalWindowInner.h | 9 ++++ dom/base/nsGlobalWindowOuter.cpp | 8 ++-- dom/base/nsGlobalWindowOuter.h | 5 ++ dom/base/nsINode.cpp | 35 ++++++-------- dom/base/nsINode.h | 10 +++- dom/base/nsWindowRoot.cpp | 21 +++++---- dom/base/nsWindowRoot.h | 8 ++++ dom/events/DOMEventTargetHelper.cpp | 48 +++++++++++--------- dom/events/DOMEventTargetHelper.h | 9 ++++ dom/events/EventTarget.h | 34 +++++++++++++- dom/interfaces/events/nsIDOMEventTarget.idl | 48 -------------------- dom/ipc/TelemetryScrollProbe.cpp | 2 +- dom/media/MediaDevices.cpp | 33 +++++++------- dom/media/MediaDevices.h | 12 ++--- dom/xhr/XMLHttpRequestWorker.cpp | 2 +- editor/libeditor/HTMLAbsPositionEditor.cpp | 11 ++--- editor/libeditor/HTMLEditorObjectResizer.cpp | 9 ++-- editor/libeditor/HTMLInlineTableEditor.cpp | 7 ++- layout/generic/ScrollbarActivity.cpp | 8 +--- 22 files changed, 186 insertions(+), 190 deletions(-) diff --git a/accessible/generic/RootAccessible.cpp b/accessible/generic/RootAccessible.cpp index 5b95b2cc350e..40bd3bee92cd 100644 --- a/accessible/generic/RootAccessible.cpp +++ b/accessible/generic/RootAccessible.cpp @@ -192,7 +192,7 @@ RootAccessible::AddEventListeners() * const* e_end = ArrayEnd(kEventTypes); e < e_end; ++e) { nsresult rv = nstarget->AddEventListener(NS_ConvertASCIItoUTF16(*e), - this, true, true, 2); + this, true, true); NS_ENSURE_SUCCESS(rv, rv); } } diff --git a/dom/base/ContentFrameMessageManager.h b/dom/base/ContentFrameMessageManager.h index 440c01702831..e36a1a060606 100644 --- a/dom/base/ContentFrameMessageManager.h +++ b/dom/base/ContentFrameMessageManager.h @@ -49,26 +49,6 @@ public: GetSystemBindingNames(aCx, thisObj, aNames, aEnumerableOnly, aRv); } - nsresult AddEventListener(const nsAString& aType, - nsIDOMEventListener* aListener, - bool aUseCapture) - { - // By default add listeners only for trusted events! - return DOMEventTargetHelper::AddEventListener(aType, aListener, - aUseCapture, false, 2); - } - using DOMEventTargetHelper::AddEventListener; - NS_IMETHOD AddEventListener(const nsAString& aType, - nsIDOMEventListener* aListener, - bool aUseCapture, bool aWantsUntrusted, - uint8_t optional_argc) override - { - return DOMEventTargetHelper::AddEventListener(aType, aListener, - aUseCapture, - aWantsUntrusted, - optional_argc); - } - virtual already_AddRefed GetContent(ErrorResult& aError) = 0; virtual already_AddRefed GetDocShell(ErrorResult& aError) = 0; virtual already_AddRefed GetTabEventTarget() = 0; diff --git a/dom/base/nsGlobalWindowInner.cpp b/dom/base/nsGlobalWindowInner.cpp index 7d20636781b0..b1a1629c62d6 100644 --- a/dom/base/nsGlobalWindowInner.cpp +++ b/dom/base/nsGlobalWindowInner.cpp @@ -4497,25 +4497,27 @@ nsGlobalWindowInner::DispatchEvent(Event& aEvent, return retval; } -NS_IMETHODIMP +bool +nsGlobalWindowInner::ComputeWantsUntrusted(const Nullable& aWantsUntrusted) +{ + if (!aWantsUntrusted.IsNull()) { + return aWantsUntrusted.Value(); + } + + return !nsContentUtils::IsChromeDoc(mDoc); +} + +nsresult nsGlobalWindowInner::AddEventListener(const nsAString& aType, nsIDOMEventListener *aListener, - bool aUseCapture, bool aWantsUntrusted, - uint8_t aOptionalArgc) + bool aUseCapture, + const Nullable& aWantsUntrusted) { - NS_ASSERTION(!aWantsUntrusted || aOptionalArgc > 1, - "Won't check if this is chrome, you want to set " - "aWantsUntrusted to false or make the aWantsUntrusted " - "explicit by making optional_argc non-zero."); - - if (!aWantsUntrusted && - (aOptionalArgc < 2 && !nsContentUtils::IsChromeDoc(mDoc))) { - aWantsUntrusted = true; - } + bool wantsUntrusted = ComputeWantsUntrusted(aWantsUntrusted); EventListenerManager* manager = GetOrCreateListenerManager(); NS_ENSURE_STATE(manager); - manager->AddEventListener(aType, aListener, aUseCapture, aWantsUntrusted); + manager->AddEventListener(aType, aListener, aUseCapture, wantsUntrusted); return NS_OK; } @@ -4526,12 +4528,7 @@ nsGlobalWindowInner::AddEventListener(const nsAString& aType, const Nullable& aWantsUntrusted, ErrorResult& aRv) { - bool wantsUntrusted; - if (aWantsUntrusted.IsNull()) { - wantsUntrusted = !nsContentUtils::IsChromeDoc(mDoc); - } else { - wantsUntrusted = aWantsUntrusted.Value(); - } + bool wantsUntrusted = ComputeWantsUntrusted(aWantsUntrusted); EventListenerManager* manager = GetOrCreateListenerManager(); if (!manager) { diff --git a/dom/base/nsGlobalWindowInner.h b/dom/base/nsGlobalWindowInner.h index cf33b242af46..0cf840888f75 100644 --- a/dom/base/nsGlobalWindowInner.h +++ b/dom/base/nsGlobalWindowInner.h @@ -324,11 +324,20 @@ public: virtual mozilla::EventListenerManager* GetOrCreateListenerManager() override; + using mozilla::dom::EventTarget::AddEventListener; virtual void AddEventListener(const nsAString& aType, mozilla::dom::EventListener* aListener, const mozilla::dom::AddEventListenerOptionsOrBoolean& aOptions, const mozilla::dom::Nullable& aWantsUntrusted, mozilla::ErrorResult& aRv) override; + virtual nsresult AddEventListener(const nsAString& aType, + nsIDOMEventListener* aListener, + bool aUseCapture, + const Nullable& aWantsUntrusted) override; + /** + * A helper to determine the wantsUntrusted value from the given Nullable. + */ + bool ComputeWantsUntrusted(const Nullable& aWantsUntrusted); virtual nsPIDOMWindowOuter* GetOwnerGlobalForBindings() override; virtual nsIGlobalObject* GetOwnerGlobal() const override; diff --git a/dom/base/nsGlobalWindowOuter.cpp b/dom/base/nsGlobalWindowOuter.cpp index f392fe3e1a93..26ad085dda99 100644 --- a/dom/base/nsGlobalWindowOuter.cpp +++ b/dom/base/nsGlobalWindowOuter.cpp @@ -6466,14 +6466,14 @@ nsGlobalWindowOuter::DispatchEvent(Event& aEvent, FORWARD_TO_INNER(DispatchEvent, (aEvent, aCallerType, aRv), false); } -NS_IMETHODIMP +nsresult nsGlobalWindowOuter::AddEventListener(const nsAString& aType, nsIDOMEventListener *aListener, - bool aUseCapture, bool aWantsUntrusted, - uint8_t aOptionalArgc) + bool aUseCapture, + const Nullable& aWantsUntrusted) { FORWARD_TO_INNER_CREATE(AddEventListener, - (aType, aListener, aUseCapture, aWantsUntrusted, aOptionalArgc), + (aType, aListener, aUseCapture, aWantsUntrusted), NS_ERROR_UNEXPECTED); } diff --git a/dom/base/nsGlobalWindowOuter.h b/dom/base/nsGlobalWindowOuter.h index 3ace0f29ae7e..82041df404f6 100644 --- a/dom/base/nsGlobalWindowOuter.h +++ b/dom/base/nsGlobalWindowOuter.h @@ -281,11 +281,16 @@ public: virtual mozilla::EventListenerManager* GetOrCreateListenerManager() override; + using mozilla::dom::EventTarget::AddEventListener; virtual void AddEventListener(const nsAString& aType, mozilla::dom::EventListener* aListener, const mozilla::dom::AddEventListenerOptionsOrBoolean& aOptions, const mozilla::dom::Nullable& aWantsUntrusted, mozilla::ErrorResult& aRv) override; + virtual nsresult AddEventListener(const nsAString& aType, + nsIDOMEventListener* aListener, + bool aUseCapture, + const Nullable& aWantsUntrusted) override; virtual nsPIDOMWindowOuter* GetOwnerGlobalForBindings() override; virtual nsIGlobalObject* GetOwnerGlobal() const override; diff --git a/dom/base/nsINode.cpp b/dom/base/nsINode.cpp index 6cc8340827ff..77c65f29ae01 100644 --- a/dom/base/nsINode.cpp +++ b/dom/base/nsINode.cpp @@ -1016,28 +1016,28 @@ nsINode::LookupNamespaceURI(const nsAString& aNamespacePrefix, } } -NS_IMETHODIMP +bool +nsINode::ComputeWantsUntrusted(const Nullable& aWantsUntrusted) +{ + if (!aWantsUntrusted.IsNull()) { + return aWantsUntrusted.Value(); + } + + return !nsContentUtils::IsChromeDoc(OwnerDoc()); +} + +nsresult nsINode::AddEventListener(const nsAString& aType, nsIDOMEventListener *aListener, bool aUseCapture, - bool aWantsUntrusted, - uint8_t aOptionalArgc) + const Nullable& aWantsUntrusted) { - NS_ASSERTION(!aWantsUntrusted || aOptionalArgc > 1, - "Won't check if this is chrome, you want to set " - "aWantsUntrusted to false or make the aWantsUntrusted " - "explicit by making aOptionalArgc non-zero."); - - if (!aWantsUntrusted && - (aOptionalArgc < 2 && - !nsContentUtils::IsChromeDoc(OwnerDoc()))) { - aWantsUntrusted = true; - } + bool wantsUntrusted = ComputeWantsUntrusted(aWantsUntrusted); EventListenerManager* listener_manager = GetOrCreateListenerManager(); NS_ENSURE_STATE(listener_manager); listener_manager->AddEventListener(aType, aListener, aUseCapture, - aWantsUntrusted); + wantsUntrusted); return NS_OK; } @@ -1048,12 +1048,7 @@ nsINode::AddEventListener(const nsAString& aType, const Nullable& aWantsUntrusted, ErrorResult& aRv) { - bool wantsUntrusted; - if (aWantsUntrusted.IsNull()) { - wantsUntrusted = !nsContentUtils::IsChromeDoc(OwnerDoc()); - } else { - wantsUntrusted = aWantsUntrusted.Value(); - } + bool wantsUntrusted = ComputeWantsUntrusted(aWantsUntrusted); EventListenerManager* listener_manager = GetOrCreateListenerManager(); if (!listener_manager) { diff --git a/dom/base/nsINode.h b/dom/base/nsINode.h index 20cc798148e7..b26f75e8f793 100644 --- a/dom/base/nsINode.h +++ b/dom/base/nsINode.h @@ -1029,12 +1029,20 @@ public: virtual mozilla::EventListenerManager* GetOrCreateListenerManager() override; - using nsIDOMEventTarget::AddEventListener; + using mozilla::dom::EventTarget::AddEventListener; virtual void AddEventListener(const nsAString& aType, mozilla::dom::EventListener* aListener, const mozilla::dom::AddEventListenerOptionsOrBoolean& aOptions, const mozilla::dom::Nullable& aWantsUntrusted, mozilla::ErrorResult& aRv) override; + virtual nsresult AddEventListener(const nsAString& aType, + nsIDOMEventListener* aListener, + bool aUseCapture, + const Nullable& aWantsUntrusted) override; + /** + * A helper to determine the wantsUntrusted value from the given Nullable. + */ + bool ComputeWantsUntrusted(const Nullable& aWantsUntrusted); using nsIDOMEventTarget::AddSystemEventListener; virtual bool IsApzAware() const override; diff --git a/dom/base/nsWindowRoot.cpp b/dom/base/nsWindowRoot.cpp index c30018a2375d..9234daed0aee 100644 --- a/dom/base/nsWindowRoot.cpp +++ b/dom/base/nsWindowRoot.cpp @@ -84,20 +84,23 @@ nsWindowRoot::DispatchEvent(Event& aEvent, CallerType aCallerType, return retval; } -NS_IMETHODIMP +bool +nsWindowRoot::ComputeWantsUntrusted(const Nullable& aWantsUntrusted) +{ + return !aWantsUntrusted.IsNull() && aWantsUntrusted.Value(); +} + +nsresult nsWindowRoot::AddEventListener(const nsAString& aType, nsIDOMEventListener *aListener, - bool aUseCapture, bool aWantsUntrusted, - uint8_t aOptionalArgc) + bool aUseCapture, + const Nullable& aWantsUntrusted) { - NS_ASSERTION(!aWantsUntrusted || aOptionalArgc > 1, - "Won't check if this is chrome, you want to set " - "aWantsUntrusted to false or make the aWantsUntrusted " - "explicit by making optional_argc non-zero."); + bool wantsUntrusted = ComputeWantsUntrusted(aWantsUntrusted); EventListenerManager* elm = GetOrCreateListenerManager(); NS_ENSURE_STATE(elm); - elm->AddEventListener(aType, aListener, aUseCapture, aWantsUntrusted); + elm->AddEventListener(aType, aListener, aUseCapture, wantsUntrusted); return NS_OK; } @@ -108,7 +111,7 @@ nsWindowRoot::AddEventListener(const nsAString& aType, const Nullable& aWantsUntrusted, ErrorResult& aRv) { - bool wantsUntrusted = !aWantsUntrusted.IsNull() && aWantsUntrusted.Value(); + bool wantsUntrusted = ComputeWantsUntrusted(aWantsUntrusted); EventListenerManager* elm = GetOrCreateListenerManager(); if (!elm) { aRv.Throw(NS_ERROR_UNEXPECTED); diff --git a/dom/base/nsWindowRoot.h b/dom/base/nsWindowRoot.h index 8f21dd8399db..9f707ab355b0 100644 --- a/dom/base/nsWindowRoot.h +++ b/dom/base/nsWindowRoot.h @@ -37,6 +37,14 @@ public: const mozilla::dom::AddEventListenerOptionsOrBoolean& aOptions, const mozilla::dom::Nullable& aWantsUntrusted, mozilla::ErrorResult& aRv) override; + virtual nsresult AddEventListener(const nsAString& aType, + nsIDOMEventListener* aListener, + bool aUseCapture, + const Nullable& aWantsUntrusted) override; + /** + * A helper to determine the wantsUntrusted value from the given Nullable. + */ + bool ComputeWantsUntrusted(const Nullable& aWantsUntrusted); bool DispatchEvent(mozilla::dom::Event& aEvent, mozilla::dom::CallerType aCallerType, diff --git a/dom/events/DOMEventTargetHelper.cpp b/dom/events/DOMEventTargetHelper.cpp index 51c7c0684c08..f6d0635dae04 100644 --- a/dom/events/DOMEventTargetHelper.cpp +++ b/dom/events/DOMEventTargetHelper.cpp @@ -173,26 +173,38 @@ DOMEventTargetHelper::GetDocumentIfCurrent() const return win->GetDoc(); } -NS_IMETHODIMP +bool +DOMEventTargetHelper::ComputeWantsUntrusted(const Nullable& aWantsUntrusted, + ErrorResult& aRv) +{ + if (!aWantsUntrusted.IsNull()) { + return aWantsUntrusted.Value(); + } + + bool wantsUntrusted; + nsresult rv = WantsUntrusted(&wantsUntrusted); + if (NS_FAILED(rv)) { + aRv.Throw(rv); + return false; + } + return wantsUntrusted; +} + +nsresult DOMEventTargetHelper::AddEventListener(const nsAString& aType, nsIDOMEventListener* aListener, bool aUseCapture, - bool aWantsUntrusted, - uint8_t aOptionalArgc) + const Nullable& aWantsUntrusted) { - NS_ASSERTION(!aWantsUntrusted || aOptionalArgc > 1, - "Won't check if this is chrome, you want to set " - "aWantsUntrusted to false or make the aWantsUntrusted " - "explicit by making aOptionalArgc non-zero."); - - if (aOptionalArgc < 2) { - nsresult rv = WantsUntrusted(&aWantsUntrusted); - NS_ENSURE_SUCCESS(rv, rv); + ErrorResult rv; + bool wantsUntrusted = ComputeWantsUntrusted(aWantsUntrusted, rv); + if (rv.Failed()) { + return rv.StealNSResult(); } EventListenerManager* elm = GetOrCreateListenerManager(); NS_ENSURE_STATE(elm); - elm->AddEventListener(aType, aListener, aUseCapture, aWantsUntrusted); + elm->AddEventListener(aType, aListener, aUseCapture, wantsUntrusted); return NS_OK; } @@ -203,15 +215,9 @@ DOMEventTargetHelper::AddEventListener(const nsAString& aType, const Nullable& aWantsUntrusted, ErrorResult& aRv) { - bool wantsUntrusted; - if (aWantsUntrusted.IsNull()) { - nsresult rv = WantsUntrusted(&wantsUntrusted); - if (NS_FAILED(rv)) { - aRv.Throw(rv); - return; - } - } else { - wantsUntrusted = aWantsUntrusted.Value(); + bool wantsUntrusted = ComputeWantsUntrusted(aWantsUntrusted, aRv); + if (aRv.Failed()) { + return; } EventListenerManager* elm = GetOrCreateListenerManager(); diff --git a/dom/events/DOMEventTargetHelper.h b/dom/events/DOMEventTargetHelper.h index 68e716ae364d..1881f6cd8d24 100644 --- a/dom/events/DOMEventTargetHelper.h +++ b/dom/events/DOMEventTargetHelper.h @@ -79,6 +79,15 @@ public: const dom::AddEventListenerOptionsOrBoolean& aOptions, const dom::Nullable& aWantsUntrusted, ErrorResult& aRv) override; + virtual nsresult AddEventListener(const nsAString& aType, + nsIDOMEventListener* aListener, + bool aUseCapture, + const Nullable& aWantsUntrusted) override; + /** + * A helper to determine the wantsUntrusted value from the given Nullable. + */ + bool ComputeWantsUntrusted(const Nullable& aWantsUntrusted, + ErrorResult& aRv); using EventTarget::DispatchEvent; bool DispatchEvent(dom::Event& aEvent, dom::CallerType aCallerType, diff --git a/dom/events/EventTarget.h b/dom/events/EventTarget.h index 8fbc9df74ad2..8fbf790a3c46 100644 --- a/dom/events/EventTarget.h +++ b/dom/events/EventTarget.h @@ -54,7 +54,6 @@ public: // WebIDL API static already_AddRefed Constructor(const GlobalObject& aGlobal, ErrorResult& aRv); - using nsIDOMEventTarget::AddEventListener; virtual void AddEventListener(const nsAString& aType, EventListener* aCallback, const AddEventListenerOptionsOrBoolean& aOptions, @@ -64,6 +63,39 @@ public: EventListener* aCallback, const EventListenerOptionsOrBoolean& aOptions, ErrorResult& aRv); + +protected: + /** + * This method allows addition of event listeners represented by + * nsIDOMEventListener, with almost the same semantics as the + * standard AddEventListener. The one difference is that it just + * has a "use capture" boolean, not an EventListenerOptions. + */ + virtual nsresult AddEventListener(const nsAString& aType, + nsIDOMEventListener* aListener, + bool aUseCapture, + const Nullable& aWantsUntrusted) = 0; + +public: + /** + * Helper methods to make the nsIDOMEventListener version of + * AddEventListener simpler to call for consumers. + */ + nsresult AddEventListener(const nsAString& aType, + nsIDOMEventListener* aListener, + bool aUseCapture) + { + return AddEventListener(aType, aListener, aUseCapture, Nullable()); + } + nsresult AddEventListener(const nsAString& aType, + nsIDOMEventListener* aListener, + bool aUseCapture, + bool aWantsUntrusted) + { + return AddEventListener(aType, aListener, aUseCapture, + Nullable(aWantsUntrusted)); + } + /** * This method allows the removal of event listeners represented by * nsIDOMEventListener from the event target, with the same semantics as the diff --git a/dom/interfaces/events/nsIDOMEventTarget.idl b/dom/interfaces/events/nsIDOMEventTarget.idl index e4432ad5b155..61734b2de33a 100644 --- a/dom/interfaces/events/nsIDOMEventTarget.idl +++ b/dom/interfaces/events/nsIDOMEventTarget.idl @@ -45,39 +45,6 @@ interface nsIDOMEvent; [uuid(9a78ac3c-9507-4d00-b2d6-10b508d2ec31)] interface nsIDOMEventTarget : nsISupports { - /** - * This method allows the registration of event listeners on the event target. - * If an EventListener is added to an EventTarget while it is processing an - * event, it will not be triggered by the current actions but may be - * triggered during a later stage of event flow, such as the bubbling phase. - * - * If multiple identical EventListeners are registered on the same - * EventTarget with the same parameters the duplicate instances are - * discarded. They do not cause the EventListener to be called twice - * and since they are discarded they do not need to be removed with the - * removeEventListener method. - * - * @param type The event type for which the user is registering - * @param listener The listener parameter takes an interface - * implemented by the user which contains the methods - * to be called when the event occurs. - * @param useCapture If true, useCapture indicates that the user - * wishes to initiate capture. After initiating - * capture, all events of the specified type will be - * dispatched to the registered EventListener before - * being dispatched to any EventTargets beneath them - * in the tree. Events which are bubbling upward - * through the tree will not trigger an - * EventListener designated to use capture. - * @param wantsUntrusted If false, the listener will not receive any - * untrusted events (see above), if true, the - * listener will receive events whether or not - * they're trusted - */ - [optional_argc] void addEventListener(in DOMString type, - in nsIDOMEventListener listener, - [optional] in boolean useCapture, - [optional] in boolean wantsUntrusted); /** * addSystemEventListener() adds an event listener of aType to the system @@ -102,21 +69,6 @@ interface nsIDOMEventTarget : nsISupports [optional] in boolean aWantsUntrusted); %{C++ - // non-virtual so it won't affect the vtable - nsresult AddEventListener(const nsAString& aType, - nsIDOMEventListener* aListener, - bool aUseCapture) - { - return AddEventListener(aType, aListener, aUseCapture, false, 1); - } - // non-virtual so it won't affect the vtable - nsresult AddEventListener(const nsAString& aType, - nsIDOMEventListener* aListener, - bool aUseCapture, - bool aWantsUntrusted) - { - return AddEventListener(aType, aListener, aUseCapture, aWantsUntrusted, 2); - } // non-virtual so it won't affect the vtable nsresult AddSystemEventListener(const nsAString& aType, nsIDOMEventListener* aListener, diff --git a/dom/ipc/TelemetryScrollProbe.cpp b/dom/ipc/TelemetryScrollProbe.cpp index a7c9814265c5..418fb2d1ed70 100644 --- a/dom/ipc/TelemetryScrollProbe.cpp +++ b/dom/ipc/TelemetryScrollProbe.cpp @@ -21,7 +21,7 @@ TelemetryScrollProbe::Create(TabChildGlobal* aWebFrame) nsWeakPtr webNav = do_GetWeakReference(aWebFrame->mTabChild->WebNavigation()); RefPtr probe = new TelemetryScrollProbe(webNav); - aWebFrame->AddEventListener(NS_LITERAL_STRING("pagehide"), probe, true, false, 0); + aWebFrame->AddEventListener(NS_LITERAL_STRING("pagehide"), probe, true); } already_AddRefed diff --git a/dom/media/MediaDevices.cpp b/dom/media/MediaDevices.cpp index 19f4a5b4d708..f871fd7440e4 100644 --- a/dom/media/MediaDevices.cpp +++ b/dom/media/MediaDevices.cpp @@ -180,7 +180,7 @@ NS_IMPL_ISUPPORTS(MediaDevices::GumRejecter, nsIDOMGetUserMediaErrorCallback) already_AddRefed MediaDevices::GetUserMedia(const MediaStreamConstraints& aConstraints, - CallerType aCallerType, + CallerType aCallerType, ErrorResult &aRv) { RefPtr p = Promise::Create(GetParentObject(), aRv); @@ -191,7 +191,7 @@ MediaDevices::GetUserMedia(const MediaStreamConstraints& aConstraints, aRv = MediaManager::Get()->GetUserMedia(GetOwner(), aConstraints, resolver, rejecter, - aCallerType); + aCallerType); return p.forget(); } @@ -273,31 +273,30 @@ MediaDevices::SetOndevicechange(mozilla::dom::EventHandlerNonNull* aCallback) nsresult MediaDevices::AddEventListener(const nsAString& aType, - nsIDOMEventListener* aListener, - bool aUseCapture, bool aWantsUntrusted, - uint8_t optional_argc) + nsIDOMEventListener* aListener, + bool aUseCapture, + const Nullable& aWantsUntrusted) { MediaManager::Get()->AddDeviceChangeCallback(this); - return mozilla::DOMEventTargetHelper::AddEventListener(aType, aListener, - aUseCapture, - aWantsUntrusted, - optional_argc); + return DOMEventTargetHelper::AddEventListener(aType, aListener, + aUseCapture, + aWantsUntrusted); } void MediaDevices::AddEventListener(const nsAString& aType, - dom::EventListener* aListener, - const dom::AddEventListenerOptionsOrBoolean& aOptions, - const dom::Nullable& aWantsUntrusted, - ErrorResult& aRv) + EventListener* aListener, + const AddEventListenerOptionsOrBoolean& aOptions, + const Nullable& aWantsUntrusted, + ErrorResult& aRv) { MediaManager::Get()->AddDeviceChangeCallback(this); - return mozilla::DOMEventTargetHelper::AddEventListener(aType, aListener, - aOptions, - aWantsUntrusted, - aRv); + return DOMEventTargetHelper::AddEventListener(aType, aListener, + aOptions, + aWantsUntrusted, + aRv); } JSObject* diff --git a/dom/media/MediaDevices.h b/dom/media/MediaDevices.h index d6be76acfeb9..3d343aaefb53 100644 --- a/dom/media/MediaDevices.h +++ b/dom/media/MediaDevices.h @@ -51,15 +51,15 @@ public: void SetOndevicechange(mozilla::dom::EventHandlerNonNull* aCallback); - NS_IMETHOD AddEventListener(const nsAString& aType, - nsIDOMEventListener* aListener, - bool aUseCapture, bool aWantsUntrusted, - uint8_t optional_argc) override; + nsresult AddEventListener(const nsAString& aType, + nsIDOMEventListener* aListener, + bool aUseCapture, + const Nullable& aWantsUntrusted) override; virtual void AddEventListener(const nsAString& aType, dom::EventListener* aListener, - const dom::AddEventListenerOptionsOrBoolean& aOptions, - const dom::Nullable& aWantsUntrusted, + const AddEventListenerOptionsOrBoolean& aOptions, + const Nullable& aWantsUntrusted, ErrorResult& aRv) override; private: diff --git a/dom/xhr/XMLHttpRequestWorker.cpp b/dom/xhr/XMLHttpRequestWorker.cpp index da354c69de96..1ed36daaeab4 100644 --- a/dom/xhr/XMLHttpRequestWorker.cpp +++ b/dom/xhr/XMLHttpRequestWorker.cpp @@ -461,7 +461,7 @@ public: { AssertIsOnMainThread(); - if (NS_FAILED(mXHR->AddEventListener(mEventType, this, false, false, 2))) { + if (NS_FAILED(mXHR->AddEventListener(mEventType, this, false, false))) { NS_WARNING("Failed to add event listener!"); return false; } diff --git a/editor/libeditor/HTMLAbsPositionEditor.cpp b/editor/libeditor/HTMLAbsPositionEditor.cpp index 886e08961089..0793065a6e57 100644 --- a/editor/libeditor/HTMLAbsPositionEditor.cpp +++ b/editor/libeditor/HTMLAbsPositionEditor.cpp @@ -219,9 +219,8 @@ HTMLEditor::CreateGrabber(nsIContent& aParentContent) } // add the mouse listener so we can detect a click on a resizer - nsCOMPtr evtTarget = do_QueryInterface(ret); - evtTarget->AddEventListener(NS_LITERAL_STRING("mousedown"), - mEventListener, false); + ret->AddEventListener(NS_LITERAL_STRING("mousedown"), + mEventListener, false); return ret; } @@ -359,12 +358,12 @@ HTMLEditor::GrabberClicked() mMouseMotionListenerP = new ResizerMouseMotionListener(*this); if (!mMouseMotionListenerP) {return NS_ERROR_NULL_POINTER;} - nsIDOMEventTarget* piTarget = GetDOMEventTarget(); + EventTarget* piTarget = GetDOMEventTarget(); NS_ENSURE_TRUE(piTarget, NS_ERROR_FAILURE); rv = piTarget->AddEventListener(NS_LITERAL_STRING("mousemove"), - mMouseMotionListenerP, - false, false); + mMouseMotionListenerP, + false, false); NS_ASSERTION(NS_SUCCEEDED(rv), "failed to register mouse motion listener"); } diff --git a/editor/libeditor/HTMLEditorObjectResizer.cpp b/editor/libeditor/HTMLEditorObjectResizer.cpp index c7f8a5d333ee..2c1e0f6d6856 100644 --- a/editor/libeditor/HTMLEditorObjectResizer.cpp +++ b/editor/libeditor/HTMLEditorObjectResizer.cpp @@ -113,9 +113,8 @@ HTMLEditor::CreateResizer(int16_t aLocation, } // add the mouse listener so we can detect a click on a resizer - nsCOMPtr evtTarget = do_QueryInterface(ret); - evtTarget->AddEventListener(NS_LITERAL_STRING("mousedown"), mEventListener, - true); + ret->AddEventListener(NS_LITERAL_STRING("mousedown"), mEventListener, + true); nsAutoString locationStr; switch (aLocation) { @@ -341,7 +340,7 @@ HTMLEditor::ShowResizersInner(Element& aResizedElement) nsCOMPtr doc = GetDocument(); NS_ENSURE_TRUE(doc, NS_ERROR_NULL_POINTER); - nsCOMPtr target = do_QueryInterface(doc->GetWindow()); + nsCOMPtr target = do_QueryInterface(doc->GetWindow()); if (!target) { return NS_ERROR_NULL_POINTER; } @@ -508,7 +507,7 @@ HTMLEditor::StartResizing(nsIDOMElement* aHandle) return NS_ERROR_OUT_OF_MEMORY; } - nsIDOMEventTarget* target = GetDOMEventTarget(); + EventTarget* target = GetDOMEventTarget(); NS_ENSURE_TRUE(target, NS_ERROR_FAILURE); result = target->AddEventListener(NS_LITERAL_STRING("mousemove"), diff --git a/editor/libeditor/HTMLInlineTableEditor.cpp b/editor/libeditor/HTMLInlineTableEditor.cpp index 9fa0058f04a2..541d00f5cac9 100644 --- a/editor/libeditor/HTMLInlineTableEditor.cpp +++ b/editor/libeditor/HTMLInlineTableEditor.cpp @@ -178,10 +178,9 @@ HTMLEditor::DoInlineTableEditingAction(const Element& aElement) void HTMLEditor::AddMouseClickListener(Element* aElement) { - nsCOMPtr evtTarget(do_QueryInterface(aElement)); - if (evtTarget) { - evtTarget->AddEventListener(NS_LITERAL_STRING("click"), - mEventListener, true); + if (aElement) { + aElement->AddEventListener(NS_LITERAL_STRING("click"), + mEventListener, true); } } diff --git a/layout/generic/ScrollbarActivity.cpp b/layout/generic/ScrollbarActivity.cpp index b134bdee8cda..134b15c0c866 100644 --- a/layout/generic/ScrollbarActivity.cpp +++ b/layout/generic/ScrollbarActivity.cpp @@ -221,12 +221,8 @@ ScrollbarActivity::StartListeningForScrollAreaEvents() return; nsIFrame* scrollArea = do_QueryFrame(mScrollableFrame); - nsCOMPtr scrollAreaTarget - = do_QueryInterface(scrollArea->GetContent()); - if (scrollAreaTarget) { - scrollAreaTarget->AddEventListener(NS_LITERAL_STRING("mousemove"), this, - true); - } + scrollArea->GetContent()->AddEventListener(NS_LITERAL_STRING("mousemove"), + this, true); mListeningForScrollAreaEvents = true; }