mirror of
https://github.com/servo/servo.git
synced 2025-07-19 05:13:55 +01:00
script: Ensure that keyboard modifiers, screen point, and client point are set in WheelEvents (#37947)
- Updating the WheelEvent initialization to correctly handle keyboard modifiers when the wheel event is triggered. The changes ensure that the modifiers (Ctrl, Alt, Shift, Meta) are properly set based on the current state of the keyboard when the wheel event is created. This is particularly important for scenarios where the wheel event is influenced by key presses, such as scrolling with the Ctrl key pressed to zoom in or out. - Updating the `screen_point` and `client_point` as it was always 0,0 before. Now, it shows the correct position of the mouse pointer while triggering the wheel event. Test: Manual Test case and existing WPT tests (classic/perform_actions/wheel.py[test_scroll_with_key_pressed]) Fixes: #37827 Signed-off-by: abdelrahman1234567 <abdelrahman.hossameldin.awadalla@huawei.com>
This commit is contained in:
parent
f70a4eb4ff
commit
c76c44d0fb
5 changed files with 129 additions and 17 deletions
|
@ -2186,11 +2186,11 @@ impl Document {
|
|||
pub(crate) fn handle_wheel_event(
|
||||
&self,
|
||||
event: WheelEvent,
|
||||
hit_test_result: Option<CompositorHitTestResult>,
|
||||
input_event: &ConstellationInputEvent,
|
||||
can_gc: CanGc,
|
||||
) {
|
||||
// Ignore all incoming events without a hit test.
|
||||
let Some(hit_test_result) = hit_test_result else {
|
||||
let Some(hit_test_result) = &input_event.hit_test_result else {
|
||||
return;
|
||||
};
|
||||
|
||||
|
@ -2220,6 +2220,16 @@ impl Document {
|
|||
EventCancelable::Cancelable,
|
||||
Some(&self.window),
|
||||
0i32,
|
||||
hit_test_result.point_in_viewport.to_i32(),
|
||||
hit_test_result.point_in_viewport.to_i32(),
|
||||
hit_test_result
|
||||
.point_relative_to_initial_containing_block
|
||||
.to_i32(),
|
||||
input_event.active_keyboard_modifiers,
|
||||
0i16,
|
||||
input_event.pressed_mouse_buttons,
|
||||
None,
|
||||
None,
|
||||
// winit defines positive wheel delta values as revealing more content left/up.
|
||||
// https://docs.rs/winit-gtk/latest/winit/event/enum.MouseScrollDelta.html
|
||||
// This is the opposite of wheel delta in uievents
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue