mirror of
https://github.com/servo/servo.git
synced 2025-08-15 10:25:32 +01:00
stylo: Store servo computed values for animation properties
MozReview-Commit-ID: IoQLN5tdIBw
This commit is contained in:
parent
f6940f686c
commit
d87b710fdd
7 changed files with 275 additions and 22 deletions
|
@ -5,10 +5,12 @@
|
|||
//! A rust helper to ease the use of Gecko's refcounted types.
|
||||
|
||||
use gecko_bindings::structs;
|
||||
use gecko_bindings::sugar::ownership::HasArcFFI;
|
||||
use heapsize::HeapSizeOf;
|
||||
use std::{mem, ptr};
|
||||
use std::marker::PhantomData;
|
||||
use std::ops::{Deref, DerefMut};
|
||||
use std::sync::Arc;
|
||||
|
||||
/// Trait for all objects that have Addref() and Release
|
||||
/// methods and can be placed inside RefPtr<T>
|
||||
|
@ -196,6 +198,14 @@ impl<T: RefCounted> structs::RefPtr<T> {
|
|||
}
|
||||
}
|
||||
|
||||
impl<T> structs::RefPtr<T> {
|
||||
/// Sets the contents to an Arc<T>
|
||||
/// will leak existing contents
|
||||
pub fn set_arc_leaky<U>(&mut self, other: Arc<U>) where U: HasArcFFI<FFIType = T> {
|
||||
*self = unsafe { mem::transmute(other) }; // Arc::into_raw is unstable :(
|
||||
}
|
||||
}
|
||||
|
||||
impl<T: RefCounted> Drop for RefPtr<T> {
|
||||
fn drop(&mut self) {
|
||||
unsafe { self.release() }
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue