aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJosh Matthews <josh@joshmatthews.net>2020-06-02 15:34:50 -0400
committerJosh Matthews <josh@joshmatthews.net>2020-06-02 15:36:54 -0400
commit1feeb23514118926098f6fab219f38fc22e8f9d7 (patch)
treedd4d94160507b56dc213c4134a0e72255de34265
parent96698779ccdddcf87175db46c379a380317ad48a (diff)
downloadservo-1feeb23514118926098f6fab219f38fc22e8f9d7.tar.gz
servo-1feeb23514118926098f6fab219f38fc22e8f9d7.zip
dom: Extract non-generic code from Root::new.
-rw-r--r--components/script/dom/bindings/root.rs17
1 files changed, 11 insertions, 6 deletions
diff --git a/components/script/dom/bindings/root.rs b/components/script/dom/bindings/root.rs
index 59f9b964564..36bc2296ee5 100644
--- a/components/script/dom/bindings/root.rs
+++ b/components/script/dom/bindings/root.rs
@@ -63,12 +63,17 @@ where
/// out references which cannot outlive this new `Root`.
#[allow(unrooted_must_root)]
pub unsafe fn new(value: T) -> Self {
- debug_assert!(thread_state::get().is_script());
- STACK_ROOTS.with(|ref root_list| {
- let root_list = &*root_list.get().unwrap();
- root_list.root(value.stable_trace_object());
- Root { value, root_list }
- })
+ unsafe fn add_to_root_list(object: *const dyn JSTraceable) -> *const RootCollection {
+ debug_assert!(thread_state::get().is_script());
+ STACK_ROOTS.with(|ref root_list| {
+ let root_list = &*root_list.get().unwrap();
+ root_list.root(object);
+ root_list
+ })
+ }
+
+ let root_list = add_to_root_list(value.stable_trace_object());
+ Root { value, root_list }
}
}