On Wed, 19 Aug 2026 01:10:25 GMT, Michael Strauß <[email protected]> wrote:

> AnchorPane's measurement and layout calculations are not correct when 
> pixel-snapping is enabled. The following problems are fixed in this PR:
> 
> * Stretched sizes and right/bottom positions are not snapped:
>    `computeChildWidth`/`computeChildHeight` subtract anchors and insets from 
> raw `getWidth()`/`getHeight()`, while `layoutChildren()` passes those values 
> directly to `resizeRelocate`.
> * Content-biased measurement and layout use different dependent dimensions:
>    `computeWidth()` passes `fillHeight=false`, while layout eventually uses 
> `fillHeight=true`
> * Result of snapped calculations is not re-snapped.
> * Anchors use `snapPositionX/Y`. However, anchors are empty space and should 
> use `snapSpaceX/Y`.
> 
> ---------
> - [x] I confirm that I make this contribution in accordance with the [OpenJDK 
> Interim AI Policy](https://openjdk.org/legal/ai).

Changes requested by angorya (Reviewer).

modules/javafx.graphics/src/main/java/javafx/scene/layout/AnchorPane.java line 
366:

> 364: 
> 365:         if (leftAnchor != null && rightAnchor != null) {
> 366:             return snapSpaceX(areaWidth - snappedLeftInset() - 
> snappedRightInset() - leftAnchor - rightAnchor);

here and L379, L429, 435: is it possible for the result to become negative 
and/or clash with -1 sentient value?
should we clamp it to 0?

modules/javafx.graphics/src/test/java/test/javafx/scene/layout/AnchorPaneTest.java
 line 752:

> 750:         Stage stage = new Stage();
> 751:         stage.setRenderScaleX(scale);
> 752:         stage.setRenderScaleY(scale);

please revert

modules/javafx.graphics/src/test/java/test/javafx/scene/layout/AnchorPaneTest.java
 line 809:

> 807: 
> 808:         Stage stage = new Stage();
> 809:         stage.setRenderScaleX(scale);

there was a reason why binding was used - please revert (applies to all other 
PRs)

modules/javafx.graphics/src/test/java/test/javafx/scene/layout/AnchorPaneTest.java
 line 818:

> 816:         try {
> 817:             stage.show();
> 818: 

... and maybe assert render scale x/y

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

PR Review: https://git.openjdk.org/jfx/pull/2264#pullrequestreview-4987777177
PR Review Comment: https://git.openjdk.org/jfx/pull/2264#discussion_r3825746481
PR Review Comment: https://git.openjdk.org/jfx/pull/2264#discussion_r3825762378
PR Review Comment: https://git.openjdk.org/jfx/pull/2264#discussion_r3825673219
PR Review Comment: https://git.openjdk.org/jfx/pull/2264#discussion_r3825765347

Reply via email to