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:
Corey Farwell 2015-12-10 22:06:05 -05:00
parent 996c0a60b8
commit 4accaf50b2
25 changed files with 156 additions and 135 deletions

View file

@ -524,7 +524,7 @@ impl Document {
self.ready_state.set(state);
let event = Event::new(GlobalRef::Window(&self.window),
DOMString::from("readystatechange"),
atom!("readystatechange"),
EventBubbles::DoesNotBubble,
EventCancelable::NotCancelable);
let target = self.upcast::<EventTarget>();
@ -1326,7 +1326,7 @@ impl Document {
update_with_current_time(&self.dom_content_loaded_event_start);
let event = Event::new(GlobalRef::Window(self.window()),
DOMString::from("DOMContentLoaded"),
atom!("DOMContentLoaded"),
EventBubbles::DoesNotBubble,
EventCancelable::NotCancelable);
let doctarget = self.upcast::<EventTarget>();
@ -2464,7 +2464,7 @@ impl DocumentProgressHandler {
let document = self.addr.root();
let window = document.window();
let event = Event::new(GlobalRef::Window(window),
DOMString::from("load"),
atom!("load"),
EventBubbles::DoesNotBubble,
EventCancelable::NotCancelable);
let wintarget = window.upcast::<EventTarget>();