aboutsummaryrefslogtreecommitdiffstats
path: root/components/script/microtask.rs
diff options
context:
space:
mode:
authorbors-servo <lbergstrom+bors@mozilla.com>2017-05-19 20:09:54 -0500
committerGitHub <noreply@github.com>2017-05-19 20:09:54 -0500
commitf05491166f21879f74758b2f03bbc4c4a4c31eb8 (patch)
tree3cf13e546ae63f314c469e03f4a71f673eeaa5b3 /components/script/microtask.rs
parent60682cf81fe19a82c73dd98ba4c1eebc1dbbfcac (diff)
parenta8390aea2451928153bd744e7eeb73fc70564124 (diff)
downloadservo-f05491166f21879f74758b2f03bbc4c4a4c31eb8.tar.gz
servo-f05491166f21879f74758b2f03bbc4c4a4c31eb8.zip
Auto merge of #16861 - gterzian:use_microtask_to_await_stable_state, r=jdm
Use microtasks to await a stable state. <!-- Please describe your changes on the following line: --> @jdm @KiChjang First pass at using microtasks to await a stable state. I ran into all sorts of problems to get it to compile, I think it's mainly related to the fact that the microtasks are stored in a `Vec`, which meant the `Runnalbe.handler(self: Box<Self>)` couldn't be called while iterating over the Vec... It compiles now although I haven't run any tests. I'm assuming I'm missing something fundamental and was hoping my changes would highlight the problems I run into, and you had a better idea of how to implement this... Perhaps we shouldn't pass a `Runnable` to `await_stable_state` at all? --- <!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `__` with appropriate data: --> - [ ] `./mach build -d` does not report any errors - [ ] `./mach test-tidy` does not report any errors - [ ] These changes fix #15375 (github issue number if applicable). <!-- Either: --> - [ ] There are tests for these changes OR - [ ] These changes do not require tests because _____ <!-- Also, please make sure that "Allow edits from maintainers" checkbox is checked, so that we can help you if you get stuck somewhere along the way.--> <!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. --> <!-- Reviewable:start --> --- This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/16861) <!-- Reviewable:end -->
Diffstat (limited to 'components/script/microtask.rs')
-rw-r--r--components/script/microtask.rs9
1 files changed, 9 insertions, 0 deletions
diff --git a/components/script/microtask.rs b/components/script/microtask.rs
index 7fadf111ddb..8f10dbcf489 100644
--- a/components/script/microtask.rs
+++ b/components/script/microtask.rs
@@ -11,6 +11,7 @@ use dom::bindings::cell::DOMRefCell;
use dom::bindings::codegen::Bindings::PromiseBinding::PromiseJobCallback;
use dom::bindings::js::Root;
use dom::globalscope::GlobalScope;
+use dom::htmlmediaelement::MediaElementMicrotask;
use dom::mutationobserver::MutationObserver;
use msg::constellation_msg::PipelineId;
use std::cell::Cell;
@@ -29,9 +30,14 @@ pub struct MicrotaskQueue {
#[derive(JSTraceable, HeapSizeOf)]
pub enum Microtask {
Promise(EnqueuedPromiseCallback),
+ MediaElement(MediaElementMicrotask),
NotifyMutationObservers,
}
+pub trait MicrotaskRunnable {
+ fn handler(&self) {}
+}
+
/// A promise callback scheduled to run during the next microtask checkpoint (#4283).
#[derive(JSTraceable, HeapSizeOf)]
pub struct EnqueuedPromiseCallback {
@@ -72,6 +78,9 @@ impl MicrotaskQueue {
if let Some(target) = target_provider(job.pipeline) {
let _ = job.callback.Call_(&*target, ExceptionHandling::Report);
}
+ },
+ Microtask::MediaElement(ref task) => {
+ task.handler();
}
Microtask::NotifyMutationObservers => {
MutationObserver::notify_mutation_observers();