On Thu, 27 Aug 2026 17:10:56 GMT, Michael Strauß <[email protected]> wrote:

>> BorderPane's measurement and layout calculations are not correct when 
>> pixel-snapping is enabled. Here is what's wrong with BorderPane, and what 
>> consequently needs to be fixed:
>> 
>> 1. Insets are not snapped:
>>    * all measurement methods use raw insets
>>    * `layoutChildren()` also uses raw insets
>> 3. Content-biased children use the wrong dependent dimension:
>>    * top and bottom children call `prefHeight(adjustedWidth)` before their 
>> final width is established; left and right have the same problem with height
>>    * measurement and layout can disagree because
>>        - constrained measurement passes the pane's total width/height 
>> without first removing its snapped insets
>>        - `getAreaWidth` uses `fillHeight=false`, while left/right/center 
>> layout uses `fillHeight=true`
>> 5. Arithmetic results are not re-snapped.
>> 
>> ---------
>> - [x] I confirm that I make this contribution in accordance with the 
>> [OpenJDK Interim AI Policy](https://openjdk.org/legal/ai).
>
> Michael Strauß has updated the pull request incrementally with one additional 
> commit since the last revision:
> 
>   enable test, extract method calls

modules/javafx.graphics/src/main/java/javafx/scene/layout/BorderPane.java line 
510:

> 508:             final double minWidth = minWidth(-1);
> 509:             final double minHeight = minHeight(-1);
> 510:             width = snapSpaceX(Math.max(width, minWidth));

I wonder if snapping width is correct in the `BorderPane` case.  For one thing, 
it represents a change in behavior, possibly causing weird vertical lines to 
appear where there weren't any lines before as @hjohn mentioned.

Perhaps we should not snap the trailing edge at all, regardless of the 
snapToPixel setting (same for the bottom edge).

If the edge itself is snapped there is no problem, if it is not - the nodes at 
the edge would just extend to the edge without leaving little gaps.

modules/javafx.graphics/src/main/java/javafx/scene/layout/BorderPane.java line 
631:

> 629:         if (child != null && child.isManaged()) {
> 630:             Insets margin = getNodeMargin(child);
> 631:             double areaWidth = minimum ? computeChildMinAreaWidth(child, 
> -1, margin, height, true):

there might be an issue laying out children with mixed biases.
consider the horizontally biased top (200 x 40) and a vertically biased center 
(100 x 200).  minWidth() for the height=440 returns 50.

if you try to resize to 50 x 440, the center does not fit in this PR, but fits 
correctly in the master.

modules/javafx.graphics/src/test/java/test/javafx/scene/layout/SnappingTest.java
 line 158:

> 156:                     return gridPane;
> 157:                 }),
> 158:                 new ContainerCreator<>(AnchorPane::new),

AnchorPane seems unrelated.

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

PR Review Comment: https://git.openjdk.org/jfx/pull/2262#discussion_r3882576801
PR Review Comment: https://git.openjdk.org/jfx/pull/2262#discussion_r3882755543
PR Review Comment: https://git.openjdk.org/jfx/pull/2262#discussion_r3881858960

Reply via email to