Skip to content

8364149: Conditional stylesheet imports#2031

Open
mstr2 wants to merge 3 commits intoopenjdk:masterfrom
mstr2:feature/conditional-import
Open

8364149: Conditional stylesheet imports#2031
mstr2 wants to merge 3 commits intoopenjdk:masterfrom
mstr2:feature/conditional-import

Conversation

@mstr2
Copy link
Collaborator

@mstr2 mstr2 commented Jan 11, 2026

The @import rule is extended to support conditional stylesheet imports:

@import [ <url> | <string> ] <media-query-list>? ;

Conceptually, a conditional import takes all rules of the referenced stylesheet, literally includes them at the location of the @import rule, and surrounds them with a @media rule with the specified <media-query-list>.

The implementation of this feature extends media queries with a context-free evaluation function:

interface MediaQuery {
    TriState evaluate(); // returns TRUE / FALSE / UNKNOWN
}

This mode of evaluation uses Kleene's strong trivalent logic to determine whether the media query will always match (it's a tautology), will never match (it's a contradiction), or whether it depends on the context or we simply don't know.

Using this mechanism, a conditional stylesheet import that can never match will be skipped at runtime. Similarly, a conditional stylesheet import that will always match doesn't need the <media-query-list> at all; its rules will be pasted verbatim into the main stylesheet.

Note that this mechanism is not meant to be a full-blown theorem solver. It won't detect that, for example, the following import conditions will always match:

@import url("stylesheet.css") (width > 1000) or (width <= 1000);

Its purpose is an optimization for "obvious" cases. For example, at the moment the built-in themes use hard-coded conditions to include user-agent stylesheets at runtime:

    // in PlatformImpl.java:
    if (isSupported(ConditionalFeature.INPUT_TOUCH)) {
        uaStylesheets.add("com/sun/javafx/scene/control/skin/modena/touch.css");
    }

In the future, we might have a way to test for ConditionalFeature flags that achieves the same thing, but with a public API available to all theme authors:

@import url("com/sun/javafx/scene/control/skin/modena/touch.css")
        (-fx-supports-conditional-feature: input-touch);

Progress

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

Issues

  • JDK-8364149: Conditional stylesheet imports (Enhancement - P4)
  • JDK-8374976: Conditional stylesheet imports (CSR)

Reviewing

Using git

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

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

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 2031

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

Using diff file

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

Using Webrev

Link to Webrev Comment

@bridgekeeper
Copy link

bridgekeeper bot commented Jan 11, 2026

👋 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
Copy link

openjdk bot commented Jan 11, 2026

❗ 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 Jan 11, 2026
@mstr2
Copy link
Collaborator Author

mstr2 commented Jan 11, 2026

/reviewers 2
/csr

@openjdk
Copy link

openjdk bot commented Jan 11, 2026

@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 openjdk bot added the csr Need approved CSR to integrate pull request label Jan 11, 2026
@openjdk
Copy link

openjdk bot commented Jan 11, 2026

@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-8364149 with the correct fix version. This pull request cannot be integrated until the CSR request is approved.

@mlbridge
Copy link

mlbridge bot commented Jan 11, 2026

Webrevs

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

Labels

csr Need approved CSR to integrate pull request rfr Ready for review

Development

Successfully merging this pull request may close these issues.

1 participant