RFR: 8345188: Support tree-structural pseudo-classes [v10]
Kevin Rushforth
kcr at openjdk.org
Thu Jan 9 17:39:53 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
I wrote a test using a VBox in a ScrollPane (no scrolling is actually happening), where the VBox is initialized with 10,000 nodes. I then measured the time to add 1,000 nodes, one at a time at index 0. There is a noticeable performance drop with this PR.
With the latest master, here are the results of adding 1,000 nodes 15 times (so there are 25,000 total nodes when this is all done).
Added 1000 nodes in 17.016208 msec
Added 1000 nodes in 12.272875 msec
Added 1000 nodes in 11.467291 msec
Added 1000 nodes in 3.575083 msec
Added 1000 nodes in 4.963792 msec
Added 1000 nodes in 9.705375 msec
Added 1000 nodes in 9.232666 msec
Added 1000 nodes in 8.88975 msec
Added 1000 nodes in 10.242958 msec
Added 1000 nodes in 10.33725 msec
Added 1000 nodes in 10.780708 msec
Added 1000 nodes in 10.877875 msec
Added 1000 nodes in 11.293583 msec
Added 1000 nodes in 11.499458 msec
Added 1000 nodes in 10.199292 msec
With this PR, here are the results:
Added 1000 nodes in 220.310875 msec
Added 1000 nodes in 195.185458 msec
Added 1000 nodes in 236.359917 msec
Added 1000 nodes in 254.438208 msec
Added 1000 nodes in 269.650458 msec
Added 1000 nodes in 323.805625 msec
Added 1000 nodes in 344.086959 msec
Added 1000 nodes in 422.552417 msec
Added 1000 nodes in 458.606666 msec
Added 1000 nodes in 560.954166 msec
Added 1000 nodes in 637.210458 msec
Added 1000 nodes in 613.063416 msec
Added 1000 nodes in 773.218375 msec
Added 1000 nodes in 838.431291 msec
Added 1000 nodes in 896.401292 msec
Note that in addition to it being slower to begin with, it gets progressively slower as the number of existing nodes increases (not surprisingly).
This is bit of a corner case, but it does validate John's concern.
-------------
PR Comment: https://git.openjdk.org/jfx/pull/1652#issuecomment-2580897575
More information about the openjfx-dev
mailing list