style: Make Element::id not clone the attribute.

This commit is contained in:
Emilio Cobos Álvarez 2018-02-24 21:49:43 +01:00
parent 98c9292ecb
commit f2efd04a5d
No known key found for this signature in database
GPG key ID: 056B727BB9C1027C
10 changed files with 46 additions and 37 deletions

View file

@ -1176,7 +1176,7 @@ impl<'le> TElement for GeckoElement<'le> {
// FIXME(emilio): we should probably just return a reference to the Atom.
#[inline]
fn id(&self) -> Option<Atom> {
fn id(&self) -> Option<&WeakAtom> {
if !self.has_id() {
return None;
}
@ -1185,10 +1185,12 @@ impl<'le> TElement for GeckoElement<'le> {
bindings::Gecko_AtomAttrValue(self.0, atom!("id").as_ptr())
};
// FIXME(emilio): Pretty sure the has_id flag is exact and we could
// assert here.
if ptr.is_null() {
None
} else {
Some(Atom::from(ptr))
Some(unsafe { WeakAtom::new(ptr) })
}
}