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

Unified Diff: chrome/browser/ui/cocoa/passwords/account_chooser_view_controller.mm

Issue 2259533006: Tune the account chooser on Mac. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: comment Created 4 years, 4 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | chrome/browser/ui/cocoa/passwords/credential_item_button.mm » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/ui/cocoa/passwords/account_chooser_view_controller.mm
diff --git a/chrome/browser/ui/cocoa/passwords/account_chooser_view_controller.mm b/chrome/browser/ui/cocoa/passwords/account_chooser_view_controller.mm
index f1be28c9186b704a336e1754bc61b046987c976e..084806d705edb02499ff071562d7d53dca15f010 100644
--- a/chrome/browser/ui/cocoa/passwords/account_chooser_view_controller.mm
+++ b/chrome/browser/ui/cocoa/passwords/account_chooser_view_controller.mm
@@ -27,7 +27,8 @@
namespace {
-// Returns height of one credential item.
+// Standard height of one credential item. It can be bigger though in case the
+// text needs more vertical space than the avatar.
constexpr CGFloat kCredentialHeight =
kAvatarImageSize + 2 * kVerticalAvatarMargin;
@@ -124,28 +125,30 @@ constexpr CGFloat kMaxHeightAccounts = 3.5;
curX - NSWidth([cancelButton_ frame]),
kFramePadding)];
- NSSize buttonsSize = NSMakeSize(
- kDesiredBubbleWidth,
- std::min<CGFloat>([credentialButtons_ count], kMaxHeightAccounts) *
- kCredentialHeight);
base::scoped_nsobject<NSScrollView> scrollView([[NSScrollView alloc]
- initWithFrame:NSMakeRect(0, 0, buttonsSize.width, buttonsSize.height)]);
+ initWithFrame:NSMakeRect(0, 0, kDesiredBubbleWidth, kCredentialHeight)]);
[scrollView
setHasVerticalScroller:[credentialButtons_ count] > kMaxHeightAccounts
? YES
: NO];
[scrollView setBorderType:NSNoBorder];
- CGFloat buttonWidth = [scrollView contentSize].width;
+ const CGFloat buttonWidth = [scrollView contentSize].width;
CGFloat curY = 0;
base::scoped_nsobject<NSView> documentView([[NSView alloc]
- initWithFrame:NSMakeRect(0, 0, buttonWidth, [credentialButtons_ count] *
- kCredentialHeight)]);
+ initWithFrame:NSZeroRect]);
for (CredentialItemButton* button in credentialButtons_.get()) {
[documentView addSubview:button];
- [button setFrame:NSMakeRect(0, curY, buttonWidth, kCredentialHeight)];
+ CGFloat cellHeight = [[button cell] cellSize].height;
+ [button setFrame:NSMakeRect(0, curY, buttonWidth,
+ cellHeight + 2 * kVerticalAvatarMargin)];
curY = NSMaxY([button frame]);
}
+ [documentView setFrameSize:NSMakeSize(buttonWidth, curY)];
[scrollView setDocumentView:documentView];
+ [scrollView setFrameSize:NSMakeSize(
+ kDesiredBubbleWidth,
+ [scrollView hasVerticalScroller] ? kMaxHeightAccounts * kCredentialHeight
+ : curY)];
[view addSubview:scrollView];
[documentView scrollRectToVisible:NSMakeRect(0, curY, buttonWidth, 0)];
curY = NSMaxY([cancelButton_ frame]) + 3 * kRelatedControlVerticalSpacing;
@@ -189,11 +192,10 @@ constexpr CGFloat kMaxHeightAccounts = 3.5;
- (void)loadCredentialItems {
base::scoped_nsobject<NSMutableArray> items([[NSMutableArray alloc] init]);
PasswordDialogController* controller = self.bridge->GetDialogController();
- NSRect rect = NSMakeRect(0, 0, kDesiredBubbleWidth, kCredentialHeight);
for (const auto& form : controller->GetLocalForms()) {
base::scoped_nsobject<CredentialItemButton> item(
[[CredentialItemButton alloc]
- initWithFrame:rect
+ initWithFrame:NSZeroRect
backgroundColor:[NSColor textBackgroundColor]
hoverColor:skia::SkColorToSRGBNSColor(kButtonHoverColor)]);
[item setPasswordForm:form.get()];
« no previous file with comments | « no previous file | chrome/browser/ui/cocoa/passwords/credential_item_button.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698