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

Unified Diff: chrome/browser/ui/cocoa/website_settings/website_settings_bubble_controller.mm

Issue 2473313005: Page Info (native Mac): truncate permission labels and add tooltip. (Closed)
Patch Set: Created 4 years, 1 month 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 | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/ui/cocoa/website_settings/website_settings_bubble_controller.mm
diff --git a/chrome/browser/ui/cocoa/website_settings/website_settings_bubble_controller.mm b/chrome/browser/ui/cocoa/website_settings/website_settings_bubble_controller.mm
index 085e3733a3be9ff68f7785246f225f33ed2c1a72..7867181ec1a6010aa77f4f41fe0b4a15de732c31 100644
--- a/chrome/browser/ui/cocoa/website_settings/website_settings_bubble_controller.mm
+++ b/chrome/browser/ui/cocoa/website_settings/website_settings_bubble_controller.mm
@@ -85,6 +85,9 @@ const CGFloat kPermissionImageSize = 16;
// Spacing between a permission image and the text.
const CGFloat kPermissionImageSpacing = 6;
+// Minimum distance between the label and its corresponding menu.
+const CGFloat kMinSeparationBetweenLabelAndMenu = 16;
+
// Square size of the permission delete button image.
const CGFloat kPermissionDeleteImageSize = 16;
@@ -862,6 +865,7 @@ bool IsInternalURL(const GURL& url) {
toView:view
atPoint:position];
}
+ [label setToolTip:base::SysUTF16ToNSString(labelText)];
[view setFrameSize:NSMakeSize(viewWidth, NSHeight([view frame]))];
@@ -879,6 +883,28 @@ bool IsInternalURL(const GURL& url) {
position.y -= titleRect.origin.y;
[button setFrameOrigin:position];
+ // Truncate the label if it's too wide.
+ // This is a workaround for https://crbug.com/654268 until MacViews ships.
+ NSRect labelFrame = [label frame];
+ if (isRTL) {
+ CGFloat maxLabelWidth = NSMaxX(labelFrame) - NSMaxX([button frame]) -
+ kMinSeparationBetweenLabelAndMenu;
+ if (NSWidth(labelFrame) > maxLabelWidth) {
+ labelFrame.origin.x = NSMaxX(labelFrame) - maxLabelWidth;
+ labelFrame.size.width = maxLabelWidth;
+ [label setFrame:labelFrame];
+ [[label cell] setLineBreakMode:NSLineBreakByTruncatingTail];
+ }
+ } else {
+ CGFloat maxLabelWidth = NSMinX([button frame]) - NSMinX(labelFrame) -
+ kMinSeparationBetweenLabelAndMenu;
+ if (NSWidth(labelFrame) > maxLabelWidth) {
+ labelFrame.size.width = maxLabelWidth;
+ [label setFrame:labelFrame];
+ [[label cell] setLineBreakMode:NSLineBreakByTruncatingTail];
+ }
+ }
+
// Align the icon with the text.
[self alignPermissionIcon:imageView withTextField:label];
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698