Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 311687

Summary: Link does not wrap without vertical fill
Product: [Eclipse Project] Platform Reporter: Markus Keller <markus.kell.r>
Component: SWTAssignee: Scott Kovatch <skovatch>
Status: RESOLVED FIXED QA Contact: Silenio Quarti <Silenio_Quarti>
Severity: normal    
Priority: P3 CC: eclipse.felipe, harp, skovatch
Version: 3.5Flags: eclipse.felipe: review+
Target Milestone: 3.6 RC1   
Hardware: PC   
OS: Mac OS X   
Whiteboard:
Attachments:
Description Flags
Fix none

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.