Rename the ConstellationControlMsg variants.

This commit is contained in:
Ms2ger 2015-01-04 19:01:13 +01:00
parent 04eb923da9
commit 6e027cda2d
7 changed files with 49 additions and 53 deletions

View file

@ -28,7 +28,7 @@ use layers::scene::Scene;
use png; use png;
use gleam::gl::types::{GLint, GLsizei}; use gleam::gl::types::{GLint, GLsizei};
use gleam::gl; use gleam::gl;
use script_traits::{ViewportMsg, ScriptControlChan}; use script_traits::{ConstellationControlMsg, ScriptControlChan};
use servo_msg::compositor_msg::{Blank, Epoch, FinishedLoading, LayerId}; use servo_msg::compositor_msg::{Blank, Epoch, FinishedLoading, LayerId};
use servo_msg::compositor_msg::{ReadyState, PaintState, Scrollable}; use servo_msg::compositor_msg::{ReadyState, PaintState, Scrollable};
use servo_msg::constellation_msg::{mod, ConstellationChan}; use servo_msg::constellation_msg::{mod, ConstellationChan};
@ -977,7 +977,7 @@ impl<Window: WindowMethods> IOCompositor<Window> {
layer.bounds.borrow().size.to_untyped()); layer.bounds.borrow().size.to_untyped());
let pipeline = &layer.extra_data.borrow().pipeline; let pipeline = &layer.extra_data.borrow().pipeline;
let ScriptControlChan(ref chan) = pipeline.script_chan; let ScriptControlChan(ref chan) = pipeline.script_chan;
chan.send(ViewportMsg(pipeline.id.clone(), layer_rect)); chan.send(ConstellationControlMsg::Viewport(pipeline.id.clone(), layer_rect));
} }
for kid in layer.children().iter() { for kid in layer.children().iter() {

View file

@ -17,8 +17,8 @@ use layers::color::Color;
use layers::geometry::LayerPixel; use layers::geometry::LayerPixel;
use layers::layers::{Layer, LayerBufferSet}; use layers::layers::{Layer, LayerBufferSet};
use layers::platform::surface::NativeSurfaceMethods; use layers::platform::surface::NativeSurfaceMethods;
use script_traits::{ClickEvent, MouseDownEvent, MouseMoveEvent, MouseUpEvent, SendEventMsg}; use script_traits::{ClickEvent, MouseDownEvent, MouseMoveEvent, MouseUpEvent};
use script_traits::{ScriptControlChan}; use script_traits::{ScriptControlChan, ConstellationControlMsg};
use servo_msg::compositor_msg::{Epoch, FixedPosition, LayerId, ScrollPolicy}; use servo_msg::compositor_msg::{Epoch, FixedPosition, LayerId, ScrollPolicy};
use std::num::Float; use std::num::Float;
use std::num::FloatMath; use std::num::FloatMath;
@ -328,7 +328,7 @@ impl CompositorLayer for Layer<CompositorData> {
}; };
let pipeline = &self.extra_data.borrow().pipeline; let pipeline = &self.extra_data.borrow().pipeline;
let ScriptControlChan(ref chan) = pipeline.script_chan; let ScriptControlChan(ref chan) = pipeline.script_chan;
let _ = chan.send_opt(SendEventMsg(pipeline.id.clone(), message)); let _ = chan.send_opt(ConstellationControlMsg::SendEvent(pipeline.id.clone(), message));
} }
fn send_mouse_move_event(&self, fn send_mouse_move_event(&self,
@ -336,7 +336,7 @@ impl CompositorLayer for Layer<CompositorData> {
let message = MouseMoveEvent(cursor.to_untyped()); let message = MouseMoveEvent(cursor.to_untyped());
let pipeline = &self.extra_data.borrow().pipeline; let pipeline = &self.extra_data.borrow().pipeline;
let ScriptControlChan(ref chan) = pipeline.script_chan; let ScriptControlChan(ref chan) = pipeline.script_chan;
let _ = chan.send_opt(SendEventMsg(pipeline.id.clone(), message)); let _ = chan.send_opt(ConstellationControlMsg::SendEvent(pipeline.id.clone(), message));
} }
fn scroll_layer_and_all_child_layers(&self, fn scroll_layer_and_all_child_layers(&self,

View file

@ -14,7 +14,7 @@ use gfx::font_cache_task::FontCacheTask;
use layers::geometry::DevicePixel; use layers::geometry::DevicePixel;
use layout_traits::LayoutTaskFactory; use layout_traits::LayoutTaskFactory;
use libc; use libc;
use script_traits::{mod, GetTitleMsg, ResizeMsg, ResizeInactiveMsg, SendEventMsg}; use script_traits::{mod, ConstellationControlMsg};
use script_traits::{ScriptControlChan, ScriptTaskFactory}; use script_traits::{ScriptControlChan, ScriptTaskFactory};
use servo_msg::compositor_msg::LayerId; use servo_msg::compositor_msg::LayerId;
use servo_msg::constellation_msg::{mod, ConstellationChan, Failure}; use servo_msg::constellation_msg::{mod, ConstellationChan, Failure};
@ -672,7 +672,7 @@ impl<LTF: LayoutTaskFactory, STF: ScriptTaskFactory> Constellation<LTF, STF> {
if !already_sent.contains(&pipeline.id) { if !already_sent.contains(&pipeline.id) {
if is_active { if is_active {
let ScriptControlChan(ref script_chan) = pipeline.script_chan; let ScriptControlChan(ref script_chan) = pipeline.script_chan;
script_chan.send(ResizeMsg(pipeline.id, WindowSizeData { script_chan.send(ConstellationControlMsg::Resize(pipeline.id, WindowSizeData {
visible_viewport: rect.size, visible_viewport: rect.size,
initial_viewport: rect.size * ScaleFactor(1.0), initial_viewport: rect.size * ScaleFactor(1.0),
device_pixel_ratio: device_pixel_ratio, device_pixel_ratio: device_pixel_ratio,
@ -838,7 +838,7 @@ impl<LTF: LayoutTaskFactory, STF: ScriptTaskFactory> Constellation<LTF, STF> {
fn handle_key_msg(&self, key: Key, state: KeyState, mods: KeyModifiers) { fn handle_key_msg(&self, key: Key, state: KeyState, mods: KeyModifiers) {
self.current_frame().as_ref().map(|frame| { self.current_frame().as_ref().map(|frame| {
let ScriptControlChan(ref chan) = frame.pipeline.script_chan; let ScriptControlChan(ref chan) = frame.pipeline.script_chan;
chan.send(SendEventMsg(frame.pipeline.id, script_traits::KeyEvent(key, state, mods))); chan.send(ConstellationControlMsg::SendEvent(frame.pipeline.id, script_traits::KeyEvent(key, state, mods)));
}); });
} }
@ -847,7 +847,7 @@ impl<LTF: LayoutTaskFactory, STF: ScriptTaskFactory> Constellation<LTF, STF> {
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; let ScriptControlChan(ref script_channel) = pipeline.script_chan;
script_channel.send(GetTitleMsg(pipeline_id)); script_channel.send(ConstellationControlMsg::GetTitle(pipeline_id));
} }
} }
} }
@ -945,7 +945,7 @@ impl<LTF: LayoutTaskFactory, STF: ScriptTaskFactory> Constellation<LTF, STF> {
debug!("constellation sending resize message to active frame"); debug!("constellation sending resize message to active frame");
let pipeline = &frame_tree.pipeline; let pipeline = &frame_tree.pipeline;
let ScriptControlChan(ref chan) = pipeline.script_chan; let ScriptControlChan(ref chan) = pipeline.script_chan;
let _ = chan.send_opt(ResizeMsg(pipeline.id, new_size)); let _ = chan.send_opt(ConstellationControlMsg::Resize(pipeline.id, new_size));
already_seen.insert(pipeline.id); already_seen.insert(pipeline.id);
} }
for frame_tree in self.navigation_context.previous.iter() for frame_tree in self.navigation_context.previous.iter()
@ -954,7 +954,7 @@ impl<LTF: LayoutTaskFactory, STF: ScriptTaskFactory> Constellation<LTF, STF> {
if !already_seen.contains(&pipeline.id) { if !already_seen.contains(&pipeline.id) {
debug!("constellation sending resize message to inactive frame"); debug!("constellation sending resize message to inactive frame");
let ScriptControlChan(ref chan) = pipeline.script_chan; let ScriptControlChan(ref chan) = pipeline.script_chan;
let _ = chan.send_opt(ResizeInactiveMsg(pipeline.id, new_size)); let _ = chan.send_opt(ConstellationControlMsg::ResizeInactive(pipeline.id, new_size));
already_seen.insert(pipeline.id); already_seen.insert(pipeline.id);
} }
} }
@ -967,7 +967,7 @@ impl<LTF: LayoutTaskFactory, STF: ScriptTaskFactory> Constellation<LTF, STF> {
debug!("constellation sending resize message to pending outer frame ({})", debug!("constellation sending resize message to pending outer frame ({})",
frame_tree.pipeline.id); frame_tree.pipeline.id);
let ScriptControlChan(ref chan) = frame_tree.pipeline.script_chan; let ScriptControlChan(ref chan) = frame_tree.pipeline.script_chan;
let _ = chan.send_opt(ResizeMsg(frame_tree.pipeline.id, new_size)); let _ = chan.send_opt(ConstellationControlMsg::Resize(frame_tree.pipeline.id, new_size));
} }
} }

View file

@ -5,7 +5,7 @@
use CompositorProxy; use CompositorProxy;
use layout_traits::{ExitNowMsg, LayoutTaskFactory, LayoutControlChan}; use layout_traits::{ExitNowMsg, LayoutTaskFactory, LayoutControlChan};
use script_traits::{ScriptControlChan, ScriptTaskFactory}; use script_traits::{ScriptControlChan, ScriptTaskFactory};
use script_traits::{AttachLayoutMsg, LoadMsg, NewLayoutInfo, ExitPipelineMsg}; use script_traits::{NewLayoutInfo, ConstellationControlMsg};
use devtools_traits::DevtoolsControlChan; use devtools_traits::DevtoolsControlChan;
use gfx::paint_task::Msg as PaintMsg; use gfx::paint_task::Msg as PaintMsg;
@ -100,7 +100,7 @@ impl Pipeline {
}; };
let ScriptControlChan(ref chan) = spipe.script_chan; let ScriptControlChan(ref chan) = spipe.script_chan;
chan.send(AttachLayoutMsg(new_layout_info)); chan.send(ConstellationControlMsg::AttachLayout(new_layout_info));
spipe.script_chan.clone() spipe.script_chan.clone()
} }
}; };
@ -162,7 +162,7 @@ impl Pipeline {
pub fn load(&self) { pub fn load(&self) {
let ScriptControlChan(ref chan) = self.script_chan; let ScriptControlChan(ref chan) = self.script_chan;
chan.send(LoadMsg(self.id, self.load_data.clone())); chan.send(ConstellationControlMsg::Load(self.id, self.load_data.clone()));
} }
pub fn grant_paint_permission(&self) { pub fn grant_paint_permission(&self) {
@ -180,7 +180,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; let ScriptControlChan(ref chan) = self.script_chan;
if chan.send_opt(ExitPipelineMsg(self.id, exit_type)).is_ok() { if chan.send_opt(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_opt(); let _ = self.paint_shutdown_port.recv_opt();
@ -191,7 +191,9 @@ impl Pipeline {
pub fn force_exit(&self) { pub fn force_exit(&self) {
let ScriptControlChan(ref script_channel) = self.script_chan; let ScriptControlChan(ref script_channel) = self.script_chan;
let _ = script_channel.send_opt( ExitPipelineMsg(self.id, PipelineExitType::PipelineOnly)); let _ = script_channel.send_opt(
ConstellationControlMsg::ExitPipeline(self.id,
PipelineExitType::PipelineOnly));
let _ = self.paint_chan.send_opt(PaintMsg::Exit(None, PipelineExitType::PipelineOnly)); let _ = self.paint_chan.send_opt(PaintMsg::Exit(None, PipelineExitType::PipelineOnly));
let LayoutControlChan(ref layout_channel) = self.layout_chan; let LayoutControlChan(ref layout_channel) = self.layout_chan;
let _ = layout_channel.send_opt(ExitNowMsg(PipelineExitType::PipelineOnly)); let _ = layout_channel.send_opt(ExitNowMsg(PipelineExitType::PipelineOnly));

View file

@ -40,7 +40,7 @@ use script::layout_interface::{ContentBoxesQuery, ContentBoxQuery};
use script::layout_interface::{HitTestResponse, LayoutChan, LayoutRPC}; use script::layout_interface::{HitTestResponse, LayoutChan, LayoutRPC};
use script::layout_interface::{MouseOverResponse, Msg, NoQuery}; use script::layout_interface::{MouseOverResponse, Msg, NoQuery};
use script::layout_interface::{Reflow, ReflowGoal, ScriptLayoutChan, TrustedNodeAddress}; use script::layout_interface::{Reflow, ReflowGoal, ScriptLayoutChan, TrustedNodeAddress};
use script_traits::{SendEventMsg, ReflowEvent, ReflowCompleteMsg, OpaqueScriptLayoutChannel}; use script_traits::{ConstellationControlMsg, ReflowEvent, OpaqueScriptLayoutChannel};
use script_traits::{ScriptControlChan, UntrustedNodeAddress}; use script_traits::{ScriptControlChan, UntrustedNodeAddress};
use servo_msg::compositor_msg::Scrollable; use servo_msg::compositor_msg::Scrollable;
use servo_msg::constellation_msg::Msg as ConstellationMsg; use servo_msg::constellation_msg::Msg as ConstellationMsg;
@ -160,7 +160,7 @@ impl ImageResponder<UntrustedNodeAddress> for LayoutImageResponder {
debug!("Dirtying {:x}", node_address as uint); debug!("Dirtying {:x}", node_address as uint);
let mut nodes = SmallVec1::new(); let mut nodes = SmallVec1::new();
nodes.vec_push(node_address); nodes.vec_push(node_address);
drop(chan.send_opt(SendEventMsg(id.clone(), ReflowEvent(nodes)))) drop(chan.send_opt(ConstellationControlMsg::SendEvent(id.clone(), ReflowEvent(nodes))))
}; };
f f
} }
@ -871,7 +871,7 @@ impl LayoutTask {
// 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(()); data.script_join_chan.send(());
let ScriptControlChan(ref chan) = data.script_chan; let ScriptControlChan(ref chan) = data.script_chan;
chan.send(ReflowCompleteMsg(self.id, data.id)); chan.send(ConstellationControlMsg::ReflowComplete(self.id, data.id));
} }
unsafe fn dirty_all_nodes(node: &mut LayoutNode) { unsafe fn dirty_all_nodes(node: &mut LayoutNode) {

View file

@ -42,11 +42,6 @@ use script_traits::CompositorEvent;
use script_traits::CompositorEvent::{ResizeEvent, ReflowEvent, ClickEvent}; use script_traits::CompositorEvent::{ResizeEvent, ReflowEvent, ClickEvent};
use script_traits::CompositorEvent::{MouseDownEvent, MouseUpEvent}; use script_traits::CompositorEvent::{MouseDownEvent, MouseUpEvent};
use script_traits::CompositorEvent::{MouseMoveEvent, KeyEvent}; use script_traits::CompositorEvent::{MouseMoveEvent, KeyEvent};
use script_traits::ConstellationControlMsg::{LoadMsg, AttachLayoutMsg};
use script_traits::ConstellationControlMsg::{ResizeMsg, ResizeInactiveMsg};
use script_traits::ConstellationControlMsg::{ExitPipelineMsg, SendEventMsg};
use script_traits::ConstellationControlMsg::{ReflowCompleteMsg, ViewportMsg};
use script_traits::ConstellationControlMsg::GetTitleMsg;
use script_traits::{NewLayoutInfo, OpaqueScriptLayoutChannel}; use script_traits::{NewLayoutInfo, OpaqueScriptLayoutChannel};
use script_traits::{ConstellationControlMsg, ScriptControlChan}; use script_traits::{ConstellationControlMsg, ScriptControlChan};
use script_traits::ScriptTaskFactory; use script_traits::ScriptTaskFactory;
@ -513,15 +508,15 @@ impl ScriptTask {
// This has to be handled before the ResizeMsg below, // This has to be handled before the ResizeMsg below,
// otherwise the page may not have been added to the // otherwise the page may not have been added to the
// child list yet, causing the find() to fail. // child list yet, causing the find() to fail.
MixedMessage::FromConstellation(AttachLayoutMsg(new_layout_info)) => { MixedMessage::FromConstellation(ConstellationControlMsg::AttachLayout(new_layout_info)) => {
self.handle_new_layout(new_layout_info); self.handle_new_layout(new_layout_info);
} }
MixedMessage::FromConstellation(ResizeMsg(id, size)) => { MixedMessage::FromConstellation(ConstellationControlMsg::Resize(id, size)) => {
let page = self.page.borrow_mut(); let page = self.page.borrow_mut();
let page = page.find(id).expect("resize sent to nonexistent pipeline"); let page = page.find(id).expect("resize sent to nonexistent pipeline");
page.resize_event.set(Some(size)); page.resize_event.set(Some(size));
} }
MixedMessage::FromConstellation(ViewportMsg(id, rect)) => { MixedMessage::FromConstellation(ConstellationControlMsg::Viewport(id, rect)) => {
let page = self.page.borrow_mut(); let page = self.page.borrow_mut();
let inner_page = page.find(id).expect("Page rect message sent to nonexistent pipeline"); let inner_page = page.find(id).expect("Page rect message sent to nonexistent pipeline");
if inner_page.set_page_clip_rect_with_new_viewport(rect) { if inner_page.set_page_clip_rect_with_new_viewport(rect) {
@ -552,7 +547,7 @@ impl ScriptTask {
// Process the gathered events. // Process the gathered events.
for msg in sequential.into_iter() { for msg in sequential.into_iter() {
match msg { match msg {
MixedMessage::FromConstellation(ExitPipelineMsg(id, exit_type)) => { MixedMessage::FromConstellation(ConstellationControlMsg::ExitPipeline(id, exit_type)) => {
if self.handle_exit_pipeline_msg(id, exit_type) { if self.handle_exit_pipeline_msg(id, exit_type) {
return false return false
} }
@ -568,24 +563,23 @@ impl ScriptTask {
fn handle_msg_from_constellation(&self, msg: ConstellationControlMsg) { fn handle_msg_from_constellation(&self, msg: ConstellationControlMsg) {
match msg { match msg {
// TODO(tkuehn) need to handle auxiliary layouts for iframes ConstellationControlMsg::AttachLayout(_) =>
AttachLayoutMsg(_) => panic!("should have handled AttachLayout already"),
panic!("should have handled AttachLayoutMsg already"), ConstellationControlMsg::Load(id, load_data) =>
LoadMsg(id, load_data) =>
self.load(id, load_data), self.load(id, load_data),
SendEventMsg(id, event) => ConstellationControlMsg::SendEvent(id, event) =>
self.handle_event(id, event), self.handle_event(id, event),
ReflowCompleteMsg(id, reflow_id) => ConstellationControlMsg::ReflowComplete(id, reflow_id) =>
self.handle_reflow_complete_msg(id, reflow_id), self.handle_reflow_complete_msg(id, reflow_id),
ResizeInactiveMsg(id, new_size) => ConstellationControlMsg::ResizeInactive(id, new_size) =>
self.handle_resize_inactive_msg(id, new_size), self.handle_resize_inactive_msg(id, new_size),
ViewportMsg(..) => ConstellationControlMsg::Viewport(..) =>
panic!("should have handled ViewportMsg already"), panic!("should have handled Viewport already"),
ResizeMsg(..) => ConstellationControlMsg::Resize(..) =>
panic!("should have handled ResizeMsg already"), panic!("should have handled Resize already"),
ExitPipelineMsg(..) => ConstellationControlMsg::ExitPipeline(..) =>
panic!("should have handled ExitPipelineMsg already"), panic!("should have handled ExitPipeline already"),
GetTitleMsg(pipeline_id) => ConstellationControlMsg::GetTitle(pipeline_id) =>
self.handle_get_title_msg(pipeline_id), self.handle_get_title_msg(pipeline_id),
} }
} }

View file

@ -50,23 +50,23 @@ pub struct NewLayoutInfo {
/// Messages sent from the constellation to the script task /// Messages sent from the constellation to the script task
pub enum ConstellationControlMsg { pub enum ConstellationControlMsg {
/// Loads a new URL on the specified pipeline. /// Loads a new URL on the specified pipeline.
LoadMsg(PipelineId, LoadData), Load(PipelineId, LoadData),
/// Gives a channel and ID to a layout task, as well as the ID of that layout's parent /// Gives a channel and ID to a layout task, as well as the ID of that layout's parent
AttachLayoutMsg(NewLayoutInfo), AttachLayout(NewLayoutInfo),
/// Window resized. Sends a DOM event eventually, but first we combine events. /// Window resized. Sends a DOM event eventually, but first we combine events.
ResizeMsg(PipelineId, WindowSizeData), Resize(PipelineId, WindowSizeData),
/// Notifies script that window has been resized but to not take immediate action. /// Notifies script that window has been resized but to not take immediate action.
ResizeInactiveMsg(PipelineId, WindowSizeData), ResizeInactive(PipelineId, WindowSizeData),
/// Notifies the script that a pipeline should be closed. /// Notifies the script that a pipeline should be closed.
ExitPipelineMsg(PipelineId, PipelineExitType), ExitPipeline(PipelineId, PipelineExitType),
/// Sends a DOM event. /// Sends a DOM event.
SendEventMsg(PipelineId, CompositorEvent), SendEvent(PipelineId, CompositorEvent),
/// Notifies script that reflow is finished. /// Notifies script that reflow is finished.
ReflowCompleteMsg(PipelineId, uint), ReflowComplete(PipelineId, uint),
/// Notifies script of the viewport. /// Notifies script of the viewport.
ViewportMsg(PipelineId, Rect<f32>), Viewport(PipelineId, Rect<f32>),
/// Requests that the script task immediately send the constellation the title of a pipeline. /// Requests that the script task immediately send the constellation the title of a pipeline.
GetTitleMsg(PipelineId), GetTitle(PipelineId),
} }
/// Events from the compositor that the script task needs to know about /// Events from the compositor that the script task needs to know about