aboutsummaryrefslogtreecommitdiffstats
path: root/components/script/script_thread.rs
diff options
context:
space:
mode:
authorAlan Jeffrey <ajeffrey@mozilla.com>2016-11-03 14:10:41 -0500
committerMichael Howell <michael@notriddle.com>2016-11-09 01:29:25 +0000
commit0e7ffafbe11c5969a8492a7f7f5c635ca56c8f0e (patch)
tree9e6d1bbe11db653e948e17e08678805c061b05f4 /components/script/script_thread.rs
parentd1b7f19410cb882280287b482bd7178a6eb529b1 (diff)
downloadservo-0e7ffafbe11c5969a8492a7f7f5c635ca56c8f0e.tar.gz
servo-0e7ffafbe11c5969a8492a7f7f5c635ca56c8f0e.zip
Script thread lifetime is now managed by the constellation.
Diffstat (limited to 'components/script/script_thread.rs')
-rw-r--r--components/script/script_thread.rs39
1 files changed, 24 insertions, 15 deletions
diff --git a/components/script/script_thread.rs b/components/script/script_thread.rs
index cad12814195..cccfbda842d 100644
--- a/components/script/script_thread.rs
+++ b/components/script/script_thread.rs
@@ -840,10 +840,9 @@ impl ScriptThread {
let result = self.profile_event(category, move || {
match msg {
- FromConstellation(ConstellationControlMsg::ExitPipeline(id)) => {
- if self.handle_exit_pipeline_msg(id) {
- return Some(false)
- }
+ FromConstellation(ConstellationControlMsg::ExitScriptThread) => {
+ self.handle_exit_script_thread_msg();
+ return Some(false);
},
FromConstellation(inner_msg) => self.handle_msg_from_constellation(inner_msg),
FromScript(inner_msg) => self.handle_msg_from_script(inner_msg),
@@ -990,11 +989,13 @@ impl ScriptThread {
self.handle_css_error_reporting(pipeline_id, filename, line, column, msg),
ConstellationControlMsg::Reload(pipeline_id) =>
self.handle_reload(pipeline_id),
+ ConstellationControlMsg::ExitPipeline(pipeline_id) =>
+ self.handle_exit_pipeline_msg(pipeline_id),
msg @ ConstellationControlMsg::AttachLayout(..) |
msg @ ConstellationControlMsg::Viewport(..) |
msg @ ConstellationControlMsg::SetScrollState(..) |
msg @ ConstellationControlMsg::Resize(..) |
- msg @ ConstellationControlMsg::ExitPipeline(..) =>
+ msg @ ConstellationControlMsg::ExitScriptThread =>
panic!("should have handled {:?} already", msg),
}
}
@@ -1487,10 +1488,9 @@ impl ScriptThread {
document.send_title_to_compositor();
}
- /// Handles a request to exit the script thread and shut down layout.
- /// Returns true if the script thread should shut down and false otherwise.
- fn handle_exit_pipeline_msg(&self, id: PipelineId) -> bool {
- debug!("Exiting pipeline {:?}.", id);
+ /// Handles a request to exit a pipeline and shut down layout.
+ fn handle_exit_pipeline_msg(&self, id: PipelineId) {
+ debug!("Exiting pipeline {}.", id);
self.closed_pipelines.borrow_mut().insert(id);
@@ -1507,7 +1507,7 @@ impl ScriptThread {
let (response_chan, response_port) = channel();
let chan = &load.layout_chan;
if chan.send(message::Msg::PrepareToExit(response_chan)).is_ok() {
- debug!("shutting down layout for page {:?}", id);
+ debug!("shutting down layout for page {}", id);
response_port.recv().unwrap();
chan.send(message::Msg::ExitNow).ok();
}
@@ -1518,13 +1518,22 @@ impl ScriptThread {
let _ = self.constellation_chan.send(ConstellationMsg::PipelineExited(id));
}
- let no_pending_loads = self.incomplete_loads.borrow().is_empty();
- let no_remaining_contexts = self.documents.borrow().is_empty();
+ debug!("Exited pipeline {}.", id);
+ }
- debug!("Exited pipeline {:?} ({}&{}).", id, no_pending_loads, no_remaining_contexts);
+ /// Handles a request to exit the script thread and shut down layout.
+ fn handle_exit_script_thread_msg(&self) {
+ debug!("Exiting script thread.");
+
+ let mut pipeline_ids = Vec::new();
+ pipeline_ids.extend(self.incomplete_loads.borrow().iter().next().map(|load| load.pipeline_id));
+ pipeline_ids.extend(self.documents.borrow().iter().next().map(|(pipeline_id, _)| pipeline_id));
+
+ for pipeline_id in pipeline_ids {
+ self.handle_exit_pipeline_msg(pipeline_id);
+ }
- // Exit if no pending loads and no remaining contexts
- no_pending_loads && no_remaining_contexts
+ debug!("Exited script thread.");
}
/// Handles when layout thread finishes all animation in one tick