Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(366)

Side by Side Diff: chrome/browser/ui/views/profiles/new_avatar_button.cc

Issue 371633002: LabelButton: cache the last computed preferred size (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 6 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/ui/views/profiles/new_avatar_button.h" 5 #include "chrome/browser/ui/views/profiles/new_avatar_button.h"
6 6
7 #include "base/strings/utf_string_conversions.h" 7 #include "base/strings/utf_string_conversions.h"
8 #include "base/win/windows_version.h" 8 #include "base/win/windows_version.h"
9 #include "chrome/browser/browser_process.h" 9 #include "chrome/browser/browser_process.h"
10 #include "chrome/browser/profiles/profile_manager.h" 10 #include "chrome/browser/profiles/profile_manager.h"
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after
167 IDR_ICON_PROFILES_AVATAR_BUTTON_ERROR).ToImageSkia(); 167 IDR_ICON_PROFILES_AVATAR_BUTTON_ERROR).ToImageSkia();
168 } 168 }
169 169
170 SetImage(views::Button::STATE_NORMAL, icon); 170 SetImage(views::Button::STATE_NORMAL, icon);
171 UpdateAvatarButtonAndRelayoutParent(); 171 UpdateAvatarButtonAndRelayoutParent();
172 } 172 }
173 173
174 void NewAvatarButton::UpdateAvatarButtonAndRelayoutParent() { 174 void NewAvatarButton::UpdateAvatarButtonAndRelayoutParent() {
175 // We want the button to resize if the new text is shorter. 175 // We want the button to resize if the new text is shorter.
176 SetText(GetButtonText(browser_->profile())); 176 SetText(GetButtonText(browser_->profile()));
177 set_min_size(gfx::Size()); 177 SetMinSize(gfx::Size());
178 InvalidateLayout(); 178 InvalidateLayout();
179 179
180 // Because the width of the button might have changed, the parent browser 180 // Because the width of the button might have changed, the parent browser
181 // frame needs to recalculate the button bounds and redraw it. 181 // frame needs to recalculate the button bounds and redraw it.
182 if (parent()) 182 if (parent())
183 parent()->Layout(); 183 parent()->Layout();
184 } 184 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698