From e84106535175211526729e532058a7514a0de372 Mon Sep 17 00:00:00 2001 From: Patrick Walton Date: Fri, 10 Jul 2015 18:08:03 -0700 Subject: compositing: Move messages that go over the `ScriptListener` to go over an IPC channel instead. Because this used a boxed trait object to invoke messages across a process boundary, and boxed trait objects are not supported across IPC, we spawn a helper thread inside the compositor to perform the marshaling for us. --- components/script/script_task.rs | 38 +++++++++++++++++++------------------- 1 file changed, 19 insertions(+), 19 deletions(-) (limited to 'components/script/script_task.rs') diff --git a/components/script/script_task.rs b/components/script/script_task.rs index 49f9ecdfa2d..693e89058ef 100644 --- a/components/script/script_task.rs +++ b/components/script/script_task.rs @@ -297,8 +297,9 @@ pub struct ScriptTask { /// For communicating load url messages to the constellation constellation_chan: ConstellationChan, + /// A handle to the compositor for communicating ready state messages. - compositor: DOMRefCell>, + compositor: DOMRefCell, /// The port on which we receive messages from the image cache image_cache_port: Receiver, @@ -374,29 +375,28 @@ impl ScriptTaskFactory for ScriptTask { box pair.sender() as Box } - fn create(_phantom: Option<&mut ScriptTask>, - id: PipelineId, - parent_info: Option<(PipelineId, SubpageId)>, - compositor: C, - layout_chan: &OpaqueScriptLayoutChannel, - control_chan: ScriptControlChan, - control_port: Receiver, - constellation_chan: ConstellationChan, - failure_msg: Failure, - resource_task: ResourceTask, - storage_task: StorageTask, - image_cache_task: ImageCacheTask, - devtools_chan: Option, - window_size: Option, - load_data: LoadData) - where C: ScriptListener + Send + 'static { + fn create(_phantom: Option<&mut ScriptTask>, + id: PipelineId, + parent_info: Option<(PipelineId, SubpageId)>, + compositor: ScriptListener, + layout_chan: &OpaqueScriptLayoutChannel, + control_chan: ScriptControlChan, + control_port: Receiver, + constellation_chan: ConstellationChan, + failure_msg: Failure, + resource_task: ResourceTask, + storage_task: StorageTask, + image_cache_task: ImageCacheTask, + devtools_chan: Option, + window_size: Option, + load_data: LoadData) { let ConstellationChan(const_chan) = constellation_chan.clone(); let (script_chan, script_port) = channel(); let layout_chan = LayoutChan(layout_chan.sender()); spawn_named_with_send_on_failure(format!("ScriptTask {:?}", id), task_state::SCRIPT, move || { let roots = RootCollection::new(); let _stack_roots_tls = StackRootTLS::new(&roots); - let script_task = ScriptTask::new(box compositor as Box, + let script_task = ScriptTask::new(compositor, script_port, NonWorkerScriptChan(script_chan), control_chan, @@ -464,7 +464,7 @@ impl ScriptTask { } /// Creates a new script task. - pub fn new(compositor: Box, + pub fn new(compositor: ScriptListener, port: Receiver, chan: NonWorkerScriptChan, control_chan: ScriptControlChan, -- cgit v1.2.3