Commit d393792a authored by Taylor Bergquist's avatar Taylor Bergquist Committed by Commit Bot

Fix tabs sometimes being min size after exiting fullscreen.

While the tabstrip is not visible, TabStripRegionView has zero width.
If any model change happens while the tabstrip is not visible, the
tabstrip calculates the ideal bounds for tabs based on this
available width. The bug was that the tabstrip was ignoring the first
layout after being restored to visibility because it believed that its
cached layout was still up-to-date.

I.e. this was the timeline:
Layout() at width and available width 1340.
Enter fullscreen. Available width is now -78.
Insert a tab. Ideal bounds are as small as possible to fit -78 width.
Exit fullscreen. Available width is now 1340.
Layout() at width and available width 1340.
Layout() is ignored because there's been no change in width or
available width, when in fact the ideal bounds are stale.

This wasn't happening pre-suspect change because it was calling Layout()
while TabStripRegionView's width was zero (since it called Layout() to
calculate the available width for calculating ideal bounds), so the
first layout after the size was normal again went through.

The fix I went with was to update |last_available_width_| whenever
ideal bounds are calculated. This more correctly reflects the
current calculated layout's dependency on available width.

Bug: 1132832
Change-Id: I5487a99bceb7267cab1e00e2163ba86e2a93b0ee
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2438774
Commit-Queue: Taylor Bergquist <tbergquist@chromium.org>
Reviewed-by: default avatarCharlene Yan <cyan@chromium.org>
Cr-Commit-Position: refs/heads/master@{#812290}
parent 55ad4375
...@@ -3415,6 +3415,11 @@ void TabStrip::UpdateIdealBounds() { ...@@ -3415,6 +3415,11 @@ void TabStrip::UpdateIdealBounds() {
if (tab_count() == 0) if (tab_count() == 0)
return; // Should only happen during creation/destruction, ignore. return; // Should only happen during creation/destruction, ignore.
// Update |last_available_width_| in case there is a different amount of
// available width than there was in the last layout (e.g. if the tabstrip
// is currently hidden).
last_available_width_ = GetAvailableWidthForTabStrip();
if (touch_layout_) { if (touch_layout_) {
const int trailing_x = tabs_.ideal_bounds(tab_count() - 1).right(); const int trailing_x = tabs_.ideal_bounds(tab_count() - 1).right();
tab_controls_container_ideal_bounds_.set_origin( tab_controls_container_ideal_bounds_.set_origin(
......
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