summaryrefslogtreecommitdiffstats
path: root/third_party/WebKit
diff options
context:
space:
mode:
authortdresser@chromium.org <tdresser@chromium.org@bbb929c8-8fbe-4397-9dbb-9b2b20218538>2013-12-11 14:15:18 +0000
committertdresser@chromium.org <tdresser@chromium.org@bbb929c8-8fbe-4397-9dbb-9b2b20218538>2013-12-11 14:15:18 +0000
commitbe6100d506a475729eeeef1ed6699439d44a6097 (patch)
treef0ef8475a5ac0ff1bbd2329d0649d68670f98a14 /third_party/WebKit
parenteaf13069f12e41c25b770862eb3bc69715c8b122 (diff)
downloadchromium_src-be6100d506a475729eeeef1ed6699439d44a6097.zip
chromium_src-be6100d506a475729eeeef1ed6699439d44a6097.tar.gz
chromium_src-be6100d506a475729eeeef1ed6699439d44a6097.tar.bz2
Scroll bars continue to scroll when finger leaves the scroll bar.
This was initially committed at https://codereview.chromium.org/99013004/, and reverted at https://codereview.chromium.org/102663003. The revert was due to some failing content_browsertests. These tests relied on the previous broken behaviour of the scrollbar. This was fixed at https://codereview.chromium.org/110403002/, so it should be safe to reland this patch. BUG=324479 Review URL: https://codereview.chromium.org/105973004 git-svn-id: svn://svn.chromium.org/blink/trunk@163706 bbb929c8-8fbe-4397-9dbb-9b2b20218538
Diffstat (limited to 'third_party/WebKit')
-rw-r--r--third_party/WebKit/LayoutTests/fast/events/touch/gesture/gesture-scrollbar-expected.txt10
-rw-r--r--third_party/WebKit/LayoutTests/fast/events/touch/gesture/gesture-scrollbar-fling-expected.html47
-rw-r--r--third_party/WebKit/LayoutTests/fast/events/touch/gesture/gesture-scrollbar-fling.html86
-rw-r--r--third_party/WebKit/LayoutTests/fast/events/touch/gesture/gesture-scrollbar-textarea.html2
-rw-r--r--third_party/WebKit/LayoutTests/fast/events/touch/gesture/gesture-scrollbar.html28
-rw-r--r--third_party/WebKit/Source/core/page/EventHandler.cpp12
-rw-r--r--third_party/WebKit/Source/platform/PlatformEvent.h1
-rw-r--r--third_party/WebKit/Source/platform/scroll/Scrollbar.cpp47
-rw-r--r--third_party/WebKit/Source/testing/runner/EventSender.cpp1
-rw-r--r--third_party/WebKit/Source/web/WebInputEventConversion.cpp3
-rw-r--r--third_party/WebKit/Source/web/WebViewImpl.cpp11
11 files changed, 210 insertions, 38 deletions
diff --git a/third_party/WebKit/LayoutTests/fast/events/touch/gesture/gesture-scrollbar-expected.txt b/third_party/WebKit/LayoutTests/fast/events/touch/gesture/gesture-scrollbar-expected.txt
index 715b130..8222327 100644
--- a/third_party/WebKit/LayoutTests/fast/events/touch/gesture/gesture-scrollbar-expected.txt
+++ b/third_party/WebKit/LayoutTests/fast/events/touch/gesture/gesture-scrollbar-expected.txt
@@ -7,9 +7,15 @@ PASS successfullyParsed is true
TEST COMPLETE
PASS movingDiv.scrollTop is 0
-PASS movingDiv.scrollTop is >= 1
+PASS movingDiv.scrollTop is 0
+PASS movingDiv.scrollTop is >= 20
+PASS movingDiv.scrollTop is >= 85
+PASS movingDiv.scrollTop is >= 85
+PASS movingDiv.scrollLeft is 0
PASS movingDiv.scrollLeft is 0
-PASS movingDiv.scrollLeft is >= 1
+PASS movingDiv.scrollLeft is >= 20
+PASS movingDiv.scrollLeft is >= 85
+PASS movingDiv.scrollLeft is >= 85
PASS successfullyParsed is true
TEST COMPLETE
diff --git a/third_party/WebKit/LayoutTests/fast/events/touch/gesture/gesture-scrollbar-fling-expected.html b/third_party/WebKit/LayoutTests/fast/events/touch/gesture/gesture-scrollbar-fling-expected.html
new file mode 100644
index 0000000..20ceaa9
--- /dev/null
+++ b/third_party/WebKit/LayoutTests/fast/events/touch/gesture/gesture-scrollbar-fling-expected.html
@@ -0,0 +1,47 @@
+<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
+<html>
+
+<!-- This tests that the scrollbar thumb is deselected on a fling start -->
+
+<head>
+<style type="text/css">
+::-webkit-scrollbar {
+ background-color: #ccc;
+ height: 15px;
+ width: 15px;
+}
+
+::-webkit-scrollbar-button {
+ display: none;
+}
+
+::-webkit-scrollbar-thumb {
+ background-color: #777;
+ height: 15px;
+ width: 15px;
+}
+
+::-webkit-scrollbar-thumb:active {
+ background-color: #333;
+}
+
+#scrollable {
+ height: 300px;
+ width: 300px;
+ overflow: scroll;
+}
+
+.large {
+ height: 600px;
+ width: 600px;
+}
+</style>
+</head>
+<body>
+<div id="scrollable">
+ <div class="large">
+ </div>
+</div>
+
+</body>
+</html>
diff --git a/third_party/WebKit/LayoutTests/fast/events/touch/gesture/gesture-scrollbar-fling.html b/third_party/WebKit/LayoutTests/fast/events/touch/gesture/gesture-scrollbar-fling.html
new file mode 100644
index 0000000..9706bed
--- /dev/null
+++ b/third_party/WebKit/LayoutTests/fast/events/touch/gesture/gesture-scrollbar-fling.html
@@ -0,0 +1,86 @@
+<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
+<html>
+
+<!-- This tests that the scrollbar thumb is deselected on a fling start -->
+
+<head>
+<style type="text/css">
+::-webkit-scrollbar {
+ background-color: #ccc;
+ height: 15px;
+ width: 15px;
+}
+
+::-webkit-scrollbar-button {
+ display: none;
+}
+
+::-webkit-scrollbar-thumb {
+ background-color: #777;
+ height: 15px;
+ width: 15px;
+}
+
+::-webkit-scrollbar-thumb:active {
+ background-color: #333;
+}
+
+#scrollable {
+ height: 300px;
+ width: 300px;
+ overflow: scroll;
+}
+
+.large {
+ height: 600px;
+ width: 600px;
+}
+</style>
+</head>
+<body onload="runTest();">
+<div id="scrollable">
+ <div class="large">
+ </div>
+</div>
+<div id="console"></div>
+
+<script type="text/javascript">
+
+
+function scrollTest() {
+ var movingDiv;
+ movingDiv = document.getElementById('scrollable');
+ var scrollbarX = movingDiv.offsetLeft + movingDiv.offsetWidth - 5;
+ var scrollThumbSafeOffset = 80;
+ var scrollbarY = movingDiv.offsetTop + scrollThumbSafeOffset;
+
+ // Ensure we use a touch with an area to test under touch adjustment
+ var touchWidth = 25;
+ var touchHeight = 25;
+
+ eventSender.gestureTapDown(scrollbarX, scrollbarY, touchWidth, touchHeight);
+ eventSender.gestureFlingStart(0, 0, 0, 0);
+}
+
+function exitIfNecessary()
+{
+ debug('Gesture events not implemented on this platform or broken');
+ isSuccessfullyParsed();
+}
+
+function runTest()
+{
+ internals.settings.setMockScrollbarsEnabled(true);
+
+ if (window.eventSender) {
+ if (eventSender.clearTouchPoints)
+ scrollTest();
+ else
+ exitIfNecessary();
+ } else {
+ debug("This test requires DumpRenderTree.");
+ }
+}
+</script>
+</body>
+</html>
diff --git a/third_party/WebKit/LayoutTests/fast/events/touch/gesture/gesture-scrollbar-textarea.html b/third_party/WebKit/LayoutTests/fast/events/touch/gesture/gesture-scrollbar-textarea.html
index 30e4308..12a171e 100644
--- a/third_party/WebKit/LayoutTests/fast/events/touch/gesture/gesture-scrollbar-textarea.html
+++ b/third_party/WebKit/LayoutTests/fast/events/touch/gesture/gesture-scrollbar-textarea.html
@@ -54,6 +54,8 @@ function verticalScrollTest() {
var touchWidth = 25;
var touchHeight = 25;
+ eventSender.gestureTapDown(
+ scrollbarX, scrollbarY, touchWidth, touchHeight);
shouldBe('textArea.scrollTop', '0');
eventSender.gestureShowPress(
scrollbarX, scrollbarY, touchWidth, touchHeight);
diff --git a/third_party/WebKit/LayoutTests/fast/events/touch/gesture/gesture-scrollbar.html b/third_party/WebKit/LayoutTests/fast/events/touch/gesture/gesture-scrollbar.html
index 409dbad..fea1412 100644
--- a/third_party/WebKit/LayoutTests/fast/events/touch/gesture/gesture-scrollbar.html
+++ b/third_party/WebKit/LayoutTests/fast/events/touch/gesture/gesture-scrollbar.html
@@ -42,7 +42,7 @@
var movingDiv;
-function verticalScrollTest() {
+function scrollTest() {
movingDiv = document.getElementById('scrollable');
var scrollbarX = movingDiv.offsetLeft + movingDiv.offsetWidth - 5;
var scrollThumbSafeOffset = 80;
@@ -53,21 +53,33 @@ function verticalScrollTest() {
var touchHeight = 25;
shouldBe('movingDiv.scrollTop', '0');
+ eventSender.gestureTapDown(scrollbarX, scrollbarY, touchWidth, touchHeight);
eventSender.gestureShowPress(scrollbarX, scrollbarY, touchWidth, touchHeight);
- eventSender.gestureScrollBegin(scrollbarX, scrollbarY, touchWidth, touchHeight);
+ eventSender.gestureScrollBegin(scrollbarX + 20, scrollbarY, touchWidth, touchHeight);
+ eventSender.gestureTapCancel(scrollbarX, scrollbarY, touchWidth, touchHeight);
+ shouldBe('movingDiv.scrollTop', '0');
eventSender.gestureScrollUpdate(0, 20);
+ shouldBeGreaterThanOrEqual('movingDiv.scrollTop', '20');
+ eventSender.gestureScrollUpdate(0, 60);
+ shouldBeGreaterThanOrEqual('movingDiv.scrollTop', '85');
eventSender.gestureScrollEnd(0, 0);
- shouldBeGreaterThanOrEqual('movingDiv.scrollTop', '1');
+ shouldBeGreaterThanOrEqual('movingDiv.scrollTop', '85');
// Test horizontal scrollbar too
scrollbarY = movingDiv.offsetTop + movingDiv.offsetHeight - 5;
scrollbarX = movingDiv.offsetLeft + scrollThumbSafeOffset;
shouldBe('movingDiv.scrollLeft', '0');
+ eventSender.gestureTapDown(scrollbarX, scrollbarY, touchWidth, touchHeight);
eventSender.gestureShowPress(scrollbarX, scrollbarY, touchWidth, touchHeight);
- eventSender.gestureScrollBegin(scrollbarX, scrollbarY, touchWidth, touchHeight);
+ eventSender.gestureScrollBegin(scrollbarX, scrollbarY + 20, touchWidth, touchHeight);
+ eventSender.gestureTapCancel(scrollbarX, scrollbarY, touchWidth, touchHeight);
+ shouldBe('movingDiv.scrollLeft', '0');
eventSender.gestureScrollUpdate(20, 0);
+ shouldBeGreaterThanOrEqual('movingDiv.scrollLeft', '20');
+ eventSender.gestureScrollUpdate(60, 0);
+ shouldBeGreaterThanOrEqual('movingDiv.scrollLeft', '85');
eventSender.gestureScrollEnd(0, 0);
- shouldBeGreaterThanOrEqual('movingDiv.scrollLeft', '1');
+ shouldBeGreaterThanOrEqual('movingDiv.scrollLeft', '85');
// If we've got here, we've passed.
isSuccessfullyParsed();
@@ -82,13 +94,17 @@ function exitIfNecessary()
function runTest()
{
internals.settings.setMockScrollbarsEnabled(true);
+
+ if (window.testRunner)
+ window.testRunner.dumpAsText();
+
if (window.eventSender) {
description('This tests scroll gesture events on a scroll bar. ' +
'The scrollable div below should be slightly scrolled down ' +
'if successful.');
if (eventSender.clearTouchPoints)
- verticalScrollTest();
+ scrollTest();
else
exitIfNecessary();
} else {
diff --git a/third_party/WebKit/Source/core/page/EventHandler.cpp b/third_party/WebKit/Source/core/page/EventHandler.cpp
index 96d1970..11d0228 100644
--- a/third_party/WebKit/Source/core/page/EventHandler.cpp
+++ b/third_party/WebKit/Source/core/page/EventHandler.cpp
@@ -2336,6 +2336,7 @@ bool EventHandler::handleGestureEvent(const PlatformGestureEvent& gestureEvent)
case PlatformEvent::GestureScrollUpdate:
case PlatformEvent::GestureScrollUpdateWithoutPropagation:
case PlatformEvent::GestureScrollEnd:
+ case PlatformEvent::GestureFlingStart:
// Handle directly in main frame
break;
@@ -2364,7 +2365,8 @@ bool EventHandler::handleGestureEvent(const PlatformGestureEvent& gestureEvent)
Scrollbar* scrollbar = 0;
if (gestureEvent.type() == PlatformEvent::GestureScrollEnd
|| gestureEvent.type() == PlatformEvent::GestureScrollUpdate
- || gestureEvent.type() == PlatformEvent::GestureScrollUpdateWithoutPropagation) {
+ || gestureEvent.type() == PlatformEvent::GestureScrollUpdateWithoutPropagation
+ || gestureEvent.type() == PlatformEvent::GestureFlingStart) {
scrollbar = m_scrollbarHandlingScrollGesture.get();
eventTarget = m_scrollGestureHandlingNode.get();
}
@@ -2400,10 +2402,13 @@ bool EventHandler::handleGestureEvent(const PlatformGestureEvent& gestureEvent)
if (scrollbar) {
bool eventSwallowed = scrollbar->gestureEvent(gestureEvent);
- if (gestureEvent.type() == PlatformEvent::GestureScrollBegin && eventSwallowed)
+ if (gestureEvent.type() == PlatformEvent::GestureTapDown && eventSwallowed) {
m_scrollbarHandlingScrollGesture = scrollbar;
- else if (gestureEvent.type() == PlatformEvent::GestureScrollEnd || !eventSwallowed)
+ } else if (gestureEvent.type() == PlatformEvent::GestureScrollEnd
+ || gestureEvent.type() == PlatformEvent::GestureFlingStart
+ || !eventSwallowed) {
m_scrollbarHandlingScrollGesture = 0;
+ }
if (eventSwallowed)
return true;
@@ -2452,6 +2457,7 @@ bool EventHandler::handleGestureEvent(const PlatformGestureEvent& gestureEvent)
case PlatformEvent::GesturePinchUpdate:
case PlatformEvent::GestureTapDownCancel:
case PlatformEvent::GestureTapUnconfirmed:
+ case PlatformEvent::GestureFlingStart:
break;
default:
ASSERT_NOT_REACHED();
diff --git a/third_party/WebKit/Source/platform/PlatformEvent.h b/third_party/WebKit/Source/platform/PlatformEvent.h
index 88fb8aa..a664c73 100644
--- a/third_party/WebKit/Source/platform/PlatformEvent.h
+++ b/third_party/WebKit/Source/platform/PlatformEvent.h
@@ -64,6 +64,7 @@ public:
GesturePinchBegin,
GesturePinchEnd,
GesturePinchUpdate,
+ GestureFlingStart,
// PlatformTouchEvent
TouchStart,
diff --git a/third_party/WebKit/Source/platform/scroll/Scrollbar.cpp b/third_party/WebKit/Source/platform/scroll/Scrollbar.cpp
index d69769c..83ce291 100644
--- a/third_party/WebKit/Source/platform/scroll/Scrollbar.cpp
+++ b/third_party/WebKit/Source/platform/scroll/Scrollbar.cpp
@@ -346,40 +346,45 @@ void Scrollbar::setPressedPart(ScrollbarPart part)
bool Scrollbar::gestureEvent(const PlatformGestureEvent& evt)
{
- bool handled = false;
switch (evt.type()) {
- case PlatformEvent::GestureShowPress:
+ case PlatformEvent::GestureTapDown:
setPressedPart(theme()->hitTest(this, evt.position()));
m_pressedPos = orientation() == HorizontalScrollbar ? convertFromContainingWindow(evt.position()).x() : convertFromContainingWindow(evt.position()).y();
return true;
case PlatformEvent::GestureTapDownCancel:
case PlatformEvent::GestureScrollBegin:
- if (m_pressedPart == ThumbPart) {
- m_scrollPos = m_pressedPos;
- return true;
- }
- break;
+ if (m_pressedPart != ThumbPart)
+ return false;
+ m_scrollPos = m_pressedPos;
+ return true;
case PlatformEvent::GestureScrollUpdate:
case PlatformEvent::GestureScrollUpdateWithoutPropagation:
- if (m_pressedPart == ThumbPart) {
- m_scrollPos += orientation() == HorizontalScrollbar ? evt.deltaX() : evt.deltaY();
- moveThumb(m_scrollPos, false);
+ if (m_pressedPart != ThumbPart)
+ return false;
+ m_scrollPos += orientation() == HorizontalScrollbar ? evt.deltaX() : evt.deltaY();
+ moveThumb(m_scrollPos, false);
+ return true;
+ case PlatformEvent::GestureScrollEnd:
+ case PlatformEvent::GestureLongPress:
+ case PlatformEvent::GestureFlingStart:
+ m_scrollPos = 0;
+ m_pressedPos = 0;
+ setPressedPart(NoPart);
+ return false;
+ case PlatformEvent::GestureTap: {
+ if (m_pressedPart != ThumbPart && m_pressedPart != NoPart && m_scrollableArea
+ && m_scrollableArea->scroll(pressedPartScrollDirection(), pressedPartScrollGranularity())) {
return true;
}
- break;
- case PlatformEvent::GestureScrollEnd:
m_scrollPos = 0;
- break;
- case PlatformEvent::GestureTap:
- if (m_pressedPart != ThumbPart && m_pressedPart != NoPart)
- handled = m_scrollableArea && m_scrollableArea->scroll(pressedPartScrollDirection(), pressedPartScrollGranularity());
- break;
+ m_pressedPos = 0;
+ setPressedPart(NoPart);
+ return false;
+ }
default:
- break;
+ // By default, we assume that gestures don't deselect the scrollbar.
+ return true;
}
- setPressedPart(NoPart);
- m_pressedPos = 0;
- return handled;
}
void Scrollbar::mouseMoved(const PlatformMouseEvent& evt)
diff --git a/third_party/WebKit/Source/testing/runner/EventSender.cpp b/third_party/WebKit/Source/testing/runner/EventSender.cpp
index bff122f..ad62873 100644
--- a/third_party/WebKit/Source/testing/runner/EventSender.cpp
+++ b/third_party/WebKit/Source/testing/runner/EventSender.cpp
@@ -1315,6 +1315,7 @@ void EventSender::gestureEvent(WebInputEvent::Type type, const CppArgumentList&
event.y = m_currentGestureLocation.y;
break;
case WebInputEvent::GestureScrollEnd:
+ case WebInputEvent::GestureFlingStart:
event.x = m_currentGestureLocation.x;
event.y = m_currentGestureLocation.y;
break;
diff --git a/third_party/WebKit/Source/web/WebInputEventConversion.cpp b/third_party/WebKit/Source/web/WebInputEventConversion.cpp
index 95d6898..51d8845 100644
--- a/third_party/WebKit/Source/web/WebInputEventConversion.cpp
+++ b/third_party/WebKit/Source/web/WebInputEventConversion.cpp
@@ -173,6 +173,9 @@ PlatformGestureEventBuilder::PlatformGestureEventBuilder(Widget* widget, const W
case WebInputEvent::GestureScrollEnd:
m_type = PlatformEvent::GestureScrollEnd;
break;
+ case WebInputEvent::GestureFlingStart:
+ m_type = PlatformEvent::GestureFlingStart;
+ break;
case WebInputEvent::GestureScrollUpdate:
m_type = PlatformEvent::GestureScrollUpdate;
m_data.m_scrollUpdate.m_deltaX = e.data.scrollUpdate.deltaX / scale;
diff --git a/third_party/WebKit/Source/web/WebViewImpl.cpp b/third_party/WebKit/Source/web/WebViewImpl.cpp
index fd553a1..c61fd57 100644
--- a/third_party/WebKit/Source/web/WebViewImpl.cpp
+++ b/third_party/WebKit/Source/web/WebViewImpl.cpp
@@ -656,13 +656,11 @@ bool WebViewImpl::handleGestureEvent(const WebGestureEvent& event)
bool eventSwallowed = false;
bool eventCancelled = false; // for disambiguation
- // Special handling for slow-path fling gestures, which have no PlatformGestureEvent equivalent.
+ // Special handling for slow-path fling gestures.
switch (event.type) {
case WebInputEvent::GestureFlingStart: {
- if (mainFrameImpl()->frame()->eventHandler().isScrollbarHandlingGestures()) {
- m_client->didHandleGestureEvent(event, eventCancelled);
- return eventSwallowed;
- }
+ if (mainFrameImpl()->frame()->eventHandler().isScrollbarHandlingGestures())
+ break;
m_client->cancelScheduledContentIntents();
m_positionOnFlingStart = WebPoint(event.x / pageScaleFactor(), event.y / pageScaleFactor());
m_globalPositionOnFlingStart = WebPoint(event.globalX, event.globalY);
@@ -796,7 +794,8 @@ bool WebViewImpl::handleGestureEvent(const WebGestureEvent& event)
case WebInputEvent::GestureTapCancel:
case WebInputEvent::GestureTapUnconfirmed:
case WebInputEvent::GesturePinchEnd:
- case WebInputEvent::GesturePinchUpdate: {
+ case WebInputEvent::GesturePinchUpdate:
+ case WebInputEvent::GestureFlingStart: {
eventSwallowed = mainFrameImpl()->frame()->eventHandler().handleGestureEvent(platformEvent);
break;
}