aboutsummaryrefslogtreecommitdiffstats
path: root/components/script/script_thread.rs
diff options
context:
space:
mode:
authorJosh Matthews <josh@joshmatthews.net>2017-02-28 10:30:13 -0500
committerJosh Matthews <josh@joshmatthews.net>2017-03-07 14:02:42 +0530
commitdc5335a21eb70f5a9751ef2f6929ed3731b4ad5e (patch)
treec688f682326d2370f90370adff3221eb98c95314 /components/script/script_thread.rs
parent2bd02fe4238e6843e81a2682e7dcd12952401e13 (diff)
downloadservo-dc5335a21eb70f5a9751ef2f6929ed3731b4ad5e.tar.gz
servo-dc5335a21eb70f5a9751ef2f6929ed3731b4ad5e.zip
Move checks for document completion to the end of the event loop.
This better reflects the text of the specification - rather than queuing a task to dispatch the load evnet as soon as the document loader is unblocked, we want to "spin the event loop until there is nothing that delays the load event in the Document." Spinning the event loop is a concept that requires running tasks completely, hence we check the condition before returning to the start of the event loop.
Diffstat (limited to 'components/script/script_thread.rs')
-rw-r--r--components/script/script_thread.rs26
1 files changed, 25 insertions, 1 deletions
diff --git a/components/script/script_thread.rs b/components/script/script_thread.rs
index 192923294a6..e877e904ceb 100644
--- a/components/script/script_thread.rs
+++ b/components/script/script_thread.rs
@@ -483,6 +483,10 @@ pub struct ScriptThread {
/// A handle to the webvr thread, if available
webvr_thread: Option<IpcSender<WebVRMsg>>,
+
+ /// A list of pipelines containing documents that finished loading all their blocking
+ /// resources during a turn of the event loop.
+ docs_with_no_blocking_loads: DOMRefCell<HashSet<JS<Document>>>,
}
/// In the event of thread panic, all data on the stack runs its destructor. However, there
@@ -567,6 +571,15 @@ impl ScriptThreadFactory for ScriptThread {
}
impl ScriptThread {
+ pub fn mark_document_with_no_blocked_loads(doc: &Document) {
+ SCRIPT_THREAD_ROOT.with(|root| {
+ let script_thread = unsafe { &*root.get().unwrap() };
+ script_thread.docs_with_no_blocking_loads
+ .borrow_mut()
+ .insert(JS::from_ref(doc));
+ })
+ }
+
pub fn invoke_perform_a_microtask_checkpoint() {
SCRIPT_THREAD_ROOT.with(|root| {
let script_thread = unsafe { &*root.get().unwrap() };
@@ -704,7 +717,9 @@ impl ScriptThread {
layout_to_constellation_chan: state.layout_to_constellation_chan,
- webvr_thread: state.webvr_thread
+ webvr_thread: state.webvr_thread,
+
+ docs_with_no_blocking_loads: Default::default(),
}
}
@@ -885,6 +900,15 @@ impl ScriptThread {
}
}
+ {
+ // https://html.spec.whatwg.org/multipage/#the-end step 6
+ let mut docs = self.docs_with_no_blocking_loads.borrow_mut();
+ for document in docs.iter() {
+ document.maybe_queue_document_completion();
+ }
+ docs.clear();
+ }
+
// https://html.spec.whatwg.org/multipage/#event-loop-processing-model step 7.12
// Issue batched reflows on any pages that require it (e.g. if images loaded)