Commit 12647726 authored by Thomas Lukaszewicz's avatar Thomas Lukaszewicz Committed by Commit Bot

Tab Search: Fix recursive paint in TabSearchButton

This CL fixes a recursive paint bug in the TabSearchButton. Currently
SetImage() is called within PaintIcon(). This causes a paint
recursion as SetImage() will schedule a paint after it has been set.

This CL moves the SetImage() call into the FrameColorsChanged()
method to fix the issue.

Bug: 1121276
Change-Id: I89e10d17bf69d757112ea8655c79191a7541d18d
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2375933
Commit-Queue: Thomas Lukaszewicz <tluk@chromium.org>
Reviewed-by: default avatarScott Violet <sky@chromium.org>
Cr-Commit-Position: refs/heads/master@{#801533}
parent d30f9aa5
......@@ -37,7 +37,7 @@ class NewTabButton : public views::ImageButton,
// Called when the tab strip transitions to/from single tab mode, the frame
// state changes or the accent color changes. Updates the glyph colors for
// the best contrast on the background.
void FrameColorsChanged();
virtual void FrameColorsChanged();
void AnimateInkDropToStateForTesting(views::InkDropState state);
......
......@@ -41,6 +41,16 @@ TabSearchButton::TabSearchButton(TabStrip* tab_strip,
TabSearchButton::~TabSearchButton() = default;
void TabSearchButton::FrameColorsChanged() {
NewTabButton::FrameColorsChanged();
// Icon color needs to be updated here as this is called when the hosting
// window switches between active and inactive states. In each state the
// foreground color of the tab controls is expected to change.
SetImage(
Button::STATE_NORMAL,
gfx::CreateVectorIcon(kCaretDownIcon, kIconSize, GetForegroundColor()));
}
void TabSearchButton::ButtonPressed(views::Button* sender,
const ui::Event& event) {
if (bubble_)
......@@ -64,11 +74,7 @@ void TabSearchButton::OnWidgetClosing(views::Widget* widget) {
}
void TabSearchButton::PaintIcon(gfx::Canvas* canvas) {
// Icon color needs to be updated here as this is called when the hosting
// window switches between active and incactive states. In each state the
// foreground color of the tab controls is expected to change.
SetImage(
Button::STATE_NORMAL,
gfx::CreateVectorIcon(kCaretDownIcon, kIconSize, GetForegroundColor()));
// Call ImageButton::PaintButtonContents() to paint the TabSearchButton's
// VectorIcon.
views::ImageButton::PaintButtonContents(canvas);
}
......@@ -36,6 +36,9 @@ class TabSearchButton : public NewTabButton,
TabSearchButton& operator=(const TabSearchButton&) = delete;
~TabSearchButton() override;
// NewTabButton:
void FrameColorsChanged() override;
// views::ButtonListener:
void ButtonPressed(views::Button* sender, const ui::Event& event) override;
......
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