mirror of
https://github.com/servo/servo.git
synced 2025-08-03 12:40:06 +01:00
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:
commit
3ad49fc689
12 changed files with 55 additions and 85 deletions
|
@ -39,7 +39,7 @@ use msg::constellation_msg::{PipelineId, WindowSizeData};
|
|||
use png;
|
||||
use profile_traits::mem::{self, Reporter, ReporterRequest, ReportKind};
|
||||
use profile_traits::time::{self, ProfilerCategory, profile};
|
||||
use script_traits::{ConstellationControlMsg, LayoutControlMsg, ScriptControlChan};
|
||||
use script_traits::{ConstellationControlMsg, LayoutControlMsg};
|
||||
use std::collections::HashMap;
|
||||
use std::collections::hash_map::Entry::{Occupied, Vacant};
|
||||
use std::mem as std_mem;
|
||||
|
@ -1278,8 +1278,7 @@ impl<Window: WindowMethods> IOCompositor<Window> {
|
|||
let layer_rect = Rect::new(-layer.extra_data.borrow().scroll_offset.to_untyped(),
|
||||
layer.bounds.borrow().size.to_untyped());
|
||||
let pipeline = self.get_pipeline(layer.pipeline_id());
|
||||
let ScriptControlChan(ref chan) = pipeline.script_chan;
|
||||
chan.send(ConstellationControlMsg::Viewport(pipeline.id.clone(), layer_rect)).unwrap();
|
||||
pipeline.script_chan.send(ConstellationControlMsg::Viewport(pipeline.id.clone(), layer_rect)).unwrap();
|
||||
}
|
||||
|
||||
for kid in layer.children().iter() {
|
||||
|
|
|
@ -14,7 +14,7 @@ use layers::color::Color;
|
|||
use layers::geometry::LayerPixel;
|
||||
use layers::layers::{Layer, LayerBufferSet};
|
||||
use script_traits::CompositorEvent::{ClickEvent, MouseDownEvent, MouseMoveEvent, MouseUpEvent};
|
||||
use script_traits::{ScriptControlChan, ConstellationControlMsg};
|
||||
use script_traits::ConstellationControlMsg;
|
||||
use msg::compositor_msg::{Epoch, LayerId, LayerProperties, ScrollPolicy};
|
||||
use msg::constellation_msg::PipelineId;
|
||||
use std::rc::Rc;
|
||||
|
@ -360,8 +360,7 @@ impl CompositorLayer for Layer<CompositorData> {
|
|||
};
|
||||
|
||||
let pipeline = compositor.get_pipeline(self.pipeline_id());
|
||||
let ScriptControlChan(ref chan) = pipeline.script_chan;
|
||||
let _ = chan.send(ConstellationControlMsg::SendEvent(pipeline.id.clone(), message));
|
||||
let _ = pipeline.script_chan.send(ConstellationControlMsg::SendEvent(pipeline.id.clone(), message));
|
||||
}
|
||||
|
||||
fn send_mouse_move_event<Window>(&self,
|
||||
|
@ -370,8 +369,7 @@ impl CompositorLayer for Layer<CompositorData> {
|
|||
where Window: WindowMethods {
|
||||
let message = MouseMoveEvent(cursor.to_untyped());
|
||||
let pipeline = compositor.get_pipeline(self.pipeline_id());
|
||||
let ScriptControlChan(ref chan) = pipeline.script_chan;
|
||||
let _ = chan.send(ConstellationControlMsg::SendEvent(pipeline.id.clone(), message));
|
||||
let _ = pipeline.script_chan.send(ConstellationControlMsg::SendEvent(pipeline.id.clone(), message));
|
||||
}
|
||||
|
||||
fn scroll_layer_and_all_child_layers(&self, new_offset: TypedPoint2D<LayerPixel, f32>)
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
|
||||
use CompositorProxy;
|
||||
use layout_traits::{LayoutTaskFactory, LayoutControlChan};
|
||||
use script_traits::{LayoutControlMsg, ScriptControlChan, ScriptTaskFactory};
|
||||
use script_traits::{LayoutControlMsg, ScriptTaskFactory};
|
||||
use script_traits::{NewLayoutInfo, ConstellationControlMsg};
|
||||
|
||||
use compositor_task;
|
||||
|
@ -38,7 +38,7 @@ use util::opts;
|
|||
pub struct Pipeline {
|
||||
pub id: PipelineId,
|
||||
pub parent_info: Option<(PipelineId, SubpageId)>,
|
||||
pub script_chan: ScriptControlChan,
|
||||
pub script_chan: Sender<ConstellationControlMsg>,
|
||||
/// A channel to layout, for performing reflows and shutdown.
|
||||
pub layout_chan: LayoutControlChan,
|
||||
pub chrome_to_paint_chan: Sender<ChromeToPaintMsg>,
|
||||
|
@ -59,7 +59,7 @@ pub struct Pipeline {
|
|||
#[derive(Clone)]
|
||||
pub struct CompositionPipeline {
|
||||
pub id: PipelineId,
|
||||
pub script_chan: ScriptControlChan,
|
||||
pub script_chan: Sender<ConstellationControlMsg>,
|
||||
pub layout_chan: LayoutControlChan,
|
||||
pub chrome_to_paint_chan: Sender<ChromeToPaintMsg>,
|
||||
}
|
||||
|
@ -80,7 +80,7 @@ impl Pipeline {
|
|||
time_profiler_chan: time::ProfilerChan,
|
||||
mem_profiler_chan: profile_mem::ProfilerChan,
|
||||
window_rect: Option<TypedRect<PagePx, f32>>,
|
||||
script_chan: Option<ScriptControlChan>,
|
||||
script_chan: Option<Sender<ConstellationControlMsg>>,
|
||||
load_data: LoadData,
|
||||
device_pixel_ratio: ScaleFactor<ViewportPx, DevicePixel, f32>)
|
||||
-> (Pipeline, PipelineContent)
|
||||
|
@ -131,14 +131,13 @@ impl Pipeline {
|
|||
layout_shutdown_chan: layout_shutdown_chan.clone(),
|
||||
};
|
||||
|
||||
script_chan.0
|
||||
.send(ConstellationControlMsg::AttachLayout(new_layout_info))
|
||||
script_chan.send(ConstellationControlMsg::AttachLayout(new_layout_info))
|
||||
.unwrap();
|
||||
(script_chan, None)
|
||||
}
|
||||
None => {
|
||||
let (script_chan, script_port) = channel();
|
||||
(ScriptControlChan(script_chan), Some(script_port))
|
||||
(script_chan, Some(script_port))
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -183,7 +182,7 @@ impl Pipeline {
|
|||
|
||||
pub fn new(id: PipelineId,
|
||||
parent_info: Option<(PipelineId, SubpageId)>,
|
||||
script_chan: ScriptControlChan,
|
||||
script_chan: Sender<ConstellationControlMsg>,
|
||||
layout_chan: LayoutControlChan,
|
||||
chrome_to_paint_chan: Sender<ChromeToPaintMsg>,
|
||||
layout_shutdown_port: Receiver<()>,
|
||||
|
@ -221,8 +220,7 @@ impl Pipeline {
|
|||
|
||||
// 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.
|
||||
let ScriptControlChan(ref chan) = self.script_chan;
|
||||
if chan.send(ConstellationControlMsg::ExitPipeline(self.id, exit_type)).is_ok() {
|
||||
if self.script_chan.send(ConstellationControlMsg::ExitPipeline(self.id, exit_type)).is_ok() {
|
||||
// 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
|
||||
let _ = self.paint_shutdown_port.recv();
|
||||
|
@ -232,18 +230,15 @@ impl Pipeline {
|
|||
}
|
||||
|
||||
pub fn freeze(&self) {
|
||||
let ScriptControlChan(ref script_channel) = self.script_chan;
|
||||
let _ = script_channel.send(ConstellationControlMsg::Freeze(self.id)).unwrap();
|
||||
let _ = self.script_chan.send(ConstellationControlMsg::Freeze(self.id)).unwrap();
|
||||
}
|
||||
|
||||
pub fn thaw(&self) {
|
||||
let ScriptControlChan(ref script_channel) = self.script_chan;
|
||||
let _ = script_channel.send(ConstellationControlMsg::Thaw(self.id)).unwrap();
|
||||
let _ = self.script_chan.send(ConstellationControlMsg::Thaw(self.id)).unwrap();
|
||||
}
|
||||
|
||||
pub fn force_exit(&self) {
|
||||
let ScriptControlChan(ref script_channel) = self.script_chan;
|
||||
let _ = script_channel.send(
|
||||
let _ = self.script_chan.send(
|
||||
ConstellationControlMsg::ExitPipeline(self.id,
|
||||
PipelineExitType::PipelineOnly)).unwrap();
|
||||
let _ = self.chrome_to_paint_chan.send(ChromeToPaintMsg::Exit(
|
||||
|
@ -277,11 +272,10 @@ impl Pipeline {
|
|||
event: MozBrowserEvent) {
|
||||
assert!(opts::experimental_enabled());
|
||||
|
||||
let ScriptControlChan(ref script_channel) = self.script_chan;
|
||||
let event = ConstellationControlMsg::MozBrowserEvent(self.id,
|
||||
subpage_id,
|
||||
event);
|
||||
script_channel.send(event).unwrap();
|
||||
self.script_chan.send(event).unwrap();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -298,7 +292,7 @@ pub struct PipelineContent {
|
|||
time_profiler_chan: time::ProfilerChan,
|
||||
mem_profiler_chan: profile_mem::ProfilerChan,
|
||||
window_size: Option<WindowSizeData>,
|
||||
script_chan: ScriptControlChan,
|
||||
script_chan: Sender<ConstellationControlMsg>,
|
||||
load_data: LoadData,
|
||||
failure: Failure,
|
||||
script_port: Option<Receiver<ConstellationControlMsg>>,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue