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:
Martin Robinson 2025-01-01 14:50:52 +01:00 committed by GitHub
parent deb819f233
commit 77cfca65c4
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
67 changed files with 432 additions and 1200 deletions

View file

@ -27,6 +27,7 @@ pub enum ScriptHangAnnotation {
InputEvent,
HistoryEvent,
NetworkEvent,
Rendering,
Resize,
ScriptEvent,
SetScrollState,

View file

@ -100,20 +100,21 @@ pub enum ProfilerCategory {
ScriptPlannedNavigation = 0x6c,
ScriptResize = 0x6d,
ScriptSetScrollState = 0x6e,
ScriptSetViewport = 0x6f,
ScriptTimerEvent = 0x70,
ScriptStylesheetLoad = 0x71,
ScriptUpdateReplacedElement = 0x72,
ScriptWebSocketEvent = 0x73,
ScriptWorkerEvent = 0x74,
ScriptServiceWorkerEvent = 0x75,
ScriptRendering = 0x6e,
ScriptSetScrollState = 0x6f,
ScriptSetViewport = 0x70,
ScriptTimerEvent = 0x71,
ScriptStylesheetLoad = 0x72,
ScriptUpdateReplacedElement = 0x73,
ScriptWebSocketEvent = 0x74,
ScriptWorkerEvent = 0x75,
ScriptServiceWorkerEvent = 0x76,
/// The script thread is parsing XML, rather than doing other work like evaluating scripts or doing layout.
ScriptParseXML = 0x76,
ScriptParseXML = 0x77,
ScriptEnterFullscreen = 0x77,
ScriptExitFullscreen = 0x78,
ScriptEnterFullscreen = 0x78,
ScriptExitFullscreen = 0x79,
ScriptWorkletEvent = 0x7a,
ScriptPerformanceEvent = 0x7b,
ScriptHistoryEvent = 0x7c,
@ -157,6 +158,7 @@ impl ProfilerCategory {
ProfilerCategory::ScriptNetworkEvent => "ScriptNetworkEvent",
ProfilerCategory::ScriptParseHTML => "ScriptParseHTML",
ProfilerCategory::ScriptPlannedNavigation => "ScriptPlannedNavigation",
ProfilerCategory::ScriptRendering => "ScriptRendering",
ProfilerCategory::ScriptResize => "ScriptResize",
ProfilerCategory::ScriptSetScrollState => "ScriptSetScrollState",
ProfilerCategory::ScriptSetViewport => "ScriptSetViewport",