Commit 39cfa034 authored by Ryan Landay's avatar Ryan Landay Committed by Commit Bot

Fix jerky incognito toggle animation in Android horizontal tab switcher

In https://chromium-review.googlesource.com/1096489, I added a fix for an issue
where a tab could get stuck in a partially-discarded state if you started
dragging it and then tapped the incognito button while you still had your finger
down. Unfortunately, my original fix for the issue, which was to start an
undiscard animation in NonOverlappingStack#runSwitchAwayAnimation(), is a bad
idea, since that animation animates the StackTabs' scroll offsets, conflicting
with the incognito animation, causing animation jankiness.

This CL replaces the call to start the discard animation with a loop that just
sets each tab's scroll offset to 0.

Bug: 853034,852995,831359
Change-Id: I4b6e34bf68afb9ce025e3272c0c0816f84f8b48e
Reviewed-on: https://chromium-review.googlesource.com/1102115Reviewed-by: default avatarMatthew Jones <mdjones@chromium.org>
Commit-Queue: Ryan Landay <rlanday@chromium.org>
Cr-Commit-Position: refs/heads/master@{#567675}
parent b5b864d7
...@@ -12,10 +12,8 @@ import android.support.annotation.IntDef; ...@@ -12,10 +12,8 @@ import android.support.annotation.IntDef;
import org.chromium.chrome.browser.compositor.animation.CompositorAnimationHandler; import org.chromium.chrome.browser.compositor.animation.CompositorAnimationHandler;
import org.chromium.chrome.browser.compositor.animation.CompositorAnimator; import org.chromium.chrome.browser.compositor.animation.CompositorAnimator;
import org.chromium.chrome.browser.compositor.layouts.LayoutManager;
import org.chromium.chrome.browser.compositor.layouts.components.LayoutTab; import org.chromium.chrome.browser.compositor.layouts.components.LayoutTab;
import org.chromium.chrome.browser.compositor.layouts.phone.StackLayoutBase; import org.chromium.chrome.browser.compositor.layouts.phone.StackLayoutBase;
import org.chromium.chrome.browser.compositor.layouts.phone.stack.StackAnimation.OverviewAnimationType;
import java.lang.annotation.Retention; import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy; import java.lang.annotation.RetentionPolicy;
...@@ -341,14 +339,14 @@ public class NonOverlappingStack extends Stack { ...@@ -341,14 +339,14 @@ public class NonOverlappingStack extends Stack {
return; return;
} }
// Make sure we don't leave any tabs stuck in a partially-discarded
// state.
startAnimation(LayoutManager.time(), OverviewAnimationType.UNDISCARD);
mDiscardingTab = null;
mSwitchedAway = true; mSwitchedAway = true;
mSuppressScrollClamping = true; mSuppressScrollClamping = true;
// Make sure we don't leave any tabs stuck in a partially-discarded state.
for (int i = 0; i < mStackTabs.length; i++) {
mStackTabs[i].setDiscardAmount(0);
}
// Make sure the tabs are not scrolling so the centered tab does not change between the // Make sure the tabs are not scrolling so the centered tab does not change between the
// "switch away" and "switch to" animations. // "switch away" and "switch to" animations.
forceScrollStop(); forceScrollStop();
...@@ -432,6 +430,17 @@ public class NonOverlappingStack extends Stack { ...@@ -432,6 +430,17 @@ public class NonOverlappingStack extends Stack {
set.addListener(new AnimatorListenerAdapter() { set.addListener(new AnimatorListenerAdapter() {
@Override @Override
public void onAnimationEnd(Animator a) { public void onAnimationEnd(Animator a) {
// There are some oddball cases, e.g. a tab was immediately closed before triggering
// the toggle animation, where the tab offsets might get left in an undesired state.
// Resetting all the scroll offsets here limits the effect of these bugs to just
// making the animation look funny vs. leaving the tabs e.g. stuck with gaps between
// them or overlapping each other.
if (mStackTabs != null) {
for (int i = 0; i < mStackTabs.length; i++) {
mStackTabs[i].setScrollOffset(i * mSpacing);
}
}
mSuppressScrollClamping = false; mSuppressScrollClamping = false;
mLayout.onSwitchToFinished(); mLayout.onSwitchToFinished();
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment