mirror of
https://github.com/servo/servo.git
synced 2025-08-03 04:30:10 +01:00
Removed JS::root Fixes #8251
This commit is contained in:
parent
521a87180a
commit
d8ef3809a6
25 changed files with 98 additions and 126 deletions
|
@ -230,8 +230,8 @@ impl GlobalField {
|
|||
/// Create a stack-bounded root for this reference.
|
||||
pub fn root(&self) -> GlobalRoot {
|
||||
match *self {
|
||||
GlobalField::Window(ref window) => GlobalRoot::Window(window.root()),
|
||||
GlobalField::Worker(ref worker) => GlobalRoot::Worker(worker.root()),
|
||||
GlobalField::Window(ref window) => GlobalRoot::Window(Root::from_ref(window)),
|
||||
GlobalField::Worker(ref worker) => GlobalRoot::Worker(Root::from_ref(worker)),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -73,10 +73,6 @@ impl<T> JS<T> {
|
|||
}
|
||||
|
||||
impl<T: Reflectable> JS<T> {
|
||||
/// Root this JS-owned value to prevent its collection as garbage.
|
||||
pub fn root(&self) -> Root<T> {
|
||||
Root::new(self.ptr)
|
||||
}
|
||||
/// Create a JS<T> from a Root<T>
|
||||
/// XXX Not a great API. Should be a call on Root<T> instead
|
||||
#[allow(unrooted_must_root)]
|
||||
|
@ -291,7 +287,7 @@ impl<T: Reflectable> MutHeap<JS<T>> {
|
|||
pub fn get(&self) -> Root<T> {
|
||||
debug_assert!(task_state::get().is_script());
|
||||
unsafe {
|
||||
ptr::read(self.val.get()).root()
|
||||
Root::from_ref(&*ptr::read(self.val.get()))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -369,7 +365,7 @@ impl<T: Reflectable> MutNullableHeap<JS<T>> {
|
|||
pub fn get(&self) -> Option<Root<T>> {
|
||||
debug_assert!(task_state::get().is_script());
|
||||
unsafe {
|
||||
ptr::read(self.ptr.get()).map(|o| o.root())
|
||||
ptr::read(self.ptr.get()).map(|o| Root::from_ref(&*o))
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue