aboutsummaryrefslogtreecommitdiffstats
path: root/components/script/microtask.rs
diff options
context:
space:
mode:
Diffstat (limited to 'components/script/microtask.rs')
-rw-r--r--components/script/microtask.rs16
1 files changed, 16 insertions, 0 deletions
diff --git a/components/script/microtask.rs b/components/script/microtask.rs
index 001262c05e1..43628f46331 100644
--- a/components/script/microtask.rs
+++ b/components/script/microtask.rs
@@ -9,6 +9,7 @@
use crate::dom::bindings::callback::ExceptionHandling;
use crate::dom::bindings::cell::DomRefCell;
use crate::dom::bindings::codegen::Bindings::PromiseBinding::PromiseJobCallback;
+use crate::dom::bindings::codegen::Bindings::VoidFunctionBinding::VoidFunction;
use crate::dom::bindings::root::DomRoot;
use crate::dom::globalscope::GlobalScope;
use crate::dom::htmlimageelement::ImageElementMicrotask;
@@ -34,6 +35,7 @@ pub struct MicrotaskQueue {
#[derive(JSTraceable, MallocSizeOf)]
pub enum Microtask {
Promise(EnqueuedPromiseCallback),
+ User(UserMicrotask),
MediaElement(MediaElementMicrotask),
ImageElement(ImageElementMicrotask),
CustomElementReaction,
@@ -52,6 +54,15 @@ pub struct EnqueuedPromiseCallback {
pub pipeline: PipelineId,
}
+/// A microtask that comes from a queueMicrotask() Javascript call,
+/// identical to EnqueuedPromiseCallback once it's on the queue
+#[derive(JSTraceable, MallocSizeOf)]
+pub struct UserMicrotask {
+ #[ignore_malloc_size_of = "Rc has unclear ownership"]
+ pub callback: Rc<VoidFunction>,
+ pub pipeline: PipelineId,
+}
+
impl MicrotaskQueue {
/// Add a new microtask to this queue. It will be invoked as part of the next
/// microtask checkpoint.
@@ -95,6 +106,11 @@ impl MicrotaskQueue {
let _ = job.callback.Call_(&*target, ExceptionHandling::Report);
}
},
+ Microtask::User(ref job) => {
+ if let Some(target) = target_provider(job.pipeline) {
+ let _ = job.callback.Call_(&*target, ExceptionHandling::Report);
+ }
+ },
Microtask::MediaElement(ref task) => {
task.handler();
},