script: Change signature of Event::dispatch to match the spec and simplify things (#38566)

- [Dispatch Event](https://dom.spec.whatwg.org/#concept-event-dispatch)
should return a Boolean. This function is used frequently in spec and
the change makes things easier to follow.
- Remove `enum EventStatus` and related functions.
- Update some dead spec link.
- Update some steps.

This is intended as cleanup before working on #38435 and reduces binary
size by 488KB in Release profile.

Testing: No behaviour change.

---------

Signed-off-by: Euclid Ye <euclid.ye@huawei.com>
This commit is contained in:
Euclid Ye 2025-08-09 16:04:31 +08:00 committed by GitHub
parent 21717158eb
commit 589d188a3f
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
9 changed files with 40 additions and 68 deletions

View file

@ -75,7 +75,7 @@ use crate::dom::bindings::root::trace_roots;
use crate::dom::bindings::utils::DOM_CALLBACKS;
use crate::dom::bindings::{principals, settings_stack};
use crate::dom::csp::CspReporting;
use crate::dom::event::{Event, EventBubbles, EventCancelable, EventStatus};
use crate::dom::event::{Event, EventBubbles, EventCancelable};
use crate::dom::eventtarget::EventTarget;
use crate::dom::globalscope::GlobalScope;
use crate::dom::promise::Promise;
@ -559,10 +559,11 @@ pub(crate) fn notify_about_rejected_promises(global: &GlobalScope) {
CanGc::note()
);
let event_status = event.upcast::<Event>().fire(&target, CanGc::note());
let not_canceled = event.upcast::<Event>().fire(&target, CanGc::note());
// Step 4-3.
if event_status == EventStatus::Canceled {
// Step 4-3. If notCanceled is true, then the user agent
// may report p.[[PromiseResult]] to a developer console.
if not_canceled {
// TODO: The promise rejection is not handled; we need to add it back to the list.
}