mirror of
https://github.com/servo/servo.git
synced 2025-07-23 15:23:42 +01:00
script: Eliminate code duplication in the task queue (#34798)
Instead of creating a type for each `TaskSource` variety have each `TaskSource` hold the same kind of sender (this was inconsistent before, but each sender was effectively the same trait object), a pipeline, and a `TaskSourceName`. This elminates the need to reimplement the same queuing code for every task source. In addition, have workers hold their own `TaskManager`. This allows just exposing the manager on the `GlobalScope`. Currently the `TaskCanceller` is different, but this will also be eliminated in a followup change. This is a the first step toward having a shared set of `Sender`s on `GlobalScope`. Signed-off-by: Martin Robinson <mrobinson@igalia.com>
This commit is contained in:
parent
deb819f233
commit
77cfca65c4
67 changed files with 432 additions and 1200 deletions
|
@ -113,6 +113,7 @@ impl Formattable for ProfilerCategory {
|
||||||
ProfilerCategory::ScriptParseXML => "Script Parse XML",
|
ProfilerCategory::ScriptParseXML => "Script Parse XML",
|
||||||
ProfilerCategory::ScriptPlannedNavigation => "Script Planned Navigation",
|
ProfilerCategory::ScriptPlannedNavigation => "Script Planned Navigation",
|
||||||
ProfilerCategory::ScriptPortMessage => "Script Port Message",
|
ProfilerCategory::ScriptPortMessage => "Script Port Message",
|
||||||
|
ProfilerCategory::ScriptRendering => "Script Rendering",
|
||||||
ProfilerCategory::ScriptResize => "Script Resize",
|
ProfilerCategory::ScriptResize => "Script Resize",
|
||||||
ProfilerCategory::ScriptEvent => "Script Event",
|
ProfilerCategory::ScriptEvent => "Script Event",
|
||||||
ProfilerCategory::ScriptUpdateReplacedElement => "Script Update Replaced Element",
|
ProfilerCategory::ScriptUpdateReplacedElement => "Script Update Replaced Element",
|
||||||
|
|
|
@ -41,7 +41,6 @@ use crate::dom::urlsearchparams::URLSearchParams;
|
||||||
use crate::realms::{enter_realm, AlreadyInRealm, InRealm};
|
use crate::realms::{enter_realm, AlreadyInRealm, InRealm};
|
||||||
use crate::script_runtime::{CanGc, JSContext};
|
use crate::script_runtime::{CanGc, JSContext};
|
||||||
use crate::task::TaskCanceller;
|
use crate::task::TaskCanceller;
|
||||||
use crate::task_source::networking::NetworkingTaskSource;
|
|
||||||
use crate::task_source::{TaskSource, TaskSourceName};
|
use crate::task_source::{TaskSource, TaskSourceName};
|
||||||
|
|
||||||
/// The Dom object, or ReadableStream, that is the source of a body.
|
/// The Dom object, or ReadableStream, that is the source of a body.
|
||||||
|
@ -72,7 +71,7 @@ enum StopReading {
|
||||||
#[derive(Clone)]
|
#[derive(Clone)]
|
||||||
struct TransmitBodyConnectHandler {
|
struct TransmitBodyConnectHandler {
|
||||||
stream: Trusted<ReadableStream>,
|
stream: Trusted<ReadableStream>,
|
||||||
task_source: NetworkingTaskSource,
|
task_source: TaskSource,
|
||||||
canceller: TaskCanceller,
|
canceller: TaskCanceller,
|
||||||
bytes_sender: Option<IpcSender<BodyChunkResponse>>,
|
bytes_sender: Option<IpcSender<BodyChunkResponse>>,
|
||||||
control_sender: IpcSender<BodyChunkRequest>,
|
control_sender: IpcSender<BodyChunkRequest>,
|
||||||
|
@ -84,7 +83,7 @@ struct TransmitBodyConnectHandler {
|
||||||
impl TransmitBodyConnectHandler {
|
impl TransmitBodyConnectHandler {
|
||||||
pub fn new(
|
pub fn new(
|
||||||
stream: Trusted<ReadableStream>,
|
stream: Trusted<ReadableStream>,
|
||||||
task_source: NetworkingTaskSource,
|
task_source: TaskSource,
|
||||||
canceller: TaskCanceller,
|
canceller: TaskCanceller,
|
||||||
control_sender: IpcSender<BodyChunkRequest>,
|
control_sender: IpcSender<BodyChunkRequest>,
|
||||||
in_memory: Option<Vec<u8>>,
|
in_memory: Option<Vec<u8>>,
|
||||||
|
@ -379,7 +378,7 @@ impl ExtractedBody {
|
||||||
let trusted_stream = Trusted::new(&*stream);
|
let trusted_stream = Trusted::new(&*stream);
|
||||||
|
|
||||||
let global = stream.global();
|
let global = stream.global();
|
||||||
let task_source = global.networking_task_source();
|
let task_source = global.task_manager().networking_task_source();
|
||||||
let canceller = global.task_canceller(TaskSourceName::Networking);
|
let canceller = global.task_canceller(TaskSourceName::Networking);
|
||||||
|
|
||||||
// In case of the data being in-memory, send everything in one chunk, by-passing SM.
|
// In case of the data being in-memory, send everything in one chunk, by-passing SM.
|
||||||
|
|
|
@ -35,7 +35,7 @@ impl ScriptChan for SendableWorkerScriptChan {
|
||||||
self.sender.send(msg).map_err(|_| ())
|
self.sender.send(msg).map_err(|_| ())
|
||||||
}
|
}
|
||||||
|
|
||||||
fn as_boxed(&self) -> Box<dyn ScriptChan + Send> {
|
fn as_boxed(&self) -> Box<dyn ScriptChan> {
|
||||||
Box::new(SendableWorkerScriptChan {
|
Box::new(SendableWorkerScriptChan {
|
||||||
sender: self.sender.clone(),
|
sender: self.sender.clone(),
|
||||||
worker: self.worker.clone(),
|
worker: self.worker.clone(),
|
||||||
|
@ -62,7 +62,7 @@ impl ScriptChan for WorkerThreadWorkerChan {
|
||||||
self.sender.send(msg).map_err(|_| ())
|
self.sender.send(msg).map_err(|_| ())
|
||||||
}
|
}
|
||||||
|
|
||||||
fn as_boxed(&self) -> Box<dyn ScriptChan + Send> {
|
fn as_boxed(&self) -> Box<dyn ScriptChan> {
|
||||||
Box::new(WorkerThreadWorkerChan {
|
Box::new(WorkerThreadWorkerChan {
|
||||||
sender: self.sender.clone(),
|
sender: self.sender.clone(),
|
||||||
worker: self.worker.clone(),
|
worker: self.worker.clone(),
|
||||||
|
|
|
@ -27,7 +27,6 @@ use crate::dom::bindings::reflector::reflect_dom_object_with_proto;
|
||||||
use crate::dom::bindings::root::DomRoot;
|
use crate::dom::bindings::root::DomRoot;
|
||||||
use crate::dom::window::Window;
|
use crate::dom::window::Window;
|
||||||
use crate::script_runtime::CanGc;
|
use crate::script_runtime::CanGc;
|
||||||
use crate::task_source::TaskSource;
|
|
||||||
|
|
||||||
#[dom_struct]
|
#[dom_struct]
|
||||||
pub struct AnalyserNode {
|
pub struct AnalyserNode {
|
||||||
|
|
|
@ -35,7 +35,6 @@ use crate::dom::promise::Promise;
|
||||||
use crate::dom::window::Window;
|
use crate::dom::window::Window;
|
||||||
use crate::realms::InRealm;
|
use crate::realms::InRealm;
|
||||||
use crate::script_runtime::CanGc;
|
use crate::script_runtime::CanGc;
|
||||||
use crate::task_source::TaskSource;
|
|
||||||
|
|
||||||
#[dom_struct]
|
#[dom_struct]
|
||||||
pub struct AudioContext {
|
pub struct AudioContext {
|
||||||
|
|
|
@ -17,7 +17,6 @@ use crate::dom::bindings::inheritance::Castable;
|
||||||
use crate::dom::bindings::num::Finite;
|
use crate::dom::bindings::num::Finite;
|
||||||
use crate::dom::bindings::refcounted::Trusted;
|
use crate::dom::bindings::refcounted::Trusted;
|
||||||
use crate::dom::bindings::reflector::DomObject;
|
use crate::dom::bindings::reflector::DomObject;
|
||||||
use crate::task_source::TaskSource;
|
|
||||||
|
|
||||||
#[dom_struct]
|
#[dom_struct]
|
||||||
pub struct AudioScheduledSourceNode {
|
pub struct AudioScheduledSourceNode {
|
||||||
|
|
|
@ -16,7 +16,6 @@ use crate::dom::eventtarget::EventTarget;
|
||||||
use crate::dom::htmlmediaelement::HTMLMediaElement;
|
use crate::dom::htmlmediaelement::HTMLMediaElement;
|
||||||
use crate::dom::window::Window;
|
use crate::dom::window::Window;
|
||||||
use crate::script_runtime::CanGc;
|
use crate::script_runtime::CanGc;
|
||||||
use crate::task_source::TaskSource;
|
|
||||||
|
|
||||||
#[dom_struct]
|
#[dom_struct]
|
||||||
pub struct AudioTrackList {
|
pub struct AudioTrackList {
|
||||||
|
|
|
@ -68,7 +68,6 @@ use crate::dom::stereopannernode::StereoPannerNode;
|
||||||
use crate::dom::window::Window;
|
use crate::dom::window::Window;
|
||||||
use crate::realms::InRealm;
|
use crate::realms::InRealm;
|
||||||
use crate::script_runtime::CanGc;
|
use crate::script_runtime::CanGc;
|
||||||
use crate::task_source::TaskSource;
|
|
||||||
|
|
||||||
#[allow(dead_code)]
|
#[allow(dead_code)]
|
||||||
pub enum BaseAudioContextOptions {
|
pub enum BaseAudioContextOptions {
|
||||||
|
|
|
@ -244,7 +244,7 @@ pub fn response_async<T: AsyncBluetoothListener + DomObject + 'static>(
|
||||||
receiver: &T,
|
receiver: &T,
|
||||||
) -> IpcSender<BluetoothResponseResult> {
|
) -> IpcSender<BluetoothResponseResult> {
|
||||||
let (action_sender, action_receiver) = ipc::channel().unwrap();
|
let (action_sender, action_receiver) = ipc::channel().unwrap();
|
||||||
let task_source = receiver.global().networking_task_source();
|
let task_source = receiver.global().task_manager().networking_task_source();
|
||||||
let context = Arc::new(Mutex::new(BluetoothContext {
|
let context = Arc::new(Mutex::new(BluetoothContext {
|
||||||
promise: Some(TrustedPromise::new(promise.clone())),
|
promise: Some(TrustedPromise::new(promise.clone())),
|
||||||
receiver: Trusted::new(receiver),
|
receiver: Trusted::new(receiver),
|
||||||
|
|
|
@ -60,8 +60,7 @@ use crate::script_runtime::{
|
||||||
ThreadSafeJSContext,
|
ThreadSafeJSContext,
|
||||||
};
|
};
|
||||||
use crate::task_queue::{QueuedTask, QueuedTaskConversion, TaskQueue};
|
use crate::task_queue::{QueuedTask, QueuedTaskConversion, TaskQueue};
|
||||||
use crate::task_source::networking::NetworkingTaskSource;
|
use crate::task_source::{TaskSource, TaskSourceName};
|
||||||
use crate::task_source::TaskSourceName;
|
|
||||||
|
|
||||||
/// Set the `worker` field of a related DedicatedWorkerGlobalScope object to a particular
|
/// Set the `worker` field of a related DedicatedWorkerGlobalScope object to a particular
|
||||||
/// value for the duration of this object's lifetime. This ensures that the related Worker
|
/// value for the duration of this object's lifetime. This ensures that the related Worker
|
||||||
|
@ -192,7 +191,7 @@ pub struct DedicatedWorkerGlobalScope {
|
||||||
worker: DomRefCell<Option<TrustedWorkerAddress>>,
|
worker: DomRefCell<Option<TrustedWorkerAddress>>,
|
||||||
#[ignore_malloc_size_of = "Can't measure trait objects"]
|
#[ignore_malloc_size_of = "Can't measure trait objects"]
|
||||||
/// Sender to the parent thread.
|
/// Sender to the parent thread.
|
||||||
parent_sender: Box<dyn ScriptChan + Send>,
|
parent_sender: Box<dyn ScriptChan>,
|
||||||
#[ignore_malloc_size_of = "Arc"]
|
#[ignore_malloc_size_of = "Arc"]
|
||||||
#[no_trace]
|
#[no_trace]
|
||||||
image_cache: Arc<dyn ImageCache>,
|
image_cache: Arc<dyn ImageCache>,
|
||||||
|
@ -381,13 +380,14 @@ impl DedicatedWorkerGlobalScope {
|
||||||
.origin(origin);
|
.origin(origin);
|
||||||
|
|
||||||
let runtime = unsafe {
|
let runtime = unsafe {
|
||||||
let task_source = NetworkingTaskSource(
|
let task_source = TaskSource {
|
||||||
Box::new(WorkerThreadWorkerChan {
|
sender: Box::new(WorkerThreadWorkerChan {
|
||||||
sender: own_sender.clone(),
|
sender: own_sender.clone(),
|
||||||
worker: worker.clone(),
|
worker: worker.clone(),
|
||||||
}),
|
}),
|
||||||
pipeline_id,
|
pipeline_id,
|
||||||
);
|
name: TaskSourceName::Networking,
|
||||||
|
};
|
||||||
Runtime::new_with_parent(Some(parent), Some(task_source))
|
Runtime::new_with_parent(Some(parent), Some(task_source))
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -192,7 +192,7 @@ use crate::script_runtime::{CanGc, CommonScriptMsg, ScriptThreadEventCategory};
|
||||||
use crate::script_thread::{with_script_thread, ScriptThread};
|
use crate::script_thread::{with_script_thread, ScriptThread};
|
||||||
use crate::stylesheet_set::StylesheetSetRef;
|
use crate::stylesheet_set::StylesheetSetRef;
|
||||||
use crate::task::TaskBox;
|
use crate::task::TaskBox;
|
||||||
use crate::task_source::{TaskSource, TaskSourceName};
|
use crate::task_source::TaskSourceName;
|
||||||
use crate::timers::OneshotTimerCallback;
|
use crate::timers::OneshotTimerCallback;
|
||||||
|
|
||||||
/// The number of times we are allowed to see spurious `requestAnimationFrame()` calls before
|
/// The number of times we are allowed to see spurious `requestAnimationFrame()` calls before
|
||||||
|
|
|
@ -45,7 +45,7 @@ use crate::fetch::{create_a_potential_cors_request, FetchCanceller};
|
||||||
use crate::network_listener::{self, NetworkListener, PreInvoke, ResourceTimingListener};
|
use crate::network_listener::{self, NetworkListener, PreInvoke, ResourceTimingListener};
|
||||||
use crate::realms::enter_realm;
|
use crate::realms::enter_realm;
|
||||||
use crate::script_runtime::CanGc;
|
use crate::script_runtime::CanGc;
|
||||||
use crate::task_source::{TaskSource, TaskSourceName};
|
use crate::task_source::TaskSourceName;
|
||||||
use crate::timers::OneshotTimerCallback;
|
use crate::timers::OneshotTimerCallback;
|
||||||
|
|
||||||
const DEFAULT_RECONNECTION_TIME: Duration = Duration::from_millis(5000);
|
const DEFAULT_RECONNECTION_TIME: Duration = Duration::from_millis(5000);
|
||||||
|
@ -113,7 +113,7 @@ impl EventSourceContext {
|
||||||
let global = event_source.global();
|
let global = event_source.global();
|
||||||
let event_source = self.event_source.clone();
|
let event_source = self.event_source.clone();
|
||||||
// FIXME(nox): Why are errors silenced here?
|
// FIXME(nox): Why are errors silenced here?
|
||||||
let _ = global.remote_event_task_source().queue(
|
let _ = global.task_manager().remote_event_task_source().queue(
|
||||||
task!(announce_the_event_source_connection: move || {
|
task!(announce_the_event_source_connection: move || {
|
||||||
let event_source = event_source.root();
|
let event_source = event_source.root();
|
||||||
if event_source.ready_state.get() != ReadyState::Closed {
|
if event_source.ready_state.get() != ReadyState::Closed {
|
||||||
|
@ -146,7 +146,7 @@ impl EventSourceContext {
|
||||||
let action_sender = self.action_sender.clone();
|
let action_sender = self.action_sender.clone();
|
||||||
let global = event_source.global();
|
let global = event_source.global();
|
||||||
// FIXME(nox): Why are errors silenced here?
|
// FIXME(nox): Why are errors silenced here?
|
||||||
let _ = global.remote_event_task_source().queue(
|
let _ = global.task_manager().remote_event_task_source().queue(
|
||||||
task!(reestablish_the_event_source_onnection: move || {
|
task!(reestablish_the_event_source_onnection: move || {
|
||||||
let event_source = trusted_event_source.root();
|
let event_source = trusted_event_source.root();
|
||||||
|
|
||||||
|
@ -259,7 +259,7 @@ impl EventSourceContext {
|
||||||
let event_source = self.event_source.clone();
|
let event_source = self.event_source.clone();
|
||||||
let event = Trusted::new(&*event);
|
let event = Trusted::new(&*event);
|
||||||
// FIXME(nox): Why are errors silenced here?
|
// FIXME(nox): Why are errors silenced here?
|
||||||
let _ = global.remote_event_task_source().queue(
|
let _ = global.task_manager().remote_event_task_source().queue(
|
||||||
task!(dispatch_the_event_source_event: move || {
|
task!(dispatch_the_event_source_event: move || {
|
||||||
let event_source = event_source.root();
|
let event_source = event_source.root();
|
||||||
if event_source.ready_state.get() != ReadyState::Closed {
|
if event_source.ready_state.get() != ReadyState::Closed {
|
||||||
|
@ -500,7 +500,7 @@ impl EventSource {
|
||||||
let global = self.global();
|
let global = self.global();
|
||||||
let event_source = Trusted::new(self);
|
let event_source = Trusted::new(self);
|
||||||
// FIXME(nox): Why are errors silenced here?
|
// FIXME(nox): Why are errors silenced here?
|
||||||
let _ = global.remote_event_task_source().queue(
|
let _ = global.task_manager().remote_event_task_source().queue(
|
||||||
task!(fail_the_event_source_connection: move || {
|
task!(fail_the_event_source_connection: move || {
|
||||||
let event_source = event_source.root();
|
let event_source = event_source.root();
|
||||||
if event_source.ready_state.get() != ReadyState::Closed {
|
if event_source.ready_state.get() != ReadyState::Closed {
|
||||||
|
@ -605,7 +605,7 @@ impl EventSourceMethods<crate::DomTypeHolder> for EventSource {
|
||||||
};
|
};
|
||||||
let listener = NetworkListener {
|
let listener = NetworkListener {
|
||||||
context: Arc::new(Mutex::new(context)),
|
context: Arc::new(Mutex::new(context)),
|
||||||
task_source: global.networking_task_source(),
|
task_source: global.task_manager().networking_task_source(),
|
||||||
canceller: Some(global.task_canceller(TaskSourceName::Networking)),
|
canceller: Some(global.task_canceller(TaskSourceName::Networking)),
|
||||||
};
|
};
|
||||||
ROUTER.add_typed_route(
|
ROUTER.add_typed_route(
|
||||||
|
|
|
@ -36,9 +36,41 @@ use crate::dom::globalscope::GlobalScope;
|
||||||
use crate::dom::progressevent::ProgressEvent;
|
use crate::dom::progressevent::ProgressEvent;
|
||||||
use crate::realms::enter_realm;
|
use crate::realms::enter_realm;
|
||||||
use crate::script_runtime::{CanGc, JSContext};
|
use crate::script_runtime::{CanGc, JSContext};
|
||||||
use crate::task_source::file_reading::FileReadingTask;
|
use crate::task::TaskOnce;
|
||||||
use crate::task_source::{TaskSource, TaskSourceName};
|
use crate::task_source::TaskSourceName;
|
||||||
|
|
||||||
|
#[allow(dead_code)]
|
||||||
|
pub enum FileReadingTask {
|
||||||
|
ProcessRead(TrustedFileReader, GenerationId),
|
||||||
|
ProcessReadData(TrustedFileReader, GenerationId),
|
||||||
|
ProcessReadError(TrustedFileReader, GenerationId, DOMErrorName),
|
||||||
|
ProcessReadEOF(TrustedFileReader, GenerationId, ReadMetaData, Vec<u8>),
|
||||||
|
}
|
||||||
|
|
||||||
|
impl TaskOnce for FileReadingTask {
|
||||||
|
fn run_once(self) {
|
||||||
|
self.handle_task(CanGc::note());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl FileReadingTask {
|
||||||
|
pub fn handle_task(self, can_gc: CanGc) {
|
||||||
|
use self::FileReadingTask::*;
|
||||||
|
|
||||||
|
match self {
|
||||||
|
ProcessRead(reader, gen_id) => FileReader::process_read(reader, gen_id, can_gc),
|
||||||
|
ProcessReadData(reader, gen_id) => {
|
||||||
|
FileReader::process_read_data(reader, gen_id, can_gc)
|
||||||
|
},
|
||||||
|
ProcessReadError(reader, gen_id, error) => {
|
||||||
|
FileReader::process_read_error(reader, gen_id, error, can_gc)
|
||||||
|
},
|
||||||
|
ProcessReadEOF(reader, gen_id, metadata, blob_contents) => {
|
||||||
|
FileReader::process_read_eof(reader, gen_id, metadata, blob_contents, can_gc)
|
||||||
|
},
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
#[derive(Clone, Copy, JSTraceable, MallocSizeOf, PartialEq)]
|
#[derive(Clone, Copy, JSTraceable, MallocSizeOf, PartialEq)]
|
||||||
pub enum FileReaderFunction {
|
pub enum FileReaderFunction {
|
||||||
Text,
|
Text,
|
||||||
|
@ -472,7 +504,7 @@ impl FileReader {
|
||||||
let filereader = Trusted::new(self);
|
let filereader = Trusted::new(self);
|
||||||
let global = self.global();
|
let global = self.global();
|
||||||
let canceller = global.task_canceller(TaskSourceName::FileReading);
|
let canceller = global.task_canceller(TaskSourceName::FileReading);
|
||||||
let task_source = global.file_reading_task_source();
|
let task_source = global.task_manager().file_reading_task_source();
|
||||||
|
|
||||||
// Queue tasks as appropriate.
|
// Queue tasks as appropriate.
|
||||||
let task = FileReadingTask::ProcessRead(filereader.clone(), gen_id);
|
let task = FileReadingTask::ProcessRead(filereader.clone(), gen_id);
|
||||||
|
|
|
@ -28,12 +28,11 @@ use crate::dom::promise::Promise;
|
||||||
use crate::realms::InRealm;
|
use crate::realms::InRealm;
|
||||||
use crate::script_runtime::{CanGc, JSContext};
|
use crate::script_runtime::{CanGc, JSContext};
|
||||||
use crate::task::TaskCanceller;
|
use crate::task::TaskCanceller;
|
||||||
use crate::task_source::gamepad::GamepadTaskSource;
|
|
||||||
use crate::task_source::{TaskSource, TaskSourceName};
|
use crate::task_source::{TaskSource, TaskSourceName};
|
||||||
|
|
||||||
struct HapticEffectListener {
|
struct HapticEffectListener {
|
||||||
canceller: TaskCanceller,
|
canceller: TaskCanceller,
|
||||||
task_source: GamepadTaskSource,
|
task_source: TaskSource,
|
||||||
context: Trusted<GamepadHapticActuator>,
|
context: Trusted<GamepadHapticActuator>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -199,7 +198,7 @@ impl GamepadHapticActuatorMethods<crate::DomTypeHolder> for GamepadHapticActuato
|
||||||
|
|
||||||
if let Some(promise) = self.playing_effect_promise.borrow_mut().take() {
|
if let Some(promise) = self.playing_effect_promise.borrow_mut().take() {
|
||||||
let trusted_promise = TrustedPromise::new(promise);
|
let trusted_promise = TrustedPromise::new(promise);
|
||||||
let _ = self.global().gamepad_task_source().queue(
|
let _ = self.global().task_manager().gamepad_task_source().queue(
|
||||||
task!(preempt_promise: move || {
|
task!(preempt_promise: move || {
|
||||||
let promise = trusted_promise.root();
|
let promise = trusted_promise.root();
|
||||||
let message = DOMString::from("preempted");
|
let message = DOMString::from("preempted");
|
||||||
|
@ -221,7 +220,7 @@ impl GamepadHapticActuatorMethods<crate::DomTypeHolder> for GamepadHapticActuato
|
||||||
let (effect_complete_sender, effect_complete_receiver) =
|
let (effect_complete_sender, effect_complete_receiver) =
|
||||||
ipc::channel().expect("ipc channel failure");
|
ipc::channel().expect("ipc channel failure");
|
||||||
let (task_source, canceller) = (
|
let (task_source, canceller) = (
|
||||||
self.global().gamepad_task_source(),
|
self.global().task_manager().gamepad_task_source(),
|
||||||
self.global().task_canceller(TaskSourceName::Gamepad),
|
self.global().task_canceller(TaskSourceName::Gamepad),
|
||||||
);
|
);
|
||||||
let listener = HapticEffectListener {
|
let listener = HapticEffectListener {
|
||||||
|
@ -272,7 +271,7 @@ impl GamepadHapticActuatorMethods<crate::DomTypeHolder> for GamepadHapticActuato
|
||||||
|
|
||||||
if let Some(promise) = self.playing_effect_promise.borrow_mut().take() {
|
if let Some(promise) = self.playing_effect_promise.borrow_mut().take() {
|
||||||
let trusted_promise = TrustedPromise::new(promise);
|
let trusted_promise = TrustedPromise::new(promise);
|
||||||
let _ = self.global().gamepad_task_source().queue(
|
let _ = self.global().task_manager().gamepad_task_source().queue(
|
||||||
task!(preempt_promise: move || {
|
task!(preempt_promise: move || {
|
||||||
let promise = trusted_promise.root();
|
let promise = trusted_promise.root();
|
||||||
let message = DOMString::from("preempted");
|
let message = DOMString::from("preempted");
|
||||||
|
@ -290,7 +289,7 @@ impl GamepadHapticActuatorMethods<crate::DomTypeHolder> for GamepadHapticActuato
|
||||||
let (effect_stop_sender, effect_stop_receiver) =
|
let (effect_stop_sender, effect_stop_receiver) =
|
||||||
ipc::channel().expect("ipc channel failure");
|
ipc::channel().expect("ipc channel failure");
|
||||||
let (task_source, canceller) = (
|
let (task_source, canceller) = (
|
||||||
self.global().gamepad_task_source(),
|
self.global().task_manager().gamepad_task_source(),
|
||||||
self.global().task_canceller(TaskSourceName::Gamepad),
|
self.global().task_canceller(TaskSourceName::Gamepad),
|
||||||
);
|
);
|
||||||
let listener = HapticEffectListener {
|
let listener = HapticEffectListener {
|
||||||
|
@ -342,7 +341,7 @@ impl GamepadHapticActuator {
|
||||||
let trusted_promise = TrustedPromise::new(promise);
|
let trusted_promise = TrustedPromise::new(promise);
|
||||||
let sequence_id = self.sequence_id.get();
|
let sequence_id = self.sequence_id.get();
|
||||||
let reset_sequence_id = self.reset_sequence_id.get();
|
let reset_sequence_id = self.reset_sequence_id.get();
|
||||||
let _ = self.global().gamepad_task_source().queue(
|
let _ = self.global().task_manager().gamepad_task_source().queue(
|
||||||
task!(complete_promise: move || {
|
task!(complete_promise: move || {
|
||||||
if sequence_id != reset_sequence_id {
|
if sequence_id != reset_sequence_id {
|
||||||
warn!("Mismatched sequence/reset sequence ids: {} != {}", sequence_id, reset_sequence_id);
|
warn!("Mismatched sequence/reset sequence ids: {} != {}", sequence_id, reset_sequence_id);
|
||||||
|
@ -364,7 +363,7 @@ impl GamepadHapticActuator {
|
||||||
}
|
}
|
||||||
|
|
||||||
let this = Trusted::new(self);
|
let this = Trusted::new(self);
|
||||||
let _ = self.global().gamepad_task_source().queue(
|
let _ = self.global().task_manager().gamepad_task_source().queue(
|
||||||
task!(stop_playing_effect: move || {
|
task!(stop_playing_effect: move || {
|
||||||
let actuator = this.root();
|
let actuator = this.root();
|
||||||
let Some(promise) = actuator.playing_effect_promise.borrow_mut().take() else {
|
let Some(promise) = actuator.playing_effect_promise.borrow_mut().take() else {
|
||||||
|
|
|
@ -138,15 +138,7 @@ use crate::script_runtime::{
|
||||||
use crate::script_thread::{with_script_thread, ScriptThread};
|
use crate::script_thread::{with_script_thread, ScriptThread};
|
||||||
use crate::security_manager::CSPViolationReporter;
|
use crate::security_manager::CSPViolationReporter;
|
||||||
use crate::task::TaskCanceller;
|
use crate::task::TaskCanceller;
|
||||||
use crate::task_source::dom_manipulation::DOMManipulationTaskSource;
|
use crate::task_manager::TaskManager;
|
||||||
use crate::task_source::file_reading::FileReadingTaskSource;
|
|
||||||
use crate::task_source::gamepad::GamepadTaskSource;
|
|
||||||
use crate::task_source::networking::NetworkingTaskSource;
|
|
||||||
use crate::task_source::performance_timeline::PerformanceTimelineTaskSource;
|
|
||||||
use crate::task_source::port_message::PortMessageQueue;
|
|
||||||
use crate::task_source::remote_event::RemoteEventTaskSource;
|
|
||||||
use crate::task_source::timer::TimerTaskSource;
|
|
||||||
use crate::task_source::websocket::WebsocketTaskSource;
|
|
||||||
use crate::task_source::{TaskSource, TaskSourceName};
|
use crate::task_source::{TaskSource, TaskSourceName};
|
||||||
use crate::timers::{
|
use crate::timers::{
|
||||||
IsInterval, OneshotTimerCallback, OneshotTimerHandle, OneshotTimers, TimerCallback,
|
IsInterval, OneshotTimerCallback, OneshotTimerHandle, OneshotTimers, TimerCallback,
|
||||||
|
@ -383,14 +375,14 @@ pub struct GlobalScope {
|
||||||
/// A wrapper for glue-code between the ipc router and the event-loop.
|
/// A wrapper for glue-code between the ipc router and the event-loop.
|
||||||
struct MessageListener {
|
struct MessageListener {
|
||||||
canceller: TaskCanceller,
|
canceller: TaskCanceller,
|
||||||
task_source: PortMessageQueue,
|
task_source: TaskSource,
|
||||||
context: Trusted<GlobalScope>,
|
context: Trusted<GlobalScope>,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// A wrapper for broadcasts coming in over IPC, and the event-loop.
|
/// A wrapper for broadcasts coming in over IPC, and the event-loop.
|
||||||
struct BroadcastListener {
|
struct BroadcastListener {
|
||||||
canceller: TaskCanceller,
|
canceller: TaskCanceller,
|
||||||
task_source: DOMManipulationTaskSource,
|
task_source: TaskSource,
|
||||||
context: Trusted<GlobalScope>,
|
context: Trusted<GlobalScope>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -398,7 +390,7 @@ struct BroadcastListener {
|
||||||
#[derive(Clone)]
|
#[derive(Clone)]
|
||||||
pub(crate) struct TimerListener {
|
pub(crate) struct TimerListener {
|
||||||
canceller: TaskCanceller,
|
canceller: TaskCanceller,
|
||||||
task_source: TimerTaskSource,
|
task_source: TaskSource,
|
||||||
context: Trusted<GlobalScope>,
|
context: Trusted<GlobalScope>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -410,7 +402,7 @@ struct FileListener {
|
||||||
/// - Some(Empty) => Some(Receiving) => None
|
/// - Some(Empty) => Some(Receiving) => None
|
||||||
/// - Some(Empty) => None
|
/// - Some(Empty) => None
|
||||||
state: Option<FileListenerState>,
|
state: Option<FileListenerState>,
|
||||||
task_source: FileReadingTaskSource,
|
task_source: TaskSource,
|
||||||
task_canceller: TaskCanceller,
|
task_canceller: TaskCanceller,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -860,7 +852,7 @@ impl GlobalScope {
|
||||||
fn timers(&self) -> &OneshotTimers {
|
fn timers(&self) -> &OneshotTimers {
|
||||||
self.timers.get_or_init(|| {
|
self.timers.get_or_init(|| {
|
||||||
let (task_source, canceller) = (
|
let (task_source, canceller) = (
|
||||||
self.timer_task_source(),
|
self.task_manager().timer_task_source(),
|
||||||
self.task_canceller(TaskSourceName::Timer),
|
self.task_canceller(TaskSourceName::Timer),
|
||||||
);
|
);
|
||||||
OneshotTimers::new(
|
OneshotTimers::new(
|
||||||
|
@ -1102,7 +1094,7 @@ impl GlobalScope {
|
||||||
for task in message_buffer {
|
for task in message_buffer {
|
||||||
let port_id = *port_id;
|
let port_id = *port_id;
|
||||||
let this = Trusted::new(self);
|
let this = Trusted::new(self);
|
||||||
let _ = self.port_message_queue().queue(
|
let _ = self.task_manager().port_message_queue().queue(
|
||||||
task!(process_pending_port_messages: move || {
|
task!(process_pending_port_messages: move || {
|
||||||
let target_global = this.root();
|
let target_global = this.root();
|
||||||
target_global.route_task_to_port(port_id, task, CanGc::note());
|
target_global.route_task_to_port(port_id, task, CanGc::note());
|
||||||
|
@ -1156,7 +1148,7 @@ impl GlobalScope {
|
||||||
if let Some(entangled_id) = entangled_port {
|
if let Some(entangled_id) = entangled_port {
|
||||||
// Step 7
|
// Step 7
|
||||||
let this = Trusted::new(self);
|
let this = Trusted::new(self);
|
||||||
let _ = self.port_message_queue().queue(
|
let _ = self.task_manager().port_message_queue().queue(
|
||||||
task!(post_message: move || {
|
task!(post_message: move || {
|
||||||
let global = this.root();
|
let global = this.root();
|
||||||
// Note: we do this in a task, as this will ensure the global and constellation
|
// Note: we do this in a task, as this will ensure the global and constellation
|
||||||
|
@ -1253,7 +1245,7 @@ impl GlobalScope {
|
||||||
// to fire the message event
|
// to fire the message event
|
||||||
let channel = Trusted::new(&*channel);
|
let channel = Trusted::new(&*channel);
|
||||||
let global = Trusted::new(self);
|
let global = Trusted::new(self);
|
||||||
let _ = self.dom_manipulation_task_source().queue(
|
let _ = self.task_manager().dom_manipulation_task_source().queue(
|
||||||
task!(process_pending_port_messages: move || {
|
task!(process_pending_port_messages: move || {
|
||||||
let destination = channel.root();
|
let destination = channel.root();
|
||||||
let global = global.root();
|
let global = global.root();
|
||||||
|
@ -1447,7 +1439,7 @@ impl GlobalScope {
|
||||||
ipc::channel().expect("ipc channel failure");
|
ipc::channel().expect("ipc channel failure");
|
||||||
let context = Trusted::new(self);
|
let context = Trusted::new(self);
|
||||||
let (task_source, canceller) = (
|
let (task_source, canceller) = (
|
||||||
self.dom_manipulation_task_source(),
|
self.task_manager().dom_manipulation_task_source(),
|
||||||
self.task_canceller(TaskSourceName::DOMManipulation),
|
self.task_canceller(TaskSourceName::DOMManipulation),
|
||||||
);
|
);
|
||||||
let listener = BroadcastListener {
|
let listener = BroadcastListener {
|
||||||
|
@ -1500,7 +1492,7 @@ impl GlobalScope {
|
||||||
ipc::channel().expect("ipc channel failure");
|
ipc::channel().expect("ipc channel failure");
|
||||||
let context = Trusted::new(self);
|
let context = Trusted::new(self);
|
||||||
let (task_source, canceller) = (
|
let (task_source, canceller) = (
|
||||||
self.port_message_queue(),
|
self.task_manager().port_message_queue(),
|
||||||
self.task_canceller(TaskSourceName::PortMessage),
|
self.task_canceller(TaskSourceName::PortMessage),
|
||||||
);
|
);
|
||||||
let listener = MessageListener {
|
let listener = MessageListener {
|
||||||
|
@ -1543,7 +1535,7 @@ impl GlobalScope {
|
||||||
// Queue a task to complete the transfer,
|
// Queue a task to complete the transfer,
|
||||||
// unless the port is re-transferred in the current task.
|
// unless the port is re-transferred in the current task.
|
||||||
let this = Trusted::new(self);
|
let this = Trusted::new(self);
|
||||||
let _ = self.port_message_queue().queue(
|
let _ = self.task_manager().port_message_queue().queue(
|
||||||
task!(process_pending_port_messages: move || {
|
task!(process_pending_port_messages: move || {
|
||||||
let target_global = this.root();
|
let target_global = this.root();
|
||||||
target_global.maybe_add_pending_ports();
|
target_global.maybe_add_pending_ports();
|
||||||
|
@ -2026,7 +2018,7 @@ impl GlobalScope {
|
||||||
|
|
||||||
let trusted_stream = Trusted::new(&*stream.clone());
|
let trusted_stream = Trusted::new(&*stream.clone());
|
||||||
let task_canceller = self.task_canceller(TaskSourceName::FileReading);
|
let task_canceller = self.task_canceller(TaskSourceName::FileReading);
|
||||||
let task_source = self.file_reading_task_source();
|
let task_source = self.task_manager().file_reading_task_source();
|
||||||
|
|
||||||
let mut file_listener = FileListener {
|
let mut file_listener = FileListener {
|
||||||
state: Some(FileListenerState::Empty(FileListenerTarget::Stream(
|
state: Some(FileListenerState::Empty(FileListenerTarget::Stream(
|
||||||
|
@ -2051,7 +2043,7 @@ impl GlobalScope {
|
||||||
|
|
||||||
let trusted_promise = TrustedPromise::new(promise);
|
let trusted_promise = TrustedPromise::new(promise);
|
||||||
let task_canceller = self.task_canceller(TaskSourceName::FileReading);
|
let task_canceller = self.task_canceller(TaskSourceName::FileReading);
|
||||||
let task_source = self.file_reading_task_source();
|
let task_source = self.task_manager().file_reading_task_source();
|
||||||
|
|
||||||
let mut file_listener = FileListener {
|
let mut file_listener = FileListener {
|
||||||
state: Some(FileListenerState::Empty(FileListenerTarget::Promise(
|
state: Some(FileListenerState::Empty(FileListenerTarget::Promise(
|
||||||
|
@ -2595,72 +2587,13 @@ impl GlobalScope {
|
||||||
unreachable!();
|
unreachable!();
|
||||||
}
|
}
|
||||||
|
|
||||||
/// `TaskSource` to send messages to the gamepad task source of
|
/// The [`TaskManager`] used to schedule tasks for this [`GlobalScope`].
|
||||||
/// this global scope.
|
pub fn task_manager(&self) -> &TaskManager {
|
||||||
/// <https://w3c.github.io/gamepad/#dfn-gamepad-task-source>
|
|
||||||
pub fn gamepad_task_source(&self) -> GamepadTaskSource {
|
|
||||||
if let Some(window) = self.downcast::<Window>() {
|
if let Some(window) = self.downcast::<Window>() {
|
||||||
return window.task_manager().gamepad_task_source();
|
return window.task_manager();
|
||||||
}
|
|
||||||
unreachable!();
|
|
||||||
}
|
|
||||||
|
|
||||||
/// `TaskSource` to send messages to the networking task source of
|
|
||||||
/// this global scope.
|
|
||||||
pub fn networking_task_source(&self) -> NetworkingTaskSource {
|
|
||||||
if let Some(window) = self.downcast::<Window>() {
|
|
||||||
return window.task_manager().networking_task_source();
|
|
||||||
}
|
}
|
||||||
if let Some(worker) = self.downcast::<WorkerGlobalScope>() {
|
if let Some(worker) = self.downcast::<WorkerGlobalScope>() {
|
||||||
return worker.networking_task_source();
|
return worker.task_manager();
|
||||||
}
|
|
||||||
unreachable!();
|
|
||||||
}
|
|
||||||
|
|
||||||
/// `TaskSource` to send messages to the port message queue of
|
|
||||||
/// this global scope.
|
|
||||||
pub fn port_message_queue(&self) -> PortMessageQueue {
|
|
||||||
if let Some(window) = self.downcast::<Window>() {
|
|
||||||
return window.task_manager().port_message_queue();
|
|
||||||
}
|
|
||||||
if let Some(worker) = self.downcast::<WorkerGlobalScope>() {
|
|
||||||
return worker.port_message_queue();
|
|
||||||
}
|
|
||||||
unreachable!();
|
|
||||||
}
|
|
||||||
|
|
||||||
/// `TaskSource` to send messages to the timer queue of
|
|
||||||
/// this global scope.
|
|
||||||
pub fn timer_task_source(&self) -> TimerTaskSource {
|
|
||||||
if let Some(window) = self.downcast::<Window>() {
|
|
||||||
return window.task_manager().timer_task_source();
|
|
||||||
}
|
|
||||||
if let Some(worker) = self.downcast::<WorkerGlobalScope>() {
|
|
||||||
return worker.timer_task_source();
|
|
||||||
}
|
|
||||||
unreachable!();
|
|
||||||
}
|
|
||||||
|
|
||||||
/// `TaskSource` to send messages to the remote-event task source of
|
|
||||||
/// this global scope.
|
|
||||||
pub fn remote_event_task_source(&self) -> RemoteEventTaskSource {
|
|
||||||
if let Some(window) = self.downcast::<Window>() {
|
|
||||||
return window.task_manager().remote_event_task_source();
|
|
||||||
}
|
|
||||||
if let Some(worker) = self.downcast::<WorkerGlobalScope>() {
|
|
||||||
return worker.remote_event_task_source();
|
|
||||||
}
|
|
||||||
unreachable!();
|
|
||||||
}
|
|
||||||
|
|
||||||
/// `TaskSource` to send messages to the websocket task source of
|
|
||||||
/// this global scope.
|
|
||||||
pub fn websocket_task_source(&self) -> WebsocketTaskSource {
|
|
||||||
if let Some(window) = self.downcast::<Window>() {
|
|
||||||
return window.task_manager().websocket_task_source();
|
|
||||||
}
|
|
||||||
if let Some(worker) = self.downcast::<WorkerGlobalScope>() {
|
|
||||||
return worker.websocket_task_source();
|
|
||||||
}
|
}
|
||||||
unreachable!();
|
unreachable!();
|
||||||
}
|
}
|
||||||
|
@ -2842,7 +2775,8 @@ impl GlobalScope {
|
||||||
scripted_caller.line,
|
scripted_caller.line,
|
||||||
scripted_caller.col,
|
scripted_caller.col,
|
||||||
);
|
);
|
||||||
self.dom_manipulation_task_source()
|
self.task_manager()
|
||||||
|
.dom_manipulation_task_source()
|
||||||
.queue(task, self)
|
.queue(task, self)
|
||||||
.unwrap();
|
.unwrap();
|
||||||
}
|
}
|
||||||
|
@ -3024,28 +2958,6 @@ impl GlobalScope {
|
||||||
unreachable!();
|
unreachable!();
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn dom_manipulation_task_source(&self) -> DOMManipulationTaskSource {
|
|
||||||
if let Some(window) = self.downcast::<Window>() {
|
|
||||||
return window.task_manager().dom_manipulation_task_source();
|
|
||||||
}
|
|
||||||
if let Some(worker) = self.downcast::<WorkerGlobalScope>() {
|
|
||||||
return worker.dom_manipulation_task_source();
|
|
||||||
}
|
|
||||||
unreachable!();
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Channel to send messages to the file reading task source of
|
|
||||||
/// this of this global scope.
|
|
||||||
pub fn file_reading_task_source(&self) -> FileReadingTaskSource {
|
|
||||||
if let Some(window) = self.downcast::<Window>() {
|
|
||||||
return window.task_manager().file_reading_task_source();
|
|
||||||
}
|
|
||||||
if let Some(worker) = self.downcast::<WorkerGlobalScope>() {
|
|
||||||
return worker.file_reading_task_source();
|
|
||||||
}
|
|
||||||
unreachable!();
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn runtime_handle(&self) -> ParentRuntime {
|
pub fn runtime_handle(&self) -> ParentRuntime {
|
||||||
if self.is::<Window>() {
|
if self.is::<Window>() {
|
||||||
ScriptThread::runtime_handle()
|
ScriptThread::runtime_handle()
|
||||||
|
@ -3096,18 +3008,6 @@ impl GlobalScope {
|
||||||
unreachable!();
|
unreachable!();
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Channel to send messages to the performance timeline task source
|
|
||||||
/// of this global scope.
|
|
||||||
pub fn performance_timeline_task_source(&self) -> PerformanceTimelineTaskSource {
|
|
||||||
if let Some(window) = self.downcast::<Window>() {
|
|
||||||
return window.task_manager().performance_timeline_task_source();
|
|
||||||
}
|
|
||||||
if let Some(worker) = self.downcast::<WorkerGlobalScope>() {
|
|
||||||
return worker.performance_timeline_task_source();
|
|
||||||
}
|
|
||||||
unreachable!();
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <https://w3c.github.io/performance-timeline/#supportedentrytypes-attribute>
|
/// <https://w3c.github.io/performance-timeline/#supportedentrytypes-attribute>
|
||||||
pub fn supported_performance_entry_types(&self, cx: SafeJSContext, retval: MutableHandleValue) {
|
pub fn supported_performance_entry_types(&self, cx: SafeJSContext, retval: MutableHandleValue) {
|
||||||
self.frozen_supported_performance_entry_types.get_or_init(
|
self.frozen_supported_performance_entry_types.get_or_init(
|
||||||
|
@ -3261,7 +3161,8 @@ impl GlobalScope {
|
||||||
// TODO: 2. If document is not null and is not allowed to use the "gamepad" permission,
|
// TODO: 2. If document is not null and is not allowed to use the "gamepad" permission,
|
||||||
// then abort these steps.
|
// then abort these steps.
|
||||||
let this = Trusted::new(self);
|
let this = Trusted::new(self);
|
||||||
self.gamepad_task_source()
|
self.task_manager()
|
||||||
|
.gamepad_task_source()
|
||||||
.queue_with_canceller(
|
.queue_with_canceller(
|
||||||
task!(gamepad_connected: move || {
|
task!(gamepad_connected: move || {
|
||||||
let global = this.root();
|
let global = this.root();
|
||||||
|
@ -3291,7 +3192,8 @@ impl GlobalScope {
|
||||||
/// <https://www.w3.org/TR/gamepad/#dfn-gamepaddisconnected>
|
/// <https://www.w3.org/TR/gamepad/#dfn-gamepaddisconnected>
|
||||||
pub fn handle_gamepad_disconnect(&self, index: usize) {
|
pub fn handle_gamepad_disconnect(&self, index: usize) {
|
||||||
let this = Trusted::new(self);
|
let this = Trusted::new(self);
|
||||||
self.gamepad_task_source()
|
self.task_manager()
|
||||||
|
.gamepad_task_source()
|
||||||
.queue_with_canceller(
|
.queue_with_canceller(
|
||||||
task!(gamepad_disconnected: move || {
|
task!(gamepad_disconnected: move || {
|
||||||
let global = this.root();
|
let global = this.root();
|
||||||
|
@ -3315,7 +3217,8 @@ impl GlobalScope {
|
||||||
let this = Trusted::new(self);
|
let this = Trusted::new(self);
|
||||||
|
|
||||||
// <https://w3c.github.io/gamepad/#dfn-update-gamepad-state>
|
// <https://w3c.github.io/gamepad/#dfn-update-gamepad-state>
|
||||||
self.gamepad_task_source()
|
self.task_manager()
|
||||||
|
.gamepad_task_source()
|
||||||
.queue_with_canceller(
|
.queue_with_canceller(
|
||||||
task!(update_gamepad_state: move || {
|
task!(update_gamepad_state: move || {
|
||||||
let global = this.root();
|
let global = this.root();
|
||||||
|
@ -3427,7 +3330,7 @@ impl GlobalScope {
|
||||||
&self,
|
&self,
|
||||||
request_builder: RequestBuilder,
|
request_builder: RequestBuilder,
|
||||||
context: Arc<Mutex<Listener>>,
|
context: Arc<Mutex<Listener>>,
|
||||||
task_source: NetworkingTaskSource,
|
task_source: TaskSource,
|
||||||
cancellation_sender: Option<ipc::IpcReceiver<()>>,
|
cancellation_sender: Option<ipc::IpcReceiver<()>>,
|
||||||
) {
|
) {
|
||||||
let canceller = Some(self.task_canceller(TaskSourceName::Networking));
|
let canceller = Some(self.task_canceller(TaskSourceName::Networking));
|
||||||
|
|
|
@ -20,7 +20,6 @@ use crate::dom::htmlelement::HTMLElement;
|
||||||
use crate::dom::node::{window_from_node, Node, NodeDamage};
|
use crate::dom::node::{window_from_node, Node, NodeDamage};
|
||||||
use crate::dom::virtualmethods::VirtualMethods;
|
use crate::dom::virtualmethods::VirtualMethods;
|
||||||
use crate::script_runtime::CanGc;
|
use crate::script_runtime::CanGc;
|
||||||
use crate::task_source::TaskSource;
|
|
||||||
|
|
||||||
#[dom_struct]
|
#[dom_struct]
|
||||||
pub struct HTMLDetailsElement {
|
pub struct HTMLDetailsElement {
|
||||||
|
|
|
@ -84,7 +84,6 @@ use crate::dom::window::Window;
|
||||||
use crate::links::{get_element_target, LinkRelations};
|
use crate::links::{get_element_target, LinkRelations};
|
||||||
use crate::script_runtime::CanGc;
|
use crate::script_runtime::CanGc;
|
||||||
use crate::script_thread::ScriptThread;
|
use crate::script_thread::ScriptThread;
|
||||||
use crate::task_source::TaskSource;
|
|
||||||
|
|
||||||
#[derive(Clone, Copy, JSTraceable, MallocSizeOf, PartialEq)]
|
#[derive(Clone, Copy, JSTraceable, MallocSizeOf, PartialEq)]
|
||||||
pub struct GenerationId(u32);
|
pub struct GenerationId(u32);
|
||||||
|
|
|
@ -98,7 +98,6 @@ use crate::network_listener::{self, PreInvoke, ResourceTimingListener};
|
||||||
use crate::realms::enter_realm;
|
use crate::realms::enter_realm;
|
||||||
use crate::script_runtime::CanGc;
|
use crate::script_runtime::CanGc;
|
||||||
use crate::script_thread::ScriptThread;
|
use crate::script_thread::ScriptThread;
|
||||||
use crate::task_source::TaskSource;
|
|
||||||
|
|
||||||
#[derive(Clone, Copy, Debug)]
|
#[derive(Clone, Copy, Debug)]
|
||||||
enum ParseState {
|
enum ParseState {
|
||||||
|
|
|
@ -106,7 +106,6 @@ use crate::network_listener::{self, PreInvoke, ResourceTimingListener};
|
||||||
use crate::realms::{enter_realm, InRealm};
|
use crate::realms::{enter_realm, InRealm};
|
||||||
use crate::script_runtime::CanGc;
|
use crate::script_runtime::CanGc;
|
||||||
use crate::script_thread::ScriptThread;
|
use crate::script_thread::ScriptThread;
|
||||||
use crate::task_source::TaskSource;
|
|
||||||
|
|
||||||
#[derive(PartialEq)]
|
#[derive(PartialEq)]
|
||||||
enum FrameStatus {
|
enum FrameStatus {
|
||||||
|
|
|
@ -67,7 +67,6 @@ use crate::script_module::{
|
||||||
};
|
};
|
||||||
use crate::script_runtime::CanGc;
|
use crate::script_runtime::CanGc;
|
||||||
use crate::task::TaskCanceller;
|
use crate::task::TaskCanceller;
|
||||||
use crate::task_source::dom_manipulation::DOMManipulationTaskSource;
|
|
||||||
use crate::task_source::{TaskSource, TaskSourceName};
|
use crate::task_source::{TaskSource, TaskSourceName};
|
||||||
use crate::unminify::{unminify_js, ScriptSource};
|
use crate::unminify::{unminify_js, ScriptSource};
|
||||||
|
|
||||||
|
@ -104,7 +103,7 @@ impl ScriptSource for ScriptOrigin {
|
||||||
script_kind: ExternalScriptKind,
|
script_kind: ExternalScriptKind,
|
||||||
final_url: ServoUrl,
|
final_url: ServoUrl,
|
||||||
url: ServoUrl,
|
url: ServoUrl,
|
||||||
task_source: DOMManipulationTaskSource,
|
task_source: TaskSource,
|
||||||
canceller: TaskCanceller,
|
canceller: TaskCanceller,
|
||||||
script_text: String,
|
script_text: String,
|
||||||
fetch_options: ScriptFetchOptions,
|
fetch_options: ScriptFetchOptions,
|
||||||
|
@ -478,7 +477,7 @@ impl FetchResponseListener for ClassicContext {
|
||||||
script_kind: self.kind,
|
script_kind: self.kind,
|
||||||
final_url,
|
final_url,
|
||||||
url: self.url.clone(),
|
url: self.url.clone(),
|
||||||
task_source: global.dom_manipulation_task_source(),
|
task_source: global.task_manager().dom_manipulation_task_source(),
|
||||||
canceller: global.task_canceller(TaskSourceName::DOMManipulation),
|
canceller: global.task_canceller(TaskSourceName::DOMManipulation),
|
||||||
script_text: source_string,
|
script_text: source_string,
|
||||||
fetch_options: self.fetch_options.clone(),
|
fetch_options: self.fetch_options.clone(),
|
||||||
|
|
|
@ -32,7 +32,6 @@ use crate::dom::promise::Promise;
|
||||||
use crate::dom::window::Window;
|
use crate::dom::window::Window;
|
||||||
use crate::realms::InRealm;
|
use crate::realms::InRealm;
|
||||||
use crate::script_runtime::CanGc;
|
use crate::script_runtime::CanGc;
|
||||||
use crate::task_source::TaskSource;
|
|
||||||
|
|
||||||
#[dom_struct]
|
#[dom_struct]
|
||||||
pub struct OfflineAudioContext {
|
pub struct OfflineAudioContext {
|
||||||
|
|
|
@ -10,6 +10,7 @@ use base::cross_process_instant::CrossProcessInstant;
|
||||||
use dom_struct::dom_struct;
|
use dom_struct::dom_struct;
|
||||||
use time_03::Duration;
|
use time_03::Duration;
|
||||||
|
|
||||||
|
use super::bindings::refcounted::Trusted;
|
||||||
use crate::dom::bindings::cell::DomRefCell;
|
use crate::dom::bindings::cell::DomRefCell;
|
||||||
use crate::dom::bindings::codegen::Bindings::PerformanceBinding::{
|
use crate::dom::bindings::codegen::Bindings::PerformanceBinding::{
|
||||||
DOMHighResTimeStamp, PerformanceEntryList as DOMPerformanceEntryList, PerformanceMethods,
|
DOMHighResTimeStamp, PerformanceEntryList as DOMPerformanceEntryList, PerformanceMethods,
|
||||||
|
@ -237,8 +238,16 @@ impl Performance {
|
||||||
|
|
||||||
if !self.pending_notification_observers_task.get() {
|
if !self.pending_notification_observers_task.get() {
|
||||||
self.pending_notification_observers_task.set(true);
|
self.pending_notification_observers_task.set(true);
|
||||||
let task_source = self.global().performance_timeline_task_source();
|
let task_source = self
|
||||||
task_source.queue_notification(&self.global());
|
.global()
|
||||||
|
.task_manager()
|
||||||
|
.performance_timeline_task_source();
|
||||||
|
let global = &self.global();
|
||||||
|
let owner = Trusted::new(&*global.performance());
|
||||||
|
let task = task!(notify_performance_observers: move || {
|
||||||
|
owner.root().notify_observers();
|
||||||
|
});
|
||||||
|
let _ = task_source.queue(task, global);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
let mut observers = self.observers.borrow_mut();
|
let mut observers = self.observers.borrow_mut();
|
||||||
|
@ -315,8 +324,17 @@ impl Performance {
|
||||||
// Step 6.
|
// Step 6.
|
||||||
// Queue a new notification task.
|
// Queue a new notification task.
|
||||||
self.pending_notification_observers_task.set(true);
|
self.pending_notification_observers_task.set(true);
|
||||||
let task_source = self.global().performance_timeline_task_source();
|
let task_source = self
|
||||||
task_source.queue_notification(&self.global());
|
.global()
|
||||||
|
.task_manager()
|
||||||
|
.performance_timeline_task_source();
|
||||||
|
|
||||||
|
let global = &self.global();
|
||||||
|
let owner = Trusted::new(&*global.performance());
|
||||||
|
let task = task!(notify_performance_observers: move || {
|
||||||
|
owner.root().notify_observers();
|
||||||
|
});
|
||||||
|
let _ = task_source.queue(task, global);
|
||||||
|
|
||||||
Some(entry_last_index)
|
Some(entry_last_index)
|
||||||
}
|
}
|
||||||
|
|
|
@ -53,7 +53,6 @@ use crate::dom::window::Window;
|
||||||
use crate::realms::{enter_realm, InRealm};
|
use crate::realms::{enter_realm, InRealm};
|
||||||
use crate::script_runtime::CanGc;
|
use crate::script_runtime::CanGc;
|
||||||
use crate::task::TaskCanceller;
|
use crate::task::TaskCanceller;
|
||||||
use crate::task_source::networking::NetworkingTaskSource;
|
|
||||||
use crate::task_source::TaskSource;
|
use crate::task_source::TaskSource;
|
||||||
|
|
||||||
#[dom_struct]
|
#[dom_struct]
|
||||||
|
@ -81,7 +80,7 @@ pub struct RTCPeerConnection {
|
||||||
|
|
||||||
struct RTCSignaller {
|
struct RTCSignaller {
|
||||||
trusted: Trusted<RTCPeerConnection>,
|
trusted: Trusted<RTCPeerConnection>,
|
||||||
task_source: NetworkingTaskSource,
|
task_source: TaskSource,
|
||||||
canceller: TaskCanceller,
|
canceller: TaskCanceller,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -20,7 +20,6 @@ use crate::dom::eventtarget::EventTarget;
|
||||||
use crate::dom::node::{window_from_node, Node};
|
use crate::dom::node::{window_from_node, Node};
|
||||||
use crate::dom::range::Range;
|
use crate::dom::range::Range;
|
||||||
use crate::script_runtime::CanGc;
|
use crate::script_runtime::CanGc;
|
||||||
use crate::task_source::TaskSource;
|
|
||||||
|
|
||||||
#[derive(Clone, Copy, JSTraceable, MallocSizeOf)]
|
#[derive(Clone, Copy, JSTraceable, MallocSizeOf)]
|
||||||
enum Direction {
|
enum Direction {
|
||||||
|
|
|
@ -27,7 +27,6 @@ use crate::dom::serviceworkerregistration::ServiceWorkerRegistration;
|
||||||
use crate::realms::{enter_realm, InRealm};
|
use crate::realms::{enter_realm, InRealm};
|
||||||
use crate::script_runtime::CanGc;
|
use crate::script_runtime::CanGc;
|
||||||
use crate::task::TaskCanceller;
|
use crate::task::TaskCanceller;
|
||||||
use crate::task_source::dom_manipulation::DOMManipulationTaskSource;
|
|
||||||
use crate::task_source::{TaskSource, TaskSourceName};
|
use crate::task_source::{TaskSource, TaskSourceName};
|
||||||
|
|
||||||
#[dom_struct]
|
#[dom_struct]
|
||||||
|
@ -143,7 +142,7 @@ impl ServiceWorkerContainerMethods<crate::DomTypeHolder> for ServiceWorkerContai
|
||||||
// Setup the callback for reject/resolve of the promise,
|
// Setup the callback for reject/resolve of the promise,
|
||||||
// from steps running "in-parallel" from here in the serviceworker manager.
|
// from steps running "in-parallel" from here in the serviceworker manager.
|
||||||
let (task_source, task_canceller) = (
|
let (task_source, task_canceller) = (
|
||||||
global.dom_manipulation_task_source(),
|
global.task_manager().dom_manipulation_task_source(),
|
||||||
global.task_canceller(TaskSourceName::DOMManipulation),
|
global.task_canceller(TaskSourceName::DOMManipulation),
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -190,7 +189,7 @@ impl ServiceWorkerContainerMethods<crate::DomTypeHolder> for ServiceWorkerContai
|
||||||
/// <https://w3c.github.io/ServiceWorker/#register>
|
/// <https://w3c.github.io/ServiceWorker/#register>
|
||||||
struct RegisterJobResultHandler {
|
struct RegisterJobResultHandler {
|
||||||
trusted_promise: Option<TrustedPromise>,
|
trusted_promise: Option<TrustedPromise>,
|
||||||
task_source: DOMManipulationTaskSource,
|
task_source: TaskSource,
|
||||||
task_canceller: TaskCanceller,
|
task_canceller: TaskCanceller,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -143,7 +143,7 @@ impl ScriptChan for ServiceWorkerChan {
|
||||||
.map_err(|_| ())
|
.map_err(|_| ())
|
||||||
}
|
}
|
||||||
|
|
||||||
fn as_boxed(&self) -> Box<dyn ScriptChan + Send> {
|
fn as_boxed(&self) -> Box<dyn ScriptChan> {
|
||||||
Box::new(ServiceWorkerChan {
|
Box::new(ServiceWorkerChan {
|
||||||
sender: self.sender.clone(),
|
sender: self.sender.clone(),
|
||||||
})
|
})
|
||||||
|
|
|
@ -21,7 +21,6 @@ use crate::dom::event::{Event, EventBubbles, EventCancelable};
|
||||||
use crate::dom::storageevent::StorageEvent;
|
use crate::dom::storageevent::StorageEvent;
|
||||||
use crate::dom::window::Window;
|
use crate::dom::window::Window;
|
||||||
use crate::script_runtime::CanGc;
|
use crate::script_runtime::CanGc;
|
||||||
use crate::task_source::TaskSource;
|
|
||||||
|
|
||||||
#[dom_struct]
|
#[dom_struct]
|
||||||
pub struct Storage {
|
pub struct Storage {
|
||||||
|
|
|
@ -54,7 +54,6 @@ use crate::dom::workerglobalscope::WorkerGlobalScope;
|
||||||
use crate::realms::InRealm;
|
use crate::realms::InRealm;
|
||||||
use crate::script_runtime::{CanGc, JSContext};
|
use crate::script_runtime::{CanGc, JSContext};
|
||||||
use crate::task::TaskCanceller;
|
use crate::task::TaskCanceller;
|
||||||
use crate::task_source::dom_manipulation::DOMManipulationTaskSource;
|
|
||||||
use crate::task_source::TaskSource;
|
use crate::task_source::TaskSource;
|
||||||
|
|
||||||
// String constants for algorithms/curves
|
// String constants for algorithms/curves
|
||||||
|
@ -142,13 +141,13 @@ impl SubtleCrypto {
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn task_source_with_canceller(&self) -> (DOMManipulationTaskSource, TaskCanceller) {
|
fn task_source_with_canceller(&self) -> (TaskSource, TaskCanceller) {
|
||||||
if let Some(window) = self.global().downcast::<Window>() {
|
if let Some(window) = self.global().downcast::<Window>() {
|
||||||
window
|
window
|
||||||
.task_manager()
|
.task_manager()
|
||||||
.dom_manipulation_task_source_with_canceller()
|
.dom_manipulation_task_source_with_canceller()
|
||||||
} else if let Some(worker_global) = self.global().downcast::<WorkerGlobalScope>() {
|
} else if let Some(worker_global) = self.global().downcast::<WorkerGlobalScope>() {
|
||||||
let task_source = worker_global.dom_manipulation_task_source();
|
let task_source = worker_global.task_manager().dom_manipulation_task_source();
|
||||||
let canceller = worker_global.task_canceller();
|
let canceller = worker_global.task_canceller();
|
||||||
(task_source, canceller)
|
(task_source, canceller)
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -18,7 +18,6 @@ use crate::dom::texttrack::TextTrack;
|
||||||
use crate::dom::trackevent::TrackEvent;
|
use crate::dom::trackevent::TrackEvent;
|
||||||
use crate::dom::window::Window;
|
use crate::dom::window::Window;
|
||||||
use crate::script_runtime::CanGc;
|
use crate::script_runtime::CanGc;
|
||||||
use crate::task_source::TaskSource;
|
|
||||||
|
|
||||||
#[dom_struct]
|
#[dom_struct]
|
||||||
pub struct TextTrackList {
|
pub struct TextTrackList {
|
||||||
|
|
|
@ -16,7 +16,6 @@ use crate::dom::htmlmediaelement::HTMLMediaElement;
|
||||||
use crate::dom::videotrack::VideoTrack;
|
use crate::dom::videotrack::VideoTrack;
|
||||||
use crate::dom::window::Window;
|
use crate::dom::window::Window;
|
||||||
use crate::script_runtime::CanGc;
|
use crate::script_runtime::CanGc;
|
||||||
use crate::task_source::TaskSource;
|
|
||||||
|
|
||||||
#[dom_struct]
|
#[dom_struct]
|
||||||
pub struct VideoTrackList {
|
pub struct VideoTrackList {
|
||||||
|
|
|
@ -16,7 +16,6 @@ use crate::dom::bindings::root::DomRoot;
|
||||||
use crate::dom::webglobject::WebGLObject;
|
use crate::dom::webglobject::WebGLObject;
|
||||||
use crate::dom::webglrenderingcontext::{Operation, WebGLRenderingContext};
|
use crate::dom::webglrenderingcontext::{Operation, WebGLRenderingContext};
|
||||||
use crate::script_runtime::CanGc;
|
use crate::script_runtime::CanGc;
|
||||||
use crate::task_source::TaskSource;
|
|
||||||
|
|
||||||
#[dom_struct]
|
#[dom_struct]
|
||||||
pub struct WebGLQuery {
|
pub struct WebGLQuery {
|
||||||
|
|
|
@ -15,7 +15,6 @@ use crate::dom::bindings::root::DomRoot;
|
||||||
use crate::dom::webglobject::WebGLObject;
|
use crate::dom::webglobject::WebGLObject;
|
||||||
use crate::dom::webglrenderingcontext::{Operation, WebGLRenderingContext};
|
use crate::dom::webglrenderingcontext::{Operation, WebGLRenderingContext};
|
||||||
use crate::script_runtime::CanGc;
|
use crate::script_runtime::CanGc;
|
||||||
use crate::task_source::TaskSource;
|
|
||||||
|
|
||||||
#[dom_struct]
|
#[dom_struct]
|
||||||
pub struct WebGLSync {
|
pub struct WebGLSync {
|
||||||
|
|
|
@ -25,7 +25,7 @@ use crate::dom::promise::Promise;
|
||||||
use crate::dom::webgpu::gpuadapter::GPUAdapter;
|
use crate::dom::webgpu::gpuadapter::GPUAdapter;
|
||||||
use crate::realms::InRealm;
|
use crate::realms::InRealm;
|
||||||
use crate::script_runtime::CanGc;
|
use crate::script_runtime::CanGc;
|
||||||
use crate::task_source::{TaskSource, TaskSourceName};
|
use crate::task_source::TaskSourceName;
|
||||||
|
|
||||||
#[dom_struct]
|
#[dom_struct]
|
||||||
#[allow(clippy::upper_case_acronyms)]
|
#[allow(clippy::upper_case_acronyms)]
|
||||||
|
@ -69,7 +69,10 @@ pub fn response_async<T: AsyncWGPUListener + DomObject + 'static>(
|
||||||
receiver: &T,
|
receiver: &T,
|
||||||
) -> IpcSender<WebGPUResponse> {
|
) -> IpcSender<WebGPUResponse> {
|
||||||
let (action_sender, action_receiver) = ipc::channel().unwrap();
|
let (action_sender, action_receiver) = ipc::channel().unwrap();
|
||||||
let task_source = receiver.global().dom_manipulation_task_source();
|
let task_source = receiver
|
||||||
|
.global()
|
||||||
|
.task_manager()
|
||||||
|
.dom_manipulation_task_source();
|
||||||
let canceller = receiver
|
let canceller = receiver
|
||||||
.global()
|
.global()
|
||||||
.task_canceller(TaskSourceName::DOMManipulation);
|
.task_canceller(TaskSourceName::DOMManipulation);
|
||||||
|
|
|
@ -38,11 +38,9 @@ use crate::dom::event::{Event, EventBubbles, EventCancelable};
|
||||||
use crate::dom::eventtarget::EventTarget;
|
use crate::dom::eventtarget::EventTarget;
|
||||||
use crate::dom::globalscope::GlobalScope;
|
use crate::dom::globalscope::GlobalScope;
|
||||||
use crate::dom::messageevent::MessageEvent;
|
use crate::dom::messageevent::MessageEvent;
|
||||||
use crate::script_runtime::ScriptThreadEventCategory::WebSocketEvent;
|
use crate::script_runtime::CanGc;
|
||||||
use crate::script_runtime::{CanGc, CommonScriptMsg};
|
|
||||||
use crate::task::{TaskCanceller, TaskOnce};
|
use crate::task::{TaskCanceller, TaskOnce};
|
||||||
use crate::task_source::websocket::WebsocketTaskSource;
|
use crate::task_source::{TaskSource, TaskSourceName};
|
||||||
use crate::task_source::TaskSource;
|
|
||||||
|
|
||||||
#[derive(Clone, Copy, Debug, JSTraceable, MallocSizeOf, PartialEq)]
|
#[derive(Clone, Copy, Debug, JSTraceable, MallocSizeOf, PartialEq)]
|
||||||
enum WebSocketRequestState {
|
enum WebSocketRequestState {
|
||||||
|
@ -72,7 +70,7 @@ mod close_code {
|
||||||
|
|
||||||
fn close_the_websocket_connection(
|
fn close_the_websocket_connection(
|
||||||
address: Trusted<WebSocket>,
|
address: Trusted<WebSocket>,
|
||||||
task_source: &WebsocketTaskSource,
|
task_source: &TaskSource,
|
||||||
canceller: &TaskCanceller,
|
canceller: &TaskCanceller,
|
||||||
code: Option<u16>,
|
code: Option<u16>,
|
||||||
reason: String,
|
reason: String,
|
||||||
|
@ -88,7 +86,7 @@ fn close_the_websocket_connection(
|
||||||
|
|
||||||
fn fail_the_websocket_connection(
|
fn fail_the_websocket_connection(
|
||||||
address: Trusted<WebSocket>,
|
address: Trusted<WebSocket>,
|
||||||
task_source: &WebsocketTaskSource,
|
task_source: &TaskSource,
|
||||||
canceller: &TaskCanceller,
|
canceller: &TaskCanceller,
|
||||||
) {
|
) {
|
||||||
let close_task = CloseTask {
|
let close_task = CloseTask {
|
||||||
|
@ -168,19 +166,12 @@ impl WebSocket {
|
||||||
if !self.clearing_buffer.get() && self.ready_state.get() == WebSocketRequestState::Open {
|
if !self.clearing_buffer.get() && self.ready_state.get() == WebSocketRequestState::Open {
|
||||||
self.clearing_buffer.set(true);
|
self.clearing_buffer.set(true);
|
||||||
|
|
||||||
let task = Box::new(BufferedAmountTask { address });
|
// TODO(mrobinson): Should this task be cancellable?
|
||||||
|
let _ = self
|
||||||
let pipeline_id = self.global().pipeline_id();
|
.global()
|
||||||
self.global()
|
.task_manager()
|
||||||
.script_chan()
|
.websocket_task_source()
|
||||||
// TODO: Use a dedicated `websocket-task-source` task source instead.
|
.queue_unconditionally(BufferedAmountTask { address });
|
||||||
.send(CommonScriptMsg::Task(
|
|
||||||
WebSocketEvent,
|
|
||||||
task,
|
|
||||||
Some(pipeline_id),
|
|
||||||
WebsocketTaskSource::NAME,
|
|
||||||
))
|
|
||||||
.unwrap();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Ok(true)
|
Ok(true)
|
||||||
|
@ -284,8 +275,8 @@ impl WebSocketMethods<crate::DomTypeHolder> for WebSocket {
|
||||||
.core_resource_thread()
|
.core_resource_thread()
|
||||||
.send(CoreResourceMsg::Fetch(request, channels));
|
.send(CoreResourceMsg::Fetch(request, channels));
|
||||||
|
|
||||||
let task_source = global.websocket_task_source();
|
let task_source = global.task_manager().websocket_task_source();
|
||||||
let canceller = global.task_canceller(WebsocketTaskSource::NAME);
|
let canceller = global.task_canceller(TaskSourceName::WebSocket);
|
||||||
ROUTER.add_typed_route(
|
ROUTER.add_typed_route(
|
||||||
dom_event_receiver.to_ipc_receiver(),
|
dom_event_receiver.to_ipc_receiver(),
|
||||||
Box::new(move |message| match message.unwrap() {
|
Box::new(move |message| match message.unwrap() {
|
||||||
|
@ -451,11 +442,11 @@ impl WebSocketMethods<crate::DomTypeHolder> for WebSocket {
|
||||||
// TODO: use a dedicated task source,
|
// TODO: use a dedicated task source,
|
||||||
// https://html.spec.whatwg.org/multipage/#websocket-task-source
|
// https://html.spec.whatwg.org/multipage/#websocket-task-source
|
||||||
// When making the switch, also update the task_canceller call.
|
// When making the switch, also update the task_canceller call.
|
||||||
let task_source = self.global().websocket_task_source();
|
let task_source = self.global().task_manager().websocket_task_source();
|
||||||
fail_the_websocket_connection(
|
fail_the_websocket_connection(
|
||||||
address,
|
address,
|
||||||
&task_source,
|
&task_source,
|
||||||
&self.global().task_canceller(WebsocketTaskSource::NAME),
|
&self.global().task_canceller(TaskSourceName::WebSocket),
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
WebSocketRequestState::Open => {
|
WebSocketRequestState::Open => {
|
||||||
|
|
|
@ -35,7 +35,6 @@ use crate::dom::fakexrinputcontroller::{init_to_mock_buttons, FakeXRInputControl
|
||||||
use crate::dom::globalscope::GlobalScope;
|
use crate::dom::globalscope::GlobalScope;
|
||||||
use crate::dom::promise::Promise;
|
use crate::dom::promise::Promise;
|
||||||
use crate::script_runtime::CanGc;
|
use crate::script_runtime::CanGc;
|
||||||
use crate::task_source::TaskSource;
|
|
||||||
|
|
||||||
#[dom_struct]
|
#[dom_struct]
|
||||||
pub struct FakeXRDevice {
|
pub struct FakeXRDevice {
|
||||||
|
|
|
@ -68,7 +68,6 @@ use crate::dom::xrsessionevent::XRSessionEvent;
|
||||||
use crate::dom::xrspace::XRSpace;
|
use crate::dom::xrspace::XRSpace;
|
||||||
use crate::realms::InRealm;
|
use crate::realms::InRealm;
|
||||||
use crate::script_runtime::JSContext;
|
use crate::script_runtime::JSContext;
|
||||||
use crate::task_source::TaskSource;
|
|
||||||
use crate::script_runtime::CanGc;
|
use crate::script_runtime::CanGc;
|
||||||
|
|
||||||
#[dom_struct]
|
#[dom_struct]
|
||||||
|
|
|
@ -35,7 +35,6 @@ use crate::dom::xrtest::XRTest;
|
||||||
use crate::realms::InRealm;
|
use crate::realms::InRealm;
|
||||||
use crate::script_runtime::CanGc;
|
use crate::script_runtime::CanGc;
|
||||||
use crate::script_thread::ScriptThread;
|
use crate::script_thread::ScriptThread;
|
||||||
use crate::task_source::TaskSource;
|
|
||||||
|
|
||||||
#[dom_struct]
|
#[dom_struct]
|
||||||
pub struct XRSystem {
|
pub struct XRSystem {
|
||||||
|
|
|
@ -28,7 +28,6 @@ use crate::dom::globalscope::GlobalScope;
|
||||||
use crate::dom::promise::Promise;
|
use crate::dom::promise::Promise;
|
||||||
use crate::script_runtime::CanGc;
|
use crate::script_runtime::CanGc;
|
||||||
use crate::script_thread::ScriptThread;
|
use crate::script_thread::ScriptThread;
|
||||||
use crate::task_source::TaskSource;
|
|
||||||
|
|
||||||
#[dom_struct]
|
#[dom_struct]
|
||||||
pub struct XRTest {
|
pub struct XRTest {
|
||||||
|
|
|
@ -158,7 +158,7 @@ use crate::script_runtime::{
|
||||||
};
|
};
|
||||||
use crate::script_thread::ScriptThread;
|
use crate::script_thread::ScriptThread;
|
||||||
use crate::task_manager::TaskManager;
|
use crate::task_manager::TaskManager;
|
||||||
use crate::task_source::{TaskSource, TaskSourceName};
|
use crate::task_source::TaskSourceName;
|
||||||
use crate::timers::{IsInterval, TimerCallback};
|
use crate::timers::{IsInterval, TimerCallback};
|
||||||
use crate::unminify::unminified_path;
|
use crate::unminify::unminified_path;
|
||||||
use crate::webdriver_handlers::jsval_to_webdriver;
|
use crate::webdriver_handlers::jsval_to_webdriver;
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||||
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
||||||
|
|
||||||
use std::cell::{RefCell, RefMut};
|
use std::cell::{OnceCell, RefCell, RefMut};
|
||||||
use std::default::Default;
|
use std::default::Default;
|
||||||
use std::rc::Rc;
|
use std::rc::Rc;
|
||||||
use std::sync::atomic::{AtomicBool, Ordering};
|
use std::sync::atomic::{AtomicBool, Ordering};
|
||||||
|
@ -44,7 +44,7 @@ use crate::dom::bindings::reflector::DomObject;
|
||||||
use crate::dom::bindings::root::{DomRoot, MutNullableDom};
|
use crate::dom::bindings::root::{DomRoot, MutNullableDom};
|
||||||
use crate::dom::bindings::settings_stack::AutoEntryScript;
|
use crate::dom::bindings::settings_stack::AutoEntryScript;
|
||||||
use crate::dom::bindings::str::{DOMString, USVString};
|
use crate::dom::bindings::str::{DOMString, USVString};
|
||||||
use crate::dom::bindings::trace::RootedTraceableBox;
|
use crate::dom::bindings::trace::{CustomTraceable, RootedTraceableBox};
|
||||||
use crate::dom::crypto::Crypto;
|
use crate::dom::crypto::Crypto;
|
||||||
use crate::dom::dedicatedworkerglobalscope::DedicatedWorkerGlobalScope;
|
use crate::dom::dedicatedworkerglobalscope::DedicatedWorkerGlobalScope;
|
||||||
use crate::dom::globalscope::GlobalScope;
|
use crate::dom::globalscope::GlobalScope;
|
||||||
|
@ -60,14 +60,7 @@ use crate::fetch;
|
||||||
use crate::realms::{enter_realm, InRealm};
|
use crate::realms::{enter_realm, InRealm};
|
||||||
use crate::script_runtime::{CanGc, CommonScriptMsg, JSContext, Runtime, ScriptChan, ScriptPort};
|
use crate::script_runtime::{CanGc, CommonScriptMsg, JSContext, Runtime, ScriptChan, ScriptPort};
|
||||||
use crate::task::TaskCanceller;
|
use crate::task::TaskCanceller;
|
||||||
use crate::task_source::dom_manipulation::DOMManipulationTaskSource;
|
use crate::task_manager::TaskManager;
|
||||||
use crate::task_source::file_reading::FileReadingTaskSource;
|
|
||||||
use crate::task_source::networking::NetworkingTaskSource;
|
|
||||||
use crate::task_source::performance_timeline::PerformanceTimelineTaskSource;
|
|
||||||
use crate::task_source::port_message::PortMessageQueue;
|
|
||||||
use crate::task_source::remote_event::RemoteEventTaskSource;
|
|
||||||
use crate::task_source::timer::TimerTaskSource;
|
|
||||||
use crate::task_source::websocket::WebsocketTaskSource;
|
|
||||||
use crate::timers::{IsInterval, TimerCallback};
|
use crate::timers::{IsInterval, TimerCallback};
|
||||||
|
|
||||||
pub fn prepare_workerscope_init(
|
pub fn prepare_workerscope_init(
|
||||||
|
@ -135,6 +128,9 @@ pub struct WorkerGlobalScope {
|
||||||
/// Timers are handled in the service worker event loop.
|
/// Timers are handled in the service worker event loop.
|
||||||
#[no_trace]
|
#[no_trace]
|
||||||
timer_scheduler: RefCell<TimerScheduler>,
|
timer_scheduler: RefCell<TimerScheduler>,
|
||||||
|
|
||||||
|
/// A [`TaskManager`] for this [`WorkerGlobalScope`].
|
||||||
|
task_manager: OnceCell<TaskManager>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl WorkerGlobalScope {
|
impl WorkerGlobalScope {
|
||||||
|
@ -189,6 +185,7 @@ impl WorkerGlobalScope {
|
||||||
navigation_start: CrossProcessInstant::now(),
|
navigation_start: CrossProcessInstant::now(),
|
||||||
performance: Default::default(),
|
performance: Default::default(),
|
||||||
timer_scheduler: RefCell::default(),
|
timer_scheduler: RefCell::default(),
|
||||||
|
task_manager: Default::default(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -510,36 +507,9 @@ impl WorkerGlobalScope {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn dom_manipulation_task_source(&self) -> DOMManipulationTaskSource {
|
pub(crate) fn task_manager(&self) -> &TaskManager {
|
||||||
DOMManipulationTaskSource(self.script_chan(), self.pipeline_id())
|
self.task_manager
|
||||||
}
|
.get_or_init(|| TaskManager::new(self.script_chan(), self.pipeline_id()))
|
||||||
|
|
||||||
pub fn file_reading_task_source(&self) -> FileReadingTaskSource {
|
|
||||||
FileReadingTaskSource(self.script_chan(), self.pipeline_id())
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn networking_task_source(&self) -> NetworkingTaskSource {
|
|
||||||
NetworkingTaskSource(self.script_chan(), self.pipeline_id())
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn performance_timeline_task_source(&self) -> PerformanceTimelineTaskSource {
|
|
||||||
PerformanceTimelineTaskSource(self.script_chan(), self.pipeline_id())
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn port_message_queue(&self) -> PortMessageQueue {
|
|
||||||
PortMessageQueue(self.script_chan(), self.pipeline_id())
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn timer_task_source(&self) -> TimerTaskSource {
|
|
||||||
TimerTaskSource(self.script_chan(), self.pipeline_id())
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn remote_event_task_source(&self) -> RemoteEventTaskSource {
|
|
||||||
RemoteEventTaskSource(self.script_chan(), self.pipeline_id())
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn websocket_task_source(&self) -> WebsocketTaskSource {
|
|
||||||
WebsocketTaskSource(self.script_chan(), self.pipeline_id())
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn new_script_pair(&self) -> (Box<dyn ScriptChan + Send>, Box<dyn ScriptPort + Send>) {
|
pub fn new_script_pair(&self) -> (Box<dyn ScriptChan + Send>, Box<dyn ScriptPort + Send>) {
|
||||||
|
|
|
@ -73,7 +73,7 @@ use crate::dom::xmlhttprequestupload::XMLHttpRequestUpload;
|
||||||
use crate::fetch::FetchCanceller;
|
use crate::fetch::FetchCanceller;
|
||||||
use crate::network_listener::{self, PreInvoke, ResourceTimingListener};
|
use crate::network_listener::{self, PreInvoke, ResourceTimingListener};
|
||||||
use crate::script_runtime::{CanGc, JSContext};
|
use crate::script_runtime::{CanGc, JSContext};
|
||||||
use crate::task_source::networking::NetworkingTaskSource;
|
use crate::task_source::{TaskSource, TaskSourceName};
|
||||||
use crate::timers::{OneshotTimerCallback, OneshotTimerHandle};
|
use crate::timers::{OneshotTimerCallback, OneshotTimerHandle};
|
||||||
|
|
||||||
#[derive(Clone, Copy, Debug, JSTraceable, MallocSizeOf, PartialEq)]
|
#[derive(Clone, Copy, Debug, JSTraceable, MallocSizeOf, PartialEq)]
|
||||||
|
@ -294,7 +294,7 @@ impl XMLHttpRequest {
|
||||||
|
|
||||||
fn initiate_async_xhr(
|
fn initiate_async_xhr(
|
||||||
context: Arc<Mutex<XHRContext>>,
|
context: Arc<Mutex<XHRContext>>,
|
||||||
task_source: NetworkingTaskSource,
|
task_source: TaskSource,
|
||||||
global: &GlobalScope,
|
global: &GlobalScope,
|
||||||
init: RequestBuilder,
|
init: RequestBuilder,
|
||||||
cancellation_chan: ipc::IpcReceiver<()>,
|
cancellation_chan: ipc::IpcReceiver<()>,
|
||||||
|
@ -1560,10 +1560,17 @@ impl XMLHttpRequest {
|
||||||
}));
|
}));
|
||||||
|
|
||||||
let (task_source, script_port) = if self.sync.get() {
|
let (task_source, script_port) = if self.sync.get() {
|
||||||
let (tx, rx) = global.new_script_pair();
|
let (sender, receiver) = global.new_script_pair();
|
||||||
(NetworkingTaskSource(tx, global.pipeline_id()), Some(rx))
|
(
|
||||||
|
TaskSource {
|
||||||
|
sender,
|
||||||
|
pipeline_id: global.pipeline_id(),
|
||||||
|
name: TaskSourceName::Networking,
|
||||||
|
},
|
||||||
|
Some(receiver),
|
||||||
|
)
|
||||||
} else {
|
} else {
|
||||||
(global.networking_task_source(), None)
|
(global.task_manager().networking_task_source(), None)
|
||||||
};
|
};
|
||||||
|
|
||||||
let cancel_receiver = self.canceller.borrow_mut().initialize();
|
let cancel_receiver = self.canceller.borrow_mut().initialize();
|
||||||
|
|
|
@ -195,7 +195,7 @@ pub fn Fetch(
|
||||||
global.fetch(
|
global.fetch(
|
||||||
request_init,
|
request_init,
|
||||||
fetch_context,
|
fetch_context,
|
||||||
global.networking_task_source(),
|
global.task_manager().networking_task_source(),
|
||||||
None,
|
None,
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
|
@ -12,7 +12,6 @@ use crate::dom::bindings::refcounted::Trusted;
|
||||||
use crate::dom::bindings::reflector::DomObject;
|
use crate::dom::bindings::reflector::DomObject;
|
||||||
use crate::dom::node::{window_from_node, Node};
|
use crate::dom::node::{window_from_node, Node};
|
||||||
use crate::script_runtime::CanGc;
|
use crate::script_runtime::CanGc;
|
||||||
use crate::task_source::TaskSource;
|
|
||||||
|
|
||||||
pub trait ImageCacheListener {
|
pub trait ImageCacheListener {
|
||||||
fn generation_id(&self) -> u32;
|
fn generation_id(&self) -> u32;
|
||||||
|
|
|
@ -22,7 +22,6 @@ use crate::dom::htmllinkelement::HTMLLinkElement;
|
||||||
use crate::dom::node::document_from_node;
|
use crate::dom::node::document_from_node;
|
||||||
use crate::dom::types::{Element, GlobalScope};
|
use crate::dom::types::{Element, GlobalScope};
|
||||||
use crate::script_runtime::CanGc;
|
use crate::script_runtime::CanGc;
|
||||||
use crate::task_source::TaskSource;
|
|
||||||
|
|
||||||
bitflags::bitflags! {
|
bitflags::bitflags! {
|
||||||
/// Describes the different relations that can be specified on elements using the `rel`
|
/// Describes the different relations that can be specified on elements using the `rel`
|
||||||
|
|
|
@ -235,7 +235,7 @@ impl ScriptChan for SendableMainThreadScriptChan {
|
||||||
self.0.send(msg).map_err(|_| ())
|
self.0.send(msg).map_err(|_| ())
|
||||||
}
|
}
|
||||||
|
|
||||||
fn as_boxed(&self) -> Box<dyn ScriptChan + Send> {
|
fn as_boxed(&self) -> Box<dyn ScriptChan> {
|
||||||
Box::new(SendableMainThreadScriptChan((self.0).clone()))
|
Box::new(SendableMainThreadScriptChan((self.0).clone()))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -251,7 +251,7 @@ impl ScriptChan for MainThreadScriptChan {
|
||||||
.map_err(|_| ())
|
.map_err(|_| ())
|
||||||
}
|
}
|
||||||
|
|
||||||
fn as_boxed(&self) -> Box<dyn ScriptChan + Send> {
|
fn as_boxed(&self) -> Box<dyn ScriptChan> {
|
||||||
Box::new(MainThreadScriptChan((self.0).clone()))
|
Box::new(MainThreadScriptChan((self.0).clone()))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,14 +17,13 @@ use crate::dom::performanceentry::PerformanceEntry;
|
||||||
use crate::dom::performanceresourcetiming::{InitiatorType, PerformanceResourceTiming};
|
use crate::dom::performanceresourcetiming::{InitiatorType, PerformanceResourceTiming};
|
||||||
use crate::script_runtime::CanGc;
|
use crate::script_runtime::CanGc;
|
||||||
use crate::task::{TaskCanceller, TaskOnce};
|
use crate::task::{TaskCanceller, TaskOnce};
|
||||||
use crate::task_source::networking::NetworkingTaskSource;
|
|
||||||
use crate::task_source::TaskSource;
|
use crate::task_source::TaskSource;
|
||||||
|
|
||||||
/// An off-thread sink for async network event tasks. All such events are forwarded to
|
/// An off-thread sink for async network event tasks. All such events are forwarded to
|
||||||
/// a target thread, where they are invoked on the provided context object.
|
/// a target thread, where they are invoked on the provided context object.
|
||||||
pub struct NetworkListener<Listener: PreInvoke + Send + 'static> {
|
pub struct NetworkListener<Listener: PreInvoke + Send + 'static> {
|
||||||
pub context: Arc<Mutex<Listener>>,
|
pub context: Arc<Mutex<Listener>>,
|
||||||
pub task_source: NetworkingTaskSource,
|
pub task_source: TaskSource,
|
||||||
pub canceller: Option<TaskCanceller>,
|
pub canceller: Option<TaskCanceller>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1769,7 +1769,7 @@ fn fetch_single_module_script(
|
||||||
resource_timing: ResourceFetchTiming::new(ResourceTimingType::Resource),
|
resource_timing: ResourceFetchTiming::new(ResourceTimingType::Resource),
|
||||||
}));
|
}));
|
||||||
|
|
||||||
let task_source = global.networking_task_source();
|
let task_source = global.task_manager().networking_task_source();
|
||||||
let canceller = global.task_canceller(TaskSourceName::Networking);
|
let canceller = global.task_canceller(TaskSourceName::Networking);
|
||||||
|
|
||||||
let network_listener = NetworkListener {
|
let network_listener = NetworkListener {
|
||||||
|
|
|
@ -49,6 +49,7 @@ use js::rust::{
|
||||||
JSEngineHandle, ParentRuntime, Runtime as RustRuntime,
|
JSEngineHandle, ParentRuntime, Runtime as RustRuntime,
|
||||||
};
|
};
|
||||||
use malloc_size_of::MallocSizeOfOps;
|
use malloc_size_of::MallocSizeOfOps;
|
||||||
|
use malloc_size_of_derive::MallocSizeOf;
|
||||||
use profile_traits::mem::{Report, ReportKind, ReportsChan};
|
use profile_traits::mem::{Report, ReportKind, ReportsChan};
|
||||||
use profile_traits::path;
|
use profile_traits::path;
|
||||||
use profile_traits::time::ProfilerCategory;
|
use profile_traits::time::ProfilerCategory;
|
||||||
|
@ -84,7 +85,6 @@ use crate::script_module::EnsureModuleHooksInitialized;
|
||||||
use crate::script_thread::trace_thread;
|
use crate::script_thread::trace_thread;
|
||||||
use crate::security_manager::CSPViolationReporter;
|
use crate::security_manager::CSPViolationReporter;
|
||||||
use crate::task::TaskBox;
|
use crate::task::TaskBox;
|
||||||
use crate::task_source::networking::NetworkingTaskSource;
|
|
||||||
use crate::task_source::{TaskSource, TaskSourceName};
|
use crate::task_source::{TaskSource, TaskSourceName};
|
||||||
|
|
||||||
static JOB_QUEUE_TRAPS: JobQueueTraps = JobQueueTraps {
|
static JOB_QUEUE_TRAPS: JobQueueTraps = JobQueueTraps {
|
||||||
|
@ -124,15 +124,15 @@ impl fmt::Debug for CommonScriptMsg {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// A cloneable interface for communicating with an event loop.
|
/// A cloneable interface for communicating with an event loop.
|
||||||
pub trait ScriptChan: JSTraceable {
|
pub trait ScriptChan: JSTraceable + Send {
|
||||||
/// Send a message to the associated event loop.
|
/// Send a message to the associated event loop.
|
||||||
#[allow(clippy::result_unit_err)]
|
#[allow(clippy::result_unit_err)]
|
||||||
fn send(&self, msg: CommonScriptMsg) -> Result<(), ()>;
|
fn send(&self, msg: CommonScriptMsg) -> Result<(), ()>;
|
||||||
/// Return a cloned version of this sender in a [`Box`].
|
/// Return a cloned version of this sender in a [`Box`].
|
||||||
fn as_boxed(&self) -> Box<dyn ScriptChan + Send>;
|
fn as_boxed(&self) -> Box<dyn ScriptChan>;
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone, Copy, Debug, Eq, Hash, JSTraceable, PartialEq)]
|
#[derive(Clone, Copy, Debug, Eq, Hash, JSTraceable, MallocSizeOf, PartialEq)]
|
||||||
pub enum ScriptThreadEventCategory {
|
pub enum ScriptThreadEventCategory {
|
||||||
AttachLayout,
|
AttachLayout,
|
||||||
ConstellationMsg,
|
ConstellationMsg,
|
||||||
|
@ -146,6 +146,7 @@ pub enum ScriptThreadEventCategory {
|
||||||
InputEvent,
|
InputEvent,
|
||||||
NetworkEvent,
|
NetworkEvent,
|
||||||
PortMessage,
|
PortMessage,
|
||||||
|
Rendering,
|
||||||
Resize,
|
Resize,
|
||||||
ScriptEvent,
|
ScriptEvent,
|
||||||
SetScrollState,
|
SetScrollState,
|
||||||
|
@ -187,6 +188,7 @@ impl From<ScriptThreadEventCategory> for ProfilerCategory {
|
||||||
},
|
},
|
||||||
ScriptThreadEventCategory::PortMessage => ProfilerCategory::ScriptPortMessage,
|
ScriptThreadEventCategory::PortMessage => ProfilerCategory::ScriptPortMessage,
|
||||||
ScriptThreadEventCategory::Resize => ProfilerCategory::ScriptResize,
|
ScriptThreadEventCategory::Resize => ProfilerCategory::ScriptResize,
|
||||||
|
ScriptThreadEventCategory::Rendering => ProfilerCategory::ScriptRendering,
|
||||||
ScriptThreadEventCategory::ScriptEvent => ProfilerCategory::ScriptEvent,
|
ScriptThreadEventCategory::ScriptEvent => ProfilerCategory::ScriptEvent,
|
||||||
ScriptThreadEventCategory::ServiceWorkerEvent => {
|
ScriptThreadEventCategory::ServiceWorkerEvent => {
|
||||||
ProfilerCategory::ScriptServiceWorkerEvent
|
ProfilerCategory::ScriptServiceWorkerEvent
|
||||||
|
@ -223,6 +225,7 @@ impl From<ScriptThreadEventCategory> for ScriptHangAnnotation {
|
||||||
ScriptThreadEventCategory::ImageCacheMsg => ScriptHangAnnotation::ImageCacheMsg,
|
ScriptThreadEventCategory::ImageCacheMsg => ScriptHangAnnotation::ImageCacheMsg,
|
||||||
ScriptThreadEventCategory::InputEvent => ScriptHangAnnotation::InputEvent,
|
ScriptThreadEventCategory::InputEvent => ScriptHangAnnotation::InputEvent,
|
||||||
ScriptThreadEventCategory::NetworkEvent => ScriptHangAnnotation::NetworkEvent,
|
ScriptThreadEventCategory::NetworkEvent => ScriptHangAnnotation::NetworkEvent,
|
||||||
|
ScriptThreadEventCategory::Rendering => ScriptHangAnnotation::Rendering,
|
||||||
ScriptThreadEventCategory::Resize => ScriptHangAnnotation::Resize,
|
ScriptThreadEventCategory::Resize => ScriptHangAnnotation::Resize,
|
||||||
ScriptThreadEventCategory::ScriptEvent => ScriptHangAnnotation::ScriptEvent,
|
ScriptThreadEventCategory::ScriptEvent => ScriptHangAnnotation::ScriptEvent,
|
||||||
ScriptThreadEventCategory::SetScrollState => ScriptHangAnnotation::SetScrollState,
|
ScriptThreadEventCategory::SetScrollState => ScriptHangAnnotation::SetScrollState,
|
||||||
|
@ -376,7 +379,7 @@ unsafe extern "C" fn promise_rejection_tracker(
|
||||||
let trusted_promise = TrustedPromise::new(promise.clone());
|
let trusted_promise = TrustedPromise::new(promise.clone());
|
||||||
|
|
||||||
// Step 5-4.
|
// Step 5-4.
|
||||||
global.dom_manipulation_task_source().queue(
|
global.task_manager().dom_manipulation_task_source().queue(
|
||||||
task!(rejection_handled_event: move || {
|
task!(rejection_handled_event: move || {
|
||||||
let target = target.root();
|
let target = target.root();
|
||||||
let cx = GlobalScope::get_cx();
|
let cx = GlobalScope::get_cx();
|
||||||
|
@ -450,6 +453,7 @@ unsafe extern "C" fn content_security_policy_allows(
|
||||||
scripted_caller.col,
|
scripted_caller.col,
|
||||||
);
|
);
|
||||||
global
|
global
|
||||||
|
.task_manager()
|
||||||
.dom_manipulation_task_source()
|
.dom_manipulation_task_source()
|
||||||
.queue(task, &global)
|
.queue(task, &global)
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
@ -485,7 +489,7 @@ pub fn notify_about_rejected_promises(global: &GlobalScope) {
|
||||||
let target = Trusted::new(global.upcast::<EventTarget>());
|
let target = Trusted::new(global.upcast::<EventTarget>());
|
||||||
|
|
||||||
// Step 4.
|
// Step 4.
|
||||||
global.dom_manipulation_task_source().queue(
|
global.task_manager().dom_manipulation_task_source().queue(
|
||||||
task!(unhandled_rejection_event: move || {
|
task!(unhandled_rejection_event: move || {
|
||||||
let target = target.root();
|
let target = target.root();
|
||||||
let cx = GlobalScope::get_cx();
|
let cx = GlobalScope::get_cx();
|
||||||
|
@ -537,11 +541,11 @@ pub struct Runtime {
|
||||||
rt: RustRuntime,
|
rt: RustRuntime,
|
||||||
pub microtask_queue: Rc<MicrotaskQueue>,
|
pub microtask_queue: Rc<MicrotaskQueue>,
|
||||||
job_queue: *mut JobQueue,
|
job_queue: *mut JobQueue,
|
||||||
networking_task_src: Option<Box<NetworkingTaskSource>>,
|
networking_task_src: Option<Box<TaskSource>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Runtime {
|
impl Runtime {
|
||||||
/// Create a new runtime, optionally with the given [`NetworkingTaskSource`].
|
/// Create a new runtime, optionally with the given [`TaskSource`] for networking.
|
||||||
///
|
///
|
||||||
/// # Safety
|
/// # Safety
|
||||||
///
|
///
|
||||||
|
@ -551,11 +555,12 @@ impl Runtime {
|
||||||
///
|
///
|
||||||
/// This, like many calls to SpiderMoney API, is unsafe.
|
/// This, like many calls to SpiderMoney API, is unsafe.
|
||||||
#[allow(unsafe_code)]
|
#[allow(unsafe_code)]
|
||||||
pub(crate) fn new(networking_task_source: Option<NetworkingTaskSource>) -> Runtime {
|
pub(crate) fn new(networking_task_source: Option<TaskSource>) -> Runtime {
|
||||||
unsafe { Self::new_with_parent(None, networking_task_source) }
|
unsafe { Self::new_with_parent(None, networking_task_source) }
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Create a new runtime, optionally with the given [`ParentRuntime`] and [`NetworkingTaskSource`].
|
/// Create a new runtime, optionally with the given [`ParentRuntime`] and [`TaskSource`]
|
||||||
|
/// for networking.
|
||||||
///
|
///
|
||||||
/// # Safety
|
/// # Safety
|
||||||
///
|
///
|
||||||
|
@ -569,7 +574,7 @@ impl Runtime {
|
||||||
#[allow(unsafe_code)]
|
#[allow(unsafe_code)]
|
||||||
pub(crate) unsafe fn new_with_parent(
|
pub(crate) unsafe fn new_with_parent(
|
||||||
parent: Option<ParentRuntime>,
|
parent: Option<ParentRuntime>,
|
||||||
networking_task_source: Option<NetworkingTaskSource>,
|
networking_task_source: Option<TaskSource>,
|
||||||
) -> Runtime {
|
) -> Runtime {
|
||||||
LiveDOMReferences::initialize();
|
LiveDOMReferences::initialize();
|
||||||
let (cx, runtime) = if let Some(parent) = parent {
|
let (cx, runtime) = if let Some(parent) = parent {
|
||||||
|
@ -617,8 +622,7 @@ impl Runtime {
|
||||||
closure: *mut c_void,
|
closure: *mut c_void,
|
||||||
dispatchable: *mut JSRunnable,
|
dispatchable: *mut JSRunnable,
|
||||||
) -> bool {
|
) -> bool {
|
||||||
let networking_task_src: &NetworkingTaskSource =
|
let networking_task_src: &TaskSource = &*(closure as *mut TaskSource);
|
||||||
&*(closure as *mut NetworkingTaskSource);
|
|
||||||
let runnable = Runnable(dispatchable);
|
let runnable = Runnable(dispatchable);
|
||||||
let task = task!(dispatch_to_event_loop_message: move || {
|
let task = task!(dispatch_to_event_loop_message: move || {
|
||||||
if let Some(cx) = RustRuntime::get() {
|
if let Some(cx) = RustRuntime::get() {
|
||||||
|
|
|
@ -148,11 +148,11 @@ use crate::microtask::{Microtask, MicrotaskQueue};
|
||||||
use crate::realms::enter_realm;
|
use crate::realms::enter_realm;
|
||||||
use crate::script_module::ScriptFetchOptions;
|
use crate::script_module::ScriptFetchOptions;
|
||||||
use crate::script_runtime::{
|
use crate::script_runtime::{
|
||||||
CanGc, CommonScriptMsg, JSContext, Runtime, ScriptThreadEventCategory, ThreadSafeJSContext,
|
CanGc, CommonScriptMsg, JSContext, Runtime, ScriptChan, ScriptThreadEventCategory,
|
||||||
|
ThreadSafeJSContext,
|
||||||
};
|
};
|
||||||
use crate::task_manager::TaskManager;
|
use crate::task_manager::TaskManager;
|
||||||
use crate::task_queue::TaskQueue;
|
use crate::task_queue::TaskQueue;
|
||||||
use crate::task_source::networking::NetworkingTaskSource;
|
|
||||||
use crate::task_source::{TaskSource, TaskSourceName};
|
use crate::task_source::{TaskSource, TaskSourceName};
|
||||||
use crate::{devtools, webdriver_handlers};
|
use crate::{devtools, webdriver_handlers};
|
||||||
|
|
||||||
|
@ -690,6 +690,7 @@ impl ScriptThread {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
global
|
global
|
||||||
|
.task_manager()
|
||||||
.dom_manipulation_task_source()
|
.dom_manipulation_task_source()
|
||||||
.queue(task, global.upcast())
|
.queue(task, global.upcast())
|
||||||
.expect("Enqueing navigate js task on the DOM manipulation task source failed");
|
.expect("Enqueing navigate js task on the DOM manipulation task source failed");
|
||||||
|
@ -901,10 +902,11 @@ impl ScriptThread {
|
||||||
|
|
||||||
let (self_sender, self_receiver) = unbounded();
|
let (self_sender, self_receiver) = unbounded();
|
||||||
let self_sender = MainThreadScriptChan(self_sender.clone());
|
let self_sender = MainThreadScriptChan(self_sender.clone());
|
||||||
let runtime = Runtime::new(Some(NetworkingTaskSource(
|
let runtime = Runtime::new(Some(TaskSource {
|
||||||
Box::new(self_sender.clone()),
|
sender: self_sender.as_boxed(),
|
||||||
state.id,
|
pipeline_id: state.id,
|
||||||
)));
|
name: TaskSourceName::Networking,
|
||||||
|
}));
|
||||||
let cx = runtime.cx();
|
let cx = runtime.cx();
|
||||||
|
|
||||||
unsafe {
|
unsafe {
|
||||||
|
|
|
@ -9,35 +9,22 @@ use std::sync::Arc;
|
||||||
use base::id::PipelineId;
|
use base::id::PipelineId;
|
||||||
|
|
||||||
use crate::dom::bindings::cell::DomRefCell;
|
use crate::dom::bindings::cell::DomRefCell;
|
||||||
use crate::messaging::MainThreadScriptChan;
|
use crate::script_runtime::ScriptChan;
|
||||||
use crate::task::TaskCanceller;
|
use crate::task::TaskCanceller;
|
||||||
use crate::task_source::dom_manipulation::DOMManipulationTaskSource;
|
use crate::task_source::{TaskSource, TaskSourceName};
|
||||||
use crate::task_source::file_reading::FileReadingTaskSource;
|
|
||||||
use crate::task_source::gamepad::GamepadTaskSource;
|
|
||||||
use crate::task_source::history_traversal::HistoryTraversalTaskSource;
|
|
||||||
use crate::task_source::media_element::MediaElementTaskSource;
|
|
||||||
use crate::task_source::networking::NetworkingTaskSource;
|
|
||||||
use crate::task_source::performance_timeline::PerformanceTimelineTaskSource;
|
|
||||||
use crate::task_source::port_message::PortMessageQueue;
|
|
||||||
use crate::task_source::remote_event::RemoteEventTaskSource;
|
|
||||||
use crate::task_source::rendering::RenderingTaskSource;
|
|
||||||
use crate::task_source::timer::TimerTaskSource;
|
|
||||||
use crate::task_source::user_interaction::UserInteractionTaskSource;
|
|
||||||
use crate::task_source::websocket::WebsocketTaskSource;
|
|
||||||
use crate::task_source::TaskSourceName;
|
|
||||||
|
|
||||||
macro_rules! task_source_functions {
|
macro_rules! task_source_functions {
|
||||||
($self:ident, $task_source:ident, $task_source_type:ident, $task_source_name:ident) => {
|
($self:ident, $task_source:ident) => {
|
||||||
pub(crate) fn $task_source(&$self) -> $task_source_type {
|
pub(crate) fn $task_source(&$self) -> TaskSource {
|
||||||
$self.$task_source.clone()
|
$self.$task_source.clone()
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
($self:ident, $with_canceller:ident, $task_source:ident, $task_source_type:ident, $task_source_name:ident) => {
|
($self:ident, $with_canceller:ident, $task_source:ident) => {
|
||||||
pub(crate) fn $with_canceller(&$self) -> ($task_source_type, TaskCanceller) {
|
pub(crate) fn $with_canceller(&$self) -> (TaskSource, TaskCanceller) {
|
||||||
($self.$task_source.clone(), $self.task_canceller(TaskSourceName::$task_source_name))
|
($self.$task_source.clone(), $self.task_canceller($self.$task_source.name))
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) fn $task_source(&$self) -> $task_source_type {
|
pub(crate) fn $task_source(&$self) -> TaskSource {
|
||||||
$self.$task_source.clone()
|
$self.$task_source.clone()
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -47,57 +34,44 @@ macro_rules! task_source_functions {
|
||||||
pub struct TaskManager {
|
pub struct TaskManager {
|
||||||
#[ignore_malloc_size_of = "task sources are hard"]
|
#[ignore_malloc_size_of = "task sources are hard"]
|
||||||
pub task_cancellers: DomRefCell<HashMap<TaskSourceName, Arc<AtomicBool>>>,
|
pub task_cancellers: DomRefCell<HashMap<TaskSourceName, Arc<AtomicBool>>>,
|
||||||
#[ignore_malloc_size_of = "task sources are hard"]
|
dom_manipulation_task_source: TaskSource,
|
||||||
dom_manipulation_task_source: DOMManipulationTaskSource,
|
file_reading_task_source: TaskSource,
|
||||||
#[ignore_malloc_size_of = "task sources are hard"]
|
gamepad_task_source: TaskSource,
|
||||||
file_reading_task_source: FileReadingTaskSource,
|
history_traversal_task_source: TaskSource,
|
||||||
#[ignore_malloc_size_of = "task sources are hard"]
|
media_element_task_source: TaskSource,
|
||||||
gamepad_task_source: GamepadTaskSource,
|
networking_task_source: TaskSource,
|
||||||
#[ignore_malloc_size_of = "task sources are hard"]
|
performance_timeline_task_source: TaskSource,
|
||||||
history_traversal_task_source: HistoryTraversalTaskSource,
|
port_message_queue: TaskSource,
|
||||||
#[ignore_malloc_size_of = "task sources are hard"]
|
user_interaction_task_source: TaskSource,
|
||||||
media_element_task_source: MediaElementTaskSource,
|
remote_event_task_source: TaskSource,
|
||||||
#[ignore_malloc_size_of = "task sources are hard"]
|
rendering_task_source: TaskSource,
|
||||||
networking_task_source: NetworkingTaskSource,
|
timer_task_source: TaskSource,
|
||||||
#[ignore_malloc_size_of = "task sources are hard"]
|
websocket_task_source: TaskSource,
|
||||||
performance_timeline_task_source: PerformanceTimelineTaskSource,
|
|
||||||
#[ignore_malloc_size_of = "task sources are hard"]
|
|
||||||
port_message_queue: PortMessageQueue,
|
|
||||||
#[ignore_malloc_size_of = "task sources are hard"]
|
|
||||||
user_interaction_task_source: UserInteractionTaskSource,
|
|
||||||
#[ignore_malloc_size_of = "task sources are hard"]
|
|
||||||
remote_event_task_source: RemoteEventTaskSource,
|
|
||||||
#[ignore_malloc_size_of = "task sources are hard"]
|
|
||||||
rendering_task_source: RenderingTaskSource,
|
|
||||||
#[ignore_malloc_size_of = "task sources are hard"]
|
|
||||||
timer_task_source: TimerTaskSource,
|
|
||||||
#[ignore_malloc_size_of = "task sources are hard"]
|
|
||||||
websocket_task_source: WebsocketTaskSource,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
impl TaskManager {
|
impl TaskManager {
|
||||||
#[allow(clippy::too_many_arguments)]
|
#[allow(clippy::too_many_arguments)]
|
||||||
pub(crate) fn new(sender: Box<MainThreadScriptChan>, pipeline_id: PipelineId) -> Self {
|
pub(crate) fn new(sender: Box<dyn ScriptChan + Send>, pipeline_id: PipelineId) -> Self {
|
||||||
|
let task_source = |name| TaskSource {
|
||||||
|
sender: sender.as_boxed(),
|
||||||
|
pipeline_id,
|
||||||
|
name,
|
||||||
|
};
|
||||||
|
|
||||||
TaskManager {
|
TaskManager {
|
||||||
dom_manipulation_task_source: DOMManipulationTaskSource(sender.clone(), pipeline_id),
|
dom_manipulation_task_source: task_source(TaskSourceName::DOMManipulation),
|
||||||
file_reading_task_source: FileReadingTaskSource(sender.clone(), pipeline_id),
|
file_reading_task_source: task_source(TaskSourceName::FileReading),
|
||||||
gamepad_task_source: GamepadTaskSource(sender.clone(), pipeline_id),
|
gamepad_task_source: task_source(TaskSourceName::Gamepad),
|
||||||
history_traversal_task_source: HistoryTraversalTaskSource(
|
history_traversal_task_source: task_source(TaskSourceName::HistoryTraversal),
|
||||||
sender.0.clone(),
|
media_element_task_source: task_source(TaskSourceName::MediaElement),
|
||||||
pipeline_id,
|
networking_task_source: task_source(TaskSourceName::Networking),
|
||||||
),
|
performance_timeline_task_source: task_source(TaskSourceName::PerformanceTimeline),
|
||||||
media_element_task_source: MediaElementTaskSource(sender.0.clone(), pipeline_id),
|
port_message_queue: task_source(TaskSourceName::PortMessage),
|
||||||
networking_task_source: NetworkingTaskSource(sender.clone(), pipeline_id),
|
user_interaction_task_source: task_source(TaskSourceName::UserInteraction),
|
||||||
performance_timeline_task_source: PerformanceTimelineTaskSource(
|
remote_event_task_source: task_source(TaskSourceName::RemoteEvent),
|
||||||
sender.clone(),
|
rendering_task_source: task_source(TaskSourceName::Rendering),
|
||||||
pipeline_id,
|
timer_task_source: task_source(TaskSourceName::Timer),
|
||||||
),
|
websocket_task_source: task_source(TaskSourceName::WebSocket),
|
||||||
port_message_queue: PortMessageQueue(sender.clone(), pipeline_id),
|
|
||||||
user_interaction_task_source: UserInteractionTaskSource(sender.0.clone(), pipeline_id),
|
|
||||||
remote_event_task_source: RemoteEventTaskSource(sender.clone(), pipeline_id),
|
|
||||||
rendering_task_source: RenderingTaskSource(sender.clone(), pipeline_id),
|
|
||||||
timer_task_source: TimerTaskSource(sender.clone(), pipeline_id),
|
|
||||||
websocket_task_source: WebsocketTaskSource(sender.clone(), pipeline_id),
|
|
||||||
task_cancellers: Default::default(),
|
task_cancellers: Default::default(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -105,64 +79,27 @@ impl TaskManager {
|
||||||
task_source_functions!(
|
task_source_functions!(
|
||||||
self,
|
self,
|
||||||
dom_manipulation_task_source_with_canceller,
|
dom_manipulation_task_source_with_canceller,
|
||||||
dom_manipulation_task_source,
|
dom_manipulation_task_source
|
||||||
DOMManipulationTaskSource,
|
|
||||||
DOMManipulation
|
|
||||||
);
|
);
|
||||||
|
task_source_functions!(self, gamepad_task_source);
|
||||||
task_source_functions!(self, gamepad_task_source, GamepadTaskSource, Gamepad);
|
|
||||||
|
|
||||||
task_source_functions!(
|
task_source_functions!(
|
||||||
self,
|
self,
|
||||||
media_element_task_source_with_canceller,
|
media_element_task_source_with_canceller,
|
||||||
media_element_task_source,
|
media_element_task_source
|
||||||
MediaElementTaskSource,
|
|
||||||
MediaElement
|
|
||||||
);
|
);
|
||||||
|
task_source_functions!(self, user_interaction_task_source);
|
||||||
task_source_functions!(
|
|
||||||
self,
|
|
||||||
user_interaction_task_source,
|
|
||||||
UserInteractionTaskSource,
|
|
||||||
UserInteraction
|
|
||||||
);
|
|
||||||
|
|
||||||
task_source_functions!(
|
task_source_functions!(
|
||||||
self,
|
self,
|
||||||
networking_task_source_with_canceller,
|
networking_task_source_with_canceller,
|
||||||
networking_task_source,
|
networking_task_source
|
||||||
NetworkingTaskSource,
|
|
||||||
Networking
|
|
||||||
);
|
);
|
||||||
|
task_source_functions!(self, file_reading_task_source);
|
||||||
task_source_functions!(
|
task_source_functions!(self, performance_timeline_task_source);
|
||||||
self,
|
task_source_functions!(self, port_message_queue);
|
||||||
file_reading_task_source,
|
task_source_functions!(self, remote_event_task_source);
|
||||||
FileReadingTaskSource,
|
task_source_functions!(self, rendering_task_source);
|
||||||
FileReading
|
task_source_functions!(self, timer_task_source);
|
||||||
);
|
task_source_functions!(self, websocket_task_source);
|
||||||
|
|
||||||
task_source_functions!(
|
|
||||||
self,
|
|
||||||
performance_timeline_task_source,
|
|
||||||
PerformanceTimelineTaskSource,
|
|
||||||
PerformanceTimeline
|
|
||||||
);
|
|
||||||
|
|
||||||
task_source_functions!(self, port_message_queue, PortMessageQueue, PortMessage);
|
|
||||||
|
|
||||||
task_source_functions!(
|
|
||||||
self,
|
|
||||||
remote_event_task_source,
|
|
||||||
RemoteEventTaskSource,
|
|
||||||
RemoteEvent
|
|
||||||
);
|
|
||||||
|
|
||||||
task_source_functions!(self, rendering_task_source, RenderingTaskSource, Rendering);
|
|
||||||
|
|
||||||
task_source_functions!(self, timer_task_source, TimerTaskSource, Timer);
|
|
||||||
|
|
||||||
task_source_functions!(self, websocket_task_source, WebsocketTaskSource, Websocket);
|
|
||||||
|
|
||||||
pub fn task_canceller(&self, name: TaskSourceName) -> TaskCanceller {
|
pub fn task_canceller(&self, name: TaskSourceName) -> TaskCanceller {
|
||||||
let mut flags = self.task_cancellers.borrow_mut();
|
let mut flags = self.task_cancellers.borrow_mut();
|
||||||
|
|
174
components/script/task_source.rs
Normal file
174
components/script/task_source.rs
Normal file
|
@ -0,0 +1,174 @@
|
||||||
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||||
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||||
|
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
||||||
|
|
||||||
|
use std::fmt;
|
||||||
|
use std::result::Result;
|
||||||
|
|
||||||
|
use base::id::PipelineId;
|
||||||
|
use malloc_size_of_derive::MallocSizeOf;
|
||||||
|
use servo_atoms::Atom;
|
||||||
|
|
||||||
|
use crate::dom::bindings::inheritance::Castable;
|
||||||
|
use crate::dom::bindings::refcounted::Trusted;
|
||||||
|
use crate::dom::event::{EventBubbles, EventCancelable, EventTask, SimpleEventTask};
|
||||||
|
use crate::dom::eventtarget::EventTarget;
|
||||||
|
use crate::dom::types::GlobalScope;
|
||||||
|
use crate::dom::window::Window;
|
||||||
|
use crate::script_runtime::{CommonScriptMsg, ScriptChan, ScriptThreadEventCategory};
|
||||||
|
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.
|
||||||
|
///
|
||||||
|
/// Note: When adding or removing a [`TaskSourceName`], be sure to also update the return value of
|
||||||
|
/// [`TaskSourceName::all`].
|
||||||
|
#[derive(Clone, Copy, Debug, Eq, Hash, JSTraceable, MallocSizeOf, PartialEq)]
|
||||||
|
pub enum TaskSourceName {
|
||||||
|
DOMManipulation,
|
||||||
|
FileReading,
|
||||||
|
HistoryTraversal,
|
||||||
|
Networking,
|
||||||
|
PerformanceTimeline,
|
||||||
|
PortMessage,
|
||||||
|
UserInteraction,
|
||||||
|
RemoteEvent,
|
||||||
|
/// <https://html.spec.whatwg.org/multipage/#rendering-task-source>
|
||||||
|
Rendering,
|
||||||
|
MediaElement,
|
||||||
|
WebSocket,
|
||||||
|
Timer,
|
||||||
|
/// <https://www.w3.org/TR/gamepad/#dfn-gamepad-task-source>
|
||||||
|
Gamepad,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl From<TaskSourceName> for ScriptThreadEventCategory {
|
||||||
|
fn from(value: TaskSourceName) -> Self {
|
||||||
|
match value {
|
||||||
|
TaskSourceName::DOMManipulation => ScriptThreadEventCategory::ScriptEvent,
|
||||||
|
TaskSourceName::FileReading => ScriptThreadEventCategory::FileRead,
|
||||||
|
TaskSourceName::HistoryTraversal => ScriptThreadEventCategory::HistoryEvent,
|
||||||
|
TaskSourceName::Networking => ScriptThreadEventCategory::NetworkEvent,
|
||||||
|
TaskSourceName::PerformanceTimeline => {
|
||||||
|
ScriptThreadEventCategory::PerformanceTimelineTask
|
||||||
|
},
|
||||||
|
TaskSourceName::PortMessage => ScriptThreadEventCategory::PortMessage,
|
||||||
|
TaskSourceName::UserInteraction => ScriptThreadEventCategory::InputEvent,
|
||||||
|
TaskSourceName::RemoteEvent => ScriptThreadEventCategory::NetworkEvent,
|
||||||
|
TaskSourceName::Rendering => ScriptThreadEventCategory::Rendering,
|
||||||
|
TaskSourceName::MediaElement => ScriptThreadEventCategory::ScriptEvent,
|
||||||
|
TaskSourceName::WebSocket => ScriptThreadEventCategory::WebSocketEvent,
|
||||||
|
TaskSourceName::Timer => ScriptThreadEventCategory::TimerEvent,
|
||||||
|
TaskSourceName::Gamepad => ScriptThreadEventCategory::InputEvent,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl TaskSourceName {
|
||||||
|
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,
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(JSTraceable, MallocSizeOf)]
|
||||||
|
pub(crate) struct TaskSource {
|
||||||
|
#[ignore_malloc_size_of = "Need to push MallocSizeOf down into the ScriptChan trait implementations"]
|
||||||
|
pub sender: Box<dyn ScriptChan + Send + 'static>,
|
||||||
|
#[no_trace]
|
||||||
|
pub pipeline_id: PipelineId,
|
||||||
|
pub name: TaskSourceName,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl TaskSource {
|
||||||
|
pub(crate) fn queue_with_canceller<T>(
|
||||||
|
&self,
|
||||||
|
task: T,
|
||||||
|
canceller: &TaskCanceller,
|
||||||
|
) -> Result<(), ()>
|
||||||
|
where
|
||||||
|
T: TaskOnce + 'static,
|
||||||
|
{
|
||||||
|
let msg = CommonScriptMsg::Task(
|
||||||
|
self.name.into(),
|
||||||
|
Box::new(canceller.wrap_task(task)),
|
||||||
|
Some(self.pipeline_id),
|
||||||
|
self.name,
|
||||||
|
);
|
||||||
|
self.sender.send(msg).map_err(|_| ())
|
||||||
|
}
|
||||||
|
|
||||||
|
pub(crate) fn queue<T>(&self, task: T, global: &GlobalScope) -> Result<(), ()>
|
||||||
|
where
|
||||||
|
T: TaskOnce + 'static,
|
||||||
|
{
|
||||||
|
let canceller = global.task_canceller(self.name);
|
||||||
|
self.queue_with_canceller(task, &canceller)
|
||||||
|
}
|
||||||
|
|
||||||
|
/// This queues a task that will not be cancelled when its associated global scope gets destroyed.
|
||||||
|
pub(crate) fn queue_unconditionally<T>(&self, task: T) -> Result<(), ()>
|
||||||
|
where
|
||||||
|
T: TaskOnce + 'static,
|
||||||
|
{
|
||||||
|
self.sender.send(CommonScriptMsg::Task(
|
||||||
|
self.name.into(),
|
||||||
|
Box::new(task),
|
||||||
|
Some(self.pipeline_id),
|
||||||
|
self.name,
|
||||||
|
))
|
||||||
|
}
|
||||||
|
|
||||||
|
pub(crate) fn queue_simple_event(&self, target: &EventTarget, name: Atom, window: &Window) {
|
||||||
|
let target = Trusted::new(target);
|
||||||
|
let _ = self.queue(SimpleEventTask { target, name }, window.upcast());
|
||||||
|
}
|
||||||
|
|
||||||
|
pub(crate) fn queue_event(
|
||||||
|
&self,
|
||||||
|
target: &EventTarget,
|
||||||
|
name: Atom,
|
||||||
|
bubbles: EventBubbles,
|
||||||
|
cancelable: EventCancelable,
|
||||||
|
window: &Window,
|
||||||
|
) {
|
||||||
|
let target = Trusted::new(target);
|
||||||
|
let task = EventTask {
|
||||||
|
target,
|
||||||
|
name,
|
||||||
|
bubbles,
|
||||||
|
cancelable,
|
||||||
|
};
|
||||||
|
let _ = self.queue(task, window.upcast());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Clone for TaskSource {
|
||||||
|
fn clone(&self) -> Self {
|
||||||
|
Self {
|
||||||
|
sender: self.sender.as_boxed(),
|
||||||
|
pipeline_id: self.pipeline_id,
|
||||||
|
name: self.name,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl fmt::Debug for TaskSource {
|
||||||
|
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||||
|
write!(f, "{:?}(...)", self.name)
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,76 +0,0 @@
|
||||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
||||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
||||||
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
|
||||||
|
|
||||||
use std::fmt;
|
|
||||||
use std::result::Result;
|
|
||||||
|
|
||||||
use base::id::PipelineId;
|
|
||||||
use servo_atoms::Atom;
|
|
||||||
|
|
||||||
use crate::dom::bindings::inheritance::Castable;
|
|
||||||
use crate::dom::bindings::refcounted::Trusted;
|
|
||||||
use crate::dom::event::{EventBubbles, EventCancelable, EventTask, SimpleEventTask};
|
|
||||||
use crate::dom::eventtarget::EventTarget;
|
|
||||||
use crate::dom::window::Window;
|
|
||||||
use crate::script_runtime::{CommonScriptMsg, ScriptChan, ScriptThreadEventCategory};
|
|
||||||
use crate::task::{TaskCanceller, TaskOnce};
|
|
||||||
use crate::task_source::{TaskSource, TaskSourceName};
|
|
||||||
|
|
||||||
#[derive(JSTraceable)]
|
|
||||||
pub struct DOMManipulationTaskSource(pub Box<dyn ScriptChan + Send>, #[no_trace] pub PipelineId);
|
|
||||||
|
|
||||||
impl Clone for DOMManipulationTaskSource {
|
|
||||||
fn clone(&self) -> DOMManipulationTaskSource {
|
|
||||||
DOMManipulationTaskSource(self.0.as_boxed(), self.1)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl fmt::Debug for DOMManipulationTaskSource {
|
|
||||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
|
||||||
write!(f, "DOMManipulationTaskSource(...)")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl TaskSource for DOMManipulationTaskSource {
|
|
||||||
const NAME: TaskSourceName = TaskSourceName::DOMManipulation;
|
|
||||||
|
|
||||||
fn queue_with_canceller<T>(&self, task: T, canceller: &TaskCanceller) -> Result<(), ()>
|
|
||||||
where
|
|
||||||
T: TaskOnce + 'static,
|
|
||||||
{
|
|
||||||
let msg_task = CommonScriptMsg::Task(
|
|
||||||
ScriptThreadEventCategory::ScriptEvent,
|
|
||||||
Box::new(canceller.wrap_task(task)),
|
|
||||||
Some(self.1),
|
|
||||||
DOMManipulationTaskSource::NAME,
|
|
||||||
);
|
|
||||||
|
|
||||||
self.0.send(msg_task).map_err(|_| ())
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl DOMManipulationTaskSource {
|
|
||||||
pub fn queue_event(
|
|
||||||
&self,
|
|
||||||
target: &EventTarget,
|
|
||||||
name: Atom,
|
|
||||||
bubbles: EventBubbles,
|
|
||||||
cancelable: EventCancelable,
|
|
||||||
window: &Window,
|
|
||||||
) {
|
|
||||||
let target = Trusted::new(target);
|
|
||||||
let task = EventTask {
|
|
||||||
target,
|
|
||||||
name,
|
|
||||||
bubbles,
|
|
||||||
cancelable,
|
|
||||||
};
|
|
||||||
let _ = self.queue(task, window.upcast());
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn queue_simple_event(&self, target: &EventTarget, name: Atom, window: &Window) {
|
|
||||||
let target = Trusted::new(target);
|
|
||||||
let _ = self.queue(SimpleEventTask { target, name }, window.upcast());
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,72 +0,0 @@
|
||||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
||||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
||||||
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
|
||||||
|
|
||||||
use base::id::PipelineId;
|
|
||||||
|
|
||||||
use crate::dom::domexception::DOMErrorName;
|
|
||||||
use crate::dom::filereader::{FileReader, GenerationId, ReadMetaData, TrustedFileReader};
|
|
||||||
use crate::script_runtime::{CanGc, CommonScriptMsg, ScriptChan, ScriptThreadEventCategory};
|
|
||||||
use crate::task::{TaskCanceller, TaskOnce};
|
|
||||||
use crate::task_source::{TaskSource, TaskSourceName};
|
|
||||||
|
|
||||||
#[derive(JSTraceable)]
|
|
||||||
pub struct FileReadingTaskSource(
|
|
||||||
pub Box<dyn ScriptChan + Send + 'static>,
|
|
||||||
#[no_trace] pub PipelineId,
|
|
||||||
);
|
|
||||||
|
|
||||||
impl Clone for FileReadingTaskSource {
|
|
||||||
fn clone(&self) -> FileReadingTaskSource {
|
|
||||||
FileReadingTaskSource(self.0.as_boxed(), self.1)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl TaskSource for FileReadingTaskSource {
|
|
||||||
const NAME: TaskSourceName = TaskSourceName::FileReading;
|
|
||||||
|
|
||||||
fn queue_with_canceller<T>(&self, task: T, canceller: &TaskCanceller) -> Result<(), ()>
|
|
||||||
where
|
|
||||||
T: TaskOnce + 'static,
|
|
||||||
{
|
|
||||||
self.0.send(CommonScriptMsg::Task(
|
|
||||||
ScriptThreadEventCategory::FileRead,
|
|
||||||
Box::new(canceller.wrap_task(task)),
|
|
||||||
Some(self.1),
|
|
||||||
FileReadingTaskSource::NAME,
|
|
||||||
))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl TaskOnce for FileReadingTask {
|
|
||||||
fn run_once(self) {
|
|
||||||
self.handle_task(CanGc::note());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#[allow(dead_code)]
|
|
||||||
pub enum FileReadingTask {
|
|
||||||
ProcessRead(TrustedFileReader, GenerationId),
|
|
||||||
ProcessReadData(TrustedFileReader, GenerationId),
|
|
||||||
ProcessReadError(TrustedFileReader, GenerationId, DOMErrorName),
|
|
||||||
ProcessReadEOF(TrustedFileReader, GenerationId, ReadMetaData, Vec<u8>),
|
|
||||||
}
|
|
||||||
|
|
||||||
impl FileReadingTask {
|
|
||||||
pub fn handle_task(self, can_gc: CanGc) {
|
|
||||||
use self::FileReadingTask::*;
|
|
||||||
|
|
||||||
match self {
|
|
||||||
ProcessRead(reader, gen_id) => FileReader::process_read(reader, gen_id, can_gc),
|
|
||||||
ProcessReadData(reader, gen_id) => {
|
|
||||||
FileReader::process_read_data(reader, gen_id, can_gc)
|
|
||||||
},
|
|
||||||
ProcessReadError(reader, gen_id, error) => {
|
|
||||||
FileReader::process_read_error(reader, gen_id, error, can_gc)
|
|
||||||
},
|
|
||||||
ProcessReadEOF(reader, gen_id, metadata, blob_contents) => {
|
|
||||||
FileReader::process_read_eof(reader, gen_id, metadata, blob_contents, can_gc)
|
|
||||||
},
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,47 +0,0 @@
|
||||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
||||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
||||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
|
||||||
|
|
||||||
use std::fmt;
|
|
||||||
use std::result::Result;
|
|
||||||
|
|
||||||
use base::id::PipelineId;
|
|
||||||
|
|
||||||
use crate::script_runtime::{CommonScriptMsg, ScriptChan, ScriptThreadEventCategory};
|
|
||||||
use crate::task::{TaskCanceller, TaskOnce};
|
|
||||||
use crate::task_source::{TaskSource, TaskSourceName};
|
|
||||||
|
|
||||||
#[derive(JSTraceable)]
|
|
||||||
pub struct GamepadTaskSource(
|
|
||||||
pub Box<dyn ScriptChan + Send + 'static>,
|
|
||||||
#[no_trace] pub PipelineId,
|
|
||||||
);
|
|
||||||
|
|
||||||
impl Clone for GamepadTaskSource {
|
|
||||||
fn clone(&self) -> GamepadTaskSource {
|
|
||||||
GamepadTaskSource(self.0.as_boxed(), self.1)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl fmt::Debug for GamepadTaskSource {
|
|
||||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
|
||||||
write!(f, "GamepadTaskSource(...)")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl TaskSource for GamepadTaskSource {
|
|
||||||
const NAME: TaskSourceName = TaskSourceName::Gamepad;
|
|
||||||
|
|
||||||
fn queue_with_canceller<T>(&self, task: T, canceller: &TaskCanceller) -> Result<(), ()>
|
|
||||||
where
|
|
||||||
T: TaskOnce + 'static,
|
|
||||||
{
|
|
||||||
let msg = CommonScriptMsg::Task(
|
|
||||||
ScriptThreadEventCategory::InputEvent,
|
|
||||||
Box::new(canceller.wrap_task(task)),
|
|
||||||
Some(self.1),
|
|
||||||
GamepadTaskSource::NAME,
|
|
||||||
);
|
|
||||||
self.0.send(msg).map_err(|_| ())
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,34 +0,0 @@
|
||||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
||||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
||||||
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
|
||||||
|
|
||||||
use base::id::PipelineId;
|
|
||||||
use crossbeam_channel::Sender;
|
|
||||||
|
|
||||||
use crate::messaging::MainThreadScriptMsg;
|
|
||||||
use crate::script_runtime::{CommonScriptMsg, ScriptThreadEventCategory};
|
|
||||||
use crate::task::{TaskCanceller, TaskOnce};
|
|
||||||
use crate::task_source::{TaskSource, TaskSourceName};
|
|
||||||
|
|
||||||
#[derive(Clone, JSTraceable)]
|
|
||||||
pub(crate) struct HistoryTraversalTaskSource(
|
|
||||||
#[no_trace] pub Sender<MainThreadScriptMsg>,
|
|
||||||
#[no_trace] pub PipelineId,
|
|
||||||
);
|
|
||||||
|
|
||||||
impl TaskSource for HistoryTraversalTaskSource {
|
|
||||||
const NAME: TaskSourceName = TaskSourceName::HistoryTraversal;
|
|
||||||
|
|
||||||
fn queue_with_canceller<T>(&self, task: T, canceller: &TaskCanceller) -> Result<(), ()>
|
|
||||||
where
|
|
||||||
T: TaskOnce + 'static,
|
|
||||||
{
|
|
||||||
let msg = MainThreadScriptMsg::Common(CommonScriptMsg::Task(
|
|
||||||
ScriptThreadEventCategory::HistoryEvent,
|
|
||||||
Box::new(canceller.wrap_task(task)),
|
|
||||||
Some(self.1),
|
|
||||||
HistoryTraversalTaskSource::NAME,
|
|
||||||
));
|
|
||||||
self.0.send(msg).map_err(|_| ())
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,56 +0,0 @@
|
||||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
||||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
||||||
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
|
||||||
|
|
||||||
use std::fmt;
|
|
||||||
use std::result::Result;
|
|
||||||
|
|
||||||
use base::id::PipelineId;
|
|
||||||
use crossbeam_channel::Sender;
|
|
||||||
use servo_atoms::Atom;
|
|
||||||
|
|
||||||
use crate::dom::bindings::inheritance::Castable;
|
|
||||||
use crate::dom::bindings::refcounted::Trusted;
|
|
||||||
use crate::dom::event::SimpleEventTask;
|
|
||||||
use crate::dom::eventtarget::EventTarget;
|
|
||||||
use crate::dom::window::Window;
|
|
||||||
use crate::messaging::MainThreadScriptMsg;
|
|
||||||
use crate::script_runtime::{CommonScriptMsg, ScriptThreadEventCategory};
|
|
||||||
use crate::task::{TaskCanceller, TaskOnce};
|
|
||||||
use crate::task_source::{TaskSource, TaskSourceName};
|
|
||||||
|
|
||||||
#[derive(Clone, JSTraceable)]
|
|
||||||
pub(crate) struct MediaElementTaskSource(
|
|
||||||
#[no_trace] pub Sender<MainThreadScriptMsg>,
|
|
||||||
#[no_trace] pub PipelineId,
|
|
||||||
);
|
|
||||||
|
|
||||||
impl fmt::Debug for MediaElementTaskSource {
|
|
||||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
|
||||||
write!(f, "MediaElementTaskSource(...)")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl TaskSource for MediaElementTaskSource {
|
|
||||||
const NAME: TaskSourceName = TaskSourceName::MediaElement;
|
|
||||||
|
|
||||||
fn queue_with_canceller<T>(&self, task: T, canceller: &TaskCanceller) -> Result<(), ()>
|
|
||||||
where
|
|
||||||
T: TaskOnce + 'static,
|
|
||||||
{
|
|
||||||
let msg = MainThreadScriptMsg::Common(CommonScriptMsg::Task(
|
|
||||||
ScriptThreadEventCategory::ScriptEvent,
|
|
||||||
Box::new(canceller.wrap_task(task)),
|
|
||||||
Some(self.1),
|
|
||||||
MediaElementTaskSource::NAME,
|
|
||||||
));
|
|
||||||
self.0.send(msg).map_err(|_| ())
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl MediaElementTaskSource {
|
|
||||||
pub fn queue_simple_event(&self, target: &EventTarget, name: Atom, window: &Window) {
|
|
||||||
let target = Trusted::new(target);
|
|
||||||
let _ = self.queue(SimpleEventTask { target, name }, window.upcast());
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,83 +0,0 @@
|
||||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
||||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
||||||
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
|
||||||
|
|
||||||
pub mod dom_manipulation;
|
|
||||||
pub mod file_reading;
|
|
||||||
pub mod gamepad;
|
|
||||||
pub mod history_traversal;
|
|
||||||
pub mod media_element;
|
|
||||||
pub mod networking;
|
|
||||||
pub mod performance_timeline;
|
|
||||||
pub mod port_message;
|
|
||||||
pub mod remote_event;
|
|
||||||
pub mod rendering;
|
|
||||||
pub mod timer;
|
|
||||||
pub mod user_interaction;
|
|
||||||
pub mod websocket;
|
|
||||||
|
|
||||||
use std::result::Result;
|
|
||||||
|
|
||||||
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.
|
|
||||||
///
|
|
||||||
/// 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,
|
|
||||||
HistoryTraversal,
|
|
||||||
Networking,
|
|
||||||
PerformanceTimeline,
|
|
||||||
PortMessage,
|
|
||||||
UserInteraction,
|
|
||||||
RemoteEvent,
|
|
||||||
/// <https://html.spec.whatwg.org/multipage/#rendering-task-source>
|
|
||||||
Rendering,
|
|
||||||
MediaElement,
|
|
||||||
Websocket,
|
|
||||||
Timer,
|
|
||||||
/// <https://www.w3.org/TR/gamepad/#dfn-gamepad-task-source>
|
|
||||||
Gamepad,
|
|
||||||
}
|
|
||||||
|
|
||||||
impl TaskSourceName {
|
|
||||||
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,
|
|
||||||
]
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
pub trait TaskSource {
|
|
||||||
const NAME: TaskSourceName;
|
|
||||||
|
|
||||||
fn queue_with_canceller<T>(&self, task: T, canceller: &TaskCanceller) -> Result<(), ()>
|
|
||||||
where
|
|
||||||
T: TaskOnce + 'static;
|
|
||||||
|
|
||||||
fn queue<T>(&self, task: T, global: &GlobalScope) -> Result<(), ()>
|
|
||||||
where
|
|
||||||
T: TaskOnce + 'static,
|
|
||||||
{
|
|
||||||
let canceller = global.task_canceller(Self::NAME);
|
|
||||||
self.queue_with_canceller(task, &canceller)
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,53 +0,0 @@
|
||||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
||||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
||||||
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
|
||||||
|
|
||||||
use base::id::PipelineId;
|
|
||||||
|
|
||||||
use crate::script_runtime::{CommonScriptMsg, ScriptChan, ScriptThreadEventCategory};
|
|
||||||
use crate::task::{TaskCanceller, TaskOnce};
|
|
||||||
use crate::task_source::{TaskSource, TaskSourceName};
|
|
||||||
|
|
||||||
#[derive(JSTraceable)]
|
|
||||||
pub struct NetworkingTaskSource(
|
|
||||||
pub Box<dyn ScriptChan + Send + 'static>,
|
|
||||||
#[no_trace] pub PipelineId,
|
|
||||||
);
|
|
||||||
|
|
||||||
impl Clone for NetworkingTaskSource {
|
|
||||||
fn clone(&self) -> NetworkingTaskSource {
|
|
||||||
NetworkingTaskSource(self.0.as_boxed(), self.1)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl TaskSource for NetworkingTaskSource {
|
|
||||||
const NAME: TaskSourceName = TaskSourceName::Networking;
|
|
||||||
|
|
||||||
fn queue_with_canceller<T>(&self, task: T, canceller: &TaskCanceller) -> Result<(), ()>
|
|
||||||
where
|
|
||||||
T: TaskOnce + 'static,
|
|
||||||
{
|
|
||||||
self.0.send(CommonScriptMsg::Task(
|
|
||||||
ScriptThreadEventCategory::NetworkEvent,
|
|
||||||
Box::new(canceller.wrap_task(task)),
|
|
||||||
Some(self.1),
|
|
||||||
NetworkingTaskSource::NAME,
|
|
||||||
))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl NetworkingTaskSource {
|
|
||||||
/// This queues a task that will not be cancelled when its associated
|
|
||||||
/// global scope gets destroyed.
|
|
||||||
pub fn queue_unconditionally<T>(&self, task: T) -> Result<(), ()>
|
|
||||||
where
|
|
||||||
T: TaskOnce + 'static,
|
|
||||||
{
|
|
||||||
self.0.send(CommonScriptMsg::Task(
|
|
||||||
ScriptThreadEventCategory::NetworkEvent,
|
|
||||||
Box::new(task),
|
|
||||||
Some(self.1),
|
|
||||||
NetworkingTaskSource::NAME,
|
|
||||||
))
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,66 +0,0 @@
|
||||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
||||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
||||||
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
|
||||||
|
|
||||||
// XXX The spec says that the performance timeline task source should be
|
|
||||||
// a low priority task and it should be processed during idle periods.
|
|
||||||
// We are currently treating this task queue as a normal priority queue.
|
|
||||||
|
|
||||||
use std::fmt;
|
|
||||||
use std::result::Result;
|
|
||||||
|
|
||||||
use base::id::PipelineId;
|
|
||||||
|
|
||||||
use crate::dom::bindings::refcounted::Trusted;
|
|
||||||
use crate::dom::globalscope::GlobalScope;
|
|
||||||
use crate::script_runtime::{CommonScriptMsg, ScriptChan, ScriptThreadEventCategory};
|
|
||||||
use crate::task::{TaskCanceller, TaskOnce};
|
|
||||||
use crate::task_source::{TaskSource, TaskSourceName};
|
|
||||||
|
|
||||||
#[derive(JSTraceable)]
|
|
||||||
pub struct PerformanceTimelineTaskSource(
|
|
||||||
pub Box<dyn ScriptChan + Send + 'static>,
|
|
||||||
#[no_trace] pub PipelineId,
|
|
||||||
);
|
|
||||||
|
|
||||||
impl Clone for PerformanceTimelineTaskSource {
|
|
||||||
fn clone(&self) -> PerformanceTimelineTaskSource {
|
|
||||||
PerformanceTimelineTaskSource(self.0.as_boxed(), self.1)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl fmt::Debug for PerformanceTimelineTaskSource {
|
|
||||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
|
||||||
write!(f, "PerformanceTimelineTaskSource(...)")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl TaskSource for PerformanceTimelineTaskSource {
|
|
||||||
const NAME: TaskSourceName = TaskSourceName::PerformanceTimeline;
|
|
||||||
|
|
||||||
fn queue_with_canceller<T>(&self, task: T, canceller: &TaskCanceller) -> Result<(), ()>
|
|
||||||
where
|
|
||||||
T: TaskOnce + 'static,
|
|
||||||
{
|
|
||||||
let msg = CommonScriptMsg::Task(
|
|
||||||
ScriptThreadEventCategory::PerformanceTimelineTask,
|
|
||||||
Box::new(canceller.wrap_task(task)),
|
|
||||||
Some(self.1),
|
|
||||||
PerformanceTimelineTaskSource::NAME,
|
|
||||||
);
|
|
||||||
self.0.send(msg).map_err(|_| ())
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl PerformanceTimelineTaskSource {
|
|
||||||
pub fn queue_notification(&self, global: &GlobalScope) {
|
|
||||||
let owner = Trusted::new(&*global.performance());
|
|
||||||
// FIXME(nox): Why are errors silenced here?
|
|
||||||
let _ = self.queue(
|
|
||||||
task!(notify_performance_observers: move || {
|
|
||||||
owner.root().notify_observers();
|
|
||||||
}),
|
|
||||||
global,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,46 +0,0 @@
|
||||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
||||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
||||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
|
||||||
|
|
||||||
use std::fmt;
|
|
||||||
|
|
||||||
use base::id::PipelineId;
|
|
||||||
|
|
||||||
use crate::script_runtime::{CommonScriptMsg, ScriptChan, ScriptThreadEventCategory};
|
|
||||||
use crate::task::{TaskCanceller, TaskOnce};
|
|
||||||
use crate::task_source::{TaskSource, TaskSourceName};
|
|
||||||
|
|
||||||
#[derive(JSTraceable)]
|
|
||||||
pub struct PortMessageQueue(
|
|
||||||
pub Box<dyn ScriptChan + Send + 'static>,
|
|
||||||
#[no_trace] pub PipelineId,
|
|
||||||
);
|
|
||||||
|
|
||||||
impl Clone for PortMessageQueue {
|
|
||||||
fn clone(&self) -> PortMessageQueue {
|
|
||||||
PortMessageQueue(self.0.as_boxed(), self.1)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl fmt::Debug for PortMessageQueue {
|
|
||||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
|
||||||
write!(f, "PortMessageQueue(...)")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl TaskSource for PortMessageQueue {
|
|
||||||
const NAME: TaskSourceName = TaskSourceName::PortMessage;
|
|
||||||
|
|
||||||
fn queue_with_canceller<T>(&self, task: T, canceller: &TaskCanceller) -> Result<(), ()>
|
|
||||||
where
|
|
||||||
T: TaskOnce + 'static,
|
|
||||||
{
|
|
||||||
let msg = CommonScriptMsg::Task(
|
|
||||||
ScriptThreadEventCategory::PortMessage,
|
|
||||||
Box::new(canceller.wrap_task(task)),
|
|
||||||
Some(self.1),
|
|
||||||
Self::NAME,
|
|
||||||
);
|
|
||||||
self.0.send(msg).map_err(|_| ())
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,37 +0,0 @@
|
||||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
||||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
||||||
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
|
||||||
|
|
||||||
use base::id::PipelineId;
|
|
||||||
|
|
||||||
use crate::script_runtime::{CommonScriptMsg, ScriptChan, ScriptThreadEventCategory};
|
|
||||||
use crate::task::{TaskCanceller, TaskOnce};
|
|
||||||
use crate::task_source::{TaskSource, TaskSourceName};
|
|
||||||
|
|
||||||
#[derive(JSTraceable)]
|
|
||||||
pub struct RemoteEventTaskSource(
|
|
||||||
pub Box<dyn ScriptChan + Send + 'static>,
|
|
||||||
#[no_trace] pub PipelineId,
|
|
||||||
);
|
|
||||||
|
|
||||||
impl Clone for RemoteEventTaskSource {
|
|
||||||
fn clone(&self) -> RemoteEventTaskSource {
|
|
||||||
RemoteEventTaskSource(self.0.as_boxed(), self.1)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl TaskSource for RemoteEventTaskSource {
|
|
||||||
const NAME: TaskSourceName = TaskSourceName::RemoteEvent;
|
|
||||||
|
|
||||||
fn queue_with_canceller<T>(&self, task: T, canceller: &TaskCanceller) -> Result<(), ()>
|
|
||||||
where
|
|
||||||
T: TaskOnce + 'static,
|
|
||||||
{
|
|
||||||
self.0.send(CommonScriptMsg::Task(
|
|
||||||
ScriptThreadEventCategory::NetworkEvent,
|
|
||||||
Box::new(canceller.wrap_task(task)),
|
|
||||||
Some(self.1),
|
|
||||||
RemoteEventTaskSource::NAME,
|
|
||||||
))
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,61 +0,0 @@
|
||||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
||||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
||||||
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
|
||||||
|
|
||||||
use std::fmt;
|
|
||||||
use std::result::Result;
|
|
||||||
|
|
||||||
use base::id::PipelineId;
|
|
||||||
|
|
||||||
use crate::script_runtime::{CommonScriptMsg, ScriptChan, ScriptThreadEventCategory};
|
|
||||||
use crate::task::{TaskCanceller, TaskOnce};
|
|
||||||
use crate::task_source::{TaskSource, TaskSourceName};
|
|
||||||
|
|
||||||
#[derive(JSTraceable)]
|
|
||||||
pub struct RenderingTaskSource(pub Box<dyn ScriptChan + Send>, #[no_trace] pub PipelineId);
|
|
||||||
|
|
||||||
impl Clone for RenderingTaskSource {
|
|
||||||
fn clone(&self) -> RenderingTaskSource {
|
|
||||||
RenderingTaskSource(self.0.as_boxed(), self.1)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl fmt::Debug for RenderingTaskSource {
|
|
||||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
|
||||||
write!(f, "RenderingTaskSource(...)")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl TaskSource for RenderingTaskSource {
|
|
||||||
const NAME: TaskSourceName = TaskSourceName::Rendering;
|
|
||||||
|
|
||||||
fn queue_with_canceller<T>(&self, task: T, canceller: &TaskCanceller) -> Result<(), ()>
|
|
||||||
where
|
|
||||||
T: TaskOnce + 'static,
|
|
||||||
{
|
|
||||||
let msg_task = CommonScriptMsg::Task(
|
|
||||||
ScriptThreadEventCategory::ScriptEvent,
|
|
||||||
Box::new(canceller.wrap_task(task)),
|
|
||||||
Some(self.1),
|
|
||||||
RenderingTaskSource::NAME,
|
|
||||||
);
|
|
||||||
|
|
||||||
self.0.send(msg_task).map_err(|_| ())
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl RenderingTaskSource {
|
|
||||||
/// This queues a task that will not be cancelled when its associated
|
|
||||||
/// global scope gets destroyed.
|
|
||||||
pub fn queue_unconditionally<T>(&self, task: T) -> Result<(), ()>
|
|
||||||
where
|
|
||||||
T: TaskOnce + 'static,
|
|
||||||
{
|
|
||||||
self.0.send(CommonScriptMsg::Task(
|
|
||||||
ScriptThreadEventCategory::NetworkEvent,
|
|
||||||
Box::new(task),
|
|
||||||
Some(self.1),
|
|
||||||
RenderingTaskSource::NAME,
|
|
||||||
))
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,47 +0,0 @@
|
||||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
||||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
||||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
|
||||||
|
|
||||||
use std::fmt;
|
|
||||||
|
|
||||||
use base::id::PipelineId;
|
|
||||||
|
|
||||||
use crate::script_runtime::{CommonScriptMsg, ScriptChan, ScriptThreadEventCategory};
|
|
||||||
use crate::task::{TaskCanceller, TaskOnce};
|
|
||||||
use crate::task_source::{TaskSource, TaskSourceName};
|
|
||||||
|
|
||||||
#[derive(JSTraceable)]
|
|
||||||
/// <https://html.spec.whatwg.org/multipage/#timer-task-source>
|
|
||||||
pub struct TimerTaskSource(
|
|
||||||
pub Box<dyn ScriptChan + Send + 'static>,
|
|
||||||
#[no_trace] pub PipelineId,
|
|
||||||
);
|
|
||||||
|
|
||||||
impl Clone for TimerTaskSource {
|
|
||||||
fn clone(&self) -> TimerTaskSource {
|
|
||||||
TimerTaskSource(self.0.as_boxed(), self.1)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl fmt::Debug for TimerTaskSource {
|
|
||||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
|
||||||
write!(f, "TimerTaskSource(...)")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl TaskSource for TimerTaskSource {
|
|
||||||
const NAME: TaskSourceName = TaskSourceName::Timer;
|
|
||||||
|
|
||||||
fn queue_with_canceller<T>(&self, task: T, canceller: &TaskCanceller) -> Result<(), ()>
|
|
||||||
where
|
|
||||||
T: TaskOnce + 'static,
|
|
||||||
{
|
|
||||||
let msg = CommonScriptMsg::Task(
|
|
||||||
ScriptThreadEventCategory::TimerEvent,
|
|
||||||
Box::new(canceller.wrap_task(task)),
|
|
||||||
Some(self.1),
|
|
||||||
Self::NAME,
|
|
||||||
);
|
|
||||||
self.0.send(msg).map_err(|_| ())
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,69 +0,0 @@
|
||||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
||||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
||||||
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
|
||||||
|
|
||||||
use std::fmt;
|
|
||||||
use std::result::Result;
|
|
||||||
|
|
||||||
use base::id::PipelineId;
|
|
||||||
use crossbeam_channel::Sender;
|
|
||||||
use servo_atoms::Atom;
|
|
||||||
|
|
||||||
use crate::dom::bindings::inheritance::Castable;
|
|
||||||
use crate::dom::bindings::refcounted::Trusted;
|
|
||||||
use crate::dom::event::{EventBubbles, EventCancelable, EventTask};
|
|
||||||
use crate::dom::eventtarget::EventTarget;
|
|
||||||
use crate::dom::window::Window;
|
|
||||||
use crate::messaging::MainThreadScriptMsg;
|
|
||||||
use crate::script_runtime::{CommonScriptMsg, ScriptThreadEventCategory};
|
|
||||||
use crate::task::{TaskCanceller, TaskOnce};
|
|
||||||
use crate::task_source::{TaskSource, TaskSourceName};
|
|
||||||
|
|
||||||
#[derive(Clone, JSTraceable)]
|
|
||||||
pub struct UserInteractionTaskSource(
|
|
||||||
#[no_trace] pub Sender<MainThreadScriptMsg>,
|
|
||||||
#[no_trace] pub PipelineId,
|
|
||||||
);
|
|
||||||
|
|
||||||
impl fmt::Debug for UserInteractionTaskSource {
|
|
||||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
|
||||||
write!(f, "UserInteractionTaskSource(...)")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl TaskSource for UserInteractionTaskSource {
|
|
||||||
const NAME: TaskSourceName = TaskSourceName::UserInteraction;
|
|
||||||
|
|
||||||
fn queue_with_canceller<T>(&self, task: T, canceller: &TaskCanceller) -> Result<(), ()>
|
|
||||||
where
|
|
||||||
T: TaskOnce + 'static,
|
|
||||||
{
|
|
||||||
let msg = MainThreadScriptMsg::Common(CommonScriptMsg::Task(
|
|
||||||
ScriptThreadEventCategory::InputEvent,
|
|
||||||
Box::new(canceller.wrap_task(task)),
|
|
||||||
Some(self.1),
|
|
||||||
UserInteractionTaskSource::NAME,
|
|
||||||
));
|
|
||||||
self.0.send(msg).map_err(|_| ())
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl UserInteractionTaskSource {
|
|
||||||
pub fn queue_event(
|
|
||||||
&self,
|
|
||||||
target: &EventTarget,
|
|
||||||
name: Atom,
|
|
||||||
bubbles: EventBubbles,
|
|
||||||
cancelable: EventCancelable,
|
|
||||||
window: &Window,
|
|
||||||
) {
|
|
||||||
let target = Trusted::new(target);
|
|
||||||
let task = EventTask {
|
|
||||||
target,
|
|
||||||
name,
|
|
||||||
bubbles,
|
|
||||||
cancelable,
|
|
||||||
};
|
|
||||||
let _ = self.queue(task, window.upcast());
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,37 +0,0 @@
|
||||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
||||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
||||||
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
|
||||||
|
|
||||||
use base::id::PipelineId;
|
|
||||||
|
|
||||||
use crate::script_runtime::{CommonScriptMsg, ScriptChan, ScriptThreadEventCategory};
|
|
||||||
use crate::task::{TaskCanceller, TaskOnce};
|
|
||||||
use crate::task_source::{TaskSource, TaskSourceName};
|
|
||||||
|
|
||||||
#[derive(JSTraceable)]
|
|
||||||
pub struct WebsocketTaskSource(
|
|
||||||
pub Box<dyn ScriptChan + Send + 'static>,
|
|
||||||
#[no_trace] pub PipelineId,
|
|
||||||
);
|
|
||||||
|
|
||||||
impl Clone for WebsocketTaskSource {
|
|
||||||
fn clone(&self) -> WebsocketTaskSource {
|
|
||||||
WebsocketTaskSource(self.0.as_boxed(), self.1)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl TaskSource for WebsocketTaskSource {
|
|
||||||
const NAME: TaskSourceName = TaskSourceName::Websocket;
|
|
||||||
|
|
||||||
fn queue_with_canceller<T>(&self, task: T, canceller: &TaskCanceller) -> Result<(), ()>
|
|
||||||
where
|
|
||||||
T: TaskOnce + 'static,
|
|
||||||
{
|
|
||||||
self.0.send(CommonScriptMsg::Task(
|
|
||||||
ScriptThreadEventCategory::NetworkEvent,
|
|
||||||
Box::new(canceller.wrap_task(task)),
|
|
||||||
Some(self.1),
|
|
||||||
WebsocketTaskSource::NAME,
|
|
||||||
))
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -27,6 +27,7 @@ pub enum ScriptHangAnnotation {
|
||||||
InputEvent,
|
InputEvent,
|
||||||
HistoryEvent,
|
HistoryEvent,
|
||||||
NetworkEvent,
|
NetworkEvent,
|
||||||
|
Rendering,
|
||||||
Resize,
|
Resize,
|
||||||
ScriptEvent,
|
ScriptEvent,
|
||||||
SetScrollState,
|
SetScrollState,
|
||||||
|
|
|
@ -100,20 +100,21 @@ pub enum ProfilerCategory {
|
||||||
|
|
||||||
ScriptPlannedNavigation = 0x6c,
|
ScriptPlannedNavigation = 0x6c,
|
||||||
ScriptResize = 0x6d,
|
ScriptResize = 0x6d,
|
||||||
ScriptSetScrollState = 0x6e,
|
ScriptRendering = 0x6e,
|
||||||
ScriptSetViewport = 0x6f,
|
ScriptSetScrollState = 0x6f,
|
||||||
ScriptTimerEvent = 0x70,
|
ScriptSetViewport = 0x70,
|
||||||
ScriptStylesheetLoad = 0x71,
|
ScriptTimerEvent = 0x71,
|
||||||
ScriptUpdateReplacedElement = 0x72,
|
ScriptStylesheetLoad = 0x72,
|
||||||
ScriptWebSocketEvent = 0x73,
|
ScriptUpdateReplacedElement = 0x73,
|
||||||
ScriptWorkerEvent = 0x74,
|
ScriptWebSocketEvent = 0x74,
|
||||||
ScriptServiceWorkerEvent = 0x75,
|
ScriptWorkerEvent = 0x75,
|
||||||
|
ScriptServiceWorkerEvent = 0x76,
|
||||||
|
|
||||||
/// The script thread is parsing XML, rather than doing other work like evaluating scripts or doing layout.
|
/// The script thread is parsing XML, rather than doing other work like evaluating scripts or doing layout.
|
||||||
ScriptParseXML = 0x76,
|
ScriptParseXML = 0x77,
|
||||||
|
|
||||||
ScriptEnterFullscreen = 0x77,
|
ScriptEnterFullscreen = 0x78,
|
||||||
ScriptExitFullscreen = 0x78,
|
ScriptExitFullscreen = 0x79,
|
||||||
ScriptWorkletEvent = 0x7a,
|
ScriptWorkletEvent = 0x7a,
|
||||||
ScriptPerformanceEvent = 0x7b,
|
ScriptPerformanceEvent = 0x7b,
|
||||||
ScriptHistoryEvent = 0x7c,
|
ScriptHistoryEvent = 0x7c,
|
||||||
|
@ -157,6 +158,7 @@ impl ProfilerCategory {
|
||||||
ProfilerCategory::ScriptNetworkEvent => "ScriptNetworkEvent",
|
ProfilerCategory::ScriptNetworkEvent => "ScriptNetworkEvent",
|
||||||
ProfilerCategory::ScriptParseHTML => "ScriptParseHTML",
|
ProfilerCategory::ScriptParseHTML => "ScriptParseHTML",
|
||||||
ProfilerCategory::ScriptPlannedNavigation => "ScriptPlannedNavigation",
|
ProfilerCategory::ScriptPlannedNavigation => "ScriptPlannedNavigation",
|
||||||
|
ProfilerCategory::ScriptRendering => "ScriptRendering",
|
||||||
ProfilerCategory::ScriptResize => "ScriptResize",
|
ProfilerCategory::ScriptResize => "ScriptResize",
|
||||||
ProfilerCategory::ScriptSetScrollState => "ScriptSetScrollState",
|
ProfilerCategory::ScriptSetScrollState => "ScriptSetScrollState",
|
||||||
ProfilerCategory::ScriptSetViewport => "ScriptSetViewport",
|
ProfilerCategory::ScriptSetViewport => "ScriptSetViewport",
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue