mirror of
https://github.com/servo/servo.git
synced 2025-06-11 01:50:10 +00:00
Pass around event types as Atoms instead of Strings
`Event` internally stores the `type` as an `Atom`, and we're `String`s everywhere, which can cause unnecessary allocations to occur since they'll end up as `Atom`s anyways.
This commit is contained in:
parent
996c0a60b8
commit
4accaf50b2
25 changed files with 156 additions and 135 deletions
|
@ -478,25 +478,25 @@ impl HTMLScriptElement {
|
|||
}
|
||||
|
||||
pub fn dispatch_before_script_execute_event(&self) -> bool {
|
||||
self.dispatch_event("beforescriptexecute".to_owned(),
|
||||
self.dispatch_event(atom!("beforescriptexecute"),
|
||||
EventBubbles::Bubbles,
|
||||
EventCancelable::Cancelable)
|
||||
}
|
||||
|
||||
pub fn dispatch_after_script_execute_event(&self) {
|
||||
self.dispatch_event("afterscriptexecute".to_owned(),
|
||||
self.dispatch_event(atom!("afterscriptexecute"),
|
||||
EventBubbles::Bubbles,
|
||||
EventCancelable::NotCancelable);
|
||||
}
|
||||
|
||||
pub fn dispatch_load_event(&self) {
|
||||
self.dispatch_event("load".to_owned(),
|
||||
self.dispatch_event(atom!("load"),
|
||||
EventBubbles::DoesNotBubble,
|
||||
EventCancelable::NotCancelable);
|
||||
}
|
||||
|
||||
pub fn dispatch_error_event(&self) {
|
||||
self.dispatch_event("error".to_owned(),
|
||||
self.dispatch_event(atom!("error"),
|
||||
EventBubbles::DoesNotBubble,
|
||||
EventCancelable::NotCancelable);
|
||||
}
|
||||
|
@ -546,15 +546,12 @@ impl HTMLScriptElement {
|
|||
}
|
||||
|
||||
fn dispatch_event(&self,
|
||||
type_: String,
|
||||
type_: Atom,
|
||||
bubbles: EventBubbles,
|
||||
cancelable: EventCancelable) -> bool {
|
||||
let window = window_from_node(self);
|
||||
let window = window.r();
|
||||
let event = Event::new(GlobalRef::Window(window),
|
||||
DOMString::from(type_),
|
||||
bubbles,
|
||||
cancelable);
|
||||
let event = Event::new(GlobalRef::Window(window), type_, bubbles, cancelable);
|
||||
event.fire(self.upcast())
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue