mirror of
https://github.com/servo/servo.git
synced 2025-08-07 06:25:32 +01:00
Store a Sender<ConstellationControlMsg> in Pipeline.
This commit is contained in:
parent
fafcc0a5da
commit
250fdc33f4
2 changed files with 20 additions and 34 deletions
|
@ -606,7 +606,6 @@ impl<LTF: LayoutTaskFactory, STF: ScriptTaskFactory> Constellation<LTF, STF> {
|
||||||
(pipeline.id, pipeline.script_chan.clone())
|
(pipeline.id, pipeline.script_chan.clone())
|
||||||
};
|
};
|
||||||
|
|
||||||
let ScriptControlChan(ref script_chan) = script_chan;
|
|
||||||
script_chan.send(ConstellationControlMsg::Resize(pipeline_id, WindowSizeData {
|
script_chan.send(ConstellationControlMsg::Resize(pipeline_id, WindowSizeData {
|
||||||
visible_viewport: rect.size,
|
visible_viewport: rect.size,
|
||||||
initial_viewport: rect.size * ScaleFactor::new(1.0),
|
initial_viewport: rect.size * ScaleFactor::new(1.0),
|
||||||
|
@ -649,7 +648,7 @@ impl<LTF: LayoutTaskFactory, STF: ScriptTaskFactory> Constellation<LTF, STF> {
|
||||||
if same_script {
|
if same_script {
|
||||||
debug!("Constellation: loading same-origin iframe, \
|
debug!("Constellation: loading same-origin iframe, \
|
||||||
parent url {:?}, iframe url {:?}", source_url, url);
|
parent url {:?}, iframe url {:?}", source_url, url);
|
||||||
Some(source_pipeline.script_chan.clone())
|
Some(ScriptControlChan(source_pipeline.script_chan.clone()))
|
||||||
} else {
|
} else {
|
||||||
debug!("Constellation: loading cross-origin iframe, \
|
debug!("Constellation: loading cross-origin iframe, \
|
||||||
parent url {:?}, iframe url {:?}", source_url, url);
|
parent url {:?}, iframe url {:?}", source_url, url);
|
||||||
|
@ -706,7 +705,7 @@ impl<LTF: LayoutTaskFactory, STF: ScriptTaskFactory> Constellation<LTF, STF> {
|
||||||
// Message the constellation to find the script task for this iframe
|
// Message the constellation to find the script task for this iframe
|
||||||
// and issue an iframe load through there.
|
// and issue an iframe load through there.
|
||||||
let parent_pipeline = self.pipeline(parent_pipeline_id);
|
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,
|
script_channel.send(ConstellationControlMsg::Navigate(parent_pipeline_id,
|
||||||
subpage_id,
|
subpage_id,
|
||||||
load_data)).unwrap();
|
load_data)).unwrap();
|
||||||
|
@ -837,7 +836,7 @@ impl<LTF: LayoutTaskFactory, STF: ScriptTaskFactory> Constellation<LTF, STF> {
|
||||||
// Update the owning iframe to point to the new subpage id.
|
// Update the owning iframe to point to the new subpage id.
|
||||||
// This makes things like contentDocument work correctly.
|
// This makes things like contentDocument work correctly.
|
||||||
if let Some((parent_pipeline_id, subpage_id)) = pipeline_info {
|
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();
|
let (_, new_subpage_id) = self.pipeline(next_pipeline_id).parent_info.unwrap();
|
||||||
script_chan.send(ConstellationControlMsg::UpdateSubpageId(parent_pipeline_id,
|
script_chan.send(ConstellationControlMsg::UpdateSubpageId(parent_pipeline_id,
|
||||||
subpage_id,
|
subpage_id,
|
||||||
|
@ -860,10 +859,9 @@ impl<LTF: LayoutTaskFactory, STF: ScriptTaskFactory> Constellation<LTF, STF> {
|
||||||
match target_pipeline_id {
|
match target_pipeline_id {
|
||||||
Some(target_pipeline_id) => {
|
Some(target_pipeline_id) => {
|
||||||
let pipeline = self.pipeline(target_pipeline_id);
|
let pipeline = self.pipeline(target_pipeline_id);
|
||||||
let ScriptControlChan(ref chan) = pipeline.script_chan;
|
|
||||||
let event = CompositorEvent::KeyEvent(key, state, mods);
|
let event = CompositorEvent::KeyEvent(key, state, mods);
|
||||||
chan.send(ConstellationControlMsg::SendEvent(pipeline.id,
|
pipeline.script_chan.send(
|
||||||
event)).unwrap();
|
ConstellationControlMsg::SendEvent(pipeline.id, event)).unwrap();
|
||||||
}
|
}
|
||||||
None => {
|
None => {
|
||||||
let event = CompositorMsg::KeyEvent(key, state, mods);
|
let event = CompositorMsg::KeyEvent(key, state, mods);
|
||||||
|
@ -876,8 +874,7 @@ impl<LTF: LayoutTaskFactory, STF: ScriptTaskFactory> Constellation<LTF, STF> {
|
||||||
match self.pipelines.get(&pipeline_id) {
|
match self.pipelines.get(&pipeline_id) {
|
||||||
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;
|
pipeline.script_chan.send(ConstellationControlMsg::GetTitle(pipeline_id)).unwrap();
|
||||||
script_channel.send(ConstellationControlMsg::GetTitle(pipeline_id)).unwrap();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -920,10 +917,9 @@ impl<LTF: LayoutTaskFactory, STF: ScriptTaskFactory> Constellation<LTF, STF> {
|
||||||
// telling it to mark the iframe element as focused.
|
// telling it to mark the iframe element as focused.
|
||||||
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 event = ConstellationControlMsg::FocusIFrame(containing_pipeline_id,
|
let event = ConstellationControlMsg::FocusIFrame(containing_pipeline_id,
|
||||||
subpage_id);
|
subpage_id);
|
||||||
script_channel.send(event).unwrap();
|
pipeline.script_chan.send(event).unwrap();
|
||||||
|
|
||||||
self.focus_parent_pipeline(containing_pipeline_id);
|
self.focus_parent_pipeline(containing_pipeline_id);
|
||||||
}
|
}
|
||||||
|
@ -997,8 +993,7 @@ impl<LTF: LayoutTaskFactory, STF: ScriptTaskFactory> Constellation<LTF, STF> {
|
||||||
WebDriverCommandMsg::ScriptCommand(pipeline_id, cmd) => {
|
WebDriverCommandMsg::ScriptCommand(pipeline_id, cmd) => {
|
||||||
let pipeline = self.pipeline(pipeline_id);
|
let pipeline = self.pipeline(pipeline_id);
|
||||||
let control_msg = ConstellationControlMsg::WebDriverScriptCommand(pipeline_id, cmd);
|
let control_msg = ConstellationControlMsg::WebDriverScriptCommand(pipeline_id, cmd);
|
||||||
let ScriptControlChan(ref script_channel) = pipeline.script_chan;
|
pipeline.script_chan.send(control_msg).unwrap();
|
||||||
script_channel.send(control_msg).unwrap();
|
|
||||||
},
|
},
|
||||||
WebDriverCommandMsg::TakeScreenshot(pipeline_id, reply) => {
|
WebDriverCommandMsg::TakeScreenshot(pipeline_id, reply) => {
|
||||||
let current_pipeline_id = self.root_frame_id.map(|frame_id| {
|
let current_pipeline_id = self.root_frame_id.map(|frame_id| {
|
||||||
|
@ -1143,13 +1138,11 @@ impl<LTF: LayoutTaskFactory, STF: ScriptTaskFactory> Constellation<LTF, STF> {
|
||||||
let frame = self.frames.get(&root_frame_id).unwrap();
|
let frame = self.frames.get(&root_frame_id).unwrap();
|
||||||
|
|
||||||
let pipeline = self.pipelines.get(&frame.current).unwrap();
|
let pipeline = self.pipelines.get(&frame.current).unwrap();
|
||||||
let ScriptControlChan(ref chan) = pipeline.script_chan;
|
let _ = pipeline.script_chan.send(ConstellationControlMsg::Resize(pipeline.id, new_size));
|
||||||
let _ = chan.send(ConstellationControlMsg::Resize(pipeline.id, new_size));
|
|
||||||
|
|
||||||
for pipeline_id in frame.prev.iter().chain(frame.next.iter()) {
|
for pipeline_id in frame.prev.iter().chain(frame.next.iter()) {
|
||||||
let pipeline = self.pipelines.get(pipeline_id).unwrap();
|
let pipeline = self.pipelines.get(pipeline_id).unwrap();
|
||||||
let ScriptControlChan(ref chan) = pipeline.script_chan;
|
let _ = pipeline.script_chan.send(ConstellationControlMsg::ResizeInactive(pipeline.id, new_size));
|
||||||
let _ = chan.send(ConstellationControlMsg::ResizeInactive(pipeline.id, new_size));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1157,8 +1150,7 @@ impl<LTF: LayoutTaskFactory, STF: ScriptTaskFactory> Constellation<LTF, STF> {
|
||||||
for pending_frame in &self.pending_frames {
|
for pending_frame in &self.pending_frames {
|
||||||
let pipeline = self.pipelines.get(&pending_frame.new_pipeline_id).unwrap();
|
let pipeline = self.pipelines.get(&pending_frame.new_pipeline_id).unwrap();
|
||||||
if pipeline.parent_info.is_none() {
|
if pipeline.parent_info.is_none() {
|
||||||
let ScriptControlChan(ref chan) = pipeline.script_chan;
|
let _ = pipeline.script_chan.send(ConstellationControlMsg::Resize(pipeline.id, new_size));
|
||||||
let _ = chan.send(ConstellationControlMsg::Resize(pipeline.id, new_size));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1198,10 +1190,9 @@ impl<LTF: LayoutTaskFactory, STF: ScriptTaskFactory> Constellation<LTF, STF> {
|
||||||
|
|
||||||
// Synchronously query the script task for this pipeline
|
// Synchronously query the script task for this pipeline
|
||||||
// to see if it is idle.
|
// to see if it is idle.
|
||||||
let ScriptControlChan(ref script_chan) = pipeline.script_chan;
|
|
||||||
let (sender, receiver) = channel();
|
let (sender, receiver) = channel();
|
||||||
let msg = ConstellationControlMsg::GetCurrentState(sender, frame.current);
|
let msg = ConstellationControlMsg::GetCurrentState(sender, frame.current);
|
||||||
script_chan.send(msg).unwrap();
|
pipeline.script_chan.send(msg).unwrap();
|
||||||
if receiver.recv().unwrap() == ScriptState::DocumentLoading {
|
if receiver.recv().unwrap() == ScriptState::DocumentLoading {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
|
@ -38,7 +38,7 @@ use util::opts;
|
||||||
pub struct Pipeline {
|
pub struct Pipeline {
|
||||||
pub id: PipelineId,
|
pub id: PipelineId,
|
||||||
pub parent_info: Option<(PipelineId, SubpageId)>,
|
pub parent_info: Option<(PipelineId, SubpageId)>,
|
||||||
pub script_chan: ScriptControlChan,
|
pub script_chan: Sender<ConstellationControlMsg>,
|
||||||
/// A channel to layout, for performing reflows and shutdown.
|
/// A channel to layout, for performing reflows and shutdown.
|
||||||
pub layout_chan: LayoutControlChan,
|
pub layout_chan: LayoutControlChan,
|
||||||
pub chrome_to_paint_chan: Sender<ChromeToPaintMsg>,
|
pub chrome_to_paint_chan: Sender<ChromeToPaintMsg>,
|
||||||
|
@ -194,7 +194,7 @@ impl Pipeline {
|
||||||
Pipeline {
|
Pipeline {
|
||||||
id: id,
|
id: id,
|
||||||
parent_info: parent_info,
|
parent_info: parent_info,
|
||||||
script_chan: script_chan,
|
script_chan: script_chan.0,
|
||||||
layout_chan: layout_chan,
|
layout_chan: layout_chan,
|
||||||
chrome_to_paint_chan: chrome_to_paint_chan,
|
chrome_to_paint_chan: chrome_to_paint_chan,
|
||||||
layout_shutdown_port: layout_shutdown_port,
|
layout_shutdown_port: layout_shutdown_port,
|
||||||
|
@ -221,8 +221,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;
|
if self.script_chan.send(ConstellationControlMsg::ExitPipeline(self.id, exit_type)).is_ok() {
|
||||||
if chan.send(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();
|
let _ = self.paint_shutdown_port.recv();
|
||||||
|
@ -232,18 +231,15 @@ impl Pipeline {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn freeze(&self) {
|
pub fn freeze(&self) {
|
||||||
let ScriptControlChan(ref script_channel) = self.script_chan;
|
let _ = self.script_chan.send(ConstellationControlMsg::Freeze(self.id)).unwrap();
|
||||||
let _ = script_channel.send(ConstellationControlMsg::Freeze(self.id)).unwrap();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn thaw(&self) {
|
pub fn thaw(&self) {
|
||||||
let ScriptControlChan(ref script_channel) = self.script_chan;
|
let _ = self.script_chan.send(ConstellationControlMsg::Thaw(self.id)).unwrap();
|
||||||
let _ = script_channel.send(ConstellationControlMsg::Thaw(self.id)).unwrap();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn force_exit(&self) {
|
pub fn force_exit(&self) {
|
||||||
let ScriptControlChan(ref script_channel) = self.script_chan;
|
let _ = self.script_chan.send(
|
||||||
let _ = script_channel.send(
|
|
||||||
ConstellationControlMsg::ExitPipeline(self.id,
|
ConstellationControlMsg::ExitPipeline(self.id,
|
||||||
PipelineExitType::PipelineOnly)).unwrap();
|
PipelineExitType::PipelineOnly)).unwrap();
|
||||||
let _ = self.chrome_to_paint_chan.send(ChromeToPaintMsg::Exit(
|
let _ = self.chrome_to_paint_chan.send(ChromeToPaintMsg::Exit(
|
||||||
|
@ -257,7 +253,7 @@ impl Pipeline {
|
||||||
pub fn to_sendable(&self) -> CompositionPipeline {
|
pub fn to_sendable(&self) -> CompositionPipeline {
|
||||||
CompositionPipeline {
|
CompositionPipeline {
|
||||||
id: self.id.clone(),
|
id: self.id.clone(),
|
||||||
script_chan: self.script_chan.0.clone(),
|
script_chan: self.script_chan.clone(),
|
||||||
layout_chan: self.layout_chan.clone(),
|
layout_chan: self.layout_chan.clone(),
|
||||||
chrome_to_paint_chan: self.chrome_to_paint_chan.clone(),
|
chrome_to_paint_chan: self.chrome_to_paint_chan.clone(),
|
||||||
}
|
}
|
||||||
|
@ -277,11 +273,10 @@ impl Pipeline {
|
||||||
event: MozBrowserEvent) {
|
event: MozBrowserEvent) {
|
||||||
assert!(opts::experimental_enabled());
|
assert!(opts::experimental_enabled());
|
||||||
|
|
||||||
let ScriptControlChan(ref script_channel) = self.script_chan;
|
|
||||||
let event = ConstellationControlMsg::MozBrowserEvent(self.id,
|
let event = ConstellationControlMsg::MozBrowserEvent(self.id,
|
||||||
subpage_id,
|
subpage_id,
|
||||||
event);
|
event);
|
||||||
script_channel.send(event).unwrap();
|
self.script_chan.send(event).unwrap();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue