diff --git a/components/style/gecko_bindings/sugar/refptr.rs b/components/style/gecko_bindings/sugar/refptr.rs index 5019663a580..10c9e627699 100644 --- a/components/style/gecko_bindings/sugar/refptr.rs +++ b/components/style/gecko_bindings/sugar/refptr.rs @@ -4,6 +4,7 @@ //! A rust helper to ease the use of Gecko's refcounted types. +use Atom; use gecko_bindings::{structs, bindings}; use gecko_bindings::sugar::ownership::HasArcFFI; use servo_arc::Arc; @@ -320,3 +321,17 @@ impl_threadsafe_refcount!( bindings::Gecko_AddRefSheetLoadDataHolderArbitraryThread, bindings::Gecko_ReleaseSheetLoadDataHolderArbitraryThread ); + +#[inline] +unsafe fn addref_atom(atom: *mut structs::nsAtom) { + mem::forget(Atom::from_raw(atom)); +} +#[inline] +unsafe fn release_atom(atom: *mut structs::nsAtom) { + let _ = Atom::from_addrefed(atom); +} +impl_threadsafe_refcount!( + structs::nsAtom, + addref_atom, + release_atom +); diff --git a/components/style/properties/gecko.mako.rs b/components/style/properties/gecko.mako.rs index b4411e1ea8b..13d93b0a144 100644 --- a/components/style/properties/gecko.mako.rs +++ b/components/style/properties/gecko.mako.rs @@ -3274,10 +3274,7 @@ fn static_assert() { self.gecko.mTransitions.ensure_len(v.len()); self.gecko.mTransitionPropertyCount = v.len() as u32; for (servo, gecko) in v.zip(self.gecko.mTransitions.iter_mut()) { - if !gecko.mUnknownProperty.mRawPtr.is_null() { - unsafe { Atom::from_addrefed(gecko.mUnknownProperty.mRawPtr) }; - gecko.mUnknownProperty.mRawPtr = ptr::null_mut(); - } + unsafe { gecko.mUnknownProperty.clear() }; match servo { TransitionProperty::Unsupported(ident) => { @@ -3355,10 +3352,7 @@ fn static_assert() { for (index, transition) in self.gecko.mTransitions.iter_mut().enumerate().take(count as usize) { transition.mProperty = other.gecko.mTransitions[index].mProperty; - if !transition.mUnknownProperty.mRawPtr.is_null() { - unsafe { Atom::from_addrefed(transition.mUnknownProperty.mRawPtr) }; - transition.mUnknownProperty.mRawPtr = ptr::null_mut(); - } + unsafe { transition.mUnknownProperty.clear() }; if transition.mProperty == eCSSProperty_UNKNOWN || transition.mProperty == eCSSPropertyExtra_variable { let atom = other.gecko.mTransitions[index].mUnknownProperty.mRawPtr;