aboutsummaryrefslogtreecommitdiffstats
path: root/components/style/gecko_string_cache/mod.rs
diff options
context:
space:
mode:
Diffstat (limited to 'components/style/gecko_string_cache/mod.rs')
-rw-r--r--components/style/gecko_string_cache/mod.rs36
1 files changed, 17 insertions, 19 deletions
diff --git a/components/style/gecko_string_cache/mod.rs b/components/style/gecko_string_cache/mod.rs
index fa89f5eab48..08933c053ff 100644
--- a/components/style/gecko_string_cache/mod.rs
+++ b/components/style/gecko_string_cache/mod.rs
@@ -10,7 +10,7 @@ use gecko_bindings::bindings::Gecko_AddRefAtom;
use gecko_bindings::bindings::Gecko_Atomize;
use gecko_bindings::bindings::Gecko_Atomize16;
use gecko_bindings::bindings::Gecko_ReleaseAtom;
-use gecko_bindings::structs::nsIAtom;
+use gecko_bindings::structs::{already_AddRefed, nsIAtom};
use nsstring::nsAString;
use precomputed_hash::PrecomputedHash;
use std::ascii::AsciiExt;
@@ -219,24 +219,6 @@ impl 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))
- }
- }
-
- /// Convert this atom into an addrefed nsIAtom pointer.
- #[inline]
- pub fn into_addrefed(self) -> *mut nsIAtom {
- let ptr = self.as_ptr();
- mem::forget(self);
- ptr
- }
-
/// Return whether two atoms are ASCII-case-insensitive matches
pub fn eq_ignore_ascii_case(&self, other: &Self) -> bool {
let a = self.as_slice();
@@ -358,3 +340,19 @@ impl From<*mut nsIAtom> for Atom {
}
}
}
+
+impl From<already_AddRefed<nsIAtom>> for Atom {
+ #[inline]
+ fn from(ptr: already_AddRefed<nsIAtom>) -> Atom {
+ unsafe { Atom(WeakAtom::new(ptr.take())) }
+ }
+}
+
+impl From<Atom> for already_AddRefed<nsIAtom> {
+ #[inline]
+ fn from(atom: Atom) -> already_AddRefed<nsIAtom> {
+ let ptr = atom.as_ptr();
+ mem::forget(atom);
+ unsafe { already_AddRefed::new_unchecked(ptr) }
+ }
+}