I wonder if this could be done as an incubator module, or hidden behind an experimental system property.
-andy From: openjfx-dev <openjfx-dev-r...@openjdk.org> on behalf of Kevin Rushforth <kevin.rushfo...@oracle.com> Date: Monday, August 26, 2024 at 14:40 To: openjfx-dev@openjdk.org <openjfx-dev@openjdk.org> Subject: Re: New CSS parser for JavaFX Deprecating the existing API is an interesting idea, but with such a large API surface it will be difficult to show that no application is using it. -- Kevin On 8/26/2024 2:35 PM, John Hendrikx wrote: > > On 26/08/2024 22:42, Michael Strauß wrote: >>> can we create stylesheets programmatically without parsing (i.e. >>> construct the token tree directly)? >> Maybe, but `Stylesheet` and its constituent classes really seem like >> exposed implementation details of JavaFX. I would rather deprecate >> their use and remove them from the public API eventually. > > I'm pretty convinced of that as well. The whole CSS API seems to have > been put in place to allow use of binary stylesheets (to perhaps > load Modena .5 seconds faster?), it doesn't seem to serve much of a > function beyond that. I haven't found a use for any of these classes > and the API surface they expose. > > For example, I implemented a LESS parser that I can use with JavaFX, > and the CSS API was absolutely no help there (what is the point of > being able to create a StyleSheet when I can't "set" it on a Scene?) > -- instead I've just resorted to writing the LESS output to memory > buffers, and pointing my stylesheet properties directly to these > (using "data:text/css;charset=UTF-8;base64," URL's -- thanks for > whoever mentioned "data" URL's, I was writing these to temporary files > before that...). > > The CSS API classes are also full of observable properties, which > seems a rather odd decision given that a Stylesheet is probably far > better represented as something immutable. Imagine assigning a > Stylesheet type to Scene (something that isn't possible, so it is > unclear what the purpose of this class is), then having the CSS engine > observe almost every aspect of this Stylesheet, just in case someone > decides to add a new Selector somewhere programmatically... it would > be incredibly complicated to "act" on such a change correctly, > requiring no doubt thousands of lines of code, that will likely never > ever be used in any FX application (well perhaps if you are writing a > Stylesheet editor, but that's hardly a use-case worth supporting just > in case...) > > --John