Stop using webrender_api::get_scroll_node_state (#30000)

This API has been removed in the latest version of WebRender and we can
simply get this information from the compositor-side scroll tree. In
addition, this change limits the amount of data sent to the pipeline
that actually changed and gives the function in the compositor a better
name.

Signed-off-by: Martin Robinson <mrobinson@igalia.com>
This commit is contained in:
Martin Robinson 2023-07-17 11:33:24 +02:00 committed by GitHub
parent cf78bd7a0f
commit e65f65a943
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -487,7 +487,7 @@ impl<Window: WindowMethods + ?Sized> IOCompositor<Window> {
(Msg::SetFrameTree(frame_tree), ShutdownState::NotShuttingDown) => { (Msg::SetFrameTree(frame_tree), ShutdownState::NotShuttingDown) => {
self.set_frame_tree(&frame_tree); self.set_frame_tree(&frame_tree);
self.send_viewport_rects(); self.send_scroll_positions_to_layout_for_pipeline(&frame_tree.pipeline.id);
}, },
(Msg::Recomposite(reason), ShutdownState::NotShuttingDown) => { (Msg::Recomposite(reason), ShutdownState::NotShuttingDown) => {
@ -1208,8 +1208,6 @@ impl<Window: WindowMethods + ?Sized> IOCompositor<Window> {
} }
fn process_pending_scroll_events(&mut self) { fn process_pending_scroll_events(&mut self) {
let had_events = self.pending_scroll_zoom_events.len() > 0;
// Batch up all scroll events into one, or else we'll do way too much painting. // Batch up all scroll events into one, or else we'll do way too much painting.
let mut last_combined_event: Option<ScrollZoomEvent> = None; let mut last_combined_event: Option<ScrollZoomEvent> = None;
for scroll_event in self.pending_scroll_zoom_events.drain(..) { for scroll_event in self.pending_scroll_zoom_events.drain(..) {
@ -1290,6 +1288,7 @@ impl<Window: WindowMethods + ?Sized> IOCompositor<Window> {
None => {}, None => {},
} }
} }
self.send_scroll_positions_to_layout_for_pipeline(&result.pipeline_id);
if combined_event.magnification != 1.0 { if combined_event.magnification != 1.0 {
let old_zoom = self.pinch_zoom_level(); let old_zoom = self.pinch_zoom_level();
@ -1301,10 +1300,6 @@ impl<Window: WindowMethods + ?Sized> IOCompositor<Window> {
.send_transaction(self.webrender_document, txn); .send_transaction(self.webrender_document, txn);
self.waiting_for_results_of_scroll = true self.waiting_for_results_of_scroll = true
} }
if had_events {
self.send_viewport_rects();
}
} }
/// If there are any animations running, dispatches appropriate messages to the constellation. /// If there are any animations running, dispatches appropriate messages to the constellation.
@ -1404,28 +1399,29 @@ impl<Window: WindowMethods + ?Sized> IOCompositor<Window> {
}); });
} }
fn send_viewport_rects(&self) { fn send_scroll_positions_to_layout_for_pipeline(&self, pipeline_id: &PipelineId) {
let mut scroll_states_per_pipeline = HashMap::new(); let details = match self.pipeline_details.get(&pipeline_id) {
for scroll_layer_state in self Some(details) => details,
.webrender_api None => return,
.get_scroll_node_state(self.webrender_document) };
{
let scroll_state = ScrollState {
scroll_id: scroll_layer_state.id,
scroll_offset: scroll_layer_state.scroll_offset,
};
scroll_states_per_pipeline let mut scroll_states = Vec::new();
.entry(scroll_layer_state.id.pipeline_id()) details.scroll_tree.nodes.iter().for_each(|node| {
.or_insert(vec![]) match (node.external_id(), node.offset()) {
.push(scroll_state); (Some(scroll_id), Some(scroll_offset)) => {
} scroll_states.push(ScrollState {
scroll_id,
for (pipeline_id, scroll_states) in scroll_states_per_pipeline { scroll_offset,
if let Some(pipeline) = self.pipeline(pipeline_id.from_webrender()) { });
let msg = LayoutControlMsg::SetScrollStates(scroll_states); },
let _ = pipeline.layout_chan.send(msg); _ => {},
} }
});
if let Some(pipeline) = details.pipeline.as_ref() {
let _ = pipeline
.layout_chan
.send(LayoutControlMsg::SetScrollStates(scroll_states));
} }
} }