From 6bca3402a61d5a06103909b35e358e6ec745b522 Mon Sep 17 00:00:00 2001 From: Gregory Terzian Date: Sun, 27 Aug 2017 03:47:31 +0800 Subject: [PATCH] implement clone for embedder and compositor proxies --- components/canvas/gl_context.rs | 2 +- components/compositing/compositor_thread.rs | 10 ++++++++-- components/constellation/constellation.rs | 6 +++--- components/servo/lib.rs | 4 ++-- 4 files changed, 14 insertions(+), 8 deletions(-) diff --git a/components/canvas/gl_context.rs b/components/canvas/gl_context.rs index 69a26c0e03c..ae7446e2eb5 100644 --- a/components/canvas/gl_context.rs +++ b/components/canvas/gl_context.rs @@ -27,7 +27,7 @@ impl GLContextFactory { if cfg!(target_os = "windows") { // Used to dispatch functions from the GLContext thread to the main thread's event loop. // Required to allow WGL GLContext sharing in Windows. - GLContextFactory::Native(handle, Some(MainThreadDispatcher::new(proxy.clone_compositor_proxy()))) + GLContextFactory::Native(handle, Some(MainThreadDispatcher::new(proxy.clone()))) } else { GLContextFactory::Native(handle, None) } diff --git a/components/compositing/compositor_thread.rs b/components/compositing/compositor_thread.rs index 0a3828c0faf..03a7b46c7c0 100644 --- a/components/compositing/compositor_thread.rs +++ b/components/compositing/compositor_thread.rs @@ -43,7 +43,10 @@ impl EmbedderProxy { } self.event_loop_waker.wake(); } - pub fn clone_embedder_proxy(&self) -> EmbedderProxy { +} + +impl Clone for EmbedderProxy { + fn clone(&self) -> EmbedderProxy { EmbedderProxy { sender: self.sender.clone(), event_loop_waker: self.event_loop_waker.clone(), @@ -79,7 +82,10 @@ impl CompositorProxy { } self.event_loop_waker.wake(); } - pub fn clone_compositor_proxy(&self) -> CompositorProxy { +} + +impl Clone for CompositorProxy { + fn clone(&self) -> CompositorProxy { CompositorProxy { sender: self.sender.clone(), event_loop_waker: self.event_loop_waker.clone(), diff --git a/components/constellation/constellation.rs b/components/constellation/constellation.rs index 9cecc148ed1..ae286fedd09 100644 --- a/components/constellation/constellation.rs +++ b/components/constellation/constellation.rs @@ -699,7 +699,7 @@ impl Constellation }, layout_to_constellation_chan: self.layout_sender.clone(), scheduler_chan: self.scheduler_chan.clone(), - compositor_proxy: self.compositor_proxy.clone_compositor_proxy(), + compositor_proxy: self.compositor_proxy.clone(), devtools_chan: self.devtools_chan.clone(), bluetooth_thread: self.bluetooth_thread.clone(), swmanager_thread: self.swmanager_sender.clone(), @@ -1694,7 +1694,7 @@ impl Constellation Some((parent_pipeline_id, frame_type)), script_sender, layout_sender, - self.compositor_proxy.clone_compositor_proxy(), + self.compositor_proxy.clone(), is_private || parent_pipeline.is_private, url.clone(), parent_pipeline.visible) @@ -1998,7 +1998,7 @@ impl Constellation }, None => { let event = EmbedderMsg::KeyEvent(None, ch, key, state, mods); - self.embedder_proxy.clone_embedder_proxy().send(event); + self.embedder_proxy.clone().send(event); } } } diff --git a/components/servo/lib.rs b/components/servo/lib.rs index 8031d4ad877..cddc84707d0 100644 --- a/components/servo/lib.rs +++ b/components/servo/lib.rs @@ -213,8 +213,8 @@ impl Servo where Window: WindowMethods + 'static { // as the navigation context. let (constellation_chan, sw_senders) = create_constellation(opts.user_agent.clone(), opts.config_dir.clone(), - embedder_proxy.clone_embedder_proxy(), - compositor_proxy.clone_compositor_proxy(), + embedder_proxy.clone(), + compositor_proxy.clone(), time_profiler_chan.clone(), mem_profiler_chan.clone(), debugger_chan,