diff options
author | Benjamin Freist <bfreist@soundhound.com> | 2023-02-13 20:23:34 +0100 |
---|---|---|
committer | Benjamin Freist <bfreist@soundhound.com> | 2023-02-13 20:23:34 +0100 |
commit | 10ef6cdb3810ac73fb0edd8d9a6deba4e0e1efca (patch) | |
tree | abc9ff7d72a027ab052aca05b22259e8db943015 /components/script/dom/worklet.rs | |
parent | aa2e1433d28158eb06e6a8a9b09b551437c4b55f (diff) | |
download | servo-10ef6cdb3810ac73fb0edd8d9a6deba4e0e1efca.tar.gz servo-10ef6cdb3810ac73fb0edd8d9a6deba4e0e1efca.zip |
26488 Move worklet drop implementation into single droppable member
Signed-off-by: Benjamin Freist <bfreist@soundhound.com>
Diffstat (limited to 'components/script/dom/worklet.rs')
-rw-r--r-- | components/script/dom/worklet.rs | 29 |
1 files changed, 18 insertions, 11 deletions
diff --git a/components/script/dom/worklet.rs b/components/script/dom/worklet.rs index 46930bbf651..d472696325a 100644 --- a/components/script/dom/worklet.rs +++ b/components/script/dom/worklet.rs @@ -70,13 +70,25 @@ use uuid::Uuid; const WORKLET_THREAD_POOL_SIZE: u32 = 3; const MIN_GC_THRESHOLD: u32 = 1_000_000; +#[derive(JSTraceable, MallocSizeOf)] +struct DroppableField { + worklet_id: WorkletId, +} + +impl Drop for DroppableField { + fn drop(&mut self) { + let script_thread = ScriptThread::worklet_thread_pool(); + script_thread.exit_worklet(self.worklet_id); + } +} + #[dom_struct] /// <https://drafts.css-houdini.org/worklets/#worklet> pub struct Worklet { reflector: Reflector, window: Dom<Window>, - worklet_id: WorkletId, global_type: WorkletGlobalScopeType, + droppable_field: DroppableField, } impl Worklet { @@ -84,8 +96,10 @@ impl Worklet { Worklet { reflector: Reflector::new(), window: Dom::from_ref(window), - worklet_id: WorkletId::new(), global_type: global_type, + droppable_field: DroppableField { + worklet_id: WorkletId::new(), + }, } } @@ -98,7 +112,7 @@ impl Worklet { } pub fn worklet_id(&self) -> WorkletId { - self.worklet_id + self.droppable_field.worklet_id } #[allow(dead_code)] @@ -138,7 +152,7 @@ impl WorkletMethods for Worklet { pool.fetch_and_invoke_a_worklet_script( global.pipeline_id(), - self.worklet_id, + self.droppable_field.worklet_id, self.global_type, self.window.origin().immutable().clone(), global.api_base_url(), @@ -154,13 +168,6 @@ impl WorkletMethods for Worklet { } } -impl Drop for Worklet { - fn drop(&mut self) { - let script_thread = ScriptThread::worklet_thread_pool(); - script_thread.exit_worklet(self.worklet_id); - } -} - /// A guid for worklets. #[derive(Clone, Copy, Debug, Eq, Hash, JSTraceable, PartialEq)] pub struct WorkletId(Uuid); |