mirror of
https://github.com/servo/servo.git
synced 2025-09-04 12:08:21 +01:00
compositor: Hide IpcSender as implementation detail (#38963)
The `CrossProcessCompositorApi` already provides methods for most messages. Remove the `sender()` method, and hide the IpcSender as an implementation detail. This is a preparation for abstracting over the internal IpcSender. Testing: No functional changes --------- Signed-off-by: Jonathan Schwender <schwenderjonathan@gmail.com>
This commit is contained in:
parent
5909eb7684
commit
33e934421e
4 changed files with 29 additions and 22 deletions
|
@ -4,7 +4,6 @@
|
|||
|
||||
use std::str::FromStr;
|
||||
|
||||
use compositing_traits::CompositorMsg;
|
||||
use compositing_traits::viewport_description::ViewportDescription;
|
||||
use dom_struct::dom_struct;
|
||||
use html5ever::{LocalName, Prefix, local_name, ns};
|
||||
|
@ -136,12 +135,7 @@ impl HTMLMetaElement {
|
|||
if let Ok(viewport) = ViewportDescription::from_str(&content.value()) {
|
||||
self.owner_window()
|
||||
.compositor_api()
|
||||
.sender()
|
||||
.send(CompositorMsg::Viewport(
|
||||
self.owner_window().webview_id(),
|
||||
viewport,
|
||||
))
|
||||
.unwrap();
|
||||
.viewport(self.owner_window().webview_id(), viewport);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -36,7 +36,7 @@ use base::cross_process_instant::CrossProcessInstant;
|
|||
use base::id::{BrowsingContextId, HistoryStateId, PipelineId, PipelineNamespace, WebViewId};
|
||||
use canvas_traits::webgl::WebGLPipeline;
|
||||
use chrono::{DateTime, Local};
|
||||
use compositing_traits::{CompositorMsg, CrossProcessCompositorApi, PipelineExitSource};
|
||||
use compositing_traits::{CrossProcessCompositorApi, PipelineExitSource};
|
||||
use constellation_traits::{
|
||||
JsEvalResult, LoadData, LoadOrigin, NavigationHistoryBehavior, ScriptToConstellationChan,
|
||||
ScriptToConstellationMessage, StructuredSerializedData, WindowSizeType,
|
||||
|
@ -2956,13 +2956,7 @@ impl ScriptThread {
|
|||
.ok();
|
||||
|
||||
self.compositor_api
|
||||
.sender()
|
||||
.send(CompositorMsg::PipelineExited(
|
||||
webview_id,
|
||||
id,
|
||||
PipelineExitSource::Script,
|
||||
))
|
||||
.ok();
|
||||
.pipeline_exited(webview_id, id, PipelineExitSource::Script);
|
||||
|
||||
debug!("{id}: Finished pipeline exit");
|
||||
}
|
||||
|
|
|
@ -1101,7 +1101,7 @@ fn create_compositor_channel(
|
|||
let (compositor_ipc_sender, compositor_ipc_receiver) =
|
||||
ipc::channel().expect("ipc channel failure");
|
||||
|
||||
let cross_process_compositor_api = CrossProcessCompositorApi(compositor_ipc_sender);
|
||||
let cross_process_compositor_api = CrossProcessCompositorApi::new(compositor_ipc_sender);
|
||||
let compositor_proxy = CompositorProxy {
|
||||
sender,
|
||||
cross_process_compositor_api,
|
||||
|
|
|
@ -174,9 +174,14 @@ pub struct CompositionPipeline {
|
|||
|
||||
/// A mechanism to send messages from ScriptThread to the parent process' WebRender instance.
|
||||
#[derive(Clone, Deserialize, MallocSizeOf, Serialize)]
|
||||
pub struct CrossProcessCompositorApi(pub IpcSender<CompositorMsg>);
|
||||
pub struct CrossProcessCompositorApi(IpcSender<CompositorMsg>);
|
||||
|
||||
impl CrossProcessCompositorApi {
|
||||
/// Create a new [`CrossProcessCompositorApi`] struct.
|
||||
pub fn new(sender: IpcSender<CompositorMsg>) -> Self {
|
||||
CrossProcessCompositorApi(sender)
|
||||
}
|
||||
|
||||
/// Create a new [`CrossProcessCompositorApi`] struct that does not have a listener on the other
|
||||
/// end to use for unit testing.
|
||||
pub fn dummy() -> Self {
|
||||
|
@ -184,11 +189,6 @@ impl CrossProcessCompositorApi {
|
|||
Self(sender)
|
||||
}
|
||||
|
||||
/// Get the sender for this proxy.
|
||||
pub fn sender(&self) -> &IpcSender<CompositorMsg> {
|
||||
&self.0
|
||||
}
|
||||
|
||||
/// Inform WebRender of the existence of this pipeline.
|
||||
pub fn send_initial_transaction(&self, pipeline: WebRenderPipelineId) {
|
||||
if let Err(e) = self.0.send(CompositorMsg::SendInitialTransaction(pipeline)) {
|
||||
|
@ -352,6 +352,25 @@ impl CrossProcessCompositorApi {
|
|||
));
|
||||
receiver.recv().unwrap()
|
||||
}
|
||||
|
||||
pub fn viewport(&self, webview_id: WebViewId, description: ViewportDescription) {
|
||||
let _ = self
|
||||
.0
|
||||
.send(CompositorMsg::Viewport(webview_id, description));
|
||||
}
|
||||
|
||||
pub fn pipeline_exited(
|
||||
&self,
|
||||
webview_id: WebViewId,
|
||||
pipeline_id: PipelineId,
|
||||
source: PipelineExitSource,
|
||||
) {
|
||||
let _ = self.0.send(CompositorMsg::PipelineExited(
|
||||
webview_id,
|
||||
pipeline_id,
|
||||
source,
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
/// This trait is used as a bridge between the different GL clients
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue