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

Bug 377607

Summary: Layout issue with Link
Product: [RT] RAP Reporter: Gunnar Wagenknecht <gunnar>
Component: RWTAssignee: Project Inbox <rap-inbox>
Status: RESOLVED WORKSFORME QA Contact:
Severity: normal    
Priority: P3    
Version: 1.5   
Target Milestone: ---   
Hardware: All   
OS: All   
Whiteboard:
Attachments:
Description Flags
screenshot
none
screenshot #2
none
generated HTML of simple snippet (without the issue)
none
generated HTML of original code (with the issue) none

Description Gunnar Wagenknecht CLA 2012-04-25 05:12:56 EDT
Created attachment 214515 [details]
screenshot

Please have a look at the attached screenshot. The Link element is rendered lower than its preceding Label although it uses similar GridData. This does not format nicely when used in the same GridLayout with elements on the left and above.

Note, the inner "div" of the Link has an offset of "2px" set (top/left/right). I wonder where that comes from. IMHO it shouldn't be there.

See bug 377605 for the code.
Comment 1 Gunnar Wagenknecht CLA 2012-04-25 05:13:44 EDT
Browser: Chrome 18.0 on Windows 7
Comment 2 Gunnar Wagenknecht CLA 2012-04-25 05:16:11 EDT
Created attachment 214516 [details]
screenshot #2

The issue is actually worse if a control is used below the Grid. That cuts off the link in half.
Comment 3 Ralf Sternberg CLA 2012-04-25 05:34:15 EDT
I agree that the padding should not break the vertical alignment between Label and Link. Apart from that, the second screenshot looks like a bug indeed.
Comment 4 Ivan Furnadjiev CLA 2012-04-25 05:55:10 EDT
The 2px padding is hard codded in the Link.java (see Link#PADDING). Probably we have to make this padding themable too. But... I don't think that this padding is the problem as it is respected in the Link#computeSize method. Could you provide a snippet to reproduce the cut-off issue?
Comment 5 Gunnar Wagenknecht CLA 2012-04-25 07:32:15 EDT
This is insane. I can't produce a simple snippet that reproduces the issues. I did one producing the same widgets but it doesn't cut-off. I'll attach the HTML and continue looking for the diff. If you compare the generated HTML you'll see that computed sizes are different. The problematic one calculates a "div" height of 4px (which is wrong).
Comment 6 Gunnar Wagenknecht CLA 2012-04-25 07:33:11 EDT
Created attachment 214520 [details]
generated HTML of simple snippet (without the issue)
Comment 7 Gunnar Wagenknecht CLA 2012-04-25 07:33:42 EDT
Created attachment 214521 [details]
generated HTML of original code (with the issue)
Comment 8 Gunnar Wagenknecht CLA 2012-04-25 08:02:28 EDT
So I think I found the issue. It's related to when the text is actually set to the Link.

This one is OK:
- New Link
- setText
- some-parent.layout(true, true);

This is not OK:
- New Link
- some-parent.layout(true, true);
- setText

Is this expected behavior? When working with SWT I'm used to simply call #setText and the layout is invalidated when needed.
Comment 9 Ivan Furnadjiev CLA 2012-04-25 09:07:44 EDT
Gunnar, I'm really curious about the difference with SWT. Could you provide a snippet? I want to test it in both RAP and SWT.
Comment 10 Gunnar Wagenknecht CLA 2012-04-26 03:02:54 EDT
Hmm. As of this morning I'm unable to reproduce it. The simple snippet always worked. I added a workaround (manual call to #layout after setting text) yesterday. Today I removed the workaround and it still works. That is weird. 

Closing as WORKSFORME. Sorry.