From 1620fb411d73776afc4a145fe5735a8d87117b8d Mon Sep 17 00:00:00 2001 From: mstr2 <43553916+mstr2@users.noreply.github.com> Date: Mon, 2 Dec 2024 15:58:09 +0100 Subject: [PATCH 1/2] Implementation of media queries --- .../docs/javafx/scene/doc-files/cssref.html | 74 ++- .../javafx/scene/doc-files/media-feature.svg | 176 +++++ .../javafx/scene/doc-files/media-query.svg | 94 +++ .../sun/javafx/application/PlatformImpl.java | 8 +- .../preferences/PlatformPreferences.java | 14 +- .../property/NullCoalescingPropertyBase.java | 74 +++ .../com/sun/javafx/css/SimpleSelector.java | 24 +- .../sun/javafx/css/media/MediaFeatures.java | 100 +++ .../javafx/css/media/MediaQueryParser.java | 286 +++++++++ .../css/media/MediaQuerySerializer.java | 118 ++++ .../expression/ConjunctionExpression.java | 69 ++ .../media/expression/ConstantExpression.java | 45 ++ .../expression/DisjunctionExpression.java | 69 ++ .../media/expression/FunctionExpression.java | 73 +++ .../media/expression/NegationExpression.java | 50 ++ .../sun/javafx/css/parser}/CssLexer.java | 93 ++- .../sun/javafx/css/parser/TokenStream.java | 114 ++++ .../com/sun/javafx/scene/SceneHelper.java | 9 +- .../javafx/scene/SceneMediaQueryContext.java} | 51 +- .../src/main/java/javafx/css/CssParser.java | 121 +++- .../src/main/java/javafx/css/MediaQuery.java | 56 ++ .../java/javafx/css/MediaQueryContext.java | 59 ++ .../src/main/java/javafx/css/MediaRule.java | 131 ++++ .../src/main/java/javafx/css/Rule.java | 44 +- .../src/main/java/javafx/css/Stylesheet.java | 7 +- .../src/main/java/javafx/scene/Scene.java | 188 ++++++ .../shims/java/javafx/css/CssLexerShim.java | 100 --- .../src/shims/java/javafx/css/RuleShim.java | 4 +- modules/javafx.graphics/src/test/addExports | 4 + .../preferences/PlatformPreferencesTest.java | 3 +- .../NullCoalescingPropertyBaseTest.java | 117 ++++ .../css/media/MediaQuerySerializerTest.java | 128 ++++ .../sun/javafx/css/parser}/CssLexerTest.java | 601 +++++++++--------- .../javafx/css/CssParser_mediaQuery_Test.java | 294 +++++++++ .../java/test/javafx/css/StylesheetTest.java | 20 + 35 files changed, 2904 insertions(+), 514 deletions(-) create mode 100644 modules/javafx.graphics/src/main/docs/javafx/scene/doc-files/media-feature.svg create mode 100644 modules/javafx.graphics/src/main/docs/javafx/scene/doc-files/media-query.svg create mode 100644 modules/javafx.graphics/src/main/java/com/sun/javafx/beans/property/NullCoalescingPropertyBase.java create mode 100644 modules/javafx.graphics/src/main/java/com/sun/javafx/css/media/MediaFeatures.java create mode 100644 modules/javafx.graphics/src/main/java/com/sun/javafx/css/media/MediaQueryParser.java create mode 100644 modules/javafx.graphics/src/main/java/com/sun/javafx/css/media/MediaQuerySerializer.java create mode 100644 modules/javafx.graphics/src/main/java/com/sun/javafx/css/media/expression/ConjunctionExpression.java create mode 100644 modules/javafx.graphics/src/main/java/com/sun/javafx/css/media/expression/ConstantExpression.java create mode 100644 modules/javafx.graphics/src/main/java/com/sun/javafx/css/media/expression/DisjunctionExpression.java create mode 100644 modules/javafx.graphics/src/main/java/com/sun/javafx/css/media/expression/FunctionExpression.java create mode 100644 modules/javafx.graphics/src/main/java/com/sun/javafx/css/media/expression/NegationExpression.java rename modules/javafx.graphics/src/main/java/{javafx/css => com/sun/javafx/css/parser}/CssLexer.java (94%) create mode 100644 modules/javafx.graphics/src/main/java/com/sun/javafx/css/parser/TokenStream.java rename modules/javafx.graphics/src/{shims/java/com/sun/javafx/css/parser/TokenShim.java => main/java/com/sun/javafx/scene/SceneMediaQueryContext.java} (51%) create mode 100644 modules/javafx.graphics/src/main/java/javafx/css/MediaQuery.java create mode 100644 modules/javafx.graphics/src/main/java/javafx/css/MediaQueryContext.java create mode 100644 modules/javafx.graphics/src/main/java/javafx/css/MediaRule.java delete mode 100644 modules/javafx.graphics/src/shims/java/javafx/css/CssLexerShim.java create mode 100644 modules/javafx.graphics/src/test/java/test/com/sun/javafx/beans/property/NullCoalescingPropertyBaseTest.java create mode 100644 modules/javafx.graphics/src/test/java/test/com/sun/javafx/css/media/MediaQuerySerializerTest.java rename modules/javafx.graphics/src/test/java/test/{javafx/css => com/sun/javafx/css/parser}/CssLexerTest.java (50%) create mode 100644 modules/javafx.graphics/src/test/java/test/javafx/css/CssParser_mediaQuery_Test.java diff --git a/modules/javafx.graphics/src/main/docs/javafx/scene/doc-files/cssref.html b/modules/javafx.graphics/src/main/docs/javafx/scene/doc-files/cssref.html index 11ae849727b..90bddec4573 100644 --- a/modules/javafx.graphics/src/main/docs/javafx/scene/doc-files/cssref.html +++ b/modules/javafx.graphics/src/main/docs/javafx/scene/doc-files/cssref.html @@ -768,14 +768,16 @@

Example

@ Rules

+

@import

Beginning with JavaFX 8u20, the CSS - @import is also partially supported. + @import is partially supported. Only unconditional import is supported. In other words, the media‑type qualifier is not supported. Also, the JavaFX CSS parser is non-compliant with regard to where an @import may appear within a stylesheet (see At‑rules). Users are cautioned that this will be fixed in a future release. Adherence to the W3C standard is strongly advised.

+

@font-face

Since JavaFX 8, the implementation partially supports the CSS3 syntax to load a font from a URL using the @font‑face rule: