Skip to content
Permalink
Browse files
Divide gesture scroll delta by scale factor
https://bugs.webkit.org/show_bug.cgi?id=106263

Reviewed by Adam Barth.

Gesture scroll deltas were not being adjusted by the frame's scale
factors, resulting in overly fast main-thread scrolling when zoomed
in.

New test: fast/events/touch/gesture/touch-gesture-scroll-div-scaled.html

* page/EventHandler.cpp:
(WebCore::EventHandler::handleGestureScrollCore):


Canonical link: https://commits.webkit.org/124482@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@139022 268f45cc-cd09-0410-ab3c-d52691b4dbfc
  • Loading branch information
alexelias committed Jan 8, 2013
1 parent bd267ad commit 73cf6d89d8f28caac59f02d97ebe11ecb98f7f3c
Showing 5 changed files with 182 additions and 1 deletion.
@@ -0,0 +1,10 @@
This tests gesture event scrolling of an overflow div with page scale.

On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".


gesture events not implemented on this platform or gesture event scrolling of a document is broken
PASS successfullyParsed is true

TEST COMPLETE

@@ -0,0 +1,131 @@
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
<html>
<head>
<script src="../../../js/resources/js-test-pre.js"></script>
<script src="resources/gesture-helpers.js"></script>
<style type="text/css">
#touchtarget {
width: 100px;
height: 100px;
position: relative;
background: white;
}

::-webkit-scrollbar {
width: 0px;
height: 0px;
}

#movingbox {
width: 100%;
height: 100%;
position: absolute;
word-wrap: break-word;
overflow-y: scroll;
overflow-x: scroll;
display: block;
}

#greenbox {
width: 100px;
height: 100px;
background: green;
padding: 0px;
margin: 0px;
}

#redbox {
width: 100px;
height: 100px;
background: red;
padding: 0px;
margin: 0px;
}

td {
padding: 0px;
}
</style>
</head>
<body style="margin:0" onload="runTest();">
<div id="touchtarget">
<div id="movingbox">
<table border="0" cellspacing="0px" id="tablefoo">
<tr>
<td><div id="redbox"></div></td>
<td><div id="greenbox"></div></td>
</tr>
<tr>
<td><div id="greenbox"></div></td>
<td><div id="greenbox"></div></td>
</tr>
</table>
</div>
</div>

<p id="description"></p>
<div id="console"></div>
<script type="text/javascript">

var movingdiv;
var expectedGesturesTotal = 2;
var gesturesOccurred = 0;
var scrollAmountX = ['45', '45'];
var scrollAmountY = ['0', '48'];
var wheelEventsOccurred = 0;
var expectedWheelEventsOccurred = ['1', '1'];
var scrollEventsOccurred = 0;
var expectedScrollEventsOccurred = '1';
var scrolledElement = 'movingdiv'

function firstGestureScroll()
{
debug("first gesture");
eventSender.gestureScrollBegin(95, 12);
eventSender.gestureScrollUpdate(-90, 0);
eventSender.gestureScrollEnd(0, 0);

// Wait for layout.
checkScrollOffset();
}

function secondGestureScroll()
{
debug("second gesture");
eventSender.gestureScrollBegin(12, 97);
eventSender.gestureScrollUpdate(0, -95);
eventSender.gestureScrollEnd(0, 0);

// Wait for layout.
checkScrollOffset();
}

if (window.testRunner)
testRunner.waitUntilDone();

function runTest()
{
var scaleFactor = 2.0;
var scaleOffset = 0;
if (window.internals) {
window.internals.setPageScaleFactor(scaleFactor, scaleOffset, scaleOffset);
}

movingdiv = document.getElementById('movingbox');
movingdiv.addEventListener("scroll", recordScroll);
window.addEventListener("mousewheel", recordWheel);

if (window.eventSender) {
description('This tests gesture event scrolling of an overflow div with page scale.');

if (checkTestDependencies())
firstGestureScroll();
else
exitIfNecessary();
} else {
debug("This test requires DumpRenderTree. Touch scroll the red rect to log.");
}
}
</script>
</body>
</html>
@@ -0,0 +1,21 @@
This tests gesture event scrolling of an overflow div with page scale.

On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".


first gesture
wheel event 0+> [object HTMLDivElement]
PASS movingdiv.scrollTop is 0
PASS movingdiv.scrollLeft is 45
PASS wheelEventsOccurred is 1
second gesture
wheel event 0+> [object HTMLDivElement]
PASS movingdiv.scrollTop is 48
PASS movingdiv.scrollLeft is 45
PASS wheelEventsOccurred is 1
scroll event 0+> [object HTMLDivElement]
PASS scrollEventsOccurred is 1
PASS successfullyParsed is true

TEST COMPLETE

@@ -1,3 +1,19 @@
2013-01-07 Alexandre Elias <aelias@chromium.org>

Divide gesture scroll delta by scale factor
https://bugs.webkit.org/show_bug.cgi?id=106263

Reviewed by Adam Barth.

Gesture scroll deltas were not being adjusted by the frame's scale
factors, resulting in overly fast main-thread scrolling when zoomed
in.

New test: fast/events/touch/gesture/touch-gesture-scroll-div-scaled.html

* page/EventHandler.cpp:
(WebCore::EventHandler::handleGestureScrollCore):

2013-01-07 Adam Barth <abarth@webkit.org>

HTMLTreeBuilder should not depend on Frame
@@ -2599,10 +2599,13 @@ bool EventHandler::isScrollbarHandlingGestures() const
bool EventHandler::handleGestureScrollCore(const PlatformGestureEvent& gestureEvent, PlatformWheelEventGranularity granularity, bool latchedWheel)
{
const float tickDivisor = (float)WheelEvent::tickMultiplier;
const float scaleFactor = m_frame->pageZoomFactor() * m_frame->frameScaleFactor();
float scaledDeltaX = gestureEvent.deltaX() / scaleFactor;
float scaledDeltaY = gestureEvent.deltaY() / scaleFactor;
IntPoint point(gestureEvent.position().x(), gestureEvent.position().y());
IntPoint globalPoint(gestureEvent.globalPosition().x(), gestureEvent.globalPosition().y());
PlatformWheelEvent syntheticWheelEvent(point, globalPoint,
gestureEvent.deltaX(), gestureEvent.deltaY(), gestureEvent.deltaX() / tickDivisor, gestureEvent.deltaY() / tickDivisor,
scaledDeltaX, scaledDeltaY, scaledDeltaX / tickDivisor, scaledDeltaY / tickDivisor,
granularity,
gestureEvent.shiftKey(), gestureEvent.ctrlKey(), gestureEvent.altKey(), gestureEvent.metaKey());
syntheticWheelEvent.setUseLatchedEventNode(latchedWheel);

0 comments on commit 73cf6d8

Please sign in to comment.