Skip to content

Commit

Permalink
[Mac] |-sizeToFit| does not handle small-sized HyperlinkButtonCell we…
Browse files Browse the repository at this point in the history
…ll, so pad the width a little.

BUG=53569
TEST=visual


Review URL: http://codereview.chromium.org/8002002

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@103042 0039d316-1c4b-4281-b951-d872f2087c98
  • Loading branch information
rsesek@chromium.org committed Sep 27, 2011
1 parent 2a5221b commit 20f3eff
Showing 1 changed file with 8 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -213,15 +213,18 @@ - (NSButton*)hyperlinkButtonWithFrame:(NSRect)frame
// Cell must be set immediately after construction.
[button setCell:cell.get()];

// Size to fit the button and add a little extra padding for the small-text
// hyperlink button, which sizeToFit gets wrong.
[GTMUILocalizerAndLayoutTweaker sizeToFitView:button];
NSRect buttonFrame = [button frame];
buttonFrame.size.width += 2;

// If the link text is too long, clamp it.
[button sizeToFit];
int maxWidth = NSWidth([[self bubble] frame]) - 2 * NSMinX(referenceFrame);
NSRect buttonFrame = [button frame];
if (NSWidth(buttonFrame) > maxWidth) {
if (NSWidth(buttonFrame) > maxWidth)
buttonFrame.size.width = maxWidth;
[button setFrame:buttonFrame];
}

[button setFrame:buttonFrame];
[button setTarget:self];
[button setAction:@selector(popupLinkClicked:)];
return button;
Expand Down

0 comments on commit 20f3eff

Please sign in to comment.