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:
Jonathan Schwender 2025-08-27 11:42:01 +02:00 committed by GitHub
parent 5909eb7684
commit 33e934421e
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 29 additions and 22 deletions

View file

@ -4,7 +4,6 @@
use std::str::FromStr; use std::str::FromStr;
use compositing_traits::CompositorMsg;
use compositing_traits::viewport_description::ViewportDescription; use compositing_traits::viewport_description::ViewportDescription;
use dom_struct::dom_struct; use dom_struct::dom_struct;
use html5ever::{LocalName, Prefix, local_name, ns}; use html5ever::{LocalName, Prefix, local_name, ns};
@ -136,12 +135,7 @@ impl HTMLMetaElement {
if let Ok(viewport) = ViewportDescription::from_str(&content.value()) { if let Ok(viewport) = ViewportDescription::from_str(&content.value()) {
self.owner_window() self.owner_window()
.compositor_api() .compositor_api()
.sender() .viewport(self.owner_window().webview_id(), viewport);
.send(CompositorMsg::Viewport(
self.owner_window().webview_id(),
viewport,
))
.unwrap();
} }
} }

View file

@ -36,7 +36,7 @@ use base::cross_process_instant::CrossProcessInstant;
use base::id::{BrowsingContextId, HistoryStateId, PipelineId, PipelineNamespace, WebViewId}; use base::id::{BrowsingContextId, HistoryStateId, PipelineId, PipelineNamespace, WebViewId};
use canvas_traits::webgl::WebGLPipeline; use canvas_traits::webgl::WebGLPipeline;
use chrono::{DateTime, Local}; use chrono::{DateTime, Local};
use compositing_traits::{CompositorMsg, CrossProcessCompositorApi, PipelineExitSource}; use compositing_traits::{CrossProcessCompositorApi, PipelineExitSource};
use constellation_traits::{ use constellation_traits::{
JsEvalResult, LoadData, LoadOrigin, NavigationHistoryBehavior, ScriptToConstellationChan, JsEvalResult, LoadData, LoadOrigin, NavigationHistoryBehavior, ScriptToConstellationChan,
ScriptToConstellationMessage, StructuredSerializedData, WindowSizeType, ScriptToConstellationMessage, StructuredSerializedData, WindowSizeType,
@ -2956,13 +2956,7 @@ impl ScriptThread {
.ok(); .ok();
self.compositor_api self.compositor_api
.sender() .pipeline_exited(webview_id, id, PipelineExitSource::Script);
.send(CompositorMsg::PipelineExited(
webview_id,
id,
PipelineExitSource::Script,
))
.ok();
debug!("{id}: Finished pipeline exit"); debug!("{id}: Finished pipeline exit");
} }

View file

@ -1101,7 +1101,7 @@ fn create_compositor_channel(
let (compositor_ipc_sender, compositor_ipc_receiver) = let (compositor_ipc_sender, compositor_ipc_receiver) =
ipc::channel().expect("ipc channel failure"); 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 { let compositor_proxy = CompositorProxy {
sender, sender,
cross_process_compositor_api, cross_process_compositor_api,

View file

@ -174,9 +174,14 @@ pub struct CompositionPipeline {
/// A mechanism to send messages from ScriptThread to the parent process' WebRender instance. /// A mechanism to send messages from ScriptThread to the parent process' WebRender instance.
#[derive(Clone, Deserialize, MallocSizeOf, Serialize)] #[derive(Clone, Deserialize, MallocSizeOf, Serialize)]
pub struct CrossProcessCompositorApi(pub IpcSender<CompositorMsg>); pub struct CrossProcessCompositorApi(IpcSender<CompositorMsg>);
impl CrossProcessCompositorApi { 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 /// Create a new [`CrossProcessCompositorApi`] struct that does not have a listener on the other
/// end to use for unit testing. /// end to use for unit testing.
pub fn dummy() -> Self { pub fn dummy() -> Self {
@ -184,11 +189,6 @@ impl CrossProcessCompositorApi {
Self(sender) Self(sender)
} }
/// Get the sender for this proxy.
pub fn sender(&self) -> &IpcSender<CompositorMsg> {
&self.0
}
/// Inform WebRender of the existence of this pipeline. /// Inform WebRender of the existence of this pipeline.
pub fn send_initial_transaction(&self, pipeline: WebRenderPipelineId) { pub fn send_initial_transaction(&self, pipeline: WebRenderPipelineId) {
if let Err(e) = self.0.send(CompositorMsg::SendInitialTransaction(pipeline)) { if let Err(e) = self.0.send(CompositorMsg::SendInitialTransaction(pipeline)) {
@ -352,6 +352,25 @@ impl CrossProcessCompositorApi {
)); ));
receiver.recv().unwrap() 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 /// This trait is used as a bridge between the different GL clients