mirror of
https://github.com/servo/servo.git
synced 2025-08-01 03:30:33 +01:00
script: Fix a few load related bugs.
This is what was making me hit the new test failures. So turns out that when the DOMContentLoaded event is fired we fired no messages to the constellation, but we fired the DOMLoad message from the DocumentProgressHandler, effectively after having dispatched the Load message from script thread. This also fixes the possibility of a subframe navigation not blocking the load event of the parent document, for example.
This commit is contained in:
parent
d81fe27b11
commit
e6958d3947
4 changed files with 22 additions and 14 deletions
|
@ -2114,7 +2114,7 @@ impl<Window: WindowMethods> IOCompositor<Window> {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check if there are any pending frames. If so, the image is not stable yet.
|
// Check if there are any pending frames. If so, the image is not stable yet.
|
||||||
if self.pending_subpages.len() > 0 {
|
if !self.pending_subpages.is_empty() {
|
||||||
return Err(NotReadyToPaint::PendingSubpages(self.pending_subpages.len()));
|
return Err(NotReadyToPaint::PendingSubpages(self.pending_subpages.len()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1441,6 +1441,7 @@ impl<Message, LTF, STF> Constellation<Message, LTF, STF>
|
||||||
let root = self.root_frame_id.is_none() || self.root_frame_id == Some(frame_id);
|
let root = self.root_frame_id.is_none() || self.root_frame_id == Some(frame_id);
|
||||||
self.compositor_proxy.send(ToCompositorMsg::LoadComplete(back, forward, root));
|
self.compositor_proxy.send(ToCompositorMsg::LoadComplete(back, forward, root));
|
||||||
}
|
}
|
||||||
|
self.handle_subframe_loaded(pipeline_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn handle_dom_load(&mut self, pipeline_id: PipelineId) {
|
fn handle_dom_load(&mut self, pipeline_id: PipelineId) {
|
||||||
|
@ -1455,8 +1456,6 @@ impl<Message, LTF, STF> Constellation<Message, LTF, STF>
|
||||||
if webdriver_reset {
|
if webdriver_reset {
|
||||||
self.webdriver.load_channel = None;
|
self.webdriver.load_channel = None;
|
||||||
}
|
}
|
||||||
|
|
||||||
self.handle_subframe_loaded(pipeline_id);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn handle_traverse_history_msg(&mut self,
|
fn handle_traverse_history_msg(&mut self,
|
||||||
|
@ -2073,7 +2072,7 @@ impl<Message, LTF, STF> Constellation<Message, LTF, STF>
|
||||||
}
|
}
|
||||||
|
|
||||||
// If there are pending loads, wait for those to complete.
|
// If there are pending loads, wait for those to complete.
|
||||||
if self.pending_frames.len() > 0 {
|
if !self.pending_frames.is_empty() {
|
||||||
return ReadyToSave::PendingFrames;
|
return ReadyToSave::PendingFrames;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2089,7 +2088,10 @@ impl<Message, LTF, STF> Constellation<Message, LTF, STF>
|
||||||
let pipeline_id = frame.current.0;
|
let pipeline_id = frame.current.0;
|
||||||
|
|
||||||
let pipeline = match self.pipelines.get(&pipeline_id) {
|
let pipeline = match self.pipelines.get(&pipeline_id) {
|
||||||
None => { warn!("Pipeline {:?} screenshot while closing.", pipeline_id); continue; },
|
None => {
|
||||||
|
warn!("Pipeline {:?} screenshot while closing.", pipeline_id);
|
||||||
|
continue;
|
||||||
|
},
|
||||||
Some(pipeline) => pipeline,
|
Some(pipeline) => pipeline,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -376,6 +376,7 @@ impl Document {
|
||||||
// that workable.
|
// that workable.
|
||||||
match self.GetDocumentElement() {
|
match self.GetDocumentElement() {
|
||||||
Some(root) => {
|
Some(root) => {
|
||||||
|
root.upcast::<Node>().is_dirty() ||
|
||||||
root.upcast::<Node>().has_dirty_descendants() ||
|
root.upcast::<Node>().has_dirty_descendants() ||
|
||||||
!self.modified_elements.borrow().is_empty()
|
!self.modified_elements.borrow().is_empty()
|
||||||
}
|
}
|
||||||
|
@ -1371,6 +1372,7 @@ impl Document {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn finish_load(&self, load: LoadType) {
|
pub fn finish_load(&self, load: LoadType) {
|
||||||
|
debug!("Document got finish_load: {:?}", load);
|
||||||
// The parser might need the loader, so restrict the lifetime of the borrow.
|
// The parser might need the loader, so restrict the lifetime of the borrow.
|
||||||
{
|
{
|
||||||
let mut loader = self.loader.borrow_mut();
|
let mut loader = self.loader.borrow_mut();
|
||||||
|
@ -1396,9 +1398,9 @@ impl Document {
|
||||||
// If we don't have a parser, and the reflow timer has been reset, explicitly
|
// If we don't have a parser, and the reflow timer has been reset, explicitly
|
||||||
// trigger a reflow.
|
// trigger a reflow.
|
||||||
if let LoadType::Stylesheet(_) = load {
|
if let LoadType::Stylesheet(_) = load {
|
||||||
self.window().reflow(ReflowGoal::ForDisplay,
|
self.window.reflow(ReflowGoal::ForDisplay,
|
||||||
ReflowQueryType::NoQuery,
|
ReflowQueryType::NoQuery,
|
||||||
ReflowReason::StylesheetLoaded);
|
ReflowReason::StylesheetLoaded);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1487,6 +1489,8 @@ impl Document {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
self.domcontentloaded_dispatched.set(true);
|
self.domcontentloaded_dispatched.set(true);
|
||||||
|
assert!(self.ReadyState() != DocumentReadyState::Complete,
|
||||||
|
"Complete before DOMContentLoaded?");
|
||||||
|
|
||||||
update_with_current_time_ms(&self.dom_content_loaded_event_start);
|
update_with_current_time_ms(&self.dom_content_loaded_event_start);
|
||||||
|
|
||||||
|
@ -1497,14 +1501,17 @@ impl Document {
|
||||||
ReflowQueryType::NoQuery,
|
ReflowQueryType::NoQuery,
|
||||||
ReflowReason::DOMContentLoaded);
|
ReflowReason::DOMContentLoaded);
|
||||||
|
|
||||||
|
let pipeline_id = self.window.pipeline();
|
||||||
|
let event = ConstellationMsg::DOMLoad(pipeline_id);
|
||||||
|
self.window.constellation_chan().send(event).unwrap();
|
||||||
|
|
||||||
update_with_current_time_ms(&self.dom_content_loaded_event_end);
|
update_with_current_time_ms(&self.dom_content_loaded_event_end);
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn notify_constellation_load(&self) {
|
pub fn notify_constellation_load(&self) {
|
||||||
let pipeline_id = self.window.pipeline();
|
let pipeline_id = self.window.pipeline();
|
||||||
let event = ConstellationMsg::DOMLoad(pipeline_id);
|
let load_event = ConstellationMsg::LoadComplete(pipeline_id);
|
||||||
self.window.constellation_chan().send(event).unwrap();
|
self.window.constellation_chan().send(load_event).unwrap();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn set_current_parser(&self, script: Option<ParserRef>) {
|
pub fn set_current_parser(&self, script: Option<ParserRef>) {
|
||||||
|
@ -2913,11 +2920,12 @@ impl DocumentProgressHandler {
|
||||||
// http://w3c.github.io/navigation-timing/#widl-PerformanceNavigationTiming-loadEventEnd
|
// http://w3c.github.io/navigation-timing/#widl-PerformanceNavigationTiming-loadEventEnd
|
||||||
update_with_current_time_ms(&document.load_event_end);
|
update_with_current_time_ms(&document.load_event_end);
|
||||||
|
|
||||||
document.notify_constellation_load();
|
|
||||||
|
|
||||||
window.reflow(ReflowGoal::ForDisplay,
|
window.reflow(ReflowGoal::ForDisplay,
|
||||||
ReflowQueryType::NoQuery,
|
ReflowQueryType::NoQuery,
|
||||||
ReflowReason::DocumentLoaded);
|
ReflowReason::DocumentLoaded);
|
||||||
|
|
||||||
|
document.notify_constellation_load();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1193,8 +1193,6 @@ impl ScriptThread {
|
||||||
// https://html.spec.whatwg.org/multipage/#the-end step 7
|
// https://html.spec.whatwg.org/multipage/#the-end step 7
|
||||||
let handler = box DocumentProgressHandler::new(Trusted::new(doc));
|
let handler = box DocumentProgressHandler::new(Trusted::new(doc));
|
||||||
self.dom_manipulation_task_source.queue(handler, GlobalRef::Window(doc.window())).unwrap();
|
self.dom_manipulation_task_source.queue(handler, GlobalRef::Window(doc.window())).unwrap();
|
||||||
|
|
||||||
self.constellation_chan.send(ConstellationMsg::LoadComplete(pipeline)).unwrap();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn collect_reports(&self, reports_chan: ReportsChan) {
|
fn collect_reports(&self, reports_chan: ReportsChan) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue