On Tue, 13 Oct 2026 08:08:53 GMT, John Hendrikx <[email protected]> wrote:

>> css: test:on { prop: 5 }
>> 
>> 1. set style test:on, applyCss
>> 2. check value 5
>> 3. set prop settable=false
>> 4. set pseudoclass :on to false via pseudoClassStateChanged()
>> 5. applyCss
>> 6. check value 5
>> 7. set settable=true
>> 8. set :on to true 
>> 9. applyCss
>> 10. set :on to false
>> 11. check value, should be default
>
>> > > Well, you can `bind` a property... good luck setting it then.
>> > > Never quite understood why it was decided that in the CSS system, `set` 
>> > > and `bind` aren't the ultimate truth, but can be overridden by the users 
>> > > own stylesheet (but not the user agent stylesheet).
>> > > I mean `USER` in browser terminology means the browser user (browsers 
>> > > allow for stylesheets set directly by the end user, that fit between the 
>> > > browsers own default look (`USER_AGENT`) and the website developers look 
>> > > (`AUTHOR`).
>> > > However, in JavaFX, `USER` has been conflated with application 
>> > > developer... it should have been the end user.
>> > 
>> > 
>> > 100% agree. This behavior is very confusing and feels just wrong.
>> 
>> There have been previous discussions on the mailing list and in JBS about 
>> the wrong ordering. Setting a property from the code should override CSS, 
>> but it's the other way around. In my opinion the ordering should be fixed, 
>> but it will break the current behavior.
> 
> The **current** behavior is also broken to be honest, and unfixable (ie. 
> `set` seems to work, then gets clobbered at random depending on when CSS will 
> run again -- which is not guaranteed to run each frame).
> 
> I would be all for to do a true fix for that, extending this:
> 
> 
> /**
>  * Enumeration of the possible source or origin of a stylesheet and styles.
>  * @since JavaFX 8.0
>  */
> public enum StyleOrigin {
>     /** The stylesheet is a user-agent stylesheet */
>     USER_AGENT,
>     /** The value of a property was set by the user through a call to a set 
> method */
>     USER,
>     /** The stylesheet is an external file */
>     AUTHOR,
>     /** The style is from the Node via setStyle */
>     INLINE
> }
> 
> Just add:
> 
>     /** Programmatic (new) */ 
>     PROGRAMMATIC
> 
> 
> The only slight annoyance here is that `USER` is specifically documented that 
> it is for the `set` method, but as we didn't specify priorities here (and 
> AFAIK nowhere in public API) we could just change the order as well (it is 
> basically just implied from how CSS works in browsers, but undocumented).

+1 from my side. If you already have an implementation in your head, feel free 
to open a draft PR, I will review.

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

PR Review Comment: https://git.openjdk.org/jfx/pull/2343#discussion_r4261237442

Reply via email to