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

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

Issue 2354323003: Set minimal width for the username in the password bubble on Mac. (Closed)
Patch Set: Created 4 years, 3 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 | « chrome/browser/ui/cocoa/passwords/passwords_bubble_utils.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/ui/cocoa/passwords/passwords_bubble_utils.mm
diff --git a/chrome/browser/ui/cocoa/passwords/passwords_bubble_utils.mm b/chrome/browser/ui/cocoa/passwords/passwords_bubble_utils.mm
index 332d4c7f24a6acd42788e7585293d96c4fad0647..7ccd22a3e9098091bccb217cf90684511766bb53 100644
--- a/chrome/browser/ui/cocoa/passwords/passwords_bubble_utils.mm
+++ b/chrome/browser/ui/cocoa/passwords/passwords_bubble_utils.mm
@@ -73,6 +73,7 @@ void InitLabel(NSTextField* textField, const base::string16& text) {
std::pair<CGFloat, CGFloat> GetResizedColumns(
CGFloat maxWidth,
std::pair<CGFloat, CGFloat> columnsWidth) {
+ DCHECK_GE(maxWidth, kItemLabelSpacing + kMinUsernameSize);
// Free space can be negative.
CGFloat freeSpace =
maxWidth - (columnsWidth.first + columnsWidth.second + kItemLabelSpacing);
@@ -83,9 +84,11 @@ std::pair<CGFloat, CGFloat> GetResizedColumns(
// Make sure that the sizes are nonnegative.
CGFloat firstColumnPercent =
columnsWidth.first / (columnsWidth.first + columnsWidth.second);
+ CGFloat firstColumnSize = std::max(
+ kMinUsernameSize, columnsWidth.first + freeSpace * firstColumnPercent);
return std::make_pair(
- columnsWidth.first + freeSpace * firstColumnPercent,
- columnsWidth.second + freeSpace * (1 - firstColumnPercent));
+ firstColumnSize,
+ maxWidth - kItemLabelSpacing - firstColumnSize);
}
NSSecureTextField* PasswordLabel(const base::string16& text) {
« no previous file with comments | « chrome/browser/ui/cocoa/passwords/passwords_bubble_utils.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698