From 6e1cc5ad36a25bca4d0f342905ad8b6117cafb40 Mon Sep 17 00:00:00 2001 From: Marco Castelluccio Date: Mon, 30 Sep 2019 20:50:28 +0000 Subject: [PATCH] servo: Merge #7191 - remove ScriptListener (from vectorijk:removeScriptListener); r=Ms2ger Fix issue #7175 and for code review Source-Repo: https://github.com/servo/servo Source-Revision: 5ab9aa5013801a8ac2b9527a6079c62cc56ff81b UltraBlame original commit: 92eebe38003ae4f4b4c49f8a41f1c591dc6ebe9a --- servo/components/compositing/pipeline.rs | 3 +- servo/components/msg/compositor_msg.rs | 37 ------------------- servo/components/script/dom/bindings/trace.rs | 8 ---- servo/components/script/dom/document.rs | 14 +++---- servo/components/script/dom/window.rs | 8 ++-- servo/components/script/script_task.rs | 17 +++++---- servo/components/script_traits/lib.rs | 5 +-- 7 files changed, 23 insertions(+), 69 deletions(-) diff --git a/servo/components/compositing/pipeline.rs b/servo/components/compositing/pipeline.rs index 7cfe52aca894..146aec7210fe 100644 --- a/servo/components/compositing/pipeline.rs +++ b/servo/components/compositing/pipeline.rs @@ -16,7 +16,6 @@ use gfx::font_cache_task::FontCacheTask; use ipc_channel::ipc::{self, IpcReceiver, IpcSender}; use ipc_channel::router::ROUTER; use layers::geometry::DevicePixel; -use msg::compositor_msg::ScriptListener; use msg::constellation_msg::{ConstellationChan, Failure, FrameId, PipelineId, SubpageId}; use msg::constellation_msg::{LoadData, WindowSizeData, PipelineExitType, MozBrowserEvent}; use profile_traits::mem as profile_mem; @@ -323,7 +322,7 @@ impl PipelineContent { ScriptTaskFactory::create(None::<&mut STF>, self.id, self.parent_info, - ScriptListener::new(script_to_compositor_chan), + script_to_compositor_chan, &layout_pair, self.script_chan.clone(), mem::replace(&mut self.script_port, None).unwrap(), diff --git a/servo/components/msg/compositor_msg.rs b/servo/components/msg/compositor_msg.rs index c5efa7902e05..002a823197c9 100644 --- a/servo/components/msg/compositor_msg.rs +++ b/servo/components/msg/compositor_msg.rs @@ -7,7 +7,6 @@ use constellation_msg::{Key, KeyState, KeyModifiers}; use euclid::point::Point2D; use euclid::rect::Rect; use euclid::Matrix4; -use ipc_channel::ipc::IpcSender; use layers::platform::surface::NativeDisplay; use layers::layers::{BufferRequest, LayerBufferSet}; use std::fmt::{Formatter, Debug}; @@ -126,39 +125,3 @@ pub enum ScriptToCompositorMsg { Exit, } - - -#[derive(Clone)] -pub struct ScriptListener(IpcSender); - -impl ScriptListener { - pub fn new(sender: IpcSender) -> ScriptListener { - ScriptListener(sender) - } - - pub fn scroll_fragment_point(&mut self, - pipeline_id: PipelineId, - layer_id: LayerId, - point: Point2D) { - self.0 - .send(ScriptToCompositorMsg::ScrollFragmentPoint(pipeline_id, layer_id, point)) - .unwrap() - } - - pub fn close(&mut self) { - self.0.send(ScriptToCompositorMsg::Exit).unwrap() - } - - pub fn dup(&mut self) -> ScriptListener { - self.clone() - } - - pub fn set_title(&mut self, pipeline_id: PipelineId, title: Option) { - self.0.send(ScriptToCompositorMsg::SetTitle(pipeline_id, title)).unwrap() - } - - pub fn send_key_event(&mut self, key: Key, state: KeyState, modifiers: KeyModifiers) { - self.0.send(ScriptToCompositorMsg::SendKeyEvent(key, state, modifiers)).unwrap() - } -} - diff --git a/servo/components/script/dom/bindings/trace.rs b/servo/components/script/dom/bindings/trace.rs index 33ea24d197c0..7825c952860b 100644 --- a/servo/components/script/dom/bindings/trace.rs +++ b/servo/components/script/dom/bindings/trace.rs @@ -58,7 +58,6 @@ use net_traits::storage_task::StorageType; use script_traits::UntrustedNodeAddress; use serde::{Serialize, Deserialize}; use smallvec::SmallVec; -use msg::compositor_msg::ScriptListener; use msg::constellation_msg::ConstellationChan; use net_traits::image::base::Image; use profile_traits::mem::ProfilerChan; @@ -342,13 +341,6 @@ impl JSTraceable for IpcSender where T: Deserialize + Serialize { } } -impl JSTraceable for ScriptListener { - #[inline] - fn trace(&self, _: *mut JSTracer) { - - } -} - impl JSTraceable for Box { #[inline] fn trace(&self, _: *mut JSTracer) { diff --git a/servo/components/script/dom/document.rs b/servo/components/script/dom/document.rs index 17609ad8b2b3..d73c436578a2 100644 --- a/servo/components/script/dom/document.rs +++ b/servo/components/script/dom/document.rs @@ -69,7 +69,7 @@ use dom::uievent::UIEvent; use dom::window::{Window, WindowHelpers, ReflowReason}; use layout_interface::{HitTestResponse, MouseOverResponse}; -use msg::compositor_msg::ScriptListener; +use msg::compositor_msg::ScriptToCompositorMsg; use msg::constellation_msg::AnimationState; use msg::constellation_msg::Msg as ConstellationMsg; use msg::constellation_msg::{ConstellationChan, FocusType, Key, KeyState, KeyModifiers, MozBrowserEvent, SubpageId}; @@ -85,7 +85,7 @@ use layout_interface::{ReflowGoal, ReflowQueryType}; use euclid::point::Point2D; use html5ever::tree_builder::{QuirksMode, NoQuirks, LimitedQuirks, Quirks}; -use ipc_channel::ipc; +use ipc_channel::ipc::{self, IpcSender}; use layout_interface::{LayoutChan, Msg}; use string_cache::{Atom, QualName}; use url::Url; @@ -272,7 +272,7 @@ pub trait DocumentHelpers<'a> { key: Key, state: KeyState, modifiers: KeyModifiers, - compositor: &mut ScriptListener); + compositor: &mut IpcSender); fn node_from_nodes_and_strings(self, nodes: Vec) -> Fallible>; fn get_body_attribute(self, local_name: &Atom) -> DOMString; @@ -637,8 +637,8 @@ impl<'a> DocumentHelpers<'a> for &'a Document { let window = self.window(); let window = window.r(); - let mut compositor = window.compositor(); - compositor.set_title(window.pipeline(), Some(self.Title())); + let compositor = window.compositor(); + compositor.send(ScriptToCompositorMsg::SetTitle(window.pipeline(), Some(self.Title()))).unwrap(); } fn dirty_all_nodes(self) { @@ -813,7 +813,7 @@ impl<'a> DocumentHelpers<'a> for &'a Document { key: Key, state: KeyState, modifiers: KeyModifiers, - compositor: &mut ScriptListener) { + compositor: &mut IpcSender) { let window = self.window.root(); let focused = self.get_focused_element(); let body = self.GetBody(); @@ -864,7 +864,7 @@ impl<'a> DocumentHelpers<'a> for &'a Document { } if !prevented { - compositor.send_key_event(key, state, modifiers); + compositor.send(ScriptToCompositorMsg::SendKeyEvent(key, state, modifiers)).unwrap(); } diff --git a/servo/components/script/dom/window.rs b/servo/components/script/dom/window.rs index 13cd82f3ad2e..dd6fabfa65cb 100644 --- a/servo/components/script/dom/window.rs +++ b/servo/components/script/dom/window.rs @@ -42,7 +42,7 @@ use webdriver_handlers::jsval_to_webdriver; use devtools_traits::{ScriptToDevtoolsControlMsg, TimelineMarker, TimelineMarkerType}; use devtools_traits::{TracingMetadata}; -use msg::compositor_msg::ScriptListener; +use msg::compositor_msg::ScriptToCompositorMsg; use msg::constellation_msg::{LoadData, PipelineId, SubpageId, ConstellationChan, WindowSizeData, WorkerId}; use msg::webdriver_msg::{WebDriverJSError, WebDriverJSResult}; use net_traits::ResourceTask; @@ -121,7 +121,7 @@ pub struct Window { #[ignore_heap_size_of = "channels are hard"] image_cache_chan: ImageCacheChan, #[ignore_heap_size_of = "TODO(#6911) newtypes containing unmeasurable types are hard"] - compositor: DOMRefCell, + compositor: DOMRefCell>, browsing_context: DOMRefCell>, page: Rc, performance: MutNullableHeap>, @@ -273,7 +273,7 @@ impl Window { &self.image_cache_task } - pub fn compositor<'a>(&'a self) -> RefMut<'a, ScriptListener> { + pub fn compositor<'a>(&'a self) -> RefMut<'a, IpcSender> { self.compositor.borrow_mut() } @@ -1073,7 +1073,7 @@ impl Window { script_chan: MainThreadScriptChan, image_cache_chan: ImageCacheChan, control_chan: Sender, - compositor: ScriptListener, + compositor: IpcSender, image_cache_task: ImageCacheTask, resource_task: Arc, storage_task: StorageTask, diff --git a/servo/components/script/script_task.rs b/servo/components/script/script_task.rs index 780168f3165e..bd3dcd411322 100644 --- a/servo/components/script/script_task.rs +++ b/servo/components/script/script_task.rs @@ -62,7 +62,7 @@ use script_traits::{CompositorEvent, MouseButton}; use script_traits::ConstellationControlMsg; use script_traits::{NewLayoutInfo, OpaqueScriptLayoutChannel}; use script_traits::{ScriptState, ScriptTaskFactory}; -use msg::compositor_msg::{LayerId, ScriptListener}; +use msg::compositor_msg::{LayerId, ScriptToCompositorMsg}; use msg::constellation_msg::{ConstellationChan, FocusType}; use msg::constellation_msg::{LoadData, PipelineId, SubpageId, MozBrowserEvent, WorkerId}; use msg::constellation_msg::{Failure, WindowSizeData, PipelineExitType}; @@ -361,7 +361,7 @@ pub struct ScriptTask { constellation_chan: ConstellationChan, - compositor: DOMRefCell, + compositor: DOMRefCell>, image_cache_port: Receiver, @@ -443,7 +443,7 @@ impl ScriptTaskFactory for ScriptTask { fn create(_phantom: Option<&mut ScriptTask>, id: PipelineId, parent_info: Option<(PipelineId, SubpageId)>, - compositor: ScriptListener, + compositor: IpcSender, layout_chan: &OpaqueScriptLayoutChannel, control_chan: Sender, control_port: Receiver, @@ -579,7 +579,7 @@ impl ScriptTask { } - pub fn new(compositor: ScriptListener, + pub fn new(compositor: IpcSender, port: Receiver, chan: MainThreadScriptChan, control_chan: Sender, @@ -1329,7 +1329,7 @@ impl ScriptTask { - self.compositor.borrow_mut().close(); + self.compositor.borrow_mut().send(ScriptToCompositorMsg::Exit).unwrap(); } @@ -1506,7 +1506,7 @@ impl ScriptTask { MainThreadScriptChan(sender.clone()), self.image_cache_channel.clone(), self.control_chan.clone(), - self.compositor.borrow_mut().dup(), + self.compositor.borrow_mut().clone(), self.image_cache_task.clone(), self.resource_task.clone(), self.storage_task.clone(), @@ -1601,7 +1601,8 @@ impl ScriptTask { - self.compositor.borrow_mut().scroll_fragment_point(pipeline_id, LayerId::null(), point); + self.compositor.borrow_mut().send(ScriptToCompositorMsg::ScrollFragmentPoint( + pipeline_id, LayerId::null(), point)).unwrap(); } @@ -1699,7 +1700,7 @@ impl ScriptTask { let page = get_page(&self.root_page(), pipeline_id); let document = page.document(); document.r().dispatch_key_event( - key, state, modifiers, &mut *self.compositor.borrow_mut()); + key, state, modifiers, &mut self.compositor.borrow_mut()); } } } diff --git a/servo/components/script_traits/lib.rs b/servo/components/script_traits/lib.rs index ee0d9a1d7718..1ad9c35fff8b 100644 --- a/servo/components/script_traits/lib.rs +++ b/servo/components/script_traits/lib.rs @@ -24,11 +24,10 @@ extern crate url; use devtools_traits::ScriptToDevtoolsControlMsg; use ipc_channel::ipc::{IpcReceiver, IpcSender}; use libc::c_void; -use msg::compositor_msg::{Epoch, LayerId}; +use msg::compositor_msg::{Epoch, LayerId, ScriptToCompositorMsg}; use msg::constellation_msg::{ConstellationChan, PipelineId, Failure, WindowSizeData}; use msg::constellation_msg::{LoadData, SubpageId, Key, KeyState, KeyModifiers}; use msg::constellation_msg::{MozBrowserEvent, PipelineExitType}; -use msg::compositor_msg::ScriptListener; use msg::webdriver_msg::WebDriverScriptCommand; use net_traits::ResourceTask; use net_traits::image_cache_task::ImageCacheTask; @@ -179,7 +178,7 @@ pub trait ScriptTaskFactory { fn create(_phantom: Option<&mut Self>, id: PipelineId, parent_info: Option<(PipelineId, SubpageId)>, - compositor: ScriptListener, + compositor: IpcSender, layout_chan: &OpaqueScriptLayoutChannel, control_chan: Sender, control_port: Receiver,