W3C home > Mailing lists > Public > public-css-archive@w3.org > August 2021

[csswg-drafts] [cssom][css-break] getComputedStyle and fragmentation (#6513)

From: Florian Rivoal via GitHub <sysbot+gh@w3.org>
Date: Thu, 12 Aug 2021 12:35:26 +0000
To: public-css-archive@w3.org
Message-ID: <issues.opened-968739379-1628771725-sysbot+gh@w3.org>
frivoal has just created a new issue for https://github.com/w3c/csswg-drafts:

== [cssom][css-break] getComputedStyle and fragmentation ==
I could not find a defintion that states how `getComputedStyle()` is supposed to work for fragmented elements.

`getComputedStyle()` returns the resolved value. In some cases, that corresponds to the computed value, and in some cases that corresponds to the used value. Even when an element is fragmented, the computed value is clearly a per-element thing, but the way the used value is calculated from the computed value as part of layout and can, in some cases, differ per fragment. In such cases, I could not find any spec that says what getComputedStyle() is supposed to return. 

For many properties, the used value is equal to the computed value anyway, so for them there's no problem, but that's not always true. Most prominently, what about the `width` and `height` of fragmented block elements: should the used value of the height property be the height of the first fragment, or the sum of the height of all fragments (or something else)? Should the used value of the width be the that of the first fragment, or the sum, or the average? Should potentially orthogonal writing-modes make a difference? Should a different display type make a difference? More properties may have answers that vary per fragment, maybe due to percentages (see https://github.com/w3c/csswg-drafts/issues/6512) or to `box-decoration-break`.

I think the only answer we can consistently apply to all properties and all display types, regardless of writing-mode, box-decoration-break, etc, is to return the used value on the first fragment. We could special-case some situations to get sums or averages or other computations to derive one value from several, but that seems like a lot corner-case handling for no clear use-case.

In terms of current implementations, as far as I can tell Firefox does just return the values of the first fragment in all cases. Chrome and Safari seem to have special cased `block-size` (and whichever of `width` and `height` it maps to) to return a sum of all fragments.

If there's no compat constraint, I'd suggest standardizing on the simpler behavior of only taking into account the first fragment. If we do want to special case some properties, we should document them.

Please view or discuss this issue at https://github.com/w3c/csswg-drafts/issues/6513 using your GitHub account


-- 
Sent via github-notify-ml as configured in https://github.com/w3c/github-notify-ml-config
Received on Thursday, 12 August 2021 12:35:28 UTC

This archive was generated by hypermail 2.4.0 : Tuesday, 5 July 2022 06:42:42 UTC