On Tue, 3 Sep 2024 13:48:06 GMT, Michael Strauß <mstra...@openjdk.org> wrote:

>> modules/javafx.graphics/src/main/java/javafx/css/StyleableLongProperty.java 
>> line 140:
>> 
>>> 138:             long diff = endValue - startValue;
>>> 139:             long result = startValue + Math.round(progress * diff);
>>> 140:             set(progress < 1 ? Utils.clamp(startValue, result, 
>>> endValue) : endValue);
>> 
>> `clamp` won't solve that if `progress = 1.0` that the calculation may result 
>> in a value less than `endValue`.  You need both the `clamp` and a special 
>> case:
>> 
>>     set(progress == 1.0 ? endValue : progress < 1 ? Utils.clamp(startValue, 
>> result, endValue) : endValue);
>> 
>> Use `==` or `>=` I don't know what's better.
>> 
>> I'm assuming that it is important that `endValue` is returned when `progress 
>> = 1.0`
>
> I don't understand this. If progress != 1, then it must be < 1 by definition. 
> It can never be > 1.
> So the current implementation will just ignore the result of the computation 
> for the special case (result = 1):
> 
> set(progress < 1 ? Utils.clamp(startValue, result, endValue) : endValue);

Sorry, you're right. I completely missed it.

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

PR Review Comment: https://git.openjdk.org/jfx/pull/1522#discussion_r1742196709

Reply via email to