Re: [csswg-drafts] [css-zoom?] Zoom and CSSOM (#9398)

The CSS Working Group just discussed `[css-zoom?] Zoom and CSSOM`, and agreed to the following:

* `RESOLVED: getComputedStyle() returns unzoomed value`
* `RESOLVED: APIs that return bounding boxes such as getClientRects and ResizeObserver and IntersectionObserver return values in page-global px units`
* `RESOLVED: s/ResizeObserver/getBoundingClientRect/`

<details><summary>The full IRC log of that discussion</summary>
&lt;fantasai> emilio: Variety of things in current browsers consistently account for zoom<br>
&lt;fantasai> emilio: I think we have consensus that anything with a position and getComputedStyle shouldn't account for zoom<br>
&lt;fantasai> emilio: would like to resolve on that<br>
&lt;chrishtr> +1 to that proposed resolution<br>
&lt;fantasai> emilio: some smaller things like clientWidth can multiple zoom<br>
&lt;fantasai> emilio: my feeling is, the less APIs account for zoom the better<br>
&lt;fantasai> emilio: It seems getClientRect and ResizeObserver don't have a lot of compat constraints<br>
&lt;Rossen_> q?<br>
&lt;fantasai> chrishtr: My guess is compat restrictions are low<br>
&lt;fantasai> chrishtr: most users not using these APIs<br>
&lt;fantasai> Rossen_: starting with a more restricted set is easier to expand than the other way around<br>
&lt;fantasai> chrishtr: WebKit and Chromium both implement the undesired behavior that emilio wants to change in this resolution<br>
&lt;fantasai> chrishtr: From my perspective, chromium happy to change, don't think we have compat risk<br>
&lt;emilio> fantasai: just checking if i understand correctly<br>
&lt;Rossen_> fantasai: just to check, we should zoom or not in getComputedStyle<br>
&lt;fantasai> emilio: if unzoomed size is 100px, and zoom is 2, gCS will return 100px to preserve round-tripping<br>
&lt;fantasai> RESOLVED: getComputedStyle() returns unzoomed value<br>
&lt;fantasai> so that it round-trips<br>
&lt;flackr> q+<br>
&lt;fantasai> Rossen_: next, the rest of the APIs will return zoomed values<br>
&lt;Rossen_> ack fantasai<br>
&lt;Rossen_> ack flackr<br>
&lt;fantasai> flackr: I think that makes sense for things like getBoundingClientRect<br>
&lt;fantasai> flackr: not so sure about offsetTop<br>
&lt;fantasai> flackr: typically those are used to position things within the same parent, which has the zoom applied<br>
&lt;fantasai> flackr: so maybe it should apply any zoom that exists on that element, but not the zoom all the way to the screen<br>
&lt;fantasai> emilio: problem is that positions cross zoom boundaries<br>
&lt;fantasai> emilio: anything that has an offset, left or right, is not relative to a particular element. Or can be relative to elements with different effective zooms.<br>
&lt;fantasai> emilio: whatever you do, if it crosses the zoom boundary, it's going to be wrong for some use cases<br>
&lt;fantasai> emilio: so I'd like to not unzoom stuff that contains positions at all<br>
&lt;fantasai> flackr: so to make sure I understand, you're saying it'll apply all of the ancestor zooms<br>
&lt;fantasai> emilio: it would return unzoomed CSS px, depends what it's relative to<br>
&lt;fantasai> emilio: it would return zoom-independent CSS pixels, if that makes sense<br>
&lt;fantasai> emilio: we don't have that concept in the spec... but that's effectively the thing that gets stored in the computed style<br>
&lt;fantasai> flackr: same true of offsetWidth/Height ...<br>
&lt;fantasai> flackr: I think this will be hard to work with if not in the same space as the element you're working with<br>
&lt;TabAtkins> I think the general point is that people shouldn't be using zoom anyway...<br>
&lt;fantasai> emilio: if the position is relative to somehting with a different effective zoom, it's wrong either way<br>
&lt;fantasai> emilio: there's no good thing to return, you cannot say it's really 2x zoom 100px + ...<br>
&lt;TabAtkins> The closer zoom is to a scale() the better imo.<br>
&lt;fantasai> emilio: Idk how you'd return sensible values if you're crossing a zoom boundary<br>
&lt;fantasai> emilio: returning unzoomed values is returning in a coordinate space that the whole page understands<br>
&lt;fantasai> flackr: My proposal would be that it returns in the element's own coordinate space<br>
&lt;fantasai> flackr: developer could determine what conversion is necessary if moving to a different space<br>
&lt;fantasai> flackr: but if e.g. applying to sibling with same ancestor zoom, can use the styles direction<br>
&lt;fantasai> s/direction/directly<br>
&lt;Rossen_> q?<br>
&lt;fantasai> flackr: e.g. set style.left = otherElementOffsetWidth<br>
&lt;fantasai> emilio: [missed]<br>
&lt;fantasai> flackr: [missed]<br>
&lt;fantasai> flackr: if multiplied by the zoom of the parent, but global zoom seems hard to work with<br>
&lt;fantasai> [flackr said something about how people write code with this]<br>
&lt;fantasai> Rossen_: [repeats Tab's comment about analogy with scale()]<br>
&lt;fantasai> Rossen_: seems like this needs more discussion?<br>
&lt;chrishtr> q+<br>
&lt;fantasai> flackr: I still have some concerns<br>
&lt;fantasai> emilio: can we resolve on things that return client rects [missed]<br>
&lt;Rossen_> ack chrishtr<br>
&lt;fantasai> chrishtr: I agree that we should resolve on things that return client rects returning those in the physical pixel space, considering zoom<br>
&lt;fantasai> chrishtr: in addition, I think we should work through some examples in the issue to see what works best for offsetTop etc.<br>
&lt;vmpstr> can we think of good terminology for these spaces?<br>
&lt;fantasai> chrishtr: I think this feature has direct value to developers, and we shouldn't consider a sad compat compromise<br>
&lt;fantasai> Rossen_: 100% agree<br>
&lt;fantasai> Rossen_: proposed resolution is, apply unzoomed value results to all bounding-box returning APIs<br>
&lt;fantasai> fantasai: this is the global coordinate system?<br>
&lt;fantasai> emilio: yeah. Let's call it global px values or something<br>
&lt;fantasai> Rossen_: page px values<br>
&lt;fantasai> RESOLVED: APIs that return bounding boxes such as getClientRects and ResizeObserver and IntersectionObserver return values in page-global px units<br>
&lt;PaulG> q+<br>
&lt;fantasai> s/units/unit coords/<br>
&lt;Rossen_> ack PaulG<br>
&lt;fantasai> PaulG: I'm concerned, if a dev wants to assess if an element is covered or visibible in the viewport, will struggle with that<br>
&lt;fantasai> PaulG: if they get it wrong, has a11y impact<br>
&lt;fantasai> emilio: for that use case, what we just resolved on is what we want<br>
&lt;fantasai> PaulG: I think so too, will review with APA<br>
&lt;chrishtr> q+<br>
&lt;Rossen_> ack chrishtr<br>
&lt;fantasai> chrishtr: Checking in on ResizeObserver, that returns offsetWidth-ish things?<br>
&lt;fantasai> chrishtr: should we exclude from resolution?<br>
&lt;fantasai> emilio: is content box relative to the element?<br>
&lt;fantasai> chrishtr: I think it is<br>
&lt;fantasai> RESOLVED: s/ResizeObserver/getBoundingClientRect/<br>
</details>


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


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

Received on Wednesday, 29 November 2023 17:27:48 UTC