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 
7 #ifndef mozilla_layers_APZInputBridgeChild_h
8 #define mozilla_layers_APZInputBridgeChild_h
9 
10 #include "mozilla/layers/APZInputBridge.h"
11 #include "mozilla/layers/PAPZInputBridgeChild.h"
12 
13 namespace mozilla {
14 namespace layers {
15 
16 class APZInputBridgeChild : public PAPZInputBridgeChild, public APZInputBridge {
17   NS_INLINE_DECL_THREADSAFE_REFCOUNTING(APZInputBridgeChild, final)
18 
19  public:
20   static RefPtr<APZInputBridgeChild> Create(
21       const uint64_t& aProcessToken,
22       Endpoint<PAPZInputBridgeChild>&& aEndpoint);
23 
24   void Destroy();
25 
26   APZEventResult ReceiveInputEvent(
27       InputData& aEvent,
28       InputBlockCallback&& aCallback = InputBlockCallback()) override;
29 
30   mozilla::ipc::IPCResult RecvCallInputBlockCallback(
31       uint64_t aInputBlockId, const APZHandledResult& handledResult);
32 
33  protected:
34   void ProcessUnhandledEvent(LayoutDeviceIntPoint* aRefPoint,
35                              ScrollableLayerGuid* aOutTargetGuid,
36                              uint64_t* aOutFocusSequenceNumber,
37                              LayersId* aOutLayersId) override;
38 
39   void UpdateWheelTransaction(
40       LayoutDeviceIntPoint aRefPoint, EventMessage aEventMessage,
41       const Maybe<ScrollableLayerGuid>& aTargetGuid) override;
42 
43   void ActorDestroy(ActorDestroyReason aWhy) override;
44 
45   explicit APZInputBridgeChild(const uint64_t& aProcessToken);
46   virtual ~APZInputBridgeChild();
47 
48  private:
49   void Open(Endpoint<PAPZInputBridgeChild>&& aEndpoint);
50 
51   bool mIsOpen;
52   uint64_t mProcessToken;
53 
54   using InputBlockCallbackMap =
55       std::unordered_map<uint64_t, InputBlockCallback>;
56   InputBlockCallbackMap mInputBlockCallbacks;
57 };
58 
59 }  // namespace layers
60 }  // namespace mozilla
61 
62 #endif  // mozilla_layers_APZInputBridgeChild_h
63