Remove pointless phantom arguments to ScriptThreadFactory and LayoutThreadFactory.

This commit is contained in:
Ms2ger 2016-05-19 17:20:57 +02:00
parent bcea0ada27
commit 9ee8c33a8d
5 changed files with 49 additions and 54 deletions

View file

@ -123,7 +123,9 @@ impl Pipeline {
/// Returns the channels wrapped in a struct. /// Returns the channels wrapped in a struct.
pub fn create<LTF, STF>(state: InitialPipelineState) pub fn create<LTF, STF>(state: InitialPipelineState)
-> (Pipeline, UnprivilegedPipelineContent, PrivilegedPipelineContent) -> (Pipeline, UnprivilegedPipelineContent, PrivilegedPipelineContent)
where LTF: LayoutThreadFactory, STF: ScriptThreadFactory { where LTF: LayoutThreadFactory,
STF: ScriptThreadFactory
{
// Note: we allow channel creation to panic, since recovering from this // Note: we allow channel creation to panic, since recovering from this
// probably requires a general low-memory strategy. // probably requires a general low-memory strategy.
let (layout_to_paint_chan, layout_to_paint_port) = util::ipc::optional_ipc_channel(); let (layout_to_paint_chan, layout_to_paint_port) = util::ipc::optional_ipc_channel();
@ -416,10 +418,12 @@ pub struct UnprivilegedPipelineContent {
impl UnprivilegedPipelineContent { impl UnprivilegedPipelineContent {
pub fn start_all<LTF, STF>(mut self, wait_for_completion: bool) pub fn start_all<LTF, STF>(mut self, wait_for_completion: bool)
where LTF: LayoutThreadFactory, STF: ScriptThreadFactory { where LTF: LayoutThreadFactory,
let layout_pair = ScriptThreadFactory::create_layout_channel(None::<&mut STF>); STF: ScriptThreadFactory
{
let layout_pair = STF::create_layout_channel();
ScriptThreadFactory::create(None::<&mut STF>, InitialScriptState { STF::create(InitialScriptState {
id: self.id, id: self.id,
parent_info: self.parent_info, parent_info: self.parent_info,
compositor: self.script_to_compositor_chan, compositor: self.script_to_compositor_chan,
@ -440,23 +444,22 @@ impl UnprivilegedPipelineContent {
content_process_shutdown_chan: self.script_content_process_shutdown_chan.clone(), content_process_shutdown_chan: self.script_content_process_shutdown_chan.clone(),
}, &layout_pair, self.load_data.clone()); }, &layout_pair, self.load_data.clone());
LayoutThreadFactory::create(None::<&mut LTF>, LTF::create(self.id,
self.id, self.load_data.url.clone(),
self.load_data.url.clone(), self.parent_info.is_some(),
self.parent_info.is_some(), layout_pair,
layout_pair, self.pipeline_port.expect("No pipeline port."),
self.pipeline_port.expect("No pipeline port."), self.layout_to_constellation_chan,
self.layout_to_constellation_chan, self.panic_chan,
self.panic_chan, self.script_chan.clone(),
self.script_chan.clone(), self.layout_to_paint_chan.clone(),
self.layout_to_paint_chan.clone(), self.image_cache_thread,
self.image_cache_thread, self.font_cache_thread,
self.font_cache_thread, self.time_profiler_chan,
self.time_profiler_chan, self.mem_profiler_chan,
self.mem_profiler_chan, self.layout_shutdown_chan,
self.layout_shutdown_chan, self.layout_content_process_shutdown_chan.clone(),
self.layout_content_process_shutdown_chan.clone(), self.webrender_api_sender);
self.webrender_api_sender);
if wait_for_completion { if wait_for_completion {
let _ = self.script_content_process_shutdown_port.recv(); let _ = self.script_content_process_shutdown_port.recv();

View file

@ -247,8 +247,7 @@ pub struct LayoutThread {
impl LayoutThreadFactory for LayoutThread { impl LayoutThreadFactory for LayoutThread {
/// Spawns a new layout thread. /// Spawns a new layout thread.
fn create(_phantom: Option<&mut LayoutThread>, fn create(id: PipelineId,
id: PipelineId,
url: Url, url: Url,
is_iframe: bool, is_iframe: bool,
chan: OpaqueScriptLayoutChannel, chan: OpaqueScriptLayoutChannel,
@ -731,23 +730,22 @@ impl LayoutThread {
} }
fn create_layout_thread(&self, info: NewLayoutThreadInfo) { fn create_layout_thread(&self, info: NewLayoutThreadInfo) {
LayoutThreadFactory::create(None::<&mut LayoutThread>, LayoutThread::create(info.id,
info.id, info.url.clone(),
info.url.clone(), info.is_parent,
info.is_parent, info.layout_pair,
info.layout_pair, info.pipeline_port,
info.pipeline_port, info.constellation_chan,
info.constellation_chan, info.panic_chan,
info.panic_chan, info.script_chan.clone(),
info.script_chan.clone(), info.paint_chan.to::<LayoutToPaintMsg>(),
info.paint_chan.to::<LayoutToPaintMsg>(), self.image_cache_thread.clone(),
self.image_cache_thread.clone(), self.font_cache_thread.clone(),
self.font_cache_thread.clone(), self.time_profiler_chan.clone(),
self.time_profiler_chan.clone(), self.mem_profiler_chan.clone(),
self.mem_profiler_chan.clone(), info.layout_shutdown_chan,
info.layout_shutdown_chan, info.content_process_shutdown_chan,
info.content_process_shutdown_chan, self.webrender_api.as_ref().map(|wr| wr.clone_sender()));
self.webrender_api.as_ref().map(|wr| wr.clone_sender()));
} }
/// Enters a quiescent state in which no new messages will be processed until an `ExitNow` is /// Enters a quiescent state in which no new messages will be processed until an `ExitNow` is

View file

@ -41,9 +41,7 @@ pub struct LayoutControlChan(pub IpcSender<LayoutControlMsg>);
// A static method creating a layout thread // A static method creating a layout thread
// Here to remove the compositor -> layout dependency // Here to remove the compositor -> layout dependency
pub trait LayoutThreadFactory { pub trait LayoutThreadFactory {
// FIXME: use a proper static method fn create(id: PipelineId,
fn create(_phantom: Option<&mut Self>,
id: PipelineId,
url: Url, url: Url,
is_iframe: bool, is_iframe: bool,
chan: OpaqueScriptLayoutChannel, chan: OpaqueScriptLayoutChannel,

View file

@ -421,18 +421,17 @@ impl<'a> Drop for ScriptMemoryFailsafe<'a> {
} }
impl ScriptThreadFactory for ScriptThread { impl ScriptThreadFactory for ScriptThread {
fn create_layout_channel(_phantom: Option<&mut ScriptThread>) -> OpaqueScriptLayoutChannel { fn create_layout_channel() -> OpaqueScriptLayoutChannel {
let (chan, port) = channel(); let (chan, port) = channel();
ScriptLayoutChan::new(chan, port) ScriptLayoutChan::new(chan, port)
} }
fn clone_layout_channel(_phantom: Option<&mut ScriptThread>, pair: &OpaqueScriptLayoutChannel) fn clone_layout_channel(pair: &OpaqueScriptLayoutChannel)
-> Box<Any + Send> { -> Box<Any + Send> {
box pair.sender() as Box<Any + Send> box pair.sender() as Box<Any + Send>
} }
fn create(_phantom: Option<&mut ScriptThread>, fn create(state: InitialScriptState,
state: InitialScriptState,
layout_chan: &OpaqueScriptLayoutChannel, layout_chan: &OpaqueScriptLayoutChannel,
load_data: LoadData) { load_data: LoadData) {
let panic_chan = state.panic_chan.clone(); let panic_chan = state.panic_chan.clone();
@ -1077,9 +1076,8 @@ impl ScriptThread {
content_process_shutdown_chan, content_process_shutdown_chan,
} = new_layout_info; } = new_layout_info;
let layout_pair = ScriptThread::create_layout_channel(None::<&mut ScriptThread>); let layout_pair = ScriptThread::create_layout_channel();
let layout_chan = LayoutChan(*ScriptThread::clone_layout_channel( let layout_chan = LayoutChan(*ScriptThread::clone_layout_channel(
None::<&mut ScriptThread>,
&layout_pair).downcast::<Sender<layout_interface::Msg>>().unwrap()); &layout_pair).downcast::<Sender<layout_interface::Msg>>().unwrap());
let layout_creation_info = NewLayoutThreadInfo { let layout_creation_info = NewLayoutThreadInfo {

View file

@ -346,15 +346,13 @@ pub struct ScriptControlChan(pub IpcSender<ConstellationControlMsg>);
/// crate. /// crate.
pub trait ScriptThreadFactory { pub trait ScriptThreadFactory {
/// Create a `ScriptThread`. /// Create a `ScriptThread`.
fn create(_phantom: Option<&mut Self>, fn create(state: InitialScriptState,
state: InitialScriptState,
layout_chan: &OpaqueScriptLayoutChannel, layout_chan: &OpaqueScriptLayoutChannel,
load_data: LoadData); load_data: LoadData);
/// Create a script -> layout channel (`Sender`, `Receiver` pair). /// Create a script -> layout channel (`Sender`, `Receiver` pair).
fn create_layout_channel(_phantom: Option<&mut Self>) -> OpaqueScriptLayoutChannel; fn create_layout_channel() -> OpaqueScriptLayoutChannel;
/// Clone the `Sender` in `pair`. /// Clone the `Sender` in `pair`.
fn clone_layout_channel(_phantom: Option<&mut Self>, pair: &OpaqueScriptLayoutChannel) fn clone_layout_channel(pair: &OpaqueScriptLayoutChannel) -> Box<Any + Send>;
-> Box<Any + Send>;
} }
/// Messages sent from the script thread to the compositor /// Messages sent from the script thread to the compositor