DESCRIPTION

Bug 518329: [Forms] SizeCache does not compute minimum width correctly

When calling computeSize to compute the minimum width, SizeCache now
provides the control with a very small width hint instead of
SWT.DEFAULT. I've also added unit tests surrounding this.

Testing Done:
- Ran the ExpandableComposite and SizeCache tests. The new tests failed
before applying this fix, but passed after it was applied
- Manual verification surrounding UI that uses Forms such as the Cheat
Sheets view. They all wrap text correctly now.

Change-Id: I0dad3b8e393933a35aed7c9ad7ccbc9e8127794e
Signed-off-by: Naomi Barrera xxx@xxx.xxx

COMMENTS

author: Naomi Barrera
date: 2017-06-15 20:09:49.000000000

Uploaded patch set 1.

-------------------------------------
author: Brenden Conley
date: 2017-06-15 20:09:54.000000000

Patch Set 1:

Build Started https://hudson.eclipse.org/platform/job/eclipse.platform.ui-Gerrit/12930/

-------------------------------------
author: Brenden Conley
date: 2017-06-15 20:36:13.000000000

Patch Set 1: Verified+1

Build Successful 

https://hudson.eclipse.org/platform/job/eclipse.platform.ui-Gerrit/12930/ : SUCCESS

-------------------------------------
author: Sebastian Porter
date: 2017-06-16 13:56:28.000000000

Patch Set 1:

(1 comment)

Line:426, bundles/org.eclipse.ui.forms/src/org/eclipse/ui/forms/widgets/SizeCache.java -> Why 5? Why not 4 or 6? Please don't answer that 5 was used before.

-------------------------------------
author: Naomi Barrera
date: 2017-06-16 15:36:18.000000000

Patch Set 1:

(1 comment)

Line:426, bundles/org.eclipse.ui.forms/src/org/eclipse/ui/forms/widgets/SizeCache.java -> Honestly, most if not all controls will simply return the width hint here. The main issue with the code as it is now is that "computeMinimumWidth" and "computeMaximumWidth" are identical in behaviour - both return the result obtained by calling control.computeSize(SWT.DEFAULT, SWT.DEFAULT) if no cached value is available. Things like TableWrapLayout expect that the two can result in different widths which is not possible at the moment.

My original intent was to restore previous behaviour for wrapped controls and the previous behaviour was to pass a width hint of 5 pixels. If there's a better way of doing this then I'm open to suggestions.

-------------------------------------
author: Naomi Barrera
date: 2017-09-08 13:25:23.000000000

Patch Set 1:

Is this fix acceptable or should it be abandoned? I'm not completely sold on the solution, but this is a regression that's affecting cheat sheets.

-------------------------------------
author: Sebastian Porter
date: 2017-09-15 14:51:41.000000000

Patch Set 1: Code-Review-1

(1 comment)

Line:426, bundles/org.eclipse.ui.forms/src/org/eclipse/ui/forms/widgets/SizeCache.java -> It was not 5 pixels. It was
FormUtil.getWidthHint(5, control)

Also, there's a commit comment that says the change to DEFAULT depends on some other change. So, rather -1 for this.

-------------------------------------
author: Naomi Barrera
date: 2017-09-15 15:46:09.000000000

Patch Set 1:

(1 comment)

Line:426, bundles/org.eclipse.ui.forms/src/org/eclipse/ui/forms/widgets/SizeCache.java -> If I'm not mistaken, the definition of FormUtil.getWidthHint() before it was removed was:

public static int getWidthHint(int wHint, Control c) {
    boolean wrap = isWrapControl(c);
    return wrap ? wHint : SWT.DEFAULT;
}

So, for wrapped controls it was 5 pixels. The bug I refer to in the Bugzilla contains a commit that says its intent was to assume all controls were wrapped, but replaced the width hint with SWT.DEFAULT which seems to conflict (I could be missing something here of course). I'm not sure which commit comment you're referring to in your second point, but there are several different commits for that particular bug.

If this change were to be abandoned, what would you suggest to try as an alternative? I'd like to have the Cheat Sheets wrapping issues resolved. It would be possible to have Cheat Sheets instead use only form controls rather than also using standard widgets such as Text (I've tried this myself and wrapping works as expected), but that doesn't really fix the underlying issue.

-------------------------------------
