mirror of
https://github.com/servo/servo.git
synced 2025-07-23 07:13:52 +01:00
Implemented Houdini worklets.
This commit is contained in:
parent
abb2985ffe
commit
af8436c9be
34 changed files with 1209 additions and 17 deletions
|
@ -56,6 +56,8 @@ use dom::uievent::UIEvent;
|
|||
use dom::window::{ReflowReason, Window};
|
||||
use dom::windowproxy::WindowProxy;
|
||||
use dom::worker::TrustedWorkerAddress;
|
||||
use dom::worklet::WorkletThreadPool;
|
||||
use dom::workletglobalscope::WorkletGlobalScopeInit;
|
||||
use euclid::Rect;
|
||||
use euclid::point::Point2D;
|
||||
use hyper::header::{ContentType, HttpDate, LastModified, Headers};
|
||||
|
@ -490,6 +492,9 @@ pub struct ScriptThread {
|
|||
/// A handle to the webvr thread, if available
|
||||
webvr_thread: Option<IpcSender<WebVRMsg>>,
|
||||
|
||||
/// The worklet thread pool
|
||||
worklet_thread_pool: DOMRefCell<Option<Rc<WorkletThreadPool>>>,
|
||||
|
||||
/// A list of pipelines containing documents that finished loading all their blocking
|
||||
/// resources during a turn of the event loop.
|
||||
docs_with_no_blocking_loads: DOMRefCell<HashSet<JS<Document>>>,
|
||||
|
@ -703,6 +708,24 @@ impl ScriptThread {
|
|||
}))
|
||||
}
|
||||
|
||||
pub fn worklet_thread_pool() -> Rc<WorkletThreadPool> {
|
||||
SCRIPT_THREAD_ROOT.with(|root| {
|
||||
let script_thread = unsafe { &*root.get().unwrap() };
|
||||
script_thread.worklet_thread_pool.borrow_mut().get_or_insert_with(|| {
|
||||
let chan = script_thread.chan.0.clone();
|
||||
let init = WorkletGlobalScopeInit {
|
||||
resource_threads: script_thread.resource_threads.clone(),
|
||||
mem_profiler_chan: script_thread.mem_profiler_chan.clone(),
|
||||
time_profiler_chan: script_thread.time_profiler_chan.clone(),
|
||||
devtools_chan: script_thread.devtools_chan.clone(),
|
||||
constellation_chan: script_thread.constellation_chan.clone(),
|
||||
scheduler_chan: script_thread.scheduler_chan.clone(),
|
||||
};
|
||||
Rc::new(WorkletThreadPool::spawn(chan, init))
|
||||
}).clone()
|
||||
})
|
||||
}
|
||||
|
||||
/// Creates a new script thread.
|
||||
pub fn new(state: InitialScriptState,
|
||||
port: Receiver<MainThreadScriptMsg>,
|
||||
|
@ -782,6 +805,8 @@ impl ScriptThread {
|
|||
|
||||
webvr_thread: state.webvr_thread,
|
||||
|
||||
worklet_thread_pool: Default::default(),
|
||||
|
||||
docs_with_no_blocking_loads: Default::default(),
|
||||
|
||||
transitioning_nodes: Default::default(),
|
||||
|
@ -1065,6 +1090,7 @@ impl ScriptThread {
|
|||
ScriptThreadEventCategory::WebSocketEvent => ProfilerCategory::ScriptWebSocketEvent,
|
||||
ScriptThreadEventCategory::WebVREvent => ProfilerCategory::ScriptWebVREvent,
|
||||
ScriptThreadEventCategory::WorkerEvent => ProfilerCategory::ScriptWorkerEvent,
|
||||
ScriptThreadEventCategory::WorkletEvent => ProfilerCategory::ScriptWorkletEvent,
|
||||
ScriptThreadEventCategory::ServiceWorkerEvent => ProfilerCategory::ScriptServiceWorkerEvent,
|
||||
ScriptThreadEventCategory::EnterFullscreen => ProfilerCategory::ScriptEnterFullscreen,
|
||||
ScriptThreadEventCategory::ExitFullscreen => ProfilerCategory::ScriptExitFullscreen,
|
||||
|
@ -1149,7 +1175,7 @@ impl ScriptThread {
|
|||
// The category of the runnable is ignored by the pattern, however
|
||||
// it is still respected by profiling (see categorize_msg).
|
||||
if !runnable.is_cancelled() {
|
||||
runnable.handler()
|
||||
runnable.main_thread_handler(self)
|
||||
}
|
||||
}
|
||||
MainThreadScriptMsg::Common(CommonScriptMsg::CollectReports(reports_chan)) =>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue