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/. */
7 #ifndef mozilla_dom_CoalescedInputData_h
8 #define mozilla_dom_CoalescedInputData_h
10 #include "mozilla/UniquePtr.h"
11 #include "mozilla/layers/ScrollableLayerGuid.h"
12 #include "nsRefreshObservers.h"
14 class nsRefreshDriver
;
16 namespace mozilla::dom
{
20 template <class InputEventType
>
21 class CoalescedInputData
{
23 using ScrollableLayerGuid
= mozilla::layers::ScrollableLayerGuid
;
25 UniquePtr
<InputEventType
> mCoalescedInputEvent
;
26 ScrollableLayerGuid mGuid
;
27 uint64_t mInputBlockId
;
30 CoalescedInputData() : mInputBlockId(0) {}
32 void RetrieveDataFrom(CoalescedInputData
& aSource
) {
33 mCoalescedInputEvent
= std::move(aSource
.mCoalescedInputEvent
);
34 mGuid
= aSource
.mGuid
;
35 mInputBlockId
= aSource
.mInputBlockId
;
38 bool IsEmpty() { return !mCoalescedInputEvent
; }
40 bool CanCoalesce(const InputEventType
& aEvent
,
41 const ScrollableLayerGuid
& aGuid
,
42 const uint64_t& aInputBlockId
);
44 UniquePtr
<InputEventType
> TakeCoalescedEvent() {
45 return std::move(mCoalescedInputEvent
);
48 ScrollableLayerGuid
GetScrollableLayerGuid() { return mGuid
; }
50 uint64_t GetInputBlockId() { return mInputBlockId
; }
53 class CoalescedInputFlusher
: public nsARefreshObserver
{
55 explicit CoalescedInputFlusher(BrowserChild
* aBrowserChild
);
57 virtual void WillRefresh(mozilla::TimeStamp aTime
) override
= 0;
59 NS_INLINE_DECL_REFCOUNTING(CoalescedInputFlusher
, override
)
62 void RemoveObserver();
65 virtual ~CoalescedInputFlusher();
67 nsRefreshDriver
* GetRefreshDriver();
69 BrowserChild
* mBrowserChild
;
70 RefPtr
<nsRefreshDriver
> mRefreshDriver
;
72 } // namespace mozilla::dom
74 #endif // mozilla_dom_CoalescedInputData_h