DESCRIPTION

Bug 482024 - ExpandableComposite layout issues DO NOT SUBMIT

Bug 368861 - ExpandableComposite failed to compute right wrapped client
size 

- removed all special cases in regards to guessing about wrapping on
client controls and let control calculate its own size based on hints
- refactored code that same calculations are used when calculating size
and doing layout, otherwise its duplicated in two spots leading to some
nasty issues
- better heuristics when calculating proportions of text client and text
label controls
- fixed bug in SizeCache where it won't let control calculate size with
given hint because it calculates wrong minimumWidth. Removed lots of
special cases in SizeCache leaving so it actually cache the size rather
then guess it. Added lots of tests for it

testing done:
- run existing junits and wrote bunch more, 
- current code coverage for ExpandableComposite is 72%
- manual tested bunch of flag combinations
- test running eclipse sdk and using PDE editors that use forms heavily 
(plugin manifest and target definition editor) seems to be ok 
(linux ubuntu and windows 8)

[do not submit, I have not fixed issues raised in the review]

Change-Id: I8fdeb70d39d3c762a297f476356257ee91ae666d
Signed-off-by: Ishaan Salas xxx@xxx.xxx

COMMENTS

author: Brenden Conley
date: 2016-01-28 01:13:43.000000000

Patch Set 20:

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

-------------------------------------
author: Brenden Conley
date: 2016-01-28 01:38:09.000000000

Patch Set 20: Verified+1

Build Successful 

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

-------------------------------------
author: Kelly Potter
date: 2016-01-28 03:24:47.000000000

Patch Set 20:

(19 comments)

> Main problem with SizeCache it will return hints more less
> verbatim if both are set, which is not the same as control returns. 

This is intentional. SizeCache lets the caller ask the question "If I were to make you x pixels wide, how tall would you want to be?" Since x is given, it is required to return non-default widths verbatim.

> Control can return minimum or maximum in one of the axes,
> instead of hint. Should I change it to cache it too instead
> of guessing?

Do you know which controls do this? It sounds like a bug. We have ILayoutExtension for computing minimum sizes. Overloading computeSize for this purpose will just make callers do the wrong thing.

For example, if you put a wrapping control with this behavior inside a GridLayout and then compressed the layout so that its width was smaller than the minimum or larger than the maximum, the height of that control would be computed incorrectly and it would either be truncated vertically or left with a bunch of unused whitespace.

Line:453, tests/org.eclipse.ui.tests.forms/forms/org/eclipse/ui/tests/forms/widgets/ExpandableCompositeTest.java -> Wrapping read-only labels are generally set to FILL, FILL alignment. Was this intentional or a bug?

Line:461, tests/org.eclipse.ui.tests.forms/forms/org/eclipse/ui/tests/forms/widgets/ExpandableCompositeTest.java -> Non-wrapping labels are generally set to SWT.FILL, SWT.CENTER alignment. Was this intentional or a bug?

Line:158, bundles/org.eclipse.ui.forms/src/org/eclipse/ui/forms/widgets/Hyperlink.java -> Simpler: innerWidth = Math.max(0, wHint - marginWidth * 2)

Line:163, bundles/org.eclipse.ui.forms/src/org/eclipse/ui/forms/widgets/Hyperlink.java -> Shouldn't this be marginHeight, not marginWidth?

Simpler: innerHeight = Math.max(0, hHint - marginHeight * 2);

Line:170, bundles/org.eclipse.ui.forms/src/org/eclipse/ui/forms/widgets/Hyperlink.java -> Nicely spotted. I wonder if the incorrect use of adjustments in SizeCache was a workaround for this bug. Seems likely.

Line:203, tests/org.eclipse.ui.tests.forms/forms/org/eclipse/ui/tests/forms/widgets/SizeCacheTest.java -> Wrapping read-only labels are generally set to FILL, FILL alignment. Was FILL, BEGIN intentional or a bug?

Line:211, tests/org.eclipse.ui.tests.forms/forms/org/eclipse/ui/tests/forms/widgets/SizeCacheTest.java -> Non-wrapping labels are generally set to align(SWT.FILL, SWT.CENTER) alignment. Was BEGIN, BEGIN intentional or a bug?

Line:45, bundles/org.eclipse.ui.forms/src/org/eclipse/ui/forms/widgets/SizeCache.java -> If you want to do things this way, you don't need both cachedWidthQuery and cachedWidth since cachedWidth.y = cachedWidthQuery and cachedHeightQuery = cachedHeight.x.

You might save a small amount of memory, though, by keeping the old variables and inlining the x,y coordinates of "cachedWidth" and "cachedHeight" and storing them in the old scaEmma Oneill.

Line:147, bundles/org.eclipse.ui.forms/src/org/eclipse/ui/forms/widgets/SizeCache.java -> null out cachedWidth and cachedHeight.

Line:186, bundles/org.eclipse.ui.forms/src/org/eclipse/ui/forms/widgets/SizeCache.java -> Return new Point(widthHint, heightHint);

Don't add the widthAdjustment and heightAdjustment to the return value. They are used to cancel out delta which most controls add to the hints they receive in computeSize. If you're not invoking computeSize on a control, you shouldn't be using the adjustments.

SizeCache is supposed to return non-DEFAULT hints verbatim -- it's not meant to return the same thing the control would have returned. When invoking computeSize(x, SWT.DEFAULT) on a control, you're asking "If I were to make you x pixels wide, how wall would you like to be". The returned width needs to be x by definition.

Line:200, bundles/org.eclipse.ui.forms/src/org/eclipse/ui/forms/widgets/SizeCache.java -> change to "result.x = widthHint"

widthAdjustment is for hints passed to computeSize, not the return value.

Line:204, bundles/org.eclipse.ui.forms/src/org/eclipse/ui/forms/widgets/SizeCache.java -> change to "result.y = heightHint"

heightAdjustment is for hints passed to computeSize, not the return value.

Line:215, bundles/org.eclipse.ui.forms/src/org/eclipse/ui/forms/widgets/SizeCache.java -> change to:

if (widthHint == preferredSize.x) {

Line:221, bundles/org.eclipse.ui.forms/src/org/eclipse/ui/forms/widgets/SizeCache.java -> Could also use "if (cachedHeight != null)" here...

Line:237, bundles/org.eclipse.ui.forms/src/org/eclipse/ui/forms/widgets/SizeCache.java -> change to:

if (widthHint >= preferredSize.x)

We shouldn't be adding widthAdjustment here.

Line:238, bundles/org.eclipse.ui.forms/src/org/eclipse/ui/forms/widgets/SizeCache.java -> Change to:

return new Point(widthHint, preferredSize.y)

Line:244, bundles/org.eclipse.ui.forms/src/org/eclipse/ui/forms/widgets/SizeCache.java -> Good change.

Line:245, bundles/org.eclipse.ui.forms/src/org/eclipse/ui/forms/widgets/SizeCache.java -> Nice catch.

Line:254, bundles/org.eclipse.ui.forms/src/org/eclipse/ui/forms/widgets/SizeCache.java -> Inappropriate use of heightAdjustment.

change to "if (heightHint == preferredSize.y) {"

-------------------------------------
author: Gerrit Code Review
date: 2017-05-04 20:04:27.000000000

Change has been successfully merged into the git repository by Kelly Potter

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