mirror of
https://github.com/servo/servo.git
synced 2025-08-05 13:40:08 +01:00
style: Make clearing atoms slightly more ergonomic.
I prefer to do it this way because Atom has inline paths for static atoms and such. Bug: 1466609 Reviewed-by: xidorn MozReview-Commit-ID: CFsBHl80KDY
This commit is contained in:
parent
d461a7ddbe
commit
63ca2a803d
2 changed files with 17 additions and 8 deletions
|
@ -4,6 +4,7 @@
|
||||||
|
|
||||||
//! A rust helper to ease the use of Gecko's refcounted types.
|
//! A rust helper to ease the use of Gecko's refcounted types.
|
||||||
|
|
||||||
|
use Atom;
|
||||||
use gecko_bindings::{structs, bindings};
|
use gecko_bindings::{structs, bindings};
|
||||||
use gecko_bindings::sugar::ownership::HasArcFFI;
|
use gecko_bindings::sugar::ownership::HasArcFFI;
|
||||||
use servo_arc::Arc;
|
use servo_arc::Arc;
|
||||||
|
@ -320,3 +321,17 @@ impl_threadsafe_refcount!(
|
||||||
bindings::Gecko_AddRefSheetLoadDataHolderArbitraryThread,
|
bindings::Gecko_AddRefSheetLoadDataHolderArbitraryThread,
|
||||||
bindings::Gecko_ReleaseSheetLoadDataHolderArbitraryThread
|
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
|
||||||
|
);
|
||||||
|
|
|
@ -3274,10 +3274,7 @@ fn static_assert() {
|
||||||
self.gecko.mTransitions.ensure_len(v.len());
|
self.gecko.mTransitions.ensure_len(v.len());
|
||||||
self.gecko.mTransitionPropertyCount = v.len() as u32;
|
self.gecko.mTransitionPropertyCount = v.len() as u32;
|
||||||
for (servo, gecko) in v.zip(self.gecko.mTransitions.iter_mut()) {
|
for (servo, gecko) in v.zip(self.gecko.mTransitions.iter_mut()) {
|
||||||
if !gecko.mUnknownProperty.mRawPtr.is_null() {
|
unsafe { gecko.mUnknownProperty.clear() };
|
||||||
unsafe { Atom::from_addrefed(gecko.mUnknownProperty.mRawPtr) };
|
|
||||||
gecko.mUnknownProperty.mRawPtr = ptr::null_mut();
|
|
||||||
}
|
|
||||||
|
|
||||||
match servo {
|
match servo {
|
||||||
TransitionProperty::Unsupported(ident) => {
|
TransitionProperty::Unsupported(ident) => {
|
||||||
|
@ -3355,10 +3352,7 @@ fn static_assert() {
|
||||||
|
|
||||||
for (index, transition) in self.gecko.mTransitions.iter_mut().enumerate().take(count as usize) {
|
for (index, transition) in self.gecko.mTransitions.iter_mut().enumerate().take(count as usize) {
|
||||||
transition.mProperty = other.gecko.mTransitions[index].mProperty;
|
transition.mProperty = other.gecko.mTransitions[index].mProperty;
|
||||||
if !transition.mUnknownProperty.mRawPtr.is_null() {
|
unsafe { transition.mUnknownProperty.clear() };
|
||||||
unsafe { Atom::from_addrefed(transition.mUnknownProperty.mRawPtr) };
|
|
||||||
transition.mUnknownProperty.mRawPtr = ptr::null_mut();
|
|
||||||
}
|
|
||||||
if transition.mProperty == eCSSProperty_UNKNOWN ||
|
if transition.mProperty == eCSSProperty_UNKNOWN ||
|
||||||
transition.mProperty == eCSSPropertyExtra_variable {
|
transition.mProperty == eCSSPropertyExtra_variable {
|
||||||
let atom = other.gecko.mTransitions[index].mUnknownProperty.mRawPtr;
|
let atom = other.gecko.mTransitions[index].mUnknownProperty.mRawPtr;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue