Separate script and layout messages, issue #8843

This commit is contained in:
Joe Kachmar 2015-12-13 13:31:20 -05:00
parent d2e7fd8221
commit 655268d111
11 changed files with 80 additions and 27 deletions

View file

@ -45,7 +45,7 @@ use profile_traits::mem;
use profile_traits::time;
use sandboxing;
use script_traits::{CompositorEvent, ConstellationControlMsg, LayoutControlMsg};
use script_traits::{ScriptMsg as FromScriptMsg, ScriptTaskFactory};
use script_traits::{LayoutMsg as FromLayoutMsg, ScriptMsg as FromScriptMsg, ScriptTaskFactory};
use script_traits::{TimerEventRequest};
use std::borrow::ToOwned;
use std::collections::HashMap;
@ -87,6 +87,9 @@ pub struct Constellation<LTF, STF> {
/// A channel through which compositor messages can be sent to this object.
pub compositor_sender: Sender<FromCompositorMsg>,
/// A channel through which layout task messages can be sent to this object.
pub layout_sender: ConstellationChan<FromLayoutMsg>,
/// A channel through which paint task messages can be sent to this object.
pub painter_sender: ConstellationChan<FromPaintMsg>,
@ -96,6 +99,9 @@ pub struct Constellation<LTF, STF> {
/// Receives messages from the compositor
pub compositor_receiver: Receiver<FromCompositorMsg>,
/// Receives messages from the layout task
pub layout_receiver: Receiver<FromLayoutMsg>,
/// Receives messages from paint task.
pub painter_receiver: Receiver<FromPaintMsg>,
@ -287,6 +293,8 @@ impl<LTF: LayoutTaskFactory, STF: ScriptTaskFactory> Constellation<LTF, STF> {
let (ipc_script_receiver, ipc_script_sender) = ConstellationChan::<FromScriptMsg>::new();
let script_receiver = ROUTER.route_ipc_receiver_to_new_mpsc_receiver(ipc_script_receiver);
let (compositor_sender, compositor_receiver) = channel();
let (ipc_layout_receiver, ipc_layout_sender) = ConstellationChan::<FromLayoutMsg>::new();
let layout_receiver = ROUTER.route_ipc_receiver_to_new_mpsc_receiver(ipc_layout_receiver);
let (ipc_painter_receiver, ipc_painter_sender) = ConstellationChan::<FromPaintMsg>::new();
let painter_receiver = ROUTER.route_ipc_receiver_to_new_mpsc_receiver(ipc_painter_receiver);
let compositor_sender_clone = compositor_sender.clone();
@ -294,9 +302,11 @@ impl<LTF: LayoutTaskFactory, STF: ScriptTaskFactory> Constellation<LTF, STF> {
let mut constellation: Constellation<LTF, STF> = Constellation {
script_sender: ipc_script_sender,
compositor_sender: compositor_sender_clone,
layout_sender: ipc_layout_sender,
painter_sender: ipc_painter_sender,
script_receiver: script_receiver,
compositor_receiver: compositor_receiver,
layout_receiver: layout_receiver,
painter_receiver: painter_receiver,
compositor_proxy: state.compositor_proxy,
devtools_chan: state.devtools_chan,
@ -371,6 +381,7 @@ impl<LTF: LayoutTaskFactory, STF: ScriptTaskFactory> Constellation<LTF, STF> {
id: pipeline_id,
parent_info: parent_info,
constellation_chan: self.script_sender.clone(),
layout_to_constellation_chan: self.layout_sender.clone(),
painter_chan: self.painter_sender.clone(),
scheduler_chan: self.scheduler_chan.clone(),
compositor_proxy: self.compositor_proxy.clone_compositor_proxy(),
@ -474,18 +485,22 @@ impl<LTF: LayoutTaskFactory, STF: ScriptTaskFactory> Constellation<LTF, STF> {
enum Request {
Script(FromScriptMsg),
Compositor(FromCompositorMsg),
Layout(FromLayoutMsg),
Paint(FromPaintMsg)
}
let request = {
let receiver_from_script = &self.script_receiver;
let receiver_from_compositor = &self.compositor_receiver;
let receiver_from_layout = &self.layout_receiver;
let receiver_from_paint = &self.painter_receiver;
select! {
msg = receiver_from_script.recv() =>
Request::Script(msg.unwrap()),
msg = receiver_from_compositor.recv() =>
Request::Compositor(msg.unwrap()),
msg = receiver_from_layout.recv() =>
Request::Layout(msg.unwrap()),
msg = receiver_from_paint.recv() =>
Request::Paint(msg.unwrap())
}
@ -577,9 +592,6 @@ impl<LTF: LayoutTaskFactory, STF: ScriptTaskFactory> Constellation<LTF, STF> {
load_info.new_subpage_id);
self.handle_script_loaded_url_in_iframe_msg(load_info);
}
Request::Script(FromScriptMsg::SetCursor(cursor)) => {
self.handle_set_cursor_msg(cursor)
}
Request::Script(FromScriptMsg::ChangeRunningAnimationsState(pipeline_id, animation_state)) => {
self.handle_change_running_animations_state(pipeline_id, animation_state)
}
@ -652,10 +664,6 @@ impl<LTF: LayoutTaskFactory, STF: ScriptTaskFactory> Constellation<LTF, STF> {
}
}
}
Request::Script(FromScriptMsg::ViewportConstrained(pipeline_id, constraints)) => {
debug!("constellation got viewport-constrained event message");
self.handle_viewport_constrained_msg(pipeline_id, constraints);
}
Request::Script(FromScriptMsg::RemoveIFrame(pipeline_id)) => {
debug!("constellation got remove iframe message");
self.handle_remove_iframe_msg(pipeline_id);
@ -686,6 +694,24 @@ impl<LTF: LayoutTaskFactory, STF: ScriptTaskFactory> Constellation<LTF, STF> {
}
// Messages from layout task
Request::Layout(FromLayoutMsg::ChangeRunningAnimationsState(pipeline_id, animation_state)) => {
self.handle_change_running_animations_state(pipeline_id, animation_state)
}
Request::Layout(FromLayoutMsg::Failure(Failure { pipeline_id, parent_info })) => {
debug!("handling paint failure message from pipeline {:?}, {:?}", pipeline_id, parent_info);
self.handle_failure_msg(pipeline_id, parent_info);
}
Request::Layout(FromLayoutMsg::SetCursor(cursor)) => {
self.handle_set_cursor_msg(cursor)
}
Request::Layout(FromLayoutMsg::ViewportConstrained(pipeline_id, constraints)) => {
debug!("constellation got viewport-constrained event message");
self.handle_viewport_constrained_msg(pipeline_id, constraints);
}
// Messages from paint task

View file

@ -24,7 +24,7 @@ use net_traits::storage_task::StorageTask;
use profile_traits::mem as profile_mem;
use profile_traits::time;
use script_traits::{ConstellationControlMsg, InitialScriptState};
use script_traits::{LayoutControlMsg, NewLayoutInfo, ScriptMsg as ConstellationMsg};
use script_traits::{LayoutControlMsg, LayoutMsg, NewLayoutInfo, ScriptMsg};
use script_traits::{ScriptToCompositorMsg, ScriptTaskFactory, TimerEventRequest};
use std::mem;
use std::sync::mpsc::{Receiver, Sender, channel};
@ -79,7 +79,9 @@ pub struct InitialPipelineState {
/// If `None`, this is the root.
pub parent_info: Option<(PipelineId, SubpageId)>,
/// A channel to the associated constellation.
pub constellation_chan: ConstellationChan<ConstellationMsg>,
pub constellation_chan: ConstellationChan<ScriptMsg>,
/// A channel for the layout task to send messages to the constellation.
pub layout_to_constellation_chan: ConstellationChan<LayoutMsg>,
/// A channel to the associated paint task.
pub painter_chan: ConstellationChan<PaintMsg>,
/// A channel to schedule timer events.
@ -207,6 +209,7 @@ impl Pipeline {
time_profiler_chan: state.time_profiler_chan.clone(),
mem_profiler_chan: state.mem_profiler_chan.clone(),
window_size: window_size,
layout_to_constellation_chan: state.layout_to_constellation_chan,
script_chan: script_chan,
load_data: state.load_data.clone(),
failure: failure,
@ -347,7 +350,8 @@ impl Pipeline {
pub struct UnprivilegedPipelineContent {
id: PipelineId,
parent_info: Option<(PipelineId, SubpageId)>,
constellation_chan: ConstellationChan<ConstellationMsg>,
constellation_chan: ConstellationChan<ScriptMsg>,
layout_to_constellation_chan: ConstellationChan<LayoutMsg>,
scheduler_chan: IpcSender<TimerEventRequest>,
devtools_chan: Option<IpcSender<ScriptToDevtoolsControlMsg>>,
script_to_compositor_chan: IpcSender<ScriptToCompositorMsg>,
@ -386,6 +390,7 @@ impl UnprivilegedPipelineContent {
control_chan: self.script_chan.clone(),
control_port: mem::replace(&mut self.script_port, None).unwrap(),
constellation_chan: self.constellation_chan.clone(),
layout_to_constellation_chan: self.layout_to_constellation_chan.clone(),
scheduler_chan: self.scheduler_chan.clone(),
failure_info: self.failure.clone(),
resource_task: self.resource_task,
@ -405,7 +410,7 @@ impl UnprivilegedPipelineContent {
self.parent_info.is_some(),
layout_pair,
self.pipeline_port.unwrap(),
self.constellation_chan,
self.layout_to_constellation_chan,
self.failure,
self.script_chan.clone(),
self.layout_to_paint_chan.clone(),