aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--components/compositing/constellation.rs51
-rw-r--r--components/servo/lib.rs26
2 files changed, 47 insertions, 30 deletions
diff --git a/components/compositing/constellation.rs b/components/compositing/constellation.rs
index bc2a385b712..46088f4dc09 100644
--- a/components/compositing/constellation.rs
+++ b/components/compositing/constellation.rs
@@ -139,6 +139,28 @@ pub struct Constellation<LTF, STF> {
webgl_paint_tasks: Vec<Sender<CanvasMsg>>,
}
+/// State needed to construct a constellation.
+pub struct InitialConstellationState {
+ /// A channel through which messages can be sent to the compositor.
+ pub compositor_proxy: Box<CompositorProxy + Send>,
+ /// A channel to the developer tools, if applicable.
+ pub devtools_chan: Option<Sender<DevtoolsControlMsg>>,
+ /// A channel to the image cache task.
+ pub image_cache_task: ImageCacheTask,
+ /// A channel to the font cache task.
+ pub font_cache_task: FontCacheTask,
+ /// A channel to the resource task.
+ pub resource_task: ResourceTask,
+ /// A channel to the storage task.
+ pub storage_task: StorageTask,
+ /// A channel to the time profiler thread.
+ pub time_profiler_chan: time::ProfilerChan,
+ /// A channel to the memory profiler thread.
+ pub mem_profiler_chan: mem::ProfilerChan,
+ /// Whether the constellation supports the clipboard.
+ pub supports_clipboard: bool,
+}
+
/// Stores the navigation context for a single frame in the frame tree.
pub struct Frame {
prev: Vec<PipelineId>,
@@ -219,28 +241,19 @@ enum ExitPipelineMode {
}
impl<LTF: LayoutTaskFactory, STF: ScriptTaskFactory> Constellation<LTF, STF> {
- pub fn start(compositor_proxy: Box<CompositorProxy + Send>,
- resource_task: ResourceTask,
- image_cache_task: ImageCacheTask,
- font_cache_task: FontCacheTask,
- time_profiler_chan: time::ProfilerChan,
- mem_profiler_chan: mem::ProfilerChan,
- devtools_chan: Option<Sender<DevtoolsControlMsg>>,
- storage_task: StorageTask,
- supports_clipboard: bool)
- -> ConstellationChan {
+ pub fn start(state: InitialConstellationState) -> ConstellationChan {
let (constellation_port, constellation_chan) = ConstellationChan::new();
let constellation_chan_clone = constellation_chan.clone();
spawn_named("Constellation".to_owned(), move || {
let mut constellation: Constellation<LTF, STF> = Constellation {
chan: constellation_chan_clone,
request_port: constellation_port,
- compositor_proxy: compositor_proxy,
- devtools_chan: devtools_chan,
- resource_task: resource_task,
- image_cache_task: image_cache_task,
- font_cache_task: font_cache_task,
- storage_task: storage_task,
+ compositor_proxy: state.compositor_proxy,
+ devtools_chan: state.devtools_chan,
+ resource_task: state.resource_task,
+ image_cache_task: state.image_cache_task,
+ font_cache_task: state.font_cache_task,
+ storage_task: state.storage_task,
pipelines: HashMap::new(),
frames: HashMap::new(),
pipeline_to_frame_map: HashMap::new(),
@@ -250,8 +263,8 @@ impl<LTF: LayoutTaskFactory, STF: ScriptTaskFactory> Constellation<LTF, STF> {
root_frame_id: None,
next_frame_id: FrameId(0),
focus_pipeline_id: None,
- time_profiler_chan: time_profiler_chan,
- mem_profiler_chan: mem_profiler_chan,
+ time_profiler_chan: state.time_profiler_chan,
+ mem_profiler_chan: state.mem_profiler_chan,
window_size: WindowSizeData {
visible_viewport: opts::get().initial_window_size.as_f32() *
ScaleFactor::new(1.0),
@@ -260,7 +273,7 @@ impl<LTF: LayoutTaskFactory, STF: ScriptTaskFactory> Constellation<LTF, STF> {
device_pixel_ratio: ScaleFactor::new(1.0),
},
phantom: PhantomData,
- clipboard_ctx: if supports_clipboard {
+ clipboard_ctx: if state.supports_clipboard {
ClipboardContext::new().ok()
} else {
None
diff --git a/components/servo/lib.rs b/components/servo/lib.rs
index feb1ef3bee5..4dcf43c6a10 100644
--- a/components/servo/lib.rs
+++ b/components/servo/lib.rs
@@ -82,6 +82,7 @@ use compositing::CompositorEventListener;
use compositing::windowing::WindowEvent;
use compositing::compositor_task::InitialCompositorState;
+use compositing::constellation::InitialConstellationState;
use compositing::windowing::WindowMethods;
use compositing::{CompositorProxy, CompositorTask, Constellation};
@@ -210,17 +211,20 @@ fn create_constellation(opts: opts::Opts,
let font_cache_task = FontCacheTask::new(resource_task.clone());
let storage_task: StorageTask = StorageTaskFactory::new();
- let constellation_chan = Constellation::<layout::layout_task::LayoutTask,
- script::script_task::ScriptTask>::start(
- compositor_proxy,
- resource_task,
- image_cache_task,
- font_cache_task,
- time_profiler_chan,
- mem_profiler_chan,
- devtools_chan,
- storage_task,
- supports_clipboard);
+ let initial_state = InitialConstellationState {
+ compositor_proxy: compositor_proxy,
+ devtools_chan: devtools_chan,
+ image_cache_task: image_cache_task,
+ font_cache_task: font_cache_task,
+ resource_task: resource_task,
+ storage_task: storage_task,
+ time_profiler_chan: time_profiler_chan,
+ mem_profiler_chan: mem_profiler_chan,
+ supports_clipboard: supports_clipboard,
+ };
+ let constellation_chan =
+ Constellation::<layout::layout_task::LayoutTask,
+ script::script_task::ScriptTask>::start(initial_state);
// Send the URL command to the constellation.
match opts.url {