mirror of
https://github.com/servo/servo.git
synced 2025-08-03 04:30:10 +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
|
@ -59,6 +59,7 @@ use js::jsapi::{JS_GC, JS_GetRuntime};
|
|||
use js::jsval::UndefinedValue;
|
||||
use js::rust::Runtime;
|
||||
use layout_image::fetch_image_for_layout;
|
||||
use microtask::{Microtask, MicrotaskQueue};
|
||||
use msg::constellation_msg::{FrameType, PipelineId};
|
||||
use net_traits::{ResourceThreads, ReferrerPolicy};
|
||||
use net_traits::image_cache::{ImageCache, ImageResponder, ImageResponse};
|
||||
|
@ -287,6 +288,10 @@ pub struct Window {
|
|||
test_worklet: MutNullableJS<Worklet>,
|
||||
/// https://drafts.css-houdini.org/css-paint-api-1/#paint-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 {
|
||||
|
@ -1785,6 +1790,16 @@ impl Window {
|
|||
.send(msg)
|
||||
.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 {
|
||||
|
@ -1818,6 +1833,7 @@ impl Window {
|
|||
navigation_start_precise: f64,
|
||||
webgl_chan: WebGLChan,
|
||||
webvr_chan: Option<IpcSender<WebVRMsg>>,
|
||||
microtask_queue: Rc<MicrotaskQueue>,
|
||||
) -> Root<Self> {
|
||||
let layout_rpc: Box<LayoutRPC + Send> = {
|
||||
let (rpc_send, rpc_recv) = channel();
|
||||
|
@ -1890,6 +1906,7 @@ impl Window {
|
|||
unminified_js_dir: Default::default(),
|
||||
test_worklet: Default::default(),
|
||||
paint_worklet: Default::default(),
|
||||
microtask_queue,
|
||||
};
|
||||
|
||||
unsafe {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue