mirror of
https://github.com/servo/servo.git
synced 2025-08-04 13:10:20 +01:00
queueMicrotask added
This commit is contained in:
parent
968b45f9dc
commit
b01b2d3d2e
11 changed files with 42 additions and 75 deletions
|
@ -4,6 +4,7 @@
|
|||
|
||||
use crate::dom::bindings::cell::DomRefCell;
|
||||
use crate::dom::bindings::codegen::Bindings::EventSourceBinding::EventSourceBinding::EventSourceMethods;
|
||||
use crate::dom::bindings::codegen::Bindings::VoidFunctionBinding::VoidFunction;
|
||||
use crate::dom::bindings::codegen::Bindings::WindowBinding::WindowMethods;
|
||||
use crate::dom::bindings::codegen::Bindings::WorkerGlobalScopeBinding::WorkerGlobalScopeMethods;
|
||||
use crate::dom::bindings::conversions::{root_from_object, root_from_object_static};
|
||||
|
@ -32,7 +33,7 @@ use crate::dom::performance::Performance;
|
|||
use crate::dom::window::Window;
|
||||
use crate::dom::workerglobalscope::WorkerGlobalScope;
|
||||
use crate::dom::workletglobalscope::WorkletGlobalScope;
|
||||
use crate::microtask::{Microtask, MicrotaskQueue};
|
||||
use crate::microtask::{Microtask, MicrotaskQueue, UserMicrotask};
|
||||
use crate::script_module::ModuleTree;
|
||||
use crate::script_runtime::{CommonScriptMsg, JSContext as SafeJSContext, ScriptChan, ScriptPort};
|
||||
use crate::script_thread::{MainThreadScriptChan, ScriptThread};
|
||||
|
@ -1772,6 +1773,13 @@ impl GlobalScope {
|
|||
self.timers.clear_timeout_or_interval(self, handle);
|
||||
}
|
||||
|
||||
pub fn queue_function_as_microtask(&self, callback: Rc<VoidFunction>) {
|
||||
self.enqueue_microtask(Microtask::User(UserMicrotask {
|
||||
callback: callback,
|
||||
pipeline: self.pipeline_id(),
|
||||
}))
|
||||
}
|
||||
|
||||
pub fn fire_timer(&self, handle: TimerEventId) {
|
||||
self.timers.fire_timer(handle, self);
|
||||
}
|
||||
|
|
|
@ -20,6 +20,9 @@ interface mixin WindowOrWorkerGlobalScope {
|
|||
long setInterval(TimerHandler handler, optional long timeout = 0, any... arguments);
|
||||
void clearInterval(optional long handle = 0);
|
||||
|
||||
// microtask queuing
|
||||
void queueMicrotask(VoidFunction callback);
|
||||
|
||||
// ImageBitmap
|
||||
// Promise<ImageBitmap> createImageBitmap(ImageBitmapSource image, optional ImageBitmapOptions options);
|
||||
// Promise<ImageBitmap> createImageBitmap(
|
||||
|
|
|
@ -11,6 +11,7 @@ use crate::dom::bindings::codegen::Bindings::HistoryBinding::HistoryBinding::His
|
|||
use crate::dom::bindings::codegen::Bindings::MediaQueryListBinding::MediaQueryListBinding::MediaQueryListMethods;
|
||||
use crate::dom::bindings::codegen::Bindings::PermissionStatusBinding::PermissionState;
|
||||
use crate::dom::bindings::codegen::Bindings::RequestBinding::RequestInit;
|
||||
use crate::dom::bindings::codegen::Bindings::VoidFunctionBinding::VoidFunction;
|
||||
use crate::dom::bindings::codegen::Bindings::WindowBinding::{
|
||||
self, FrameRequestCallback, WindowMethods, WindowPostMessageOptions,
|
||||
};
|
||||
|
@ -871,6 +872,12 @@ impl WindowMethods for Window {
|
|||
self.ClearTimeout(handle);
|
||||
}
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/#dom-queuemicrotask
|
||||
fn QueueMicrotask(&self, callback: Rc<VoidFunction>) {
|
||||
self.upcast::<GlobalScope>()
|
||||
.queue_function_as_microtask(callback);
|
||||
}
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/#dom-window
|
||||
fn Window(&self) -> DomRoot<WindowProxy> {
|
||||
self.window_proxy()
|
||||
|
|
|
@ -5,6 +5,7 @@
|
|||
use crate::compartments::InCompartment;
|
||||
use crate::dom::bindings::cell::{DomRefCell, Ref};
|
||||
use crate::dom::bindings::codegen::Bindings::RequestBinding::RequestInit;
|
||||
use crate::dom::bindings::codegen::Bindings::VoidFunctionBinding::VoidFunction;
|
||||
use crate::dom::bindings::codegen::Bindings::WorkerBinding::WorkerType;
|
||||
use crate::dom::bindings::codegen::Bindings::WorkerGlobalScopeBinding::WorkerGlobalScopeMethods;
|
||||
use crate::dom::bindings::codegen::UnionTypes::{RequestOrUSVString, StringOrFunction};
|
||||
|
@ -341,6 +342,12 @@ impl WorkerGlobalScopeMethods for WorkerGlobalScope {
|
|||
self.ClearTimeout(handle);
|
||||
}
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/#dom-queuemicrotask
|
||||
fn QueueMicrotask(&self, callback: Rc<VoidFunction>) {
|
||||
self.upcast::<GlobalScope>()
|
||||
.queue_function_as_microtask(callback);
|
||||
}
|
||||
|
||||
#[allow(unrooted_must_root)]
|
||||
// https://fetch.spec.whatwg.org/#fetch-method
|
||||
fn Fetch(
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue