mirror of
https://github.com/servo/servo.git
synced 2025-08-06 14:10:11 +01:00
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.
This commit is contained in:
parent
2bd02fe423
commit
dc5335a21e
3 changed files with 41 additions and 7 deletions
|
@ -107,7 +107,7 @@ use net_traits::response::HttpsState;
|
|||
use num_traits::ToPrimitive;
|
||||
use script_layout_interface::message::{Msg, ReflowQueryType};
|
||||
use script_runtime::{CommonScriptMsg, ScriptThreadEventCategory};
|
||||
use script_thread::{MainThreadScriptMsg, Runnable};
|
||||
use script_thread::{MainThreadScriptMsg, Runnable, ScriptThread};
|
||||
use script_traits::{AnimationState, CompositorEvent, DocumentActivity};
|
||||
use script_traits::{MouseButton, MouseEventType, MozBrowserEvent};
|
||||
use script_traits::{ScriptMsg as ConstellationMsg, TouchpadPressurePhase};
|
||||
|
@ -1599,17 +1599,26 @@ impl Document {
|
|||
// Step 5 can be found in asap_script_loaded and
|
||||
// asap_in_order_script_loaded.
|
||||
|
||||
let loader = self.loader.borrow();
|
||||
if loader.is_blocked() || loader.events_inhibited() {
|
||||
// Step 6.
|
||||
return;
|
||||
}
|
||||
|
||||
ScriptThread::mark_document_with_no_blocked_loads(self);
|
||||
}
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/#the-end
|
||||
pub fn maybe_queue_document_completion(&self) {
|
||||
if self.loader.borrow().is_blocked() {
|
||||
// Step 6.
|
||||
return;
|
||||
}
|
||||
|
||||
// The rest will ever run only once per document.
|
||||
if self.loader.borrow().events_inhibited() {
|
||||
return;
|
||||
}
|
||||
assert!(!self.loader.borrow().events_inhibited());
|
||||
self.loader.borrow_mut().inhibit_events();
|
||||
|
||||
// The rest will ever run only once per document.
|
||||
// Step 7.
|
||||
debug!("Document loads are complete.");
|
||||
let handler = box DocumentProgressHandler::new(Trusted::new(self));
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue