Commit ef0a921f authored by Connie Wan's avatar Connie Wan Committed by Commit Bot

Ensure TabGroupUnderline bounds are always non-zero

See inline comments for why this is needed and when it happens.

I don't have a good test repro for this, since I'd need to manually trigger a paint cycle to get the underline to appear anyway. I was, however, able to reproduce the issue in the bug and verify that it is fixed.

Bug: 1014913
Change-Id: I0b70be1b0d83370714a004b96a437ca589c34bf1
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1874448Reviewed-by: default avatarTaylor Bergquist <tbergquist@chromium.org>
Reviewed-by: default avatarCharlene Yan <cyan@chromium.org>
Commit-Queue: Connie Wan <connily@chromium.org>
Cr-Commit-Position: refs/heads/master@{#709687}
parent 2d60d44e
...@@ -22,7 +22,11 @@ constexpr int TabGroupUnderline::kStrokeThickness; ...@@ -22,7 +22,11 @@ constexpr int TabGroupUnderline::kStrokeThickness;
TabGroupUnderline::TabGroupUnderline(TabStrip* tab_strip, TabGroupId group) TabGroupUnderline::TabGroupUnderline(TabStrip* tab_strip, TabGroupId group)
: tab_strip_(tab_strip), group_(group) { : tab_strip_(tab_strip), group_(group) {
UpdateBounds(); // Set non-zero bounds to start with, so that painting isn't pruned.
// Needed because UpdateBounds() happens during OnPaint(), which is called
// after painting is pruned.
const int y = tab_strip_->bounds().height() - 1;
SetBounds(0, y - kStrokeThickness, kStrokeThickness * 2, kStrokeThickness);
} }
void TabGroupUnderline::OnPaint(gfx::Canvas* canvas) { void TabGroupUnderline::OnPaint(gfx::Canvas* canvas) {
...@@ -40,6 +44,12 @@ void TabGroupUnderline::UpdateBounds() { ...@@ -40,6 +44,12 @@ void TabGroupUnderline::UpdateBounds() {
const int start_x = GetStart(); const int start_x = GetStart();
const int end_x = GetEnd(); const int end_x = GetEnd();
// The width may be zero if the group underline and header are initialized at
// the same time, as with tab restore. In this case, don't update the bounds
// and defer to the next paint cycle.
if (end_x <= start_x)
return;
const int start_y = tab_strip_->bounds().height() - 1; const int start_y = tab_strip_->bounds().height() - 1;
SetBounds(start_x, start_y - kStrokeThickness, end_x - start_x, SetBounds(start_x, start_y - kStrokeThickness, end_x - start_x,
......
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