no bug - Bumping Firefox l10n changesets r=release a=l10n-bump DONTBUILD CLOSED TREE
[gecko.git] / dom / ipc / CoalescedInputData.h
blobaeac9d99a0c38cee189e80baa94631483c569ef4
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 {
18 class BrowserChild;
20 template <class InputEventType>
21 class CoalescedInputData {
22 protected:
23 using ScrollableLayerGuid = mozilla::layers::ScrollableLayerGuid;
25 UniquePtr<InputEventType> mCoalescedInputEvent;
26 ScrollableLayerGuid mGuid;
27 uint64_t mInputBlockId;
29 public:
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 {
54 public:
55 explicit CoalescedInputFlusher(BrowserChild* aBrowserChild);
57 virtual void WillRefresh(mozilla::TimeStamp aTime) override = 0;
59 NS_INLINE_DECL_REFCOUNTING(CoalescedInputFlusher, override)
61 void StartObserver();
62 void RemoveObserver();
64 protected:
65 virtual ~CoalescedInputFlusher();
67 nsRefreshDriver* GetRefreshDriver();
69 BrowserChild* mBrowserChild;
70 RefPtr<nsRefreshDriver> mRefreshDriver;
72 } // namespace mozilla::dom
74 #endif // mozilla_dom_CoalescedInputData_h