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

Unified Diff: ui/base/cocoa/controls/hyperlink_text_view.mm

Issue 1364113003: Only (and always) put URLs in NSLinkAttributeName. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@infobar1
Patch Set: stray deletion Created 5 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
Index: ui/base/cocoa/controls/hyperlink_text_view.mm
diff --git a/ui/base/cocoa/controls/hyperlink_text_view.mm b/ui/base/cocoa/controls/hyperlink_text_view.mm
index 092c096e9934d6a0fb2676de28460c4a2e6dacea..c4936e28f2ad2e1b22758559e7b4b3a6c0ff6f54 100644
--- a/ui/base/cocoa/controls/hyperlink_text_view.mm
+++ b/ui/base/cocoa/controls/hyperlink_text_view.mm
@@ -4,6 +4,7 @@
#import "ui/base/cocoa/controls/hyperlink_text_view.h"
+#include "base/logging.h"
#include "base/mac/scoped_nsobject.h"
#include "ui/base/cocoa/nsview_additions.h"
@@ -122,13 +123,19 @@ const float kTextBaselineShift = -1.0;
}
- (void)addLinkRange:(NSRange)range
- withName:(id)name
+ withURL:(NSString*)url
linkColor:(NSColor*)linkColor {
+ // When the NSLinkAttributeName attribute is used, AppKit makes the link
+ // draggable. If no URL is provided, dropping it on the tab strip will crash
+ // <http://crbug.com/528228>. Require that a URL is used, and that only a URL
+ // is used.
+ DCHECK_GT([url length], 0u);
+ DCHECK([NSURL URLWithString:url]);
NSDictionary* attributes = @{
NSForegroundColorAttributeName : linkColor,
NSUnderlineStyleAttributeName : @(YES),
NSCursorAttributeName : [NSCursor pointingHandCursor],
- NSLinkAttributeName : name,
+ NSLinkAttributeName : url,
NSUnderlineStyleAttributeName : @(NSSingleUnderlineStyle)
};
« no previous file with comments | « ui/base/cocoa/controls/hyperlink_text_view.h ('k') | ui/base/cocoa/controls/hyperlink_text_view_unittest.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698