From c05f0906d55831a97571d9eec13735ebfa975c49 Mon Sep 17 00:00:00 2001 From: Ms2ger Date: Wed, 12 Aug 2015 15:18:17 +0200 Subject: [PATCH 01/10] Store a Sender in ScriptTask. --- components/compositing/pipeline.rs | 2 +- components/script/script_task.rs | 10 +++++----- components/script_traits/lib.rs | 2 +- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/components/compositing/pipeline.rs b/components/compositing/pipeline.rs index 68f977f7ea6..e61d597b4b5 100644 --- a/components/compositing/pipeline.rs +++ b/components/compositing/pipeline.rs @@ -331,7 +331,7 @@ impl PipelineContent { self.parent_info, ScriptListener::new(script_to_compositor_chan), &layout_pair, - self.script_chan.clone(), + self.script_chan.0.clone(), mem::replace(&mut self.script_port, None).unwrap(), self.constellation_chan.clone(), self.failure.clone(), diff --git a/components/script/script_task.rs b/components/script/script_task.rs index efbad39dc86..43c047c3231 100644 --- a/components/script/script_task.rs +++ b/components/script/script_task.rs @@ -311,7 +311,7 @@ pub struct ScriptTask { chan: NonWorkerScriptChan, /// A channel to hand out to tasks that need to respond to a message from the script task. - control_chan: ScriptControlChan, + control_chan: Sender, /// The port on which the constellation and layout tasks can communicate with the /// script task. @@ -405,7 +405,7 @@ impl ScriptTaskFactory for ScriptTask { parent_info: Option<(PipelineId, SubpageId)>, compositor: ScriptListener, layout_chan: &OpaqueScriptLayoutChannel, - control_chan: ScriptControlChan, + control_chan: Sender, control_port: Receiver, constellation_chan: ConstellationChan, failure_msg: Failure, @@ -542,7 +542,7 @@ impl ScriptTask { pub fn new(compositor: ScriptListener, port: Receiver, chan: NonWorkerScriptChan, - control_chan: ScriptControlChan, + control_chan: Sender, control_port: Receiver, constellation_chan: ConstellationChan, resource_task: Arc, @@ -1053,7 +1053,7 @@ impl ScriptTask { constellation_chan: self.constellation_chan.clone(), failure: failure, paint_chan: paint_chan, - script_chan: self.control_chan.0.clone(), + script_chan: self.control_chan.clone(), image_cache_task: self.image_cache_task.clone(), layout_shutdown_chan: layout_shutdown_chan, }; @@ -1466,7 +1466,7 @@ impl ScriptTask { page.clone(), self.chan.clone(), self.image_cache_channel.clone(), - self.control_chan.clone(), + ScriptControlChan(self.control_chan.clone()), self.compositor.borrow_mut().dup(), self.image_cache_task.clone(), self.resource_task.clone(), diff --git a/components/script_traits/lib.rs b/components/script_traits/lib.rs index c5dec4d5b4f..9ebeb1cd2e0 100644 --- a/components/script_traits/lib.rs +++ b/components/script_traits/lib.rs @@ -185,7 +185,7 @@ pub trait ScriptTaskFactory { parent_info: Option<(PipelineId, SubpageId)>, compositor: ScriptListener, layout_chan: &OpaqueScriptLayoutChannel, - control_chan: ScriptControlChan, + control_chan: Sender, control_port: Receiver, constellation_msg: ConstellationChan, failure_msg: Failure, From 26d191f0683bae5ab6b9f1e9ea5d12e78e117035 Mon Sep 17 00:00:00 2001 From: Ms2ger Date: Wed, 12 Aug 2015 15:32:30 +0200 Subject: [PATCH 02/10] Remove the unused Window::control_chan() method. --- components/script/dom/window.rs | 4 ---- 1 file changed, 4 deletions(-) diff --git a/components/script/dom/window.rs b/components/script/dom/window.rs index 7bfdf4e46d4..7788fe05dd7 100644 --- a/components/script/dom/window.rs +++ b/components/script/dom/window.rs @@ -264,10 +264,6 @@ impl Window { (box NonWorkerScriptChan(tx), box rx) } - pub fn control_chan<'a>(&'a self) -> &'a ScriptControlChan { - &self.control_chan - } - pub fn image_cache_task<'a>(&'a self) -> &'a ImageCacheTask { &self.image_cache_task } From 41ac66112aa36497dc0761620be5f5ace7f610ed Mon Sep 17 00:00:00 2001 From: Ms2ger Date: Wed, 12 Aug 2015 15:34:41 +0200 Subject: [PATCH 03/10] Store a Sender in Window. --- components/script/dom/window.rs | 10 +++++----- components/script/script_task.rs | 4 ++-- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/components/script/dom/window.rs b/components/script/dom/window.rs index 7788fe05dd7..f2c92b79ed9 100644 --- a/components/script/dom/window.rs +++ b/components/script/dom/window.rs @@ -36,7 +36,7 @@ use layout_interface::{ContentBoxResponse, ContentBoxesResponse, ResolvedStyleRe use page::Page; use script_task::{TimerSource, ScriptChan, ScriptPort, NonWorkerScriptChan}; use script_task::ScriptMsg; -use script_traits::ScriptControlChan; +use script_traits::{ConstellationControlMsg, ScriptControlChan}; use timers::{IsInterval, TimerId, TimerManager, TimerCallback}; use webdriver_handlers::jsval_to_webdriver; @@ -77,7 +77,7 @@ use std::mem as std_mem; use std::rc::Rc; use std::sync::Arc; use std::sync::mpsc::TryRecvError::{Empty, Disconnected}; -use std::sync::mpsc::{channel, Receiver}; +use std::sync::mpsc::{channel, Receiver, Sender}; use time; /// Current state of the window object @@ -112,7 +112,7 @@ pub struct Window { #[ignore_heap_size_of = "trait objects are hard"] script_chan: Box, #[ignore_heap_size_of = "channels are hard"] - control_chan: ScriptControlChan, + control_chan: Sender, console: MutNullableHeap>, crypto: MutNullableHeap>, navigator: MutNullableHeap>, @@ -744,7 +744,7 @@ impl<'a> WindowHelpers for &'a Window { }, document_root: root.to_trusted_node_address(), window_size: window_size, - script_chan: self.control_chan.clone(), + script_chan: ScriptControlChan(self.control_chan.clone()), script_join_chan: join_chan, id: last_reflow_id.get(), query_type: query_type, @@ -1073,7 +1073,7 @@ impl Window { page: Rc, script_chan: Box, image_cache_chan: ImageCacheChan, - control_chan: ScriptControlChan, + control_chan: Sender, compositor: ScriptListener, image_cache_task: ImageCacheTask, resource_task: Arc, diff --git a/components/script/script_task.rs b/components/script/script_task.rs index 43c047c3231..6b170e5b1b2 100644 --- a/components/script/script_task.rs +++ b/components/script/script_task.rs @@ -60,7 +60,7 @@ use script_traits::CompositorEvent::{MouseDownEvent, MouseUpEvent}; use script_traits::CompositorEvent::{MouseMoveEvent, KeyEvent}; use script_traits::CompositorEvent::{ResizeEvent, ClickEvent}; use script_traits::{CompositorEvent, MouseButton}; -use script_traits::{ConstellationControlMsg, ScriptControlChan}; +use script_traits::ConstellationControlMsg; use script_traits::{NewLayoutInfo, OpaqueScriptLayoutChannel}; use script_traits::{ScriptState, ScriptTaskFactory}; use msg::compositor_msg::{LayerId, ScriptListener}; @@ -1466,7 +1466,7 @@ impl ScriptTask { page.clone(), self.chan.clone(), self.image_cache_channel.clone(), - ScriptControlChan(self.control_chan.clone()), + self.control_chan.clone(), self.compositor.borrow_mut().dup(), self.image_cache_task.clone(), self.resource_task.clone(), From 4f9ec8915d6169d3dbff2891b07f7d81b8d56f8f Mon Sep 17 00:00:00 2001 From: Ms2ger Date: Wed, 12 Aug 2015 15:42:37 +0200 Subject: [PATCH 04/10] Store a Sender in ScriptReflow. --- components/layout/layout_task.rs | 3 +-- components/script/dom/window.rs | 4 ++-- components/script/layout_interface.rs | 4 ++-- 3 files changed, 5 insertions(+), 6 deletions(-) diff --git a/components/layout/layout_task.rs b/components/layout/layout_task.rs index 76baafc8013..3b3ae0e4009 100644 --- a/components/layout/layout_task.rs +++ b/components/layout/layout_task.rs @@ -1197,8 +1197,7 @@ impl LayoutTask { // FIXME(pcwalton): This should probably be *one* channel, but we can't fix this without // either select or a filtered recv() that only looks for messages of a given type. data.script_join_chan.send(()).unwrap(); - let ScriptControlChan(ref chan) = data.script_chan; - chan.send(ConstellationControlMsg::ReflowComplete(self.id, data.id)).unwrap(); + data.script_chan.send(ConstellationControlMsg::ReflowComplete(self.id, data.id)).unwrap(); } fn set_visible_rects<'a>(&'a self, diff --git a/components/script/dom/window.rs b/components/script/dom/window.rs index f2c92b79ed9..3190e6081dc 100644 --- a/components/script/dom/window.rs +++ b/components/script/dom/window.rs @@ -36,7 +36,7 @@ use layout_interface::{ContentBoxResponse, ContentBoxesResponse, ResolvedStyleRe use page::Page; use script_task::{TimerSource, ScriptChan, ScriptPort, NonWorkerScriptChan}; use script_task::ScriptMsg; -use script_traits::{ConstellationControlMsg, ScriptControlChan}; +use script_traits::ConstellationControlMsg; use timers::{IsInterval, TimerId, TimerManager, TimerCallback}; use webdriver_handlers::jsval_to_webdriver; @@ -744,7 +744,7 @@ impl<'a> WindowHelpers for &'a Window { }, document_root: root.to_trusted_node_address(), window_size: window_size, - script_chan: ScriptControlChan(self.control_chan.clone()), + script_chan: self.control_chan.clone(), script_join_chan: join_chan, id: last_reflow_id.get(), query_type: query_type, diff --git a/components/script/layout_interface.rs b/components/script/layout_interface.rs index a6fb9ad8491..53ab48a7769 100644 --- a/components/script/layout_interface.rs +++ b/components/script/layout_interface.rs @@ -19,7 +19,7 @@ use msg::compositor_msg::Epoch; use net_traits::image_cache_task::ImageCacheTask; use net_traits::PendingAsyncLoad; use profile_traits::mem::ReportsChan; -use script_traits::{ConstellationControlMsg, LayoutControlMsg, ScriptControlChan}; +use script_traits::{ConstellationControlMsg, LayoutControlMsg}; use script_traits::{OpaqueScriptLayoutChannel, StylesheetLoadResponder, UntrustedNodeAddress}; use selectors::parser::PseudoElement; use std::any::Any; @@ -167,7 +167,7 @@ pub struct ScriptReflow { /// The document node. pub document_root: TrustedNodeAddress, /// The channel through which messages can be sent back to the script task. - pub script_chan: ScriptControlChan, + pub script_chan: Sender, /// The current window size. pub window_size: WindowSizeData, /// The channel that we send a notification to. From fdafc5c360a74e669e3dede816733b302838a9de Mon Sep 17 00:00:00 2001 From: Ms2ger Date: Wed, 12 Aug 2015 15:55:16 +0200 Subject: [PATCH 05/10] Store a Sender in LayoutTask. --- components/compositing/pipeline.rs | 2 +- components/layout/animation.rs | 5 ++--- components/layout/layout_task.rs | 13 ++++++------- components/layout_traits/lib.rs | 4 ++-- 4 files changed, 11 insertions(+), 13 deletions(-) diff --git a/components/compositing/pipeline.rs b/components/compositing/pipeline.rs index e61d597b4b5..cbd905ef00e 100644 --- a/components/compositing/pipeline.rs +++ b/components/compositing/pipeline.rs @@ -351,7 +351,7 @@ impl PipelineContent { self.pipeline_port.unwrap(), self.constellation_chan, self.failure, - self.script_chan.clone(), + self.script_chan.0.clone(), self.layout_to_paint_chan.clone(), self.image_cache_task, self.font_cache_task, diff --git a/components/layout/animation.rs b/components/layout/animation.rs index e8acb3b3229..a3f27267c00 100644 --- a/components/layout/animation.rs +++ b/components/layout/animation.rs @@ -12,7 +12,7 @@ use gfx::display_list::OpaqueNode; use layout_task::{LayoutTask, LayoutTaskData}; use msg::constellation_msg::{AnimationState, Msg, PipelineId}; use script::layout_interface::Animation; -use script_traits::{ConstellationControlMsg, ScriptControlChan}; +use script_traits::ConstellationControlMsg; use std::collections::HashMap; use std::collections::hash_map::Entry; use std::sync::Arc; @@ -128,7 +128,6 @@ pub fn recalc_style_for_animations(flow: &mut Flow, pub fn tick_all_animations(layout_task: &LayoutTask, rw_data: &mut LayoutTaskData) { layout_task.tick_animations(rw_data); - let ScriptControlChan(ref chan) = layout_task.script_chan; - chan.send(ConstellationControlMsg::TickAllAnimations(layout_task.id)).unwrap(); + layout_task.script_chan.send(ConstellationControlMsg::TickAllAnimations(layout_task.id)).unwrap(); } diff --git a/components/layout/layout_task.rs b/components/layout/layout_task.rs index 3b3ae0e4009..80403c1dca3 100644 --- a/components/layout/layout_task.rs +++ b/components/layout/layout_task.rs @@ -59,7 +59,7 @@ use script::layout_interface::{LayoutChan, LayoutRPC, OffsetParentResponse}; use script::layout_interface::{NewLayoutTaskInfo, Msg, Reflow, ReflowGoal, ReflowQueryType}; use script::layout_interface::{ScriptLayoutChan, ScriptReflow, TrustedNodeAddress}; use script_traits::{ConstellationControlMsg, LayoutControlMsg, OpaqueScriptLayoutChannel}; -use script_traits::{ScriptControlChan, StylesheetLoadResponder}; +use script_traits::StylesheetLoadResponder; use selectors::parser::PseudoElement; use serde_json; use std::borrow::ToOwned; @@ -186,7 +186,7 @@ pub struct LayoutTask { pub constellation_chan: ConstellationChan, /// The channel on which messages can be sent to the script task. - pub script_chan: ScriptControlChan, + pub script_chan: Sender, /// The channel on which messages can be sent to the painting task. pub paint_chan: OptionalIpcSender, @@ -228,7 +228,7 @@ impl LayoutTaskFactory for LayoutTask { pipeline_port: IpcReceiver, constellation_chan: ConstellationChan, failure_msg: Failure, - script_chan: ScriptControlChan, + script_chan: Sender, paint_chan: OptionalIpcSender, image_cache_task: ImageCacheTask, font_cache_task: FontCacheTask, @@ -311,7 +311,7 @@ impl LayoutTask { chan: LayoutChan, pipeline_port: IpcReceiver, constellation_chan: ConstellationChan, - script_chan: ScriptControlChan, + script_chan: Sender, paint_chan: OptionalIpcSender, image_cache_task: ImageCacheTask, font_cache_task: FontCacheTask, @@ -645,7 +645,7 @@ impl LayoutTask { info.pipeline_port, info.constellation_chan, info.failure, - ScriptControlChan(info.script_chan.clone()), + info.script_chan.clone(), *info.paint_chan .downcast::>() .unwrap(), @@ -726,8 +726,7 @@ impl LayoutTask { Origin::Author); //TODO: mark critical subresources as blocking load as well (#5974) - let ScriptControlChan(ref chan) = self.script_chan; - chan.send(ConstellationControlMsg::StylesheetLoadComplete(self.id, url, responder)).unwrap(); + self.script_chan.send(ConstellationControlMsg::StylesheetLoadComplete(self.id, url, responder)).unwrap(); self.handle_add_stylesheet(sheet, mq, possibly_locked_rw_data); } diff --git a/components/layout_traits/lib.rs b/components/layout_traits/lib.rs index d75817911a7..16b3bdcda06 100644 --- a/components/layout_traits/lib.rs +++ b/components/layout_traits/lib.rs @@ -28,7 +28,7 @@ use msg::constellation_msg::{ConstellationChan, Failure, PipelineId}; use profile_traits::mem; use profile_traits::time; use net_traits::image_cache_task::ImageCacheTask; -use script_traits::{LayoutControlMsg, ScriptControlChan, OpaqueScriptLayoutChannel}; +use script_traits::{LayoutControlMsg, ConstellationControlMsg, OpaqueScriptLayoutChannel}; use std::sync::mpsc::Sender; use url::Url; use util::ipc::OptionalIpcSender; @@ -49,7 +49,7 @@ pub trait LayoutTaskFactory { pipeline_port: IpcReceiver, constellation_chan: ConstellationChan, failure_msg: Failure, - script_chan: ScriptControlChan, + script_chan: Sender, layout_to_paint_chan: OptionalIpcSender, image_cache_task: ImageCacheTask, font_cache_task: FontCacheTask, From 947647426779dd4f7f2bb8e4ae82e6fd3d3ab072 Mon Sep 17 00:00:00 2001 From: Ms2ger Date: Wed, 12 Aug 2015 15:58:10 +0200 Subject: [PATCH 06/10] Store a Sender in PipelineContent. --- components/compositing/pipeline.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/components/compositing/pipeline.rs b/components/compositing/pipeline.rs index cbd905ef00e..ca3a6331b60 100644 --- a/components/compositing/pipeline.rs +++ b/components/compositing/pipeline.rs @@ -165,7 +165,7 @@ impl Pipeline { time_profiler_chan: time_profiler_chan, mem_profiler_chan: mem_profiler_chan, window_size: window_size, - script_chan: script_chan, + script_chan: script_chan.0, load_data: load_data, failure: failure, script_port: script_port, @@ -298,7 +298,7 @@ pub struct PipelineContent { time_profiler_chan: time::ProfilerChan, mem_profiler_chan: profile_mem::ProfilerChan, window_size: Option, - script_chan: ScriptControlChan, + script_chan: Sender, load_data: LoadData, failure: Failure, script_port: Option>, @@ -331,7 +331,7 @@ impl PipelineContent { self.parent_info, ScriptListener::new(script_to_compositor_chan), &layout_pair, - self.script_chan.0.clone(), + self.script_chan.clone(), mem::replace(&mut self.script_port, None).unwrap(), self.constellation_chan.clone(), self.failure.clone(), @@ -351,7 +351,7 @@ impl PipelineContent { self.pipeline_port.unwrap(), self.constellation_chan, self.failure, - self.script_chan.0.clone(), + self.script_chan.clone(), self.layout_to_paint_chan.clone(), self.image_cache_task, self.font_cache_task, From fafcc0a5da7b98f843fb53970bc020d9555fec31 Mon Sep 17 00:00:00 2001 From: Ms2ger Date: Wed, 12 Aug 2015 16:03:38 +0200 Subject: [PATCH 07/10] Store a Sender in CompositionPipeline. --- components/compositing/compositor.rs | 5 ++--- components/compositing/compositor_layer.rs | 8 +++----- components/compositing/pipeline.rs | 4 ++-- 3 files changed, 7 insertions(+), 10 deletions(-) diff --git a/components/compositing/compositor.rs b/components/compositing/compositor.rs index 5dfe85a4390..c7fc95d59a7 100644 --- a/components/compositing/compositor.rs +++ b/components/compositing/compositor.rs @@ -39,7 +39,7 @@ use msg::constellation_msg::{PipelineId, WindowSizeData}; use png; use profile_traits::mem::{self, Reporter, ReporterRequest, ReportKind}; use profile_traits::time::{self, ProfilerCategory, profile}; -use script_traits::{ConstellationControlMsg, LayoutControlMsg, ScriptControlChan}; +use script_traits::{ConstellationControlMsg, LayoutControlMsg}; use std::collections::HashMap; use std::collections::hash_map::Entry::{Occupied, Vacant}; use std::mem as std_mem; @@ -1278,8 +1278,7 @@ impl IOCompositor { let layer_rect = Rect::new(-layer.extra_data.borrow().scroll_offset.to_untyped(), layer.bounds.borrow().size.to_untyped()); let pipeline = self.get_pipeline(layer.pipeline_id()); - let ScriptControlChan(ref chan) = pipeline.script_chan; - chan.send(ConstellationControlMsg::Viewport(pipeline.id.clone(), layer_rect)).unwrap(); + pipeline.script_chan.send(ConstellationControlMsg::Viewport(pipeline.id.clone(), layer_rect)).unwrap(); } for kid in layer.children().iter() { diff --git a/components/compositing/compositor_layer.rs b/components/compositing/compositor_layer.rs index 71a21b0c9ba..0d3c27ab53f 100644 --- a/components/compositing/compositor_layer.rs +++ b/components/compositing/compositor_layer.rs @@ -14,7 +14,7 @@ use layers::color::Color; use layers::geometry::LayerPixel; use layers::layers::{Layer, LayerBufferSet}; use script_traits::CompositorEvent::{ClickEvent, MouseDownEvent, MouseMoveEvent, MouseUpEvent}; -use script_traits::{ScriptControlChan, ConstellationControlMsg}; +use script_traits::ConstellationControlMsg; use msg::compositor_msg::{Epoch, LayerId, LayerProperties, ScrollPolicy}; use msg::constellation_msg::PipelineId; use std::rc::Rc; @@ -360,8 +360,7 @@ impl CompositorLayer for Layer { }; let pipeline = compositor.get_pipeline(self.pipeline_id()); - let ScriptControlChan(ref chan) = pipeline.script_chan; - let _ = chan.send(ConstellationControlMsg::SendEvent(pipeline.id.clone(), message)); + let _ = pipeline.script_chan.send(ConstellationControlMsg::SendEvent(pipeline.id.clone(), message)); } fn send_mouse_move_event(&self, @@ -370,8 +369,7 @@ impl CompositorLayer for Layer { where Window: WindowMethods { let message = MouseMoveEvent(cursor.to_untyped()); let pipeline = compositor.get_pipeline(self.pipeline_id()); - let ScriptControlChan(ref chan) = pipeline.script_chan; - let _ = chan.send(ConstellationControlMsg::SendEvent(pipeline.id.clone(), message)); + let _ = pipeline.script_chan.send(ConstellationControlMsg::SendEvent(pipeline.id.clone(), message)); } fn scroll_layer_and_all_child_layers(&self, new_offset: TypedPoint2D) diff --git a/components/compositing/pipeline.rs b/components/compositing/pipeline.rs index ca3a6331b60..a854137f770 100644 --- a/components/compositing/pipeline.rs +++ b/components/compositing/pipeline.rs @@ -59,7 +59,7 @@ pub struct Pipeline { #[derive(Clone)] pub struct CompositionPipeline { pub id: PipelineId, - pub script_chan: ScriptControlChan, + pub script_chan: Sender, pub layout_chan: LayoutControlChan, pub chrome_to_paint_chan: Sender, } @@ -257,7 +257,7 @@ impl Pipeline { pub fn to_sendable(&self) -> CompositionPipeline { CompositionPipeline { id: self.id.clone(), - script_chan: self.script_chan.clone(), + script_chan: self.script_chan.0.clone(), layout_chan: self.layout_chan.clone(), chrome_to_paint_chan: self.chrome_to_paint_chan.clone(), } From 250fdc33f44a8dfbac9b7ee637d41ff02d1eb9f3 Mon Sep 17 00:00:00 2001 From: Ms2ger Date: Wed, 12 Aug 2015 16:15:21 +0200 Subject: [PATCH 08/10] Store a Sender in Pipeline. --- components/compositing/constellation.rs | 33 +++++++++---------------- components/compositing/pipeline.rs | 21 ++++++---------- 2 files changed, 20 insertions(+), 34 deletions(-) diff --git a/components/compositing/constellation.rs b/components/compositing/constellation.rs index 50e755eb086..d66966cbd26 100644 --- a/components/compositing/constellation.rs +++ b/components/compositing/constellation.rs @@ -606,7 +606,6 @@ impl Constellation { (pipeline.id, pipeline.script_chan.clone()) }; - let ScriptControlChan(ref script_chan) = script_chan; script_chan.send(ConstellationControlMsg::Resize(pipeline_id, WindowSizeData { visible_viewport: rect.size, initial_viewport: rect.size * ScaleFactor::new(1.0), @@ -649,7 +648,7 @@ impl Constellation { if same_script { debug!("Constellation: loading same-origin iframe, \ parent url {:?}, iframe url {:?}", source_url, url); - Some(source_pipeline.script_chan.clone()) + Some(ScriptControlChan(source_pipeline.script_chan.clone())) } else { debug!("Constellation: loading cross-origin iframe, \ parent url {:?}, iframe url {:?}", source_url, url); @@ -706,7 +705,7 @@ impl Constellation { // Message the constellation to find the script task for this iframe // and issue an iframe load through there. let parent_pipeline = self.pipeline(parent_pipeline_id); - let ScriptControlChan(ref script_channel) = parent_pipeline.script_chan; + let script_channel = &parent_pipeline.script_chan; script_channel.send(ConstellationControlMsg::Navigate(parent_pipeline_id, subpage_id, load_data)).unwrap(); @@ -837,7 +836,7 @@ impl Constellation { // Update the owning iframe to point to the new subpage id. // This makes things like contentDocument work correctly. if let Some((parent_pipeline_id, subpage_id)) = pipeline_info { - let ScriptControlChan(ref script_chan) = self.pipeline(parent_pipeline_id).script_chan; + let script_chan = &self.pipeline(parent_pipeline_id).script_chan; let (_, new_subpage_id) = self.pipeline(next_pipeline_id).parent_info.unwrap(); script_chan.send(ConstellationControlMsg::UpdateSubpageId(parent_pipeline_id, subpage_id, @@ -860,10 +859,9 @@ impl Constellation { match target_pipeline_id { Some(target_pipeline_id) => { let pipeline = self.pipeline(target_pipeline_id); - let ScriptControlChan(ref chan) = pipeline.script_chan; let event = CompositorEvent::KeyEvent(key, state, mods); - chan.send(ConstellationControlMsg::SendEvent(pipeline.id, - event)).unwrap(); + pipeline.script_chan.send( + ConstellationControlMsg::SendEvent(pipeline.id, event)).unwrap(); } None => { let event = CompositorMsg::KeyEvent(key, state, mods); @@ -876,8 +874,7 @@ impl Constellation { match self.pipelines.get(&pipeline_id) { None => self.compositor_proxy.send(CompositorMsg::ChangePageTitle(pipeline_id, None)), Some(pipeline) => { - let ScriptControlChan(ref script_channel) = pipeline.script_chan; - script_channel.send(ConstellationControlMsg::GetTitle(pipeline_id)).unwrap(); + pipeline.script_chan.send(ConstellationControlMsg::GetTitle(pipeline_id)).unwrap(); } } } @@ -920,10 +917,9 @@ impl Constellation { // telling it to mark the iframe element as focused. if let Some((containing_pipeline_id, subpage_id)) = self.pipeline(pipeline_id).parent_info { let pipeline = self.pipeline(containing_pipeline_id); - let ScriptControlChan(ref script_channel) = pipeline.script_chan; let event = ConstellationControlMsg::FocusIFrame(containing_pipeline_id, subpage_id); - script_channel.send(event).unwrap(); + pipeline.script_chan.send(event).unwrap(); self.focus_parent_pipeline(containing_pipeline_id); } @@ -997,8 +993,7 @@ impl Constellation { WebDriverCommandMsg::ScriptCommand(pipeline_id, cmd) => { let pipeline = self.pipeline(pipeline_id); let control_msg = ConstellationControlMsg::WebDriverScriptCommand(pipeline_id, cmd); - let ScriptControlChan(ref script_channel) = pipeline.script_chan; - script_channel.send(control_msg).unwrap(); + pipeline.script_chan.send(control_msg).unwrap(); }, WebDriverCommandMsg::TakeScreenshot(pipeline_id, reply) => { let current_pipeline_id = self.root_frame_id.map(|frame_id| { @@ -1143,13 +1138,11 @@ impl Constellation { let frame = self.frames.get(&root_frame_id).unwrap(); let pipeline = self.pipelines.get(&frame.current).unwrap(); - let ScriptControlChan(ref chan) = pipeline.script_chan; - let _ = chan.send(ConstellationControlMsg::Resize(pipeline.id, new_size)); + let _ = pipeline.script_chan.send(ConstellationControlMsg::Resize(pipeline.id, new_size)); for pipeline_id in frame.prev.iter().chain(frame.next.iter()) { let pipeline = self.pipelines.get(pipeline_id).unwrap(); - let ScriptControlChan(ref chan) = pipeline.script_chan; - let _ = chan.send(ConstellationControlMsg::ResizeInactive(pipeline.id, new_size)); + let _ = pipeline.script_chan.send(ConstellationControlMsg::ResizeInactive(pipeline.id, new_size)); } } @@ -1157,8 +1150,7 @@ impl Constellation { for pending_frame in &self.pending_frames { let pipeline = self.pipelines.get(&pending_frame.new_pipeline_id).unwrap(); if pipeline.parent_info.is_none() { - let ScriptControlChan(ref chan) = pipeline.script_chan; - let _ = chan.send(ConstellationControlMsg::Resize(pipeline.id, new_size)); + let _ = pipeline.script_chan.send(ConstellationControlMsg::Resize(pipeline.id, new_size)); } } @@ -1198,10 +1190,9 @@ impl Constellation { // Synchronously query the script task for this pipeline // to see if it is idle. - let ScriptControlChan(ref script_chan) = pipeline.script_chan; let (sender, receiver) = channel(); let msg = ConstellationControlMsg::GetCurrentState(sender, frame.current); - script_chan.send(msg).unwrap(); + pipeline.script_chan.send(msg).unwrap(); if receiver.recv().unwrap() == ScriptState::DocumentLoading { return false; } diff --git a/components/compositing/pipeline.rs b/components/compositing/pipeline.rs index a854137f770..a73dc891d84 100644 --- a/components/compositing/pipeline.rs +++ b/components/compositing/pipeline.rs @@ -38,7 +38,7 @@ use util::opts; pub struct Pipeline { pub id: PipelineId, pub parent_info: Option<(PipelineId, SubpageId)>, - pub script_chan: ScriptControlChan, + pub script_chan: Sender, /// A channel to layout, for performing reflows and shutdown. pub layout_chan: LayoutControlChan, pub chrome_to_paint_chan: Sender, @@ -194,7 +194,7 @@ impl Pipeline { Pipeline { id: id, parent_info: parent_info, - script_chan: script_chan, + script_chan: script_chan.0, layout_chan: layout_chan, chrome_to_paint_chan: chrome_to_paint_chan, layout_shutdown_port: layout_shutdown_port, @@ -221,8 +221,7 @@ impl Pipeline { // Script task handles shutting down layout, and layout handles shutting down the painter. // For now, if the script task has failed, we give up on clean shutdown. - let ScriptControlChan(ref chan) = self.script_chan; - if chan.send(ConstellationControlMsg::ExitPipeline(self.id, exit_type)).is_ok() { + if self.script_chan.send(ConstellationControlMsg::ExitPipeline(self.id, exit_type)).is_ok() { // Wait until all slave tasks have terminated and run destructors // NOTE: We don't wait for script task as we don't always own it let _ = self.paint_shutdown_port.recv(); @@ -232,18 +231,15 @@ impl Pipeline { } pub fn freeze(&self) { - let ScriptControlChan(ref script_channel) = self.script_chan; - let _ = script_channel.send(ConstellationControlMsg::Freeze(self.id)).unwrap(); + let _ = self.script_chan.send(ConstellationControlMsg::Freeze(self.id)).unwrap(); } pub fn thaw(&self) { - let ScriptControlChan(ref script_channel) = self.script_chan; - let _ = script_channel.send(ConstellationControlMsg::Thaw(self.id)).unwrap(); + let _ = self.script_chan.send(ConstellationControlMsg::Thaw(self.id)).unwrap(); } pub fn force_exit(&self) { - let ScriptControlChan(ref script_channel) = self.script_chan; - let _ = script_channel.send( + let _ = self.script_chan.send( ConstellationControlMsg::ExitPipeline(self.id, PipelineExitType::PipelineOnly)).unwrap(); let _ = self.chrome_to_paint_chan.send(ChromeToPaintMsg::Exit( @@ -257,7 +253,7 @@ impl Pipeline { pub fn to_sendable(&self) -> CompositionPipeline { CompositionPipeline { id: self.id.clone(), - script_chan: self.script_chan.0.clone(), + script_chan: self.script_chan.clone(), layout_chan: self.layout_chan.clone(), chrome_to_paint_chan: self.chrome_to_paint_chan.clone(), } @@ -277,11 +273,10 @@ impl Pipeline { event: MozBrowserEvent) { assert!(opts::experimental_enabled()); - let ScriptControlChan(ref script_channel) = self.script_chan; let event = ConstellationControlMsg::MozBrowserEvent(self.id, subpage_id, event); - script_channel.send(event).unwrap(); + self.script_chan.send(event).unwrap(); } } From 0aae98e9c08d8b3d839016afdd0b5612eaecff02 Mon Sep 17 00:00:00 2001 From: Ms2ger Date: Wed, 12 Aug 2015 16:19:30 +0200 Subject: [PATCH 09/10] Pass a Sender to Pipeline::new. --- components/compositing/constellation.rs | 6 +++--- components/compositing/pipeline.rs | 15 +++++++-------- 2 files changed, 10 insertions(+), 11 deletions(-) diff --git a/components/compositing/constellation.rs b/components/compositing/constellation.rs index d66966cbd26..81cdbd9a374 100644 --- a/components/compositing/constellation.rs +++ b/components/compositing/constellation.rs @@ -41,7 +41,7 @@ use offscreen_gl_context::GLContextAttributes; use profile_traits::mem; use profile_traits::time; use script_traits::{CompositorEvent, ConstellationControlMsg, LayoutControlMsg}; -use script_traits::{ScriptControlChan, ScriptState, ScriptTaskFactory}; +use script_traits::{ScriptState, ScriptTaskFactory}; use std::borrow::ToOwned; use std::collections::HashMap; use std::io::{self, Write}; @@ -287,7 +287,7 @@ impl Constellation { fn new_pipeline(&mut self, parent_info: Option<(PipelineId, SubpageId)>, initial_window_rect: Option>, - script_channel: Option, + script_channel: Option>, load_data: LoadData) -> PipelineId { let pipeline_id = self.next_pipeline_id; @@ -648,7 +648,7 @@ impl Constellation { if same_script { debug!("Constellation: loading same-origin iframe, \ parent url {:?}, iframe url {:?}", source_url, url); - Some(ScriptControlChan(source_pipeline.script_chan.clone())) + Some(source_pipeline.script_chan.clone()) } else { debug!("Constellation: loading cross-origin iframe, \ parent url {:?}, iframe url {:?}", source_url, url); diff --git a/components/compositing/pipeline.rs b/components/compositing/pipeline.rs index a73dc891d84..a78f606f870 100644 --- a/components/compositing/pipeline.rs +++ b/components/compositing/pipeline.rs @@ -4,7 +4,7 @@ use CompositorProxy; use layout_traits::{LayoutTaskFactory, LayoutControlChan}; -use script_traits::{LayoutControlMsg, ScriptControlChan, ScriptTaskFactory}; +use script_traits::{LayoutControlMsg, ScriptTaskFactory}; use script_traits::{NewLayoutInfo, ConstellationControlMsg}; use compositor_task; @@ -80,7 +80,7 @@ impl Pipeline { time_profiler_chan: time::ProfilerChan, mem_profiler_chan: profile_mem::ProfilerChan, window_rect: Option>, - script_chan: Option, + script_chan: Option>, load_data: LoadData, device_pixel_ratio: ScaleFactor) -> (Pipeline, PipelineContent) @@ -131,14 +131,13 @@ impl Pipeline { layout_shutdown_chan: layout_shutdown_chan.clone(), }; - script_chan.0 - .send(ConstellationControlMsg::AttachLayout(new_layout_info)) + script_chan.send(ConstellationControlMsg::AttachLayout(new_layout_info)) .unwrap(); (script_chan, None) } None => { let (script_chan, script_port) = channel(); - (ScriptControlChan(script_chan), Some(script_port)) + (script_chan, Some(script_port)) } }; @@ -165,7 +164,7 @@ impl Pipeline { time_profiler_chan: time_profiler_chan, mem_profiler_chan: mem_profiler_chan, window_size: window_size, - script_chan: script_chan.0, + script_chan: script_chan, load_data: load_data, failure: failure, script_port: script_port, @@ -183,7 +182,7 @@ impl Pipeline { pub fn new(id: PipelineId, parent_info: Option<(PipelineId, SubpageId)>, - script_chan: ScriptControlChan, + script_chan: Sender, layout_chan: LayoutControlChan, chrome_to_paint_chan: Sender, layout_shutdown_port: Receiver<()>, @@ -194,7 +193,7 @@ impl Pipeline { Pipeline { id: id, parent_info: parent_info, - script_chan: script_chan.0, + script_chan: script_chan, layout_chan: layout_chan, chrome_to_paint_chan: chrome_to_paint_chan, layout_shutdown_port: layout_shutdown_port, From 2cdc043fcf574b96204f32e9cc95b02dee270d01 Mon Sep 17 00:00:00 2001 From: Ms2ger Date: Wed, 12 Aug 2015 16:24:09 +0200 Subject: [PATCH 10/10] Remove ScriptControlChan. --- components/script/dom/bindings/trace.rs | 3 +-- components/script_traits/lib.rs | 4 ---- 2 files changed, 1 insertion(+), 6 deletions(-) diff --git a/components/script/dom/bindings/trace.rs b/components/script/dom/bindings/trace.rs index 770515cce40..29172c64198 100644 --- a/components/script/dom/bindings/trace.rs +++ b/components/script/dom/bindings/trace.rs @@ -55,7 +55,6 @@ use libc; use msg::constellation_msg::{PipelineId, SubpageId, WindowSizeData, WorkerId}; use net_traits::image_cache_task::{ImageCacheChan, ImageCacheTask}; use net_traits::storage_task::StorageType; -use script_traits::ScriptControlChan; use script_traits::UntrustedNodeAddress; use serde::{Serialize, Deserialize}; use smallvec::SmallVec; @@ -280,7 +279,7 @@ no_jsmanaged_fields!(Receiver); no_jsmanaged_fields!(Rect); no_jsmanaged_fields!(Size2D); no_jsmanaged_fields!(Arc); -no_jsmanaged_fields!(Image, ImageCacheChan, ImageCacheTask, ScriptControlChan); +no_jsmanaged_fields!(Image, ImageCacheChan, ImageCacheTask); no_jsmanaged_fields!(Atom, Namespace); no_jsmanaged_fields!(Trusted); no_jsmanaged_fields!(PropertyDeclarationBlock); diff --git a/components/script_traits/lib.rs b/components/script_traits/lib.rs index 9ebeb1cd2e0..60d38eb4651 100644 --- a/components/script_traits/lib.rs +++ b/components/script_traits/lib.rs @@ -172,10 +172,6 @@ pub enum CompositorEvent { /// crates that don't need to know about them. pub struct OpaqueScriptLayoutChannel(pub (Box, Box)); -/// Encapsulates external communication with the script task. -#[derive(Clone)] -pub struct ScriptControlChan(pub Sender); - /// This trait allows creating a `ScriptTask` without depending on the `script` /// crate. pub trait ScriptTaskFactory {