Title: [269151] trunk/Source/WebKit
Revision
269151
Author
[email protected]
Date
2020-10-29 09:53:19 -0700 (Thu, 29 Oct 2020)

Log Message

[WPE] Add axis-locking to kinetic scrolling
https://bugs.webkit.org/show_bug.cgi?id=209729

Reviewed by Adrian Perez de Castro.

Add axis-locking to scroll gestures on WPE, and new WPE-specific
settings to control the process.

* UIProcess/API/wpe/ScrollGestureController.cpp:
(WebKit::ScrollGestureController::handleEvent):
* UIProcess/API/wpe/ScrollGestureController.h:

Modified Paths

Diff

Modified: trunk/Source/WebKit/ChangeLog (269150 => 269151)


--- trunk/Source/WebKit/ChangeLog	2020-10-29 16:20:31 UTC (rev 269150)
+++ trunk/Source/WebKit/ChangeLog	2020-10-29 16:53:19 UTC (rev 269151)
@@ -1,3 +1,17 @@
+2020-10-29  Chris Lord  <[email protected]>
+
+        [WPE] Add axis-locking to kinetic scrolling
+        https://bugs.webkit.org/show_bug.cgi?id=209729
+
+        Reviewed by Adrian Perez de Castro.
+
+        Add axis-locking to scroll gestures on WPE, and new WPE-specific
+        settings to control the process.
+
+        * UIProcess/API/wpe/ScrollGestureController.cpp:
+        (WebKit::ScrollGestureController::handleEvent):
+        * UIProcess/API/wpe/ScrollGestureController.h:
+
 2020-10-29  Youenn Fablet  <[email protected]>
 
         Improve LibWebRTCSocketClient logging

Modified: trunk/Source/WebKit/UIProcess/API/wpe/ScrollGestureController.cpp (269150 => 269151)


--- trunk/Source/WebKit/UIProcess/API/wpe/ScrollGestureController.cpp	2020-10-29 16:20:31 UTC (rev 269150)
+++ trunk/Source/WebKit/UIProcess/API/wpe/ScrollGestureController.cpp	2020-10-29 16:53:19 UTC (rev 269151)
@@ -26,10 +26,18 @@
 #include "config.h"
 #include "ScrollGestureController.h"
 
+#include "WebKitSettings.h"
 #include <WebCore/Scrollbar.h>
 
 namespace WebKit {
 
+// FIXME: These ought to be either configurable or derived from system
+//        properties, such as screen size and pixel density.
+static constexpr uint32_t scrollCaptureThreshold { 200 };
+static constexpr uint32_t axisLockMovementThreshold { 8 };
+static constexpr uint32_t axisLockActivationThreshold { 15 };
+static constexpr uint32_t axisLockReleaseThreshold { 30 };
+
 bool ScrollGestureController::handleEvent(const struct wpe_input_touch_event_raw* touchPoint)
 {
     switch (touchPoint->type) {
@@ -39,6 +47,8 @@
         m_start.y = touchPoint->y;
         m_offset.x = touchPoint->x;
         m_offset.y = touchPoint->y;
+        m_xAxisLockBroken = false;
+        m_yAxisLockBroken = false;
         return false;
     case wpe_input_touch_event_type_motion:
         if (!m_handling) {
@@ -49,7 +59,7 @@
             int pixelsPerLineStep = WebCore::Scrollbar::pixelsPerLineStep();
             m_handling = std::abs(deltaX) >= pixelsPerLineStep
                 || std::abs(deltaY) >= pixelsPerLineStep
-                || deltaTime >= 200;
+                || deltaTime >= scrollCaptureThreshold;
         }
         if (m_handling) {
 #if WPE_CHECK_VERSION(1, 5, 0)
@@ -58,8 +68,22 @@
                 touchPoint->time, m_start.x, m_start.y,
                 0, 0, 0,
             };
-            m_axisEvent.x_axis = -(m_offset.x - touchPoint->x);
-            m_axisEvent.y_axis = -(m_offset.y - touchPoint->y);
+
+            auto xOffset = std::abs(touchPoint->x - m_start.x);
+            auto yOffset = std::abs(touchPoint->y - m_start.y);
+
+            if (xOffset >= axisLockReleaseThreshold)
+                m_xAxisLockBroken = true;
+            if (yOffset >= axisLockReleaseThreshold)
+                m_yAxisLockBroken = true;
+
+            if (xOffset >= axisLockMovementThreshold && yOffset >= axisLockMovementThreshold && xOffset < axisLockActivationThreshold && yOffset < axisLockActivationThreshold) {
+                m_xAxisLockBroken = true;
+                m_yAxisLockBroken = true;
+            }
+
+            m_axisEvent.x_axis = (m_xAxisLockBroken || yOffset < axisLockActivationThreshold) ?  -(m_offset.x - touchPoint->x) : 0;
+            m_axisEvent.y_axis = (m_yAxisLockBroken || xOffset < axisLockActivationThreshold) ?  -(m_offset.y - touchPoint->y) : 0;
 #else
             m_axisEvent = {
                 wpe_input_axis_event_type_motion,

Modified: trunk/Source/WebKit/UIProcess/API/wpe/ScrollGestureController.h (269150 => 269151)


--- trunk/Source/WebKit/UIProcess/API/wpe/ScrollGestureController.h	2020-10-29 16:20:31 UTC (rev 269150)
+++ trunk/Source/WebKit/UIProcess/API/wpe/ScrollGestureController.h	2020-10-29 16:53:19 UTC (rev 269151)
@@ -68,6 +68,9 @@
     struct wpe_input_axis_event m_axisEvent;
 #endif
     WebWheelEvent::Phase m_phase { WebWheelEvent::Phase::PhaseNone };
+
+    bool m_xAxisLockBroken { false };
+    bool m_yAxisLockBroken { false };
 };
 
 } // namespace WebKit
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to