mirror of
https://github.com/servo/servo.git
synced 2025-08-04 05:00:08 +01:00
Store a Rc<MicrotaskQueue> directly on Window
This commit is contained in:
parent
7f9f95b7ce
commit
7481ce177f
3 changed files with 22 additions and 4 deletions
|
@ -479,8 +479,8 @@ impl GlobalScope {
|
||||||
|
|
||||||
/// Perform a microtask checkpoint.
|
/// Perform a microtask checkpoint.
|
||||||
pub fn perform_a_microtask_checkpoint(&self) {
|
pub fn perform_a_microtask_checkpoint(&self) {
|
||||||
if self.is::<Window>() {
|
if let Some(window) = self.downcast::<Window>() {
|
||||||
return ScriptThread::invoke_perform_a_microtask_checkpoint();
|
return window.perform_a_microtask_checkpoint();
|
||||||
}
|
}
|
||||||
if let Some(worker) = self.downcast::<WorkerGlobalScope>() {
|
if let Some(worker) = self.downcast::<WorkerGlobalScope>() {
|
||||||
return worker.perform_a_microtask_checkpoint();
|
return worker.perform_a_microtask_checkpoint();
|
||||||
|
@ -493,8 +493,8 @@ impl GlobalScope {
|
||||||
|
|
||||||
/// Enqueue a microtask for subsequent execution.
|
/// Enqueue a microtask for subsequent execution.
|
||||||
pub fn enqueue_microtask(&self, job: Microtask) {
|
pub fn enqueue_microtask(&self, job: Microtask) {
|
||||||
if self.is::<Window>() {
|
if let Some(window) = self.downcast::<Window>() {
|
||||||
return ScriptThread::enqueue_microtask(job);
|
return window.enqueue_microtask(job);
|
||||||
}
|
}
|
||||||
if let Some(worker) = self.downcast::<WorkerGlobalScope>() {
|
if let Some(worker) = self.downcast::<WorkerGlobalScope>() {
|
||||||
return worker.enqueue_microtask(job);
|
return worker.enqueue_microtask(job);
|
||||||
|
|
|
@ -59,6 +59,7 @@ use js::jsapi::{JS_GC, JS_GetRuntime};
|
||||||
use js::jsval::UndefinedValue;
|
use js::jsval::UndefinedValue;
|
||||||
use js::rust::Runtime;
|
use js::rust::Runtime;
|
||||||
use layout_image::fetch_image_for_layout;
|
use layout_image::fetch_image_for_layout;
|
||||||
|
use microtask::{Microtask, MicrotaskQueue};
|
||||||
use msg::constellation_msg::{FrameType, PipelineId};
|
use msg::constellation_msg::{FrameType, PipelineId};
|
||||||
use net_traits::{ResourceThreads, ReferrerPolicy};
|
use net_traits::{ResourceThreads, ReferrerPolicy};
|
||||||
use net_traits::image_cache::{ImageCache, ImageResponder, ImageResponse};
|
use net_traits::image_cache::{ImageCache, ImageResponder, ImageResponse};
|
||||||
|
@ -287,6 +288,10 @@ pub struct Window {
|
||||||
test_worklet: MutNullableJS<Worklet>,
|
test_worklet: MutNullableJS<Worklet>,
|
||||||
/// https://drafts.css-houdini.org/css-paint-api-1/#paint-worklet
|
/// https://drafts.css-houdini.org/css-paint-api-1/#paint-worklet
|
||||||
paint_worklet: MutNullableJS<Worklet>,
|
paint_worklet: MutNullableJS<Worklet>,
|
||||||
|
|
||||||
|
/// https://html.spec.whatwg.org/multipage/#microtask-queue
|
||||||
|
#[ignore_heap_size_of = "Rc<T> is hard"]
|
||||||
|
microtask_queue: Rc<MicrotaskQueue>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Window {
|
impl Window {
|
||||||
|
@ -1785,6 +1790,16 @@ impl Window {
|
||||||
.send(msg)
|
.send(msg)
|
||||||
.unwrap();
|
.unwrap();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn enqueue_microtask(&self, job: Microtask) {
|
||||||
|
self.microtask_queue.enqueue(job);
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn perform_a_microtask_checkpoint(&self) {
|
||||||
|
self.microtask_queue.checkpoint(|_| {
|
||||||
|
Some(Root::from_ref(self.upcast::<GlobalScope>()))
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Window {
|
impl Window {
|
||||||
|
@ -1818,6 +1833,7 @@ impl Window {
|
||||||
navigation_start_precise: f64,
|
navigation_start_precise: f64,
|
||||||
webgl_chan: WebGLChan,
|
webgl_chan: WebGLChan,
|
||||||
webvr_chan: Option<IpcSender<WebVRMsg>>,
|
webvr_chan: Option<IpcSender<WebVRMsg>>,
|
||||||
|
microtask_queue: Rc<MicrotaskQueue>,
|
||||||
) -> Root<Self> {
|
) -> Root<Self> {
|
||||||
let layout_rpc: Box<LayoutRPC + Send> = {
|
let layout_rpc: Box<LayoutRPC + Send> = {
|
||||||
let (rpc_send, rpc_recv) = channel();
|
let (rpc_send, rpc_recv) = channel();
|
||||||
|
@ -1890,6 +1906,7 @@ impl Window {
|
||||||
unminified_js_dir: Default::default(),
|
unminified_js_dir: Default::default(),
|
||||||
test_worklet: Default::default(),
|
test_worklet: Default::default(),
|
||||||
paint_worklet: Default::default(),
|
paint_worklet: Default::default(),
|
||||||
|
microtask_queue,
|
||||||
};
|
};
|
||||||
|
|
||||||
unsafe {
|
unsafe {
|
||||||
|
|
|
@ -2068,6 +2068,7 @@ impl ScriptThread {
|
||||||
incomplete.navigation_start_precise,
|
incomplete.navigation_start_precise,
|
||||||
self.webgl_chan.channel(),
|
self.webgl_chan.channel(),
|
||||||
self.webvr_chan.clone(),
|
self.webvr_chan.clone(),
|
||||||
|
self.microtask_queue.clone(),
|
||||||
);
|
);
|
||||||
|
|
||||||
// Initialize the browsing context for the window.
|
// Initialize the browsing context for the window.
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue