On Mon, 17 Aug 2026 00:39:29 GMT, Michael Strauß <[email protected]> wrote:

>> modules/javafx.graphics/src/main/java/javafx/scene/layout/package-info.java 
>> line 442:
>> 
>>> 440:  *
>>> 441:  *         // Incorrect: snapSizeX can turn floating-point noise into 
>>> an extra pixel
>>> 442:  *         double allocatedWidth = snapSizeX(firstWidth + gapWidth + 
>>> secondWidth);
>> 
>> The correct example uses `snapSpaceX` (after snapping individually), but 
>> this incorrect example uses `snapSizeX` without snapping individually. If 
>> the idea is to demonstrate re-snapping, then the same method should be used, 
>> otherwise it introduces another incorrectness.
>
> I'm not sure what you mean here. The individual components are always snapped 
> in this example, the mistake is using `snapSizeX` instead of `snapSpaceX`.

I misplaced the comment. It was supposed to be at the example in *Snap 
independent allocations independently*,

 *         // Correct: each content item receives an independent allocation
 *         double total = snapSpaceX(snapSizeX(firstWidth) + 
snapSizeX(secondWidth)); // 2.0
 *
 *         // Incorrect: 0.4 + 0.4 is treated as one content allocation
 *         double total = snapSizeX(firstWidth + secondWidth); // 1.0

which showed both a different snapping method and a difference in re-snapping. 
You've changed the incorrect example to use `snapSpaceX`, so now the incorrect 
part is clear.

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

PR Review Comment: https://git.openjdk.org/jfx/pull/2260#discussion_r3798638816

Reply via email to