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

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

Issue 2440913003: Fix issue with broken links in HyperlinkTextView. (Closed)
Patch Set: Add unit test. Created 4 years, 2 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
« no previous file with comments | « no previous file | ui/base/cocoa/controls/hyperlink_text_view_unittest.mm » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 dd5e4504333832bdc9ba90cea4ae475c28c39d9d..86204e99e5772d92027f4a76bbeeaf662ee4d093 100644
--- a/ui/base/cocoa/controls/hyperlink_text_view.mm
+++ b/ui/base/cocoa/controls/hyperlink_text_view.mm
@@ -54,8 +54,12 @@ const float kTextBaselineShift = -1.0;
- (NSRange)selectionRangeForProposedRange:(NSRange)proposedSelRange
granularity:(NSSelectionGranularity)granularity {
- // Do not allow selections.
- return NSMakeRange(0, 0);
+ // Return a range of length 0 to prevent text selection. Note that the start
+ // of the range (the first argument) is treated as the position of the
+ // subsequent click so it must not be 0. If it is, links that begin at a
+ // non-zero position in the text will not function correctly when they are
+ // clicked in such a way as to look like a possible text selection.
+ return NSMakeRange(proposedSelRange.location, 0);
}
// Convince NSTextView to not show an I-Beam cursor when the cursor is over the
« no previous file with comments | « no previous file | ui/base/cocoa/controls/hyperlink_text_view_unittest.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698