Bug 1364018 - Coalesce wheel events more aggressively, r=stone

--HG--
extra : rebase_source : 17171c517a0c49cfbb2a6c99a06d655e61930e2d
This commit is contained in:
Olli Pettay 2017-05-12 14:13:59 +03:00
parent 68950682a9
commit 1b1642f523
2 changed files with 9 additions and 4 deletions

View File

@ -1686,12 +1686,16 @@ TabChild::MaybeCoalesceWheelEvent(const WidgetWheelEvent& aEvent,
// 1. It's eWheel (we don't coalesce eOperationStart and eWheelOperationEnd)
// 2. It's not the first wheel event.
// 3. It's not the last wheel event.
// 4. It's dispatched before the last wheel event was processed.
// 4. It's dispatched before the last wheel event was processed +
// the processing time of the last event.
// This way pages spending lots of time in wheel listeners get wheel
// events coalesced more aggressively.
// 5. It has same attributes as the coalesced wheel event which is not yet
// fired.
if (!mLastWheelProcessedTimeFromParent.IsNull() &&
*aIsNextWheelEvent &&
aEvent.mTimeStamp < mLastWheelProcessedTimeFromParent &&
aEvent.mTimeStamp < (mLastWheelProcessedTimeFromParent +
mLastWheelProcessingDuration) &&
(mCoalescedWheelData.IsEmpty() ||
mCoalescedWheelData.CanCoalesce(aEvent, aGuid, aInputBlockId))) {
mCoalescedWheelData.Coalesce(aEvent, aGuid, aInputBlockId);
@ -1759,8 +1763,8 @@ TabChild::RecvMouseWheelEvent(const WidgetWheelEvent& aEvent,
mozilla::TimeStamp beforeDispatchingTime = TimeStamp::Now();
MaybeDispatchCoalescedWheelEvent();
DispatchWheelEvent(aEvent, aGuid, aInputBlockId);
mLastWheelProcessedTimeFromParent +=
(TimeStamp::Now() - beforeDispatchingTime);
mLastWheelProcessingDuration = (TimeStamp::Now() - beforeDispatchingTime);
mLastWheelProcessedTimeFromParent += mLastWheelProcessingDuration;
} else {
// This is the last wheel event. Set mLastWheelProcessedTimeFromParent to
// null moment to avoid coalesce the next incoming wheel event.

View File

@ -842,6 +842,7 @@ private:
// of handling the last repeated wheel event so that in case event handling
// takes time, some repeated events can be skipped to not flood child process.
mozilla::TimeStamp mLastWheelProcessedTimeFromParent;
mozilla::TimeDuration mLastWheelProcessingDuration;
CoalescedWheelData mCoalescedWheelData;
AutoTArray<bool, NUMBER_OF_AUDIO_CHANNELS> mAudioChannelsActive;