Skip to content

8390440: Region.layoutInArea measures content-biased children against an unsnapped value - #2261

Open
mstr2 wants to merge 2 commits into
openjdk:masterfrom
mstr2:fixes/layout-in-area
Open

8390440: Region.layoutInArea measures content-biased children against an unsnapped value#2261
mstr2 wants to merge 2 commits into
openjdk:masterfrom
mstr2:fixes/layout-in-area

Conversation

@mstr2

@mstr2 mstr2 commented Aug 16, 2026

Copy link
Copy Markdown
Collaborator

Region.layoutInArea() calls Region.boundedNodeSizeWithBias(), which derives the dependent value from a potentially unsnapped value, after which layoutInArea() assigns a potentially different, snapped value to the child. This is wrong, because the dependent value is effectively computed against a value that might not be assigned to the child.

For a horizontally biased child, the current sequence is effectively:

double rawWidth = boundedSize(...);
double rawHeight = boundedSize(
        child.minHeight(rawWidth),
        ... child.prefHeight(rawWidth) ...,
        child.maxHeight(rawWidth));

child.resize(
        snapSize(rawWidth),
        snapSize(rawHeight));

The correct sequence would be:

double width = snapSize(boundedSize(...));
double height = snapSize(boundedSize(
        child.minHeight(width),
        ... child.prefHeight(width) ...,
        child.maxHeight(width)));

child.resize(width, height);

This snapping bug can only be observed when all of the following conditions are met:

  1. pixel snapping is enabled
  2. the child is resizable and has a horizontal or vertical content bias
  3. the bounded primary dimension is not already correctly snapped
  4. the dependent size constraints change between the raw and snapped primary dimensions

This came out of the "snapping rules" I've compiled for PR #2260, specifically the rule Use the same snapped dependent dimension for measurement and layout.



Progress

  • Change must not contain extraneous whitespace
  • Commit message must refer to an issue
  • Change must be properly reviewed (2 reviews required, with at least 1 Reviewer, 1 Author)

Issue

  • JDK-8390440: Region.layoutInArea measures content-biased children against an unsnapped value (Bug - P4)

Reviewing

Using git

Checkout this PR locally:
$ git fetch https://git.openjdk.org/jfx.git pull/2261/head:pull/2261
$ git checkout pull/2261

Update a local copy of the PR:
$ git checkout pull/2261
$ git pull https://git.openjdk.org/jfx.git pull/2261/head

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 2261

View PR using the GUI difftool:
$ git pr show -t 2261

Using diff file

Download this PR as a diff file:
https://git.openjdk.org/jfx/pull/2261.diff

Using Webrev

Link to Webrev Comment

@bridgekeeper

bridgekeeper Bot commented Aug 16, 2026

Copy link
Copy Markdown

👋 Welcome back mstrauss! A progress list of the required criteria for merging this PR into master will be added to the body of your pull request. There are additional pull request commands available for use with this pull request.

@openjdk

openjdk Bot commented Aug 16, 2026

Copy link
Copy Markdown

❗ This change is not yet ready to be integrated.
See the Progress checklist in the description for automated requirements.

@openjdk openjdk Bot added the rfr Ready for review label Aug 16, 2026
@openjdk

openjdk Bot commented Aug 16, 2026

Copy link
Copy Markdown

The total number of required reviews for this PR has been set to 2 based on the presence of this label: rfr. This can be overridden with the /reviewers command.

@mlbridge

mlbridge Bot commented Aug 16, 2026

Copy link
Copy Markdown

Webrevs

@hjohn

hjohn commented Aug 16, 2026

Copy link
Copy Markdown
Collaborator

Will review soon, but I agree that this makes sense.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

rfr Ready for review

Development

Successfully merging this pull request may close these issues.

2 participants