In the current implementation, WorkletGlobalScope has the following class hierarchy:
- WorkerOrWorkletGlobalScope
- WorkletGlobalScope
- MainThreadWorkletGlobalScope
- PaintWorkletGlobalScope
- LayoutWorkletGlobalScope
- ThreadedWorkletGlobalScope
- AudioWorkletGlobalScope
- AnimationWorkletGlobalScope
Separation between MainThreadWorkletGlobalScope and ThreadedWorkletGlobalScope makes it difficult to implement worklets that can run on both the main thread and a worker thread (e.g., threaded paint worklets. See issue 829967). To makes it easier, we could merge them into WorkletGlobalScope like this:
- WorkerOrWorkletGlobalScope
- WorkletGlobalScope
- PaintWorkletGlobalScope
- LayoutWorkletGlobalScope
- AudioWorkletGlobalScope
- AnimationWorkletGlobalScope
Probably thread-specific parts in MainThread/ThreadedWorkletGlobalScope will be implemented in WorkletGlobalScope::Delegate or something, and injected by each WorkletGlobalScope subclass to WorkletGlobalScope.
Comment 1 by bugdroid1@chromium.org
, Oct 9