diff options
Diffstat (limited to 'components/script')
-rw-r--r-- | components/script/Cargo.toml | 1 | ||||
-rw-r--r-- | components/script/dom/window.rs | 4 | ||||
-rw-r--r-- | components/script/task_source/mod.rs | 32 |
3 files changed, 25 insertions, 12 deletions
diff --git a/components/script/Cargo.toml b/components/script/Cargo.toml index f21a9760b56..d30147adea5 100644 --- a/components/script/Cargo.toml +++ b/components/script/Cargo.toml @@ -49,7 +49,6 @@ dom_struct = { path = "../dom_struct" } domobject_derive = { path = "../domobject_derive" } embedder_traits = { workspace = true } encoding_rs = { workspace = true } -enum-iterator = "0.3" euclid = { workspace = true } fnv = { workspace = true } fxhash = { workspace = true } diff --git a/components/script/dom/window.rs b/components/script/dom/window.rs index a9d3dd3c16b..15a5b15c6fe 100644 --- a/components/script/dom/window.rs +++ b/components/script/dom/window.rs @@ -413,7 +413,7 @@ impl Window { pub fn ignore_all_tasks(&self) { let mut ignore_flags = self.task_manager.task_cancellers.borrow_mut(); for task_source_name in TaskSourceName::all() { - let flag = ignore_flags.entry(task_source_name).or_default(); + let flag = ignore_flags.entry(*task_source_name).or_default(); flag.store(true, Ordering::SeqCst); } } @@ -1646,7 +1646,7 @@ impl Window { pub fn cancel_all_tasks(&self) { let mut ignore_flags = self.task_manager.task_cancellers.borrow_mut(); for task_source_name in TaskSourceName::all() { - let flag = ignore_flags.entry(task_source_name).or_default(); + let flag = ignore_flags.entry(*task_source_name).or_default(); let cancelled = std::mem::take(&mut *flag); cancelled.store(true, Ordering::SeqCst); } diff --git a/components/script/task_source/mod.rs b/components/script/task_source/mod.rs index 5186b319ba7..beddc9495c6 100644 --- a/components/script/task_source/mod.rs +++ b/components/script/task_source/mod.rs @@ -18,16 +18,16 @@ pub mod websocket; use std::result::Result; -use enum_iterator::IntoEnumIterator; - use crate::dom::globalscope::GlobalScope; use crate::task::{TaskCanceller, TaskOnce}; -// The names of all task sources, used to differentiate TaskCancellers. -// Note: When adding a task source, update this enum. -// Note: The HistoryTraversalTaskSource is not part of this, -// because it doesn't implement TaskSource. -#[derive(Clone, Eq, Hash, IntoEnumIterator, JSTraceable, PartialEq)] +/// The names of all task sources, used to differentiate TaskCancellers. Note: When adding a task +/// source, update this enum. Note: The HistoryTraversalTaskSource is not part of this, because it +/// doesn't implement TaskSource. +/// +/// Note: When adding or removing a [`TaskSourceName`], be sure to also update the return value of +/// [`TaskSourceName::all`]. +#[derive(Clone, Copy, Eq, Hash, JSTraceable, PartialEq)] pub enum TaskSourceName { DOMManipulation, FileReading, @@ -47,8 +47,22 @@ pub enum TaskSourceName { } impl TaskSourceName { - pub fn all() -> Vec<TaskSourceName> { - TaskSourceName::into_enum_iter().collect() + pub fn all() -> &'static [TaskSourceName] { + &[ + TaskSourceName::DOMManipulation, + TaskSourceName::FileReading, + TaskSourceName::HistoryTraversal, + TaskSourceName::Networking, + TaskSourceName::PerformanceTimeline, + TaskSourceName::PortMessage, + TaskSourceName::UserInteraction, + TaskSourceName::RemoteEvent, + TaskSourceName::Rendering, + TaskSourceName::MediaElement, + TaskSourceName::Websocket, + TaskSourceName::Timer, + TaskSourceName::Gamepad, + ] } } |