Commit d8851f09 authored by Andrew Xu's avatar Andrew Xu Committed by Commit Bot

[Scrollable Shelf] Fix crash under extremely small display

As reported by Clusterfuzz, hotseat widget may not have enough space to
fully show even one shelf icon. Under that edge case, the end of the
last shelf icon will be outside the scrollable shelf. Based on the
current code, |last_visible_view_index| will be -1. This CL fixes the
issue.

Bug: 1094363
Change-Id: Ib4a49267c82a54e3c66f88df9702dddb216eca89
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2250706
Commit-Queue: Andrew Xu <andrewxu@chromium.org>
Reviewed-by: default avatarXiyuan Xia <xiyuan@chromium.org>
Cr-Commit-Position: refs/heads/master@{#779561}
parent 8c90236d
...@@ -1965,8 +1965,13 @@ std::pair<int, int> ScrollableShelfView::CalculateTappableIconIndices( ...@@ -1965,8 +1965,13 @@ std::pair<int, int> ScrollableShelfView::CalculateTappableIconIndices(
const int end_of_last_visible_view = const int end_of_last_visible_view =
last_visible_view_index * space_needed_for_button + last_visible_view_index * space_needed_for_button +
shelf_view_->GetButtonSize() - scroll_distance_on_main_axis; shelf_view_->GetButtonSize() - scroll_distance_on_main_axis;
if (end_of_last_visible_view > visible_size)
// It is very rare but |visible_size| may be smaller than
// |space_needed_for_button| as reported in https://crbug.com/1094363.
if (end_of_last_visible_view > visible_size &&
last_visible_view_index > first_visible_view_index) {
last_visible_view_index--; last_visible_view_index--;
}
} else { } else {
DCHECK_EQ(layout_strategy, kShowLeftArrowButton); DCHECK_EQ(layout_strategy, kShowLeftArrowButton);
last_visible_view_index = visible_views_indices.size() - 1; last_visible_view_index = visible_views_indices.size() - 1;
......
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