libservo|compositor: Have scroll offset directionality match that of WebRender and the web (#37752)

Previously, our Servo-specific spatial tree scroll offsets were opposite
to
that of WebRender and also the web platform. This is due to the fact,
likely, that `winit` wheel directionality is also flipped. This change
has both the Servo spatial tree and the API take offsets that are
consistent with the web.

Any possible changes to the meaning of wheel directionality will be
handled in a followup change.

This is a breaking change to the Servo API.

Testing: This change updates unit tests.

Signed-off-by: Martin Robinson <mrobinson@igalia.com>
Co-authored-by: Oriol Brufau <obrufau@igalia.com>
This commit is contained in:
Martin Robinson 2025-07-03 15:04:06 +02:00 committed by GitHub
parent d33d057763
commit 89bfa26f00
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
14 changed files with 54 additions and 132 deletions

View file

@ -44,7 +44,7 @@ use style_traits::CSSPixel;
use webrender::{CaptureBits, RenderApi, Transaction};
use webrender_api::units::{
DeviceIntPoint, DeviceIntRect, DevicePixel, DevicePoint, DeviceRect, LayoutPoint, LayoutRect,
LayoutSize, LayoutVector2D, WorldPoint,
LayoutSize, WorldPoint,
};
use webrender_api::{
self, BuiltDisplayList, DirtyRect, DisplayListPayload, DocumentId, Epoch as WebRenderEpoch,
@ -714,11 +714,9 @@ impl IOCompositor {
// is inverted compared to `winit`s wheel delta. Hence,
// here we invert the sign to mimic wheel scroll
// implementation in `headed_window.rs`.
let dx = -dx;
let dy = -dy;
let delta = WheelDelta {
x: dx,
y: dy,
x: -dx,
y: -dy,
z: 0.0,
mode: WheelMode::DeltaPixel,
};
@ -768,7 +766,7 @@ impl IOCompositor {
txn.set_scroll_offsets(
external_scroll_id,
vec![SampledScrollOffset {
offset: -offset,
offset,
generation: 0,
}],
);
@ -1169,7 +1167,6 @@ impl IOCompositor {
continue;
};
let offset = LayoutVector2D::new(-offset.x, -offset.y);
transaction.set_scroll_offsets(
external_id,
vec![SampledScrollOffset {
@ -1731,11 +1728,10 @@ impl IOCompositor {
self.send_root_pipeline_display_list_in_transaction(&mut transaction);
}
for update in scroll_offset_updates {
let offset = LayoutVector2D::new(-update.offset.x, -update.offset.y);
transaction.set_scroll_offsets(
update.external_scroll_id,
vec![SampledScrollOffset {
offset,
offset: update.offset,
generation: 0,
}],
);