Skip to content

Commit

Permalink
Ignore clicks on tab cards during disappearing animation
Browse files Browse the repository at this point in the history
https://crrev.com/c/1730253 introduced a crashing regression: after
clicking the incognito toggle or "close all", before the animation
is done, click on a disappearing tab would crash Clank.

That CL makes tabs not clickable during the animation.

Bug: 991014, 990698
Change-Id: I6d8c03012cd029ebff51495fba593b5c20b44106
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1740851
Reviewed-by: Mei Liang <meiliang@chromium.org>
Commit-Queue: Wei-Yin Chen (陳威尹) <wychen@chromium.org>
Cr-Commit-Position: refs/heads/master@{#685840}
  • Loading branch information
wychen authored and Commit Bot committed Aug 10, 2019
1 parent 4ac1469 commit cec2fb9
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,8 @@ Rect getRecyclerViewLocation() {
* @return Whether a valid {@link Rect} is obtained.
*/
boolean updateThumbnailLocation() {
Rect rect = mRecyclerView.getRectOfCurrentThumbnail(mMediator.indexOfSelected());
Rect rect = mRecyclerView.getRectOfCurrentThumbnail(
mMediator.indexOfSelected(), mMediator.selectedTabId());
if (rect == null) return false;
mThumbnailLocationOfCurrentTab.set(rect);
return true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,8 @@ interface GridCardOnClickListenerProvider {
private final TabActionListener mTabSelectedListener = new TabActionListener() {
@Override
public void run(int tabId) {
if (mModel.indexFromId(tabId) == TabModel.INVALID_TAB_INDEX) return;

mNextTabId = tabId;

if (!mActionsOnAllRelatedTabs) {
Expand Down Expand Up @@ -592,6 +594,9 @@ public void didCreateGroup(
mTabClosedListener = new TabActionListener() {
@Override
public void run(int tabId) {
// TODO(crbug.com/990698): Consider disabling all touch events during animation.
if (mModel.indexFromId(tabId) == TabModel.INVALID_TAB_INDEX) return;

RecordUserAction.record("MobileTabClosed." + mComponentName);

if (mActionsOnAllRelatedTabs) {
Expand Down Expand Up @@ -962,6 +967,14 @@ private TabActionListener getCreateGroupButtonListener(Tab tab, boolean isSelect
return createGroupButtonOnClickListener;
}

int selectedTabId() {
if (mNextTabId != Tab.INVALID_TAB_ID) {
return mNextTabId;
}

return mTabModelSelector.getCurrentTabId();
}

int indexOfSelected() {
if (mNextTabId != Tab.INVALID_TAB_ID) {
return getIndexOfTab(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -401,15 +401,17 @@ private void endAllAnimations() {
}

/**
* @param currentTabIndex The the current tab's index in the model.
* @param selectedTabIndex The index in the RecyclerView of the selected tab.
* @param selectedTabId The tab ID of the selected tab.
* @return The {@link Rect} of the thumbnail of the current tab, relative to the
* {@link TabListRecyclerView} coordinates.
*/
@Nullable
Rect getRectOfCurrentThumbnail(int currentTabIndex) {
Rect getRectOfCurrentThumbnail(int selectedTabIndex, int selectedTabId) {
TabGridViewHolder holder =
(TabGridViewHolder) findViewHolderForAdapterPosition(currentTabIndex);
(TabGridViewHolder) findViewHolderForAdapterPosition(selectedTabIndex);
if (holder == null) return null;
assert holder.getTabId() == selectedTabId;
return getRectOfComponent(holder.thumbnail);
}

Expand Down

0 comments on commit cec2fb9

Please sign in to comment.