mirror of
https://github.com/servo/servo.git
synced 2025-08-06 14:10:11 +01:00
dom: Extract non-generic code from Root::new.
This commit is contained in:
parent
96698779cc
commit
1feeb23514
1 changed files with 11 additions and 6 deletions
|
@ -63,12 +63,17 @@ where
|
||||||
/// out references which cannot outlive this new `Root`.
|
/// out references which cannot outlive this new `Root`.
|
||||||
#[allow(unrooted_must_root)]
|
#[allow(unrooted_must_root)]
|
||||||
pub unsafe fn new(value: T) -> Self {
|
pub unsafe fn new(value: T) -> Self {
|
||||||
debug_assert!(thread_state::get().is_script());
|
unsafe fn add_to_root_list(object: *const dyn JSTraceable) -> *const RootCollection {
|
||||||
STACK_ROOTS.with(|ref root_list| {
|
debug_assert!(thread_state::get().is_script());
|
||||||
let root_list = &*root_list.get().unwrap();
|
STACK_ROOTS.with(|ref root_list| {
|
||||||
root_list.root(value.stable_trace_object());
|
let root_list = &*root_list.get().unwrap();
|
||||||
Root { value, root_list }
|
root_list.root(object);
|
||||||
})
|
root_list
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
let root_list = add_to_root_list(value.stable_trace_object());
|
||||||
|
Root { value, root_list }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue