Uniformise the various Msg types [#5882]

This commit is contained in:
Prabhjyot Singh Sodhi 2015-04-29 19:54:22 +05:30
parent 5b0c6c9d31
commit b980278d90
9 changed files with 37 additions and 37 deletions

View file

@ -385,7 +385,7 @@ impl<LTF: LayoutTaskFactory, STF: ScriptTaskFactory> Constellation<LTF, STF> {
debug!("constellation got get-pipeline-title message"); debug!("constellation got get-pipeline-title message");
self.handle_get_pipeline_title_msg(pipeline_id); self.handle_get_pipeline_title_msg(pipeline_id);
} }
ConstellationMsg::MozBrowserEventMsg(pipeline_id, ConstellationMsg::MozBrowserEvent(pipeline_id,
subpage_id, subpage_id,
event) => { event) => {
debug!("constellation got mozbrowser event message"); debug!("constellation got mozbrowser event message");
@ -397,7 +397,7 @@ impl<LTF: LayoutTaskFactory, STF: ScriptTaskFactory> Constellation<LTF, STF> {
debug!("constellation got get root pipeline message"); debug!("constellation got get root pipeline message");
self.handle_get_root_pipeline(resp_chan); self.handle_get_root_pipeline(resp_chan);
} }
ConstellationMsg::FocusMsg(pipeline_id) => { 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);
} }
@ -411,7 +411,7 @@ impl<LTF: LayoutTaskFactory, STF: ScriptTaskFactory> Constellation<LTF, STF> {
}; };
sender.send(result).unwrap(); sender.send(result).unwrap();
} }
ConstellationMsg::WebDriverCommandMsg(pipeline_id, ConstellationMsg::WebDriverCommand(pipeline_id,
command) => { command) => {
debug!("constellation got webdriver command message"); debug!("constellation got webdriver command message");
self.handle_webdriver_command_msg(pipeline_id, self.handle_webdriver_command_msg(pipeline_id,
@ -569,7 +569,7 @@ impl<LTF: LayoutTaskFactory, STF: ScriptTaskFactory> Constellation<LTF, STF> {
self.pipeline(pipeline_id) self.pipeline(pipeline_id)
.layout_chan .layout_chan
.0 .0
.send(LayoutControlMsg::TickAnimationsMsg) .send(LayoutControlMsg::TickAnimations)
.unwrap(); .unwrap();
} }
@ -745,7 +745,7 @@ impl<LTF: LayoutTaskFactory, STF: ScriptTaskFactory> Constellation<LTF, STF> {
if let Some((containing_pipeline_id, subpage_id)) = self.pipeline(pipeline_id).parent_info { if let Some((containing_pipeline_id, subpage_id)) = self.pipeline(pipeline_id).parent_info {
let pipeline = self.pipeline(containing_pipeline_id); let pipeline = self.pipeline(containing_pipeline_id);
let ScriptControlChan(ref script_channel) = pipeline.script_chan; let ScriptControlChan(ref script_channel) = pipeline.script_chan;
let event = ConstellationControlMsg::FocusIFrameMsg(containing_pipeline_id, let event = ConstellationControlMsg::FocusIFrame(containing_pipeline_id,
subpage_id); subpage_id);
script_channel.send(event).unwrap(); script_channel.send(event).unwrap();
@ -766,7 +766,7 @@ impl<LTF: LayoutTaskFactory, STF: ScriptTaskFactory> Constellation<LTF, STF> {
// Find the script channel for the given parent pipeline, // Find the script channel for the given parent pipeline,
// and pass the event to that script task. // and pass the event to that script task.
let pipeline = self.pipeline(pipeline_id); let pipeline = self.pipeline(pipeline_id);
let control_msg = ConstellationControlMsg::WebDriverCommandMsg(pipeline_id, msg); let control_msg = ConstellationControlMsg::WebDriverCommand(pipeline_id, msg);
let ScriptControlChan(ref script_channel) = pipeline.script_chan; let ScriptControlChan(ref script_channel) = pipeline.script_chan;
script_channel.send(control_msg).unwrap(); script_channel.send(control_msg).unwrap();
} }

View file

@ -239,7 +239,7 @@ impl Pipeline {
let _ = self.paint_chan.send(PaintMsg::Exit(None, PipelineExitType::PipelineOnly)); let _ = self.paint_chan.send(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( let _ = layout_channel.send(
LayoutControlMsg::ExitNowMsg(PipelineExitType::PipelineOnly)).unwrap(); LayoutControlMsg::ExitNow(PipelineExitType::PipelineOnly)).unwrap();
} }
pub fn to_sendable(&self) -> CompositionPipeline { pub fn to_sendable(&self) -> CompositionPipeline {
@ -260,7 +260,7 @@ impl Pipeline {
assert!(opts::experimental_enabled()); assert!(opts::experimental_enabled());
let ScriptControlChan(ref script_channel) = self.script_chan; let ScriptControlChan(ref script_channel) = self.script_chan;
let event = ConstellationControlMsg::MozBrowserEventMsg(self.id, let event = ConstellationControlMsg::MozBrowserEvent(self.id,
subpage_id, subpage_id,
event); event);
script_channel.send(event).unwrap(); script_channel.send(event).unwrap();

View file

@ -404,10 +404,10 @@ impl LayoutTask {
match port_to_read { match port_to_read {
PortToRead::Pipeline => { PortToRead::Pipeline => {
match self.pipeline_port.recv().unwrap() { match self.pipeline_port.recv().unwrap() {
LayoutControlMsg::TickAnimationsMsg => { LayoutControlMsg::TickAnimations => {
self.handle_request_helper(Msg::TickAnimations, possibly_locked_rw_data) self.handle_request_helper(Msg::TickAnimations, possibly_locked_rw_data)
} }
LayoutControlMsg::ExitNowMsg(exit_type) => { LayoutControlMsg::ExitNow(exit_type) => {
self.handle_request_helper(Msg::ExitNow(exit_type), self.handle_request_helper(Msg::ExitNow(exit_type),
possibly_locked_rw_data) possibly_locked_rw_data)
} }
@ -516,7 +516,7 @@ impl LayoutTask {
return false return false
}, },
Msg::ExitNow(exit_type) => { Msg::ExitNow(exit_type) => {
debug!("layout: ExitNowMsg received"); debug!("layout: ExitNow received");
self.exit_now(possibly_locked_rw_data, exit_type); self.exit_now(possibly_locked_rw_data, exit_type);
return false return false
} }
@ -542,7 +542,7 @@ impl LayoutTask {
} }
/// Enters a quiescent state in which no new messages except for /// Enters a quiescent state in which no new messages except for
/// `layout_interface::Msg::ReapLayoutData` will be processed until an `ExitNowMsg` is /// `layout_interface::Msg::ReapLayoutData` will be processed until an `ExitNow` is
/// received. A pong is immediately sent on the given response channel. /// received. A pong is immediately sent on the given response channel.
fn prepare_to_exit<'a>(&'a self, fn prepare_to_exit<'a>(&'a self,
response_chan: Sender<()>, response_chan: Sender<()>,
@ -561,7 +561,7 @@ impl LayoutTask {
break break
} }
_ => { _ => {
panic!("layout: message that wasn't `ExitNowMsg` received after \ panic!("layout: message that wasn't `ExitNow` received after \
`PrepareToExitMsg`") `PrepareToExitMsg`")
} }
} }

View file

@ -28,8 +28,8 @@ use std::sync::mpsc::{Sender, Receiver};
/// Messages sent to the layout task from the constellation /// Messages sent to the layout task from the constellation
pub enum LayoutControlMsg { pub enum LayoutControlMsg {
ExitNowMsg(PipelineExitType), ExitNow(PipelineExitType),
TickAnimationsMsg, TickAnimations,
} }
/// A channel wrapper for constellation messages /// A channel wrapper for constellation messages

View file

@ -221,7 +221,7 @@ pub enum Msg {
/// Requests that the constellation inform the compositor of the a cursor change. /// Requests that the constellation inform the compositor of the a cursor change.
SetCursor(Cursor), SetCursor(Cursor),
/// Dispatch a mozbrowser event to a given iframe. Only available in experimental mode. /// Dispatch a mozbrowser event to a given iframe. Only available in experimental mode.
MozBrowserEventMsg(PipelineId, SubpageId, MozBrowserEvent), MozBrowserEvent(PipelineId, SubpageId, MozBrowserEvent),
/// Indicates whether this pipeline is currently running animations. /// Indicates whether this pipeline is currently running animations.
ChangeRunningAnimationsState(PipelineId, bool), ChangeRunningAnimationsState(PipelineId, bool),
/// Requests that the constellation instruct layout to begin a new tick of the animation. /// Requests that the constellation instruct layout to begin a new tick of the animation.
@ -229,11 +229,11 @@ pub enum Msg {
// Request that the constellation send the current root pipeline id over a provided channel // Request that the constellation send the current root pipeline id over a provided channel
GetRootPipeline(Sender<Option<PipelineId>>), GetRootPipeline(Sender<Option<PipelineId>>),
/// Notifies the constellation that this frame has received focus. /// Notifies the constellation that this frame has received focus.
FocusMsg(PipelineId), Focus(PipelineId),
/// Requests that the constellation retrieve the current contents of the clipboard /// Requests that the constellation retrieve the current contents of the clipboard
GetClipboardContents(Sender<String>), GetClipboardContents(Sender<String>),
// Dispatch a webdriver command // Dispatch a webdriver command
WebDriverCommandMsg(PipelineId, WebDriverScriptCommand) WebDriverCommand(PipelineId, WebDriverScriptCommand)
} }
// https://developer.mozilla.org/en-US/docs/Web/API/Using_the_Browser_API#Events // https://developer.mozilla.org/en-US/docs/Web/API/Using_the_Browser_API#Events

View file

@ -481,7 +481,7 @@ impl<'a> DocumentHelpers<'a> for JSRef<'a, Document> {
if focus_type == FocusType::Element { if focus_type == FocusType::Element {
let window = self.window.root(); let window = self.window.root();
let ConstellationChan(ref chan) = window.r().constellation_chan(); let ConstellationChan(ref chan) = window.r().constellation_chan();
let event = ConstellationMsg::FocusMsg(window.r().pipeline()); let event = ConstellationMsg::Focus(window.r().pipeline());
chan.send(event).unwrap(); chan.send(event).unwrap();
} }
} }
@ -769,7 +769,7 @@ impl<'a> DocumentHelpers<'a> for JSRef<'a, Document> {
if let Some((containing_pipeline_id, subpage_id)) = window.r().parent_info() { if let Some((containing_pipeline_id, subpage_id)) = window.r().parent_info() {
let ConstellationChan(ref chan) = window.r().constellation_chan(); let ConstellationChan(ref chan) = window.r().constellation_chan();
let event = ConstellationMsg::MozBrowserEventMsg(containing_pipeline_id, let event = ConstellationMsg::MozBrowserEvent(containing_pipeline_id,
subpage_id, subpage_id,
event); event);
chan.send(event).unwrap(); chan.send(event).unwrap();

View file

@ -718,7 +718,7 @@ impl ScriptTask {
self.handle_freeze_msg(pipeline_id), self.handle_freeze_msg(pipeline_id),
ConstellationControlMsg::Thaw(pipeline_id) => ConstellationControlMsg::Thaw(pipeline_id) =>
self.handle_thaw_msg(pipeline_id), self.handle_thaw_msg(pipeline_id),
ConstellationControlMsg::MozBrowserEventMsg(parent_pipeline_id, ConstellationControlMsg::MozBrowserEvent(parent_pipeline_id,
subpage_id, subpage_id,
event) => event) =>
self.handle_mozbrowser_event_msg(parent_pipeline_id, self.handle_mozbrowser_event_msg(parent_pipeline_id,
@ -728,9 +728,9 @@ impl ScriptTask {
old_subpage_id, old_subpage_id,
new_subpage_id) => new_subpage_id) =>
self.handle_update_subpage_id(containing_pipeline_id, old_subpage_id, new_subpage_id), self.handle_update_subpage_id(containing_pipeline_id, old_subpage_id, new_subpage_id),
ConstellationControlMsg::FocusIFrameMsg(containing_pipeline_id, subpage_id) => ConstellationControlMsg::FocusIFrame(containing_pipeline_id, subpage_id) =>
self.handle_focus_iframe_msg(containing_pipeline_id, subpage_id), self.handle_focus_iframe_msg(containing_pipeline_id, subpage_id),
ConstellationControlMsg::WebDriverCommandMsg(pipeline_id, msg) => { ConstellationControlMsg::WebDriverCommand(pipeline_id, msg) => {
self.handle_webdriver_msg(pipeline_id, msg); self.handle_webdriver_msg(pipeline_id, msg);
} }
} }

View file

@ -72,13 +72,13 @@ pub enum ConstellationControlMsg {
/// Notifies script task that a url should be loaded in this iframe. /// Notifies script task that a url should be loaded in this iframe.
Navigate(PipelineId, SubpageId, LoadData), Navigate(PipelineId, SubpageId, LoadData),
/// Requests the script task forward a mozbrowser event to an iframe it owns /// Requests the script task forward a mozbrowser event to an iframe it owns
MozBrowserEventMsg(PipelineId, SubpageId, MozBrowserEvent), MozBrowserEvent(PipelineId, SubpageId, MozBrowserEvent),
/// Updates the current subpage id of a given iframe /// Updates the current subpage id of a given iframe
UpdateSubpageId(PipelineId, SubpageId, SubpageId), UpdateSubpageId(PipelineId, SubpageId, SubpageId),
/// Set an iframe to be focused. Used when an element in an iframe gains focus. /// Set an iframe to be focused. Used when an element in an iframe gains focus.
FocusIFrameMsg(PipelineId, SubpageId), FocusIFrame(PipelineId, SubpageId),
// Passes a webdriver command to the script task for execution // Passes a webdriver command to the script task for execution
WebDriverCommandMsg(PipelineId, WebDriverScriptCommand) WebDriverCommand(PipelineId, WebDriverScriptCommand)
} }
/// The mouse button involved in the event. /// The mouse button involved in the event.

View file

@ -133,7 +133,7 @@ impl Handler {
let (sender, reciever) = channel(); let (sender, reciever) = channel();
let ConstellationChan(ref const_chan) = self.constellation_chan; let ConstellationChan(ref const_chan) = self.constellation_chan;
const_chan.send(ConstellationMsg::WebDriverCommandMsg(pipeline_id, const_chan.send(ConstellationMsg::WebDriverCommand(pipeline_id,
WebDriverScriptCommand::EvaluateJS(script, sender))).unwrap(); WebDriverScriptCommand::EvaluateJS(script, sender))).unwrap();
match reciever.recv().unwrap() { match reciever.recv().unwrap() {