On Sun, 14 Dec 2025 18:57:50 GMT, Michael Strauß <[email protected]> wrote:
>> Implementation of [viewport characteristics media >> features](https://www.w3.org/TR/mediaqueries-5/#mf-viewport-characteristics): >> * `width` >> * `height` >> * `aspect-ratio`: width / height >> * `orientation`: `portrait`, `landscape` >> * `display-mode`: `fullscreen`, `standalone` (note: `browser` and >> `minimal-ui` are not supported in JavaFX) >> >> Here's a small example how the new media features can be used: >> >> @Override >> public void start(Stage stage) { >> var button = new Button("Toggle full-screen"); >> button.setOnAction(_ -> stage.setFullScreen(!stage.isFullScreen())); >> var label = new Label(); >> var root = new BorderPane(button, null, null, label, null); >> var scene = new Scene(root, 650, 200); >> BorderPane.setAlignment(label, Pos.CENTER); >> label.textProperty().bind(scene.widthProperty().map(v -> >> String.format("Width: %.2f", v.doubleValue()))); >> scene.getStylesheets().add("data:text/css;base64," + >> Base64.getEncoder().encodeToString(""" >> @media (max-width: 500) { >> .button { >> -fx-background-color: red; >> } >> } >> >> @media (600 < width <= 700) { >> .button { >> -fx-background-color: green; >> } >> } >> >> @media (min-width: 800) { >> .button { >> -fx-background-color: yellow; >> } >> } >> >> @media (display-mode: fullscreen) { >> .button { >> -fx-background-color: black !important; >> } >> } >> """.getBytes(StandardCharsets.UTF_8))); >> >> stage.initStyle(StageStyle.DECORATED); >> stage.setScene(scene); >> stage.show(); >> } > > Michael Strauß has updated the pull request with a new target base due to a > merge or a rebase. The pull request now contains 14 commits: > > - Merge branch 'master' into feature/media-features-viewport-characteristics > - resolve merge conflicts > - Merge branch 'master' into feature/media-features-viewport-characteristics > > # Conflicts: > # > modules/javafx.graphics/src/test/java/test/javafx/css/CssParser_mediaQuery_Test.java > - update cssref.html > - Merge branch 'master' into feature/media-features-viewport-characteristics > - whitespace, add final modifier > - Merge branch 'master' into feature/media-features-viewport-characteristics > - Refactor context awareness > - Merge branch 'master' into feature/media-features-viewport-characteristics > - Merge branch 'master' into feature/media-features-viewport-characteristics > - ... and 4 more: https://git.openjdk.org/jfx/compare/32e667df...19cdaeaa Changes requested by angorya (Reviewer). modules/javafx.graphics/src/main/java/com/sun/javafx/css/media/MediaFeatures.java line 250: > 248: case "pc" -> SizeUnits.PC; > 249: default -> throw new IllegalArgumentException( > 250: String.format("Invalid value <%s> for media feature > <%s>", lowerCaseText, featureName)); is this a new code? could we add a unit test for all the combinations of decimal values (integer, fractional, scientific), with and without the units? modules/javafx.graphics/src/main/java/com/sun/javafx/css/media/SizeQueryType.java line 60: > 58: } > 59: > 60: private static final SizeQueryType[] VALUES = values(); is this really needed? modules/javafx.graphics/src/main/java/com/sun/javafx/css/parser/CssLexer.java line 53: > 51: public static final int GREATER = 27; > 52: public static final int LESS = 48; > 53: public static final int EQUALS = 49; this **will** cause problems. could we arrange these by value please (add new after `AT_KEYWORD`)? modules/javafx.graphics/src/main/java/javafx/css/Stylesheet.java line 70: > 68: * Version 8: viewport characteristics media queries > 69: */ > 70: final static int BINARY_CSS_VERSION = 8; Does this impact backward compatibility with .bss files? Should it be mentioned in the CSR? modules/javafx.graphics/src/main/java/javafx/scene/Scene.java line 2776: > 2774: boolean widthChanged = w != Scene.this.getWidth(); > 2775: boolean heightChanged = h != Scene.this.getHeight(); > 2776: if (widthChanged) Scene.this.setWidth(w); it might be my personal preference, but I would rather see one statement per line. use case: stepping through in the debugger. can we add { }'s please? modules/javafx.graphics/src/test/java/test/javafx/css/CssParser_mediaQuery_Test.java line 675: > 673: assertEquals(1, stylesheet.getRules().size()); > 674: assertEquals( > 675: List.of(EqualExpression.of(SizeQueryType.WIDTH, new > Size(100, SizeUnits.PX))), Could we add a test that verifies that the CSS parser accepts fractional decimals? With or without the units specified? Also, does it support scientific notation line `1e2` for `100` ? ------------- PR Review: https://git.openjdk.org/jfx/pull/1844#pullrequestreview-3580478763 PR Review Comment: https://git.openjdk.org/jfx/pull/1844#discussion_r2621124272 PR Review Comment: https://git.openjdk.org/jfx/pull/1844#discussion_r2621103826 PR Review Comment: https://git.openjdk.org/jfx/pull/1844#discussion_r2621106888 PR Review Comment: https://git.openjdk.org/jfx/pull/1844#discussion_r2621112439 PR Review Comment: https://git.openjdk.org/jfx/pull/1844#discussion_r2621116371 PR Review Comment: https://git.openjdk.org/jfx/pull/1844#discussion_r2621121423
