Auto merge of #7171 - Ms2ger:ScriptControlChan, r=jdm

Remove ScriptControlChan.



<!-- Reviewable:start -->
[<img src="https://reviewable.io/review_button.png" height=40 alt="Review on Reviewable"/>](https://reviewable.io/reviews/servo/servo/7171)
<!-- Reviewable:end -->
This commit is contained in:
bors-servo 2015-08-12 08:28:29 -06:00
commit 3ad49fc689
12 changed files with 55 additions and 85 deletions

View file

@ -39,7 +39,7 @@ use msg::constellation_msg::{PipelineId, WindowSizeData};
use png; use png;
use profile_traits::mem::{self, Reporter, ReporterRequest, ReportKind}; use profile_traits::mem::{self, Reporter, ReporterRequest, ReportKind};
use profile_traits::time::{self, ProfilerCategory, profile}; use profile_traits::time::{self, ProfilerCategory, profile};
use script_traits::{ConstellationControlMsg, LayoutControlMsg, ScriptControlChan}; use script_traits::{ConstellationControlMsg, LayoutControlMsg};
use std::collections::HashMap; use std::collections::HashMap;
use std::collections::hash_map::Entry::{Occupied, Vacant}; use std::collections::hash_map::Entry::{Occupied, Vacant};
use std::mem as std_mem; use std::mem as std_mem;
@ -1278,8 +1278,7 @@ impl<Window: WindowMethods> IOCompositor<Window> {
let layer_rect = Rect::new(-layer.extra_data.borrow().scroll_offset.to_untyped(), let layer_rect = Rect::new(-layer.extra_data.borrow().scroll_offset.to_untyped(),
layer.bounds.borrow().size.to_untyped()); layer.bounds.borrow().size.to_untyped());
let pipeline = self.get_pipeline(layer.pipeline_id()); let pipeline = self.get_pipeline(layer.pipeline_id());
let ScriptControlChan(ref chan) = pipeline.script_chan; pipeline.script_chan.send(ConstellationControlMsg::Viewport(pipeline.id.clone(), layer_rect)).unwrap();
chan.send(ConstellationControlMsg::Viewport(pipeline.id.clone(), layer_rect)).unwrap();
} }
for kid in layer.children().iter() { for kid in layer.children().iter() {

View file

@ -14,7 +14,7 @@ use layers::color::Color;
use layers::geometry::LayerPixel; use layers::geometry::LayerPixel;
use layers::layers::{Layer, LayerBufferSet}; use layers::layers::{Layer, LayerBufferSet};
use script_traits::CompositorEvent::{ClickEvent, MouseDownEvent, MouseMoveEvent, MouseUpEvent}; use script_traits::CompositorEvent::{ClickEvent, MouseDownEvent, MouseMoveEvent, MouseUpEvent};
use script_traits::{ScriptControlChan, ConstellationControlMsg}; use script_traits::ConstellationControlMsg;
use msg::compositor_msg::{Epoch, LayerId, LayerProperties, ScrollPolicy}; use msg::compositor_msg::{Epoch, LayerId, LayerProperties, ScrollPolicy};
use msg::constellation_msg::PipelineId; use msg::constellation_msg::PipelineId;
use std::rc::Rc; use std::rc::Rc;
@ -360,8 +360,7 @@ impl CompositorLayer for Layer<CompositorData> {
}; };
let pipeline = compositor.get_pipeline(self.pipeline_id()); let pipeline = compositor.get_pipeline(self.pipeline_id());
let ScriptControlChan(ref chan) = pipeline.script_chan; let _ = pipeline.script_chan.send(ConstellationControlMsg::SendEvent(pipeline.id.clone(), message));
let _ = chan.send(ConstellationControlMsg::SendEvent(pipeline.id.clone(), message));
} }
fn send_mouse_move_event<Window>(&self, fn send_mouse_move_event<Window>(&self,
@ -370,8 +369,7 @@ impl CompositorLayer for Layer<CompositorData> {
where Window: WindowMethods { where Window: WindowMethods {
let message = MouseMoveEvent(cursor.to_untyped()); let message = MouseMoveEvent(cursor.to_untyped());
let pipeline = compositor.get_pipeline(self.pipeline_id()); let pipeline = compositor.get_pipeline(self.pipeline_id());
let ScriptControlChan(ref chan) = pipeline.script_chan; let _ = pipeline.script_chan.send(ConstellationControlMsg::SendEvent(pipeline.id.clone(), message));
let _ = chan.send(ConstellationControlMsg::SendEvent(pipeline.id.clone(), message));
} }
fn scroll_layer_and_all_child_layers(&self, new_offset: TypedPoint2D<LayerPixel, f32>) fn scroll_layer_and_all_child_layers(&self, new_offset: TypedPoint2D<LayerPixel, f32>)

View file

@ -41,7 +41,7 @@ use offscreen_gl_context::GLContextAttributes;
use profile_traits::mem; use profile_traits::mem;
use profile_traits::time; use profile_traits::time;
use script_traits::{CompositorEvent, ConstellationControlMsg, LayoutControlMsg}; use script_traits::{CompositorEvent, ConstellationControlMsg, LayoutControlMsg};
use script_traits::{ScriptControlChan, ScriptState, ScriptTaskFactory}; use script_traits::{ScriptState, ScriptTaskFactory};
use std::borrow::ToOwned; use std::borrow::ToOwned;
use std::collections::HashMap; use std::collections::HashMap;
use std::io::{self, Write}; use std::io::{self, Write};
@ -287,7 +287,7 @@ impl<LTF: LayoutTaskFactory, STF: ScriptTaskFactory> Constellation<LTF, STF> {
fn new_pipeline(&mut self, fn new_pipeline(&mut self,
parent_info: Option<(PipelineId, SubpageId)>, parent_info: Option<(PipelineId, SubpageId)>,
initial_window_rect: Option<TypedRect<PagePx, f32>>, initial_window_rect: Option<TypedRect<PagePx, f32>>,
script_channel: Option<ScriptControlChan>, script_channel: Option<Sender<ConstellationControlMsg>>,
load_data: LoadData) load_data: LoadData)
-> PipelineId { -> PipelineId {
let pipeline_id = self.next_pipeline_id; let pipeline_id = self.next_pipeline_id;
@ -606,7 +606,6 @@ impl<LTF: LayoutTaskFactory, STF: ScriptTaskFactory> Constellation<LTF, STF> {
(pipeline.id, pipeline.script_chan.clone()) (pipeline.id, pipeline.script_chan.clone())
}; };
let ScriptControlChan(ref script_chan) = script_chan;
script_chan.send(ConstellationControlMsg::Resize(pipeline_id, WindowSizeData { script_chan.send(ConstellationControlMsg::Resize(pipeline_id, WindowSizeData {
visible_viewport: rect.size, visible_viewport: rect.size,
initial_viewport: rect.size * ScaleFactor::new(1.0), initial_viewport: rect.size * ScaleFactor::new(1.0),
@ -706,7 +705,7 @@ impl<LTF: LayoutTaskFactory, STF: ScriptTaskFactory> Constellation<LTF, STF> {
// Message the constellation to find the script task for this iframe // Message the constellation to find the script task for this iframe
// and issue an iframe load through there. // and issue an iframe load through there.
let parent_pipeline = self.pipeline(parent_pipeline_id); let parent_pipeline = self.pipeline(parent_pipeline_id);
let ScriptControlChan(ref script_channel) = parent_pipeline.script_chan; let script_channel = &parent_pipeline.script_chan;
script_channel.send(ConstellationControlMsg::Navigate(parent_pipeline_id, script_channel.send(ConstellationControlMsg::Navigate(parent_pipeline_id,
subpage_id, subpage_id,
load_data)).unwrap(); load_data)).unwrap();
@ -845,7 +844,7 @@ impl<LTF: LayoutTaskFactory, STF: ScriptTaskFactory> Constellation<LTF, STF> {
// Update the owning iframe to point to the new subpage id. // Update the owning iframe to point to the new subpage id.
// This makes things like contentDocument work correctly. // This makes things like contentDocument work correctly.
if let Some((parent_pipeline_id, subpage_id)) = pipeline_info { if let Some((parent_pipeline_id, subpage_id)) = pipeline_info {
let ScriptControlChan(ref script_chan) = self.pipeline(parent_pipeline_id).script_chan; let script_chan = &self.pipeline(parent_pipeline_id).script_chan;
let (_, new_subpage_id) = self.pipeline(next_pipeline_id).parent_info.unwrap(); let (_, new_subpage_id) = self.pipeline(next_pipeline_id).parent_info.unwrap();
script_chan.send(ConstellationControlMsg::UpdateSubpageId(parent_pipeline_id, script_chan.send(ConstellationControlMsg::UpdateSubpageId(parent_pipeline_id,
subpage_id, subpage_id,
@ -868,10 +867,9 @@ impl<LTF: LayoutTaskFactory, STF: ScriptTaskFactory> Constellation<LTF, STF> {
match target_pipeline_id { match target_pipeline_id {
Some(target_pipeline_id) => { Some(target_pipeline_id) => {
let pipeline = self.pipeline(target_pipeline_id); let pipeline = self.pipeline(target_pipeline_id);
let ScriptControlChan(ref chan) = pipeline.script_chan;
let event = CompositorEvent::KeyEvent(key, state, mods); let event = CompositorEvent::KeyEvent(key, state, mods);
chan.send(ConstellationControlMsg::SendEvent(pipeline.id, pipeline.script_chan.send(
event)).unwrap(); ConstellationControlMsg::SendEvent(pipeline.id, event)).unwrap();
} }
None => { None => {
let event = CompositorMsg::KeyEvent(key, state, mods); let event = CompositorMsg::KeyEvent(key, state, mods);
@ -884,8 +882,7 @@ impl<LTF: LayoutTaskFactory, STF: ScriptTaskFactory> Constellation<LTF, STF> {
match self.pipelines.get(&pipeline_id) { match self.pipelines.get(&pipeline_id) {
None => self.compositor_proxy.send(CompositorMsg::ChangePageTitle(pipeline_id, None)), None => self.compositor_proxy.send(CompositorMsg::ChangePageTitle(pipeline_id, None)),
Some(pipeline) => { Some(pipeline) => {
let ScriptControlChan(ref script_channel) = pipeline.script_chan; pipeline.script_chan.send(ConstellationControlMsg::GetTitle(pipeline_id)).unwrap();
script_channel.send(ConstellationControlMsg::GetTitle(pipeline_id)).unwrap();
} }
} }
} }
@ -928,10 +925,9 @@ impl<LTF: LayoutTaskFactory, STF: ScriptTaskFactory> Constellation<LTF, STF> {
// telling it to mark the iframe element as focused. // telling it to mark the iframe element as focused.
if let Some((containing_pipeline_id, subpage_id)) = self.pipeline(pipeline_id).parent_info { if let Some((containing_pipeline_id, subpage_id)) = self.pipeline(pipeline_id).parent_info {
let pipeline = self.pipeline(containing_pipeline_id); let pipeline = self.pipeline(containing_pipeline_id);
let ScriptControlChan(ref script_channel) = pipeline.script_chan;
let event = ConstellationControlMsg::FocusIFrame(containing_pipeline_id, let event = ConstellationControlMsg::FocusIFrame(containing_pipeline_id,
subpage_id); subpage_id);
script_channel.send(event).unwrap(); pipeline.script_chan.send(event).unwrap();
self.focus_parent_pipeline(containing_pipeline_id); self.focus_parent_pipeline(containing_pipeline_id);
} }
@ -1005,8 +1001,7 @@ impl<LTF: LayoutTaskFactory, STF: ScriptTaskFactory> Constellation<LTF, STF> {
WebDriverCommandMsg::ScriptCommand(pipeline_id, cmd) => { WebDriverCommandMsg::ScriptCommand(pipeline_id, cmd) => {
let pipeline = self.pipeline(pipeline_id); let pipeline = self.pipeline(pipeline_id);
let control_msg = ConstellationControlMsg::WebDriverScriptCommand(pipeline_id, cmd); let control_msg = ConstellationControlMsg::WebDriverScriptCommand(pipeline_id, cmd);
let ScriptControlChan(ref script_channel) = pipeline.script_chan; pipeline.script_chan.send(control_msg).unwrap();
script_channel.send(control_msg).unwrap();
}, },
WebDriverCommandMsg::TakeScreenshot(pipeline_id, reply) => { WebDriverCommandMsg::TakeScreenshot(pipeline_id, reply) => {
let current_pipeline_id = self.root_frame_id.map(|frame_id| { let current_pipeline_id = self.root_frame_id.map(|frame_id| {
@ -1151,13 +1146,11 @@ impl<LTF: LayoutTaskFactory, STF: ScriptTaskFactory> Constellation<LTF, STF> {
let frame = self.frames.get(&root_frame_id).unwrap(); let frame = self.frames.get(&root_frame_id).unwrap();
let pipeline = self.pipelines.get(&frame.current).unwrap(); let pipeline = self.pipelines.get(&frame.current).unwrap();
let ScriptControlChan(ref chan) = pipeline.script_chan; let _ = pipeline.script_chan.send(ConstellationControlMsg::Resize(pipeline.id, new_size));
let _ = chan.send(ConstellationControlMsg::Resize(pipeline.id, new_size));
for pipeline_id in frame.prev.iter().chain(frame.next.iter()) { for pipeline_id in frame.prev.iter().chain(frame.next.iter()) {
let pipeline = self.pipelines.get(pipeline_id).unwrap(); let pipeline = self.pipelines.get(pipeline_id).unwrap();
let ScriptControlChan(ref chan) = pipeline.script_chan; let _ = pipeline.script_chan.send(ConstellationControlMsg::ResizeInactive(pipeline.id, new_size));
let _ = chan.send(ConstellationControlMsg::ResizeInactive(pipeline.id, new_size));
} }
} }
@ -1165,8 +1158,7 @@ impl<LTF: LayoutTaskFactory, STF: ScriptTaskFactory> Constellation<LTF, STF> {
for pending_frame in &self.pending_frames { for pending_frame in &self.pending_frames {
let pipeline = self.pipelines.get(&pending_frame.new_pipeline_id).unwrap(); let pipeline = self.pipelines.get(&pending_frame.new_pipeline_id).unwrap();
if pipeline.parent_info.is_none() { if pipeline.parent_info.is_none() {
let ScriptControlChan(ref chan) = pipeline.script_chan; let _ = pipeline.script_chan.send(ConstellationControlMsg::Resize(pipeline.id, new_size));
let _ = chan.send(ConstellationControlMsg::Resize(pipeline.id, new_size));
} }
} }
@ -1206,10 +1198,9 @@ impl<LTF: LayoutTaskFactory, STF: ScriptTaskFactory> Constellation<LTF, STF> {
// Synchronously query the script task for this pipeline // Synchronously query the script task for this pipeline
// to see if it is idle. // to see if it is idle.
let ScriptControlChan(ref script_chan) = pipeline.script_chan;
let (sender, receiver) = channel(); let (sender, receiver) = channel();
let msg = ConstellationControlMsg::GetCurrentState(sender, frame.current); let msg = ConstellationControlMsg::GetCurrentState(sender, frame.current);
script_chan.send(msg).unwrap(); pipeline.script_chan.send(msg).unwrap();
if receiver.recv().unwrap() == ScriptState::DocumentLoading { if receiver.recv().unwrap() == ScriptState::DocumentLoading {
return false; return false;
} }

View file

@ -4,7 +4,7 @@
use CompositorProxy; use CompositorProxy;
use layout_traits::{LayoutTaskFactory, LayoutControlChan}; use layout_traits::{LayoutTaskFactory, LayoutControlChan};
use script_traits::{LayoutControlMsg, ScriptControlChan, ScriptTaskFactory}; use script_traits::{LayoutControlMsg, ScriptTaskFactory};
use script_traits::{NewLayoutInfo, ConstellationControlMsg}; use script_traits::{NewLayoutInfo, ConstellationControlMsg};
use compositor_task; use compositor_task;
@ -38,7 +38,7 @@ use util::opts;
pub struct Pipeline { pub struct Pipeline {
pub id: PipelineId, pub id: PipelineId,
pub parent_info: Option<(PipelineId, SubpageId)>, pub parent_info: Option<(PipelineId, SubpageId)>,
pub script_chan: ScriptControlChan, pub script_chan: Sender<ConstellationControlMsg>,
/// A channel to layout, for performing reflows and shutdown. /// A channel to layout, for performing reflows and shutdown.
pub layout_chan: LayoutControlChan, pub layout_chan: LayoutControlChan,
pub chrome_to_paint_chan: Sender<ChromeToPaintMsg>, pub chrome_to_paint_chan: Sender<ChromeToPaintMsg>,
@ -59,7 +59,7 @@ pub struct Pipeline {
#[derive(Clone)] #[derive(Clone)]
pub struct CompositionPipeline { pub struct CompositionPipeline {
pub id: PipelineId, pub id: PipelineId,
pub script_chan: ScriptControlChan, pub script_chan: Sender<ConstellationControlMsg>,
pub layout_chan: LayoutControlChan, pub layout_chan: LayoutControlChan,
pub chrome_to_paint_chan: Sender<ChromeToPaintMsg>, pub chrome_to_paint_chan: Sender<ChromeToPaintMsg>,
} }
@ -80,7 +80,7 @@ impl Pipeline {
time_profiler_chan: time::ProfilerChan, time_profiler_chan: time::ProfilerChan,
mem_profiler_chan: profile_mem::ProfilerChan, mem_profiler_chan: profile_mem::ProfilerChan,
window_rect: Option<TypedRect<PagePx, f32>>, window_rect: Option<TypedRect<PagePx, f32>>,
script_chan: Option<ScriptControlChan>, script_chan: Option<Sender<ConstellationControlMsg>>,
load_data: LoadData, load_data: LoadData,
device_pixel_ratio: ScaleFactor<ViewportPx, DevicePixel, f32>) device_pixel_ratio: ScaleFactor<ViewportPx, DevicePixel, f32>)
-> (Pipeline, PipelineContent) -> (Pipeline, PipelineContent)
@ -131,14 +131,13 @@ impl Pipeline {
layout_shutdown_chan: layout_shutdown_chan.clone(), layout_shutdown_chan: layout_shutdown_chan.clone(),
}; };
script_chan.0 script_chan.send(ConstellationControlMsg::AttachLayout(new_layout_info))
.send(ConstellationControlMsg::AttachLayout(new_layout_info))
.unwrap(); .unwrap();
(script_chan, None) (script_chan, None)
} }
None => { None => {
let (script_chan, script_port) = channel(); let (script_chan, script_port) = channel();
(ScriptControlChan(script_chan), Some(script_port)) (script_chan, Some(script_port))
} }
}; };
@ -183,7 +182,7 @@ impl Pipeline {
pub fn new(id: PipelineId, pub fn new(id: PipelineId,
parent_info: Option<(PipelineId, SubpageId)>, parent_info: Option<(PipelineId, SubpageId)>,
script_chan: ScriptControlChan, script_chan: Sender<ConstellationControlMsg>,
layout_chan: LayoutControlChan, layout_chan: LayoutControlChan,
chrome_to_paint_chan: Sender<ChromeToPaintMsg>, chrome_to_paint_chan: Sender<ChromeToPaintMsg>,
layout_shutdown_port: Receiver<()>, layout_shutdown_port: Receiver<()>,
@ -221,8 +220,7 @@ impl Pipeline {
// Script task handles shutting down layout, and layout handles shutting down the painter. // Script task handles shutting down layout, and layout handles shutting down the painter.
// For now, if the script task has failed, we give up on clean shutdown. // For now, if the script task has failed, we give up on clean shutdown.
let ScriptControlChan(ref chan) = self.script_chan; if self.script_chan.send(ConstellationControlMsg::ExitPipeline(self.id, exit_type)).is_ok() {
if chan.send(ConstellationControlMsg::ExitPipeline(self.id, exit_type)).is_ok() {
// Wait until all slave tasks have terminated and run destructors // Wait until all slave tasks have terminated and run destructors
// NOTE: We don't wait for script task as we don't always own it // NOTE: We don't wait for script task as we don't always own it
let _ = self.paint_shutdown_port.recv(); let _ = self.paint_shutdown_port.recv();
@ -232,18 +230,15 @@ impl Pipeline {
} }
pub fn freeze(&self) { pub fn freeze(&self) {
let ScriptControlChan(ref script_channel) = self.script_chan; let _ = self.script_chan.send(ConstellationControlMsg::Freeze(self.id)).unwrap();
let _ = script_channel.send(ConstellationControlMsg::Freeze(self.id)).unwrap();
} }
pub fn thaw(&self) { pub fn thaw(&self) {
let ScriptControlChan(ref script_channel) = self.script_chan; let _ = self.script_chan.send(ConstellationControlMsg::Thaw(self.id)).unwrap();
let _ = script_channel.send(ConstellationControlMsg::Thaw(self.id)).unwrap();
} }
pub fn force_exit(&self) { pub fn force_exit(&self) {
let ScriptControlChan(ref script_channel) = self.script_chan; let _ = self.script_chan.send(
let _ = script_channel.send(
ConstellationControlMsg::ExitPipeline(self.id, ConstellationControlMsg::ExitPipeline(self.id,
PipelineExitType::PipelineOnly)).unwrap(); PipelineExitType::PipelineOnly)).unwrap();
let _ = self.chrome_to_paint_chan.send(ChromeToPaintMsg::Exit( let _ = self.chrome_to_paint_chan.send(ChromeToPaintMsg::Exit(
@ -277,11 +272,10 @@ impl Pipeline {
event: MozBrowserEvent) { event: MozBrowserEvent) {
assert!(opts::experimental_enabled()); assert!(opts::experimental_enabled());
let ScriptControlChan(ref script_channel) = self.script_chan;
let event = ConstellationControlMsg::MozBrowserEvent(self.id, let event = ConstellationControlMsg::MozBrowserEvent(self.id,
subpage_id, subpage_id,
event); event);
script_channel.send(event).unwrap(); self.script_chan.send(event).unwrap();
} }
} }
@ -298,7 +292,7 @@ pub struct PipelineContent {
time_profiler_chan: time::ProfilerChan, time_profiler_chan: time::ProfilerChan,
mem_profiler_chan: profile_mem::ProfilerChan, mem_profiler_chan: profile_mem::ProfilerChan,
window_size: Option<WindowSizeData>, window_size: Option<WindowSizeData>,
script_chan: ScriptControlChan, script_chan: Sender<ConstellationControlMsg>,
load_data: LoadData, load_data: LoadData,
failure: Failure, failure: Failure,
script_port: Option<Receiver<ConstellationControlMsg>>, script_port: Option<Receiver<ConstellationControlMsg>>,

View file

@ -12,7 +12,7 @@ use gfx::display_list::OpaqueNode;
use layout_task::{LayoutTask, LayoutTaskData}; use layout_task::{LayoutTask, LayoutTaskData};
use msg::constellation_msg::{AnimationState, Msg, PipelineId}; use msg::constellation_msg::{AnimationState, Msg, PipelineId};
use script::layout_interface::Animation; use script::layout_interface::Animation;
use script_traits::{ConstellationControlMsg, ScriptControlChan}; use script_traits::ConstellationControlMsg;
use std::collections::HashMap; use std::collections::HashMap;
use std::collections::hash_map::Entry; use std::collections::hash_map::Entry;
use std::sync::Arc; use std::sync::Arc;
@ -128,7 +128,6 @@ pub fn recalc_style_for_animations(flow: &mut Flow,
pub fn tick_all_animations(layout_task: &LayoutTask, rw_data: &mut LayoutTaskData) { pub fn tick_all_animations(layout_task: &LayoutTask, rw_data: &mut LayoutTaskData) {
layout_task.tick_animations(rw_data); layout_task.tick_animations(rw_data);
let ScriptControlChan(ref chan) = layout_task.script_chan; layout_task.script_chan.send(ConstellationControlMsg::TickAllAnimations(layout_task.id)).unwrap();
chan.send(ConstellationControlMsg::TickAllAnimations(layout_task.id)).unwrap();
} }

View file

@ -59,7 +59,7 @@ use script::layout_interface::{LayoutChan, LayoutRPC, OffsetParentResponse};
use script::layout_interface::{NewLayoutTaskInfo, Msg, Reflow, ReflowGoal, ReflowQueryType}; use script::layout_interface::{NewLayoutTaskInfo, Msg, Reflow, ReflowGoal, ReflowQueryType};
use script::layout_interface::{ScriptLayoutChan, ScriptReflow, TrustedNodeAddress}; use script::layout_interface::{ScriptLayoutChan, ScriptReflow, TrustedNodeAddress};
use script_traits::{ConstellationControlMsg, LayoutControlMsg, OpaqueScriptLayoutChannel}; use script_traits::{ConstellationControlMsg, LayoutControlMsg, OpaqueScriptLayoutChannel};
use script_traits::{ScriptControlChan, StylesheetLoadResponder}; use script_traits::StylesheetLoadResponder;
use selectors::parser::PseudoElement; use selectors::parser::PseudoElement;
use serde_json; use serde_json;
use std::borrow::ToOwned; use std::borrow::ToOwned;
@ -186,7 +186,7 @@ pub struct LayoutTask {
pub constellation_chan: ConstellationChan, pub constellation_chan: ConstellationChan,
/// The channel on which messages can be sent to the script task. /// The channel on which messages can be sent to the script task.
pub script_chan: ScriptControlChan, pub script_chan: Sender<ConstellationControlMsg>,
/// The channel on which messages can be sent to the painting task. /// The channel on which messages can be sent to the painting task.
pub paint_chan: OptionalIpcSender<LayoutToPaintMsg>, pub paint_chan: OptionalIpcSender<LayoutToPaintMsg>,
@ -228,7 +228,7 @@ impl LayoutTaskFactory for LayoutTask {
pipeline_port: IpcReceiver<LayoutControlMsg>, pipeline_port: IpcReceiver<LayoutControlMsg>,
constellation_chan: ConstellationChan, constellation_chan: ConstellationChan,
failure_msg: Failure, failure_msg: Failure,
script_chan: ScriptControlChan, script_chan: Sender<ConstellationControlMsg>,
paint_chan: OptionalIpcSender<LayoutToPaintMsg>, paint_chan: OptionalIpcSender<LayoutToPaintMsg>,
image_cache_task: ImageCacheTask, image_cache_task: ImageCacheTask,
font_cache_task: FontCacheTask, font_cache_task: FontCacheTask,
@ -311,7 +311,7 @@ impl LayoutTask {
chan: LayoutChan, chan: LayoutChan,
pipeline_port: IpcReceiver<LayoutControlMsg>, pipeline_port: IpcReceiver<LayoutControlMsg>,
constellation_chan: ConstellationChan, constellation_chan: ConstellationChan,
script_chan: ScriptControlChan, script_chan: Sender<ConstellationControlMsg>,
paint_chan: OptionalIpcSender<LayoutToPaintMsg>, paint_chan: OptionalIpcSender<LayoutToPaintMsg>,
image_cache_task: ImageCacheTask, image_cache_task: ImageCacheTask,
font_cache_task: FontCacheTask, font_cache_task: FontCacheTask,
@ -645,7 +645,7 @@ impl LayoutTask {
info.pipeline_port, info.pipeline_port,
info.constellation_chan, info.constellation_chan,
info.failure, info.failure,
ScriptControlChan(info.script_chan.clone()), info.script_chan.clone(),
*info.paint_chan *info.paint_chan
.downcast::<OptionalIpcSender<LayoutToPaintMsg>>() .downcast::<OptionalIpcSender<LayoutToPaintMsg>>()
.unwrap(), .unwrap(),
@ -726,8 +726,7 @@ impl LayoutTask {
Origin::Author); Origin::Author);
//TODO: mark critical subresources as blocking load as well (#5974) //TODO: mark critical subresources as blocking load as well (#5974)
let ScriptControlChan(ref chan) = self.script_chan; self.script_chan.send(ConstellationControlMsg::StylesheetLoadComplete(self.id, url, responder)).unwrap();
chan.send(ConstellationControlMsg::StylesheetLoadComplete(self.id, url, responder)).unwrap();
self.handle_add_stylesheet(sheet, mq, possibly_locked_rw_data); self.handle_add_stylesheet(sheet, mq, possibly_locked_rw_data);
} }
@ -1197,8 +1196,7 @@ impl LayoutTask {
// FIXME(pcwalton): This should probably be *one* channel, but we can't fix this without // FIXME(pcwalton): This should probably be *one* channel, but we can't fix this without
// either select or a filtered recv() that only looks for messages of a given type. // either select or a filtered recv() that only looks for messages of a given type.
data.script_join_chan.send(()).unwrap(); data.script_join_chan.send(()).unwrap();
let ScriptControlChan(ref chan) = data.script_chan; data.script_chan.send(ConstellationControlMsg::ReflowComplete(self.id, data.id)).unwrap();
chan.send(ConstellationControlMsg::ReflowComplete(self.id, data.id)).unwrap();
} }
fn set_visible_rects<'a>(&'a self, fn set_visible_rects<'a>(&'a self,

View file

@ -28,7 +28,7 @@ use msg::constellation_msg::{ConstellationChan, Failure, PipelineId};
use profile_traits::mem; use profile_traits::mem;
use profile_traits::time; use profile_traits::time;
use net_traits::image_cache_task::ImageCacheTask; use net_traits::image_cache_task::ImageCacheTask;
use script_traits::{LayoutControlMsg, ScriptControlChan, OpaqueScriptLayoutChannel}; use script_traits::{LayoutControlMsg, ConstellationControlMsg, OpaqueScriptLayoutChannel};
use std::sync::mpsc::Sender; use std::sync::mpsc::Sender;
use url::Url; use url::Url;
use util::ipc::OptionalIpcSender; use util::ipc::OptionalIpcSender;
@ -49,7 +49,7 @@ pub trait LayoutTaskFactory {
pipeline_port: IpcReceiver<LayoutControlMsg>, pipeline_port: IpcReceiver<LayoutControlMsg>,
constellation_chan: ConstellationChan, constellation_chan: ConstellationChan,
failure_msg: Failure, failure_msg: Failure,
script_chan: ScriptControlChan, script_chan: Sender<ConstellationControlMsg>,
layout_to_paint_chan: OptionalIpcSender<LayoutToPaintMsg>, layout_to_paint_chan: OptionalIpcSender<LayoutToPaintMsg>,
image_cache_task: ImageCacheTask, image_cache_task: ImageCacheTask,
font_cache_task: FontCacheTask, font_cache_task: FontCacheTask,

View file

@ -55,7 +55,6 @@ use libc;
use msg::constellation_msg::{PipelineId, SubpageId, WindowSizeData, WorkerId}; use msg::constellation_msg::{PipelineId, SubpageId, WindowSizeData, WorkerId};
use net_traits::image_cache_task::{ImageCacheChan, ImageCacheTask}; use net_traits::image_cache_task::{ImageCacheChan, ImageCacheTask};
use net_traits::storage_task::StorageType; use net_traits::storage_task::StorageType;
use script_traits::ScriptControlChan;
use script_traits::UntrustedNodeAddress; use script_traits::UntrustedNodeAddress;
use serde::{Serialize, Deserialize}; use serde::{Serialize, Deserialize};
use smallvec::SmallVec; use smallvec::SmallVec;
@ -280,7 +279,7 @@ no_jsmanaged_fields!(Receiver<T>);
no_jsmanaged_fields!(Rect<T>); no_jsmanaged_fields!(Rect<T>);
no_jsmanaged_fields!(Size2D<T>); no_jsmanaged_fields!(Size2D<T>);
no_jsmanaged_fields!(Arc<T>); no_jsmanaged_fields!(Arc<T>);
no_jsmanaged_fields!(Image, ImageCacheChan, ImageCacheTask, ScriptControlChan); no_jsmanaged_fields!(Image, ImageCacheChan, ImageCacheTask);
no_jsmanaged_fields!(Atom, Namespace); no_jsmanaged_fields!(Atom, Namespace);
no_jsmanaged_fields!(Trusted<T>); no_jsmanaged_fields!(Trusted<T>);
no_jsmanaged_fields!(PropertyDeclarationBlock); no_jsmanaged_fields!(PropertyDeclarationBlock);

View file

@ -36,7 +36,7 @@ use layout_interface::{ContentBoxResponse, ContentBoxesResponse, ResolvedStyleRe
use page::Page; use page::Page;
use script_task::{TimerSource, ScriptChan, ScriptPort, NonWorkerScriptChan}; use script_task::{TimerSource, ScriptChan, ScriptPort, NonWorkerScriptChan};
use script_task::ScriptMsg; use script_task::ScriptMsg;
use script_traits::ScriptControlChan; use script_traits::ConstellationControlMsg;
use timers::{IsInterval, TimerId, TimerManager, TimerCallback}; use timers::{IsInterval, TimerId, TimerManager, TimerCallback};
use webdriver_handlers::jsval_to_webdriver; use webdriver_handlers::jsval_to_webdriver;
@ -77,7 +77,7 @@ use std::mem as std_mem;
use std::rc::Rc; use std::rc::Rc;
use std::sync::Arc; use std::sync::Arc;
use std::sync::mpsc::TryRecvError::{Empty, Disconnected}; use std::sync::mpsc::TryRecvError::{Empty, Disconnected};
use std::sync::mpsc::{channel, Receiver}; use std::sync::mpsc::{channel, Receiver, Sender};
use time; use time;
/// Current state of the window object /// Current state of the window object
@ -112,7 +112,7 @@ pub struct Window {
#[ignore_heap_size_of = "trait objects are hard"] #[ignore_heap_size_of = "trait objects are hard"]
script_chan: Box<ScriptChan+Send>, script_chan: Box<ScriptChan+Send>,
#[ignore_heap_size_of = "channels are hard"] #[ignore_heap_size_of = "channels are hard"]
control_chan: ScriptControlChan, control_chan: Sender<ConstellationControlMsg>,
console: MutNullableHeap<JS<Console>>, console: MutNullableHeap<JS<Console>>,
crypto: MutNullableHeap<JS<Crypto>>, crypto: MutNullableHeap<JS<Crypto>>,
navigator: MutNullableHeap<JS<Navigator>>, navigator: MutNullableHeap<JS<Navigator>>,
@ -264,10 +264,6 @@ impl Window {
(box NonWorkerScriptChan(tx), box rx) (box NonWorkerScriptChan(tx), box rx)
} }
pub fn control_chan<'a>(&'a self) -> &'a ScriptControlChan {
&self.control_chan
}
pub fn image_cache_task<'a>(&'a self) -> &'a ImageCacheTask { pub fn image_cache_task<'a>(&'a self) -> &'a ImageCacheTask {
&self.image_cache_task &self.image_cache_task
} }
@ -1077,7 +1073,7 @@ impl Window {
page: Rc<Page>, page: Rc<Page>,
script_chan: Box<ScriptChan+Send>, script_chan: Box<ScriptChan+Send>,
image_cache_chan: ImageCacheChan, image_cache_chan: ImageCacheChan,
control_chan: ScriptControlChan, control_chan: Sender<ConstellationControlMsg>,
compositor: ScriptListener, compositor: ScriptListener,
image_cache_task: ImageCacheTask, image_cache_task: ImageCacheTask,
resource_task: Arc<ResourceTask>, resource_task: Arc<ResourceTask>,

View file

@ -19,7 +19,7 @@ use msg::compositor_msg::Epoch;
use net_traits::image_cache_task::ImageCacheTask; use net_traits::image_cache_task::ImageCacheTask;
use net_traits::PendingAsyncLoad; use net_traits::PendingAsyncLoad;
use profile_traits::mem::ReportsChan; use profile_traits::mem::ReportsChan;
use script_traits::{ConstellationControlMsg, LayoutControlMsg, ScriptControlChan}; use script_traits::{ConstellationControlMsg, LayoutControlMsg};
use script_traits::{OpaqueScriptLayoutChannel, StylesheetLoadResponder, UntrustedNodeAddress}; use script_traits::{OpaqueScriptLayoutChannel, StylesheetLoadResponder, UntrustedNodeAddress};
use selectors::parser::PseudoElement; use selectors::parser::PseudoElement;
use std::any::Any; use std::any::Any;
@ -167,7 +167,7 @@ pub struct ScriptReflow {
/// The document node. /// The document node.
pub document_root: TrustedNodeAddress, pub document_root: TrustedNodeAddress,
/// The channel through which messages can be sent back to the script task. /// The channel through which messages can be sent back to the script task.
pub script_chan: ScriptControlChan, pub script_chan: Sender<ConstellationControlMsg>,
/// The current window size. /// The current window size.
pub window_size: WindowSizeData, pub window_size: WindowSizeData,
/// The channel that we send a notification to. /// The channel that we send a notification to.

View file

@ -60,7 +60,7 @@ use script_traits::CompositorEvent::{MouseDownEvent, MouseUpEvent};
use script_traits::CompositorEvent::{MouseMoveEvent, KeyEvent}; use script_traits::CompositorEvent::{MouseMoveEvent, KeyEvent};
use script_traits::CompositorEvent::{ResizeEvent, ClickEvent}; use script_traits::CompositorEvent::{ResizeEvent, ClickEvent};
use script_traits::{CompositorEvent, MouseButton}; use script_traits::{CompositorEvent, MouseButton};
use script_traits::{ConstellationControlMsg, ScriptControlChan}; use script_traits::ConstellationControlMsg;
use script_traits::{NewLayoutInfo, OpaqueScriptLayoutChannel}; use script_traits::{NewLayoutInfo, OpaqueScriptLayoutChannel};
use script_traits::{ScriptState, ScriptTaskFactory}; use script_traits::{ScriptState, ScriptTaskFactory};
use msg::compositor_msg::{LayerId, ScriptListener}; use msg::compositor_msg::{LayerId, ScriptListener};
@ -311,7 +311,7 @@ pub struct ScriptTask {
chan: NonWorkerScriptChan, chan: NonWorkerScriptChan,
/// A channel to hand out to tasks that need to respond to a message from the script task. /// A channel to hand out to tasks that need to respond to a message from the script task.
control_chan: ScriptControlChan, control_chan: Sender<ConstellationControlMsg>,
/// The port on which the constellation and layout tasks can communicate with the /// The port on which the constellation and layout tasks can communicate with the
/// script task. /// script task.
@ -405,7 +405,7 @@ impl ScriptTaskFactory for ScriptTask {
parent_info: Option<(PipelineId, SubpageId)>, parent_info: Option<(PipelineId, SubpageId)>,
compositor: ScriptListener, compositor: ScriptListener,
layout_chan: &OpaqueScriptLayoutChannel, layout_chan: &OpaqueScriptLayoutChannel,
control_chan: ScriptControlChan, control_chan: Sender<ConstellationControlMsg>,
control_port: Receiver<ConstellationControlMsg>, control_port: Receiver<ConstellationControlMsg>,
constellation_chan: ConstellationChan, constellation_chan: ConstellationChan,
failure_msg: Failure, failure_msg: Failure,
@ -542,7 +542,7 @@ impl ScriptTask {
pub fn new(compositor: ScriptListener, pub fn new(compositor: ScriptListener,
port: Receiver<ScriptMsg>, port: Receiver<ScriptMsg>,
chan: NonWorkerScriptChan, chan: NonWorkerScriptChan,
control_chan: ScriptControlChan, control_chan: Sender<ConstellationControlMsg>,
control_port: Receiver<ConstellationControlMsg>, control_port: Receiver<ConstellationControlMsg>,
constellation_chan: ConstellationChan, constellation_chan: ConstellationChan,
resource_task: Arc<ResourceTask>, resource_task: Arc<ResourceTask>,
@ -1053,7 +1053,7 @@ impl ScriptTask {
constellation_chan: self.constellation_chan.clone(), constellation_chan: self.constellation_chan.clone(),
failure: failure, failure: failure,
paint_chan: paint_chan, paint_chan: paint_chan,
script_chan: self.control_chan.0.clone(), script_chan: self.control_chan.clone(),
image_cache_task: self.image_cache_task.clone(), image_cache_task: self.image_cache_task.clone(),
layout_shutdown_chan: layout_shutdown_chan, layout_shutdown_chan: layout_shutdown_chan,
}; };

View file

@ -172,10 +172,6 @@ pub enum CompositorEvent {
/// crates that don't need to know about them. /// crates that don't need to know about them.
pub struct OpaqueScriptLayoutChannel(pub (Box<Any+Send>, Box<Any+Send>)); pub struct OpaqueScriptLayoutChannel(pub (Box<Any+Send>, Box<Any+Send>));
/// Encapsulates external communication with the script task.
#[derive(Clone)]
pub struct ScriptControlChan(pub Sender<ConstellationControlMsg>);
/// This trait allows creating a `ScriptTask` without depending on the `script` /// This trait allows creating a `ScriptTask` without depending on the `script`
/// crate. /// crate.
pub trait ScriptTaskFactory { pub trait ScriptTaskFactory {
@ -185,7 +181,7 @@ pub trait ScriptTaskFactory {
parent_info: Option<(PipelineId, SubpageId)>, parent_info: Option<(PipelineId, SubpageId)>,
compositor: ScriptListener, compositor: ScriptListener,
layout_chan: &OpaqueScriptLayoutChannel, layout_chan: &OpaqueScriptLayoutChannel,
control_chan: ScriptControlChan, control_chan: Sender<ConstellationControlMsg>,
control_port: Receiver<ConstellationControlMsg>, control_port: Receiver<ConstellationControlMsg>,
constellation_msg: ConstellationChan, constellation_msg: ConstellationChan,
failure_msg: Failure, failure_msg: Failure,