Coverage Report

Created: 2018-09-25 14:53

/src/mozilla-central/gfx/layers/ipc/APZCTreeManagerChild.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
7
#include "mozilla/layers/APZCTreeManagerChild.h"
8
9
#include "InputData.h"                  // for InputData
10
#include "mozilla/dom/TabParent.h"      // for TabParent
11
#include "mozilla/layers/APZCCallbackHelper.h" // for APZCCallbackHelper
12
#include "mozilla/layers/APZInputBridgeChild.h" // for APZInputBridgeChild
13
#include "mozilla/layers/RemoteCompositorSession.h" // for RemoteCompositorSession
14
15
namespace mozilla {
16
namespace layers {
17
18
APZCTreeManagerChild::APZCTreeManagerChild()
19
  : mCompositorSession(nullptr)
20
0
{
21
0
}
22
23
APZCTreeManagerChild::~APZCTreeManagerChild()
24
0
{
25
0
}
26
27
void
28
APZCTreeManagerChild::SetCompositorSession(RemoteCompositorSession* aSession)
29
0
{
30
0
  // Exactly one of mCompositorSession and aSession must be null (i.e. either
31
0
  // we're setting mCompositorSession or we're clearing it).
32
0
  MOZ_ASSERT(!mCompositorSession ^ !aSession);
33
0
  mCompositorSession = aSession;
34
0
}
35
36
void
37
APZCTreeManagerChild::SetInputBridge(APZInputBridgeChild* aInputBridge)
38
0
{
39
0
  // The input bridge only exists from the UI process to the GPU process.
40
0
  MOZ_ASSERT(XRE_IsParentProcess());
41
0
  MOZ_ASSERT(!mInputBridge);
42
0
43
0
  mInputBridge = aInputBridge;
44
0
}
45
46
void
47
APZCTreeManagerChild::Destroy()
48
0
{
49
0
  MOZ_ASSERT(NS_IsMainThread());
50
0
  if (mInputBridge) {
51
0
    mInputBridge->Destroy();
52
0
    mInputBridge = nullptr;
53
0
  }
54
0
}
55
56
void
57
APZCTreeManagerChild::SetKeyboardMap(const KeyboardMap& aKeyboardMap)
58
0
{
59
0
  SendSetKeyboardMap(aKeyboardMap);
60
0
}
61
62
void
63
APZCTreeManagerChild::ZoomToRect(
64
    const ScrollableLayerGuid& aGuid,
65
    const CSSRect& aRect,
66
    const uint32_t aFlags)
67
0
{
68
0
  SendZoomToRect(aGuid, aRect, aFlags);
69
0
}
70
71
void
72
APZCTreeManagerChild::ContentReceivedInputBlock(
73
    uint64_t aInputBlockId,
74
    bool aPreventDefault)
75
0
{
76
0
  SendContentReceivedInputBlock(aInputBlockId, aPreventDefault);
77
0
}
78
79
void
80
APZCTreeManagerChild::SetTargetAPZC(
81
    uint64_t aInputBlockId,
82
    const nsTArray<ScrollableLayerGuid>& aTargets)
83
0
{
84
0
  SendSetTargetAPZC(aInputBlockId, aTargets);
85
0
}
86
87
void
88
APZCTreeManagerChild::UpdateZoomConstraints(
89
    const ScrollableLayerGuid& aGuid,
90
    const Maybe<ZoomConstraints>& aConstraints)
91
0
{
92
0
  SendUpdateZoomConstraints(aGuid, aConstraints);
93
0
}
94
95
void
96
APZCTreeManagerChild::SetDPI(float aDpiValue)
97
0
{
98
0
  SendSetDPI(aDpiValue);
99
0
}
100
101
void
102
APZCTreeManagerChild::SetAllowedTouchBehavior(
103
    uint64_t aInputBlockId,
104
    const nsTArray<TouchBehaviorFlags>& aValues)
105
0
{
106
0
  SendSetAllowedTouchBehavior(aInputBlockId, aValues);
107
0
}
108
109
void
110
APZCTreeManagerChild::StartScrollbarDrag(
111
    const ScrollableLayerGuid& aGuid,
112
    const AsyncDragMetrics& aDragMetrics)
113
0
{
114
0
  SendStartScrollbarDrag(aGuid, aDragMetrics);
115
0
}
116
117
bool
118
APZCTreeManagerChild::StartAutoscroll(
119
    const ScrollableLayerGuid& aGuid,
120
    const ScreenPoint& aAnchorLocation)
121
0
{
122
0
  return SendStartAutoscroll(aGuid, aAnchorLocation);
123
0
}
124
125
void
126
APZCTreeManagerChild::StopAutoscroll(const ScrollableLayerGuid& aGuid)
127
0
{
128
0
  SendStopAutoscroll(aGuid);
129
0
}
130
131
void
132
APZCTreeManagerChild::SetLongTapEnabled(bool aTapGestureEnabled)
133
0
{
134
0
  SendSetLongTapEnabled(aTapGestureEnabled);
135
0
}
136
137
APZInputBridge*
138
APZCTreeManagerChild::InputBridge()
139
0
{
140
0
  MOZ_ASSERT(XRE_IsParentProcess());
141
0
  MOZ_ASSERT(mInputBridge);
142
0
143
0
  return mInputBridge.get();
144
0
}
145
146
mozilla::ipc::IPCResult
147
APZCTreeManagerChild::RecvHandleTap(const TapType& aType,
148
                                    const LayoutDevicePoint& aPoint,
149
                                    const Modifiers& aModifiers,
150
                                    const ScrollableLayerGuid& aGuid,
151
                                    const uint64_t& aInputBlockId)
152
0
{
153
0
  MOZ_ASSERT(XRE_IsParentProcess());
154
0
  if (mCompositorSession &&
155
0
      mCompositorSession->RootLayerTreeId() == aGuid.mLayersId &&
156
0
      mCompositorSession->GetContentController()) {
157
0
    mCompositorSession->GetContentController()->HandleTap(aType, aPoint,
158
0
        aModifiers, aGuid, aInputBlockId);
159
0
    return IPC_OK();
160
0
  }
161
0
  dom::TabParent* tab = dom::TabParent::GetTabParentFromLayersId(aGuid.mLayersId);
162
0
  if (tab) {
163
0
    tab->SendHandleTap(aType, aPoint, aModifiers, aGuid, aInputBlockId);
164
0
  }
165
0
  return IPC_OK();
166
0
}
167
168
mozilla::ipc::IPCResult
169
APZCTreeManagerChild::RecvNotifyPinchGesture(const PinchGestureType& aType,
170
                                             const ScrollableLayerGuid& aGuid,
171
                                             const LayoutDeviceCoord& aSpanChange,
172
                                             const Modifiers& aModifiers)
173
0
{
174
0
  // This will only get sent from the GPU process to the parent process, so
175
0
  // this function should never get called in the content process.
176
0
  MOZ_ASSERT(XRE_IsParentProcess());
177
0
  MOZ_ASSERT(NS_IsMainThread());
178
0
179
0
  // We want to handle it in this process regardless of what the target guid
180
0
  // of the pinch is. This may change in the future.
181
0
  if (mCompositorSession &&
182
0
      mCompositorSession->GetWidget()) {
183
0
    APZCCallbackHelper::NotifyPinchGesture(aType, aSpanChange, aModifiers, mCompositorSession->GetWidget());
184
0
  }
185
0
  return IPC_OK();
186
0
}
187
188
mozilla::ipc::IPCResult
189
APZCTreeManagerChild::RecvCancelAutoscroll(const FrameMetrics::ViewID& aScrollId)
190
0
{
191
0
  // This will only get sent from the GPU process to the parent process, so
192
0
  // this function should never get called in the content process.
193
0
  MOZ_ASSERT(XRE_IsParentProcess());
194
0
  MOZ_ASSERT(NS_IsMainThread());
195
0
196
0
  APZCCallbackHelper::CancelAutoscroll(aScrollId);
197
0
  return IPC_OK();
198
0
}
199
200
} // namespace layers
201
} // namespace mozilla