Bug 1843484 - Use EventTarget* instead of nsISupports* for the event target parameter of the nsContentUtils::Dispatch methods. r=smaug

This saves a few queryInterface calls on the hot path.

Differential Revision: https://phabricator.services.mozilla.com/D186976
This commit is contained in:
Markus Stange 2023-08-28 23:38:42 +00:00
parent 2572abb974
commit 3d20b7df6c
24 changed files with 110 additions and 114 deletions

View File

@ -3022,7 +3022,8 @@ void BrowsingContext::DidSet(FieldIndex<IDX_IsActiveBrowserWindowInternal>,
// 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);
}
}

View File

@ -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<nsPresContext> presContext = doc->GetPresContext()) {
presContext->EmulateMedium(aBefore ? nsGkAtoms::print : nullptr);
// Ensure media query listeners fire.

View File

@ -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<ServiceWorkerContainer> 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<nsIObserverService> obs = mozilla::services::GetObserverService();
if (obs) {
@ -14463,7 +14461,7 @@ already_AddRefed<Promise> 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<FullscreenRequest> 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();

View File

@ -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;
}

View File

@ -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);
}

View File

@ -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<EventTarget> target(do_QueryInterface(aTarget));
nsCOMPtr<EventTarget> 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<EventTarget> target(do_QueryInterface(aTarget));
nsCOMPtr<EventTarget> 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> event;
nsCOMPtr<EventTarget> 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,

View File

@ -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 <class WidgetEventType>
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 <class WidgetEventType>
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();

View File

@ -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);
}

View File

@ -5016,8 +5016,8 @@ void nsGlobalWindowInner::FireOfflineStatusEventIfChanged() {
} else {
name.AssignLiteral("online");
}
nsContentUtils::DispatchTrustedEvent(mDoc, static_cast<EventTarget*>(this),
name, CanBubble::eNo, Cancelable::eNo);
nsContentUtils::DispatchTrustedEvent(mDoc, this, name, CanBubble::eNo,
Cancelable::eNo);
}
nsGlobalWindowInner::SlowScriptResponse

View File

@ -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<nsIObserverService> 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);
}

View File

@ -235,9 +235,9 @@ bool ClientWebGLContext::DispatchEvent(const nsAString& eventName) const {
bool useDefaultHandler = true;
if (mCanvasElement) {
nsContentUtils::DispatchTrustedEvent(
mCanvasElement->OwnerDoc(), static_cast<nsIContent*>(mCanvasElement),
eventName, kCanBubble, kIsCancelable, &useDefaultHandler);
nsContentUtils::DispatchTrustedEvent(mCanvasElement->OwnerDoc(),
mCanvasElement, eventName, kCanBubble,
kIsCancelable, &useDefaultHandler);
} else if (mOffscreenCanvas) {
// OffscreenCanvas case
RefPtr<dom::Event> event =

View File

@ -74,8 +74,8 @@ static bool MaybeCreateAndDispatchMozClipboardReadPasteEvent(
// It ensures to receive the event by declaring the event in
// <BrowserGlue.sys.mjs>.
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() {

View File

@ -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<Element*>(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<HTMLInputElement> inputElement(mInput);
return nsContentUtils::DispatchTrustedEvent(
inputElement->OwnerDoc(), static_cast<Element*>(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;
}

View File

@ -6248,9 +6248,8 @@ nsresult HTMLMediaElement::DispatchEvent(const nsAString& aName) {
return NS_OK;
}
return nsContentUtils::DispatchTrustedEvent(
OwnerDoc(), static_cast<nsIContent*>(this), aName, CanBubble::eNo,
Cancelable::eNo);
return nsContentUtils::DispatchTrustedEvent(OwnerDoc(), this, aName,
CanBubble::eNo, Cancelable::eNo);
}
void HTMLMediaElement::DispatchAsyncEvent(const nsAString& aName) {

View File

@ -354,9 +354,8 @@ void HTMLSlotElement::EnqueueSlotChangeEvent() {
}
void HTMLSlotElement::FireSlotChangeEvent() {
nsContentUtils::DispatchTrustedEvent(
OwnerDoc(), static_cast<nsIContent*>(this), u"slotchange"_ns,
CanBubble::eYes, Cancelable::eNo);
nsContentUtils::DispatchTrustedEvent(OwnerDoc(), this, u"slotchange"_ns,
CanBubble::eYes, Cancelable::eNo);
}
void HTMLSlotElement::RemoveManuallyAssignedNode(nsIContent& aNode) {

View File

@ -472,9 +472,8 @@ void HTMLTextAreaElement::FireChangeEventIfNeeded() {
// Dispatch the change event.
mFocusedValue = value;
nsContentUtils::DispatchTrustedEvent(
OwnerDoc(), static_cast<nsIContent*>(this), u"change"_ns, CanBubble::eYes,
Cancelable::eNo);
nsContentUtils::DispatchTrustedEvent(OwnerDoc(), this, u"change"_ns,
CanBubble::eYes, Cancelable::eNo);
}
nsresult HTMLTextAreaElement::PostHandleEvent(EventChainPostVisitor& aVisitor) {

View File

@ -468,8 +468,8 @@ void HTMLTrackElement::DispatchTrustedEvent(const nsAString& aName) {
if (!doc) {
return;
}
nsContentUtils::DispatchTrustedEvent(doc, static_cast<nsIContent*>(this),
aName, CanBubble::eNo, Cancelable::eNo);
nsContentUtils::DispatchTrustedEvent(doc, this, aName, CanBubble::eNo,
Cancelable::eNo);
}
void HTMLTrackElement::CancelChannelAndListener() {

View File

@ -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() {

View File

@ -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,

View File

@ -843,8 +843,7 @@ class OnStateChangeTask final : public Runnable {
}
return nsContentUtils::DispatchTrustedEvent(
doc, static_cast<DOMEventTargetHelper*>(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<DOMEventTargetHelper*>(self), u"blocked"_ns,
CanBubble::eNo, Cancelable::eNo);
nsContentUtils::DispatchTrustedEvent(doc, self, u"blocked"_ns,
CanBubble::eNo, Cancelable::eNo);
});
Dispatch(r.forget());
}

View File

@ -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);
}

View File

@ -1776,8 +1776,8 @@ void nsPresContext::ThemeChangedInternal() {
if (Document()->IsInChromeDocShell()) {
if (RefPtr<nsPIDOMWindowInner> 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);
}
}
}

View File

@ -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);
}

View File

@ -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<nsINode*>(inputElement),
u"change"_ns, CanBubble::eYes, Cancelable::eNo);
nsContentUtils::DispatchTrustedEvent(inputElement->OwnerDoc(),
inputElement, u"change"_ns,
CanBubble::eYes, Cancelable::eNo);
}
}