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

Remove ScriptControlChan.



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

View file

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