Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(808)

Unified Diff: third_party/WebKit/Source/web/WebViewImpl.cpp

Issue 1841053002: Fix mouse wheel scrolling on PDFs. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix gesture fling Created 4 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « third_party/WebKit/Source/web/WebViewImpl.h ('k') | third_party/WebKit/public/web/WebSettings.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/Source/web/WebViewImpl.cpp
diff --git a/third_party/WebKit/Source/web/WebViewImpl.cpp b/third_party/WebKit/Source/web/WebViewImpl.cpp
index 98b04285fcb22d795e62fbf56591a796e7734f21..f06729c474823b2a262a8d93eb885f3655fdca6e 100644
--- a/third_party/WebKit/Source/web/WebViewImpl.cpp
+++ b/third_party/WebKit/Source/web/WebViewImpl.cpp
@@ -643,9 +643,24 @@ WebInputEventResult WebViewImpl::handleMouseWheel(LocalFrame& mainFrame, const W
return PageWidgetEventHandler::handleMouseWheel(mainFrame, event);
}
+void WebViewImpl::populateGestureScrollEventFromFling(WebInputEvent::Type type, WebGestureDevice sourceDevice, WebGestureEvent* gestureEvent)
tdresser 2016/03/29 19:16:03 Why not just return a WebGestureEvent?
dtapuska 2016/03/29 19:42:05 Done.
+{
+ gestureEvent->type = type;
+ gestureEvent->sourceDevice = sourceDevice;
+ gestureEvent->timeStampSeconds = WTF::monotonicallyIncreasingTime();
+ gestureEvent->x = m_positionOnFlingStart.x;
+ gestureEvent->y = m_positionOnFlingStart.y;
+ gestureEvent->globalX = m_globalPositionOnFlingStart.x;
+ gestureEvent->globalY = m_globalPositionOnFlingStart.y;
+ gestureEvent->modifiers = m_flingModifier;
+}
+
bool WebViewImpl::scrollBy(const WebFloatSize& delta, const WebFloatSize& velocity)
{
ASSERT(m_flingSourceDevice != WebGestureDeviceUninitialized);
+ if (!m_page || !m_page->mainFrame() || !m_page->mainFrame()->isLocalFrame() || !m_page->deprecatedLocalMainFrame()->view())
+ return false;
+
if (m_flingSourceDevice == WebGestureDeviceTouchpad) {
WebMouseWheelEvent syntheticWheel;
const float tickDivisor = WheelEvent::TickMultiplier;
@@ -663,30 +678,52 @@ bool WebViewImpl::scrollBy(const WebFloatSize& delta, const WebFloatSize& veloci
syntheticWheel.globalY = m_globalPositionOnFlingStart.y;
syntheticWheel.modifiers = m_flingModifier;
- if (m_page && m_page->mainFrame() && m_page->mainFrame()->isLocalFrame() && m_page->deprecatedLocalMainFrame()->view())
- return handleMouseWheel(*m_page->deprecatedLocalMainFrame(), syntheticWheel) != WebInputEventResult::NotHandled;
+ if (handleMouseWheel(*m_page->deprecatedLocalMainFrame(), syntheticWheel) != WebInputEventResult::NotHandled)
+ return true;
+ if (!m_webSettings->wheelGesturesEnabled())
+ return false;
+
+ WebGestureEvent syntheticScrollBegin;
+ populateGestureScrollEventFromFling(WebInputEvent::GestureScrollBegin,
+ WebGestureDeviceTouchpad,
+ &syntheticScrollBegin);
+ syntheticScrollBegin.data.scrollBegin.deltaXHint = delta.width;
+ syntheticScrollBegin.data.scrollBegin.deltaYHint = delta.height;
+ syntheticScrollBegin.data.scrollBegin.inertial = true;
+ handleGestureEvent(syntheticScrollBegin);
+
+ WebGestureEvent syntheticScrollUpdate;
+ populateGestureScrollEventFromFling(WebInputEvent::GestureScrollUpdate,
+ WebGestureDeviceTouchpad,
+ &syntheticScrollUpdate);
+ syntheticScrollUpdate.data.scrollUpdate.deltaX = delta.width;
+ syntheticScrollUpdate.data.scrollUpdate.deltaY = delta.height;
+ syntheticScrollUpdate.data.scrollUpdate.velocityX = velocity.width;
+ syntheticScrollUpdate.data.scrollUpdate.velocityY = velocity.height;
+ syntheticScrollUpdate.data.scrollUpdate.inertial = true;
+ bool scrollUpdateHandled = handleGestureEvent(syntheticScrollUpdate) != WebInputEventResult::NotHandled;
+
+ WebGestureEvent syntheticScrollEnd;
+ populateGestureScrollEventFromFling(WebInputEvent::GestureScrollEnd,
+ WebGestureDeviceTouchpad,
+ &syntheticScrollUpdate);
tdresser 2016/03/29 19:16:03 We're passing in syntheticGestureScrollUpdate here
dtapuska 2016/03/29 19:42:05 Ugh; this should fail in a debug build bot.
+ syntheticScrollEnd.data.scrollEnd.inertial = true;
+ handleGestureEvent(syntheticScrollEnd);
+ return scrollUpdateHandled;
} else {
WebGestureEvent syntheticGestureEvent;
-
- syntheticGestureEvent.type = WebInputEvent::GestureScrollUpdate;
- syntheticGestureEvent.timeStampSeconds = WTF::monotonicallyIncreasingTime();
+ populateGestureScrollEventFromFling(WebInputEvent::GestureScrollUpdate,
+ WebGestureDeviceTouchscreen,
+ &syntheticGestureEvent);
syntheticGestureEvent.data.scrollUpdate.preventPropagation = true;
syntheticGestureEvent.data.scrollUpdate.deltaX = delta.width;
syntheticGestureEvent.data.scrollUpdate.deltaY = delta.height;
syntheticGestureEvent.data.scrollUpdate.velocityX = velocity.width;
syntheticGestureEvent.data.scrollUpdate.velocityY = velocity.height;
- syntheticGestureEvent.x = m_positionOnFlingStart.x;
- syntheticGestureEvent.y = m_positionOnFlingStart.y;
- syntheticGestureEvent.globalX = m_globalPositionOnFlingStart.x;
- syntheticGestureEvent.globalY = m_globalPositionOnFlingStart.y;
- syntheticGestureEvent.modifiers = m_flingModifier;
- syntheticGestureEvent.sourceDevice = WebGestureDeviceTouchscreen;
syntheticGestureEvent.data.scrollUpdate.inertial = true;
- if (m_page && m_page->mainFrame() && m_page->mainFrame()->isLocalFrame() && m_page->deprecatedLocalMainFrame()->view())
- return handleGestureEvent(syntheticGestureEvent) != WebInputEventResult::NotHandled;
+ return handleGestureEvent(syntheticGestureEvent) != WebInputEventResult::NotHandled;
}
- return false;
}
WebInputEventResult WebViewImpl::handleGestureEvent(const WebGestureEvent& event)
« no previous file with comments | « third_party/WebKit/Source/web/WebViewImpl.h ('k') | third_party/WebKit/public/web/WebSettings.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698