summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAllan Sandfeld Jensen <allan.jensen@qt.io>2018-08-31 14:37:56 +0200
committerAllan Sandfeld Jensen <allan.jensen@qt.io>2018-09-22 08:47:28 +0000
commit75fcb640fae72446b26d7978a5df3c058e0ab67f (patch)
tree3467a5d3eb1f31337b81ab8976a07cac0e694541
parent06e3d201299ab803f4dc41f35201830c74242d19 (diff)
Adapt to forced scroll-wheel latching
Handle that Chromium now requires all wheel events to be phases despite them not being phased on the majority of platforms. Change-Id: Iabd5630652c0d8fd67563db3d63ef1f2f528c35c Reviewed-by: Michael BrĂ¼ning <michael.bruning@qt.io>
-rw-r--r--src/core/render_widget_host_view_qt.cpp25
-rw-r--r--src/core/render_widget_host_view_qt.h3
-rw-r--r--src/core/web_engine_context.cpp2
-rw-r--r--src/core/web_event_factory.cpp11
4 files changed, 28 insertions, 13 deletions
diff --git a/src/core/render_widget_host_view_qt.cpp b/src/core/render_widget_host_view_qt.cpp
index 15881674c..737f42439 100644
--- a/src/core/render_widget_host_view_qt.cpp
+++ b/src/core/render_widget_host_view_qt.cpp
@@ -332,6 +332,7 @@ RenderWidgetHostViewQt::RenderWidgetHostViewQt(content::RenderWidgetHost *widget
, m_cursorPosition(0)
, m_emptyPreviousSelection(true)
, m_wheelAckPending(false)
+ , m_mouseWheelPhaseHandler(this)
{
host()->SetView(this);
#ifndef QT_NO_ACCESSIBILITY
@@ -1421,8 +1422,10 @@ void RenderWidgetHostViewQt::handleWheelEvent(QWheelEvent *ev)
{
if (!m_wheelAckPending) {
Q_ASSERT(m_pendingWheelEvents.isEmpty());
- m_wheelAckPending = true;
- host()->ForwardWheelEvent(WebEventFactory::toWebWheelEvent(ev, dpiScale()));
+ blink::WebMouseWheelEvent webEvent = WebEventFactory::toWebWheelEvent(ev, dpiScale());
+ m_wheelAckPending = (webEvent.phase != blink::WebMouseWheelEvent::kPhaseEnded);
+ m_mouseWheelPhaseHandler.AddPhaseIfNeededAndScheduleEndEvent(webEvent, false);
+ host()->ForwardWheelEvent(webEvent);
return;
}
if (!m_pendingWheelEvents.isEmpty()) {
@@ -1433,16 +1436,26 @@ void RenderWidgetHostViewQt::handleWheelEvent(QWheelEvent *ev)
m_pendingWheelEvents.append(WebEventFactory::toWebWheelEvent(ev, dpiScale()));
}
-void RenderWidgetHostViewQt::WheelEventAck(const blink::WebMouseWheelEvent &/*event*/, content::InputEventAckState /*ack_result*/)
+void RenderWidgetHostViewQt::WheelEventAck(const blink::WebMouseWheelEvent &event, content::InputEventAckState /*ack_result*/)
{
+ if (event.phase == blink::WebMouseWheelEvent::kPhaseEnded)
+ return;
+ Q_ASSERT(m_wheelAckPending);
m_wheelAckPending = false;
- if (!m_pendingWheelEvents.isEmpty()) {
- m_wheelAckPending = true;
- host()->ForwardWheelEvent(m_pendingWheelEvents.takeFirst());
+ while (!m_pendingWheelEvents.isEmpty() && !m_wheelAckPending) {
+ blink::WebMouseWheelEvent webEvent = m_pendingWheelEvents.takeFirst();
+ m_wheelAckPending = (webEvent.phase != blink::WebMouseWheelEvent::kPhaseEnded);
+ m_mouseWheelPhaseHandler.AddPhaseIfNeededAndScheduleEndEvent(webEvent, false);
+ host()->ForwardWheelEvent(webEvent);
}
// TODO: We could forward unhandled wheelevents to our parent.
}
+content::MouseWheelPhaseHandler *RenderWidgetHostViewQt::GetMouseWheelPhaseHandler()
+{
+ return &m_mouseWheelPhaseHandler;
+}
+
void RenderWidgetHostViewQt::clearPreviousTouchMotionState()
{
m_previousTouchPoints.clear();
diff --git a/src/core/render_widget_host_view_qt.h b/src/core/render_widget_host_view_qt.h
index 26fd16631..92cc422a8 100644
--- a/src/core/render_widget_host_view_qt.h
+++ b/src/core/render_widget_host_view_qt.h
@@ -46,6 +46,7 @@
#include "components/viz/common/frame_sinks/begin_frame_source.h"
#include "components/viz/common/resources/transferable_resource.h"
#include "content/browser/accessibility/browser_accessibility_manager.h"
+#include "content/browser/renderer_host/input/mouse_wheel_phase_handler.h"
#include "content/browser/renderer_host/render_widget_host_view_base.h"
#include "content/browser/renderer_host/text_input_manager.h"
#include "content/common/view_messages.h"
@@ -141,6 +142,7 @@ public:
void DidCreateNewRendererCompositorFrameSink(viz::mojom::CompositorFrameSinkClient* renderer_compositor_frame_sink) override;
void SubmitCompositorFrame(const viz::LocalSurfaceId&, viz::CompositorFrame, base::Optional<viz::HitTestRegionList>) override;
void WheelEventAck(const blink::WebMouseWheelEvent &event, content::InputEventAckState ack_result) override;
+ content::MouseWheelPhaseHandler *GetMouseWheelPhaseHandler() override;
void GetScreenInfo(content::ScreenInfo* results) const override;
gfx::Rect GetBoundsInRootWindow() override;
@@ -255,6 +257,7 @@ private:
bool m_wheelAckPending;
QList<blink::WebMouseWheelEvent> m_pendingWheelEvents;
+ content::MouseWheelPhaseHandler m_mouseWheelPhaseHandler;
std::string m_editCommand;
};
diff --git a/src/core/web_engine_context.cpp b/src/core/web_engine_context.cpp
index 4b0a2f6cd..e2c127b22 100644
--- a/src/core/web_engine_context.cpp
+++ b/src/core/web_engine_context.cpp
@@ -417,8 +417,6 @@ WebEngineContext::WebEngineContext()
appendToFeatureSwitch(parsedCommandLine, switches::kEnableFeatures, features::kAllowContentInitiatedDataUrlNavigations.name);
// Surface synchronization breaks our current graphics integration (since 65)
appendToFeatureSwitch(parsedCommandLine, switches::kDisableFeatures, features::kEnableSurfaceSynchronization.name);
- // Scroll latching expects phases on all wheel events when it really only makes sense for simulated ones.
- appendToFeatureSwitch(parsedCommandLine, switches::kDisableFeatures, features::kTouchpadAndWheelScrollLatching.name);
if (useEmbeddedSwitches) {
appendToFeatureSwitch(parsedCommandLine, switches::kEnableFeatures, features::kOverlayScrollbar.name);
diff --git a/src/core/web_event_factory.cpp b/src/core/web_event_factory.cpp
index b97235ceb..479fc38f8 100644
--- a/src/core/web_event_factory.cpp
+++ b/src/core/web_event_factory.cpp
@@ -1422,13 +1422,14 @@ static void setBlinkWheelEventDelta(blink::WebMouseWheelEvent &webEvent)
webEvent.delta_y = webEvent.wheel_ticks_y * wheelScrollLines * cDefaultQtScrollStep;
}
-blink::WebMouseWheelEvent::Phase toBlinkPhase(Qt::ScrollPhase phase)
+blink::WebMouseWheelEvent::Phase toBlinkPhase(QWheelEvent *ev)
{
- switch (phase) {
+ switch (ev->phase()) {
case Qt::NoScrollPhase:
+ case Qt::ScrollMomentum:
return blink::WebMouseWheelEvent::kPhaseNone;
case Qt::ScrollBegin:
- return blink::WebMouseWheelEvent::kPhaseBegan;
+ return ev->angleDelta().isNull() ? blink::WebMouseWheelEvent::kPhaseMayBegin : blink::WebMouseWheelEvent::kPhaseBegan;
case Qt::ScrollUpdate:
return blink::WebMouseWheelEvent::kPhaseChanged;
case Qt::ScrollEnd:
@@ -1449,7 +1450,7 @@ blink::WebMouseWheelEvent WebEventFactory::toWebWheelEvent(QWheelEvent *ev, doub
webEvent.wheel_ticks_x = static_cast<float>(ev->angleDelta().x()) / QWheelEvent::DefaultDeltasPerStep;
webEvent.wheel_ticks_y = static_cast<float>(ev->angleDelta().y()) / QWheelEvent::DefaultDeltasPerStep;
- webEvent.phase = toBlinkPhase(ev->phase());
+ webEvent.phase = toBlinkPhase(ev);
webEvent.has_precise_scrolling_deltas = true;
setBlinkWheelEventDelta(webEvent);
@@ -1462,7 +1463,7 @@ bool WebEventFactory::coalesceWebWheelEvent(blink::WebMouseWheelEvent &webEvent,
return false;
if (modifiersForEvent(ev) != webEvent.GetModifiers())
return false;
- if (toBlinkPhase(ev->phase()) != webEvent.phase)
+ if (toBlinkPhase(ev) != webEvent.phase)
return false;
webEvent.SetTimeStamp(currentTimeForEvent(ev));