mirror of
https://github.com/servo/servo.git
synced 2025-08-06 22:15:33 +01:00
Trigger mozbrowsererror event when a pipeline fails.
This commit is contained in:
parent
6edcad206d
commit
59824ccb92
1 changed files with 44 additions and 16 deletions
|
@ -873,6 +873,9 @@ impl<LTF: LayoutThreadFactory, STF: ScriptThreadFactory> Constellation<LTF, STF>
|
||||||
|
|
||||||
let window_size = self.pipelines.get(&failure.pipeline_id).and_then(|pipeline| pipeline.size);
|
let window_size = self.pipelines.get(&failure.pipeline_id).and_then(|pipeline| pipeline.size);
|
||||||
|
|
||||||
|
// Notify the browser chrome that the pipeline has failed
|
||||||
|
self.trigger_mozbrowsererror(failure.pipeline_id);
|
||||||
|
|
||||||
self.close_pipeline(failure.pipeline_id, ExitPipelineMode::Force);
|
self.close_pipeline(failure.pipeline_id, ExitPipelineMode::Force);
|
||||||
|
|
||||||
while let Some(pending_pipeline_id) = self.pending_frames.iter().find(|pending| {
|
while let Some(pending_pipeline_id) = self.pending_frames.iter().find(|pending| {
|
||||||
|
@ -1916,30 +1919,54 @@ impl<LTF: LayoutThreadFactory, STF: ScriptThreadFactory> Constellation<LTF, STF>
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://developer.mozilla.org/en-US/docs/Web/Events/mozbrowserlocationchange
|
// https://developer.mozilla.org/en-US/docs/Web/Events/mozbrowserlocationchange
|
||||||
|
// Note that this is a no-op if the pipeline is not an immediate child iframe of the root
|
||||||
fn trigger_mozbrowserlocationchange(&self, pipeline_id: PipelineId) {
|
fn trigger_mozbrowserlocationchange(&self, pipeline_id: PipelineId) {
|
||||||
if prefs::get_pref("dom.mozbrowser.enabled").as_boolean().unwrap_or(false) {
|
if !prefs::get_pref("dom.mozbrowser.enabled").as_boolean().unwrap_or(false) { return; }
|
||||||
let event_info = self.pipelines.get(&pipeline_id).and_then(|pipeline| {
|
|
||||||
pipeline.parent_info.map(|(containing_pipeline_id, subpage_id)| {
|
|
||||||
(containing_pipeline_id, subpage_id, pipeline.url.serialize())
|
|
||||||
})
|
|
||||||
});
|
|
||||||
|
|
||||||
// If this is an iframe, then send the event with new url
|
let event_info = self.pipelines.get(&pipeline_id).and_then(|pipeline| {
|
||||||
if let Some((containing_pipeline_id, subpage_id, url)) = event_info {
|
pipeline.parent_info.map(|(containing_pipeline_id, subpage_id)| {
|
||||||
if let Some(parent_pipeline) = self.pipelines.get(&containing_pipeline_id) {
|
(containing_pipeline_id, subpage_id, pipeline.url.serialize())
|
||||||
if let Some(frame_id) = self.pipeline_to_frame_map.get(&pipeline_id) {
|
})
|
||||||
if let Some(frame) = self.frames.get(&frame_id) {
|
});
|
||||||
let can_go_backward = !frame.prev.is_empty();
|
|
||||||
let can_go_forward = !frame.next.is_empty();
|
// If this is an iframe, then send the event with new url
|
||||||
let event = MozBrowserEvent::LocationChange(url, can_go_backward, can_go_forward);
|
if let Some((containing_pipeline_id, subpage_id, url)) = event_info {
|
||||||
parent_pipeline.trigger_mozbrowser_event(subpage_id, event);
|
if let Some(parent_pipeline) = self.pipelines.get(&containing_pipeline_id) {
|
||||||
}
|
if let Some(frame_id) = self.pipeline_to_frame_map.get(&pipeline_id) {
|
||||||
|
if let Some(frame) = self.frames.get(&frame_id) {
|
||||||
|
let can_go_backward = !frame.prev.is_empty();
|
||||||
|
let can_go_forward = !frame.next.is_empty();
|
||||||
|
let event = MozBrowserEvent::LocationChange(url, can_go_backward, can_go_forward);
|
||||||
|
parent_pipeline.trigger_mozbrowser_event(subpage_id, event);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// https://developer.mozilla.org/en-US/docs/Web/Events/mozbrowsererror
|
||||||
|
// Note that this does not require the pipeline to be an immediate child of the root
|
||||||
|
// TODO: propagate more error information, e.g. a backtrace
|
||||||
|
fn trigger_mozbrowsererror(&self, pipeline_id: PipelineId) {
|
||||||
|
if !prefs::get_pref("dom.mozbrowser.enabled").as_boolean().unwrap_or(false) { return; }
|
||||||
|
|
||||||
|
if let Some(pipeline) = self.pipelines.get(&pipeline_id) {
|
||||||
|
if let Some(mut ancestor_info) = pipeline.parent_info {
|
||||||
|
if let Some(mut ancestor) = self.pipelines.get(&ancestor_info.0) {
|
||||||
|
while let Some(next_info) = ancestor.parent_info {
|
||||||
|
ancestor_info = next_info;
|
||||||
|
ancestor = match self.pipelines.get(&ancestor_info.0) {
|
||||||
|
Some(ancestor) => ancestor,
|
||||||
|
None => return warn!("Mozbrowsererror via closed pipeline {:?}.", ancestor_info.0),
|
||||||
|
};
|
||||||
|
}
|
||||||
|
let event = MozBrowserEvent::Error;
|
||||||
|
ancestor.trigger_mozbrowser_event(ancestor_info.1, event);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
fn focused_pipeline_in_tree(&self, frame_id: FrameId) -> bool {
|
fn focused_pipeline_in_tree(&self, frame_id: FrameId) -> bool {
|
||||||
self.focus_pipeline_id.map_or(false, |pipeline_id| {
|
self.focus_pipeline_id.map_or(false, |pipeline_id| {
|
||||||
self.pipeline_exists_in_tree(pipeline_id, Some(frame_id))
|
self.pipeline_exists_in_tree(pipeline_id, Some(frame_id))
|
||||||
|
@ -1956,4 +1983,5 @@ impl<LTF: LayoutThreadFactory, STF: ScriptThreadFactory> Constellation<LTF, STF>
|
||||||
self.current_frame_tree_iter(root_frame_id)
|
self.current_frame_tree_iter(root_frame_id)
|
||||||
.any(|current_frame| current_frame.current == pipeline_id)
|
.any(|current_frame| current_frame.current == pipeline_id)
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue