mirror of
https://github.com/servo/servo.git
synced 2025-08-04 05:00:08 +01:00
Use atom to match id selector.
This commit is contained in:
parent
f2db7faf19
commit
794ce9cd4d
6 changed files with 51 additions and 10 deletions
|
@ -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,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue