Line data Source code
1 : /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 : /* vim: set ts=8 sts=2 et sw=2 tw=80: */
3 : /* This Source Code Form is subject to the terms of the Mozilla Public
4 : * License, v. 2.0. If a copy of the MPL was not distributed with this
5 : * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
6 : #include "base/basictypes.h"
7 :
8 : #include "CoalescedWheelData.h"
9 : #include "FrameMetrics.h"
10 :
11 : using namespace mozilla;
12 : using namespace mozilla::dom;
13 :
14 : void
15 0 : CoalescedWheelData::Coalesce(const WidgetWheelEvent& aEvent,
16 : const ScrollableLayerGuid& aGuid,
17 : const uint64_t& aInputBlockId)
18 : {
19 0 : if (IsEmpty()) {
20 0 : mCoalescedWheelEvent = MakeUnique<WidgetWheelEvent>(aEvent);
21 0 : mGuid = aGuid;
22 0 : mInputBlockId = aInputBlockId;
23 : } else {
24 0 : MOZ_ASSERT(mGuid == aGuid);
25 0 : MOZ_ASSERT(mInputBlockId == aInputBlockId);
26 0 : MOZ_ASSERT(mCoalescedWheelEvent->mModifiers == aEvent.mModifiers);
27 0 : MOZ_ASSERT(mCoalescedWheelEvent->mDeltaMode == aEvent.mDeltaMode);
28 0 : MOZ_ASSERT(mCoalescedWheelEvent->mCanTriggerSwipe ==
29 : aEvent.mCanTriggerSwipe);
30 0 : mCoalescedWheelEvent->mDeltaX += aEvent.mDeltaX;
31 0 : mCoalescedWheelEvent->mDeltaY += aEvent.mDeltaY;
32 0 : mCoalescedWheelEvent->mDeltaZ += aEvent.mDeltaZ;
33 0 : mCoalescedWheelEvent->mLineOrPageDeltaX += aEvent.mLineOrPageDeltaX;
34 0 : mCoalescedWheelEvent->mLineOrPageDeltaY += aEvent.mLineOrPageDeltaY;
35 0 : mCoalescedWheelEvent->mTimeStamp = aEvent.mTimeStamp;
36 : }
37 0 : }
38 :
39 : bool
40 0 : CoalescedWheelData::CanCoalesce(const WidgetWheelEvent& aEvent,
41 : const ScrollableLayerGuid& aGuid,
42 : const uint64_t& aInputBlockId)
43 : {
44 0 : MOZ_ASSERT(!IsEmpty());
45 0 : return !mCoalescedWheelEvent ||
46 0 : (mCoalescedWheelEvent->mRefPoint == aEvent.mRefPoint &&
47 0 : mCoalescedWheelEvent->mModifiers == aEvent.mModifiers &&
48 0 : mCoalescedWheelEvent->mDeltaMode == aEvent.mDeltaMode &&
49 0 : mCoalescedWheelEvent->mCanTriggerSwipe == aEvent.mCanTriggerSwipe &&
50 0 : mGuid == aGuid &&
51 0 : mInputBlockId == aInputBlockId);
52 : }
|