From 37ad3fe4f17901d2ef54480126fcf520e3bacaa4 Mon Sep 17 00:00:00 2001 From: Lijin Shen Date: Thu, 8 Jun 2023 23:34:17 +0000 Subject: [PATCH] [M115] Fix tab switcher handler keeps consuming back event on tablet mIsTransitionInProgress was introduced to prevent back event from being consumed by tab navigation during the transition of tab-to-GTS animation (expand/shrink tabs). On tablet, a translation replaces that and a back event will cancel the animation rather than causing the tab to be navigated. The bug can be triggered when a back gesture is performed during closing the tab switcher on tablet. The 2nd back event will force the previous animation to end and assign mIsTransitionInProgress to false. Then the 2nd back event triggered hideTabSwitcherView again to assign it to true. But the previous animation has hidden the tab switcher, postHiding will not be invoked again, leaving mIsTransitionInProgress being true forever. (cherry picked from commit 51b108dac4d1c3bb3c2a7c5cab6afad60ca1fd46) Bug: 1449027 Change-Id: I33eb191907a3e9d95abef9e6a9906d63eefeb329 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4575333 Commit-Queue: Lijin Shen Code-Coverage: Findit Reviewed-by: Calder Kitagawa Cr-Original-Commit-Position: refs/heads/main@{#1151434} Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4599890 Reviewed-by: Mei Liang Cr-Commit-Position: refs/branch-heads/5790@{#509} Cr-Branched-From: 1d71a337b1f6e707a13ae074dca1e2c34905eb9f-refs/heads/main@{#1148114} --- .../tasks/tab_management/TabSwitcherMediator.java | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/chrome/android/features/tab_ui/java/src/org/chromium/chrome/browser/tasks/tab_management/TabSwitcherMediator.java b/chrome/android/features/tab_ui/java/src/org/chromium/chrome/browser/tasks/tab_management/TabSwitcherMediator.java index 40797c09239cf..3f094cd1ee67b 100644 --- a/chrome/android/features/tab_ui/java/src/org/chromium/chrome/browser/tasks/tab_management/TabSwitcherMediator.java +++ b/chrome/android/features/tab_ui/java/src/org/chromium/chrome/browser/tasks/tab_management/TabSwitcherMediator.java @@ -877,10 +877,11 @@ private boolean onBackPressedInternal() { return true; } - if (mIsTransitionInProgress && mMode == TabListCoordinator.TabListMode.GRID) { - // crbug.com/1420410: intentionally do nothing to wait for transition to be finished. - // Note this has to be before following if-branch since during transition, the container - // is still invisible. + if (!mIsTablet && mIsTransitionInProgress && mMode == TabListCoordinator.TabListMode.GRID) { + // crbug.com/1420410: intentionally do nothing to wait for tab-to-GTS transition to be + // finished. Note this has to be before following if-branch since during transition, the + // container is still invisible. On tablet, the translation transition replaces the + // tab-to-GTS (expand/shrink) animation, which does not suffer from the same issue. return true; } @@ -1184,7 +1185,9 @@ boolean shouldInterceptBackPress() { if (isDialogVisible()) return true; if (mCustomViewBackPressRunnable != null) return true; - if (mIsTransitionInProgress && mMode == TabListCoordinator.TabListMode.GRID) return true; + if (!mIsTablet && mIsTransitionInProgress && mMode == TabListCoordinator.TabListMode.GRID) { + return true; + } if (!mContainerViewModel.get(IS_VISIBLE)) return false;