RFR: 8276313: ScrollPane scroll delta incorrectly depends on content height [v2]

Kevin Rushforth kcr at openjdk.java.net
Thu Dec 2 21:55:19 UTC 2021


On Wed, 1 Dec 2021 14:00:06 GMT, Michael Strauß <mstrauss at openjdk.org> wrote:

>> This PR fixes an issue where the scroll delta of ScrollPane incorrectly depends on the size of its content.
>> This leads to extremely slow scrolling when the content is only slightly larger than the ScrollPane.
>
> Michael Strauß has updated the pull request incrementally with one additional commit since the last revision:
> 
>   Handle division by zero

modules/javafx.controls/src/main/java/javafx/scene/control/skin/ScrollPaneSkin.java line 895:

> 893:                 double vRange = getSkinnable().getVmax()-getSkinnable().getVmin();
> 894:                 double vPixelValue = vRange / (nodeHeight - contentHeight);
> 895:                 vPixelValue = Double.isFinite(vPixelValue) ? vPixelValue : 0.0;

I liked the previous logic better and would have just changed the comparison to check `(nodeHeight - contentHeight) > 0.0` (possibly saving the adjusted width or height in a local various to avoid doing it twice). As it is, this is replacing an explicit check on the source values with an out of range check on the result, which seems less intuitive. Also, the previous code did a `> 0` test and the new code effectively does a `!= 0` test.

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

PR: https://git.openjdk.java.net/jfx/pull/660


More information about the openjfx-dev mailing list