constellation: Proxy ScrollState through the Constellation (#36062)

This will allow removing the dependency of the compositor on
`script_traits`, which should make our internal dependency chain a lot
easier to deal with.

Part of #35984.

Signed-off-by: Martin Robinson <mrobinson@igalia.com>
This commit is contained in:
Martin Robinson 2025-03-21 13:09:01 +01:00 committed by GitHub
parent ec20d9a3d7
commit 1f232eb17c
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
10 changed files with 60 additions and 33 deletions

View file

@ -160,7 +160,7 @@ use webgpu::{self, WebGPU, WebGPURequest, WebGPUResponse};
use webrender::RenderApi;
use webrender::RenderApiSender;
use webrender_api::{DocumentId, ImageKey};
use webrender_traits::{CompositorHitTestResult, WebrenderExternalImageRegistry};
use webrender_traits::{CompositorHitTestResult, ScrollState, WebrenderExternalImageRegistry};
use crate::browsingcontext::{
AllBrowsingContextsIterator, BrowsingContext, FullyActiveBrowsingContextsIterator,
@ -1406,6 +1406,9 @@ where
FromCompositorMsg::SetWebViewThrottled(webview_id, throttled) => {
self.set_webview_throttled(webview_id, throttled);
},
FromCompositorMsg::SetScrollStates(pipeline_id, scroll_states) => {
self.handle_set_scroll_states(pipeline_id, scroll_states)
},
}
}
@ -5562,4 +5565,24 @@ where
error!("Got a media session action but no active media session is registered");
}
}
#[cfg_attr(
feature = "tracing",
tracing::instrument(skip_all, fields(servo_profiling = true), level = "trace")
)]
fn handle_set_scroll_states(&self, pipeline_id: PipelineId, scroll_states: Vec<ScrollState>) {
let Some(pipeline) = self.pipelines.get(&pipeline_id) else {
warn!("Discarding scroll offset update for unknown pipeline");
return;
};
if let Err(error) = pipeline
.event_loop
.send(ScriptThreadMessage::SetScrollStates(
pipeline_id,
scroll_states,
))
{
warn!("Could not send scroll offsets to pipeline: {pipeline_id:?}: {error:?}");
}
}
}

View file

@ -86,6 +86,7 @@ mod from_compositor {
Self::ExitFullScreen(_) => target!("ExitFullScreen"),
Self::MediaSessionAction(_) => target!("MediaSessionAction"),
Self::SetWebViewThrottled(_, _) => target!("SetWebViewThrottled"),
Self::SetScrollStates(..) => target!("SetScrollStates"),
}
}
}