mirror of
https://github.com/servo/servo.git
synced 2025-08-03 04:30:10 +01:00
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:
parent
d33d057763
commit
89bfa26f00
14 changed files with 54 additions and 132 deletions
|
@ -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,
|
||||
}],
|
||||
);
|
||||
|
|
|
@ -406,7 +406,9 @@ impl TouchHandler {
|
|||
*velocity /= 2.0;
|
||||
// update the touch point every time when panning.
|
||||
touch_sequence.active_touch_points[idx].point = point;
|
||||
TouchMoveAction::Scroll(delta, point)
|
||||
|
||||
// Scroll offsets are opposite to the direction of finger motion.
|
||||
TouchMoveAction::Scroll(-delta, point)
|
||||
} else if delta.x.abs() > TOUCH_PAN_MIN_SCREEN_PX ||
|
||||
delta.y.abs() > TOUCH_PAN_MIN_SCREEN_PX
|
||||
{
|
||||
|
@ -417,7 +419,9 @@ impl TouchHandler {
|
|||
touch_sequence.prevent_click = true;
|
||||
// update the touch point
|
||||
touch_sequence.active_touch_points[idx].point = point;
|
||||
TouchMoveAction::Scroll(delta, point)
|
||||
|
||||
// Scroll offsets are opposite to the direction of finger motion.
|
||||
TouchMoveAction::Scroll(-delta, point)
|
||||
} else {
|
||||
// We don't update the touchpoint, so multiple small moves can
|
||||
// accumulate and merge into a larger move.
|
||||
|
@ -435,8 +439,11 @@ impl TouchHandler {
|
|||
touch_sequence.active_touch_points[idx].point = point;
|
||||
let (d1, c1) = touch_sequence.pinch_distance_and_center();
|
||||
let magnification = d1 / d0;
|
||||
|
||||
let scroll_delta = c1 - c0 * Scale::new(magnification);
|
||||
TouchMoveAction::Zoom(magnification, scroll_delta)
|
||||
|
||||
// Scroll offsets are opposite to the direction of finger motion.
|
||||
TouchMoveAction::Zoom(magnification, -scroll_delta)
|
||||
} else {
|
||||
// We don't update the touchpoint, so multiple small moves can
|
||||
// accumulate and merge into a larger move.
|
||||
|
|
|
@ -339,7 +339,7 @@ impl WebViewRenderer {
|
|||
pub(crate) fn on_vsync(&mut self) {
|
||||
if let Some(fling_action) = self.touch_handler.on_vsync() {
|
||||
self.on_scroll_window_event(
|
||||
ScrollLocation::Delta(fling_action.delta),
|
||||
ScrollLocation::Delta(-fling_action.delta),
|
||||
fling_action.cursor,
|
||||
);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue