mirror of
https://github.com/servo/servo.git
synced 2025-08-05 05:30:08 +01:00
Introduce InitialConstellationState
This commit is contained in:
parent
7d140113e7
commit
9e1e2b8ed3
2 changed files with 47 additions and 30 deletions
|
@ -139,6 +139,28 @@ pub struct Constellation<LTF, STF> {
|
||||||
webgl_paint_tasks: Vec<Sender<CanvasMsg>>,
|
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.
|
/// Stores the navigation context for a single frame in the frame tree.
|
||||||
pub struct Frame {
|
pub struct Frame {
|
||||||
prev: Vec<PipelineId>,
|
prev: Vec<PipelineId>,
|
||||||
|
@ -219,28 +241,19 @@ enum ExitPipelineMode {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<LTF: LayoutTaskFactory, STF: ScriptTaskFactory> Constellation<LTF, STF> {
|
impl<LTF: LayoutTaskFactory, STF: ScriptTaskFactory> Constellation<LTF, STF> {
|
||||||
pub fn start(compositor_proxy: Box<CompositorProxy + Send>,
|
pub fn start(state: InitialConstellationState) -> ConstellationChan {
|
||||||
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 {
|
|
||||||
let (constellation_port, constellation_chan) = ConstellationChan::new();
|
let (constellation_port, constellation_chan) = ConstellationChan::new();
|
||||||
let constellation_chan_clone = constellation_chan.clone();
|
let constellation_chan_clone = constellation_chan.clone();
|
||||||
spawn_named("Constellation".to_owned(), move || {
|
spawn_named("Constellation".to_owned(), move || {
|
||||||
let mut constellation: Constellation<LTF, STF> = Constellation {
|
let mut constellation: Constellation<LTF, STF> = Constellation {
|
||||||
chan: constellation_chan_clone,
|
chan: constellation_chan_clone,
|
||||||
request_port: constellation_port,
|
request_port: constellation_port,
|
||||||
compositor_proxy: compositor_proxy,
|
compositor_proxy: state.compositor_proxy,
|
||||||
devtools_chan: devtools_chan,
|
devtools_chan: state.devtools_chan,
|
||||||
resource_task: resource_task,
|
resource_task: state.resource_task,
|
||||||
image_cache_task: image_cache_task,
|
image_cache_task: state.image_cache_task,
|
||||||
font_cache_task: font_cache_task,
|
font_cache_task: state.font_cache_task,
|
||||||
storage_task: storage_task,
|
storage_task: state.storage_task,
|
||||||
pipelines: HashMap::new(),
|
pipelines: HashMap::new(),
|
||||||
frames: HashMap::new(),
|
frames: HashMap::new(),
|
||||||
pipeline_to_frame_map: HashMap::new(),
|
pipeline_to_frame_map: HashMap::new(),
|
||||||
|
@ -250,8 +263,8 @@ impl<LTF: LayoutTaskFactory, STF: ScriptTaskFactory> Constellation<LTF, STF> {
|
||||||
root_frame_id: None,
|
root_frame_id: None,
|
||||||
next_frame_id: FrameId(0),
|
next_frame_id: FrameId(0),
|
||||||
focus_pipeline_id: None,
|
focus_pipeline_id: None,
|
||||||
time_profiler_chan: time_profiler_chan,
|
time_profiler_chan: state.time_profiler_chan,
|
||||||
mem_profiler_chan: mem_profiler_chan,
|
mem_profiler_chan: state.mem_profiler_chan,
|
||||||
window_size: WindowSizeData {
|
window_size: WindowSizeData {
|
||||||
visible_viewport: opts::get().initial_window_size.as_f32() *
|
visible_viewport: opts::get().initial_window_size.as_f32() *
|
||||||
ScaleFactor::new(1.0),
|
ScaleFactor::new(1.0),
|
||||||
|
@ -260,7 +273,7 @@ impl<LTF: LayoutTaskFactory, STF: ScriptTaskFactory> Constellation<LTF, STF> {
|
||||||
device_pixel_ratio: ScaleFactor::new(1.0),
|
device_pixel_ratio: ScaleFactor::new(1.0),
|
||||||
},
|
},
|
||||||
phantom: PhantomData,
|
phantom: PhantomData,
|
||||||
clipboard_ctx: if supports_clipboard {
|
clipboard_ctx: if state.supports_clipboard {
|
||||||
ClipboardContext::new().ok()
|
ClipboardContext::new().ok()
|
||||||
} else {
|
} else {
|
||||||
None
|
None
|
||||||
|
|
|
@ -82,6 +82,7 @@ use compositing::CompositorEventListener;
|
||||||
use compositing::windowing::WindowEvent;
|
use compositing::windowing::WindowEvent;
|
||||||
|
|
||||||
use compositing::compositor_task::InitialCompositorState;
|
use compositing::compositor_task::InitialCompositorState;
|
||||||
|
use compositing::constellation::InitialConstellationState;
|
||||||
use compositing::windowing::WindowMethods;
|
use compositing::windowing::WindowMethods;
|
||||||
use compositing::{CompositorProxy, CompositorTask, Constellation};
|
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 font_cache_task = FontCacheTask::new(resource_task.clone());
|
||||||
let storage_task: StorageTask = StorageTaskFactory::new();
|
let storage_task: StorageTask = StorageTaskFactory::new();
|
||||||
|
|
||||||
let constellation_chan = Constellation::<layout::layout_task::LayoutTask,
|
let initial_state = InitialConstellationState {
|
||||||
script::script_task::ScriptTask>::start(
|
compositor_proxy: compositor_proxy,
|
||||||
compositor_proxy,
|
devtools_chan: devtools_chan,
|
||||||
resource_task,
|
image_cache_task: image_cache_task,
|
||||||
image_cache_task,
|
font_cache_task: font_cache_task,
|
||||||
font_cache_task,
|
resource_task: resource_task,
|
||||||
time_profiler_chan,
|
storage_task: storage_task,
|
||||||
mem_profiler_chan,
|
time_profiler_chan: time_profiler_chan,
|
||||||
devtools_chan,
|
mem_profiler_chan: mem_profiler_chan,
|
||||||
storage_task,
|
supports_clipboard: 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.
|
// Send the URL command to the constellation.
|
||||||
match opts.url {
|
match opts.url {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue