On Thu, 10 Apr 2025 16:05:53 GMT, Andy Goryachev <ango...@openjdk.org> wrote:

> In the .md document, you make a reference to w3.org media queries, so one 
> question comes right away: do you eventually plan to implement the whole spec 
> as defined there, or we are really talking about a very small subset of 
> features?

We'd probably never implement the whole spec, but only the parts that make 
sense for JavaFX. Starting with user-preference media features is an obvious 
choice, because we already have a matching set of platform preferences (the 
astute reader might notice just how closely the existing platform preferences, 
the proposed media queries, and the W3C standard align -- almost as if by 
design 😉).

> For example, do you plan to support media query operations like `and`, `not`, 
> `only`, etc.? Also, the w3.org spec might be way too complicated even to be 
> referenced - things there will never apply to JavaFX (`tty`, `projection`, 
> `speech`, etc.)

The `only` keyword makes no sense here, it's a legacy keyword for the web. 
Other than that, this PR already implements the full syntax for media feature 
queries, including `and`, `or`, and `not` (except for the _range form_, which 
we only need to support if we decide to also support viewport characteristics 
features like `width`).

I reference the W3C specification because like with all recently added CSS 
features, this is an implementation of the standard. The JavaFX CSS reference 
documents the extent to which the standard is implemented.

> Alternatively, wouldn't it make _more_ sense to add variables to the JavaFX 
> CSS instead? Or maybe in conjunction with a simpler media-query-like syntax, 
> something like @if(scene.isDark)?

CSS variables can't be implemented without a [major rewrite of the CSS 
system](https://gist.github.com/mstr2/f416996caf48e11193f0b6a5883a3926). We can 
do this, but it is not really related to the feature proposed here. Even with 
CSS variables, you need a way to toggle their value based on external 
configuration, and then you're right back at the start of the problem.

I am very much against inventing _any_ non-standard CSS syntax whatsoever. 
Every time JavaFX did that, the result was not good. Let's face the reality 
here: the JavaFX CSS implementation is severely undercooked, and that's the 
very best thing I can say about it. I don't want to make it any worse.

> My concern is that the media query features (whatever subset of it we decide 
> to implement) might make the code way too complex without providing 
> substantial benefit, and perhaps we can achieve the same goal (of dynamically 
> activating parts of the stylesheet) using simpler solutions like variables?

You seem to be arguing against media queries themselves, not against their 
implementation in JavaFX. But they are a thing in the technology that 99,9% of 
developers know as CSS, it's a brute fact of nature. I think we should 
acknowledge that, and not try to do our own little thing again.

-------------

PR Comment: https://git.openjdk.org/jfx/pull/1655#issuecomment-2794497352

Reply via email to