/src/mozilla-central/dom/ipc/CoalescedWheelData.cpp
Line | Count | Source (jump to first uncovered line) |
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 | | |
10 | | using namespace mozilla; |
11 | | using namespace mozilla::dom; |
12 | | |
13 | | void |
14 | | CoalescedWheelData::Coalesce(const WidgetWheelEvent& aEvent, |
15 | | const ScrollableLayerGuid& aGuid, |
16 | | const uint64_t& aInputBlockId) |
17 | 0 | { |
18 | 0 | if (IsEmpty()) { |
19 | 0 | mCoalescedInputEvent = MakeUnique<WidgetWheelEvent>(aEvent); |
20 | 0 | mGuid = aGuid; |
21 | 0 | mInputBlockId = aInputBlockId; |
22 | 0 | } else { |
23 | 0 | MOZ_ASSERT(mGuid == aGuid); |
24 | 0 | MOZ_ASSERT(mInputBlockId == aInputBlockId); |
25 | 0 | MOZ_ASSERT(mCoalescedInputEvent->mModifiers == aEvent.mModifiers); |
26 | 0 | MOZ_ASSERT(mCoalescedInputEvent->mDeltaMode == aEvent.mDeltaMode); |
27 | 0 | MOZ_ASSERT(mCoalescedInputEvent->mCanTriggerSwipe == |
28 | 0 | aEvent.mCanTriggerSwipe); |
29 | 0 | mCoalescedInputEvent->mDeltaX += aEvent.mDeltaX; |
30 | 0 | mCoalescedInputEvent->mDeltaY += aEvent.mDeltaY; |
31 | 0 | mCoalescedInputEvent->mDeltaZ += aEvent.mDeltaZ; |
32 | 0 | mCoalescedInputEvent->mLineOrPageDeltaX += aEvent.mLineOrPageDeltaX; |
33 | 0 | mCoalescedInputEvent->mLineOrPageDeltaY += aEvent.mLineOrPageDeltaY; |
34 | 0 | mCoalescedInputEvent->mTimeStamp = aEvent.mTimeStamp; |
35 | 0 | } |
36 | 0 | } |
37 | | |
38 | | bool |
39 | | CoalescedWheelData::CanCoalesce(const WidgetWheelEvent& aEvent, |
40 | | const ScrollableLayerGuid& aGuid, |
41 | | const uint64_t& aInputBlockId) |
42 | 0 | { |
43 | 0 | MOZ_ASSERT(!IsEmpty()); |
44 | 0 | return !mCoalescedInputEvent || |
45 | 0 | (mCoalescedInputEvent->mRefPoint == aEvent.mRefPoint && |
46 | 0 | mCoalescedInputEvent->mModifiers == aEvent.mModifiers && |
47 | 0 | mCoalescedInputEvent->mDeltaMode == aEvent.mDeltaMode && |
48 | 0 | mCoalescedInputEvent->mCanTriggerSwipe == aEvent.mCanTriggerSwipe && |
49 | 0 | mGuid == aGuid && |
50 | 0 | mInputBlockId == aInputBlockId); |
51 | 0 | } |