mirror of
https://github.com/servo/servo.git
synced 2025-09-30 00:29:14 +01:00
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:
parent
21717158eb
commit
589d188a3f
9 changed files with 40 additions and 68 deletions
|
@ -57,7 +57,7 @@ use crate::dom::csp::{CspReporting, InlineCheckType};
|
|||
use crate::dom::document::Document;
|
||||
use crate::dom::element::Element;
|
||||
use crate::dom::errorevent::ErrorEvent;
|
||||
use crate::dom::event::{Event, EventBubbles, EventCancelable, EventComposed, EventStatus};
|
||||
use crate::dom::event::{Event, EventBubbles, EventCancelable, EventComposed};
|
||||
use crate::dom::globalscope::GlobalScope;
|
||||
use crate::dom::htmlformelement::FormControlElementHelpers;
|
||||
use crate::dom::node::{Node, NodeTraits};
|
||||
|
@ -430,7 +430,7 @@ impl EventTarget {
|
|||
.map_or(EventListeners(vec![]), |listeners| listeners.clone())
|
||||
}
|
||||
|
||||
pub(crate) fn dispatch_event(&self, event: &Event, can_gc: CanGc) -> EventStatus {
|
||||
pub(crate) fn dispatch_event(&self, event: &Event, can_gc: CanGc) -> bool {
|
||||
event.dispatch(self, false, can_gc)
|
||||
}
|
||||
|
||||
|
@ -994,10 +994,7 @@ impl EventTargetMethods<crate::DomTypeHolder> for EventTarget {
|
|||
return Err(Error::InvalidState);
|
||||
}
|
||||
event.set_trusted(false);
|
||||
Ok(match self.dispatch_event(event, can_gc) {
|
||||
EventStatus::Canceled => false,
|
||||
EventStatus::NotCanceled => true,
|
||||
})
|
||||
Ok(self.dispatch_event(event, can_gc))
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue