mirror of
https://github.com/servo/servo.git
synced 2025-08-07 14:35:33 +01:00
Auto merge of #10551 - asajeffrey:trigger-mozbrowsererror-event, r=jdm
Trigger mozbrowsererror event when a pipeline fails. Addresses part of #10334 (it fires the event, but does not include a backtrace). <!-- Reviewable:start --> --- This change is [<img src="https://reviewable.io/review_button.svg" height="35" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/10551) <!-- Reviewable:end -->
This commit is contained in:
commit
4001a24c46
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,8 +1919,10 @@ 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| {
|
let event_info = self.pipelines.get(&pipeline_id).and_then(|pipeline| {
|
||||||
pipeline.parent_info.map(|(containing_pipeline_id, subpage_id)| {
|
pipeline.parent_info.map(|(containing_pipeline_id, subpage_id)| {
|
||||||
(containing_pipeline_id, subpage_id, pipeline.url.serialize())
|
(containing_pipeline_id, subpage_id, pipeline.url.serialize())
|
||||||
|
@ -1938,6 +1943,28 @@ impl<LTF: LayoutThreadFactory, STF: ScriptThreadFactory> Constellation<LTF, STF>
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 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 {
|
||||||
|
@ -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