Auto merge of #16269 - heycam:atom-already-addrefed, r=upsuper

Add an Atom::from_addrefed function.

<!-- Reviewable:start -->
This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/16269)
<!-- Reviewable:end -->
This commit is contained in:
bors-servo 2017-04-05 05:10:07 -05:00 committed by GitHub
commit a55cb8425d
2 changed files with 11 additions and 1 deletions

View file

@ -197,6 +197,16 @@ impl Atom {
"Called from_static for a non-static atom!");
atom
}
/// Creates an atom from a dynamic atom pointer that has already had AddRef
/// called on it.
#[inline]
pub unsafe fn from_addrefed(ptr: *mut nsIAtom) -> Self {
debug_assert!(!ptr.is_null());
unsafe {
Atom(WeakAtom::new(ptr))
}
}
}
impl Hash for Atom {