servo: Merge #14344 - Script thread creating layout thread should use the incomplete loads (from asajeffrey:script-thread-new-layout-use-incomplete-loads); r=jdm

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

When a script thread creates a new layout thread, it does so by sending a message to an existing layout thread asking it to spawn. At the moment, we're only looking at the completed loads for that layout thread, so we can get a panic if two loads happen in quick succession. The temporary fix is to look for the layout thread in the incomplete loads too.

---
<!-- 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 #14333.
- [X] These changes do not require tests because it fixes a panic.

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

Source-Repo: https://github.com/servo/servo
Source-Revision: 99c4821485de30eabc0eb81af9cc5e5102e2f3f6
This commit is contained in:
Alan Jeffrey 2016-11-24 04:57:50 -08:00
Родитель f15dfb6ad6
Коммит 8d04971274
1 изменённых файлов: 6 добавлений и 2 удалений

Просмотреть файл

@ -1201,10 +1201,14 @@ impl ScriptThread {
});
// Pick a layout thread, any layout thread
match self.documents.borrow().iter().next() {
let current_layout_chan = self.documents.borrow().iter().next()
.map(|(_, document)| document.window().layout_chan().clone())
.or_else(|| self.incomplete_loads.borrow().first().map(|load| load.layout_chan.clone()));
match current_layout_chan {
None => panic!("Layout attached to empty script thread."),
// Tell the layout thread factory to actually spawn the thread.
Some((_, document)) => document.window().layout_chan().send(msg).unwrap(),
Some(layout_chan) => layout_chan.send(msg).unwrap(),
};
// Kick off the fetch for the new resource.