RFR: 8311527: Region.snapInnerSpace*()

Andy Goryachev angorya at openjdk.org
Thu Sep 7 16:07:54 UTC 2023


On Wed, 6 Sep 2023 23:10:11 GMT, Kevin Rushforth <kcr at openjdk.org> wrote:

>> Introduces Region.snapInnerSpaceX/Y() methods for dealing with inner space (using Math.floor), see for instance [JDK-8299753](https://bugs.openjdk.org/browse/JDK-8299753), using existing methods Region.snapPortionX/Y().
>
> modules/javafx.graphics/src/test/java/test/javafx/scene/layout/RegionTest.java line 1289:
> 
>> 1287:         assertEquals(Double.POSITIVE_INFINITY, region.snapInnerSpaceY(Double.MAX_VALUE), 0.0);
>> 1288:         assertEquals(Double.NEGATIVE_INFINITY, region.snapInnerSpaceX(-Double.MAX_VALUE), 0.0);
>> 1289:         assertEquals(Double.NEGATIVE_INFINITY, region.snapInnerSpaceY(-Double.MAX_VALUE), 0.0);
> 
> Why is the expected value infinity here?

Good question!

ScaledMath.floor() goes through 

Math.floor(d + Math.ulp(d)) / scale;

which results in a value greater than Double.MAX_VALUE for positive input.

Similarly, the negative input goes through

Math.ceil(d - Math.ulp(d)) / scale;

and the result is less than -Double.MAX_VALUE, so negative infinity.

It's not really important because all these are way beyond the values acceptable as coordinates.

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

PR Review Comment: https://git.openjdk.org/jfx/pull/1190#discussion_r1318828360


More information about the openjfx-dev mailing list