Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 #import "chrome/browser/ui/cocoa/hyperlink_text_view.h" | 5 #import "chrome/browser/ui/cocoa/hyperlink_text_view.h" |
| 6 | 6 |
| 7 #include "base/mac/scoped_nsobject.h" | 7 #include "base/mac/scoped_nsobject.h" |
| 8 | 8 |
| 9 // The baseline shift for text in the NSTextView. | 9 // The baseline shift for text in the NSTextView. |
| 10 const float kTextBaselineShift = -1.0; | 10 const float kTextBaselineShift = -1.0; |
| (...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 137 NSUnderlineStyleAttributeName : @(NSSingleUnderlineStyle) | 137 NSUnderlineStyleAttributeName : @(NSSingleUnderlineStyle) |
| 138 }; | 138 }; |
| 139 | 139 |
| 140 [[self textStorage] addAttributes:attributes range:range]; | 140 [[self textStorage] addAttributes:attributes range:range]; |
| 141 } | 141 } |
| 142 | 142 |
| 143 - (void)setAcceptsFirstResponder:(BOOL)acceptsFirstResponder { | 143 - (void)setAcceptsFirstResponder:(BOOL)acceptsFirstResponder { |
| 144 acceptsFirstResponder_ = acceptsFirstResponder; | 144 acceptsFirstResponder_ = acceptsFirstResponder; |
| 145 } | 145 } |
| 146 | 146 |
| 147 - (void)setFrameSizeForWidth:(CGFloat)width { | |
|
Scott Hess - ex-Googler
2013/10/31 23:33:38
This is like -sizeToFit, except with a fixed width
groby-ooo-7-16
2013/11/01 00:28:59
Turns out minsize/maxsize don't bother sizeToFit t
| |
| 148 // There's no direct API to compute desired sizes - use layouting instead. | |
| 149 // Layout in a rect with fixed width and "infinite" height. | |
| 150 [self setFrameSize:NSMakeSize(width, CGFLOAT_MAX)]; | |
| 151 | |
| 152 // Use the layout manager to compute size. | |
| 153 NSLayoutManager* layoutManager = [self layoutManager]; | |
| 154 NSTextContainer* textContainer = [self textContainer]; | |
| 155 [layoutManager ensureLayoutForTextContainer:textContainer]; | |
| 156 NSRect newFrame = [layoutManager usedRectForTextContainer:textContainer]; | |
| 157 [self setFrameSize:newFrame.size]; | |
| 158 } | |
| 159 | |
| 160 | |
| 147 @end | 161 @end |
| OLD | NEW |