Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 311687 - Link does not wrap without vertical fill
Summary: Link does not wrap without vertical fill
Status: RESOLVED FIXED
Alias: None
Product: Platform
Classification: Eclipse Project
Component: SWT (show other bugs)
Version: 3.5   Edit
Hardware: PC Mac OS X
: P3 normal (vote)
Target Milestone: 3.6 RC1   Edit
Assignee: Scott Kovatch CLA
QA Contact: Silenio Quarti CLA
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-05-05 05:49 EDT by Markus Keller CLA
Modified: 2010-09-29 03:49 EDT (History)
3 users (show)

See Also:
eclipse.felipe: review+


Attachments
Fix (4.24 KB, patch)
2010-05-06 00:27 EDT, Scott Kovatch CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Markus Keller CLA 2010-05-05 05:49:57 EDT
3.5 and I20100504-0800

The link widget does not properly wrap on Cocoa. If you open the ControlExample, select Size > Preferred, Horizontal Fill, and then make the window narrow, the Link wraps on WinXP and GTK, but doesn't wrap on Cocoa.

When Vertical Fill is also checked, it also works properly on Cocoa.

This bug can also be seen in the SDK in "Preferences > Java > Editor" and "Preferences > Java > Editor > Syntax Coloring" (links on top don't wrap).
Comment 1 Scott Kovatch CLA 2010-05-05 20:55:33 EDT
Link.computeSize has a TODO in it that basically says it isn't implemented. This is pretty safe to add for 3.6.
Comment 2 Scott Kovatch CLA 2010-05-06 00:27:59 EDT
Created attachment 167260 [details]
Fix

Implemented computeSize using code from the multiline Text case. Also cleaned up creation of the widget so that the BORDER and non-BORDER case has a consistent gap around it, and matches Carbon.
Comment 3 Scott Kovatch CLA 2010-05-06 00:28:44 EDT
Felipe, can you review?
Comment 4 Felipe Heidrich CLA 2010-05-06 11:09:56 EDT
Good to go,

two (small) things I might have done differently:
1) Why setting the line fragment padding to zero when no border ?
we don't do that for any other widget
causes the different in the size of no border/border to be greater.

2) Link#computeSize() started with 
	if (wHint != SWT.DEFAULT && wHint < 0) wHint = 0;
	if (hHint != SWT.DEFAULT && hHint < 0) hHint = 0;

This code is correct IMO and was removed by the patch.
Comment 5 Scott Kovatch CLA 2010-05-06 14:31:05 EDT
(In reply to comment #4)
> Good to go,
> 
> two (small) things I might have done differently:
> 1) Why setting the line fragment padding to zero when no border ?
> we don't do that for any other widget
> causes the different in the size of no border/border to be greater.

This is done primarily for compatibility/fidelity with Carbon. A Link is implemented with an NSTextView, but shouldn't look any different than a Label. That was fixed in bug 276115.

Turns out this was slightly wrong anyway. I should set the padding to 2 all the time and then adjust the height and width returned in computeSize if there isn't a border. This way the size of the widget is the same whether or not there's a border, and it has the same appearance as a Label.

> 2) Link#computeSize() started with 
>     if (wHint != SWT.DEFAULT && wHint < 0) wHint = 0;
>     if (hHint != SWT.DEFAULT && hHint < 0) hHint = 0;
> 
> This code is correct IMO and was removed by the patch.

I had taken this out because the WRAP case from Text didn't have it, but now that I understand what it's doing, yes, it should go back.
Comment 6 Scott Kovatch CLA 2010-05-06 14:35:29 EDT
Fixed > 20100506.