Should only fire a single set of mouse events and update hover state once when scroll...
authorojan@chromium.org <ojan@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 10 Nov 2012 05:16:00 +0000 (05:16 +0000)
committerojan@chromium.org <ojan@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 10 Nov 2012 05:16:00 +0000 (05:16 +0000)
commit867522120a3846f1cf6c50a84ce90b624d3b6dd8
tree2ea10e84e51960b4aaef50a004e14137660e8ce1
parent90b81696e3e1acdbb350d9a2041dc3433c2c5a9e
Should only fire a single set of mouse events and update hover state once when scrolling is done
https://bugs.webkit.org/show_bug.cgi?id=99940

Reviewed by Levi Weintraub.

Source/WebCore:

-Use a DeferrableOneShotTimer instead of a Timer. By resetting when the
timer is fired, we ensure the actual goal of not firing fake mouse events
until the scroll is completed. This is the core part of this change.
-Change our mouse event throttling to keep a running average of how long
mouse events take and adjust throttling appropriately.
Test: fast/scrolling/fake-mouse-event-throttling.html
-Maintain a minimum throttle of 100ms.

* page/EventHandler.cpp:
(WebCore):
(WebCore::RunningAverageDurationTracker::RunningAverageDurationTracker):
(WebCore::RunningAverageDurationTracker::~RunningAverageDurationTracker):
Keep track of a running average instead of max. This lets us adjust throttling
dynamically without punishing a page for having a single mouse event handler
that takes disproportionately long.
(RunningAverageDurationTracker):
(WebCore::EventHandler::EventHandler):
(WebCore::EventHandler::clear):
(WebCore::EventHandler::mouseMoved):
(WebCore::EventHandler::handleMouseMoveEvent):
(WebCore::EventHandler::dispatchFakeMouseMoveEventSoon):
(WebCore::EventHandler::fakeMouseMoveEventTimerFired):
* page/EventHandler.h:
(EventHandler):
* platform/Timer.h:
(WebCore::DeferrableOneShotTimer::setDelay):
(WebCore::DeferrableOneShotTimer::delay):
Add a way of adjusting the timer delay.

LayoutTests:

Tests basic throttling. I couldn't think of a good way to test changing
the delay that wouldn't make for a test that takes minutes to run.

* fast/scrolling/fake-mouse-event-throttling-expected.txt: Added.
* fast/scrolling/fake-mouse-event-throttling.html: Added.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@134150 268f45cc-cd09-0410-ab3c-d52691b4dbfc
LayoutTests/ChangeLog
LayoutTests/fast/scrolling/fake-mouse-event-throttling-expected.txt [new file with mode: 0644]
LayoutTests/fast/scrolling/fake-mouse-event-throttling.html [new file with mode: 0644]
LayoutTests/platform/mac/TestExpectations
Source/WebCore/ChangeLog
Source/WebCore/page/EventHandler.cpp
Source/WebCore/page/EventHandler.h
Source/WebCore/platform/Timer.h