w3c / csswg-drafts

CSS Working Group Editor Drafts
https://drafts.csswg.org/
Other
4.5k stars 660 forks source link

[css-ui-3] Can |CSS resize| change the value of the width/height properties which has been set with !Important? #5184

Open mjf-g opened 4 years ago

mjf-g commented 4 years ago

https://drafts.csswg.org/css-ui-3/#resize:

When an element is resized by the user, the user agent sets the width and height properties to px unit length values of the size indicated by the user, in the element’s style attribute DOM, replacing existing property declaration(s), if any, without !important, if any.

Does this mean that we can't resize an element with !important width/height? The end of this sentence may not be easy to understand.

The div element with the following style can't be resized indeed in Firefox and Chrome.

#div {
  width: 200px !important;
  height: 200px !important;
  overflow: hidden;
  resize: both;
}
mjf-g commented 4 years ago

@frivoal can perhaps confirm this.

This issue is related to https://github.com/whatwg/fullscreen/issues/171. cc: @annevk, @emilio

frivoal commented 4 years ago

Yeah, the phrasing isn't great. what this means is that the style is injected in to a style attribute, and does not include !important. So:

This has been a while, so I don't fully remember, but I believe this design was much more driven by existing implementations and compat than by a belief this was a smart approach. If this is causing issues and there's evidence than a better behavior would be web compatible, we could definitely consider it.

Otherwise, maybe just an editorial clarification is in order.

annevk commented 4 years ago

Is that equivalent to

Some rules are intended for the author-level zero-specificity presentational hints part of the CSS cascade; these are explicitly called out as presentational hints.

from HTML? It seems like it might be a tiny bit different.

tabatkins commented 4 years ago

It is different, yes. These are explicitly at the style-attribute level (so they'll win over normal width/height declarations in CSS), which is a much higher specificity level than presentational hints.

annevk commented 4 years ago

How are both of these implemented? Do browsers have a more complicated cascade model than the specification allows for? (I'm wondering if HTML and CSS UI monkey patching the cascade is really what we want long term.)

emilio commented 4 years ago

They're implemented literally changing the style attribute I think.

annevk commented 4 years ago

Ah okay, I guess for this the way we could improve clarity then is by having the appropriate (low-level) calls into CSSOM to do just that.

frivoal commented 4 years ago

@annevk are you suggesting this clarification for css-ui, or for HTML, or both?

annevk commented 4 years ago

CSSOM might need to expose the appropriate hook and CSS UI would have to invoke it. (HTML might need a better integration hook from CSS Cascade I suppose to make presentational hints more formalized.)