mirror of
https://github.com/servo/servo.git
synced 2025-08-03 04:30:10 +01:00
Remove unrooted() methods
This commit is contained in:
parent
af21229c0e
commit
2770886196
3 changed files with 10 additions and 33 deletions
|
@ -174,10 +174,6 @@ impl<T: Reflectable> Temporary<T> {
|
|||
pub fn from_rooted<'a>(root: JSRef<'a, T>) -> Temporary<T> {
|
||||
Temporary::new(JS::from_rooted(root))
|
||||
}
|
||||
|
||||
unsafe fn inner(&self) -> JS<T> {
|
||||
self.inner.clone()
|
||||
}
|
||||
}
|
||||
|
||||
impl<T: Reflectable> Rootable<T> for Temporary<T> {
|
||||
|
@ -406,7 +402,7 @@ impl<T: Reflectable> JS<T> {
|
|||
/// are reachable in the GC graph, so this unrooted value becomes
|
||||
/// transitively rooted for the lifetime of its new owner.
|
||||
pub fn assign(&mut self, val: Temporary<T>) {
|
||||
*self = unsafe { val.inner() };
|
||||
*self = val.inner.clone();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -461,13 +457,15 @@ impl<T> Assignable<T> for JS<T> {
|
|||
|
||||
impl<'a, T: Reflectable> Assignable<T> for JSRef<'a, T> {
|
||||
unsafe fn get_js(&self) -> JS<T> {
|
||||
self.unrooted()
|
||||
JS {
|
||||
ptr: self.ptr
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl<T: Reflectable> Assignable<T> for Temporary<T> {
|
||||
unsafe fn get_js(&self) -> JS<T> {
|
||||
self.inner()
|
||||
self.inner.clone()
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -484,18 +482,6 @@ impl<T: Reflectable, U: Rootable<T>> OptionalRootable<T> for Option<U> {
|
|||
}
|
||||
}
|
||||
|
||||
/// Return an unrooted type for storing in optional DOM fields
|
||||
pub trait OptionalUnrootable<T> {
|
||||
/// Returns a `JS<T>` for the inner value, if it exists.
|
||||
fn unrooted(&self) -> Option<JS<T>>;
|
||||
}
|
||||
|
||||
impl<'a, T: Reflectable> OptionalUnrootable<T> for Option<JSRef<'a, T>> {
|
||||
fn unrooted(&self) -> Option<JS<T>> {
|
||||
self.as_ref().map(|inner| JS::from_rooted(*inner))
|
||||
}
|
||||
}
|
||||
|
||||
/// Root a rootable `Option<Option>` type (used for `Option<Option<JS<T>>>`)
|
||||
pub trait OptionalOptionalRootable<T> {
|
||||
/// Root the inner value, if it exists.
|
||||
|
@ -692,15 +678,6 @@ impl<'a, 'b, T> PartialEq<JSRef<'b, T>> for JSRef<'a, T> {
|
|||
}
|
||||
}
|
||||
|
||||
impl<'a,T> JSRef<'a,T> {
|
||||
/// Return an unrooted `JS<T>` for the inner pointer.
|
||||
pub fn unrooted(&self) -> JS<T> {
|
||||
JS {
|
||||
ptr: self.ptr
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a, T: Reflectable> JSRef<'a, T> {
|
||||
/// Returns the inner pointer directly.
|
||||
pub fn extended_deref(self) -> &'a T {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue