On Sun, 17 Mar 2024 18:07:35 GMT, Johan Vos <j...@openjdk.org> wrote:

>> Florian Kirmaier has updated the pull request incrementally with one 
>> additional commit since the last revision:
>> 
>>   JDK-8323511
>>   reverted accidental indentation chang
>
> modules/javafx.controls/src/main/java/com/sun/javafx/scene/control/VirtualScrollBar.java
>  line 142:
> 
>> 140:                 int index = firstVisibleCell.getIndex();
>> 141:                 if (newValue < oldValue) {
>> 142:                     index = Math.max(0, index - 1);
> 
> Why are the boundary checks (Math.max/min) removed here?

The ``Math.max(0, index - 1)`` was introduced to fix an 
IndesOutOfBoundsException 
([JDK-8311983](https://bugs.openjdk.org/browse/JDK-8311983)) for mouse clicks 
above the thumb, but it also introduced this bug (different scroll amount for 
clicks above and below thumb).
This change fixes the handling of -1 cell indexes in a different way, but for 
that we have to pass it to ``VirtualFlow.scrollTo(int index)`` and then to  
``VirtualFlow.tryScrollOneCell(int targetIndex, boolean downOrRight)``.
Therefore it is necessary to remove this ``Math.max(..)`` call.

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

PR Review Comment: https://git.openjdk.org/jfx/pull/1326#discussion_r1528208036

Reply via email to