Skip to content

Truly independent web browser

LibWeb: Exclude wheel event handling time from gesture pauses

Tim Ledbetter0498b8d361d4
diff --git a/Libraries/LibCompositing/Scrolling/WheelGestureIdentity.cpp b/Libraries/LibCompositing/Scrolling/WheelGestureIdentity.cpp
index 3af9bcb7e84..efa21941664 100644
--- a/Libraries/LibCompositing/Scrolling/WheelGestureIdentity.cpp
+++ b/Libraries/LibCompositing/Scrolling/WheelGestureIdentity.cpp
@@ -61,4 +61,12 @@ void WheelGestureIdentity::advance_to(Web::ScrollGesturePhase phase, MonotonicTi
m_ended_at = now;
}
+void WheelGestureIdentity::did_handle_event(MonotonicTime now)
+{
+ bool handled_event_ended_gesture = m_ended_at == m_last_event_time;
+ if (handled_event_ended_gesture)
+ m_ended_at = now;
+ m_last_event_time = now;
+}
+
}
diff --git a/Libraries/LibCompositing/Scrolling/WheelGestureIdentity.h b/Libraries/LibCompositing/Scrolling/WheelGestureIdentity.h
index b46d714deaa..1f117b45563 100644
--- a/Libraries/LibCompositing/Scrolling/WheelGestureIdentity.h
+++ b/Libraries/LibCompositing/Scrolling/WheelGestureIdentity.h
@@ -28,6 +28,7 @@ public:
// Positions and the slop are in whatever unit the caller routes in.
bool is_continued_by(Gfx::FloatPoint position, Web::ScrollGesturePhase, u32 modifiers, MonotonicTime now, float position_slop) const;
void advance_to(Web::ScrollGesturePhase, MonotonicTime now);
+ void did_handle_event(MonotonicTime now);
private:
enum class Kind : u8 {
diff --git a/Libraries/LibWeb/Page/EventHandler.cpp b/Libraries/LibWeb/Page/EventHandler.cpp
index e8d9bca57c1..488e0ecabe6 100644
--- a/Libraries/LibWeb/Page/EventHandler.cpp
+++ b/Libraries/LibWeb/Page/EventHandler.cpp
@@ -952,6 +952,11 @@ EventResult EventHandler::handle_mousewheel(CSSPixelPoint visual_viewport_positi
else
m_wheel_scroll_latch.clear();
+ ScopeGuard measure_next_pause_from_end_of_handling = [this] {
+ if (m_wheel_scroll_latch.has_value())
+ m_wheel_scroll_latch->gesture.did_handle_event(MonotonicTime::now());
+ };
+
// A wheel step is routed against the offsets the compositor holds now, which a step it just took may
// have moved ahead of any rendering update.
m_navigable->adopt_pending_async_scroll_offsets(Compositing::AsyncScrollUpdateFreshness::FromCompositor);