servo: Merge #11270 - Remove ConstellationChan (from servo:ConstellationChan); r=asajeffrey

Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `__` with appropriate data:
- [x] `./mach build -d` does not report any errors
- [x] `./mach test-tidy --faster` does not report any errors
- [ ] These changes fix #__ (github issue number if applicable).

Either:
- [ ] There are tests for these changes OR
- [x] These changes do not require tests because _____

Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process.

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.

Source-Repo: https://github.com/servo/servo
Source-Revision: 27c25e859a45c3d79c85e96b85ec5226a3231e10
This commit is contained in:
Ms2ger 2016-05-19 12:38:26 -07:00
parent aa9de18fe4
commit c69abc638b
24 changed files with 110 additions and 162 deletions

View File

@ -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>,

View File

@ -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,

View File

@ -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)]

View File

@ -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();
}

View File

@ -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) {

View File

@ -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()),

View File

@ -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,

View File

@ -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<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)]

View File

@ -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();
}
}

View File

@ -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(),

View File

@ -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<ScriptMsg> {
#[inline]
fn trace(&self, _trc: *mut JSTracer) {
// Do nothing
}
}
impl JSTraceable for ConstellationChan<LayoutMsg> {
#[inline]
fn trace(&self, _trc: *mut JSTracer) {
// Do nothing
}
}
impl JSTraceable for Box<ScriptChan + Send> {
#[inline]
fn trace(&self, _trc: *mut JSTracer) {

View File

@ -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(),

View File

@ -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();
}

View File

@ -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 {

View File

@ -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::<Node>().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()
}

View File

@ -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<u32>,
maxlength: Cell<i32>,
#[ignore_heap_size_of = "#7193"]
textinput: DOMRefCell<TextInput<ConstellationChan<ConstellationMsg>>>,
textinput: DOMRefCell<TextInput<IpcSender<ConstellationMsg>>>,
activation_state: DOMRefCell<InputActivationState>,
// https://html.spec.whatwg.org/multipage/#concept-input-value-dirty-flag
value_dirty: Cell<bool>,

View File

@ -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()),

View File

@ -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<ConstellationChan<ConstellationMsg>>>,
textinput: DOMRefCell<TextInput<IpcSender<ConstellationMsg>>>,
// https://html.spec.whatwg.org/multipage/#concept-textarea-dirty
value_changed: Cell<bool>,
}

View File

@ -95,8 +95,7 @@ impl WebGLRenderingContext {
-> Result<WebGLRenderingContext, String> {
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();

View File

@ -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<ConstellationMsg>,
constellation_chan: IpcSender<ConstellationMsg>,
/// Pending scroll to fragment event, if any
fragment_name: DOMRefCell<Option<String>>,
@ -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<ConstellationMsg> {
pub fn constellation_chan(&self) -> &IpcSender<ConstellationMsg> {
&self.constellation_chan
}
@ -1459,7 +1459,7 @@ impl Window {
mem_profiler_chan: mem::ProfilerChan,
time_profiler_chan: ProfilerChan,
devtools_chan: Option<IpcSender<ScriptToDevtoolsControlMsg>>,
constellation_chan: ConstellationChan<ConstellationMsg>,
constellation_chan: IpcSender<ConstellationMsg>,
control_chan: IpcSender<ConstellationControlMsg>,
scheduler_chan: IpcSender<TimerEventRequest>,
panic_chan: IpcSender<PanicMsg>,

View File

@ -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<IpcSender<ScriptToDevtoolsControlMsg>>,
pub from_devtools_sender: Option<IpcSender<DevtoolScriptControlMsg>>,
pub constellation_chan: ConstellationChan<ConstellationMsg>,
pub constellation_chan: IpcSender<ConstellationMsg>,
pub scheduler_chan: IpcSender<TimerEventRequest>,
pub panic_chan: IpcSender<PanicMsg>,
pub worker_id: WorkerId,
@ -94,7 +94,7 @@ pub struct WorkerGlobalScope {
devtools_wants_updates: Cell<bool>,
#[ignore_heap_size_of = "Defined in std"]
constellation_chan: ConstellationChan<ConstellationMsg>,
constellation_chan: IpcSender<ConstellationMsg>,
#[ignore_heap_size_of = "Defined in std"]
scheduler_chan: IpcSender<TimerEventRequest>,
@ -156,7 +156,7 @@ impl WorkerGlobalScope {
&self.from_devtools_receiver
}
pub fn constellation_chan(&self) -> &ConstellationChan<ConstellationMsg> {
pub fn constellation_chan(&self) -> &IpcSender<ConstellationMsg> {
&self.constellation_chan
}

View File

@ -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<LayoutControlMsg>,
pub constellation_chan: ConstellationChan<ConstellationMsg>,
pub panic_chan: ConstellationChan<PanicMsg>,
pub constellation_chan: IpcSender<ConstellationMsg>,
pub panic_chan: IpcSender<PanicMsg>,
pub script_chan: IpcSender<ConstellationControlMsg>,
pub image_cache_thread: ImageCacheThread,
pub paint_chan: OptionalOpaqueIpcSender,

View File

@ -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<ConstellationControlMsg>,
/// For communicating load url messages to the constellation
constellation_chan: ConstellationChan<ConstellationMsg>,
constellation_chan: IpcSender<ConstellationMsg>,
/// For communicating layout messages to the constellation
layout_to_constellation_chan: ConstellationChan<LayoutMsg>,
layout_to_constellation_chan: IpcSender<LayoutMsg>,
/// A handle to the compositor for communicating ready state messages.
compositor: DOMRefCell<IpcSender<ScriptToCompositorMsg>>,
@ -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::<HTMLAnchorElement>)
.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();
}
}
}

View File

@ -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<LayoutControlMsg>,
/// A channel for sending panics on
pub panic_chan: ConstellationChan<PanicMsg>,
pub panic_chan: IpcSender<PanicMsg>,
/// 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<ConstellationControlMsg>,
/// A channel on which messages can be sent to the constellation from script.
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 for sending panics to the constellation.
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 resource manager thread.