Skip to content
Permalink
Browse files
[GTK] REGRESSION: Touch scrolling is broken
https://bugs.webkit.org/show_bug.cgi?id=235436

Reviewed by Chris Lord.

Source/WebKit:

Remove webkitWebViewBaseSetWheelHasPreciseDeltas(), instead add a parameter
to webkitWebViewBaseSynthesizeWheelEvent() that specifies whether the event
should have precise deltas or not.

Correct the touch swipe velocity, since it won't get multiplied by
pixelsPerLineStep().

* UIProcess/API/gtk/PageClientImpl.cpp:
(WebKit::PageClientImpl::navigationGestureDidBegin):
* UIProcess/API/gtk/WebKitWebViewBase.cpp:
(webkitWebViewBaseZoomBegin):
(webkitWebViewBaseTouchDragBegin):
(webkitWebViewBaseTouchDragUpdate):
(webkitWebViewBaseTouchSwipe):
(webkitWebViewBaseSynthesizeWheelEvent):
(webkitWebViewBaseSetWheelHasPreciseDeltas): Deleted.
* UIProcess/API/gtk/WebKitWebViewBaseInternal.h:
* UIProcess/API/gtk/WebKitWebViewBasePrivate.h:
* UIProcess/Automation/gtk/WebAutomationSessionGtk.cpp:
(WebKit::WebAutomationSession::platformSimulateWheelInteraction):

Tools:

Stop using webkitWebViewBaseSetWheelHasPreciseDeltas(), instead pass the correct parameter into
webkitWebViewBaseSynthesizeWheelEvent().

* WebKitTestRunner/EventSenderProxy.h:
* WebKitTestRunner/gtk/EventSenderProxyGtk.cpp:
(WTR::EventSenderProxy::~EventSenderProxy):
(WTR::EventSenderProxy::mouseScrollBy):
(WTR::EventSenderProxy::continuousMouseScrollBy):
(WTR::EventSenderProxy::mouseScrollByWithWheelAndMomentumPhases):
(WTR::EventSenderProxy::setWheelHasPreciseDeltas):



Canonical link: https://commits.webkit.org/246428@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@288609 268f45cc-cd09-0410-ab3c-d52691b4dbfc
  • Loading branch information
Exalm committed Jan 26, 2022
1 parent f543db7 commit 9fd5052c329eab650231c329a004e747b03b89d5
Showing 9 changed files with 70 additions and 29 deletions.
@@ -1,3 +1,31 @@
2022-01-26 Alexander Mikhaylenko <alexm@gnome.org>

[GTK] REGRESSION: Touch scrolling is broken
https://bugs.webkit.org/show_bug.cgi?id=235436

Reviewed by Chris Lord.

Remove webkitWebViewBaseSetWheelHasPreciseDeltas(), instead add a parameter
to webkitWebViewBaseSynthesizeWheelEvent() that specifies whether the event
should have precise deltas or not.

Correct the touch swipe velocity, since it won't get multiplied by
pixelsPerLineStep().

* UIProcess/API/gtk/PageClientImpl.cpp:
(WebKit::PageClientImpl::navigationGestureDidBegin):
* UIProcess/API/gtk/WebKitWebViewBase.cpp:
(webkitWebViewBaseZoomBegin):
(webkitWebViewBaseTouchDragBegin):
(webkitWebViewBaseTouchDragUpdate):
(webkitWebViewBaseTouchSwipe):
(webkitWebViewBaseSynthesizeWheelEvent):
(webkitWebViewBaseSetWheelHasPreciseDeltas): Deleted.
* UIProcess/API/gtk/WebKitWebViewBaseInternal.h:
* UIProcess/API/gtk/WebKitWebViewBasePrivate.h:
* UIProcess/Automation/gtk/WebAutomationSessionGtk.cpp:
(WebKit::WebAutomationSession::platformSimulateWheelInteraction):

2022-01-25 Chris Dumez <cdumez@apple.com>

REGRESSION (iOS 15.2): Loading gets stuck after back-navigation involving COOP header
@@ -474,7 +474,7 @@ void PageClientImpl::didFinishLoadingDataForCustomContentProvider(const String&,

void PageClientImpl::navigationGestureDidBegin()
{
webkitWebViewBaseSynthesizeWheelEvent(WEBKIT_WEB_VIEW_BASE(m_viewWidget), 0, 0, 0, 0, WheelEventPhase::Began, WheelEventPhase::NoPhase);
webkitWebViewBaseSynthesizeWheelEvent(WEBKIT_WEB_VIEW_BASE(m_viewWidget), 0, 0, 0, 0, WheelEventPhase::Began, WheelEventPhase::NoPhase, true);
}

void PageClientImpl::navigationGestureWillEnd(bool, WebBackForwardListItem&)
@@ -284,7 +284,6 @@ struct _WebKitWebViewBasePrivate {
TouchEventsMap touchEvents;
IntSize contentsSize;
std::optional<MotionEvent> lastMotionEvent;
bool wheelHasPreciseDeltas { false };
bool isBlank;
bool shouldNotifyFocusEvents { true };

@@ -1842,7 +1841,7 @@ static void webkitWebViewBaseZoomBegin(WebKitWebViewBase* webViewBase, GdkEventS

auto* event = gtk_gesture_get_last_event(gesture, sequence);

webkitWebViewBaseSynthesizeWheelEvent(webViewBase, event, 0, 0, x, y, WheelEventPhase::Began, WheelEventPhase::NoPhase);
webkitWebViewBaseSynthesizeWheelEvent(webViewBase, event, 0, 0, x, y, WheelEventPhase::Began, WheelEventPhase::NoPhase, true);
}

static void webkitWebViewBaseZoomChanged(WebKitWebViewBase* webViewBase, gdouble scale, GtkGesture* gesture)
@@ -1922,7 +1921,7 @@ static void webkitWebViewBaseTouchDragBegin(WebKitWebViewBase* webViewBase, gdou
auto* sequence = gtk_gesture_single_get_current_sequence(GTK_GESTURE_SINGLE(gesture));
auto* event = gtk_gesture_get_last_event(gesture, sequence);

webkitWebViewBaseSynthesizeWheelEvent(webViewBase, event, 0, 0, startX, startY, WheelEventPhase::Began, WheelEventPhase::NoPhase);
webkitWebViewBaseSynthesizeWheelEvent(webViewBase, event, 0, 0, startX, startY, WheelEventPhase::Began, WheelEventPhase::NoPhase, true);
}

static void webkitWebViewBaseTouchDragUpdate(WebKitWebViewBase* webViewBase, double offsetX, double offsetY, GtkGesture* gesture)
@@ -1949,26 +1948,26 @@ static void webkitWebViewBaseTouchDragUpdate(WebKitWebViewBase* webViewBase, dou
webkitWebViewBaseSynthesizeMouseEvent(webViewBase, MouseEventType::Motion, 0, 0, x, y, modifiers, 1, mousePointerEventType());
webkitWebViewBaseSynthesizeMouseEvent(webViewBase, MouseEventType::Press, GDK_BUTTON_PRIMARY, 0, x, y, modifiers, 0, mousePointerEventType());
} else
webkitWebViewBaseSynthesizeWheelEvent(webViewBase, event, 0, 0, x, y, WheelEventPhase::Began, WheelEventPhase::NoPhase);
webkitWebViewBaseSynthesizeWheelEvent(webViewBase, event, 0, 0, x, y, WheelEventPhase::Began, WheelEventPhase::NoPhase, true);
}

if (priv->isLongPressed)
webkitWebViewBaseSynthesizeMouseEvent(webViewBase, MouseEventType::Motion, GDK_BUTTON_PRIMARY, GDK_BUTTON1_MASK, x + offsetX, y + offsetY, modifiers, 0, mousePointerEventType());
else {
double deltaX = (priv->dragOffset.x() - offsetX) / Scrollbar::pixelsPerLineStep();
double deltaY = (priv->dragOffset.y() - offsetY) / Scrollbar::pixelsPerLineStep();
double deltaX = priv->dragOffset.x() - offsetX;
double deltaY = priv->dragOffset.y() - offsetY;
priv->dragOffset.set(offsetX, offsetY);

ViewGestureController* controller = webkitWebViewBaseViewGestureController(webViewBase);
if (controller && controller->isSwipeGestureEnabled()) {
FloatSize delta(deltaX, deltaY);
FloatSize delta(deltaX / Scrollbar::pixelsPerLineStep(), deltaY / Scrollbar::pixelsPerLineStep());
int32_t eventTime = static_cast<int32_t>(gtk_event_controller_get_current_event_time(GTK_EVENT_CONTROLLER(gesture)));
PlatformGtkScrollData scrollData = { .delta = delta, .eventTime = eventTime, .source = GDK_SOURCE_TOUCHSCREEN, .isEnd = false };
if (controller->handleScrollWheelEvent(&scrollData))
return;
}

webkitWebViewBaseSynthesizeWheelEvent(webViewBase, event, -deltaX, -deltaY, x, y, WheelEventPhase::Changed, WheelEventPhase::NoPhase);
webkitWebViewBaseSynthesizeWheelEvent(webViewBase, event, -deltaX, -deltaY, x, y, WheelEventPhase::Changed, WheelEventPhase::NoPhase, true);
}
}

@@ -2011,7 +2010,7 @@ static void webkitWebViewBaseTouchSwipe(WebKitWebViewBase* webViewBase, gdouble
return;
}

webkitWebViewBaseSynthesizeWheelEvent(webViewBase, event, -velocityX / Scrollbar::pixelsPerLineStep(), velocityY / Scrollbar::pixelsPerLineStep(), x, y, WheelEventPhase::NoPhase, WheelEventPhase::Began);
webkitWebViewBaseSynthesizeWheelEvent(webViewBase, event, -velocityX, -velocityY, x, y, WheelEventPhase::NoPhase, WheelEventPhase::Began, true);
}
}

@@ -3000,29 +2999,24 @@ static inline WebWheelEvent::Phase toWebKitWheelEventPhase(WheelEventPhase phase
RELEASE_ASSERT_NOT_REACHED();
}

void webkitWebViewBaseSynthesizeWheelEvent(WebKitWebViewBase* webViewBase, double deltaX, double deltaY, int x, int y, WheelEventPhase phase, WheelEventPhase momentumPhase)
void webkitWebViewBaseSynthesizeWheelEvent(WebKitWebViewBase* webViewBase, double deltaX, double deltaY, int x, int y, WheelEventPhase phase, WheelEventPhase momentumPhase, bool hasPreciseDeltas)
{
webkitWebViewBaseSynthesizeWheelEvent(webViewBase, nullptr, deltaX, deltaY, x, y, phase, momentumPhase);
webkitWebViewBaseSynthesizeWheelEvent(webViewBase, nullptr, deltaX, deltaY, x, y, phase, momentumPhase, hasPreciseDeltas);
}

void webkitWebViewBaseSynthesizeWheelEvent(WebKitWebViewBase* webViewBase, const GdkEvent* event, double deltaX, double deltaY, int x, int y, WheelEventPhase phase, WheelEventPhase momentumPhase)
void webkitWebViewBaseSynthesizeWheelEvent(WebKitWebViewBase* webViewBase, const GdkEvent* event, double deltaX, double deltaY, int x, int y, WheelEventPhase phase, WheelEventPhase momentumPhase, bool hasPreciseDeltas)
{
WebKitWebViewBasePrivate* priv = webViewBase->priv;
if (priv->dialog)
return;

FloatSize wheelTicks(deltaX, deltaY);
FloatSize delta(wheelTicks);
if (!priv->wheelHasPreciseDeltas)
if (!hasPreciseDeltas)
delta.scale(static_cast<float>(Scrollbar::pixelsPerLineStep()));

priv->pageProxy->handleWheelEvent(NativeWebWheelEvent(const_cast<GdkEvent*>(event), { x, y }, widgetRootCoords(GTK_WIDGET(webViewBase), x, y),
delta, wheelTicks, toWebKitWheelEventPhase(phase), toWebKitWheelEventPhase(momentumPhase), priv->wheelHasPreciseDeltas));
}

void webkitWebViewBaseSetWheelHasPreciseDeltas(WebKitWebViewBase* webViewBase, bool hasPreciseDeltas)
{
webViewBase->priv->wheelHasPreciseDeltas = hasPreciseDeltas;
delta, wheelTicks, toWebKitWheelEventPhase(phase), toWebKitWheelEventPhase(momentumPhase), true));
}

void webkitWebViewBaseMakeBlank(WebKitWebViewBase* webViewBase, bool makeBlank)
@@ -44,6 +44,5 @@ enum class ShouldTranslateKeyboardState { No, Yes };
WK_EXPORT void webkitWebViewBaseSynthesizeKeyEvent(WebKitWebViewBase*, KeyEventType, unsigned keyVal, unsigned modifiers, ShouldTranslateKeyboardState);

enum class WheelEventPhase { NoPhase, Began, Changed, Ended, Cancelled, MayBegin };
WK_EXPORT void webkitWebViewBaseSynthesizeWheelEvent(WebKitWebViewBase*, double deltaX, double deltaY, int x, int y, WheelEventPhase, WheelEventPhase momentumPhase);
WK_EXPORT void webkitWebViewBaseSetWheelHasPreciseDeltas(WebKitWebViewBase*, bool);
WK_EXPORT void webkitWebViewBaseSynthesizeWheelEvent(WebKitWebViewBase*, double deltaX, double deltaY, int x, int y, WheelEventPhase, WheelEventPhase momentumPhase, bool);

@@ -114,7 +114,7 @@ void webkitWebViewBaseDidLosePointerLock(WebKitWebViewBase*);
void webkitWebViewBaseSetInputMethodContext(WebKitWebViewBase*, WebKitInputMethodContext*);
WebKitInputMethodContext* webkitWebViewBaseGetInputMethodContext(WebKitWebViewBase*);
void webkitWebViewBaseSynthesizeCompositionKeyPress(WebKitWebViewBase*, const String& text, std::optional<Vector<WebCore::CompositionUnderline>>&&, std::optional<WebKit::EditingRange>&&);
void webkitWebViewBaseSynthesizeWheelEvent(WebKitWebViewBase*, const GdkEvent*, double deltaX, double deltaY, int x, int y, WheelEventPhase, WheelEventPhase momentumPhase);
void webkitWebViewBaseSynthesizeWheelEvent(WebKitWebViewBase*, const GdkEvent*, double deltaX, double deltaY, int x, int y, WheelEventPhase, WheelEventPhase momentumPhase, bool hasPreciseDeltas);

void webkitWebViewBaseMakeBlank(WebKitWebViewBase*, bool);
void webkitWebViewBasePageGrabbedTouch(WebKitWebViewBase*);
@@ -335,7 +335,7 @@ void WebAutomationSession::platformSimulateWheelInteraction(WebPageProxy& page,
auto* viewWidget = reinterpret_cast<WebKitWebViewBase*>(page.viewWidget());
FloatSize scrollDelta(delta);
scrollDelta.scale(1 / static_cast<float>(Scrollbar::pixelsPerLineStep()));
webkitWebViewBaseSynthesizeWheelEvent(viewWidget, -scrollDelta.width(), -scrollDelta.height(), locationInViewport.x(), locationInViewport.y(), WheelEventPhase::NoPhase, WheelEventPhase::NoPhase);
webkitWebViewBaseSynthesizeWheelEvent(viewWidget, -scrollDelta.width(), -scrollDelta.height(), locationInViewport.x(), locationInViewport.y(), WheelEventPhase::NoPhase, WheelEventPhase::NoPhase, false);
}
#endif // ENABLE(WEBDRIVER_WHEEL_INTERACTIONS)

@@ -1,3 +1,21 @@
2022-01-26 Alexander Mikhaylenko <alexm@gnome.org>

[GTK] REGRESSION: Touch scrolling is broken
https://bugs.webkit.org/show_bug.cgi?id=235436

Reviewed by Chris Lord.

Stop using webkitWebViewBaseSetWheelHasPreciseDeltas(), instead pass the correct parameter into
webkitWebViewBaseSynthesizeWheelEvent().

* WebKitTestRunner/EventSenderProxy.h:
* WebKitTestRunner/gtk/EventSenderProxyGtk.cpp:
(WTR::EventSenderProxy::~EventSenderProxy):
(WTR::EventSenderProxy::mouseScrollBy):
(WTR::EventSenderProxy::continuousMouseScrollBy):
(WTR::EventSenderProxy::mouseScrollByWithWheelAndMomentumPhases):
(WTR::EventSenderProxy::setWheelHasPreciseDeltas):

2022-01-25 Chris Dumez <cdumez@apple.com>

REGRESSION (iOS 15.2): Loading gets stuck after back-navigation involving COOP header
@@ -152,6 +152,9 @@ class EventSenderProxy {
#if PLATFORM(COCOA)
int m_eventNumber { 0 };
#endif
#if PLATFORM(GTK)
bool m_hasPreciseDeltas { false };
#endif
#if PLATFORM(WPE)
uint32_t m_buttonState { 0 };
Vector<struct wpe_input_touch_event_raw> m_touchEvents;
@@ -77,7 +77,6 @@ static inline WebKitWebViewBase* toWebKitGLibAPI(PlatformWKView view)

EventSenderProxy::~EventSenderProxy()
{
webkitWebViewBaseSetWheelHasPreciseDeltas(toWebKitGLibAPI(m_testController->mainWebView()->platformView()), false);
}

static unsigned eventSenderButtonToGDKButton(unsigned button)
@@ -298,7 +297,7 @@ void EventSenderProxy::mouseScrollBy(int horizontal, int vertical)
return;

webkitWebViewBaseSynthesizeWheelEvent(toWebKitGLibAPI(m_testController->mainWebView()->platformView()),
horizontal, vertical, m_position.x, m_position.y, WheelEventPhase::NoPhase, WheelEventPhase::NoPhase);
horizontal, vertical, m_position.x, m_position.y, WheelEventPhase::NoPhase, WheelEventPhase::NoPhase, m_hasPreciseDeltas);
}

void EventSenderProxy::continuousMouseScrollBy(int horizontal, int vertical, bool paged)
@@ -310,7 +309,7 @@ void EventSenderProxy::continuousMouseScrollBy(int horizontal, int vertical, boo
}

webkitWebViewBaseSynthesizeWheelEvent(toWebKitGLibAPI(m_testController->mainWebView()->platformView()),
horizontal / pixelsPerScrollTick, vertical / pixelsPerScrollTick, m_position.x, m_position.y, WheelEventPhase::NoPhase, WheelEventPhase::NoPhase);
horizontal / pixelsPerScrollTick, vertical / pixelsPerScrollTick, m_position.x, m_position.y, WheelEventPhase::NoPhase, WheelEventPhase::NoPhase, m_hasPreciseDeltas);
}

void EventSenderProxy::mouseScrollByWithWheelAndMomentumPhases(int horizontal, int vertical, int phase, int momentum)
@@ -354,12 +353,12 @@ void EventSenderProxy::mouseScrollByWithWheelAndMomentumPhases(int horizontal, i
}

webkitWebViewBaseSynthesizeWheelEvent(toWebKitGLibAPI(m_testController->mainWebView()->platformView()),
horizontal, vertical, m_position.x, m_position.y, eventPhase, eventMomentumPhase);
horizontal, vertical, m_position.x, m_position.y, eventPhase, eventMomentumPhase, m_hasPreciseDeltas);
}

void EventSenderProxy::setWheelHasPreciseDeltas(bool hasPreciseDeltas)
{
webkitWebViewBaseSetWheelHasPreciseDeltas(toWebKitGLibAPI(m_testController->mainWebView()->platformView()), hasPreciseDeltas);
m_hasPreciseDeltas = hasPreciseDeltas;
}

void EventSenderProxy::leapForward(int milliseconds)

0 comments on commit 9fd5052

Please sign in to comment.