Avoid QueryInterface to convert nsINode to EventTarget in EventDispatcher::Dispatch and friends
Categories
(Core :: DOM: Events, task)
Tracking
()
Tracking | Status | |
---|---|---|
firefox119 | --- | fixed |
People
(Reporter: mstange, Assigned: mstange)
References
(Blocks 1 open bug)
Details
(Whiteboard: [sp3])
Attachments
(4 files)
nsINode
inherits from mozilla::dom::EventTarget
.
However, both EventDispatcher::Dispatch
and nsContentUtis::DispatchEvent
use nsISupports*
for their event target argument. Then they convert this nsISupports
into a mozilla::dom::EventTarget
with a QueryInterface
:
nsCOMPtr<EventTarget> target = do_QueryInterface(aTarget);
So when we want to dispatch an event on an nsINode
, we pay the QueryInterface cost even though the conversion is trivial.
This shows up noticeably in the testcases in bug 1834003: https://share.firefox.dev/3Oe7Jd5
The funniest part is that nsContentUtils::DispatchEvent
does a QueryInterface, and then calls EventDispatcher::DispatchDOMEvent
which calls EventDispatcher::Dispatch
which does another QueryInterface.
We should change all these methods to accept the aTarget
parameter as a mozilla::dom::EventTarget*
. It should be the caller's responsibility to do the type conversion.
Updated•1 year ago
|
Assignee | ||
Updated•1 year ago
|
Assignee | ||
Comment 1•1 year ago
|
||
This saves a few queryInterface calls on the hot path.
Assignee | ||
Comment 2•1 year ago
|
||
thods. r=smaug
This saves a few queryInterface calls on the hot path.
Depends on D186976
Assignee | ||
Comment 3•1 year ago
|
||
Depends on D186977
Assignee | ||
Comment 4•1 year ago
|
||
Depends on D186978
Updated•1 year ago
|
Assignee | ||
Comment 5•1 year ago
|
||
Pushed by mstange@themasta.com: https://hg.mozilla.org/integration/autoland/rev/dbe2251dd9b2 Use EventTarget* instead of nsISupports* for the event target parameter of the nsContentUtils::Dispatch methods. r=smaug https://hg.mozilla.org/integration/autoland/rev/688628005eae Use EventTarget* instead of nsISupports* for the event target parameter of the EventDispatcher::Dispatch methods. r=smaug https://hg.mozilla.org/integration/autoland/rev/8031bd3adbe3 Use EventTarget* instead of nsISupports* in some nsFocusManager methods. r=smaug https://hg.mozilla.org/integration/autoland/rev/74ca256e1cb6 Don't hold an extra strong reference to the event target. r=smaug
Comment 7•1 year ago
|
||
bugherder |
https://hg.mozilla.org/mozilla-central/rev/dbe2251dd9b2
https://hg.mozilla.org/mozilla-central/rev/688628005eae
https://hg.mozilla.org/mozilla-central/rev/8031bd3adbe3
https://hg.mozilla.org/mozilla-central/rev/74ca256e1cb6
Description
•