mirror of
https://github.com/servo/servo.git
synced 2025-08-14 01:45:33 +01:00
Add performant implementations of get_id, has_class, and each_class.
This commit is contained in:
parent
0e6bc9f60b
commit
b90b4a5e0f
2 changed files with 51 additions and 11 deletions
|
@ -134,6 +134,10 @@ impl Atom {
|
|||
self.0
|
||||
}
|
||||
|
||||
pub unsafe fn with<F>(ptr: *mut nsIAtom, callback: &mut F) where F: FnMut(&Atom) {
|
||||
callback(transmute(&ptr))
|
||||
}
|
||||
|
||||
// Static atoms have a dummy AddRef/Release, so we don't bother calling
|
||||
// AddRef() here. This would cause memory corruption with non-static atoms
|
||||
// both because (a) we wouldn't hold the atom alive, and (b) we can't avoid
|
||||
|
@ -226,3 +230,12 @@ impl From<String> for Atom {
|
|||
Atom::from(&*string)
|
||||
}
|
||||
}
|
||||
|
||||
impl From<*mut nsIAtom> for Atom {
|
||||
fn from(ptr: *mut nsIAtom) -> Atom {
|
||||
unsafe {
|
||||
Gecko_AddRefAtom(ptr);
|
||||
Atom(ptr)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue