Commit c323bda1 authored by Peter Kasting's avatar Peter Kasting Committed by Commit Bot

Reland r786979, part 3: switch ToolbarAccountIconContainer.

The original CL was landed in one piece and reverted due to apparent
perf regressions.  Reland in sections to try and determine more
precisely whether there is any perf impact.

This CL switches ToolbarAccountIconContainer away from ButtonObserver
and over to callbacks.

If this causes perf regressions, something about the actual callback
dispatch is weird.

Bug: none
Change-Id: I7c8ef2dd4cb89330c95677e3e0d88add77776dec
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2347327
Commit-Queue: Peter Kasting <pkasting@chromium.org>
Reviewed-by: default avatarAllen Bauer <kylixrd@chromium.org>
Cr-Commit-Position: refs/heads/master@{#796627}
parent 14bd4f1a
...@@ -6,7 +6,6 @@ ...@@ -6,7 +6,6 @@
#include <memory> #include <memory>
#include "base/bind_helpers.h"
#include "base/stl_util.h" #include "base/stl_util.h"
#include "chrome/browser/themes/theme_properties.h" #include "chrome/browser/themes/theme_properties.h"
#include "chrome/browser/ui/layout_constants.h" #include "chrome/browser/ui/layout_constants.h"
...@@ -101,10 +100,12 @@ void ToolbarIconContainerView::ObserveButton(views::Button* button) { ...@@ -101,10 +100,12 @@ void ToolbarIconContainerView::ObserveButton(views::Button* button) {
// We don't care about the main button being highlighted. // We don't care about the main button being highlighted.
if (button != main_button_) { if (button != main_button_) {
subscriptions_.push_back( subscriptions_.push_back(
button->AddHighlightedChangedCallback(base::DoNothing())); button->AddHighlightedChangedCallback(base::BindRepeating(
&ToolbarIconContainerView::OnButtonHighlightedChanged,
base::Unretained(this), base::Unretained(button))));
} }
subscriptions_.push_back(button->AddStateChangedCallback(base::DoNothing())); subscriptions_.push_back(button->AddStateChangedCallback(base::BindRepeating(
button->AddButtonObserver(this); &ToolbarIconContainerView::UpdateHighlight, base::Unretained(this))));
button->AddObserver(this); button->AddObserver(this);
} }
...@@ -132,22 +133,6 @@ bool ToolbarIconContainerView::IsHighlighted() { ...@@ -132,22 +133,6 @@ bool ToolbarIconContainerView::IsHighlighted() {
return ShouldDisplayHighlight(); return ShouldDisplayHighlight();
} }
void ToolbarIconContainerView::OnHighlightChanged(
views::Button* observed_button,
bool highlighted) {
// We don't care about the main button being highlighted.
if (observed_button == main_button_)
return;
OnButtonHighlightedChanged(observed_button);
}
void ToolbarIconContainerView::OnStateChanged(
views::Button* observed_button,
views::Button::ButtonState old_state) {
UpdateHighlight();
}
void ToolbarIconContainerView::OnViewFocused(views::View* observed_view) { void ToolbarIconContainerView::OnViewFocused(views::View* observed_view) {
UpdateHighlight(); UpdateHighlight();
} }
......
...@@ -10,7 +10,6 @@ ...@@ -10,7 +10,6 @@
#include "base/observer_list.h" #include "base/observer_list.h"
#include "ui/gfx/animation/animation_delegate.h" #include "ui/gfx/animation/animation_delegate.h"
#include "ui/views/controls/button/button.h" #include "ui/views/controls/button/button.h"
#include "ui/views/controls/button/button_observer.h"
#include "ui/views/layout/animating_layout_manager.h" #include "ui/views/layout/animating_layout_manager.h"
#include "ui/views/layout/flex_layout.h" #include "ui/views/layout/flex_layout.h"
#include "ui/views/view.h" #include "ui/views/view.h"
...@@ -18,7 +17,6 @@ ...@@ -18,7 +17,6 @@
// A general view container for any type of toolbar icons. // A general view container for any type of toolbar icons.
class ToolbarIconContainerView : public views::View, class ToolbarIconContainerView : public views::View,
public gfx::AnimationDelegate, public gfx::AnimationDelegate,
public views::ButtonObserver,
public views::ViewObserver { public views::ViewObserver {
public: public:
class Observer : public base::CheckedObserver { class Observer : public base::CheckedObserver {
...@@ -49,12 +47,6 @@ class ToolbarIconContainerView : public views::View, ...@@ -49,12 +47,6 @@ class ToolbarIconContainerView : public views::View,
bool IsHighlighted(); bool IsHighlighted();
// views::ButtonObserver:
void OnHighlightChanged(views::Button* observed_button,
bool highlighted) override;
void OnStateChanged(views::Button* observed_button,
views::Button::ButtonState old_state) override;
// views::ViewObserver: // views::ViewObserver:
void OnViewFocused(views::View* observed_view) override; void OnViewFocused(views::View* observed_view) override;
void OnViewBlurred(views::View* observed_view) override; void OnViewBlurred(views::View* observed_view) 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