| 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 #include "chrome/browser/ui/cocoa/nsview_additions.h" | 8 #include "chrome/browser/ui/cocoa/nsview_additions.h" |
| 9 | 9 |
| 10 // The baseline shift for text in the NSTextView. | 10 // The baseline shift for text in the NSTextView. |
| (...skipping 17 matching lines...) Expand all Loading... |
| 28 return self; | 28 return self; |
| 29 } | 29 } |
| 30 | 30 |
| 31 - (id)initWithFrame:(NSRect)frameRect { | 31 - (id)initWithFrame:(NSRect)frameRect { |
| 32 if ((self = [super initWithFrame:frameRect])) | 32 if ((self = [super initWithFrame:frameRect])) |
| 33 [self configureTextView]; | 33 [self configureTextView]; |
| 34 return self; | 34 return self; |
| 35 } | 35 } |
| 36 | 36 |
| 37 - (BOOL)acceptsFirstResponder { | 37 - (BOOL)acceptsFirstResponder { |
| 38 return acceptsFirstResponder_; | 38 return !refusesFirstResponder_; |
| 39 } | 39 } |
| 40 | 40 |
| 41 - (void)drawViewBackgroundInRect:(NSRect)rect { | 41 - (void)drawViewBackgroundInRect:(NSRect)rect { |
| 42 if (drawsBackgroundUsingSuperview_) | 42 if (drawsBackgroundUsingSuperview_) |
| 43 [self cr_drawUsingAncestor:[self superview] inRect:rect]; | 43 [self cr_drawUsingAncestor:[self superview] inRect:rect]; |
| 44 else | 44 else |
| 45 [super drawViewBackgroundInRect:rect]; | 45 [super drawViewBackgroundInRect:rect]; |
| 46 } | 46 } |
| 47 | 47 |
| 48 // Never draw the insertion point (otherwise, it shows up without any user | 48 // Never draw the insertion point (otherwise, it shows up without any user |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 85 [self setDrawsBackground:NO]; | 85 [self setDrawsBackground:NO]; |
| 86 [self setHorizontallyResizable:NO]; | 86 [self setHorizontallyResizable:NO]; |
| 87 [self setVerticallyResizable:NO]; | 87 [self setVerticallyResizable:NO]; |
| 88 | 88 |
| 89 // When text is rendered, linkTextAttributes override anything set via | 89 // When text is rendered, linkTextAttributes override anything set via |
| 90 // addAttributes for text that has NSLinkAttributeName. Set to nil to allow | 90 // addAttributes for text that has NSLinkAttributeName. Set to nil to allow |
| 91 // custom attributes to take precedence. | 91 // custom attributes to take precedence. |
| 92 [self setLinkTextAttributes:nil]; | 92 [self setLinkTextAttributes:nil]; |
| 93 [self setDisplaysLinkToolTips:NO]; | 93 [self setDisplaysLinkToolTips:NO]; |
| 94 | 94 |
| 95 acceptsFirstResponder_ = YES; | 95 refusesFirstResponder_ = NO; |
| 96 drawsBackgroundUsingSuperview_ = NO; | 96 drawsBackgroundUsingSuperview_ = NO; |
| 97 } | 97 } |
| 98 | 98 |
| 99 - (void)fixupCursor { | 99 - (void)fixupCursor { |
| 100 if ([[NSCursor currentCursor] isEqual:[NSCursor IBeamCursor]]) | 100 if ([[NSCursor currentCursor] isEqual:[NSCursor IBeamCursor]]) |
| 101 [[NSCursor arrowCursor] set]; | 101 [[NSCursor arrowCursor] set]; |
| 102 } | 102 } |
| 103 | 103 |
| 104 - (void)setMessageAndLink:(NSString*)message | 104 - (void)setMessageAndLink:(NSString*)message |
| 105 withLink:(NSString*)link | 105 withLink:(NSString*)link |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 144 NSForegroundColorAttributeName : linkColor, | 144 NSForegroundColorAttributeName : linkColor, |
| 145 NSUnderlineStyleAttributeName : @(YES), | 145 NSUnderlineStyleAttributeName : @(YES), |
| 146 NSCursorAttributeName : [NSCursor pointingHandCursor], | 146 NSCursorAttributeName : [NSCursor pointingHandCursor], |
| 147 NSLinkAttributeName : name, | 147 NSLinkAttributeName : name, |
| 148 NSUnderlineStyleAttributeName : @(NSSingleUnderlineStyle) | 148 NSUnderlineStyleAttributeName : @(NSSingleUnderlineStyle) |
| 149 }; | 149 }; |
| 150 | 150 |
| 151 [[self textStorage] addAttributes:attributes range:range]; | 151 [[self textStorage] addAttributes:attributes range:range]; |
| 152 } | 152 } |
| 153 | 153 |
| 154 - (void)setAcceptsFirstResponder:(BOOL)acceptsFirstResponder { | 154 - (void)setRefusesFirstResponder:(BOOL)refusesFirstResponder { |
| 155 acceptsFirstResponder_ = acceptsFirstResponder; | 155 refusesFirstResponder_ = refusesFirstResponder; |
| 156 } | 156 } |
| 157 | 157 |
| 158 @end | 158 @end |
| OLD | NEW |