Dedupliate syn (#33038)

This is the last step toward removing our use of `syn` version
1. It does three things:

1. Upgrades `async-recursion` to a newer version that uses `syn` 2.
2. Removes the use of `enum-iterator` that was only used to produce a
   trivial list of enum names. This reduces the number of crates we
   dependo on by 2.
3. Upgrades `media` to a version which no longer uses `syn` 1

Fixes #33034.

Signed-off-by: Martin Robinson <mrobinson@igalia.com>
This commit is contained in:
Martin Robinson 2024-08-13 23:21:47 +02:00 committed by GitHub
parent fb6b56cdda
commit 478d95d245
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 89 additions and 109 deletions

View file

@ -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 }

View file

@ -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);
}

View file

@ -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,
]
}
}