Bug 1839198 - Skip processing swipe-to-navigation stuff in PiP windows. r=botond,pip-reviewers,mconley

Depends on D181417

Differential Revision: https://phabricator.services.mozilla.com/D181418
This commit is contained in:
Hiroyuki Ikezoe 2023-06-22 20:53:18 +00:00
Родитель c2df274d5e
Коммит 64aa4601c5
3 изменённых файлов: 58 добавлений и 0 удалений

Просмотреть файл

@ -60,6 +60,7 @@ skip-if = os == "linux" && bits == 64 && os_version == "18.04" # Bug 1569205
[browser_cornerSnapping.js]
run-if = os == "mac"
[browser_dblclickFullscreen.js]
[browser_disableSwipeGestures.js]
[browser_durationChange.js]
[browser_flipIconWithRTL.js]
skip-if =

Просмотреть файл

@ -0,0 +1,47 @@
/* Any copyright is dedicated to the Public Domain.
* http://creativecommons.org/publicdomain/zero/1.0/ */
"use strict";
Services.scriptloader.loadSubScript(
"chrome://mochitests/content/browser/gfx/layers/apz/test/mochitest/apz_test_native_event_utils.js",
this
);
add_task(async () => {
await BrowserTestUtils.withNewTab(
{
gBrowser,
url: TEST_PAGE,
},
async browser => {
let pipWin = await triggerPictureInPicture(browser, "with-controls");
let receivedSwipeGestureEvents = false;
pipWin.addEventListener("MozSwipeGestureMayStart", () => {
receivedSwipeGestureEvents = true;
});
const wheelEventPromise = BrowserTestUtils.waitForEvent(pipWin, "wheel");
// Try swiping left to right.
await panLeftToRightBegin(pipWin, 100, 100, 100);
await panLeftToRightEnd(pipWin, 100, 100, 100);
// Wait a wheel event and a couple of frames to give a chance to receive
// the MozSwipeGestureMayStart event.
await wheelEventPromise;
await new Promise(resolve => requestAnimationFrame(resolve));
await new Promise(resolve => requestAnimationFrame(resolve));
Assert.ok(
!receivedSwipeGestureEvents,
"No swipe gesture events observed"
);
let pipClosed = BrowserTestUtils.domWindowClosed(pipWin);
pipWin.close();
await pipClosed;
}
);
});

Просмотреть файл

@ -2316,6 +2316,11 @@ WidgetWheelEvent nsBaseWidget::MayStartSwipeForAPZ(
const PanGestureInput& aPanInput, const APZEventResult& aApzResult) {
WidgetWheelEvent event = aPanInput.ToWidgetEvent(this);
// Ignore swipe-to-navigation in PiP window.
if (mIsPIPWindow) {
return event;
}
if (aPanInput.AllowsSwipe()) {
SwipeInfo swipeInfo = SendMayStartSwipe(aPanInput);
event.mCanTriggerSwipe = swipeInfo.wantsSwipe;
@ -2357,6 +2362,11 @@ WidgetWheelEvent nsBaseWidget::MayStartSwipeForAPZ(
}
bool nsBaseWidget::MayStartSwipeForNonAPZ(const PanGestureInput& aPanInput) {
// Ignore swipe-to-navigation in PiP window.
if (mIsPIPWindow) {
return false;
}
if (aPanInput.mType == PanGestureInput::PANGESTURE_MAYSTART ||
aPanInput.mType == PanGestureInput::PANGESTURE_START) {
mCurrentPanGestureBelongsToSwipe = false;