diff --git a/docshell/base/BrowsingContext.cpp b/docshell/base/BrowsingContext.cpp index ebf183695a54..488577ba6401 100644 --- a/docshell/base/BrowsingContext.cpp +++ b/docshell/base/BrowsingContext.cpp @@ -3022,7 +3022,8 @@ void BrowsingContext::DidSet(FieldIndex, // the context is the top of a sub-tree of in-process // contexts. nsContentUtils::DispatchEventOnlyToChrome( - doc, win, isActivateEvent ? u"activate"_ns : u"deactivate"_ns, + doc, nsGlobalWindowInner::Cast(win), + isActivateEvent ? u"activate"_ns : u"deactivate"_ns, CanBubble::eYes, Cancelable::eYes, nullptr); } } diff --git a/dom/base/AutoPrintEventDispatcher.h b/dom/base/AutoPrintEventDispatcher.h index 994afc1f768b..38382fdfea69 100644 --- a/dom/base/AutoPrintEventDispatcher.h +++ b/dom/base/AutoPrintEventDispatcher.h @@ -10,6 +10,7 @@ #include "mozilla/dom/Document.h" #include "mozilla/dom/DocumentInlines.h" #include "nsContentUtils.h" +#include "nsGlobalWindowOuter.h" #include "nsIPrintSettings.h" namespace mozilla::dom { @@ -30,8 +31,9 @@ class AutoPrintEventDispatcher { MOZ_CAN_RUN_SCRIPT void DispatchEvent(bool aBefore) { for (auto& doc : mDocuments) { nsContentUtils::DispatchTrustedEvent( - doc, doc->GetWindow(), aBefore ? u"beforeprint"_ns : u"afterprint"_ns, - CanBubble::eNo, Cancelable::eNo, nullptr); + doc, nsGlobalWindowOuter::Cast(doc->GetWindow()), + aBefore ? u"beforeprint"_ns : u"afterprint"_ns, CanBubble::eNo, + Cancelable::eNo, nullptr); if (RefPtr presContext = doc->GetPresContext()) { presContext->EmulateMedium(aBefore ? nsGkAtoms::print : nullptr); // Ensure media query listeners fire. diff --git a/dom/base/Document.cpp b/dom/base/Document.cpp index 08cdd3ad9df2..ccce493369d2 100644 --- a/dom/base/Document.cpp +++ b/dom/base/Document.cpp @@ -5927,8 +5927,8 @@ void Document::MaybeEditingStateChanged() { void Document::NotifyFetchOrXHRSuccess() { if (mShouldNotifyFetchSuccess) { nsContentUtils::DispatchEventOnlyToChrome( - this, ToSupports(this), u"DOMDocFetchSuccess"_ns, CanBubble::eNo, - Cancelable::eNo, /* DefaultAction */ nullptr); + this, this, u"DOMDocFetchSuccess"_ns, CanBubble::eNo, Cancelable::eNo, + /* DefaultAction */ nullptr); } } @@ -8067,9 +8067,8 @@ void Document::DispatchContentLoadedEvents() { // Fire a DOM event notifying listeners that this document has been // loaded (excluding images and other loads initiated by this // document). - nsContentUtils::DispatchTrustedEvent(this, ToSupports(this), - u"DOMContentLoaded"_ns, CanBubble::eYes, - Cancelable::eNo); + nsContentUtils::DispatchTrustedEvent(this, this, u"DOMContentLoaded"_ns, + CanBubble::eYes, Cancelable::eNo); if (auto* const window = GetInnerWindow()) { const RefPtr serviceWorker = @@ -9320,9 +9319,8 @@ void Document::DoNotifyPossibleTitleChange() { } // Fire a DOM event for the title change. - nsContentUtils::DispatchChromeEvent(this, ToSupports(this), - u"DOMTitleChanged"_ns, CanBubble::eYes, - Cancelable::eYes); + nsContentUtils::DispatchChromeEvent(this, this, u"DOMTitleChanged"_ns, + CanBubble::eYes, Cancelable::eYes); nsCOMPtr obs = mozilla::services::GetObserverService(); if (obs) { @@ -14463,7 +14461,7 @@ already_AddRefed Document::ExitFullscreen(ErrorResult& aRv) { static void AskWindowToExitFullscreen(Document* aDoc) { if (XRE_GetProcessType() == GeckoProcessType_Content) { nsContentUtils::DispatchEventOnlyToChrome( - aDoc, ToSupports(aDoc), u"MozDOMFullscreen:Exit"_ns, CanBubble::eYes, + aDoc, aDoc, u"MozDOMFullscreen:Exit"_ns, CanBubble::eYes, Cancelable::eNo, /* DefaultAction */ nullptr); } else { if (nsPIDOMWindowOuter* win = aDoc->GetWindow()) { @@ -14576,8 +14574,8 @@ class ExitFullscreenScriptRunnable : public Runnable { // document since we want this event to follow the same path that // MozDOMFullscreen:Entered was dispatched. nsContentUtils::DispatchEventOnlyToChrome( - mLeaf, ToSupports(mLeaf), u"MozDOMFullscreen:Exited"_ns, - CanBubble::eYes, Cancelable::eNo, /* DefaultAction */ nullptr); + mLeaf, mLeaf, u"MozDOMFullscreen:Exited"_ns, CanBubble::eYes, + Cancelable::eNo, /* DefaultAction */ nullptr); // Ensure the window exits fullscreen, as long as we don't have // pending fullscreen requests. if (nsPIDOMWindowOuter* win = mRoot->GetWindow()) { @@ -15506,8 +15504,8 @@ void Document::RequestFullscreenInContentProcess( return; } nsContentUtils::DispatchEventOnlyToChrome( - self, ToSupports(self), u"MozDOMFullscreen:Request"_ns, - CanBubble::eYes, Cancelable::eNo, /* DefaultAction */ nullptr); + self, self, u"MozDOMFullscreen:Request"_ns, CanBubble::eYes, + Cancelable::eNo, /* DefaultAction */ nullptr); })); } @@ -15676,7 +15674,7 @@ bool Document::ApplyFullscreen(UniquePtr aRequest) { // to pop up warning UI. if (!previousFullscreenDoc) { nsContentUtils::DispatchEventOnlyToChrome( - this, ToSupports(elem), u"MozDOMFullscreen:Entered"_ns, CanBubble::eYes, + this, elem, u"MozDOMFullscreen:Entered"_ns, CanBubble::eYes, Cancelable::eNo, /* DefaultAction */ nullptr); } @@ -15720,8 +15718,7 @@ void Document::UpdateVisibilityState(DispatchVisibilityChange aDispatchEvent) { mVisibilityState = ComputeVisibilityState(); if (oldState != mVisibilityState) { if (aDispatchEvent == DispatchVisibilityChange::Yes) { - nsContentUtils::DispatchTrustedEvent(this, ToSupports(this), - u"visibilitychange"_ns, + nsContentUtils::DispatchTrustedEvent(this, this, u"visibilitychange"_ns, CanBubble::eYes, Cancelable::eNo); } NotifyActivityChanged(); diff --git a/dom/base/PointerLockManager.cpp b/dom/base/PointerLockManager.cpp index 78f1d600afe0..af144ab600a0 100644 --- a/dom/base/PointerLockManager.cpp +++ b/dom/base/PointerLockManager.cpp @@ -233,8 +233,8 @@ bool PointerLockManager::StartSetPointerLock(Element* aElement, ChangePointerLockedElement(aElement, aDocument, nullptr); nsContentUtils::DispatchEventOnlyToChrome( - aDocument, ToSupports(aElement), u"MozDOMPointerLock:Entered"_ns, - CanBubble::eYes, Cancelable::eNo, /* DefaultAction */ nullptr); + aDocument, aElement, u"MozDOMPointerLock:Entered"_ns, CanBubble::eYes, + Cancelable::eNo, /* DefaultAction */ nullptr); return true; } diff --git a/dom/base/nsContentSink.cpp b/dom/base/nsContentSink.cpp index 9de86ef56058..b58e56a8f6a5 100644 --- a/dom/base/nsContentSink.cpp +++ b/dom/base/nsContentSink.cpp @@ -950,8 +950,7 @@ void nsContentSink::NotifyDocElementCreated(Document* aDoc) { observerService->NotifyObservers(ToSupports(aDoc), "document-element-inserted", u""); - nsContentUtils::DispatchChromeEvent(aDoc, ToSupports(aDoc), - u"DOMDocElementInserted"_ns, + nsContentUtils::DispatchChromeEvent(aDoc, aDoc, u"DOMDocElementInserted"_ns, CanBubble::eYes, Cancelable::eNo); } diff --git a/dom/base/nsContentUtils.cpp b/dom/base/nsContentUtils.cpp index 52650a856f8e..36b56b1c0dce 100644 --- a/dom/base/nsContentUtils.cpp +++ b/dom/base/nsContentUtils.cpp @@ -4575,12 +4575,12 @@ EventMessage nsContentUtils::GetEventMessageAndAtomForListener( return msg; } -static nsresult GetEventAndTarget(Document* aDoc, nsISupports* aTarget, +static nsresult GetEventAndTarget(Document* aDoc, EventTarget* aTarget, const nsAString& aEventName, CanBubble aCanBubble, Cancelable aCancelable, Composed aComposed, Trusted aTrusted, Event** aEvent, EventTarget** aTargetOut) { - nsCOMPtr target(do_QueryInterface(aTarget)); + nsCOMPtr target(aTarget); NS_ENSURE_TRUE(aDoc && target, NS_ERROR_INVALID_ARG); ErrorResult err; @@ -4602,7 +4602,7 @@ static nsresult GetEventAndTarget(Document* aDoc, nsISupports* aTarget, // static nsresult nsContentUtils::DispatchTrustedEvent( - Document* aDoc, nsISupports* aTarget, const nsAString& aEventName, + Document* aDoc, EventTarget* aTarget, const nsAString& aEventName, CanBubble aCanBubble, Cancelable aCancelable, Composed aComposed, bool* aDefaultAction) { MOZ_ASSERT(!aEventName.EqualsLiteral("input") && @@ -4614,14 +4614,14 @@ nsresult nsContentUtils::DispatchTrustedEvent( // static nsresult nsContentUtils::DispatchUntrustedEvent( - Document* aDoc, nsISupports* aTarget, const nsAString& aEventName, + Document* aDoc, EventTarget* aTarget, const nsAString& aEventName, CanBubble aCanBubble, Cancelable aCancelable, bool* aDefaultAction) { return DispatchEvent(aDoc, aTarget, aEventName, aCanBubble, aCancelable, Composed::eDefault, Trusted::eNo, aDefaultAction); } // static -nsresult nsContentUtils::DispatchEvent(Document* aDoc, nsISupports* aTarget, +nsresult nsContentUtils::DispatchEvent(Document* aDoc, EventTarget* aTarget, const nsAString& aEventName, CanBubble aCanBubble, Cancelable aCancelable, @@ -4646,7 +4646,7 @@ nsresult nsContentUtils::DispatchEvent(Document* aDoc, nsISupports* aTarget, } // static -nsresult nsContentUtils::DispatchEvent(Document* aDoc, nsISupports* aTarget, +nsresult nsContentUtils::DispatchEvent(Document* aDoc, EventTarget* aTarget, WidgetEvent& aEvent, EventMessage aEventMessage, CanBubble aCanBubble, @@ -4656,7 +4656,7 @@ nsresult nsContentUtils::DispatchEvent(Document* aDoc, nsISupports* aTarget, MOZ_ASSERT_IF(aOnlyChromeDispatch == ChromeOnlyDispatch::eYes, aTrusted == Trusted::eYes); - nsCOMPtr target(do_QueryInterface(aTarget)); + nsCOMPtr target(aTarget); aEvent.mSpecifiedEventType = GetEventTypeFromMessage(aEventMessage); aEvent.SetDefaultComposed(); @@ -4846,7 +4846,7 @@ nsresult nsContentUtils::DispatchInputEvent( } nsresult nsContentUtils::DispatchChromeEvent( - Document* aDoc, nsISupports* aTarget, const nsAString& aEventName, + Document* aDoc, EventTarget* aTarget, const nsAString& aEventName, CanBubble aCanBubble, Cancelable aCancelable, bool* aDefaultAction) { RefPtr event; nsCOMPtr target; @@ -4901,7 +4901,7 @@ void nsContentUtils::RequestFrameFocus(Element& aFrameElement, bool aCanRaise, } nsresult nsContentUtils::DispatchEventOnlyToChrome( - Document* aDoc, nsISupports* aTarget, const nsAString& aEventName, + Document* aDoc, EventTarget* aTarget, const nsAString& aEventName, CanBubble aCanBubble, Cancelable aCancelable, Composed aComposed, bool* aDefaultAction) { return DispatchEvent(aDoc, aTarget, aEventName, aCanBubble, aCancelable, diff --git a/dom/base/nsContentUtils.h b/dom/base/nsContentUtils.h index b09dacc2be6d..9f2850584bbb 100644 --- a/dom/base/nsContentUtils.h +++ b/dom/base/nsContentUtils.h @@ -1472,8 +1472,7 @@ class nsContentUtils { * DispatchInputEvent() instead. * * @param aDoc The document which will be used to create the event. - * @param aTarget The target of the event, should be QIable to - * EventTarget. + * @param aTarget The target of the event. * @param aEventName The name of the event. * @param aCanBubble Whether the event can bubble. * @param aCancelable Is the event cancelable. @@ -1483,7 +1482,8 @@ class nsContentUtils { */ // TODO: annotate with `MOZ_CAN_RUN_SCRIPT` // (https://bugzilla.mozilla.org/show_bug.cgi?id=1625902). - static nsresult DispatchTrustedEvent(Document* aDoc, nsISupports* aTarget, + static nsresult DispatchTrustedEvent(Document* aDoc, + mozilla::dom::EventTarget* aTarget, const nsAString& aEventName, CanBubble, Cancelable, Composed aComposed = Composed::eDefault, @@ -1491,7 +1491,8 @@ class nsContentUtils { // TODO: annotate with `MOZ_CAN_RUN_SCRIPT` // (https://bugzilla.mozilla.org/show_bug.cgi?id=1625902). - static nsresult DispatchTrustedEvent(Document* aDoc, nsISupports* aTarget, + static nsresult DispatchTrustedEvent(Document* aDoc, + mozilla::dom::EventTarget* aTarget, const nsAString& aEventName, CanBubble aCanBubble, Cancelable aCancelable, @@ -1504,8 +1505,7 @@ class nsContentUtils { /** * This method creates and dispatches a trusted event using an event message. * @param aDoc The document which will be used to create the event. - * @param aTarget The target of the event, should be QIable to - * EventTarget. + * @param aTarget The target of the event. * @param aEventMessage The event message. * @param aCanBubble Whether the event can bubble. * @param aCancelable Is the event cancelable. @@ -1514,8 +1514,8 @@ class nsContentUtils { */ template static nsresult DispatchTrustedEvent( - Document* aDoc, nsISupports* aTarget, EventMessage aEventMessage, - CanBubble aCanBubble, Cancelable aCancelable, + Document* aDoc, mozilla::dom::EventTarget* aTarget, + EventMessage aEventMessage, CanBubble aCanBubble, Cancelable aCancelable, bool* aDefaultAction = nullptr, ChromeOnlyDispatch aOnlyChromeDispatch = ChromeOnlyDispatch::eNo) { WidgetEventType event(true, aEventMessage); @@ -1567,15 +1567,15 @@ class nsContentUtils { * Works only with events which can be created by calling * Document::CreateEvent() with parameter "Events". * @param aDoc The document which will be used to create the event. - * @param aTarget The target of the event, should be QIable to - * EventTarget. + * @param aTarget The target of the event. * @param aEventName The name of the event. * @param aCanBubble Whether the event can bubble. * @param aCancelable Is the event cancelable. * @param aDefaultAction Set to true if default action should be taken, * see EventTarget::DispatchEvent. */ - static nsresult DispatchUntrustedEvent(Document* aDoc, nsISupports* aTarget, + static nsresult DispatchUntrustedEvent(Document* aDoc, + mozilla::dom::EventTarget* aTarget, const nsAString& aEventName, CanBubble, Cancelable, bool* aDefaultAction = nullptr); @@ -1584,8 +1584,7 @@ class nsContentUtils { * This method creates and dispatches a untrusted event using an event * message. * @param aDoc The document which will be used to create the event. - * @param aTarget The target of the event, should be QIable to - * EventTarget. + * @param aTarget The target of the event. * @param aEventMessage The event message. * @param aCanBubble Whether the event can bubble. * @param aCancelable Is the event cancelable. @@ -1594,8 +1593,8 @@ class nsContentUtils { */ template static nsresult DispatchUntrustedEvent( - Document* aDoc, nsISupports* aTarget, EventMessage aEventMessage, - CanBubble aCanBubble, Cancelable aCancelable, + Document* aDoc, mozilla::dom::EventTarget* aTarget, + EventMessage aEventMessage, CanBubble aCanBubble, Cancelable aCancelable, bool* aDefaultAction = nullptr, ChromeOnlyDispatch aOnlyChromeDispatch = ChromeOnlyDispatch::eNo) { WidgetEventType event(false, aEventMessage); @@ -1623,7 +1622,8 @@ class nsContentUtils { * @param aDefaultAction Set to true if default action should be taken, * see EventTarget::DispatchEvent. */ - static nsresult DispatchChromeEvent(Document* aDoc, nsISupports* aTarget, + static nsresult DispatchChromeEvent(Document* aDoc, + mozilla::dom::EventTarget* aTarget, const nsAString& aEventName, CanBubble, Cancelable, bool* aDefaultAction = nullptr); @@ -1646,8 +1646,7 @@ class nsContentUtils { * Works only with events which can be created by calling * Document::CreateEvent() with parameter "Events". * @param aDoc The document which will be used to create the event. - * @param aTarget The target of the event, should be QIable to - * EventTarget. + * @param aTarget The target of the event. * @param aEventName The name of the event. * @param aCanBubble Whether the event can bubble. * @param aCancelable Is the event cancelable. @@ -1656,13 +1655,16 @@ class nsContentUtils { * see EventTarget::DispatchEvent. */ static nsresult DispatchEventOnlyToChrome( - Document* aDoc, nsISupports* aTarget, const nsAString& aEventName, - CanBubble, Cancelable, Composed aComposed = Composed::eDefault, - bool* aDefaultAction = nullptr); + Document* aDoc, mozilla::dom::EventTarget* aTarget, + const nsAString& aEventName, CanBubble, Cancelable, + Composed aComposed = Composed::eDefault, bool* aDefaultAction = nullptr); - static nsresult DispatchEventOnlyToChrome( - Document* aDoc, nsISupports* aTarget, const nsAString& aEventName, - CanBubble aCanBubble, Cancelable aCancelable, bool* aDefaultAction) { + static nsresult DispatchEventOnlyToChrome(Document* aDoc, + mozilla::dom::EventTarget* aTarget, + const nsAString& aEventName, + CanBubble aCanBubble, + Cancelable aCancelable, + bool* aDefaultAction) { return DispatchEventOnlyToChrome(aDoc, aTarget, aEventName, aCanBubble, aCancelable, Composed::eDefault, aDefaultAction); @@ -3476,15 +3478,16 @@ class nsContentUtils { // TODO: Convert this to MOZ_CAN_RUN_SCRIPT (bug 1415230) MOZ_CAN_RUN_SCRIPT_BOUNDARY static nsresult DispatchEvent( - Document* aDoc, nsISupports* aTarget, const nsAString& aEventName, - CanBubble, Cancelable, Composed, Trusted, bool* aDefaultAction = nullptr, + Document* aDoc, mozilla::dom::EventTarget* aTarget, + const nsAString& aEventName, CanBubble, Cancelable, Composed, Trusted, + bool* aDefaultAction = nullptr, ChromeOnlyDispatch = ChromeOnlyDispatch::eNo); // TODO: Convert this to MOZ_CAN_RUN_SCRIPT (bug 1415230) MOZ_CAN_RUN_SCRIPT_BOUNDARY static nsresult DispatchEvent( - Document* aDoc, nsISupports* aTarget, mozilla::WidgetEvent& aWidgetEvent, - EventMessage aEventMessage, CanBubble, Cancelable, Trusted, - bool* aDefaultAction = nullptr, + Document* aDoc, mozilla::dom::EventTarget* aTarget, + mozilla::WidgetEvent& aWidgetEvent, EventMessage aEventMessage, CanBubble, + Cancelable, Trusted, bool* aDefaultAction = nullptr, ChromeOnlyDispatch = ChromeOnlyDispatch::eNo); static void InitializeModifierStrings(); diff --git a/dom/base/nsFocusManager.cpp b/dom/base/nsFocusManager.cpp index 141617e93a6b..867d1cd7fc49 100644 --- a/dom/base/nsFocusManager.cpp +++ b/dom/base/nsFocusManager.cpp @@ -1431,7 +1431,8 @@ void nsFocusManager::ActivateOrDeactivate(nsPIDOMWindowOuter* aWindow, if (aWindow->GetExtantDoc()) { nsContentUtils::DispatchEventOnlyToChrome( - aWindow->GetExtantDoc(), aWindow->GetCurrentInnerWindow(), + aWindow->GetExtantDoc(), + nsGlobalWindowInner::Cast(aWindow->GetCurrentInnerWindow()), aActive ? u"activate"_ns : u"deactivate"_ns, CanBubble::eYes, Cancelable::eYes, nullptr); } diff --git a/dom/base/nsGlobalWindowInner.cpp b/dom/base/nsGlobalWindowInner.cpp index fa992b77f16a..5b822636507e 100644 --- a/dom/base/nsGlobalWindowInner.cpp +++ b/dom/base/nsGlobalWindowInner.cpp @@ -5016,8 +5016,8 @@ void nsGlobalWindowInner::FireOfflineStatusEventIfChanged() { } else { name.AssignLiteral("online"); } - nsContentUtils::DispatchTrustedEvent(mDoc, static_cast(this), - name, CanBubble::eNo, Cancelable::eNo); + nsContentUtils::DispatchTrustedEvent(mDoc, this, name, CanBubble::eNo, + Cancelable::eNo); } nsGlobalWindowInner::SlowScriptResponse diff --git a/dom/base/nsGlobalWindowOuter.cpp b/dom/base/nsGlobalWindowOuter.cpp index c9a45b8a21e6..3321e7a4030e 100644 --- a/dom/base/nsGlobalWindowOuter.cpp +++ b/dom/base/nsGlobalWindowOuter.cpp @@ -2610,9 +2610,8 @@ void nsGlobalWindowOuter::DispatchDOMWindowCreated() { } // Fire DOMWindowCreated at chrome event listeners - nsContentUtils::DispatchChromeEvent(mDoc, ToSupports(mDoc), - u"DOMWindowCreated"_ns, CanBubble::eYes, - Cancelable::eNo); + nsContentUtils::DispatchChromeEvent(mDoc, mDoc, u"DOMWindowCreated"_ns, + CanBubble::eYes, Cancelable::eNo); nsCOMPtr observerService = mozilla::services::GetObserverService(); @@ -3857,11 +3856,11 @@ bool nsGlobalWindowOuter::DispatchCustomEvent( bool defaultActionEnabled = true; if (aChromeOnlyDispatch == ChromeOnlyDispatch::eYes) { - nsContentUtils::DispatchEventOnlyToChrome( - mDoc, ToSupports(this), aEventName, CanBubble::eYes, Cancelable::eYes, - &defaultActionEnabled); + nsContentUtils::DispatchEventOnlyToChrome(mDoc, this, aEventName, + CanBubble::eYes, Cancelable::eYes, + &defaultActionEnabled); } else { - nsContentUtils::DispatchTrustedEvent(mDoc, ToSupports(this), aEventName, + nsContentUtils::DispatchTrustedEvent(mDoc, this, aEventName, CanBubble::eYes, Cancelable::eYes, &defaultActionEnabled); } diff --git a/dom/canvas/ClientWebGLContext.cpp b/dom/canvas/ClientWebGLContext.cpp index be03d6ada913..8183484cd411 100644 --- a/dom/canvas/ClientWebGLContext.cpp +++ b/dom/canvas/ClientWebGLContext.cpp @@ -235,9 +235,9 @@ bool ClientWebGLContext::DispatchEvent(const nsAString& eventName) const { bool useDefaultHandler = true; if (mCanvasElement) { - nsContentUtils::DispatchTrustedEvent( - mCanvasElement->OwnerDoc(), static_cast(mCanvasElement), - eventName, kCanBubble, kIsCancelable, &useDefaultHandler); + nsContentUtils::DispatchTrustedEvent(mCanvasElement->OwnerDoc(), + mCanvasElement, eventName, kCanBubble, + kIsCancelable, &useDefaultHandler); } else if (mOffscreenCanvas) { // OffscreenCanvas case RefPtr event = diff --git a/dom/events/Clipboard.cpp b/dom/events/Clipboard.cpp index 090f06834bbb..5beaab939ce8 100644 --- a/dom/events/Clipboard.cpp +++ b/dom/events/Clipboard.cpp @@ -74,8 +74,8 @@ static bool MaybeCreateAndDispatchMozClipboardReadPasteEvent( // It ensures to receive the event by declaring the event in // . return !NS_WARN_IF(NS_FAILED(nsContentUtils::DispatchChromeEvent( - document, ToSupports(document), u"MozClipboardReadPaste"_ns, - CanBubble::eNo, Cancelable::eNo))); + document, document, u"MozClipboardReadPaste"_ns, CanBubble::eNo, + Cancelable::eNo))); } void Clipboard::ReadRequest::Answer() { diff --git a/dom/html/HTMLInputElement.cpp b/dom/html/HTMLInputElement.cpp index 75536c2488bd..264677146ac0 100644 --- a/dom/html/HTMLInputElement.cpp +++ b/dom/html/HTMLInputElement.cpp @@ -248,9 +248,9 @@ class DispatchChangeEventCallback final : public GetFilesCallback { nsresult rv = nsContentUtils::DispatchInputEvent(inputElement); NS_WARNING_ASSERTION(NS_SUCCEEDED(rv), "Failed to dispatch input event"); - rv = nsContentUtils::DispatchTrustedEvent( - mInputElement->OwnerDoc(), static_cast(mInputElement.get()), - u"change"_ns, CanBubble::eYes, Cancelable::eNo); + rv = nsContentUtils::DispatchTrustedEvent(mInputElement->OwnerDoc(), + mInputElement, u"change"_ns, + CanBubble::eYes, Cancelable::eNo); return rv; } @@ -451,8 +451,8 @@ HTMLInputElement::nsFilePickerShownCallback::Done( if (aResult == nsIFilePicker::returnCancel) { RefPtr inputElement(mInput); return nsContentUtils::DispatchTrustedEvent( - inputElement->OwnerDoc(), static_cast(inputElement.get()), - u"cancel"_ns, CanBubble::eYes, Cancelable::eNo); + inputElement->OwnerDoc(), inputElement, u"cancel"_ns, CanBubble::eYes, + Cancelable::eNo); } mInput->OwnerDoc()->NotifyUserGestureActivation(); @@ -6851,8 +6851,8 @@ void HTMLInputElement::SetRevealPassword(bool aValue) { // revealing the saved passwords. bool defaultAction = true; nsContentUtils::DispatchEventOnlyToChrome( - doc, ToSupports(this), u"MozWillToggleReveal"_ns, CanBubble::eYes, - Cancelable::eYes, &defaultAction); + doc, this, u"MozWillToggleReveal"_ns, CanBubble::eYes, Cancelable::eYes, + &defaultAction); if (NS_WARN_IF(!defaultAction)) { return; } diff --git a/dom/html/HTMLMediaElement.cpp b/dom/html/HTMLMediaElement.cpp index 0512d6563436..f581bcfead54 100644 --- a/dom/html/HTMLMediaElement.cpp +++ b/dom/html/HTMLMediaElement.cpp @@ -6248,9 +6248,8 @@ nsresult HTMLMediaElement::DispatchEvent(const nsAString& aName) { return NS_OK; } - return nsContentUtils::DispatchTrustedEvent( - OwnerDoc(), static_cast(this), aName, CanBubble::eNo, - Cancelable::eNo); + return nsContentUtils::DispatchTrustedEvent(OwnerDoc(), this, aName, + CanBubble::eNo, Cancelable::eNo); } void HTMLMediaElement::DispatchAsyncEvent(const nsAString& aName) { diff --git a/dom/html/HTMLSlotElement.cpp b/dom/html/HTMLSlotElement.cpp index 7c53d0de3f23..9fb3986e93fb 100644 --- a/dom/html/HTMLSlotElement.cpp +++ b/dom/html/HTMLSlotElement.cpp @@ -354,9 +354,8 @@ void HTMLSlotElement::EnqueueSlotChangeEvent() { } void HTMLSlotElement::FireSlotChangeEvent() { - nsContentUtils::DispatchTrustedEvent( - OwnerDoc(), static_cast(this), u"slotchange"_ns, - CanBubble::eYes, Cancelable::eNo); + nsContentUtils::DispatchTrustedEvent(OwnerDoc(), this, u"slotchange"_ns, + CanBubble::eYes, Cancelable::eNo); } void HTMLSlotElement::RemoveManuallyAssignedNode(nsIContent& aNode) { diff --git a/dom/html/HTMLTextAreaElement.cpp b/dom/html/HTMLTextAreaElement.cpp index 00e50c742c77..5379c0984190 100644 --- a/dom/html/HTMLTextAreaElement.cpp +++ b/dom/html/HTMLTextAreaElement.cpp @@ -472,9 +472,8 @@ void HTMLTextAreaElement::FireChangeEventIfNeeded() { // Dispatch the change event. mFocusedValue = value; - nsContentUtils::DispatchTrustedEvent( - OwnerDoc(), static_cast(this), u"change"_ns, CanBubble::eYes, - Cancelable::eNo); + nsContentUtils::DispatchTrustedEvent(OwnerDoc(), this, u"change"_ns, + CanBubble::eYes, Cancelable::eNo); } nsresult HTMLTextAreaElement::PostHandleEvent(EventChainPostVisitor& aVisitor) { diff --git a/dom/html/HTMLTrackElement.cpp b/dom/html/HTMLTrackElement.cpp index 51be886eb3a7..11411bcddc62 100644 --- a/dom/html/HTMLTrackElement.cpp +++ b/dom/html/HTMLTrackElement.cpp @@ -468,8 +468,8 @@ void HTMLTrackElement::DispatchTrustedEvent(const nsAString& aName) { if (!doc) { return; } - nsContentUtils::DispatchTrustedEvent(doc, static_cast(this), - aName, CanBubble::eNo, Cancelable::eNo); + nsContentUtils::DispatchTrustedEvent(doc, this, aName, CanBubble::eNo, + Cancelable::eNo); } void HTMLTrackElement::CancelChannelAndListener() { diff --git a/dom/l10n/L10nMutations.cpp b/dom/l10n/L10nMutations.cpp index 63e30c2d8354..4ae88b020be1 100644 --- a/dom/l10n/L10nMutations.cpp +++ b/dom/l10n/L10nMutations.cpp @@ -286,8 +286,8 @@ void L10nMutations::MaybeFirePendingTranslationsFinished() { doc->UnblockOnload(false); } nsContentUtils::DispatchEventOnlyToChrome( - doc, ToSupports(doc), u"L10nMutationsFinished"_ns, CanBubble::eNo, - Cancelable::eNo, Composed::eNo, nullptr); + doc, doc, u"L10nMutationsFinished"_ns, CanBubble::eNo, Cancelable::eNo, + Composed::eNo, nullptr); } void L10nMutations::Disconnect() { diff --git a/dom/media/doctor/DecoderDoctorDiagnostics.cpp b/dom/media/doctor/DecoderDoctorDiagnostics.cpp index abd774d6ddbb..fb6d71f17559 100644 --- a/dom/media/doctor/DecoderDoctorDiagnostics.cpp +++ b/dom/media/doctor/DecoderDoctorDiagnostics.cpp @@ -420,8 +420,8 @@ static void ReportToConsole(dom::Document* aDocument, aParams.Length() < 2 ? "" : ", ..."); if (StaticPrefs::media_decoder_doctor_testing()) { Unused << nsContentUtils::DispatchTrustedEvent( - aDocument, ToSupports(aDocument), u"mozreportmediaerror"_ns, - CanBubble::eNo, Cancelable::eNo); + aDocument, aDocument, u"mozreportmediaerror"_ns, CanBubble::eNo, + Cancelable::eNo); } nsContentUtils::ReportToConsole(nsIScriptError::warningFlag, "Media"_ns, aDocument, nsContentUtils::eDOM_PROPERTIES, diff --git a/dom/media/webaudio/AudioContext.cpp b/dom/media/webaudio/AudioContext.cpp index cb5719d035de..f6627af75391 100644 --- a/dom/media/webaudio/AudioContext.cpp +++ b/dom/media/webaudio/AudioContext.cpp @@ -843,8 +843,7 @@ class OnStateChangeTask final : public Runnable { } return nsContentUtils::DispatchTrustedEvent( - doc, static_cast(mAudioContext), - u"statechange"_ns, CanBubble::eNo, Cancelable::eNo); + doc, mAudioContext, u"statechange"_ns, CanBubble::eNo, Cancelable::eNo); } private: @@ -1193,9 +1192,8 @@ void AudioContext::ReportBlocked() { AUTOPLAY_LOG("Dispatch `blocked` event for AudioContext %p", self.get()); - nsContentUtils::DispatchTrustedEvent( - doc, static_cast(self), u"blocked"_ns, - CanBubble::eNo, Cancelable::eNo); + nsContentUtils::DispatchTrustedEvent(doc, self, u"blocked"_ns, + CanBubble::eNo, Cancelable::eNo); }); Dispatch(r.forget()); } diff --git a/dom/prototype/PrototypeDocumentContentSink.cpp b/dom/prototype/PrototypeDocumentContentSink.cpp index 8f2c880856ea..2094609f75ca 100644 --- a/dom/prototype/PrototypeDocumentContentSink.cpp +++ b/dom/prototype/PrototypeDocumentContentSink.cpp @@ -651,7 +651,7 @@ nsresult PrototypeDocumentContentSink::DoneWalking() { mDocument->SetReadyStateInternal(Document::READYSTATE_INTERACTIVE); mDocument->NotifyPossibleTitleChange(false); - nsContentUtils::DispatchEventOnlyToChrome(mDocument, ToSupports(mDocument), + nsContentUtils::DispatchEventOnlyToChrome(mDocument, mDocument, u"MozBeforeInitialXULLayout"_ns, CanBubble::eYes, Cancelable::eNo); } diff --git a/layout/base/nsPresContext.cpp b/layout/base/nsPresContext.cpp index 888acf724269..d8bdf95b4f62 100644 --- a/layout/base/nsPresContext.cpp +++ b/layout/base/nsPresContext.cpp @@ -1776,8 +1776,8 @@ void nsPresContext::ThemeChangedInternal() { if (Document()->IsInChromeDocShell()) { if (RefPtr win = Document()->GetInnerWindow()) { nsContentUtils::DispatchEventOnlyToChrome( - Document(), win, u"nativethemechange"_ns, CanBubble::eYes, - Cancelable::eYes, nullptr); + Document(), nsGlobalWindowInner::Cast(win), u"nativethemechange"_ns, + CanBubble::eYes, Cancelable::eYes, nullptr); } } } diff --git a/layout/forms/HTMLSelectEventListener.cpp b/layout/forms/HTMLSelectEventListener.cpp index c3d7c542c9e4..85ca3f1bb511 100644 --- a/layout/forms/HTMLSelectEventListener.cpp +++ b/layout/forms/HTMLSelectEventListener.cpp @@ -278,8 +278,8 @@ void HTMLSelectEventListener::Detach() { if (!element->IsCombobox() || !element->GetPrimaryFrame(FlushType::Frames)) { nsContentUtils::DispatchChromeEvent( - element->OwnerDoc(), ToSupports(element.get()), - u"mozhidedropdown"_ns, CanBubble::eYes, Cancelable::eNo); + element->OwnerDoc(), element, u"mozhidedropdown"_ns, + CanBubble::eYes, Cancelable::eNo); } })); } @@ -383,7 +383,7 @@ void HTMLSelectEventListener::FireOnInputAndOnChange() { "Failed to dispatch input event"); // Dispatch the change event. - nsContentUtils::DispatchTrustedEvent(element->OwnerDoc(), ToSupports(element), + nsContentUtils::DispatchTrustedEvent(element->OwnerDoc(), element, u"change"_ns, CanBubble::eYes, Cancelable::eNo); } @@ -397,8 +397,7 @@ static void FireDropDownEvent(HTMLSelectElement* aElement, bool aShow, } return u"mozhidedropdown"_ns; }(); - nsContentUtils::DispatchChromeEvent(aElement->OwnerDoc(), - ToSupports(aElement), eventName, + nsContentUtils::DispatchChromeEvent(aElement->OwnerDoc(), aElement, eventName, CanBubble::eYes, Cancelable::eNo); } diff --git a/layout/forms/nsFileControlFrame.cpp b/layout/forms/nsFileControlFrame.cpp index 1a91d0715341..cdbf266e1e43 100644 --- a/layout/forms/nsFileControlFrame.cpp +++ b/layout/forms/nsFileControlFrame.cpp @@ -283,9 +283,9 @@ nsFileControlFrame::DnDListener::HandleEvent(Event* aEvent) { nsContentUtils::DispatchInputEvent(inputElement); NS_WARNING_ASSERTION(NS_SUCCEEDED(rvIgnored), "Failed to dispatch input event"); - nsContentUtils::DispatchTrustedEvent( - inputElement->OwnerDoc(), static_cast(inputElement), - u"change"_ns, CanBubble::eYes, Cancelable::eNo); + nsContentUtils::DispatchTrustedEvent(inputElement->OwnerDoc(), + inputElement, u"change"_ns, + CanBubble::eYes, Cancelable::eNo); } }