jfx icon indicating copy to clipboard operation
jfx copied to clipboard

8358450: Viewport characteristics media features

Open mstr2 opened this issue 5 months ago • 10 comments

Implementation of viewport characteristics media features:

  • width
  • height
  • aspect-ratio: width / height
  • orientation: portrait, landscape
  • display-mode: fullscreen, standalone (note: browser and minimal-ui are not supported in JavaFX)

/reviewers 2 /csr


Progress

  • [x] Change must not contain extraneous whitespace
  • [x] Commit message must refer to an issue
  • [ ] Change requires CSR request JDK-8363983 to be approved
  • [ ] Change must be properly reviewed (2 reviews required, with at least 1 Reviewer, 1 Author)

Issues

  • JDK-8358450: Viewport characteristics media features (Enhancement - P4)
  • JDK-8368508: Missing info in JavaFX CSS Reference Guide (Bug - P4)
  • JDK-8363983: Viewport characteristics media features (CSR)

Reviewing

Using git

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

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

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 1844

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

Using diff file

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

Using Webrev

Link to Webrev Comment

mstr2 avatar Jul 12 '25 05:07 mstr2

:wave: 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.

bridgekeeper[bot] avatar Jul 12 '25 05:07 bridgekeeper[bot]

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

openjdk[bot] avatar Jul 12 '25 05:07 openjdk[bot]

@mstr2 The total number of required reviews for this PR (including the jcheck configuration and the last /reviewers command) is now set to 2 (with at least 1 Reviewer, 1 Author).

openjdk[bot] avatar Jul 12 '25 05:07 openjdk[bot]

@mstr2 has indicated that a compatibility and specification (CSR) request is needed for this pull request.

@mstr2 please create a CSR request for issue JDK-8358450 with the correct fix version. This pull request cannot be integrated until the CSR request is approved.

openjdk[bot] avatar Jul 12 '25 05:07 openjdk[bot]

/issue add 8368508

mstr2 avatar Sep 24 '25 15:09 mstr2

@mstr2 Adding additional issue to issue list: 8368508: Missing info in JavaFX CSS Reference Guide.

openjdk[bot] avatar Sep 24 '25 15:09 openjdk[bot]

Reviewers: @kevinrushforth @arapte

kevinrushforth avatar Oct 29 '25 17:10 kevinrushforth

@mstr2 This pull request has been inactive for more than 4 weeks and will be automatically closed if another 4 weeks passes without any activity. To avoid this, simply issue a /touch or /keepalive command to the pull request. Feel free to ask for assistance if you need help with progressing this pull request towards integration!

bridgekeeper[bot] avatar Nov 26 '25 22:11 bridgekeeper[bot]

It would be nice to get this in for JavaFX 26, so will look at it soon.

kevinrushforth avatar Nov 26 '25 23:11 kevinrushforth

A CSS example (either in the ticket or the PR) would be nice, for ease of reviewing.

Here, I am trying to see if the button background will change when I move the monkey tester window from one monitor to another (one is 1900 px wide, the other is 2560). I see no change:

    @media (width < 2000) {
        .button {
            -fx-background-color: red;
        }
    }

What am I doing wrong?

andy-goryachev-oracle avatar Dec 15 '25 20:12 andy-goryachev-oracle

What am I doing wrong?

All of the new media features query the scene, not the screen. If you resize the window, you should see the background color change.

mstr2 avatar Dec 15 '25 21:12 mstr2

A CSS example (either in the ticket or the PR) would be nice, for ease of reviewing.

Added an example to the description of this PR.

mstr2 avatar Dec 15 '25 21:12 mstr2

Having both aspect-ratio and orientation is a bit redundant, isn't it? Is it just for convenience?

andy-goryachev-oracle avatar Dec 15 '25 21:12 andy-goryachev-oracle

Having both aspect-ratio and orientation is a bit redundant, isn't it? Is it just for convenience?

It almost seems like there could be historical reasons, like one preceded the other or something like that. But as far as I can see, both media features appear at the same time around 2008, and they've been around ever since. So I guess it's mostly convenience.

mstr2 avatar Dec 15 '25 21:12 mstr2

Why do I get stderr output with this:

WARNING: CSS Error parsing '    @media (aspect-ratio > 0.5) {
        .button {
            -fx-background-color: red;
        }
    }
: Invalid value <0.5> for media feature <aspect-ratio> at [1,30]

andy-goryachev-oracle avatar Dec 15 '25 21:12 andy-goryachev-oracle

However, display-mode does not seem to work on macOS 26.1. To reproduce: [...]

Fixed that. I was using an InvalidationListener that would not be called again if the value of the observable was not actually read.

mstr2 avatar Dec 16 '25 20:12 mstr2

for other reviewers: I've updated the monkey tester's CSS Playground to apply the stylesheets to the newly created windows.

andy-goryachev-oracle avatar Dec 16 '25 22:12 andy-goryachev-oracle