Re: [csswg-drafts] [css-transforms-1] The computed value of `transform` if the transformed element is display:none (#9121)

The CSS Working Group just discussed ``[css-transforms-1] The computed value of `transform` if the transformed element is display:none``, and agreed to the following:

* `RESOLVED: non-transformable elements and elements without a box return a matrix() resolved against a 0x0 box`

<details><summary>The full IRC log of that discussion</summary>
&lt;fantasai> astearns: David, you had a proposal?<br>
&lt;fantasai> dbaron: I'm not sure I'd go so far as to call it a proposal.<br>
&lt;fantasai> dbaron: Basic problem is we don't have interop on getComputedStyle for the transform property for elements that are `display: none`<br>
&lt;fantasai> dbaron: Some UAs try to return none, as though there is no transform... which is weird if there is a transform, but that's also what happens when you do getComputedStyle on an inline box<br>
&lt;fantasai> dbaron: I think?<br>
&lt;fantasai> dbaron: normally, gCS for transforms returns either `none` or a matrix<br>
&lt;fantasai> dbaron: matrix() or matrix3d(). Not a sequence of transform functions.<br>
&lt;fantasai> dbaron: I think some UAs return sequence of transform functions when `display: none`<br>
&lt;fantasai> dbaron: There are 3 reasonably sensible options<br>
&lt;fantasai> dbaron: ... sensible is maybe a stretch<br>
&lt;fantasai> dbaron: Could return a matrix, but some things need a box to e.g. resolve percentages<br>
&lt;fantasai> dbaron: so if you want to return a matrix, you have to make up a box size<br>
&lt;fantasai> dbaron: e.g. 0x0<br>
&lt;fantasai> dbaron: Another option is return `none`<br>
&lt;fantasai> dbaron: Third possibility is to return sequence of transform functions.<br>
&lt;fantasai> dbaron: Maybe it's theoretically sensible, but not done anywhere else so might break people's code.<br>
&lt;fantasai> dbaron: So I think that's probably the least good option<br>
&lt;fantasai> dbaron: I know there is lack of interop, forget who does what<br>
&lt;TabAtkins> q+<br>
&lt;fantasai> Rossen_: Are there any use cases motivating any of these options?<br>
&lt;fantasai> dbaron: Not really. Just need to not break stuff.<br>
&lt;Rossen_> ack TabAtkins<br>
&lt;fantasai> TabAtkins: I don't know what backwards compat is, but I suspect naive code is more likely to depend on matrix() than anything else, so returning matrix against a 0x0 box would be sufficient<br>
&lt;emilio> q+<br>
&lt;fantasai> fantasai: It was only resolving percentages against 0x0, not making the matrix zero<br>
&lt;fantasai> dbaron: so usually it'll still be right, unless you have percentages in translates<br>
&lt;Rossen_> ack emilio<br>
&lt;fantasai> emilio: That's what Gecko does afaict. I don't think we special-case inlines either, just return a matrix for those also<br>
&lt;fantasai> emilio: if there's no box, we use an empty rect and carry on<br>
&lt;fantasai> emilio: Could return computed value instead, that's what we do for a lot of other properties when they don't have a box<br>
&lt;fantasai> emilio: would that break stuff?<br>
&lt;fantasai> dbaron: I don't know if anyone tried to ship that<br>
&lt;fantasai> dbaron: Worried since it parses so differently from the other values<br>
&lt;fantasai> emilio: My preference is between those two<br>
&lt;fantasai> emilio: using transform with empty rect seems more useful than 'none', gives you the right answer most times<br>
&lt;fantasai> fantasai: but wrong answer sometimes<br>
&lt;fantasai> dbaron: Blink does 'none' for case of not having a box. Don't think that's what it does for inlines.<br>
&lt;fantasai> TabAtkins: returns a matrix. it's kinda weird<br>
&lt;fantasai> [seems to be resolved against zero]<br>
&lt;fantasai> Rossen_: You mentioned a compat issue in WebKit?<br>
&lt;fantasai> kbabbitt: That was my interpretationof the prior comments in the issue<br>
&lt;kbabbitt> https://github.com/w3c/csswg-drafts/issues/9121#issuecomment-1691139831<br>
&lt;fantasai> emilio: that looks like breakage if returning a function list<br>
&lt;TabAtkins> (doing `display:block; transform:translate(50%)`, you get `matrix(1,0,0,1,NNN,0)` where NNN is a correct px value. In chrome, `display:inline; transform:translate(50%)` returns `matrix(1,0,0,1,0,0)`.<br>
&lt;fantasai> fantasai: Problem with matrix is that you might think you have the transform, but you don't when you display the box it'll resolve to something else<br>
&lt;fantasai> emilio: that's true if you change width or height<br>
&lt;fantasai> dbaron: If we think doing the matrix does more sense, and I probably lean that way, given Gecko's behavior it seems like something we could try<br>
&lt;fantasai> fantasai: It's not unreasonable answer, not thrilled that it could be misleading<br>
&lt;fantasai> Rossen_: Then let's resolve on the matrix behavior, and see what happens<br>
&lt;fantasai> Rossen_: since no objections<br>
&lt;fantasai> fantasai: Do we resolve on this for both inline and none?<br>
&lt;fantasai> dbaron: Already iimplemented in Blink and Gecko<br>
&lt;fantasai> fantasai: but is it in the spec<br>
&lt;fantasai> dbaron: probably not, so should spec it<br>
&lt;fantasai> dbaron: So for display:none and non-transformable boxes, compute a matrix against 0x0 box.<br>
&lt;emilio> q+<br>
&lt;fantasai> Rossen_: does that include tables?<br>
&lt;kbabbitt> s/tables/table parts/<br>
&lt;fantasai> dbaron: Ignoring SVG, non-transformable would be non-replaced inlines, table columns, and table column groups<br>
&lt;Rossen_> ack emilio<br>
&lt;fantasai> emilio: I prefer a separate resolution for none, because Gecko resolves percentages on inlines against something<br>
&lt;fantasai> dbaron: Chrome does 0x0 on inlines<br>
&lt;fantasai> emilio: ok, we can adopt that<br>
&lt;fantasai> fantasai: I would prefer doing something consistent<br>
&lt;fantasai> emilio: so we'll swap around some engine behaviors<br>
&lt;dbaron> emilio: Gecko uses a size for inlines<br>
&lt;fantasai> PROPOSED: non-transformable elements and elements without a box return a matrix() resolved against a 0x0 box<br>
&lt;fantasai> TabAtkins: Table column elements return 'none'<br>
&lt;fantasai> TabAtkins tests some stuff and is confused<br>
&lt;TabAtkins> &lt;!DOCTYPE html><br>
&lt;TabAtkins> &lt;table>&lt;col style="transform: translate(50%);">&lt;/col>&lt;/table><br>
&lt;TabAtkins> &lt;script><br>
&lt;TabAtkins> w(getComputedStyle(document.querySelector("col")).transform);<br>
&lt;TabAtkins> &lt;/script><br>
&lt;fantasai> RESOLVED: non-transformable elements and elements without a box return a matrix() resolved against a 0x0 box<br>
</details>


-- 
GitHub Notification of comment by css-meeting-bot
Please view or discuss this issue at https://github.com/w3c/csswg-drafts/issues/9121#issuecomment-1942886970 using your GitHub account


-- 
Sent via github-notify-ml as configured in https://github.com/w3c/github-notify-ml-config

Received on Wednesday, 14 February 2024 00:13:19 UTC