Auto merge of #27163 - alarsyo:23053-layout-queries-disconnected-frames-panic, r=jdm

Return Option for Window's layout channel

<!-- Please describe your changes on the following line: -->

`Window::layout_chan()` now returns an `Option<Sender<Msg>>`, returning `None` if the window is dead.

FIX #26969
FIX #26429
FIX #21208
FIX #19092
FIX #22559
FIX #22584
FIX #22652

---
<!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `___` with appropriate data: -->
- [X] `./mach build -d` does not report any errors
- [X] `./mach test-tidy` does not report any errors
- [X] These changes fix #23053

<!-- Either: -->
- [x] There are tests for these changes

<!-- Also, please make sure that "Allow edits from maintainers" checkbox is checked, so that we can help you if you get stuck somewhere along the way.-->

<!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. -->

This is my first contribution, I'm trying to figure things out!

This fix passes the test case shown in #23053, however I don't know what the behavior should be in `Document` and `ScriptThread` if `Window::is_alive()` is false : simply ignore it, don't do anything ? Or is this something that should not happen now that we return false in `Window::force_reflow()` ?

I'm not sure about the directory where the test case should go, any advice?
This commit is contained in:
bors-servo 2020-07-04 01:30:27 -04:00 committed by GitHub
commit 8916a42180
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 84 additions and 32 deletions

View file

@ -1172,9 +1172,13 @@ impl ScriptThread {
);
},
};
let _ = window
.layout_chan()
.send(Msg::RegisterPaint(name, properties, painter));
match window.layout_chan() {
Some(chan) => chan
.send(Msg::RegisterPaint(name, properties, painter))
.unwrap(),
None => warn!("Layout channel unavailable"),
}
}
pub fn push_new_element_queue() {
@ -2467,12 +2471,12 @@ impl ScriptThread {
});
// Pick a layout thread, any layout thread
let current_layout_chan = self
let current_layout_chan: Option<Sender<Msg>> = self
.documents
.borrow()
.iter()
.next()
.map(|(_, document)| document.window().layout_chan().clone())
.and_then(|(_, document)| document.window().layout_chan().cloned())
.or_else(|| {
self.incomplete_loads
.borrow()
@ -2879,7 +2883,10 @@ impl ScriptThread {
let load = self.incomplete_loads.borrow_mut().remove(idx);
load.layout_chan.clone()
} else if let Some(ref document) = document {
document.window().layout_chan().clone()
match document.window().layout_chan() {
Some(chan) => chan.clone(),
None => return warn!("Layout channel unavailable"),
}
} else {
return warn!("Exiting nonexistant pipeline {}.", id);
};