diff options
-rw-r--r-- | components/compositing/compositor.rs | 5 | ||||
-rw-r--r-- | components/compositing/compositor_layer.rs | 8 | ||||
-rw-r--r-- | components/compositing/constellation.rs | 35 | ||||
-rw-r--r-- | components/compositing/pipeline.rs | 32 | ||||
-rw-r--r-- | components/layout/animation.rs | 5 | ||||
-rw-r--r-- | components/layout/layout_task.rs | 16 | ||||
-rw-r--r-- | components/layout_traits/lib.rs | 4 | ||||
-rw-r--r-- | components/script/dom/bindings/trace.rs | 3 | ||||
-rw-r--r-- | components/script/dom/window.rs | 12 | ||||
-rw-r--r-- | components/script/layout_interface.rs | 4 | ||||
-rw-r--r-- | components/script/script_task.rs | 10 | ||||
-rw-r--r-- | components/script_traits/lib.rs | 6 |
12 files changed, 55 insertions, 85 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<Window: WindowMethods> IOCompositor<Window> { 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<CompositorData> { }; 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<Window>(&self, @@ -370,8 +369,7 @@ impl CompositorLayer for Layer<CompositorData> { 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<LayerPixel, f32>) diff --git a/components/compositing/constellation.rs b/components/compositing/constellation.rs index ab5a69b429e..2c5493370c2 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<LTF: LayoutTaskFactory, STF: ScriptTaskFactory> Constellation<LTF, STF> { fn new_pipeline(&mut self, parent_info: Option<(PipelineId, SubpageId)>, initial_window_rect: Option<TypedRect<PagePx, f32>>, - script_channel: Option<ScriptControlChan>, + script_channel: Option<Sender<ConstellationControlMsg>>, load_data: LoadData) -> PipelineId { let pipeline_id = self.next_pipeline_id; @@ -606,7 +606,6 @@ impl<LTF: LayoutTaskFactory, STF: ScriptTaskFactory> Constellation<LTF, STF> { (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), @@ -706,7 +705,7 @@ impl<LTF: LayoutTaskFactory, STF: ScriptTaskFactory> Constellation<LTF, STF> { // 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(); @@ -845,7 +844,7 @@ impl<LTF: LayoutTaskFactory, STF: ScriptTaskFactory> Constellation<LTF, STF> { // 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, @@ -868,10 +867,9 @@ impl<LTF: LayoutTaskFactory, STF: ScriptTaskFactory> Constellation<LTF, STF> { 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); @@ -884,8 +882,7 @@ impl<LTF: LayoutTaskFactory, STF: ScriptTaskFactory> Constellation<LTF, STF> { 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(); } } } @@ -928,10 +925,9 @@ impl<LTF: LayoutTaskFactory, STF: ScriptTaskFactory> Constellation<LTF, STF> { // 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); } @@ -1005,8 +1001,7 @@ impl<LTF: LayoutTaskFactory, STF: ScriptTaskFactory> Constellation<LTF, STF> { 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| { @@ -1151,13 +1146,11 @@ impl<LTF: LayoutTaskFactory, STF: ScriptTaskFactory> Constellation<LTF, STF> { 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)); } } @@ -1165,8 +1158,7 @@ impl<LTF: LayoutTaskFactory, STF: ScriptTaskFactory> Constellation<LTF, STF> { 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)); } } @@ -1206,10 +1198,9 @@ impl<LTF: LayoutTaskFactory, STF: ScriptTaskFactory> Constellation<LTF, STF> { // 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 68f977f7ea6..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; @@ -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<ConstellationControlMsg>, /// A channel to layout, for performing reflows and shutdown. pub layout_chan: LayoutControlChan, pub chrome_to_paint_chan: Sender<ChromeToPaintMsg>, @@ -59,7 +59,7 @@ pub struct Pipeline { #[derive(Clone)] pub struct CompositionPipeline { pub id: PipelineId, - pub script_chan: ScriptControlChan, + pub script_chan: Sender<ConstellationControlMsg>, pub layout_chan: LayoutControlChan, pub chrome_to_paint_chan: Sender<ChromeToPaintMsg>, } @@ -80,7 +80,7 @@ impl Pipeline { time_profiler_chan: time::ProfilerChan, mem_profiler_chan: profile_mem::ProfilerChan, window_rect: Option<TypedRect<PagePx, f32>>, - script_chan: Option<ScriptControlChan>, + script_chan: Option<Sender<ConstellationControlMsg>>, load_data: LoadData, device_pixel_ratio: ScaleFactor<ViewportPx, DevicePixel, f32>) -> (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)) } }; @@ -183,7 +182,7 @@ impl Pipeline { pub fn new(id: PipelineId, parent_info: Option<(PipelineId, SubpageId)>, - script_chan: ScriptControlChan, + script_chan: Sender<ConstellationControlMsg>, layout_chan: LayoutControlChan, chrome_to_paint_chan: Sender<ChromeToPaintMsg>, layout_shutdown_port: Receiver<()>, @@ -221,8 +220,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 +230,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( @@ -277,11 +272,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(); } } @@ -298,7 +292,7 @@ pub struct PipelineContent { time_profiler_chan: time::ProfilerChan, mem_profiler_chan: profile_mem::ProfilerChan, window_size: Option<WindowSizeData>, - script_chan: ScriptControlChan, + script_chan: Sender<ConstellationControlMsg>, load_data: LoadData, failure: Failure, script_port: Option<Receiver<ConstellationControlMsg>>, 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 76baafc8013..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<ConstellationControlMsg>, /// The channel on which messages can be sent to the painting task. pub paint_chan: OptionalIpcSender<LayoutToPaintMsg>, @@ -228,7 +228,7 @@ impl LayoutTaskFactory for LayoutTask { pipeline_port: IpcReceiver<LayoutControlMsg>, constellation_chan: ConstellationChan, failure_msg: Failure, - script_chan: ScriptControlChan, + script_chan: Sender<ConstellationControlMsg>, paint_chan: OptionalIpcSender<LayoutToPaintMsg>, image_cache_task: ImageCacheTask, font_cache_task: FontCacheTask, @@ -311,7 +311,7 @@ impl LayoutTask { chan: LayoutChan, pipeline_port: IpcReceiver<LayoutControlMsg>, constellation_chan: ConstellationChan, - script_chan: ScriptControlChan, + script_chan: Sender<ConstellationControlMsg>, paint_chan: OptionalIpcSender<LayoutToPaintMsg>, 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::<OptionalIpcSender<LayoutToPaintMsg>>() .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); } @@ -1197,8 +1196,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/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<LayoutControlMsg>, constellation_chan: ConstellationChan, failure_msg: Failure, - script_chan: ScriptControlChan, + script_chan: Sender<ConstellationControlMsg>, layout_to_paint_chan: OptionalIpcSender<LayoutToPaintMsg>, image_cache_task: ImageCacheTask, font_cache_task: FontCacheTask, 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<T>); no_jsmanaged_fields!(Rect<T>); no_jsmanaged_fields!(Size2D<T>); no_jsmanaged_fields!(Arc<T>); -no_jsmanaged_fields!(Image, ImageCacheChan, ImageCacheTask, ScriptControlChan); +no_jsmanaged_fields!(Image, ImageCacheChan, ImageCacheTask); no_jsmanaged_fields!(Atom, Namespace); no_jsmanaged_fields!(Trusted<T>); no_jsmanaged_fields!(PropertyDeclarationBlock); diff --git a/components/script/dom/window.rs b/components/script/dom/window.rs index 7bfdf4e46d4..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::ScriptControlChan; +use script_traits::ConstellationControlMsg; 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<ScriptChan+Send>, #[ignore_heap_size_of = "channels are hard"] - control_chan: ScriptControlChan, + control_chan: Sender<ConstellationControlMsg>, console: MutNullableHeap<JS<Console>>, crypto: MutNullableHeap<JS<Crypto>>, navigator: MutNullableHeap<JS<Navigator>>, @@ -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 } @@ -1077,7 +1073,7 @@ impl Window { page: Rc<Page>, script_chan: Box<ScriptChan+Send>, image_cache_chan: ImageCacheChan, - control_chan: ScriptControlChan, + control_chan: Sender<ConstellationControlMsg>, compositor: ScriptListener, image_cache_task: ImageCacheTask, resource_task: Arc<ResourceTask>, 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<ConstellationControlMsg>, /// The current window size. pub window_size: WindowSizeData, /// The channel that we send a notification to. diff --git a/components/script/script_task.rs b/components/script/script_task.rs index efbad39dc86..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}; @@ -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<ConstellationControlMsg>, /// 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<ConstellationControlMsg>, control_port: Receiver<ConstellationControlMsg>, constellation_chan: ConstellationChan, failure_msg: Failure, @@ -542,7 +542,7 @@ impl ScriptTask { pub fn new(compositor: ScriptListener, port: Receiver<ScriptMsg>, chan: NonWorkerScriptChan, - control_chan: ScriptControlChan, + control_chan: Sender<ConstellationControlMsg>, control_port: Receiver<ConstellationControlMsg>, constellation_chan: ConstellationChan, resource_task: Arc<ResourceTask>, @@ -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, }; diff --git a/components/script_traits/lib.rs b/components/script_traits/lib.rs index c5dec4d5b4f..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<Any+Send>, Box<Any+Send>)); -/// Encapsulates external communication with the script task. -#[derive(Clone)] -pub struct ScriptControlChan(pub Sender<ConstellationControlMsg>); - /// This trait allows creating a `ScriptTask` without depending on the `script` /// crate. pub trait ScriptTaskFactory { @@ -185,7 +181,7 @@ pub trait ScriptTaskFactory { parent_info: Option<(PipelineId, SubpageId)>, compositor: ScriptListener, layout_chan: &OpaqueScriptLayoutChannel, - control_chan: ScriptControlChan, + control_chan: Sender<ConstellationControlMsg>, control_port: Receiver<ConstellationControlMsg>, constellation_msg: ConstellationChan, failure_msg: Failure, |