Skip to content

Commit

Permalink
[M110 Merge] Search tab icon displays properly after theme changed
Browse files Browse the repository at this point in the history
(cherry picked from commit 9510c5f)

Bug: 1401293
Change-Id: I840abf6fbc82ef120edc3c6f7e4bc80d3c783d5a
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4111720
Reviewed-by: Peter Kasting <pkasting@chromium.org>
Auto-Submit: jongmok kim <johny.kimc@gmail.com>
Commit-Queue: jongmok kim <johny.kimc@gmail.com>
Cr-Original-Commit-Position: refs/heads/main@{#1087245}
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4153450
Owners-Override: Daniel Yip <danielyip@google.com>
Cr-Commit-Position: refs/branch-heads/5481@{#230}
Cr-Branched-From: 130f3e4-refs/heads/main@{#1084008}
  • Loading branch information
Jongmok Kim authored and Daniel Yip committed Jan 12, 2023
1 parent a505695 commit c38e1c7
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 10 deletions.
7 changes: 5 additions & 2 deletions chrome/browser/ui/views/tabs/new_tab_button.cc
Original file line number Diff line number Diff line change
Expand Up @@ -124,14 +124,17 @@ void NewTabButton::AddedToWidget() {
paint_as_active_subscription_ =
GetWidget()->RegisterPaintAsActiveChangedCallback(base::BindRepeating(
&NewTabButton::FrameColorsChanged, base::Unretained(this)));
// Set the initial state correctly.
FrameColorsChanged();
}

void NewTabButton::RemovedFromWidget() {
paint_as_active_subscription_ = {};
}

void NewTabButton::OnThemeChanged() {
views::ImageButton::OnThemeChanged();
FrameColorsChanged();
}

#if BUILDFLAG(IS_WIN)
void NewTabButton::OnMouseReleased(const ui::MouseEvent& event) {
if (!event.IsOnlyRightMouseButton()) {
Expand Down
1 change: 1 addition & 0 deletions chrome/browser/ui/views/tabs/new_tab_button.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ class NewTabButton : public views::ImageButton,
void OnBoundsChanged(const gfx::Rect& previous_bounds) override;
void AddedToWidget() override;
void RemovedFromWidget() override;
void OnThemeChanged() override;

private:
class HighlightPathGenerator;
Expand Down
2 changes: 0 additions & 2 deletions chrome/browser/ui/views/tabs/tab.cc
Original file line number Diff line number Diff line change
Expand Up @@ -688,8 +688,6 @@ void Tab::AddedToWidget() {
paint_as_active_subscription_ =
GetWidget()->RegisterPaintAsActiveChangedCallback(base::BindRepeating(
&Tab::UpdateForegroundColors, base::Unretained(this)));
// Set the initial state correctly
UpdateForegroundColors();
}

void Tab::RemovedFromWidget() {
Expand Down
11 changes: 7 additions & 4 deletions chrome/browser/ui/views/tabs/tab_strip.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1881,8 +1881,6 @@ void TabStrip::Init() {
// So we only get enter/exit messages when the mouse enters/exits the whole
// tabstrip, even if it is entering/exiting a specific Tab, too.
SetNotifyEnterExitOnChild(true);

UpdateContrastRatioValues();
}

void TabStrip::NewTabButtonPressed(const ui::Event& event) {
Expand Down Expand Up @@ -2023,6 +2021,8 @@ void TabStrip::UpdateContrastRatioValues() {
// The contrast ratio for the separator between inactive tabs.
constexpr float kTabSeparatorContrast = 2.5f;
separator_color_ = get_blend(inactive_fg, kTabSeparatorContrast).color;

SchedulePaint();
}

void TabStrip::ShiftTabRelative(Tab* tab, int offset) {
Expand Down Expand Up @@ -2170,15 +2170,18 @@ void TabStrip::AddedToWidget() {
paint_as_active_subscription_ =
GetWidget()->RegisterPaintAsActiveChangedCallback(base::BindRepeating(
&TabStrip::UpdateContrastRatioValues, base::Unretained(this)));
// Set the initial state correctly.
UpdateContrastRatioValues();
}

void TabStrip::RemovedFromWidget() {
GetWidget()->RemoveObserver(this);
paint_as_active_subscription_ = {};
}

void TabStrip::OnThemeChanged() {
views::View::OnThemeChanged();
UpdateContrastRatioValues();
}

void TabStrip::OnGestureEvent(ui::GestureEvent* event) {
switch (event->type()) {
case ui::ET_GESTURE_LONG_TAP: {
Expand Down
1 change: 1 addition & 0 deletions chrome/browser/ui/views/tabs/tab_strip.h
Original file line number Diff line number Diff line change
Expand Up @@ -395,6 +395,7 @@ class TabStrip : public views::View,
void OnMouseExited(const ui::MouseEvent& event) override;
void AddedToWidget() override;
void RemovedFromWidget() override;
void OnThemeChanged() override;

// ui::EventHandler:
void OnGestureEvent(ui::GestureEvent* event) override;
Expand Down
2 changes: 0 additions & 2 deletions chrome/browser/ui/views/tabs/tab_strip_scroll_container.cc
Original file line number Diff line number Diff line change
Expand Up @@ -313,8 +313,6 @@ void TabStripScrollContainer::AddedToWidget() {
GetWidget()->RegisterPaintAsActiveChangedCallback(
base::BindRepeating(&TabStripScrollContainer::FrameColorsChanged,
base::Unretained(this)));
// Set the initial state correctly.
FrameColorsChanged();
}

void TabStripScrollContainer::RemovedFromWidget() {
Expand Down

0 comments on commit c38e1c7

Please sign in to comment.