From cc2b2b50a74515700b6cae88c66e734312d1fdbb Mon Sep 17 00:00:00 2001 From: Ms2ger Date: Thu, 19 May 2016 16:53:52 +0200 Subject: [PATCH] Remove ConstellationChan. It's a pointless abstraction that propagates the obsolete chan terminology, swaps the order in which the sender and receiver are returned, and hides a source of panics. --- components/compositing/pipeline.rs | 19 +++++----- components/constellation/constellation.rs | 20 ++++++----- components/gfx/paint_thread.rs | 7 ++-- components/layout/animation.rs | 8 ++--- components/layout/layout_thread.rs | 21 ++++++----- components/layout/query.rs | 4 +-- components/layout_traits/lib.rs | 6 ++-- components/msg/constellation_msg.rs | 19 +--------- components/script/clipboard_provider.rs | 9 +++-- components/script/dom/bindings/global.rs | 6 ++-- components/script/dom/bindings/trace.rs | 17 +-------- .../script/dom/canvasrenderingcontext2d.rs | 2 +- components/script/dom/document.rs | 24 +++++-------- components/script/dom/htmlbodyelement.rs | 4 +-- components/script/dom/htmliframeelement.rs | 17 ++++----- components/script/dom/htmlinputelement.rs | 4 +-- components/script/dom/htmllinkelement.rs | 4 +-- components/script/dom/htmltextareaelement.rs | 4 +-- .../script/dom/webglrenderingcontext.rs | 3 +- components/script/dom/window.rs | 12 +++---- components/script/dom/workerglobalscope.rs | 8 ++--- components/script/layout_interface.rs | 7 ++-- components/script/script_thread.rs | 35 +++++++++---------- components/script_traits/lib.rs | 12 +++---- 24 files changed, 110 insertions(+), 162 deletions(-) diff --git a/components/compositing/pipeline.rs b/components/compositing/pipeline.rs index ca44fa49faf..15550f99002 100644 --- a/components/compositing/pipeline.rs +++ b/components/compositing/pipeline.rs @@ -14,9 +14,8 @@ use ipc_channel::ipc::{self, IpcReceiver, IpcSender}; use ipc_channel::router::ROUTER; use layers::geometry::DevicePixel; use layout_traits::{LayoutControlChan, LayoutThreadFactory}; -use msg::constellation_msg::{ConstellationChan, PanicMsg, FrameId, PipelineId, SubpageId}; -use msg::constellation_msg::{LoadData, WindowSizeData}; -use msg::constellation_msg::{PipelineNamespaceId}; +use msg::constellation_msg::{FrameId, LoadData, PanicMsg, PipelineId}; +use msg::constellation_msg::{PipelineNamespaceId, SubpageId, WindowSizeData}; use net_traits::ResourceThread; use net_traits::bluetooth_thread::BluetoothMethodMsg; use net_traits::image_cache_thread::ImageCacheThread; @@ -82,11 +81,11 @@ pub struct InitialPipelineState { /// If `None`, this is the root. pub parent_info: Option<(PipelineId, SubpageId)>, /// A channel to the associated constellation. - pub constellation_chan: ConstellationChan, + pub constellation_chan: IpcSender, /// A channel for the layout thread to send messages to the constellation. - pub layout_to_constellation_chan: ConstellationChan, + pub layout_to_constellation_chan: IpcSender, /// A channel to report panics - pub panic_chan: ConstellationChan, + pub panic_chan: IpcSender, /// A channel to schedule timer events. pub scheduler_chan: IpcSender, /// A channel to the compositor. @@ -389,8 +388,8 @@ impl Pipeline { pub struct UnprivilegedPipelineContent { id: PipelineId, parent_info: Option<(PipelineId, SubpageId)>, - constellation_chan: ConstellationChan, - layout_to_constellation_chan: ConstellationChan, + constellation_chan: IpcSender, + layout_to_constellation_chan: IpcSender, scheduler_chan: IpcSender, devtools_chan: Option>, script_to_compositor_chan: IpcSender, @@ -404,7 +403,7 @@ pub struct UnprivilegedPipelineContent { window_size: Option, script_chan: IpcSender, load_data: LoadData, - panic_chan: ConstellationChan, + panic_chan: IpcSender, script_port: Option>, layout_to_paint_chan: OptionalIpcSender, opts: Opts, @@ -488,7 +487,7 @@ pub struct PrivilegedPipelineContent { time_profiler_chan: time::ProfilerChan, mem_profiler_chan: profile_mem::ProfilerChan, load_data: LoadData, - panic_chan: ConstellationChan, + panic_chan: IpcSender, layout_to_paint_port: Receiver, chrome_to_paint_chan: Sender, chrome_to_paint_port: Receiver, diff --git a/components/constellation/constellation.rs b/components/constellation/constellation.rs index 05ac60f76ff..4b2a0d431c5 100644 --- a/components/constellation/constellation.rs +++ b/components/constellation/constellation.rs @@ -39,7 +39,7 @@ use msg::constellation_msg::{FrameId, PipelineId}; use msg::constellation_msg::{Key, KeyModifiers, KeyState, LoadData}; use msg::constellation_msg::{PipelineNamespace, PipelineNamespaceId, NavigationDirection}; use msg::constellation_msg::{SubpageId, WindowSizeData, WindowSizeType}; -use msg::constellation_msg::{self, ConstellationChan, PanicMsg}; +use msg::constellation_msg::{self, PanicMsg}; use msg::webdriver_msg; use net_traits::bluetooth_thread::BluetoothMethodMsg; use net_traits::image_cache_thread::ImageCacheThread; @@ -91,16 +91,16 @@ enum ReadyToSave { /// the `script` crate). pub struct Constellation { /// A channel through which script messages can be sent to this object. - script_sender: ConstellationChan, + script_sender: IpcSender, /// A channel through which compositor messages can be sent to this object. compositor_sender: Sender, /// A channel through which layout thread messages can be sent to this object. - layout_sender: ConstellationChan, + layout_sender: IpcSender, /// A channel through which panic messages can be sent to this object. - panic_sender: ConstellationChan, + panic_sender: IpcSender, /// Receives messages from scripts. script_receiver: Receiver, @@ -323,14 +323,18 @@ enum ChildProcess { impl Constellation { pub fn start(state: InitialConstellationState) -> Sender { - let (ipc_script_receiver, ipc_script_sender) = ConstellationChan::::new(); + let (ipc_script_sender, ipc_script_receiver) = ipc::channel().expect("ipc channel failure"); let script_receiver = ROUTER.route_ipc_receiver_to_new_mpsc_receiver(ipc_script_receiver); - let (compositor_sender, compositor_receiver) = channel(); - let (ipc_layout_receiver, ipc_layout_sender) = ConstellationChan::::new(); + + let (ipc_layout_sender, ipc_layout_receiver) = ipc::channel().expect("ipc channel failure"); let layout_receiver = ROUTER.route_ipc_receiver_to_new_mpsc_receiver(ipc_layout_receiver); - let (ipc_panic_receiver, ipc_panic_sender) = ConstellationChan::::new(); + + let (ipc_panic_sender, ipc_panic_receiver) = ipc::channel().expect("ipc channel failure"); let panic_receiver = ROUTER.route_ipc_receiver_to_new_mpsc_receiver(ipc_panic_receiver); + + let (compositor_sender, compositor_receiver) = channel(); let compositor_sender_clone = compositor_sender.clone(); + spawn_named("Constellation".to_owned(), move || { let mut constellation: Constellation = Constellation { script_sender: ipc_script_sender, diff --git a/components/gfx/paint_thread.rs b/components/gfx/paint_thread.rs index 5b8de18b7c4..0a4ed4383bd 100644 --- a/components/gfx/paint_thread.rs +++ b/components/gfx/paint_thread.rs @@ -19,7 +19,7 @@ use gfx_traits::{Epoch, FrameTreeId, LayerId, LayerKind, LayerProperties, PaintL use ipc_channel::ipc::IpcSender; use layers::layers::{BufferRequest, LayerBuffer, LayerBufferSet}; use layers::platform::surface::{NativeDisplay, NativeSurface}; -use msg::constellation_msg::{ConstellationChan, PanicMsg, PipelineId}; +use msg::constellation_msg::{PanicMsg, PipelineId}; use paint_context::PaintContext; use profile_traits::mem::{self, ReportsChan}; use profile_traits::time; @@ -393,12 +393,11 @@ impl PaintThread where C: PaintListener + Send + 'static { layout_to_paint_port: Receiver, chrome_to_paint_port: Receiver, compositor: C, - panic_chan: ConstellationChan, + panic_chan: IpcSender, font_cache_thread: FontCacheThread, time_profiler_chan: time::ProfilerChan, mem_profiler_chan: mem::ProfilerChan, shutdown_chan: IpcSender<()>) { - let ConstellationChan(c) = panic_chan.clone(); thread::spawn_named_with_send_on_panic(format!("PaintThread {:?}", id), thread_state::PAINT, move || { @@ -439,7 +438,7 @@ impl PaintThread where C: PaintListener + Send + 'static { debug!("paint_thread: shutdown_chan send"); shutdown_chan.send(()).unwrap(); - }, Some(id), c); + }, Some(id), panic_chan); } #[allow(unsafe_code)] diff --git a/components/layout/animation.rs b/components/layout/animation.rs index e706a74e524..e9a530e7d90 100644 --- a/components/layout/animation.rs +++ b/components/layout/animation.rs @@ -7,7 +7,8 @@ use flow::{self, Flow}; use gfx::display_list::OpaqueNode; use incremental::RestyleDamage; -use msg::constellation_msg::{ConstellationChan, PipelineId}; +use ipc_channel::ipc::IpcSender; +use msg::constellation_msg::PipelineId; use script_traits::{AnimationState, LayoutMsg as ConstellationMsg}; use std::collections::HashMap; use std::collections::hash_map::Entry; @@ -17,7 +18,7 @@ use time; /// Processes any new animations that were discovered after style recalculation. /// Also expire any old animations that have completed, inserting them into `expired_animations`. -pub fn update_animation_state(constellation_chan: &ConstellationChan, +pub fn update_animation_state(constellation_chan: &IpcSender, running_animations: &mut HashMap>, expired_animations: &mut HashMap>, new_animations_receiver: &Receiver, @@ -77,8 +78,7 @@ pub fn update_animation_state(constellation_chan: &ConstellationChan, + pub constellation_chan: IpcSender, /// The root stacking context. pub display_list: Option>, @@ -168,7 +168,7 @@ pub struct LayoutThread { font_cache_sender: IpcSender<()>, /// The channel on which messages can be sent to the constellation. - constellation_chan: ConstellationChan, + constellation_chan: IpcSender, /// The channel on which messages can be sent to the script thread. script_chan: IpcSender, @@ -253,8 +253,8 @@ impl LayoutThreadFactory for LayoutThread { is_iframe: bool, chan: OpaqueScriptLayoutChannel, pipeline_port: IpcReceiver, - constellation_chan: ConstellationChan, - panic_chan: ConstellationChan, + constellation_chan: IpcSender, + panic_chan: IpcSender, script_chan: IpcSender, paint_chan: OptionalIpcSender, image_cache_thread: ImageCacheThread, @@ -264,7 +264,6 @@ impl LayoutThreadFactory for LayoutThread { shutdown_chan: IpcSender<()>, content_process_shutdown_chan: IpcSender<()>, webrender_api_sender: Option) { - let ConstellationChan(fail_chan) = panic_chan.clone(); thread::spawn_named_with_send_on_panic(format!("LayoutThread {:?}", id), thread_state::LAYOUT, move || { @@ -291,7 +290,7 @@ impl LayoutThreadFactory for LayoutThread { } let _ = shutdown_chan.send(()); let _ = content_process_shutdown_chan.send(()); - }, Some(id), fail_chan); + }, Some(id), panic_chan); } } @@ -385,7 +384,7 @@ impl LayoutThread { is_iframe: bool, port: Receiver, pipeline_port: IpcReceiver, - constellation_chan: ConstellationChan, + constellation_chan: IpcSender, script_chan: IpcSender, paint_chan: OptionalIpcSender, image_cache_thread: ImageCacheThread, @@ -1080,9 +1079,9 @@ impl LayoutThread { if viewport_size_changed { if let Some(constraints) = constraints { // let the constellation know about the viewport constraints - let ConstellationChan(ref constellation_chan) = rw_data.constellation_chan; - constellation_chan.send(ConstellationMsg::ViewportConstrained( - self.id, constraints)).unwrap(); + rw_data.constellation_chan + .send(ConstellationMsg::ViewportConstrained(self.id, constraints)) + .unwrap(); } // FIXME (#10104): Only dirty nodes affected by vh/vw/vmin/vmax styles. if data.document_stylesheets.iter().any(|sheet| sheet.dirty_on_viewport_size_change) { diff --git a/components/layout/query.rs b/components/layout/query.rs index 6e49b397e8d..162a7642724 100644 --- a/components/layout/query.rs +++ b/components/layout/query.rs @@ -15,7 +15,6 @@ use fragment::{Fragment, FragmentBorderBoxIterator, SpecificFragmentInfo}; use gfx::display_list::OpaqueNode; use gfx_traits::{LayerId}; use layout_thread::LayoutThreadData; -use msg::constellation_msg::ConstellationChan; use opaque_node::OpaqueNodeMethods; use script::layout_interface::{ContentBoxResponse, NodeOverflowResponse, ContentBoxesResponse, NodeGeometryResponse}; use script::layout_interface::{HitTestResponse, LayoutRPC, OffsetParentResponse, NodeLayerIdResponse}; @@ -79,8 +78,7 @@ impl LayoutRPC for LayoutRPCImpl { None => Cursor::DefaultCursor, Some(dim) => dim.pointing.unwrap(), }; - let ConstellationChan(ref constellation_chan) = rw_data.constellation_chan; - constellation_chan.send(ConstellationMsg::SetCursor(cursor)).unwrap(); + rw_data.constellation_chan.send(ConstellationMsg::SetCursor(cursor)).unwrap(); } HitTestResponse { node_address: result.map(|dim| dim.node.to_untrusted_node_address()), diff --git a/components/layout_traits/lib.rs b/components/layout_traits/lib.rs index efc24f33fc3..0b12676b0db 100644 --- a/components/layout_traits/lib.rs +++ b/components/layout_traits/lib.rs @@ -26,7 +26,7 @@ extern crate webrender_traits; use gfx::font_cache_thread::FontCacheThread; use gfx::paint_thread::LayoutToPaintMsg; use ipc_channel::ipc::{IpcReceiver, IpcSender}; -use msg::constellation_msg::{ConstellationChan, PanicMsg, PipelineId, PipelineNamespaceId, PipelineIndex}; +use msg::constellation_msg::{PanicMsg, PipelineId, PipelineNamespaceId, PipelineIndex}; use net_traits::image_cache_thread::ImageCacheThread; use profile_traits::{mem, time}; use script_traits::LayoutMsg as ConstellationMsg; @@ -48,8 +48,8 @@ pub trait LayoutThreadFactory { is_iframe: bool, chan: OpaqueScriptLayoutChannel, pipeline_port: IpcReceiver, - constellation_chan: ConstellationChan, - panic_chan: ConstellationChan, + constellation_chan: IpcSender, + panic_chan: IpcSender, script_chan: IpcSender, layout_to_paint_chan: OptionalIpcSender, image_cache_thread: ImageCacheThread, diff --git a/components/msg/constellation_msg.rs b/components/msg/constellation_msg.rs index 5114ae8a384..3433b6915f0 100644 --- a/components/msg/constellation_msg.rs +++ b/components/msg/constellation_msg.rs @@ -9,9 +9,8 @@ use euclid::scale_factor::ScaleFactor; use euclid::size::TypedSize2D; use hyper::header::Headers; use hyper::method::Method; -use ipc_channel::ipc::{self, IpcReceiver, IpcSender, IpcSharedMemory}; +use ipc_channel::ipc::{IpcSender, IpcSharedMemory}; use layers::geometry::DevicePixel; -use serde::{Deserialize, Serialize}; use std::cell::Cell; use std::fmt; use url::Url; @@ -19,22 +18,6 @@ use util::geometry::{PagePx, ViewportPx}; use webdriver_msg::{LoadStatus, WebDriverScriptCommand}; use webrender_traits; -#[derive(Deserialize, Serialize)] -pub struct ConstellationChan(pub IpcSender); - -impl ConstellationChan { - pub fn new() -> (IpcReceiver, ConstellationChan) { - let (chan, port) = ipc::channel().unwrap(); - (port, ConstellationChan(chan)) - } -} - -impl Clone for ConstellationChan { - fn clone(&self) -> ConstellationChan { - ConstellationChan(self.0.clone()) - } -} - pub type PanicMsg = (Option, String, String); #[derive(Copy, Clone, Deserialize, Serialize, HeapSizeOf)] diff --git a/components/script/clipboard_provider.rs b/components/script/clipboard_provider.rs index c11944f1697..e8a9552277a 100644 --- a/components/script/clipboard_provider.rs +++ b/components/script/clipboard_provider.rs @@ -2,8 +2,7 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -use ipc_channel::ipc; -use msg::constellation_msg::ConstellationChan; +use ipc_channel::ipc::{self, IpcSender}; use script_traits::ScriptMsg as ConstellationMsg; use std::borrow::ToOwned; @@ -14,14 +13,14 @@ pub trait ClipboardProvider { fn set_clipboard_contents(&mut self, String); } -impl ClipboardProvider for ConstellationChan { +impl ClipboardProvider for IpcSender { fn clipboard_contents(&mut self) -> String { let (tx, rx) = ipc::channel().unwrap(); - self.0.send(ConstellationMsg::GetClipboardContents(tx)).unwrap(); + self.send(ConstellationMsg::GetClipboardContents(tx)).unwrap(); rx.recv().unwrap() } fn set_clipboard_contents(&mut self, s: String) { - self.0.send(ConstellationMsg::SetClipboardContents(s)).unwrap(); + self.send(ConstellationMsg::SetClipboardContents(s)).unwrap(); } } diff --git a/components/script/dom/bindings/global.rs b/components/script/dom/bindings/global.rs index d9c5b8d64cb..b48a941af01 100644 --- a/components/script/dom/bindings/global.rs +++ b/components/script/dom/bindings/global.rs @@ -18,7 +18,7 @@ use ipc_channel::ipc::IpcSender; use js::jsapi::{CurrentGlobalOrNull, GetGlobalForObjectCrossCompartment}; use js::jsapi::{JSContext, JSObject, JS_GetClass, MutableHandleValue}; use js::{JSCLASS_IS_DOMJSCLASS, JSCLASS_IS_GLOBAL}; -use msg::constellation_msg::{ConstellationChan, PanicMsg, PipelineId}; +use msg::constellation_msg::{PanicMsg, PipelineId}; use net_traits::ResourceThread; use profile_traits::{mem, time}; use script_runtime::{CommonScriptMsg, ScriptChan, ScriptPort}; @@ -89,8 +89,8 @@ impl<'a> GlobalRef<'a> { } } - /// Get a `ConstellationChan` to send messages to the constellation channel when available. - pub fn constellation_chan(&self) -> &ConstellationChan { + /// Get a `IpcSender` to send messages to the constellation when available. + pub fn constellation_chan(&self) -> &IpcSender { match *self { GlobalRef::Window(window) => window.constellation_chan(), GlobalRef::Worker(worker) => worker.constellation_chan(), diff --git a/components/script/dom/bindings/trace.rs b/components/script/dom/bindings/trace.rs index 7e6d16f59db..1acb5ee9e4b 100644 --- a/components/script/dom/bindings/trace.rs +++ b/components/script/dom/bindings/trace.rs @@ -55,7 +55,6 @@ use js::jsval::JSVal; use js::rust::Runtime; use layout_interface::{LayoutChan, LayoutRPC}; use libc; -use msg::constellation_msg::ConstellationChan; use msg::constellation_msg::{PipelineId, SubpageId, WindowSizeData, WindowSizeType, ReferrerPolicy}; use net_traits::image::base::{Image, ImageMetadata}; use net_traits::image_cache_thread::{ImageCacheChan, ImageCacheThread}; @@ -66,7 +65,7 @@ use offscreen_gl_context::GLLimits; use profile_traits::mem::ProfilerChan as MemProfilerChan; use profile_traits::time::ProfilerChan as TimeProfilerChan; use script_runtime::ScriptChan; -use script_traits::{LayoutMsg, ScriptMsg, TimerEventId, TimerSource, TouchpadPressurePhase, UntrustedNodeAddress}; +use script_traits::{TimerEventId, TimerSource, TouchpadPressurePhase, UntrustedNodeAddress}; use serde::{Deserialize, Serialize}; use smallvec::SmallVec; use std::boxed::FnBox; @@ -323,20 +322,6 @@ no_jsmanaged_fields!(SharedRt); no_jsmanaged_fields!(TouchpadPressurePhase); no_jsmanaged_fields!(ReferrerPolicy); -impl JSTraceable for ConstellationChan { - #[inline] - fn trace(&self, _trc: *mut JSTracer) { - // Do nothing - } -} - -impl JSTraceable for ConstellationChan { - #[inline] - fn trace(&self, _trc: *mut JSTracer) { - // Do nothing - } -} - impl JSTraceable for Box { #[inline] fn trace(&self, _trc: *mut JSTracer) { diff --git a/components/script/dom/canvasrenderingcontext2d.rs b/components/script/dom/canvasrenderingcontext2d.rs index ac7215d3293..e7ac0813174 100644 --- a/components/script/dom/canvasrenderingcontext2d.rs +++ b/components/script/dom/canvasrenderingcontext2d.rs @@ -123,7 +123,7 @@ impl CanvasRenderingContext2D { -> CanvasRenderingContext2D { let (sender, receiver) = ipc::channel().unwrap(); let constellation_chan = global.constellation_chan(); - constellation_chan.0.send(ConstellationMsg::CreateCanvasPaintThread(size, sender)).unwrap(); + constellation_chan.send(ConstellationMsg::CreateCanvasPaintThread(size, sender)).unwrap(); let ipc_renderer = receiver.recv().unwrap(); CanvasRenderingContext2D { reflector_: Reflector::new(), diff --git a/components/script/dom/document.rs b/components/script/dom/document.rs index 866b698687d..f6000e28a8b 100644 --- a/components/script/dom/document.rs +++ b/components/script/dom/document.rs @@ -94,7 +94,7 @@ use js::jsapi::JS_GetRuntime; use js::jsapi::{JSContext, JSObject, JSRuntime}; use layout_interface::{LayoutChan, Msg, ReflowQueryType}; use msg::constellation_msg::{ALT, CONTROL, SHIFT, SUPER}; -use msg::constellation_msg::{ConstellationChan, Key, KeyModifiers, KeyState}; +use msg::constellation_msg::{Key, KeyModifiers, KeyState}; use msg::constellation_msg::{PipelineId, ReferrerPolicy, SubpageId}; use net_traits::ControlMsg::{GetCookiesForUrl, SetCookiesForUrl}; use net_traits::CookieSource::NonHTTP; @@ -623,9 +623,8 @@ impl Document { // Update the focus state for all elements in the focus chain. // https://html.spec.whatwg.org/multipage/#focus-chain if focus_type == FocusType::Element { - let ConstellationChan(ref chan) = *self.window.constellation_chan(); let event = ConstellationMsg::Focus(self.window.pipeline()); - chan.send(event).unwrap(); + self.window.constellation_chan().send(event).unwrap(); } } } @@ -699,7 +698,7 @@ impl Document { let event = ConstellationMsg::ForwardMouseButtonEvent(pipeline_id, mouse_event_type, button, child_point); - self.window.constellation_chan().0.send(event).unwrap(); + self.window.constellation_chan().send(event).unwrap(); } return; } @@ -880,7 +879,7 @@ impl Document { let child_point = client_point - child_origin; let event = ConstellationMsg::ForwardMouseMoveEvent(pipeline_id, child_point); - self.window.constellation_chan().0.send(event).unwrap(); + self.window.constellation_chan().send(event).unwrap(); } return; } @@ -1270,11 +1269,10 @@ impl Document { pub fn trigger_mozbrowser_event(&self, event: MozBrowserEvent) { if htmliframeelement::mozbrowser_enabled() { if let Some((containing_pipeline_id, subpage_id)) = self.window.parent_info() { - let ConstellationChan(ref chan) = *self.window.constellation_chan(); let event = ConstellationMsg::MozBrowserEvent(containing_pipeline_id, subpage_id, event); - chan.send(event).unwrap(); + self.window.constellation_chan().send(event).unwrap(); } } } @@ -1294,11 +1292,10 @@ impl Document { // // TODO: Should tick animation only when document is visible if !self.running_animation_callbacks.get() { - let ConstellationChan(ref chan) = *self.window.constellation_chan(); let event = ConstellationMsg::ChangeRunningAnimationsState( self.window.pipeline(), AnimationState::AnimationCallbacksPresent); - chan.send(event).unwrap(); + self.window.constellation_chan().send(event).unwrap(); } ident @@ -1308,10 +1305,9 @@ impl Document { pub fn cancel_animation_frame(&self, ident: u32) { self.animation_frame_list.borrow_mut().remove(&ident); if self.animation_frame_list.borrow().is_empty() { - let ConstellationChan(ref chan) = *self.window.constellation_chan(); let event = ConstellationMsg::ChangeRunningAnimationsState(self.window.pipeline(), AnimationState::NoAnimationCallbacksPresent); - chan.send(event).unwrap(); + self.window.constellation_chan().send(event).unwrap(); } } @@ -1333,10 +1329,9 @@ impl Document { // the next frame (which is the common case), we won't send a NoAnimationCallbacksPresent // message quickly followed by an AnimationCallbacksPresent message. if self.animation_frame_list.borrow().is_empty() { - let ConstellationChan(ref chan) = *self.window.constellation_chan(); let event = ConstellationMsg::ChangeRunningAnimationsState(self.window.pipeline(), AnimationState::NoAnimationCallbacksPresent); - chan.send(event).unwrap(); + self.window.constellation_chan().send(event).unwrap(); } self.running_animation_callbacks.set(false); @@ -1495,9 +1490,8 @@ impl Document { pub fn notify_constellation_load(&self) { let pipeline_id = self.window.pipeline(); - let ConstellationChan(ref chan) = *self.window.constellation_chan(); let event = ConstellationMsg::DOMLoad(pipeline_id); - chan.send(event).unwrap(); + self.window.constellation_chan().send(event).unwrap(); } diff --git a/components/script/dom/htmlbodyelement.rs b/components/script/dom/htmlbodyelement.rs index 5b4b9a48cb6..2fd18a00c08 100644 --- a/components/script/dom/htmlbodyelement.rs +++ b/components/script/dom/htmlbodyelement.rs @@ -15,7 +15,6 @@ use dom::eventtarget::EventTarget; use dom::htmlelement::HTMLElement; use dom::node::{Node, document_from_node, window_from_node}; use dom::virtualmethods::VirtualMethods; -use msg::constellation_msg::ConstellationChan; use script_traits::ScriptMsg as ConstellationMsg; use std::rc::Rc; use string_cache::Atom; @@ -153,9 +152,8 @@ impl VirtualMethods for HTMLBodyElement { let window = window_from_node(self); let document = window.Document(); document.set_reflow_timeout(time::precise_time_ns() + INITIAL_REFLOW_DELAY); - let ConstellationChan(ref chan) = *window.constellation_chan(); let event = ConstellationMsg::HeadParsed; - chan.send(event).unwrap(); + window.constellation_chan().send(event).unwrap(); } fn parse_plain_attribute(&self, name: &Atom, value: DOMString) -> AttrValue { diff --git a/components/script/dom/htmliframeelement.rs b/components/script/dom/htmliframeelement.rs index d31c8a09484..db7728ca710 100644 --- a/components/script/dom/htmliframeelement.rs +++ b/components/script/dom/htmliframeelement.rs @@ -33,8 +33,7 @@ use ipc_channel::ipc; use js::jsapi::{JSAutoCompartment, RootedValue, JSContext, MutableHandleValue}; use js::jsval::{UndefinedValue, NullValue}; use layout_interface::ReflowQueryType; -use msg::constellation_msg::{ConstellationChan, LoadData}; -use msg::constellation_msg::{NavigationDirection, PipelineId, SubpageId}; +use msg::constellation_msg::{LoadData, NavigationDirection, PipelineId, SubpageId}; use net_traits::response::HttpsState; use script_traits::IFrameSandboxState::{IFrameSandboxed, IFrameUnsandboxed}; use script_traits::{IFrameLoadInfo, MozBrowserEvent, ScriptMsg as ConstellationMsg}; @@ -120,12 +119,10 @@ impl HTMLIFrameElement { } let window = window_from_node(self); - let window = window.r(); let (new_subpage_id, old_subpage_id) = self.generate_new_subpage_id(); let new_pipeline_id = self.pipeline_id.get().unwrap(); let private_iframe = self.privatebrowsing(); - let ConstellationChan(ref chan) = *window.constellation_chan(); let load_info = IFrameLoadInfo { load_data: load_data, containing_pipeline_id: window.pipeline(), @@ -135,7 +132,9 @@ impl HTMLIFrameElement { sandbox: sandboxed, is_private: private_iframe, }; - chan.send(ConstellationMsg::ScriptLoadedURLInIFrame(load_info)).unwrap(); + window.constellation_chan() + .send(ConstellationMsg::ScriptLoadedURLInIFrame(load_info)) + .unwrap(); if mozbrowser_enabled() { // https://developer.mozilla.org/en-US/docs/Web/Events/mozbrowserloadstart @@ -372,13 +371,11 @@ pub fn Navigate(iframe: &HTMLIFrameElement, direction: NavigationDirection) -> E if iframe.Mozbrowser() { if iframe.upcast::().is_in_doc() { let window = window_from_node(iframe); - let window = window.r(); let pipeline_info = Some((window.pipeline(), iframe.subpage_id().unwrap())); - let ConstellationChan(ref chan) = *window.constellation_chan(); let msg = ConstellationMsg::Navigate(pipeline_info, direction); - chan.send(msg).unwrap(); + window.constellation_chan().send(msg).unwrap(); } Ok(()) @@ -568,7 +565,6 @@ impl VirtualMethods for HTMLIFrameElement { // https://html.spec.whatwg.org/multipage/#a-browsing-context-is-discarded if let Some(pipeline_id) = self.pipeline_id.get() { let window = window_from_node(self); - let window = window.r(); // The only reason we're waiting for the iframe to be totally // removed is to ensure the script thread can't add iframes faster @@ -576,7 +572,6 @@ impl VirtualMethods for HTMLIFrameElement { // // Since most of this cleanup doesn't happen on same-origin // iframes, and since that would cause a deadlock, don't do it. - let ConstellationChan(ref chan) = *window.constellation_chan(); let same_origin = { // FIXME(#10968): this should probably match the origin check in // HTMLIFrameElement::contentDocument. @@ -591,7 +586,7 @@ impl VirtualMethods for HTMLIFrameElement { (Some(sender), Some(receiver)) }; let msg = ConstellationMsg::RemoveIFrame(pipeline_id, sender); - chan.send(msg).unwrap(); + window.constellation_chan().send(msg).unwrap(); if let Some(receiver) = receiver { receiver.recv().unwrap() } diff --git a/components/script/dom/htmlinputelement.rs b/components/script/dom/htmlinputelement.rs index c1b2f1b7f76..c2c76dd16e8 100644 --- a/components/script/dom/htmlinputelement.rs +++ b/components/script/dom/htmlinputelement.rs @@ -27,7 +27,7 @@ use dom::node::{document_from_node, window_from_node}; use dom::nodelist::NodeList; use dom::validation::Validatable; use dom::virtualmethods::VirtualMethods; -use msg::constellation_msg::ConstellationChan; +use ipc_channel::ipc::IpcSender; use script_traits::ScriptMsg as ConstellationMsg; use std::borrow::ToOwned; use std::cell::Cell; @@ -76,7 +76,7 @@ pub struct HTMLInputElement { size: Cell, maxlength: Cell, #[ignore_heap_size_of = "#7193"] - textinput: DOMRefCell>>, + textinput: DOMRefCell>>, activation_state: DOMRefCell, // https://html.spec.whatwg.org/multipage/#concept-input-value-dirty-flag value_dirty: Cell, diff --git a/components/script/dom/htmllinkelement.rs b/components/script/dom/htmllinkelement.rs index 023d8a36f58..0a7ebb5de1b 100644 --- a/components/script/dom/htmllinkelement.rs +++ b/components/script/dom/htmllinkelement.rs @@ -26,7 +26,6 @@ use hyper::mime::{Mime, TopLevel, SubLevel}; use ipc_channel::ipc; use ipc_channel::router::ROUTER; use layout_interface::{LayoutChan, Msg}; -use msg::constellation_msg::ConstellationChan; use net_traits::{AsyncResponseListener, AsyncResponseTarget, Metadata, NetworkError}; use network_listener::{NetworkListener, PreInvoke}; use script_traits::{MozBrowserEvent, ScriptMsg as ConstellationMsg}; @@ -242,9 +241,8 @@ impl HTMLLinkElement { let document = document_from_node(self); match document.base_url().join(href) { Ok(url) => { - let ConstellationChan(ref chan) = *document.window().constellation_chan(); let event = ConstellationMsg::NewFavicon(url.clone()); - chan.send(event).unwrap(); + document.window().constellation_chan().send(event).unwrap(); let mozbrowser_event = match *sizes { Some(ref sizes) => MozBrowserEvent::IconChange(rel.to_owned(), url.to_string(), sizes.to_owned()), diff --git a/components/script/dom/htmltextareaelement.rs b/components/script/dom/htmltextareaelement.rs index 56296ad9321..516f421f436 100644 --- a/components/script/dom/htmltextareaelement.rs +++ b/components/script/dom/htmltextareaelement.rs @@ -23,7 +23,7 @@ use dom::node::{document_from_node, window_from_node}; use dom::nodelist::NodeList; use dom::validation::Validatable; use dom::virtualmethods::VirtualMethods; -use msg::constellation_msg::ConstellationChan; +use ipc_channel::ipc::IpcSender; use script_traits::ScriptMsg as ConstellationMsg; use std::cell::Cell; use std::ops::Range; @@ -36,7 +36,7 @@ use util::str::DOMString; pub struct HTMLTextAreaElement { htmlelement: HTMLElement, #[ignore_heap_size_of = "#7193"] - textinput: DOMRefCell>>, + textinput: DOMRefCell>>, // https://html.spec.whatwg.org/multipage/#concept-textarea-dirty value_changed: Cell, } diff --git a/components/script/dom/webglrenderingcontext.rs b/components/script/dom/webglrenderingcontext.rs index 1141637f908..241aa0aa60e 100644 --- a/components/script/dom/webglrenderingcontext.rs +++ b/components/script/dom/webglrenderingcontext.rs @@ -95,8 +95,7 @@ impl WebGLRenderingContext { -> Result { let (sender, receiver) = ipc::channel().unwrap(); let constellation_chan = global.constellation_chan(); - constellation_chan.0 - .send(ConstellationMsg::CreateWebGLPaintThread(size, attrs, sender)) + constellation_chan.send(ConstellationMsg::CreateWebGLPaintThread(size, attrs, sender)) .unwrap(); let result = receiver.recv().unwrap(); diff --git a/components/script/dom/window.rs b/components/script/dom/window.rs index 727ae7d8c32..e665add7928 100644 --- a/components/script/dom/window.rs +++ b/components/script/dom/window.rs @@ -42,7 +42,7 @@ use js::rust::Runtime; use layout_interface::{ContentBoxResponse, ContentBoxesResponse, ResolvedStyleResponse, ScriptReflow}; use layout_interface::{LayoutChan, LayoutRPC, Msg, Reflow, ReflowQueryType, MarginStyleResponse}; use libc; -use msg::constellation_msg::{ConstellationChan, LoadData, PanicMsg, PipelineId, SubpageId}; +use msg::constellation_msg::{LoadData, PanicMsg, PipelineId, SubpageId}; use msg::constellation_msg::{WindowSizeData, WindowSizeType}; use msg::webdriver_msg::{WebDriverJSError, WebDriverJSResult}; use net_traits::ResourceThread; @@ -228,7 +228,7 @@ pub struct Window { /// A handle for communicating messages to the constellation thread. #[ignore_heap_size_of = "channels are hard"] - constellation_chan: ConstellationChan, + constellation_chan: IpcSender, /// Pending scroll to fragment event, if any fragment_name: DOMRefCell>, @@ -449,7 +449,7 @@ impl WindowMethods for Window { stderr.flush().unwrap(); let (sender, receiver) = ipc::channel().unwrap(); - self.constellation_chan().0.send(ConstellationMsg::Alert(self.pipeline(), s.to_string(), sender)).unwrap(); + self.constellation_chan().send(ConstellationMsg::Alert(self.pipeline(), s.to_string(), sender)).unwrap(); let should_display_alert_dialog = receiver.recv().unwrap(); if should_display_alert_dialog { @@ -1120,7 +1120,7 @@ impl Window { if ready_state == DocumentReadyState::Complete && !reftest_wait { let event = ConstellationMsg::SetDocumentState(self.id, DocumentState::Idle); - self.constellation_chan().0.send(event).unwrap(); + self.constellation_chan().send(event).unwrap(); } } } @@ -1296,7 +1296,7 @@ impl Window { &self.layout_chan } - pub fn constellation_chan(&self) -> &ConstellationChan { + pub fn constellation_chan(&self) -> &IpcSender { &self.constellation_chan } @@ -1459,7 +1459,7 @@ impl Window { mem_profiler_chan: mem::ProfilerChan, time_profiler_chan: ProfilerChan, devtools_chan: Option>, - constellation_chan: ConstellationChan, + constellation_chan: IpcSender, control_chan: IpcSender, scheduler_chan: IpcSender, panic_chan: IpcSender, diff --git a/components/script/dom/workerglobalscope.rs b/components/script/dom/workerglobalscope.rs index 618da932d44..8b5b2637179 100644 --- a/components/script/dom/workerglobalscope.rs +++ b/components/script/dom/workerglobalscope.rs @@ -21,7 +21,7 @@ use ipc_channel::ipc::IpcSender; use js::jsapi::{HandleValue, JSContext, JSRuntime, RootedValue}; use js::jsval::UndefinedValue; use js::rust::Runtime; -use msg::constellation_msg::{ConstellationChan, PanicMsg, PipelineId}; +use msg::constellation_msg::{PanicMsg, PipelineId}; use net_traits::{LoadContext, ResourceThread, load_whole_resource}; use profile_traits::{mem, time}; use script_runtime::{CommonScriptMsg, ScriptChan, ScriptPort}; @@ -48,7 +48,7 @@ pub struct WorkerGlobalScopeInit { pub time_profiler_chan: time::ProfilerChan, pub to_devtools_sender: Option>, pub from_devtools_sender: Option>, - pub constellation_chan: ConstellationChan, + pub constellation_chan: IpcSender, pub scheduler_chan: IpcSender, pub panic_chan: IpcSender, pub worker_id: WorkerId, @@ -94,7 +94,7 @@ pub struct WorkerGlobalScope { devtools_wants_updates: Cell, #[ignore_heap_size_of = "Defined in std"] - constellation_chan: ConstellationChan, + constellation_chan: IpcSender, #[ignore_heap_size_of = "Defined in std"] scheduler_chan: IpcSender, @@ -156,7 +156,7 @@ impl WorkerGlobalScope { &self.from_devtools_receiver } - pub fn constellation_chan(&self) -> &ConstellationChan { + pub fn constellation_chan(&self) -> &IpcSender { &self.constellation_chan } diff --git a/components/script/layout_interface.rs b/components/script/layout_interface.rs index 2a9598fcc8b..2a6e0b1d79a 100644 --- a/components/script/layout_interface.rs +++ b/components/script/layout_interface.rs @@ -12,8 +12,7 @@ use euclid::point::Point2D; use euclid::rect::Rect; use gfx_traits::{Epoch, LayerId}; use ipc_channel::ipc::{IpcReceiver, IpcSender}; -use msg::constellation_msg::{ConstellationChan, PanicMsg, PipelineId}; -use msg::constellation_msg::{WindowSizeData}; +use msg::constellation_msg::{PanicMsg, PipelineId, WindowSizeData}; use net_traits::image_cache_thread::ImageCacheThread; use profile_traits::mem::ReportsChan; use script_traits::{ConstellationControlMsg, LayoutControlMsg, LayoutMsg as ConstellationMsg}; @@ -262,8 +261,8 @@ pub struct NewLayoutThreadInfo { pub is_parent: bool, pub layout_pair: OpaqueScriptLayoutChannel, pub pipeline_port: IpcReceiver, - pub constellation_chan: ConstellationChan, - pub panic_chan: ConstellationChan, + pub constellation_chan: IpcSender, + pub panic_chan: IpcSender, pub script_chan: IpcSender, pub image_cache_thread: ImageCacheThread, pub paint_chan: OptionalOpaqueIpcSender, diff --git a/components/script/script_thread.rs b/components/script/script_thread.rs index 0e3d9935435..0fe4ab3ea3c 100644 --- a/components/script/script_thread.rs +++ b/components/script/script_thread.rs @@ -59,8 +59,7 @@ use js::rust::Runtime; use layout_interface::{ReflowQueryType}; use layout_interface::{self, LayoutChan, NewLayoutThreadInfo, ScriptLayoutChan}; use mem::heap_size_of_self_and_children; -use msg::constellation_msg::{ConstellationChan, LoadData, PanicMsg}; -use msg::constellation_msg::{PipelineId, PipelineNamespace}; +use msg::constellation_msg::{LoadData, PanicMsg, PipelineId, PipelineNamespace}; use msg::constellation_msg::{SubpageId, WindowSizeData, WindowSizeType}; use msg::webdriver_msg::WebDriverScriptCommand; use net_traits::LoadData as NetLoadData; @@ -342,10 +341,10 @@ pub struct ScriptThread { control_port: Receiver, /// For communicating load url messages to the constellation - constellation_chan: ConstellationChan, + constellation_chan: IpcSender, /// For communicating layout messages to the constellation - layout_to_constellation_chan: ConstellationChan, + layout_to_constellation_chan: IpcSender, /// A handle to the compositor for communicating ready state messages. compositor: DOMRefCell>, @@ -438,7 +437,7 @@ impl ScriptThreadFactory for ScriptThread { state: InitialScriptState, layout_chan: &OpaqueScriptLayoutChannel, load_data: LoadData) { - let ConstellationChan(panic_chan) = state.panic_chan.clone(); + let panic_chan = state.panic_chan.clone(); let (script_chan, script_port) = channel(); let layout_chan = LayoutChan(layout_chan.sender()); let pipeline_id = state.id; @@ -577,7 +576,7 @@ impl ScriptThread { compositor: DOMRefCell::new(state.compositor), time_profiler_chan: state.time_profiler_chan, mem_profiler_chan: state.mem_profiler_chan, - panic_chan: state.panic_chan.0, + panic_chan: state.panic_chan, devtools_chan: state.devtools_chan, devtools_port: devtools_port, @@ -1134,8 +1133,7 @@ impl ScriptThread { let handler = box DocumentProgressHandler::new(Trusted::new(doc)); self.dom_manipulation_task_source.queue(DOMManipulationTask::DocumentProgress(handler)).unwrap(); - let ConstellationChan(ref chan) = self.constellation_chan; - chan.send(ConstellationMsg::LoadComplete(pipeline)).unwrap(); + self.constellation_chan.send(ConstellationMsg::LoadComplete(pipeline)).unwrap(); } fn collect_reports(&self, reports_chan: ReportsChan) { @@ -1398,8 +1396,9 @@ impl ScriptThread { chan.send(layout_interface::Msg::SetFinalUrl(final_url.clone())).unwrap(); // update the pipeline url - let ConstellationChan(ref chan) = self.constellation_chan; - chan.send(ConstellationMsg::SetFinalUrl(incomplete.pipeline_id, final_url.clone())).unwrap(); + self.constellation_chan + .send(ConstellationMsg::SetFinalUrl(incomplete.pipeline_id, final_url.clone())) + .unwrap(); } debug!("ScriptThread: loading {} on pipeline {:?}", incomplete.url, incomplete.pipeline_id); @@ -1569,8 +1568,9 @@ impl ScriptThread { } document.set_ready_state(DocumentReadyState::Loading); - let ConstellationChan(ref chan) = self.constellation_chan; - chan.send(ConstellationMsg::ActivateDocument(incomplete.pipeline_id)).unwrap(); + self.constellation_chan + .send(ConstellationMsg::ActivateDocument(incomplete.pipeline_id)) + .unwrap(); // Notify devtools that a new script global exists. self.notify_devtools(document.Title(), final_url.clone(), (browsing_context.pipeline(), None)); @@ -1729,8 +1729,7 @@ impl ScriptThread { }); let event = ConstellationMsg::NodeStatus(status); - let ConstellationChan(ref chan) = self.constellation_chan; - chan.send(event).unwrap(); + self.constellation_chan.send(event).unwrap(); state_already_changed = true; } @@ -1744,8 +1743,7 @@ impl ScriptThread { .filter_map(Root::downcast::) .next() { let event = ConstellationMsg::NodeStatus(None); - let ConstellationChan(ref chan) = self.constellation_chan; - chan.send(event).unwrap(); + self.constellation_chan.send(event).unwrap(); } } } @@ -1844,8 +1842,9 @@ impl ScriptThread { } } None => { - let ConstellationChan(ref const_chan) = self.constellation_chan; - const_chan.send(ConstellationMsg::LoadUrl(pipeline_id, load_data)).unwrap(); + self.constellation_chan + .send(ConstellationMsg::LoadUrl(pipeline_id, load_data)) + .unwrap(); } } } diff --git a/components/script_traits/lib.rs b/components/script_traits/lib.rs index a001159acfb..47a69012bb3 100644 --- a/components/script_traits/lib.rs +++ b/components/script_traits/lib.rs @@ -41,9 +41,9 @@ use gfx_traits::Epoch; use gfx_traits::LayerId; use ipc_channel::ipc::{IpcReceiver, IpcSender}; use libc::c_void; -use msg::constellation_msg::{ConstellationChan, PanicMsg, PipelineId, WindowSizeData, WindowSizeType}; use msg::constellation_msg::{Key, KeyModifiers, KeyState, LoadData}; -use msg::constellation_msg::{PipelineNamespaceId, SubpageId}; +use msg::constellation_msg::{PanicMsg, PipelineId, PipelineNamespaceId}; +use msg::constellation_msg::{SubpageId, WindowSizeData, WindowSizeType}; use msg::webdriver_msg::WebDriverScriptCommand; use net_traits::ResourceThread; use net_traits::bluetooth_thread::BluetoothMethodMsg; @@ -96,7 +96,7 @@ pub struct NewLayoutInfo { /// A port on which layout can receive messages from the pipeline. pub pipeline_port: IpcReceiver, /// A channel for sending panics on - pub panic_chan: ConstellationChan, + pub panic_chan: IpcSender, /// A shutdown channel so that layout can notify others when it's done. pub layout_shutdown_chan: IpcSender<()>, /// A shutdown channel so that layout can tell the content process to shut down when it's done. @@ -312,11 +312,11 @@ pub struct InitialScriptState { /// A port on which messages sent by the constellation to script can be received. pub control_port: IpcReceiver, /// A channel on which messages can be sent to the constellation from script. - pub constellation_chan: ConstellationChan, + pub constellation_chan: IpcSender, /// A channel for the layout thread to send messages to the constellation. - pub layout_to_constellation_chan: ConstellationChan, + pub layout_to_constellation_chan: IpcSender, /// A channel for sending panics to the constellation. - pub panic_chan: ConstellationChan, + pub panic_chan: IpcSender, /// A channel to schedule timer events. pub scheduler_chan: IpcSender, /// A channel to the resource manager thread.