mirror of
https://github.com/servo/servo.git
synced 2025-08-03 20:50:07 +01:00
Auto merge of #29354 - ben-freist:dom-drop-impl-worklet, r=delan
#26488 Move worklet drop implementation into single droppable member Signed-off-by: Benjamin Freist <bfreist@soundhound.com> <!-- Please describe your changes on the following line: --> Hey @jdm , is this issue still free? I would like to start contributing to servo. This patch is straight from PR 28302, I thought it would be good to start with a small part, I hope that's ok. --- <!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `___` with appropriate data: --> - [x] `./mach build -d` does not report any errors - [x] `./mach test-tidy` does not report any errors - [ ] These changes fix #___ (GitHub issue number if applicable) <!-- Either: --> - [ ] There are tests for these changes OR - [x] These changes do not require tests because they will be checked by the compiler. <!-- Also, please make sure that "Allow edits from maintainers" checkbox is checked, so that we can help you if you get stuck somewhere along the way.--> <!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. -->
This commit is contained in:
commit
02de93dc38
1 changed files with 18 additions and 11 deletions
|
@ -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);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue