mirror of
https://github.com/servo/servo.git
synced 2025-08-03 04:30:10 +01:00
Bug fixes, mainly about document loading.
This commit is contained in:
parent
cda9099396
commit
21d8235a82
10 changed files with 87 additions and 81 deletions
|
@ -94,6 +94,7 @@ impl DocumentLoader {
|
|||
|
||||
pub fn new_with_threads(resource_threads: ResourceThreads,
|
||||
initial_load: Option<Url>) -> DocumentLoader {
|
||||
debug!("Initial blocking load {:?}.", initial_load);
|
||||
let initial_loads = initial_load.into_iter().map(LoadType::PageSource).collect();
|
||||
|
||||
DocumentLoader {
|
||||
|
@ -105,6 +106,7 @@ impl DocumentLoader {
|
|||
|
||||
/// Add a load to the list of blocking loads.
|
||||
fn add_blocking_load(&mut self, load: LoadType) {
|
||||
debug!("Adding blocking load {:?} ({}).", load, self.blocking_loads.len());
|
||||
self.blocking_loads.push(load);
|
||||
}
|
||||
|
||||
|
@ -119,6 +121,7 @@ impl DocumentLoader {
|
|||
|
||||
/// Mark an in-progress network request complete.
|
||||
pub fn finish_load(&mut self, load: &LoadType) {
|
||||
debug!("Removing blocking load {:?} ({}).", load, self.blocking_loads.len());
|
||||
let idx = self.blocking_loads.iter().position(|unfinished| *unfinished == *load);
|
||||
self.blocking_loads.remove(idx.expect(&format!("unknown completed load {:?}", load)));
|
||||
}
|
||||
|
|
|
@ -1399,7 +1399,7 @@ impl Document {
|
|||
if let Some((parent_pipeline_id, _)) = self.window.parent_info() {
|
||||
let global_scope = self.window.upcast::<GlobalScope>();
|
||||
let event = ConstellationMsg::MozBrowserEvent(parent_pipeline_id,
|
||||
Some(global_scope.pipeline_id()),
|
||||
global_scope.pipeline_id(),
|
||||
event);
|
||||
global_scope.constellation_chan().send(event).unwrap();
|
||||
}
|
||||
|
@ -1512,8 +1512,10 @@ impl Document {
|
|||
}
|
||||
}
|
||||
|
||||
let loader = self.loader.borrow();
|
||||
if !loader.is_blocked() && !loader.events_inhibited() {
|
||||
if !self.loader.borrow().is_blocked() && !self.loader.borrow().events_inhibited() {
|
||||
// Schedule a task to fire a "load" event (if no blocking loads have arrived in the mean time)
|
||||
// NOTE: we can end up executing this code more than once, in case more blocking loads arrive.
|
||||
debug!("Document loads are complete.");
|
||||
let win = self.window();
|
||||
let msg = MainThreadScriptMsg::DocumentLoadsComplete(
|
||||
win.upcast::<GlobalScope>().pipeline_id());
|
||||
|
|
|
@ -231,7 +231,11 @@ impl HTMLIFrameElement {
|
|||
}
|
||||
|
||||
/// https://html.spec.whatwg.org/multipage/#iframe-load-event-steps steps 1-4
|
||||
pub fn iframe_load_event_steps(&self) {
|
||||
pub fn iframe_load_event_steps(&self, loaded_pipeline: PipelineId) {
|
||||
// TODO(#9592): assert that the load blocker is present at all times when we
|
||||
// can guarantee that it's created for the case of iframe.reload().
|
||||
assert_eq!(loaded_pipeline, self.pipeline_id().unwrap());
|
||||
|
||||
// TODO A cross-origin child document would not be easily accessible
|
||||
// from this script thread. It's unclear how to implement
|
||||
// steps 2, 3, and 5 efficiently in this case.
|
||||
|
|
|
@ -932,8 +932,8 @@ impl ScriptThread {
|
|||
ConstellationControlMsg::WebFontLoaded(pipeline_id) =>
|
||||
self.handle_web_font_loaded(pipeline_id),
|
||||
ConstellationControlMsg::DispatchFrameLoadEvent {
|
||||
target: frame_id, parent: parent_pipeline_id } =>
|
||||
self.handle_frame_load_event(parent_pipeline_id, frame_id),
|
||||
target: frame_id, parent: parent_id, child: child_id } =>
|
||||
self.handle_frame_load_event(parent_id, frame_id, child_id),
|
||||
ConstellationControlMsg::FramedContentChanged(parent_pipeline_id, frame_id) =>
|
||||
self.handle_framed_content_changed(parent_pipeline_id, frame_id),
|
||||
ConstellationControlMsg::ReportCSSError(pipeline_id, filename, line, column, msg) =>
|
||||
|
@ -1193,12 +1193,15 @@ impl ScriptThread {
|
|||
None => return warn!("Message sent to closed pipeline {}.", pipeline),
|
||||
};
|
||||
if doc.loader().is_blocked() {
|
||||
debug!("Script thread got loads complete while loader is blocked.");
|
||||
return;
|
||||
}
|
||||
|
||||
doc.mut_loader().inhibit_events();
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/#the-end step 7
|
||||
// Schedule a task to fire a "load" event (if no blocking loads have arrived in the mean time)
|
||||
// NOTE: we can end up executing this code more than once, in case more blocking loads arrive.
|
||||
let handler = box DocumentProgressHandler::new(Trusted::new(&doc));
|
||||
self.dom_manipulation_task_source.queue(handler, doc.window().upcast()).unwrap();
|
||||
|
||||
|
@ -1573,13 +1576,15 @@ impl ScriptThread {
|
|||
}
|
||||
|
||||
/// Notify the containing document of a child frame that has completed loading.
|
||||
fn handle_frame_load_event(&self, parent_pipeline_id: PipelineId, id: FrameId) {
|
||||
let document = match self.root_browsing_context().find(parent_pipeline_id) {
|
||||
fn handle_frame_load_event(&self, parent_id: PipelineId, frame_id: FrameId, child_id: PipelineId) {
|
||||
let document = match self.root_browsing_context().find(parent_id) {
|
||||
Some(browsing_context) => browsing_context.active_document(),
|
||||
None => return warn!("Message sent to closed pipeline {}.", parent_pipeline_id),
|
||||
None => return warn!("Message sent to closed pipeline {}.", parent_id),
|
||||
};
|
||||
if let Some(iframe) = document.find_iframe(id) {
|
||||
iframe.iframe_load_event_steps();
|
||||
if let Some(iframe) = document.find_iframe(frame_id) {
|
||||
if iframe.pipeline_id() == Some(child_id) {
|
||||
iframe.iframe_load_event_steps(child_id);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue