Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove ConstellationChan. #11270

Merged
merged 1 commit into from May 19, 2016
Merged
Changes from all commits
Commits
File filter...
Filter file types
Jump to…
Jump to file
Failed to load files.

Always

Just for now

@@ -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<ScriptMsg>,
pub constellation_chan: IpcSender<ScriptMsg>,
/// A channel for the layout thread to send messages to the constellation.
pub layout_to_constellation_chan: ConstellationChan<LayoutMsg>,
pub layout_to_constellation_chan: IpcSender<LayoutMsg>,
/// A channel to report panics
pub panic_chan: ConstellationChan<PanicMsg>,
pub panic_chan: IpcSender<PanicMsg>,
/// A channel to schedule timer events.
pub scheduler_chan: IpcSender<TimerEventRequest>,
/// A channel to the compositor.
@@ -389,8 +388,8 @@ impl Pipeline {
pub struct UnprivilegedPipelineContent {
id: PipelineId,
parent_info: Option<(PipelineId, SubpageId)>,
constellation_chan: ConstellationChan<ScriptMsg>,
layout_to_constellation_chan: ConstellationChan<LayoutMsg>,
constellation_chan: IpcSender<ScriptMsg>,
layout_to_constellation_chan: IpcSender<LayoutMsg>,
scheduler_chan: IpcSender<TimerEventRequest>,
devtools_chan: Option<IpcSender<ScriptToDevtoolsControlMsg>>,
script_to_compositor_chan: IpcSender<ScriptToCompositorMsg>,
@@ -404,7 +403,7 @@ pub struct UnprivilegedPipelineContent {
window_size: Option<WindowSizeData>,
script_chan: IpcSender<ConstellationControlMsg>,
load_data: LoadData,
panic_chan: ConstellationChan<PanicMsg>,
panic_chan: IpcSender<PanicMsg>,
script_port: Option<IpcReceiver<ConstellationControlMsg>>,
layout_to_paint_chan: OptionalIpcSender<LayoutToPaintMsg>,
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<PanicMsg>,
panic_chan: IpcSender<PanicMsg>,
layout_to_paint_port: Receiver<LayoutToPaintMsg>,
chrome_to_paint_chan: Sender<ChromeToPaintMsg>,
chrome_to_paint_port: Receiver<ChromeToPaintMsg>,
@@ -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<LTF, STF> {
/// A channel through which script messages can be sent to this object.
script_sender: ConstellationChan<FromScriptMsg>,
script_sender: IpcSender<FromScriptMsg>,

/// A channel through which compositor messages can be sent to this object.
compositor_sender: Sender<FromCompositorMsg>,

/// A channel through which layout thread messages can be sent to this object.
layout_sender: ConstellationChan<FromLayoutMsg>,
layout_sender: IpcSender<FromLayoutMsg>,

/// A channel through which panic messages can be sent to this object.
panic_sender: ConstellationChan<PanicMsg>,
panic_sender: IpcSender<PanicMsg>,

/// Receives messages from scripts.
script_receiver: Receiver<FromScriptMsg>,
@@ -323,14 +323,18 @@ enum ChildProcess {

impl<LTF: LayoutThreadFactory, STF: ScriptThreadFactory> Constellation<LTF, STF> {
pub fn start(state: InitialConstellationState) -> Sender<FromCompositorMsg> {
let (ipc_script_receiver, ipc_script_sender) = ConstellationChan::<FromScriptMsg>::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::<FromLayoutMsg>::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::<PanicMsg>::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<LTF, STF> = Constellation {
script_sender: ipc_script_sender,
@@ -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<C> PaintThread<C> where C: PaintListener + Send + 'static {
layout_to_paint_port: Receiver<LayoutToPaintMsg>,
chrome_to_paint_port: Receiver<ChromeToPaintMsg>,
compositor: C,
panic_chan: ConstellationChan<PanicMsg>,
panic_chan: IpcSender<PanicMsg>,
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<C> PaintThread<C> 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)]
@@ -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<ConstellationMsg>,
pub fn update_animation_state(constellation_chan: &IpcSender<ConstellationMsg>,
running_animations: &mut HashMap<OpaqueNode, Vec<Animation>>,
expired_animations: &mut HashMap<OpaqueNode, Vec<Animation>>,
new_animations_receiver: &Receiver<Animation>,
@@ -77,8 +78,7 @@ pub fn update_animation_state(constellation_chan: &ConstellationChan<Constellati
animation_state = AnimationState::AnimationsPresent;
}

constellation_chan.0
.send(ConstellationMsg::ChangeRunningAnimationsState(pipeline_id, animation_state))
constellation_chan.send(ConstellationMsg::ChangeRunningAnimationsState(pipeline_id, animation_state))
.unwrap();
}

@@ -37,7 +37,7 @@ use ipc_channel::router::ROUTER;
use layout_debug;
use layout_traits::{ConvertPipelineIdToWebRender, LayoutThreadFactory};
use log;
use msg::constellation_msg::{ConstellationChan, PanicMsg, PipelineId};
use msg::constellation_msg::{PanicMsg, PipelineId};
use net_traits::image_cache_thread::{ImageCacheChan, ImageCacheResult, ImageCacheThread};
use net_traits::image_cache_thread::{UsePlaceholder};
use parallel;
@@ -100,7 +100,7 @@ const DISPLAY_PORT_THRESHOLD_SIZE_FACTOR: i32 = 4;
/// This needs to be protected by a mutex so we can do fast RPCs.
pub struct LayoutThreadData {
/// The channel on which messages can be sent to the constellation.
pub constellation_chan: ConstellationChan<ConstellationMsg>,
pub constellation_chan: IpcSender<ConstellationMsg>,

/// The root stacking context.
pub display_list: Option<Arc<DisplayList>>,
@@ -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<ConstellationMsg>,
constellation_chan: IpcSender<ConstellationMsg>,

/// The channel on which messages can be sent to the script thread.
script_chan: IpcSender<ConstellationControlMsg>,
@@ -253,8 +253,8 @@ impl LayoutThreadFactory for LayoutThread {
is_iframe: bool,
chan: OpaqueScriptLayoutChannel,
pipeline_port: IpcReceiver<LayoutControlMsg>,
constellation_chan: ConstellationChan<ConstellationMsg>,
panic_chan: ConstellationChan<PanicMsg>,
constellation_chan: IpcSender<ConstellationMsg>,
panic_chan: IpcSender<PanicMsg>,
script_chan: IpcSender<ConstellationControlMsg>,
paint_chan: OptionalIpcSender<LayoutToPaintMsg>,
image_cache_thread: ImageCacheThread,
@@ -264,7 +264,6 @@ impl LayoutThreadFactory for LayoutThread {
shutdown_chan: IpcSender<()>,
content_process_shutdown_chan: IpcSender<()>,
webrender_api_sender: Option<webrender_traits::RenderApiSender>) {
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<Msg>,
pipeline_port: IpcReceiver<LayoutControlMsg>,
constellation_chan: ConstellationChan<ConstellationMsg>,
constellation_chan: IpcSender<ConstellationMsg>,
script_chan: IpcSender<ConstellationControlMsg>,
paint_chan: OptionalIpcSender<LayoutToPaintMsg>,
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) {
@@ -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()),
@@ -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<LayoutControlMsg>,
constellation_chan: ConstellationChan<ConstellationMsg>,
panic_chan: ConstellationChan<PanicMsg>,
constellation_chan: IpcSender<ConstellationMsg>,
panic_chan: IpcSender<PanicMsg>,
script_chan: IpcSender<ConstellationControlMsg>,
layout_to_paint_chan: OptionalIpcSender<LayoutToPaintMsg>,
image_cache_thread: ImageCacheThread,
@@ -9,32 +9,15 @@ 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;
use util::geometry::{PagePx, ViewportPx};
use webdriver_msg::{LoadStatus, WebDriverScriptCommand};
use webrender_traits;

#[derive(Deserialize, Serialize)]
pub struct ConstellationChan<T: Deserialize + Serialize>(pub IpcSender<T>);

impl<T: Deserialize + Serialize> ConstellationChan<T> {
pub fn new() -> (IpcReceiver<T>, ConstellationChan<T>) {
let (chan, port) = ipc::channel().unwrap();
(port, ConstellationChan(chan))
}
}

impl<T: Serialize + Deserialize> Clone for ConstellationChan<T> {
fn clone(&self) -> ConstellationChan<T> {
ConstellationChan(self.0.clone())
}
}

pub type PanicMsg = (Option<PipelineId>, String, String);

#[derive(Copy, Clone, Deserialize, Serialize, HeapSizeOf)]
@@ -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<ConstellationMsg> {
impl ClipboardProvider for IpcSender<ConstellationMsg> {
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();
}
}

@@ -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<ConstellationMsg> {
/// Get a `IpcSender` to send messages to the constellation when available.
pub fn constellation_chan(&self) -> &IpcSender<ConstellationMsg> {
match *self {
GlobalRef::Window(window) => window.constellation_chan(),
GlobalRef::Worker(worker) => worker.constellation_chan(),
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.