-
Notifications
You must be signed in to change notification settings - Fork 671
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[css-ui] Changing UA styles based on the computed value of the appearance property #10028
Comments
#5998 is the other thread. In particular what we're looking for here is a way whereby a new value of the @nt1m conceptualized this idea as a user agent at-rule, e.g., select {
@appearance-base {
border: thin solid ButtonBorder;
...
}
} (Conceptually this needs to be something like an at-rule as you might need to style various states as well.) |
I’ve tried implementing a few solutions to this and here are my thoughts: solution 1: internal pseudo-class for child contentWe could have an internal pseudo-class which matches the select when it has a child in the new content model, which would be a button or datalist. This way we can adjust the UA styles based on the new DOM to get the new UA styles. I currently have this implemented in the chromium prototype here: https://source.chromium.org/chromium/chromium/src/+/main:third_party/blink/renderer/core/html/resources/html.css;l=918-929;drc=df34b11bbe7a46c53c782a6d4a24145a4af05e10 Issues:
solution 2: adjust style after style calculation to remove old appearance:auto UA stylesAfter style recalc, chromium and webkit have a style adjuster which changes the computed style. We could look for appearance:bikeshed on a select element here and remove a few styles we don’t want, like border and background-color. I started a patch to implement this in chromium here: https://chromium-review.googlesource.com/c/chromium/src/+/5348242/2/third_party/blink/renderer/core/css/resolver/style_adjuster.cc Issues:
solution 3: leave the UA styles in thereWe could just leave the problematic UA styles in there and make the developer revert all of them when they apply appearance:bikeshed. Issues:
solution 4: put an attribute on select to opt-inWe could use an HTML attribute instead of appearance:bikeshed to opt in to the new behavior and content model (similar to to the proposed switch attribute?). This attribute could be used in the UA stylesheet to change the styles as desired. solution 5: add an internal pseudo-class or @ rule which matches when style is computed to appearance:bikeshedWe could add an internal @ rule or internal pseudo-class to gate the UA styles based on appearance as desired. Issues:
@emilio do you have any thoughts? |
I'm not sure solution 5 would require two style passes. I think that depends on how it's implemented. If it's implemented in terms of solution 2 for instance, maybe not? Also, for solution 2 you can read out author styles and account for them. It's just a lot of work which is why some kind of novel mechanism is needed that abstract that so you don't have to implement "base style sheets" from scratch for each control. |
I agree with @andruud that requiring two styling passes is a no-go. It's also cyclic, even though if you restrict the pseudo-class / at-rule to the UA sheet you can kinda cheat and assume that there's no cycle... What styles do you plan to apply to We discussed this with @annevk and @mfreed7 in the context of
This has no cycles and is trivialish to implement, but whether this is possible depends on the kind of styling differences that you want to have between |
For the |
Ah, I guess gecko has |
@emilio While your suggestion does remove magic from style system, it does introduce a burden to the web developer to specify |
@nt1m you mean |
Would the base styles for the input move to the anonymous box? Or would the anonymous box have a pseudo-element to target them (e.g. ::decoration) with the UA sheet styling that? |
What kinds of differences do we want between My preference would be to keep the styles the same, and the difference would be which kind of box |
I reviewed all of the UA styles for Therefore "solution 3: leave the UA styles in there" will work fine and turns out to have no significant problem of poor ergonomics. And we can go with what Emilio suggested and all is well. When the time comes to add stylability to other form controls, we can follow this pattern and just leave existing interoperable UA styles in place, and expect developers to add in their own customizations. |
But that means we cannot for instance have consistent sizing and theming for |
That’s correct. The user agent style sheet rules will have to be the same for all values of
Right.
That was the original plan, but I concluded that it’s not implementable due to the circularity / double-style recalc / needing bespoke style engine hacks problems mentioned earlier. I think that’s acceptable, because developers likely want to add their own customizations anyway in this mode, and it’s simple because there are only four CSS properties to override ( |
Hi, I worked with @argyleink to explore how developers might style a checkbox, switch or range control on top of Note: Again, these are not API proposals, but just data to show styling can work, to validate that the current design path regarding CSS is feasible for additional form controls. In the prototypes you'll find markup like:
The intent of the custom elements is to help articulate an end result where in the box tree the marker is under the input:
The range input needs more parts than just a custom checkmark; the shape of it is like this (modeled very much after what has already been shipped):
When
|
I don't really understand what I'm looking at. Are you suggesting that How does it end up being different from This still seems like a far cry from the I would find it useful if we could find another hour to discuss this in person again. Happy to organize that if that's agreeable. |
@annevk not necessarily. The box tree might change without the shadow tree having to change. E.g. the shadow tree could be the same, but |
@emilio fair, but that doesn't really address how it's different from |
|
It hadn't occurred to me before, but we could do something like As I've implemented in chromium, it looks like this for background-color specifically: select {
background-color: -internal-appearance-auto-base-select(Field, transparent);
} This required the I don't know if the per-property priority is something that exists in csswg specs, and I'm not sure if the particular form of this function is what we would want to spec either, but from my point of view this solves the issue. |
It doesn't, we just generally ensure that there aren't dependency loops and assume UAs will handle the rest themselves. Elevating the priority for appearance makes sense for how Chrome handles these things. And that function proposal (so long as it remains internal, of course) looks reasonable to me. |
Here is a proposed resolution: "Changing UA styles based on the computed value of the appearance property is acceptable" |
The CSS Working Group just discussed
The full IRC log of that discussion<emilio> jarhar: for appearance: base one of the things is that chrome and webkit have different border property and we want to make this interoperable<emilio> ... for html-based solution this was not a proble <emilio> problem* <fantasai> s/popover or/ <fantasai> s/popover or// <emilio> ... so I thought it'd be not possible to solve, but lilles suggested something like light-dark <emilio> ... that took multiple values, one for auto/none and one for base <emilio> ... I implemented it for border and so on <RRSAgent> I have made the request to generate https://www.w3.org/2024/06/27-css-minutes.html fantasai <emilio> ... not sure if you need details <emilio> q+ <chrishtr> +1 <gregwhitworth> ack emilio <fantasai> scribe+ <fantasai> emilio: This is fine, but I'm sad that we can't get interoperable UA stylesheets <gregwhitworth> emilio: this seems fine, it makes me sad that we can't get interoperable UA stylesheets <masonf> q+ <fantasai> emilio: The fact that now we cannot use regular CSS to represent the HTML styles is a bit unfortunate <gregwhitworth> emilio: now we can not use regular CSS to represent the HTML styles is unfortunate <gregwhitworth> emilio: either we define this entirely and we can use this from HTML then we have to say "if appearance is base" you need to do this <jarhar> q? <gregwhitworth> emilio: it makes me a bit sad that it would spec fiction but maybe it's fine <tantek> +1 emilio, it is surprising that appearance:none is not interoperable across engines <gregwhitworth> emilio: I think we should look into interoperable UA stylesheet. Appearance: none is not interoperable at this point <gregwhitworth> ack masonf <emilio> masonf: first I think this doesn't mean that we shouldn't work on making appearance: none interoperable, but decouples it <emilio> ... so that we don't have to worry about that for now <chrishtr> PROPOSED: user agent styles can depend on appearance:base <jarhar> q+ <emilio> ... the other thing is that maybe there should be an author-visible way to do this <gregwhitworth> ack jarhar <emilio> jarhar: I agree we can work on make appearance: none more interop, but decoupling them is easier <fantasai> i/Topic: [css-ui] DOM/scribe+ gregwhitworth/ <emilio> ... re author visibility, I had to implement it for each prop, so I'm reluctant to do that <RRSAgent> I have made the request to generate https://www.w3.org/2024/06/27-css-minutes.html fantasai <emilio> q+ <masonf> q+ <gregwhitworth> ack emilio <gregwhitworth> zakim, close queue <Zakim> ok, gregwhitworth, the speaker queue is closed <gregwhitworth> emilio: can we resolve on the issue with the goal of making things interoperable and this function would go away <gregwhitworth> emilio: once we make appearance: none consistent this would go away <chrishtr> PROPOSED: user agent styles can depend on appearance:base. Aim for eventual interoperability across all values of the property. <tantek> +1 emilio <gregwhitworth> jarhar: sounds good to me <gregwhitworth> ack masonf <masonf> +1 <dandclark> +1 <emilio> +1 <tantek> 0 <emilio> RESOLVED: user agent styles can depend on appearance:base. Aim for eventual interoperability across all values of the property. <gregwhitworth> Zakim, end meeting |
I'm working on improvements to the
<select>
element (whatwg thread here), and I came across an issue while implementing a prototype of the Apple-supported behavior of switching to a new rendering mode based on the value of the appearance property.The select element has several UA style rules which we don't want in the new rendering mode, such as white-space:pre, which makes all of the options in the popup have a bunch of line breaks rendered in my examples.
I tried adding an internal pseudo-selector which matches when the element has the new appearance value, but I found that it took two style updates to get the final style, which @andruud described as a "non-starter".
@annevk suggested that I should ask here to see if there is a way that we can make this work.
Also, if there are any previous discussions about the appearance property that are related to this, I would appreciate links to them.
cc @nt1m
The text was updated successfully, but these errors were encountered: