mirror of
https://github.com/servo/servo.git
synced 2025-08-07 06:25:32 +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
|
@ -361,14 +361,14 @@ impl RunningAppState {
|
|||
.shortcut(Modifiers::empty(), Key::PageDown, || {
|
||||
let scroll_location = ScrollLocation::Delta(Vector2D::new(
|
||||
0.0,
|
||||
-self.inner().window.page_height() + 2.0 * LINE_HEIGHT,
|
||||
self.inner().window.page_height() - 2.0 * LINE_HEIGHT,
|
||||
));
|
||||
webview.notify_scroll_event(scroll_location, origin);
|
||||
})
|
||||
.shortcut(Modifiers::empty(), Key::PageUp, || {
|
||||
let scroll_location = ScrollLocation::Delta(Vector2D::new(
|
||||
0.0,
|
||||
self.inner().window.page_height() - 2.0 * LINE_HEIGHT,
|
||||
-self.inner().window.page_height() + 2.0 * LINE_HEIGHT,
|
||||
));
|
||||
webview.notify_scroll_event(scroll_location, origin);
|
||||
})
|
||||
|
@ -379,19 +379,19 @@ impl RunningAppState {
|
|||
webview.notify_scroll_event(ScrollLocation::End, origin);
|
||||
})
|
||||
.shortcut(Modifiers::empty(), Key::ArrowUp, || {
|
||||
let location = ScrollLocation::Delta(Vector2D::new(0.0, 3.0 * LINE_HEIGHT));
|
||||
webview.notify_scroll_event(location, origin);
|
||||
})
|
||||
.shortcut(Modifiers::empty(), Key::ArrowDown, || {
|
||||
let location = ScrollLocation::Delta(Vector2D::new(0.0, -3.0 * LINE_HEIGHT));
|
||||
webview.notify_scroll_event(location, origin);
|
||||
})
|
||||
.shortcut(Modifiers::empty(), Key::ArrowDown, || {
|
||||
let location = ScrollLocation::Delta(Vector2D::new(0.0, 3.0 * LINE_HEIGHT));
|
||||
webview.notify_scroll_event(location, origin);
|
||||
})
|
||||
.shortcut(Modifiers::empty(), Key::ArrowLeft, || {
|
||||
let location = ScrollLocation::Delta(Vector2D::new(LINE_HEIGHT, 0.0));
|
||||
let location = ScrollLocation::Delta(Vector2D::new(-LINE_HEIGHT, 0.0));
|
||||
webview.notify_scroll_event(location, origin);
|
||||
})
|
||||
.shortcut(Modifiers::empty(), Key::ArrowRight, || {
|
||||
let location = ScrollLocation::Delta(Vector2D::new(-LINE_HEIGHT, 0.0));
|
||||
let location = ScrollLocation::Delta(Vector2D::new(LINE_HEIGHT, 0.0));
|
||||
webview.notify_scroll_event(location, origin);
|
||||
});
|
||||
}
|
||||
|
|
|
@ -630,10 +630,9 @@ impl WindowPortsMethods for Window {
|
|||
dy = 0.0;
|
||||
}
|
||||
|
||||
let scroll_location = ScrollLocation::Delta(Vector2D::new(dx as f32, dy as f32));
|
||||
|
||||
// Send events
|
||||
webview.notify_input_event(InputEvent::Wheel(WheelEvent::new(delta, point)));
|
||||
let scroll_location = ScrollLocation::Delta(-Vector2D::new(dx as f32, dy as f32));
|
||||
webview.notify_scroll_event(scroll_location, point.to_i32());
|
||||
},
|
||||
WindowEvent::Touch(touch) => {
|
||||
|
|
|
@ -244,32 +244,6 @@ pub extern "C" fn Java_org_servo_servoview_JNIServo_goForward<'local>(
|
|||
call(&mut env, |s| s.go_forward());
|
||||
}
|
||||
|
||||
#[unsafe(no_mangle)]
|
||||
pub extern "C" fn Java_org_servo_servoview_JNIServo_scrollStart<'local>(
|
||||
mut env: JNIEnv<'local>,
|
||||
_: JClass<'local>,
|
||||
dx: jint,
|
||||
dy: jint,
|
||||
x: jint,
|
||||
y: jint,
|
||||
) {
|
||||
debug!("scrollStart");
|
||||
call(&mut env, |s| s.scroll_start(dx as f32, dy as f32, x, y));
|
||||
}
|
||||
|
||||
#[unsafe(no_mangle)]
|
||||
pub extern "C" fn Java_org_servo_servoview_JNIServo_scrollEnd<'local>(
|
||||
mut env: JNIEnv<'local>,
|
||||
_: JClass<'local>,
|
||||
dx: jint,
|
||||
dy: jint,
|
||||
x: jint,
|
||||
y: jint,
|
||||
) {
|
||||
debug!("scrollEnd");
|
||||
call(&mut env, |s| s.scroll_end(dx as f32, dy as f32, x, y));
|
||||
}
|
||||
|
||||
#[unsafe(no_mangle)]
|
||||
pub extern "C" fn Java_org_servo_servoview_JNIServo_scroll<'local>(
|
||||
mut env: JNIEnv<'local>,
|
||||
|
|
|
@ -474,18 +474,6 @@ impl RunningAppState {
|
|||
self.perform_updates();
|
||||
}
|
||||
|
||||
/// Start scrolling.
|
||||
/// x/y are scroll coordinates.
|
||||
/// dx/dy are scroll deltas.
|
||||
#[cfg(not(target_env = "ohos"))]
|
||||
pub fn scroll_start(&self, dx: f32, dy: f32, x: i32, y: i32) {
|
||||
let delta = Vector2D::new(dx, dy);
|
||||
let scroll_location = ScrollLocation::Delta(delta);
|
||||
self.active_webview()
|
||||
.notify_scroll_event(scroll_location, Point2D::new(x, y));
|
||||
self.perform_updates();
|
||||
}
|
||||
|
||||
/// Scroll.
|
||||
/// x/y are scroll coordinates.
|
||||
/// dx/dy are scroll deltas.
|
||||
|
@ -497,18 +485,6 @@ impl RunningAppState {
|
|||
self.perform_updates();
|
||||
}
|
||||
|
||||
/// End scrolling.
|
||||
/// x/y are scroll coordinates.
|
||||
/// dx/dy are scroll deltas.
|
||||
#[cfg(not(target_env = "ohos"))]
|
||||
pub fn scroll_end(&self, dx: f32, dy: f32, x: i32, y: i32) {
|
||||
let delta = Vector2D::new(dx, dy);
|
||||
let scroll_location = ScrollLocation::Delta(delta);
|
||||
self.active_webview()
|
||||
.notify_scroll_event(scroll_location, Point2D::new(x, y));
|
||||
self.perform_updates();
|
||||
}
|
||||
|
||||
/// Touch event: press down
|
||||
pub fn touch_down(&self, x: f32, y: f32, pointer_id: i32) {
|
||||
self.active_webview()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue