Use atom to match id selector.

This commit is contained in:
Tetsuharu OHZEKI 2014-07-26 04:33:54 +09:00
parent f2db7faf19
commit 794ce9cd4d
6 changed files with 51 additions and 10 deletions

View file

@ -167,6 +167,7 @@ impl<'a> AttrMethods for JSRef<'a, Attr> {
pub trait AttrHelpersForLayout {
unsafe fn value_ref_forever(&self) -> &'static str;
unsafe fn value_atom_forever(&self) -> Option<Atom>;
}
impl AttrHelpersForLayout for Attr {
@ -175,4 +176,13 @@ impl AttrHelpersForLayout for Attr {
let value = mem::transmute::<&RefCell<AttrValue>, &AttrValue>(self.value.deref());
value.as_slice()
}
unsafe fn value_atom_forever(&self) -> Option<Atom> {
// cast to point to T in RefCell<T> directly
let value = mem::transmute::<&RefCell<AttrValue>, &AttrValue>(self.value.deref());
match *value {
AtomAttrValue(ref val) => Some(val.clone()),
_ => None,
}
}
}