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

Andy Goryachev angorya at openjdk.org
Wed Jan 8 23:00:17 UTC 2025


On Wed, 8 Jan 2025 19:24:33 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:
> 
>   move pseudo-class changes to end of onChanged

Okay, check out HBox page in the latest monkey tester 
https://github.com/andy-goryachev-oracle/MonkeyTest

set Children to "1000 text nodes", open Tools -> Css Playground and play with the CSS, for example

`.T1000:nth-child(odd) { -fx-fill-color:red; }`

![Screenshot 2025-01-08 at 14 42 37](https://github.com/user-attachments/assets/e780b03d-0c99-45a9-aa80-c0837a102534)

To me on macOS 15.1.1, the style change looks instantaneous.

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

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


More information about the openjfx-dev mailing list