Skip to content

Commit 28077f3

Browse files
committed
Bug 1856716 - Ensure that we hold a strong reference to the APZ event state. r=hiro
- Ensure that we hold a strong reference to the APZ event state before calling ProcessSingleTap, as ProcessSingleTap fires events. - Mark ProcessSingleTap as MOZ_CAN_RUN_SCRIPT since it can fire events. Differential Revision: https://phabricator.services.mozilla.com/D190228
1 parent 3eceb9a commit 28077f3

File tree

3 files changed

+15
-10
lines changed

3 files changed

+15
-10
lines changed

dom/ipc/BrowserChild.cpp

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1341,17 +1341,19 @@ mozilla::ipc::IPCResult BrowserChild::RecvHandleTap(
13411341
switch (aType) {
13421342
case GeckoContentController::TapType::eSingleTap:
13431343
if (mBrowserChildMessageManager) {
1344-
mAPZEventState->ProcessSingleTap(point, scale, aModifiers, 1,
1345-
aInputBlockId);
1344+
RefPtr<APZEventState> eventState(mAPZEventState);
1345+
eventState->ProcessSingleTap(point, scale, aModifiers, 1,
1346+
aInputBlockId);
13461347
}
13471348
break;
13481349
case GeckoContentController::TapType::eDoubleTap:
13491350
HandleDoubleTap(point, aModifiers, aGuid);
13501351
break;
13511352
case GeckoContentController::TapType::eSecondTap:
13521353
if (mBrowserChildMessageManager) {
1353-
mAPZEventState->ProcessSingleTap(point, scale, aModifiers, 2,
1354-
aInputBlockId);
1354+
RefPtr<APZEventState> eventState(mAPZEventState);
1355+
eventState->ProcessSingleTap(point, scale, aModifiers, 2,
1356+
aInputBlockId);
13551357
}
13561358
break;
13571359
case GeckoContentController::TapType::eLongTap:

gfx/layers/apz/util/APZEventState.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ class APZEventState final {
5757

5858
NS_INLINE_DECL_REFCOUNTING(APZEventState);
5959

60+
MOZ_CAN_RUN_SCRIPT
6061
void ProcessSingleTap(const CSSPoint& aPoint,
6162
const CSSToLayoutDeviceScale& aScale,
6263
Modifiers aModifiers, int32_t aClickCount,

gfx/layers/apz/util/ChromeProcessController.cpp

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -193,17 +193,19 @@ void ChromeProcessController::HandleTap(
193193
InputAPZContext context(aGuid, aInputBlockId, nsEventStatus_eSentinel);
194194

195195
switch (aType) {
196-
case TapType::eSingleTap:
197-
mAPZEventState->ProcessSingleTap(point, scale, aModifiers, 1,
198-
aInputBlockId);
196+
case TapType::eSingleTap: {
197+
RefPtr<APZEventState> eventState(mAPZEventState);
198+
eventState->ProcessSingleTap(point, scale, aModifiers, 1, aInputBlockId);
199199
break;
200+
}
200201
case TapType::eDoubleTap:
201202
HandleDoubleTap(point, aModifiers, aGuid);
202203
break;
203-
case TapType::eSecondTap:
204-
mAPZEventState->ProcessSingleTap(point, scale, aModifiers, 2,
205-
aInputBlockId);
204+
case TapType::eSecondTap: {
205+
RefPtr<APZEventState> eventState(mAPZEventState);
206+
eventState->ProcessSingleTap(point, scale, aModifiers, 2, aInputBlockId);
206207
break;
208+
}
207209
case TapType::eLongTap: {
208210
RefPtr<APZEventState> eventState(mAPZEventState);
209211
eventState->ProcessLongTap(presShell, point, scale, aModifiers,

0 commit comments

Comments
 (0)