Split ConstellationMsg into ScriptMsg and CompositorMsg

This commit is contained in:
Keith Yeung 2015-11-14 16:01:34 -08:00
parent afe03870ce
commit 19294db6e5
29 changed files with 259 additions and 210 deletions

View file

@ -28,7 +28,7 @@ use layers::scene::Scene;
use layout_traits::LayoutControlChan; use layout_traits::LayoutControlChan;
use msg::compositor_msg::{Epoch, EventResult, FrameTreeId, LayerId, LayerKind}; use msg::compositor_msg::{Epoch, EventResult, FrameTreeId, LayerId, LayerKind};
use msg::compositor_msg::{LayerProperties, ScrollPolicy}; use msg::compositor_msg::{LayerProperties, ScrollPolicy};
use msg::constellation_msg::Msg as ConstellationMsg; use msg::constellation_msg::CompositorMsg as ConstellationMsg;
use msg::constellation_msg::{AnimationState, Image, PixelFormat}; use msg::constellation_msg::{AnimationState, Image, PixelFormat};
use msg::constellation_msg::{ConstellationChan, Key, KeyModifiers, KeyState, LoadData}; use msg::constellation_msg::{ConstellationChan, Key, KeyModifiers, KeyState, LoadData};
use msg::constellation_msg::{NavigationDirection, PipelineId, WindowSizeData}; use msg::constellation_msg::{NavigationDirection, PipelineId, WindowSizeData};
@ -168,7 +168,7 @@ pub struct IOCompositor<Window: WindowMethods> {
frame_tree_id: FrameTreeId, frame_tree_id: FrameTreeId,
/// The channel on which messages can be sent to the constellation. /// The channel on which messages can be sent to the constellation.
constellation_chan: ConstellationChan, constellation_chan: ConstellationChan<ConstellationMsg>,
/// The channel on which messages can be sent to the time profiler. /// The channel on which messages can be sent to the time profiler.
time_profiler_chan: time::ProfilerChan, time_profiler_chan: time::ProfilerChan,
@ -703,7 +703,7 @@ impl<Window: WindowMethods> IOCompositor<Window> {
fn set_frame_tree(&mut self, fn set_frame_tree(&mut self,
frame_tree: &SendableFrameTree, frame_tree: &SendableFrameTree,
response_chan: Sender<()>, response_chan: Sender<()>,
new_constellation_chan: ConstellationChan) { new_constellation_chan: ConstellationChan<ConstellationMsg>) {
response_chan.send(()).unwrap(); response_chan.send(()).unwrap();
// There are now no more pending iframes. // There are now no more pending iframes.

View file

@ -12,6 +12,7 @@ use layers::layers::{BufferRequest, LayerBufferSet};
use layers::platform::surface::{NativeDisplay, NativeSurface}; use layers::platform::surface::{NativeDisplay, NativeSurface};
use msg::compositor_msg::{Epoch, EventResult, FrameTreeId, LayerId, LayerProperties}; use msg::compositor_msg::{Epoch, EventResult, FrameTreeId, LayerId, LayerProperties};
use msg::compositor_msg::{PaintListener, ScriptToCompositorMsg}; use msg::compositor_msg::{PaintListener, ScriptToCompositorMsg};
use msg::constellation_msg::CompositorMsg as ConstellationMsg;
use msg::constellation_msg::{AnimationState, ConstellationChan, PipelineId}; use msg::constellation_msg::{AnimationState, ConstellationChan, PipelineId};
use msg::constellation_msg::{Image, Key, KeyModifiers, KeyState}; use msg::constellation_msg::{Image, Key, KeyModifiers, KeyState};
use profile_traits::mem; use profile_traits::mem;
@ -179,7 +180,7 @@ pub enum Msg {
/// Alerts the compositor that the given pipeline has changed whether it is running animations. /// Alerts the compositor that the given pipeline has changed whether it is running animations.
ChangeRunningAnimationsState(PipelineId, AnimationState), ChangeRunningAnimationsState(PipelineId, AnimationState),
/// Replaces the current frame tree, typically called during main frame navigation. /// Replaces the current frame tree, typically called during main frame navigation.
SetFrameTree(SendableFrameTree, Sender<()>, ConstellationChan), SetFrameTree(SendableFrameTree, Sender<()>, ConstellationChan<ConstellationMsg>),
/// The load of a page has begun: (can go back, can go forward). /// The load of a page has begun: (can go back, can go forward).
LoadStart(bool, bool), LoadStart(bool, bool),
/// The load of a page has completed: (can go back, can go forward). /// The load of a page has completed: (can go back, can go forward).
@ -295,7 +296,7 @@ pub struct InitialCompositorState {
/// A port on which messages inbound to the compositor can be received. /// A port on which messages inbound to the compositor can be received.
pub receiver: Box<CompositorReceiver>, pub receiver: Box<CompositorReceiver>,
/// A channel to the constellation. /// A channel to the constellation.
pub constellation_chan: ConstellationChan, pub constellation_chan: ConstellationChan<ConstellationMsg>,
/// A channel to the time profiler thread. /// A channel to the time profiler thread.
pub time_profiler_chan: time::ProfilerChan, pub time_profiler_chan: time::ProfilerChan,
/// A channel to the memory profiler thread. /// A channel to the memory profiler thread.

View file

@ -14,7 +14,7 @@ use canvas::webgl_paint_task::WebGLPaintTask;
use canvas_traits::CanvasMsg; use canvas_traits::CanvasMsg;
use clipboard::ClipboardContext; use clipboard::ClipboardContext;
use compositor_task::CompositorProxy; use compositor_task::CompositorProxy;
use compositor_task::Msg as CompositorMsg; use compositor_task::Msg as ToCompositorMsg;
use devtools_traits::{ChromeToDevtoolsControlMsg, DevtoolsControlMsg}; use devtools_traits::{ChromeToDevtoolsControlMsg, DevtoolsControlMsg};
use euclid::scale_factor::ScaleFactor; use euclid::scale_factor::ScaleFactor;
use euclid::size::{Size2D, TypedSize2D}; use euclid::size::{Size2D, TypedSize2D};
@ -23,7 +23,8 @@ use ipc_channel::ipc::{self, IpcSender};
use layout_traits::{LayoutControlChan, LayoutTaskFactory}; use layout_traits::{LayoutControlChan, LayoutTaskFactory};
use msg::compositor_msg::Epoch; use msg::compositor_msg::Epoch;
use msg::constellation_msg::AnimationState; use msg::constellation_msg::AnimationState;
use msg::constellation_msg::Msg as ConstellationMsg; use msg::constellation_msg::CompositorMsg as FromCompositorMsg;
use msg::constellation_msg::ScriptMsg as FromScriptMsg;
use msg::constellation_msg::WebDriverCommandMsg; use msg::constellation_msg::WebDriverCommandMsg;
use msg::constellation_msg::{FrameId, PipelineId}; use msg::constellation_msg::{FrameId, PipelineId};
use msg::constellation_msg::{IframeLoadInfo, IFrameSandboxState, MozBrowserEvent, NavigationDirection}; use msg::constellation_msg::{IframeLoadInfo, IFrameSandboxState, MozBrowserEvent, NavigationDirection};
@ -75,16 +76,16 @@ enum ReadyToSave {
/// the `script` crate). /// the `script` crate).
pub struct Constellation<LTF, STF> { pub struct Constellation<LTF, STF> {
/// A channel through which script messages can be sent to this object. /// A channel through which script messages can be sent to this object.
pub script_sender: ConstellationChan, pub script_sender: ConstellationChan<FromScriptMsg>,
/// A channel through which compositor messages can be sent to this object. /// A channel through which compositor messages can be sent to this object.
pub compositor_sender: ConstellationChan, pub compositor_sender: ConstellationChan<FromCompositorMsg>,
/// Receives messages from scripts. /// Receives messages from scripts.
pub script_receiver: Receiver<ConstellationMsg>, pub script_receiver: Receiver<FromScriptMsg>,
/// Receives messages from the compositor /// Receives messages from the compositor
pub compositor_receiver: Receiver<ConstellationMsg>, pub compositor_receiver: Receiver<FromCompositorMsg>,
/// A channel (the implementation of which is port-specific) through which messages can be sent /// A channel (the implementation of which is port-specific) through which messages can be sent
/// to the compositor. /// to the compositor.
@ -259,14 +260,13 @@ enum ExitPipelineMode {
} }
impl<LTF: LayoutTaskFactory, STF: ScriptTaskFactory> Constellation<LTF, STF> { impl<LTF: LayoutTaskFactory, STF: ScriptTaskFactory> Constellation<LTF, STF> {
pub fn start(state: InitialConstellationState) -> ConstellationChan { pub fn start(state: InitialConstellationState) -> ConstellationChan<FromCompositorMsg> {
let (script_receiver, script_sender) = ConstellationChan::new(); let (script_receiver, script_sender) = ConstellationChan::<FromScriptMsg>::new();
let (compositor_receiver, compositor_sender) = ConstellationChan::new(); let (compositor_receiver, compositor_sender) = ConstellationChan::<FromCompositorMsg>::new();
let script_sender_clone = script_sender.clone();
let compositor_sender_clone = compositor_sender.clone(); let compositor_sender_clone = compositor_sender.clone();
spawn_named("Constellation".to_owned(), move || { spawn_named("Constellation".to_owned(), move || {
let mut constellation: Constellation<LTF, STF> = Constellation { let mut constellation: Constellation<LTF, STF> = Constellation {
script_sender: script_sender_clone, script_sender: script_sender,
compositor_sender: compositor_sender_clone, compositor_sender: compositor_sender_clone,
script_receiver: script_receiver, script_receiver: script_receiver,
compositor_receiver: compositor_receiver, compositor_receiver: compositor_receiver,
@ -313,18 +313,9 @@ impl<LTF: LayoutTaskFactory, STF: ScriptTaskFactory> Constellation<LTF, STF> {
compositor_sender compositor_sender
} }
#[allow(unsafe_code)]
fn run(&mut self) { fn run(&mut self) {
loop { loop {
let request = { if !self.handle_request() {
let receiver_from_script = &self.script_receiver;
let receiver_from_compositor = &self.compositor_receiver;
select! {
msg = receiver_from_script.recv() => msg.unwrap(),
msg = receiver_from_compositor.recv() => msg.unwrap()
}
};
if !self.handle_request(request) {
break; break;
} }
} }
@ -420,104 +411,155 @@ impl<LTF: LayoutTaskFactory, STF: ScriptTaskFactory> Constellation<LTF, STF> {
} }
/// Handles loading pages, navigation, and granting access to the compositor /// Handles loading pages, navigation, and granting access to the compositor
fn handle_request(&mut self, request: ConstellationMsg) -> bool { #[allow(unsafe_code)]
fn handle_request(&mut self) -> bool {
enum Request {
Script(FromScriptMsg),
Compositor(FromCompositorMsg)
}
let request = {
let receiver_from_script = &self.script_receiver;
let receiver_from_compositor = &self.compositor_receiver;
select! {
msg = receiver_from_script.recv() =>
Request::Script(msg.unwrap()),
msg = receiver_from_compositor.recv() =>
Request::Compositor(msg.unwrap())
}
};
match request { match request {
ConstellationMsg::Exit => { // Messages from compositor
Request::Compositor(FromCompositorMsg::Exit) => {
debug!("constellation exiting"); debug!("constellation exiting");
self.handle_exit(); self.handle_exit();
return false; return false;
} }
ConstellationMsg::Failure(Failure { pipeline_id, parent_info }) => {
self.handle_failure_msg(pipeline_id, parent_info);
}
// This should only be called once per constellation, and only by the browser
ConstellationMsg::InitLoadUrl(url) => {
debug!("constellation got init load URL message");
self.handle_init_load(url);
}
// The compositor discovered the size of a subframe. This needs to be reflected by all // The compositor discovered the size of a subframe. This needs to be reflected by all
// frame trees in the navigation context containing the subframe. // frame trees in the navigation context containing the subframe.
ConstellationMsg::FrameSize(pipeline_id, size) => { Request::Compositor(FromCompositorMsg::FrameSize(pipeline_id, size)) => {
debug!("constellation got frame size message"); debug!("constellation got frame size message");
self.handle_frame_size_msg(pipeline_id, &Size2D::from_untyped(&size)); self.handle_frame_size_msg(pipeline_id, &Size2D::from_untyped(&size));
} }
ConstellationMsg::ScriptLoadedURLInIFrame(load_info) => { Request::Compositor(FromCompositorMsg::GetFrame(pipeline_id, resp_chan)) => {
debug!("constellation got get root pipeline message");
self.handle_get_frame(pipeline_id, resp_chan);
}
Request::Compositor(FromCompositorMsg::GetPipeline(frame_id, resp_chan)) => {
debug!("constellation got get root pipeline message");
self.handle_get_pipeline(frame_id, resp_chan);
}
Request::Compositor(FromCompositorMsg::GetPipelineTitle(pipeline_id)) => {
debug!("constellation got get-pipeline-title message");
self.handle_get_pipeline_title_msg(pipeline_id);
}
Request::Compositor(FromCompositorMsg::KeyEvent(key, state, modifiers)) => {
debug!("constellation got key event message");
self.handle_key_msg(key, state, modifiers);
}
// Load a new page from a typed url
// If there is already a pending page (self.pending_frames), it will not be overridden;
// However, if the id is not encompassed by another change, it will be.
Request::Compositor(FromCompositorMsg::LoadUrl(source_id, load_data)) => {
debug!("constellation got URL load message from compositor");
self.handle_load_url_msg(source_id, load_data);
}
Request::Compositor(FromCompositorMsg::IsReadyToSaveImage(pipeline_states)) => {
let is_ready = self.handle_is_ready_to_save_image(pipeline_states);
if opts::get().is_running_problem_test {
println!("got ready to save image query, result is {:?}", is_ready);
}
let is_ready = is_ready == ReadyToSave::Ready;
self.compositor_proxy.send(ToCompositorMsg::IsReadyToSaveImageReply(is_ready));
if opts::get().is_running_problem_test {
println!("sent response");
}
}
// This should only be called once per constellation, and only by the browser
Request::Compositor(FromCompositorMsg::InitLoadUrl(url)) => {
debug!("constellation got init load URL message");
self.handle_init_load(url);
}
// Handle a forward or back request
Request::Compositor(FromCompositorMsg::Navigate(pipeline_info, direction)) => {
debug!("constellation got navigation message from compositor");
self.handle_navigate_msg(pipeline_info, direction);
}
Request::Compositor(FromCompositorMsg::ResizedWindow(new_size)) => {
debug!("constellation got window resize message");
self.handle_resized_window_msg(new_size);
}
Request::Compositor(FromCompositorMsg::TickAnimation(pipeline_id)) => {
self.handle_tick_animation(pipeline_id)
}
Request::Compositor(FromCompositorMsg::WebDriverCommand(command)) => {
debug!("constellation got webdriver command message");
self.handle_webdriver_msg(command);
}
// Messages from script
Request::Script(FromScriptMsg::Failure(Failure { pipeline_id, parent_info })) => {
self.handle_failure_msg(pipeline_id, parent_info);
}
Request::Script(FromScriptMsg::ScriptLoadedURLInIFrame(load_info)) => {
debug!("constellation got iframe URL load message {:?} {:?} {:?}", debug!("constellation got iframe URL load message {:?} {:?} {:?}",
load_info.containing_pipeline_id, load_info.containing_pipeline_id,
load_info.old_subpage_id, load_info.old_subpage_id,
load_info.new_subpage_id); load_info.new_subpage_id);
self.handle_script_loaded_url_in_iframe_msg(load_info); self.handle_script_loaded_url_in_iframe_msg(load_info);
} }
ConstellationMsg::SetCursor(cursor) => { Request::Script(FromScriptMsg::SetCursor(cursor)) => {
self.handle_set_cursor_msg(cursor) self.handle_set_cursor_msg(cursor)
} }
ConstellationMsg::ChangeRunningAnimationsState(pipeline_id, animation_state) => { Request::Script(FromScriptMsg::ChangeRunningAnimationsState(pipeline_id, animation_state)) => {
self.handle_change_running_animations_state(pipeline_id, animation_state) self.handle_change_running_animations_state(pipeline_id, animation_state)
} }
ConstellationMsg::TickAnimation(pipeline_id) => { // Load a new page from a mouse click
self.handle_tick_animation(pipeline_id)
}
// Load a new page, usually -- but not always -- from a mouse click or typed url
// If there is already a pending page (self.pending_frames), it will not be overridden; // If there is already a pending page (self.pending_frames), it will not be overridden;
// However, if the id is not encompassed by another change, it will be. // However, if the id is not encompassed by another change, it will be.
ConstellationMsg::LoadUrl(source_id, load_data) => { Request::Script(FromScriptMsg::LoadUrl(source_id, load_data)) => {
debug!("constellation got URL load message"); debug!("constellation got URL load message from script");
self.handle_load_url_msg(source_id, load_data); self.handle_load_url_msg(source_id, load_data);
} }
// A page loaded through one of several methods above has completed all parsing, // A page loaded has completed all parsing, script, and reflow messages have been sent.
// script, and reflow messages have been sent. Request::Script(FromScriptMsg::LoadComplete(pipeline_id)) => {
ConstellationMsg::LoadComplete(pipeline_id) => {
debug!("constellation got load complete message"); debug!("constellation got load complete message");
self.handle_load_complete_msg(&pipeline_id) self.handle_load_complete_msg(&pipeline_id)
} }
// The DOM load event fired on a document // The DOM load event fired on a document
ConstellationMsg::DOMLoad(pipeline_id) => { Request::Script(FromScriptMsg::DOMLoad(pipeline_id)) => {
debug!("constellation got dom load message"); debug!("constellation got dom load message");
self.handle_dom_load(pipeline_id) self.handle_dom_load(pipeline_id)
} }
// Handle a forward or back request // Handle a forward or back request
ConstellationMsg::Navigate(pipeline_info, direction) => { Request::Script(FromScriptMsg::Navigate(pipeline_info, direction)) => {
debug!("constellation got navigation message"); debug!("constellation got navigation message from script");
self.handle_navigate_msg(pipeline_info, direction); self.handle_navigate_msg(pipeline_info, direction);
} }
// Notification that painting has finished and is requesting permission to paint. // Notification that painting has finished and is requesting permission to paint.
ConstellationMsg::PainterReady(pipeline_id) => { Request::Script(FromScriptMsg::PainterReady(pipeline_id)) => {
debug!("constellation got painter ready message"); debug!("constellation got painter ready message");
self.handle_painter_ready_msg(pipeline_id); self.handle_painter_ready_msg(pipeline_id);
} }
ConstellationMsg::ResizedWindow(new_size) => { Request::Script(FromScriptMsg::MozBrowserEvent(pipeline_id,
debug!("constellation got window resize message");
self.handle_resized_window_msg(new_size);
}
ConstellationMsg::KeyEvent(key, state, modifiers) => {
debug!("constellation got key event message");
self.handle_key_msg(key, state, modifiers);
}
ConstellationMsg::GetPipelineTitle(pipeline_id) => {
debug!("constellation got get-pipeline-title message");
self.handle_get_pipeline_title_msg(pipeline_id);
}
ConstellationMsg::MozBrowserEvent(pipeline_id,
subpage_id, subpage_id,
event) => { event)) => {
debug!("constellation got mozbrowser event message"); debug!("constellation got mozbrowser event message");
self.handle_mozbrowser_event_msg(pipeline_id, self.handle_mozbrowser_event_msg(pipeline_id,
subpage_id, subpage_id,
event); event);
} }
ConstellationMsg::GetPipeline(frame_id, resp_chan) => { Request::Script(FromScriptMsg::Focus(pipeline_id)) => {
debug!("constellation got get root pipeline message");
self.handle_get_pipeline(frame_id, resp_chan);
}
ConstellationMsg::GetFrame(pipeline_id, resp_chan) => {
debug!("constellation got get root pipeline message");
self.handle_get_frame(pipeline_id, resp_chan);
}
ConstellationMsg::Focus(pipeline_id) => {
debug!("constellation got focus message"); debug!("constellation got focus message");
self.handle_focus_msg(pipeline_id); self.handle_focus_msg(pipeline_id);
} }
ConstellationMsg::GetClipboardContents(sender) => { Request::Script(FromScriptMsg::GetClipboardContents(sender)) => {
let result = self.clipboard_ctx.as_ref().map_or( let result = self.clipboard_ctx.as_ref().map_or(
"".to_owned(), "".to_owned(),
|ctx| ctx.get_contents().unwrap_or_else(|e| { |ctx| ctx.get_contents().unwrap_or_else(|e| {
@ -527,55 +569,40 @@ impl<LTF: LayoutTaskFactory, STF: ScriptTaskFactory> Constellation<LTF, STF> {
); );
sender.send(result).unwrap(); sender.send(result).unwrap();
} }
ConstellationMsg::SetClipboardContents(s) => { Request::Script(FromScriptMsg::SetClipboardContents(s)) => {
if let Some(ref mut ctx) = self.clipboard_ctx { if let Some(ref mut ctx) = self.clipboard_ctx {
if let Err(e) = ctx.set_contents(s) { if let Err(e) = ctx.set_contents(s) {
debug!("Error setting clipboard contents ({})", e); debug!("Error setting clipboard contents ({})", e);
} }
} }
} }
ConstellationMsg::WebDriverCommand(command) => { Request::Script(FromScriptMsg::ViewportConstrained(pipeline_id, constraints)) => {
debug!("constellation got webdriver command message");
self.handle_webdriver_msg(command);
}
ConstellationMsg::ViewportConstrained(pipeline_id, constraints) => {
debug!("constellation got viewport-constrained event message"); debug!("constellation got viewport-constrained event message");
self.handle_viewport_constrained_msg(pipeline_id, constraints); self.handle_viewport_constrained_msg(pipeline_id, constraints);
} }
ConstellationMsg::IsReadyToSaveImage(pipeline_states) => { Request::Script(FromScriptMsg::RemoveIFrame(pipeline_id)) => {
let is_ready = self.handle_is_ready_to_save_image(pipeline_states);
if opts::get().is_running_problem_test {
println!("got ready to save image query, result is {:?}", is_ready);
}
let is_ready = is_ready == ReadyToSave::Ready;
self.compositor_proxy.send(CompositorMsg::IsReadyToSaveImageReply(is_ready));
if opts::get().is_running_problem_test {
println!("sent response");
}
}
ConstellationMsg::RemoveIFrame(pipeline_id) => {
debug!("constellation got remove iframe message"); debug!("constellation got remove iframe message");
self.handle_remove_iframe_msg(pipeline_id); self.handle_remove_iframe_msg(pipeline_id);
} }
ConstellationMsg::NewFavicon(url) => { Request::Script(FromScriptMsg::NewFavicon(url)) => {
debug!("constellation got new favicon message"); debug!("constellation got new favicon message");
self.compositor_proxy.send(CompositorMsg::NewFavicon(url)); self.compositor_proxy.send(ToCompositorMsg::NewFavicon(url));
} }
ConstellationMsg::HeadParsed => { Request::Script(FromScriptMsg::HeadParsed) => {
debug!("constellation got head parsed message"); debug!("constellation got head parsed message");
self.compositor_proxy.send(CompositorMsg::HeadParsed); self.compositor_proxy.send(ToCompositorMsg::HeadParsed);
} }
ConstellationMsg::CreateCanvasPaintTask(size, sender) => { Request::Script(FromScriptMsg::CreateCanvasPaintTask(size, sender)) => {
debug!("constellation got create-canvas-paint-task message"); debug!("constellation got create-canvas-paint-task message");
self.handle_create_canvas_paint_task_msg(&size, sender) self.handle_create_canvas_paint_task_msg(&size, sender)
} }
ConstellationMsg::CreateWebGLPaintTask(size, attributes, sender) => { Request::Script(FromScriptMsg::CreateWebGLPaintTask(size, attributes, sender)) => {
debug!("constellation got create-WebGL-paint-task message"); debug!("constellation got create-WebGL-paint-task message");
self.handle_create_webgl_paint_task_msg(&size, attributes, sender) self.handle_create_webgl_paint_task_msg(&size, attributes, sender)
} }
ConstellationMsg::NodeStatus(message) => { Request::Script(FromScriptMsg::NodeStatus(message)) => {
debug!("constellation got NodeStatus message"); debug!("constellation got NodeStatus message");
self.compositor_proxy.send(CompositorMsg::Status(message)); self.compositor_proxy.send(ToCompositorMsg::Status(message));
} }
} }
true true
@ -593,7 +620,7 @@ impl<LTF: LayoutTaskFactory, STF: ScriptTaskFactory> Constellation<LTF, STF> {
}); });
self.storage_task.send(StorageTaskMsg::Exit).unwrap(); self.storage_task.send(StorageTaskMsg::Exit).unwrap();
self.font_cache_task.exit(); self.font_cache_task.exit();
self.compositor_proxy.send(CompositorMsg::ShutdownComplete); self.compositor_proxy.send(ToCompositorMsg::ShutdownComplete);
} }
fn handle_failure_msg(&mut self, fn handle_failure_msg(&mut self,
@ -643,7 +670,7 @@ impl<LTF: LayoutTaskFactory, STF: ScriptTaskFactory> Constellation<LTF, STF> {
self.new_pipeline(root_pipeline_id, None, Some(window_size), None, LoadData::new(url.clone())); self.new_pipeline(root_pipeline_id, None, Some(window_size), None, LoadData::new(url.clone()));
self.handle_load_start_msg(&root_pipeline_id); self.handle_load_start_msg(&root_pipeline_id);
self.push_pending_frame(root_pipeline_id, None); self.push_pending_frame(root_pipeline_id, None);
self.compositor_proxy.send(CompositorMsg::ChangePageUrl(root_pipeline_id, url)); self.compositor_proxy.send(ToCompositorMsg::ChangePageUrl(root_pipeline_id, url));
} }
fn handle_frame_size_msg(&mut self, fn handle_frame_size_msg(&mut self,
@ -719,13 +746,13 @@ impl<LTF: LayoutTaskFactory, STF: ScriptTaskFactory> Constellation<LTF, STF> {
} }
fn handle_set_cursor_msg(&mut self, cursor: Cursor) { fn handle_set_cursor_msg(&mut self, cursor: Cursor) {
self.compositor_proxy.send(CompositorMsg::SetCursor(cursor)) self.compositor_proxy.send(ToCompositorMsg::SetCursor(cursor))
} }
fn handle_change_running_animations_state(&mut self, fn handle_change_running_animations_state(&mut self,
pipeline_id: PipelineId, pipeline_id: PipelineId,
animation_state: AnimationState) { animation_state: AnimationState) {
self.compositor_proxy.send(CompositorMsg::ChangeRunningAnimationsState(pipeline_id, self.compositor_proxy.send(ToCompositorMsg::ChangeRunningAnimationsState(pipeline_id,
animation_state)) animation_state))
} }
@ -789,7 +816,7 @@ impl<LTF: LayoutTaskFactory, STF: ScriptTaskFactory> Constellation<LTF, STF> {
if let Some(id) = self.pipeline_to_frame_map.get(pipeline_id) { if let Some(id) = self.pipeline_to_frame_map.get(pipeline_id) {
let forward = !self.frame(*id).next.is_empty(); let forward = !self.frame(*id).next.is_empty();
let back = !self.frame(*id).prev.is_empty(); let back = !self.frame(*id).prev.is_empty();
self.compositor_proxy.send(CompositorMsg::LoadStart(back, forward)); self.compositor_proxy.send(ToCompositorMsg::LoadStart(back, forward));
} }
} }
@ -804,7 +831,7 @@ impl<LTF: LayoutTaskFactory, STF: ScriptTaskFactory> Constellation<LTF, STF> {
let forward = !self.frame(frame_id).next.is_empty(); let forward = !self.frame(frame_id).next.is_empty();
let back = !self.frame(frame_id).prev.is_empty(); let back = !self.frame(frame_id).prev.is_empty();
self.compositor_proxy.send(CompositorMsg::LoadComplete(back, forward)); self.compositor_proxy.send(ToCompositorMsg::LoadComplete(back, forward));
} }
fn handle_dom_load(&mut self, fn handle_dom_load(&mut self,
@ -920,7 +947,7 @@ impl<LTF: LayoutTaskFactory, STF: ScriptTaskFactory> Constellation<LTF, STF> {
ConstellationControlMsg::SendEvent(pipeline.id, event)).unwrap(); ConstellationControlMsg::SendEvent(pipeline.id, event)).unwrap();
} }
None => { None => {
let event = CompositorMsg::KeyEvent(key, state, mods); let event = ToCompositorMsg::KeyEvent(key, state, mods);
self.compositor_proxy.clone_compositor_proxy().send(event); self.compositor_proxy.clone_compositor_proxy().send(event);
} }
} }
@ -928,7 +955,7 @@ impl<LTF: LayoutTaskFactory, STF: ScriptTaskFactory> Constellation<LTF, STF> {
fn handle_get_pipeline_title_msg(&mut self, pipeline_id: PipelineId) { fn handle_get_pipeline_title_msg(&mut self, pipeline_id: PipelineId) {
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(ToCompositorMsg::ChangePageTitle(pipeline_id, None)),
Some(pipeline) => { Some(pipeline) => {
pipeline.script_chan.send(ConstellationControlMsg::GetTitle(pipeline_id)).unwrap(); pipeline.script_chan.send(ConstellationControlMsg::GetTitle(pipeline_id)).unwrap();
} }
@ -1062,7 +1089,7 @@ impl<LTF: LayoutTaskFactory, STF: ScriptTaskFactory> Constellation<LTF, STF> {
frame.current frame.current
}); });
if Some(pipeline_id) == current_pipeline_id { if Some(pipeline_id) == current_pipeline_id {
self.compositor_proxy.send(CompositorMsg::CreatePng(reply)); self.compositor_proxy.send(ToCompositorMsg::CreatePng(reply));
} else { } else {
reply.send(None).unwrap(); reply.send(None).unwrap();
} }
@ -1223,7 +1250,7 @@ impl<LTF: LayoutTaskFactory, STF: ScriptTaskFactory> Constellation<LTF, STF> {
fn handle_viewport_constrained_msg(&mut self, fn handle_viewport_constrained_msg(&mut self,
pipeline_id: PipelineId, pipeline_id: PipelineId,
constraints: ViewportConstraints) { constraints: ViewportConstraints) {
self.compositor_proxy.send(CompositorMsg::ViewportConstrained(pipeline_id, constraints)); self.compositor_proxy.send(ToCompositorMsg::ViewportConstrained(pipeline_id, constraints));
} }
/// Checks the state of all script and layout pipelines to see if they are idle /// Checks the state of all script and layout pipelines to see if they are idle
@ -1419,7 +1446,7 @@ impl<LTF: LayoutTaskFactory, STF: ScriptTaskFactory> Constellation<LTF, STF> {
let frame_tree = self.frame_to_sendable(root_frame_id); let frame_tree = self.frame_to_sendable(root_frame_id);
let (chan, port) = channel(); let (chan, port) = channel();
self.compositor_proxy.send(CompositorMsg::SetFrameTree(frame_tree, self.compositor_proxy.send(ToCompositorMsg::SetFrameTree(frame_tree,
chan, chan,
self.compositor_sender.clone())); self.compositor_sender.clone()));
if port.recv().is_err() { if port.recv().is_err() {

View file

@ -7,7 +7,7 @@ use compositor_task::{InitialCompositorState, Msg};
use euclid::scale_factor::ScaleFactor; use euclid::scale_factor::ScaleFactor;
use euclid::{Point2D, Size2D}; use euclid::{Point2D, Size2D};
use msg::constellation_msg::AnimationState; use msg::constellation_msg::AnimationState;
use msg::constellation_msg::Msg as ConstellationMsg; use msg::constellation_msg::CompositorMsg as ConstellationMsg;
use msg::constellation_msg::{ConstellationChan, WindowSizeData}; use msg::constellation_msg::{ConstellationChan, WindowSizeData};
use profile_traits::mem; use profile_traits::mem;
use profile_traits::time; use profile_traits::time;
@ -22,7 +22,7 @@ pub struct NullCompositor {
/// The port on which we receive messages. /// The port on which we receive messages.
pub port: Box<CompositorReceiver>, pub port: Box<CompositorReceiver>,
/// A channel to the constellation. /// A channel to the constellation.
constellation_chan: ConstellationChan, constellation_chan: ConstellationChan<ConstellationMsg>,
/// A channel to the time profiler. /// A channel to the time profiler.
time_profiler_chan: time::ProfilerChan, time_profiler_chan: time::ProfilerChan,
/// A channel to the memory profiler. /// A channel to the memory profiler.

View file

@ -14,6 +14,7 @@ use ipc_channel::ipc::{self, IpcReceiver, IpcSender};
use ipc_channel::router::ROUTER; use ipc_channel::router::ROUTER;
use layers::geometry::DevicePixel; use layers::geometry::DevicePixel;
use layout_traits::{LayoutControlChan, LayoutTaskFactory}; use layout_traits::{LayoutControlChan, LayoutTaskFactory};
use msg::constellation_msg::ScriptMsg as ConstellationMsg;
use msg::constellation_msg::{ConstellationChan, Failure, FrameId, PipelineId, SubpageId}; use msg::constellation_msg::{ConstellationChan, Failure, FrameId, PipelineId, SubpageId};
use msg::constellation_msg::{LoadData, MozBrowserEvent, WindowSizeData}; use msg::constellation_msg::{LoadData, MozBrowserEvent, WindowSizeData};
use msg::constellation_msg::{PipelineNamespaceId}; use msg::constellation_msg::{PipelineNamespaceId};
@ -78,7 +79,7 @@ pub struct InitialPipelineState {
/// If `None`, this is the root. /// If `None`, this is the root.
pub parent_info: Option<(PipelineId, SubpageId)>, pub parent_info: Option<(PipelineId, SubpageId)>,
/// A channel to the associated constellation. /// A channel to the associated constellation.
pub constellation_chan: ConstellationChan, pub constellation_chan: ConstellationChan<ConstellationMsg>,
/// A channel to schedule timer events. /// A channel to schedule timer events.
pub scheduler_chan: IpcSender<TimerEventRequest>, pub scheduler_chan: IpcSender<TimerEventRequest>,
/// A channel to the compositor. /// A channel to the compositor.
@ -317,7 +318,7 @@ impl Pipeline {
pub struct PipelineContent { pub struct PipelineContent {
id: PipelineId, id: PipelineId,
parent_info: Option<(PipelineId, SubpageId)>, parent_info: Option<(PipelineId, SubpageId)>,
constellation_chan: ConstellationChan, constellation_chan: ConstellationChan<ConstellationMsg>,
scheduler_chan: IpcSender<TimerEventRequest>, scheduler_chan: IpcSender<TimerEventRequest>,
compositor_proxy: Box<CompositorProxy + Send + 'static>, compositor_proxy: Box<CompositorProxy + Send + 'static>,
devtools_chan: Option<IpcSender<ScriptToDevtoolsControlMsg>>, devtools_chan: Option<IpcSender<ScriptToDevtoolsControlMsg>>,

View file

@ -21,7 +21,7 @@ use layers::layers::{BufferRequest, LayerBuffer, LayerBufferSet};
use layers::platform::surface::{NativeDisplay, NativeSurface}; use layers::platform::surface::{NativeDisplay, NativeSurface};
use msg::compositor_msg::{Epoch, FrameTreeId, LayerId, LayerKind, LayerProperties}; use msg::compositor_msg::{Epoch, FrameTreeId, LayerId, LayerKind, LayerProperties};
use msg::compositor_msg::{PaintListener, ScrollPolicy}; use msg::compositor_msg::{PaintListener, ScrollPolicy};
use msg::constellation_msg::Msg as ConstellationMsg; use msg::constellation_msg::ScriptMsg as ConstellationMsg;
use msg::constellation_msg::{ConstellationChan, Failure, PipelineId}; use msg::constellation_msg::{ConstellationChan, Failure, PipelineId};
use paint_context::PaintContext; use paint_context::PaintContext;
use profile_traits::mem::{self, ReportsChan}; use profile_traits::mem::{self, ReportsChan};
@ -214,7 +214,7 @@ pub struct PaintTask<C> {
layout_to_paint_port: Receiver<LayoutToPaintMsg>, layout_to_paint_port: Receiver<LayoutToPaintMsg>,
chrome_to_paint_port: Receiver<ChromeToPaintMsg>, chrome_to_paint_port: Receiver<ChromeToPaintMsg>,
compositor: C, compositor: C,
constellation_chan: ConstellationChan, constellation_chan: ConstellationChan<ConstellationMsg>,
/// A channel to the time profiler. /// A channel to the time profiler.
time_profiler_chan: time::ProfilerChan, time_profiler_chan: time::ProfilerChan,
@ -250,7 +250,7 @@ impl<C> PaintTask<C> where C: PaintListener + Send + 'static {
layout_to_paint_port: Receiver<LayoutToPaintMsg>, layout_to_paint_port: Receiver<LayoutToPaintMsg>,
chrome_to_paint_port: Receiver<ChromeToPaintMsg>, chrome_to_paint_port: Receiver<ChromeToPaintMsg>,
compositor: C, compositor: C,
constellation_chan: ConstellationChan, constellation_chan: ConstellationChan<ConstellationMsg>,
font_cache_task: FontCacheTask, font_cache_task: FontCacheTask,
failure_msg: Failure, failure_msg: Failure,
time_profiler_chan: time::ProfilerChan, time_profiler_chan: time::ProfilerChan,
@ -268,7 +268,6 @@ impl<C> PaintTask<C> where C: PaintListener + Send + 'static {
font_cache_task, font_cache_task,
time_profiler_chan.clone()); time_profiler_chan.clone());
// FIXME: rust/#5967
let mut paint_task = PaintTask { let mut paint_task = PaintTask {
id: id, id: id,
_url: url, _url: url,

View file

@ -8,7 +8,8 @@ use clock_ticks;
use flow::{self, Flow}; use flow::{self, Flow};
use gfx::display_list::OpaqueNode; use gfx::display_list::OpaqueNode;
use incremental::{self, RestyleDamage}; use incremental::{self, RestyleDamage};
use msg::constellation_msg::{AnimationState, ConstellationChan, Msg, PipelineId}; use msg::constellation_msg::ScriptMsg as ConstellationMsg;
use msg::constellation_msg::{AnimationState, ConstellationChan, PipelineId};
use script::layout_interface::Animation; use script::layout_interface::Animation;
use std::collections::HashMap; use std::collections::HashMap;
use std::collections::hash_map::Entry; use std::collections::hash_map::Entry;
@ -48,7 +49,7 @@ pub fn start_transitions_if_applicable(new_animations_sender: &Mutex<Sender<Anim
/// Processes any new animations that were discovered after style recalculation. /// Processes any new animations that were discovered after style recalculation.
/// Also expire any old animations that have completed. /// Also expire any old animations that have completed.
pub fn update_animation_state(constellation_chan: &ConstellationChan, pub fn update_animation_state(constellation_chan: &ConstellationChan<ConstellationMsg>,
running_animations: &mut Arc<HashMap<OpaqueNode, Vec<Animation>>>, running_animations: &mut Arc<HashMap<OpaqueNode, Vec<Animation>>>,
new_animations_receiver: &Receiver<Animation>, new_animations_receiver: &Receiver<Animation>,
pipeline_id: PipelineId) { pipeline_id: PipelineId) {
@ -100,7 +101,7 @@ pub fn update_animation_state(constellation_chan: &ConstellationChan,
} }
constellation_chan.0 constellation_chan.0
.send(Msg::ChangeRunningAnimationsState(pipeline_id, animation_state)) .send(ConstellationMsg::ChangeRunningAnimationsState(pipeline_id, animation_state))
.unwrap(); .unwrap();
} }

View file

@ -37,7 +37,7 @@ use layout_debug;
use layout_traits::LayoutTaskFactory; use layout_traits::LayoutTaskFactory;
use log; use log;
use msg::compositor_msg::{Epoch, LayerId, ScrollPolicy}; use msg::compositor_msg::{Epoch, LayerId, ScrollPolicy};
use msg::constellation_msg::Msg as ConstellationMsg; use msg::constellation_msg::ScriptMsg as ConstellationMsg;
use msg::constellation_msg::{ConstellationChan, Failure, PipelineId}; use msg::constellation_msg::{ConstellationChan, Failure, PipelineId};
use net_traits::image_cache_task::{ImageCacheChan, ImageCacheResult, ImageCacheTask}; use net_traits::image_cache_task::{ImageCacheChan, ImageCacheResult, ImageCacheTask};
use opaque_node::OpaqueNodeMethods; use opaque_node::OpaqueNodeMethods;
@ -95,7 +95,7 @@ const DISPLAY_PORT_THRESHOLD_SIZE_FACTOR: i32 = 4;
/// This needs to be protected by a mutex so we can do fast RPCs. /// This needs to be protected by a mutex so we can do fast RPCs.
pub struct LayoutTaskData { pub struct LayoutTaskData {
/// The channel on which messages can be sent to the constellation. /// The channel on which messages can be sent to the constellation.
pub constellation_chan: ConstellationChan, pub constellation_chan: ConstellationChan<ConstellationMsg>,
/// The root stacking context. /// The root stacking context.
pub stacking_context: Option<Arc<StackingContext>>, pub stacking_context: Option<Arc<StackingContext>>,
@ -149,7 +149,7 @@ pub struct LayoutTask {
font_cache_sender: Sender<()>, font_cache_sender: Sender<()>,
/// The channel on which messages can be sent to the constellation. /// The channel on which messages can be sent to the constellation.
constellation_chan: ConstellationChan, constellation_chan: ConstellationChan<ConstellationMsg>,
/// The channel on which messages can be sent to the script task. /// The channel on which messages can be sent to the script task.
script_chan: Sender<ConstellationControlMsg>, script_chan: Sender<ConstellationControlMsg>,
@ -226,7 +226,7 @@ impl LayoutTaskFactory for LayoutTask {
is_iframe: bool, is_iframe: bool,
chan: OpaqueScriptLayoutChannel, chan: OpaqueScriptLayoutChannel,
pipeline_port: IpcReceiver<LayoutControlMsg>, pipeline_port: IpcReceiver<LayoutControlMsg>,
constellation_chan: ConstellationChan, constellation_chan: ConstellationChan<ConstellationMsg>,
failure_msg: Failure, failure_msg: Failure,
script_chan: Sender<ConstellationControlMsg>, script_chan: Sender<ConstellationControlMsg>,
paint_chan: OptionalIpcSender<LayoutToPaintMsg>, paint_chan: OptionalIpcSender<LayoutToPaintMsg>,
@ -354,7 +354,7 @@ impl LayoutTask {
is_iframe: bool, is_iframe: bool,
port: Receiver<Msg>, port: Receiver<Msg>,
pipeline_port: IpcReceiver<LayoutControlMsg>, pipeline_port: IpcReceiver<LayoutControlMsg>,
constellation_chan: ConstellationChan, constellation_chan: ConstellationChan<ConstellationMsg>,
script_chan: Sender<ConstellationControlMsg>, script_chan: Sender<ConstellationControlMsg>,
paint_chan: OptionalIpcSender<LayoutToPaintMsg>, paint_chan: OptionalIpcSender<LayoutToPaintMsg>,
image_cache_task: ImageCacheTask, image_cache_task: ImageCacheTask,

View file

@ -12,7 +12,7 @@ use fragment::{Fragment, FragmentBorderBoxIterator};
use gfx::display_list::{DisplayItemMetadata, OpaqueNode}; use gfx::display_list::{DisplayItemMetadata, OpaqueNode};
use layout_task::LayoutTaskData; use layout_task::LayoutTaskData;
use msg::constellation_msg::ConstellationChan; use msg::constellation_msg::ConstellationChan;
use msg::constellation_msg::Msg as ConstellationMsg; use msg::constellation_msg::ScriptMsg as ConstellationMsg;
use opaque_node::OpaqueNodeMethods; use opaque_node::OpaqueNodeMethods;
use script::layout_interface::{ContentBoxResponse, ContentBoxesResponse, NodeGeometryResponse}; use script::layout_interface::{ContentBoxResponse, ContentBoxesResponse, NodeGeometryResponse};
use script::layout_interface::{HitTestResponse, LayoutRPC, MouseOverResponse, OffsetParentResponse}; use script::layout_interface::{HitTestResponse, LayoutRPC, MouseOverResponse, OffsetParentResponse};

View file

@ -24,6 +24,7 @@ extern crate util;
use gfx::font_cache_task::FontCacheTask; use gfx::font_cache_task::FontCacheTask;
use gfx::paint_task::LayoutToPaintMsg; use gfx::paint_task::LayoutToPaintMsg;
use ipc_channel::ipc::{IpcReceiver, IpcSender}; use ipc_channel::ipc::{IpcReceiver, IpcSender};
use msg::constellation_msg::ScriptMsg as ConstellationMsg;
use msg::constellation_msg::{ConstellationChan, Failure, PipelineId}; use msg::constellation_msg::{ConstellationChan, Failure, PipelineId};
use net_traits::image_cache_task::ImageCacheTask; use net_traits::image_cache_task::ImageCacheTask;
use profile_traits::{mem, time}; use profile_traits::{mem, time};
@ -46,7 +47,7 @@ pub trait LayoutTaskFactory {
is_iframe: bool, is_iframe: bool,
chan: OpaqueScriptLayoutChannel, chan: OpaqueScriptLayoutChannel,
pipeline_port: IpcReceiver<LayoutControlMsg>, pipeline_port: IpcReceiver<LayoutControlMsg>,
constellation_chan: ConstellationChan, constellation_chan: ConstellationChan<ConstellationMsg>,
failure_msg: Failure, failure_msg: Failure,
script_chan: Sender<ConstellationControlMsg>, script_chan: Sender<ConstellationControlMsg>,
layout_to_paint_chan: OptionalIpcSender<LayoutToPaintMsg>, layout_to_paint_chan: OptionalIpcSender<LayoutToPaintMsg>,

View file

@ -25,16 +25,21 @@ use util::geometry::{PagePx, ViewportPx};
use util::mem::HeapSizeOf; use util::mem::HeapSizeOf;
use webdriver_msg::{LoadStatus, WebDriverScriptCommand}; use webdriver_msg::{LoadStatus, WebDriverScriptCommand};
#[derive(Clone)] pub struct ConstellationChan<T>(pub Sender<T>);
pub struct ConstellationChan(pub Sender<Msg>);
impl ConstellationChan { impl<T> ConstellationChan<T> {
pub fn new() -> (Receiver<Msg>, ConstellationChan) { pub fn new() -> (Receiver<T>, ConstellationChan<T>) {
let (chan, port) = channel(); let (chan, port) = channel();
(port, ConstellationChan(chan)) (port, ConstellationChan(chan))
} }
} }
impl<T> Clone for ConstellationChan<T> {
fn clone(&self) -> ConstellationChan<T> {
ConstellationChan(self.0.clone())
}
}
#[derive(PartialEq, Eq, Copy, Clone, Debug, Deserialize, Serialize)] #[derive(PartialEq, Eq, Copy, Clone, Debug, Deserialize, Serialize)]
pub enum IFrameSandboxState { pub enum IFrameSandboxState {
IFrameSandboxed, IFrameSandboxed,
@ -229,57 +234,38 @@ pub struct IframeLoadInfo {
pub sandbox: IFrameSandboxState, pub sandbox: IFrameSandboxState,
} }
/// Messages from the compositor and script to the constellation. /// Messages from the compositor to the constellation.
#[derive(Deserialize, Serialize)] #[derive(Deserialize, Serialize)]
pub enum Msg { pub enum CompositorMsg {
Exit, Exit,
Failure(Failure),
InitLoadUrl(Url),
LoadComplete(PipelineId),
/// Dispatched after the DOM load event has fired on a document
DOMLoad(PipelineId),
FrameSize(PipelineId, Size2D<f32>), FrameSize(PipelineId, Size2D<f32>),
LoadUrl(PipelineId, LoadData),
ScriptLoadedURLInIFrame(IframeLoadInfo),
Navigate(Option<(PipelineId, SubpageId)>, NavigationDirection),
PainterReady(PipelineId),
ResizedWindow(WindowSizeData),
KeyEvent(Key, KeyState, KeyModifiers),
/// Requests that the constellation inform the compositor of the title of the pipeline
/// immediately.
GetPipelineTitle(PipelineId),
/// Requests that the constellation inform the compositor of the a cursor change.
SetCursor(Cursor),
/// Dispatch a mozbrowser event to a given iframe. Only available in experimental mode.
MozBrowserEvent(PipelineId, SubpageId, MozBrowserEvent),
/// Indicates whether this pipeline is currently running animations.
ChangeRunningAnimationsState(PipelineId, AnimationState),
/// Requests that the constellation instruct layout to begin a new tick of the animation.
TickAnimation(PipelineId),
/// Request that the constellation send the current pipeline id for the provided frame
/// id, or for the root frame if this is None, over a provided channel
GetPipeline(Option<FrameId>, IpcSender<Option<PipelineId>>),
/// Request that the constellation send the FrameId corresponding to the document /// Request that the constellation send the FrameId corresponding to the document
/// with the provided pipeline id /// with the provided pipeline id
GetFrame(PipelineId, IpcSender<Option<FrameId>>), GetFrame(PipelineId, IpcSender<Option<FrameId>>),
/// Notifies the constellation that this frame has received focus. /// Request that the constellation send the current pipeline id for the provided frame
Focus(PipelineId), /// id, or for the root frame if this is None, over a provided channel
/// Requests that the constellation retrieve the current contents of the clipboard GetPipeline(Option<FrameId>, IpcSender<Option<PipelineId>>),
GetClipboardContents(IpcSender<String>), /// Requests that the constellation inform the compositor of the title of the pipeline
/// Requests that the constellation set the contents of the clipboard /// immediately.
SetClipboardContents(String), GetPipelineTitle(PipelineId),
/// Dispatch a webdriver command InitLoadUrl(Url),
WebDriverCommand(WebDriverCommandMsg),
/// Notifies the constellation that the viewport has been constrained in some manner
ViewportConstrained(PipelineId, ViewportConstraints),
/// Query the constellation to see if the current compositor output is stable /// Query the constellation to see if the current compositor output is stable
IsReadyToSaveImage(HashMap<PipelineId, Epoch>), IsReadyToSaveImage(HashMap<PipelineId, Epoch>),
/// Notification that this iframe should be removed. KeyEvent(Key, KeyState, KeyModifiers),
RemoveIFrame(PipelineId), LoadUrl(PipelineId, LoadData),
/// Favicon detected Navigate(Option<(PipelineId, SubpageId)>, NavigationDirection),
NewFavicon(Url), ResizedWindow(WindowSizeData),
/// <head> tag finished parsing /// Requests that the constellation instruct layout to begin a new tick of the animation.
HeadParsed, TickAnimation(PipelineId),
/// Dispatch a webdriver command
WebDriverCommand(WebDriverCommandMsg),
}
/// Messages from the script to the constellation.
#[derive(Deserialize, Serialize)]
pub enum ScriptMsg {
/// Indicates whether this pipeline is currently running animations.
ChangeRunningAnimationsState(PipelineId, AnimationState),
/// Requests that a new 2D canvas thread be created. (This is done in the constellation because /// Requests that a new 2D canvas thread be created. (This is done in the constellation because
/// 2D canvases may use the GPU and we don't want to give untrusted content access to the GPU.) /// 2D canvases may use the GPU and we don't want to give untrusted content access to the GPU.)
CreateCanvasPaintTask(Size2D<i32>, IpcSender<(IpcSender<CanvasMsg>, usize)>), CreateCanvasPaintTask(Size2D<i32>, IpcSender<(IpcSender<CanvasMsg>, usize)>),
@ -288,8 +274,34 @@ pub enum Msg {
CreateWebGLPaintTask(Size2D<i32>, CreateWebGLPaintTask(Size2D<i32>,
GLContextAttributes, GLContextAttributes,
IpcSender<Result<(IpcSender<CanvasMsg>, usize), String>>), IpcSender<Result<(IpcSender<CanvasMsg>, usize), String>>),
/// Dispatched after the DOM load event has fired on a document
DOMLoad(PipelineId),
Failure(Failure),
/// Notifies the constellation that this frame has received focus.
Focus(PipelineId),
/// Requests that the constellation retrieve the current contents of the clipboard
GetClipboardContents(IpcSender<String>),
/// <head> tag finished parsing
HeadParsed,
LoadComplete(PipelineId),
LoadUrl(PipelineId, LoadData),
/// Dispatch a mozbrowser event to a given iframe. Only available in experimental mode.
MozBrowserEvent(PipelineId, SubpageId, MozBrowserEvent),
Navigate(Option<(PipelineId, SubpageId)>, NavigationDirection),
/// Favicon detected
NewFavicon(Url),
/// Status message to be displayed in the chrome, eg. a link URL on mouseover. /// Status message to be displayed in the chrome, eg. a link URL on mouseover.
NodeStatus(Option<String>), NodeStatus(Option<String>),
PainterReady(PipelineId),
/// Notification that this iframe should be removed.
RemoveIFrame(PipelineId),
ScriptLoadedURLInIFrame(IframeLoadInfo),
/// Requests that the constellation set the contents of the clipboard
SetClipboardContents(String),
/// Requests that the constellation inform the compositor of the a cursor change.
SetCursor(Cursor),
/// Notifies the constellation that the viewport has been constrained in some manner
ViewportConstrained(PipelineId, ViewportConstraints),
} }
#[derive(Clone, Eq, PartialEq, Deserialize, Serialize, Debug)] #[derive(Clone, Eq, PartialEq, Deserialize, Serialize, Debug)]

View file

@ -4,7 +4,7 @@
use ipc_channel::ipc; use ipc_channel::ipc;
use msg::constellation_msg::ConstellationChan; use msg::constellation_msg::ConstellationChan;
use msg::constellation_msg::Msg as ConstellationMsg; use msg::constellation_msg::ScriptMsg as ConstellationMsg;
use std::borrow::ToOwned; use std::borrow::ToOwned;
use std::sync::mpsc::channel; use std::sync::mpsc::channel;
@ -15,7 +15,7 @@ pub trait ClipboardProvider {
fn set_clipboard_contents(&mut self, String); fn set_clipboard_contents(&mut self, String);
} }
impl ClipboardProvider for ConstellationChan { impl ClipboardProvider for ConstellationChan<ConstellationMsg> {
fn clipboard_contents(&mut self) -> String { fn clipboard_contents(&mut self) -> String {
let (tx, rx) = ipc::channel().unwrap(); let (tx, rx) = ipc::channel().unwrap();
self.0.send(ConstellationMsg::GetClipboardContents(tx)).unwrap(); self.0.send(ConstellationMsg::GetClipboardContents(tx)).unwrap();

View file

@ -18,6 +18,7 @@ use ipc_channel::ipc::IpcSender;
use js::jsapi::{GetGlobalForObjectCrossCompartment}; use js::jsapi::{GetGlobalForObjectCrossCompartment};
use js::jsapi::{JSContext, JSObject, JS_GetClass, MutableHandleValue}; use js::jsapi::{JSContext, JSObject, JS_GetClass, MutableHandleValue};
use js::{JSCLASS_IS_DOMJSCLASS, JSCLASS_IS_GLOBAL}; use js::{JSCLASS_IS_DOMJSCLASS, JSCLASS_IS_GLOBAL};
use msg::constellation_msg::ScriptMsg as ConstellationMsg;
use msg::constellation_msg::{ConstellationChan, PipelineId, WorkerId}; use msg::constellation_msg::{ConstellationChan, PipelineId, WorkerId};
use net_traits::ResourceTask; use net_traits::ResourceTask;
use profile_traits::mem; use profile_traits::mem;
@ -91,7 +92,7 @@ impl<'a> GlobalRef<'a> {
} }
/// Get a `ConstellationChan` to send messages to the constellation channel when available. /// Get a `ConstellationChan` to send messages to the constellation channel when available.
pub fn constellation_chan(&self) -> ConstellationChan { pub fn constellation_chan(&self) -> ConstellationChan<ConstellationMsg> {
match *self { match *self {
GlobalRef::Window(window) => window.constellation_chan(), GlobalRef::Window(window) => window.constellation_chan(),
GlobalRef::Worker(worker) => worker.constellation_chan(), GlobalRef::Worker(worker) => worker.constellation_chan(),

View file

@ -54,6 +54,7 @@ use js::rust::Runtime;
use layout_interface::{LayoutChan, LayoutRPC}; use layout_interface::{LayoutChan, LayoutRPC};
use libc; use libc;
use msg::constellation_msg::ConstellationChan; use msg::constellation_msg::ConstellationChan;
use msg::constellation_msg::ScriptMsg as ConstellationMsg;
use msg::constellation_msg::{PipelineId, SubpageId, WindowSizeData, WorkerId}; use msg::constellation_msg::{PipelineId, SubpageId, WindowSizeData, WorkerId};
use net_traits::Metadata; use net_traits::Metadata;
use net_traits::image::base::Image; use net_traits::image::base::Image;
@ -271,7 +272,7 @@ no_jsmanaged_fields!(WorkerId);
no_jsmanaged_fields!(QuirksMode); no_jsmanaged_fields!(QuirksMode);
no_jsmanaged_fields!(Runtime); no_jsmanaged_fields!(Runtime);
no_jsmanaged_fields!(Headers, Method); no_jsmanaged_fields!(Headers, Method);
no_jsmanaged_fields!(ConstellationChan); no_jsmanaged_fields!(ConstellationChan<ConstellationMsg>);
no_jsmanaged_fields!(LayoutChan); no_jsmanaged_fields!(LayoutChan);
no_jsmanaged_fields!(WindowProxyHandler); no_jsmanaged_fields!(WindowProxyHandler);
no_jsmanaged_fields!(UntrustedNodeAddress); no_jsmanaged_fields!(UntrustedNodeAddress);

View file

@ -33,7 +33,7 @@ use euclid::point::Point2D;
use euclid::rect::Rect; use euclid::rect::Rect;
use euclid::size::Size2D; use euclid::size::Size2D;
use ipc_channel::ipc::{self, IpcSender}; use ipc_channel::ipc::{self, IpcSender};
use msg::constellation_msg::Msg as ConstellationMsg; use msg::constellation_msg::ScriptMsg as ConstellationMsg;
use net_traits::image::base::PixelFormat; use net_traits::image::base::PixelFormat;
use net_traits::image_cache_task::ImageResponse; use net_traits::image_cache_task::ImageResponse;
use num::{Float, ToPrimitive}; use num::{Float, ToPrimitive};

View file

@ -80,7 +80,7 @@ use layout_interface::{LayoutChan, Msg};
use layout_interface::{ReflowGoal, ReflowQueryType}; use layout_interface::{ReflowGoal, ReflowQueryType};
use msg::compositor_msg::ScriptToCompositorMsg; use msg::compositor_msg::ScriptToCompositorMsg;
use msg::constellation_msg::AnimationState; use msg::constellation_msg::AnimationState;
use msg::constellation_msg::Msg as ConstellationMsg; use msg::constellation_msg::ScriptMsg as ConstellationMsg;
use msg::constellation_msg::{ALT, CONTROL, SHIFT, SUPER}; use msg::constellation_msg::{ALT, CONTROL, SHIFT, SUPER};
use msg::constellation_msg::{ConstellationChan, FocusType, Key, KeyModifiers, KeyState, MozBrowserEvent, SubpageId}; use msg::constellation_msg::{ConstellationChan, FocusType, Key, KeyModifiers, KeyState, MozBrowserEvent, SubpageId};
use net_traits::ControlMsg::{GetCookiesForUrl, SetCookiesForUrl}; use net_traits::ControlMsg::{GetCookiesForUrl, SetCookiesForUrl};

View file

@ -18,7 +18,7 @@ use dom::htmlelement::HTMLElement;
use dom::node::{Node, document_from_node, window_from_node}; use dom::node::{Node, document_from_node, window_from_node};
use dom::virtualmethods::VirtualMethods; use dom::virtualmethods::VirtualMethods;
use msg::constellation_msg::ConstellationChan; use msg::constellation_msg::ConstellationChan;
use msg::constellation_msg::Msg as ConstellationMsg; use msg::constellation_msg::ScriptMsg as ConstellationMsg;
use std::rc::Rc; use std::rc::Rc;
use string_cache::Atom; use string_cache::Atom;
use time; use time;

View file

@ -25,7 +25,7 @@ use dom::window::Window;
use js::jsapi::{JSAutoCompartment, JSAutoRequest, RootedValue, JSContext, MutableHandleValue}; use js::jsapi::{JSAutoCompartment, JSAutoRequest, RootedValue, JSContext, MutableHandleValue};
use js::jsval::{UndefinedValue, NullValue}; use js::jsval::{UndefinedValue, NullValue};
use msg::constellation_msg::IFrameSandboxState::{IFrameSandboxed, IFrameUnsandboxed}; use msg::constellation_msg::IFrameSandboxState::{IFrameSandboxed, IFrameUnsandboxed};
use msg::constellation_msg::Msg as ConstellationMsg; use msg::constellation_msg::ScriptMsg as ConstellationMsg;
use msg::constellation_msg::{ConstellationChan, IframeLoadInfo, MozBrowserEvent}; use msg::constellation_msg::{ConstellationChan, IframeLoadInfo, MozBrowserEvent};
use msg::constellation_msg::{NavigationDirection, PipelineId, SubpageId}; use msg::constellation_msg::{NavigationDirection, PipelineId, SubpageId};
use page::IterablePage; use page::IterablePage;

View file

@ -28,6 +28,7 @@ use dom::node::{document_from_node, window_from_node};
use dom::nodelist::NodeList; use dom::nodelist::NodeList;
use dom::virtualmethods::VirtualMethods; use dom::virtualmethods::VirtualMethods;
use msg::constellation_msg::ConstellationChan; use msg::constellation_msg::ConstellationChan;
use msg::constellation_msg::ScriptMsg as ConstellationMsg;
use selectors::states::*; use selectors::states::*;
use std::borrow::ToOwned; use std::borrow::ToOwned;
use std::cell::Cell; use std::cell::Cell;
@ -64,7 +65,7 @@ pub struct HTMLInputElement {
value_changed: Cell<bool>, value_changed: Cell<bool>,
size: Cell<u32>, size: Cell<u32>,
#[ignore_heap_size_of = "#7193"] #[ignore_heap_size_of = "#7193"]
textinput: DOMRefCell<TextInput<ConstellationChan>>, textinput: DOMRefCell<TextInput<ConstellationChan<ConstellationMsg>>>,
activation_state: DOMRefCell<InputActivationState>, activation_state: DOMRefCell<InputActivationState>,
} }

View file

@ -24,7 +24,7 @@ use encoding::all::UTF_8;
use ipc_channel::ipc; use ipc_channel::ipc;
use ipc_channel::router::ROUTER; use ipc_channel::router::ROUTER;
use layout_interface::{LayoutChan, Msg}; use layout_interface::{LayoutChan, Msg};
use msg::constellation_msg::Msg as ConstellationMsg; use msg::constellation_msg::ScriptMsg as ConstellationMsg;
use msg::constellation_msg::{ConstellationChan, MozBrowserEvent}; use msg::constellation_msg::{ConstellationChan, MozBrowserEvent};
use net_traits::{AsyncResponseListener, AsyncResponseTarget, Metadata}; use net_traits::{AsyncResponseListener, AsyncResponseTarget, Metadata};
use network_listener::{NetworkListener, PreInvoke}; use network_listener::{NetworkListener, PreInvoke};

View file

@ -25,6 +25,7 @@ use dom::node::{document_from_node, window_from_node};
use dom::nodelist::NodeList; use dom::nodelist::NodeList;
use dom::virtualmethods::VirtualMethods; use dom::virtualmethods::VirtualMethods;
use msg::constellation_msg::ConstellationChan; use msg::constellation_msg::ConstellationChan;
use msg::constellation_msg::ScriptMsg as ConstellationMsg;
use script_task::ScriptTaskEventCategory::InputEvent; use script_task::ScriptTaskEventCategory::InputEvent;
use script_task::{CommonScriptMsg, Runnable}; use script_task::{CommonScriptMsg, Runnable};
use selectors::states::*; use selectors::states::*;
@ -37,7 +38,7 @@ use util::str::DOMString;
pub struct HTMLTextAreaElement { pub struct HTMLTextAreaElement {
htmlelement: HTMLElement, htmlelement: HTMLElement,
#[ignore_heap_size_of = "#7193"] #[ignore_heap_size_of = "#7193"]
textinput: DOMRefCell<TextInput<ConstellationChan>>, textinput: DOMRefCell<TextInput<ConstellationChan<ConstellationMsg>>>,
cols: Cell<u32>, cols: Cell<u32>,
rows: Cell<u32>, rows: Cell<u32>,
// https://html.spec.whatwg.org/multipage/#concept-textarea-dirty // https://html.spec.whatwg.org/multipage/#concept-textarea-dirty

View file

@ -31,7 +31,7 @@ use ipc_channel::ipc::{self, IpcSender};
use js::jsapi::{JSContext, JSObject, RootedValue}; use js::jsapi::{JSContext, JSObject, RootedValue};
use js::jsapi::{JS_GetFloat32ArrayData, JS_GetObjectAsArrayBufferView}; use js::jsapi::{JS_GetFloat32ArrayData, JS_GetObjectAsArrayBufferView};
use js::jsval::{BooleanValue, Int32Value, JSVal, NullValue, UndefinedValue}; use js::jsval::{BooleanValue, Int32Value, JSVal, NullValue, UndefinedValue};
use msg::constellation_msg::Msg as ConstellationMsg; use msg::constellation_msg::ScriptMsg as ConstellationMsg;
use net_traits::image::base::PixelFormat; use net_traits::image::base::PixelFormat;
use net_traits::image_cache_task::ImageResponse; use net_traits::image_cache_task::ImageResponse;
use offscreen_gl_context::GLContextAttributes; use offscreen_gl_context::GLContextAttributes;

View file

@ -43,6 +43,7 @@ use layout_interface::{ContentBoxResponse, ContentBoxesResponse, ResolvedStyleRe
use layout_interface::{LayoutChan, LayoutRPC, Msg, Reflow, ReflowGoal, ReflowQueryType}; use layout_interface::{LayoutChan, LayoutRPC, Msg, Reflow, ReflowGoal, ReflowQueryType};
use libc; use libc;
use msg::compositor_msg::{LayerId, ScriptToCompositorMsg}; use msg::compositor_msg::{LayerId, ScriptToCompositorMsg};
use msg::constellation_msg::ScriptMsg as ConstellationMsg;
use msg::constellation_msg::{ConstellationChan, LoadData, PipelineId, SubpageId, WindowSizeData, WorkerId}; use msg::constellation_msg::{ConstellationChan, LoadData, PipelineId, SubpageId, WindowSizeData, WorkerId};
use msg::webdriver_msg::{WebDriverJSError, WebDriverJSResult}; use msg::webdriver_msg::{WebDriverJSError, WebDriverJSResult};
use net_traits::ResourceTask; use net_traits::ResourceTask;
@ -191,7 +192,7 @@ pub struct Window {
/// A handle for communicating messages to the constellation task. /// A handle for communicating messages to the constellation task.
#[ignore_heap_size_of = "channels are hard"] #[ignore_heap_size_of = "channels are hard"]
constellation_chan: ConstellationChan, constellation_chan: ConstellationChan<ConstellationMsg>,
/// Pending scroll to fragment event, if any /// Pending scroll to fragment event, if any
fragment_name: DOMRefCell<Option<String>>, fragment_name: DOMRefCell<Option<String>>,
@ -1071,7 +1072,7 @@ impl Window {
self.layout_chan.clone() self.layout_chan.clone()
} }
pub fn constellation_chan(&self) -> ConstellationChan { pub fn constellation_chan(&self) -> ConstellationChan<ConstellationMsg> {
self.constellation_chan.clone() self.constellation_chan.clone()
} }
@ -1224,7 +1225,7 @@ impl Window {
storage_task: StorageTask, storage_task: StorageTask,
mem_profiler_chan: mem::ProfilerChan, mem_profiler_chan: mem::ProfilerChan,
devtools_chan: Option<IpcSender<ScriptToDevtoolsControlMsg>>, devtools_chan: Option<IpcSender<ScriptToDevtoolsControlMsg>>,
constellation_chan: ConstellationChan, constellation_chan: ConstellationChan<ConstellationMsg>,
scheduler_chan: IpcSender<TimerEventRequest>, scheduler_chan: IpcSender<TimerEventRequest>,
timer_event_chan: IpcSender<TimerEvent>, timer_event_chan: IpcSender<TimerEvent>,
layout_chan: LayoutChan, layout_chan: LayoutChan,

View file

@ -20,6 +20,7 @@ use dom::workernavigator::WorkerNavigator;
use ipc_channel::ipc::IpcSender; use ipc_channel::ipc::IpcSender;
use js::jsapi::{HandleValue, JSAutoRequest, JSContext}; use js::jsapi::{HandleValue, JSAutoRequest, JSContext};
use js::rust::Runtime; use js::rust::Runtime;
use msg::constellation_msg::ScriptMsg as ConstellationMsg;
use msg::constellation_msg::{ConstellationChan, PipelineId, WorkerId}; use msg::constellation_msg::{ConstellationChan, PipelineId, WorkerId};
use net_traits::{ResourceTask, load_whole_resource}; use net_traits::{ResourceTask, load_whole_resource};
use profile_traits::mem; use profile_traits::mem;
@ -43,7 +44,7 @@ pub struct WorkerGlobalScopeInit {
pub mem_profiler_chan: mem::ProfilerChan, pub mem_profiler_chan: mem::ProfilerChan,
pub to_devtools_sender: Option<IpcSender<ScriptToDevtoolsControlMsg>>, pub to_devtools_sender: Option<IpcSender<ScriptToDevtoolsControlMsg>>,
pub from_devtools_sender: Option<IpcSender<DevtoolScriptControlMsg>>, pub from_devtools_sender: Option<IpcSender<DevtoolScriptControlMsg>>,
pub constellation_chan: ConstellationChan, pub constellation_chan: ConstellationChan<ConstellationMsg>,
pub scheduler_chan: IpcSender<TimerEventRequest>, pub scheduler_chan: IpcSender<TimerEventRequest>,
pub worker_id: WorkerId, pub worker_id: WorkerId,
} }
@ -84,7 +85,7 @@ pub struct WorkerGlobalScope {
devtools_wants_updates: Cell<bool>, devtools_wants_updates: Cell<bool>,
#[ignore_heap_size_of = "Defined in std"] #[ignore_heap_size_of = "Defined in std"]
constellation_chan: ConstellationChan, constellation_chan: ConstellationChan<ConstellationMsg>,
#[ignore_heap_size_of = "Defined in std"] #[ignore_heap_size_of = "Defined in std"]
scheduler_chan: IpcSender<TimerEventRequest>, scheduler_chan: IpcSender<TimerEventRequest>,
@ -135,7 +136,7 @@ impl WorkerGlobalScope {
&self.from_devtools_receiver &self.from_devtools_receiver
} }
pub fn constellation_chan(&self) -> ConstellationChan { pub fn constellation_chan(&self) -> ConstellationChan<ConstellationMsg> {
self.constellation_chan.clone() self.constellation_chan.clone()
} }

View file

@ -14,6 +14,7 @@ use ipc_channel::ipc::{IpcReceiver, IpcSender};
use libc::uintptr_t; use libc::uintptr_t;
use msg::compositor_msg::Epoch; use msg::compositor_msg::Epoch;
use msg::compositor_msg::LayerId; use msg::compositor_msg::LayerId;
use msg::constellation_msg::ScriptMsg as ConstellationMsg;
use msg::constellation_msg::{ConstellationChan, Failure, PipelineId}; use msg::constellation_msg::{ConstellationChan, Failure, PipelineId};
use msg::constellation_msg::{WindowSizeData}; use msg::constellation_msg::{WindowSizeData};
use net_traits::image_cache_task::ImageCacheTask; use net_traits::image_cache_task::ImageCacheTask;
@ -251,7 +252,7 @@ pub struct NewLayoutTaskInfo {
pub is_parent: bool, pub is_parent: bool,
pub layout_pair: OpaqueScriptLayoutChannel, pub layout_pair: OpaqueScriptLayoutChannel,
pub pipeline_port: IpcReceiver<LayoutControlMsg>, pub pipeline_port: IpcReceiver<LayoutControlMsg>,
pub constellation_chan: ConstellationChan, pub constellation_chan: ConstellationChan<ConstellationMsg>,
pub failure: Failure, pub failure: Failure,
pub script_chan: Sender<ConstellationControlMsg>, pub script_chan: Sender<ConstellationControlMsg>,
pub image_cache_task: ImageCacheTask, pub image_cache_task: ImageCacheTask,

View file

@ -62,7 +62,7 @@ use layout_interface::{self, LayoutChan, NewLayoutTaskInfo, ReflowGoal, ScriptLa
use libc; use libc;
use mem::heap_size_of_self_and_children; use mem::heap_size_of_self_and_children;
use msg::compositor_msg::{EventResult, LayerId, ScriptToCompositorMsg}; use msg::compositor_msg::{EventResult, LayerId, ScriptToCompositorMsg};
use msg::constellation_msg::Msg as ConstellationMsg; use msg::constellation_msg::ScriptMsg as ConstellationMsg;
use msg::constellation_msg::{ConstellationChan, FocusType, LoadData}; use msg::constellation_msg::{ConstellationChan, FocusType, LoadData};
use msg::constellation_msg::{MozBrowserEvent, PipelineId}; use msg::constellation_msg::{MozBrowserEvent, PipelineId};
use msg::constellation_msg::{PipelineNamespace}; use msg::constellation_msg::{PipelineNamespace};
@ -403,7 +403,7 @@ pub struct ScriptTask {
control_port: Receiver<ConstellationControlMsg>, control_port: Receiver<ConstellationControlMsg>,
/// For communicating load url messages to the constellation /// For communicating load url messages to the constellation
constellation_chan: ConstellationChan, constellation_chan: ConstellationChan<ConstellationMsg>,
/// A handle to the compositor for communicating ready state messages. /// A handle to the compositor for communicating ready state messages.
compositor: DOMRefCell<IpcSender<ScriptToCompositorMsg>>, compositor: DOMRefCell<IpcSender<ScriptToCompositorMsg>>,

View file

@ -31,6 +31,7 @@ use euclid::rect::Rect;
use ipc_channel::ipc::{IpcReceiver, IpcSender}; use ipc_channel::ipc::{IpcReceiver, IpcSender};
use libc::c_void; use libc::c_void;
use msg::compositor_msg::{Epoch, LayerId, ScriptToCompositorMsg}; use msg::compositor_msg::{Epoch, LayerId, ScriptToCompositorMsg};
use msg::constellation_msg::ScriptMsg as ConstellationMsg;
use msg::constellation_msg::{ConstellationChan, Failure, PipelineId, WindowSizeData}; use msg::constellation_msg::{ConstellationChan, Failure, PipelineId, WindowSizeData};
use msg::constellation_msg::{Key, KeyModifiers, KeyState, LoadData, SubpageId}; use msg::constellation_msg::{Key, KeyModifiers, KeyState, LoadData, SubpageId};
use msg::constellation_msg::{MozBrowserEvent, PipelineNamespaceId}; use msg::constellation_msg::{MozBrowserEvent, PipelineNamespaceId};
@ -253,7 +254,7 @@ pub struct InitialScriptState {
/// A port on which messages sent by the constellation to script can be received. /// A port on which messages sent by the constellation to script can be received.
pub control_port: Receiver<ConstellationControlMsg>, pub control_port: Receiver<ConstellationControlMsg>,
/// A channel on which messages can be sent to the constellation from script. /// A channel on which messages can be sent to the constellation from script.
pub constellation_chan: ConstellationChan, pub constellation_chan: ConstellationChan<ConstellationMsg>,
/// A channel to schedule timer events. /// A channel to schedule timer events.
pub scheduler_chan: IpcSender<TimerEventRequest>, pub scheduler_chan: IpcSender<TimerEventRequest>,
/// Information that script sends out when it panics. /// Information that script sends out when it panics.

View file

@ -48,12 +48,12 @@ extern crate libc;
extern crate webdriver_server; extern crate webdriver_server;
#[cfg(feature = "webdriver")] #[cfg(feature = "webdriver")]
fn webdriver(port: u16, constellation: msg::constellation_msg::ConstellationChan) { fn webdriver(port: u16, constellation: msg::constellation_msg::ConstellationChan<ConstellationMsg>) {
webdriver_server::start_server(port, constellation.clone()); webdriver_server::start_server(port, constellation.clone());
} }
#[cfg(not(feature = "webdriver"))] #[cfg(not(feature = "webdriver"))]
fn webdriver(_port: u16, _constellation: msg::constellation_msg::ConstellationChan) { } fn webdriver(_port: u16, _constellation: msg::constellation_msg::ConstellationChan<ConstellationMsg>) { }
use compositing::CompositorEventListener; use compositing::CompositorEventListener;
use compositing::compositor_task::InitialCompositorState; use compositing::compositor_task::InitialCompositorState;
@ -62,8 +62,8 @@ use compositing::windowing::WindowEvent;
use compositing::windowing::WindowMethods; use compositing::windowing::WindowMethods;
use compositing::{CompositorProxy, CompositorTask, Constellation}; use compositing::{CompositorProxy, CompositorTask, Constellation};
use gfx::font_cache_task::FontCacheTask; use gfx::font_cache_task::FontCacheTask;
use msg::constellation_msg::CompositorMsg as ConstellationMsg;
use msg::constellation_msg::ConstellationChan; use msg::constellation_msg::ConstellationChan;
use msg::constellation_msg::Msg as ConstellationMsg;
use net::image_cache_task::new_image_cache_task; use net::image_cache_task::new_image_cache_task;
use net::resource_task::new_resource_task; use net::resource_task::new_resource_task;
use net::storage_task::StorageTaskFactory; use net::storage_task::StorageTaskFactory;
@ -193,7 +193,7 @@ fn create_constellation(opts: opts::Opts,
time_profiler_chan: time::ProfilerChan, time_profiler_chan: time::ProfilerChan,
mem_profiler_chan: mem::ProfilerChan, mem_profiler_chan: mem::ProfilerChan,
devtools_chan: Option<Sender<devtools_traits::DevtoolsControlMsg>>, devtools_chan: Option<Sender<devtools_traits::DevtoolsControlMsg>>,
supports_clipboard: bool) -> ConstellationChan { supports_clipboard: bool) -> ConstellationChan<ConstellationMsg> {
let resource_task = new_resource_task(opts.user_agent.clone(), devtools_chan.clone()); let resource_task = new_resource_task(opts.user_agent.clone(), devtools_chan.clone());
let image_cache_task = new_image_cache_task(resource_task.clone()); let image_cache_task = new_image_cache_task(resource_task.clone());

View file

@ -27,7 +27,7 @@ use hyper::method::Method::{self, Post};
use image::{DynamicImage, ImageFormat, RgbImage}; use image::{DynamicImage, ImageFormat, RgbImage};
use ipc_channel::ipc::{self, IpcReceiver, IpcSender}; use ipc_channel::ipc::{self, IpcReceiver, IpcSender};
use keys::keycodes_to_keys; use keys::keycodes_to_keys;
use msg::constellation_msg::Msg as ConstellationMsg; use msg::constellation_msg::CompositorMsg as ConstellationMsg;
use msg::constellation_msg::{ConstellationChan, FrameId, LoadData, PipelineId}; use msg::constellation_msg::{ConstellationChan, FrameId, LoadData, PipelineId};
use msg::constellation_msg::{NavigationDirection, PixelFormat, WebDriverCommandMsg}; use msg::constellation_msg::{NavigationDirection, PixelFormat, WebDriverCommandMsg};
use msg::webdriver_msg::{LoadStatus, WebDriverFrameId, WebDriverJSError, WebDriverJSResult, WebDriverScriptCommand}; use msg::webdriver_msg::{LoadStatus, WebDriverFrameId, WebDriverJSError, WebDriverJSResult, WebDriverScriptCommand};
@ -57,7 +57,7 @@ fn extension_routes() -> Vec<(Method, &'static str, ServoExtensionRoute)> {
(Post, "/session/{sessionId}/servo/prefs/reset", ServoExtensionRoute::ResetPrefs)] (Post, "/session/{sessionId}/servo/prefs/reset", ServoExtensionRoute::ResetPrefs)]
} }
pub fn start_server(port: u16, constellation_chan: ConstellationChan) { pub fn start_server(port: u16, constellation_chan: ConstellationChan<ConstellationMsg>) {
let handler = Handler::new(constellation_chan); let handler = Handler::new(constellation_chan);
spawn_named("WebdriverHttpServer".to_owned(), move || { spawn_named("WebdriverHttpServer".to_owned(), move || {
server::start(SocketAddr::new("0.0.0.0".parse().unwrap(), port), handler, server::start(SocketAddr::new("0.0.0.0".parse().unwrap(), port), handler,
@ -72,7 +72,7 @@ struct WebDriverSession {
struct Handler { struct Handler {
session: Option<WebDriverSession>, session: Option<WebDriverSession>,
constellation_chan: ConstellationChan, constellation_chan: ConstellationChan<ConstellationMsg>,
script_timeout: u32, script_timeout: u32,
load_timeout: u32, load_timeout: u32,
implicit_wait_timeout: u32 implicit_wait_timeout: u32
@ -207,9 +207,8 @@ impl WebDriverSession {
} }
} }
impl Handler { impl Handler {
pub fn new(constellation_chan: ConstellationChan) -> Handler { pub fn new(constellation_chan: ConstellationChan<ConstellationMsg>) -> Handler {
Handler { Handler {
session: None, session: None,
constellation_chan: constellation_chan, constellation_chan: constellation_chan,