RFR: 8345188: Support tree-structural pseudo-classes [v10]

Michael Strauß mstrauss at openjdk.org
Thu Jan 9 19:15:55 UTC 2025


On Wed, 8 Jan 2025 23:47:10 GMT, Michael Strauß <mstrauss at openjdk.org> wrote:

>> The CSS Selectors specification defines the `:root` pseudo-class that matches root nodes:
>> https://www.w3.org/TR/selectors-4/#the-root-pseudo
>> 
>> JavaFX uses the non-standard `.root` style class for the same purpose. We should also support the `:root` pseudo-class for increased compatibility of JavaFX CSS with the web specification.
>> 
>> Additionally, we should also support the following child-indexed pseudo-classes:
>> `:first-child`
>> `:last-child`
>> `:only-child`
>> `:nth-child()` with arguments `even` and `odd`
>> 
>> The `An+B [of S]?` microsyntax for `:nth-child()` is not supported, as this would require major changes in JavaFX CSS.
>
> Michael Strauß has updated the pull request incrementally with one additional commit since the last revision:
> 
>   updated cssref

By the way, I still think that front-inserting nodes one by one is a pathological situation, and can be easily fixed by just using `addAll` instead of `add` in a loop.

In terms of a future enhancement, I can't really see us put in a lot of work just for one pathological use case. Discarding this feature will probably put it in the "never" category. On the other hand, there's a whole category of pseudo-classes that are unrepresentable right now in JavaFX, as they basically depend on a formula, like `nth-child(2n+1)`. But that's just speculation at this point.

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

PR Comment: https://git.openjdk.org/jfx/pull/1652#issuecomment-2581067203


More information about the openjfx-dev mailing list