From 24bb272ac83fe42ad4cab58a9e97bdf2a53d2be8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=BCri=20Valdmann?= Date: Mon, 28 Oct 2019 16:37:42 +0100 Subject: Fix handling of autorepeating KeyRelease events A regression in 5.10 has resulted in the web events generated for autorepeating keys not conforming to the spec. Restore the correct behavior from 5.9. Fixes: QTBUG-77208 Change-Id: Ia2f07fd4a8ee78c4599b36aceb235c245a49d566 Reviewed-by: Michal Klocek --- src/core/render_widget_host_view_qt.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'src/core/render_widget_host_view_qt.cpp') diff --git a/src/core/render_widget_host_view_qt.cpp b/src/core/render_widget_host_view_qt.cpp index e86f05d60..e721cba3b 100644 --- a/src/core/render_widget_host_view_qt.cpp +++ b/src/core/render_widget_host_view_qt.cpp @@ -1311,6 +1311,14 @@ void RenderWidgetHostViewQt::handleKeyEvent(QKeyEvent *ev) } } + // Ignore autorepeating KeyRelease events so that the generated web events + // conform to the spec, which requires autorepeat to result in a sequence of + // keypress events and only one final keyup event: + // https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent#Auto-repeat_handling + // https://w3c.github.io/uievents/#dom-keyboardevent-repeat + if (ev->type() == QEvent::KeyRelease && ev->isAutoRepeat()) + return; + content::NativeWebKeyboardEvent webEvent = WebEventFactory::toWebKeyboardEvent(ev); if (webEvent.GetType() == blink::WebInputEvent::kRawKeyDown && !m_editCommand.empty()) { ui::LatencyInfo latency; -- cgit v1.2.3