diff options
Diffstat (limited to 'components/script/dom/event.rs')
-rw-r--r-- | components/script/dom/event.rs | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/components/script/dom/event.rs b/components/script/dom/event.rs index c56d44e15c3..0aa57146a8e 100644 --- a/components/script/dom/event.rs +++ b/components/script/dom/event.rs @@ -13,6 +13,7 @@ use dom::eventtarget::EventTarget; use std::borrow::ToOwned; use std::cell::Cell; use std::default::Default; +use string_cache::Atom; use time; use util::str::DOMString; @@ -43,7 +44,7 @@ pub struct Event { reflector_: Reflector, current_target: MutNullableHeap<JS<EventTarget>>, target: MutNullableHeap<JS<EventTarget>>, - type_: DOMRefCell<DOMString>, + type_: DOMRefCell<Atom>, phase: Cell<EventPhase>, canceled: Cell<bool>, stop_propagation: Cell<bool>, @@ -62,7 +63,7 @@ impl Event { reflector_: Reflector::new(), current_target: Default::default(), target: Default::default(), - type_: DOMRefCell::new("".to_owned()), + type_: DOMRefCell::new(atom!("")), phase: Cell::new(EventPhase::None), canceled: Cell::new(false), stop_propagation: Cell::new(false), @@ -153,6 +154,11 @@ impl Event { pub fn initialized(&self) -> bool { self.initialized.get() } + + #[inline] + pub fn type_(&self) -> Atom { + self.type_.borrow().clone() + } } impl EventMethods for Event { @@ -163,7 +169,7 @@ impl EventMethods for Event { // https://dom.spec.whatwg.org/#dom-event-type fn Type(&self) -> DOMString { - self.type_.borrow().clone() + (*self.type_()).to_owned() } // https://dom.spec.whatwg.org/#dom-event-target @@ -229,7 +235,7 @@ impl EventMethods for Event { self.canceled.set(false); self.trusted.set(false); self.target.set(None); - *self.type_.borrow_mut() = type_; + *self.type_.borrow_mut() = Atom::from_slice(&type_); self.bubbles.set(bubbles); self.cancelable.set(cancelable); } |