Bug 256178

Summary: Container query length units use border box instead of a content box
Product: WebKit Reporter: Roman Komarov <kizmarh>
Component: CSSAssignee: Antti Koivisto <koivisto>
Status: RESOLVED FIXED    
Severity: Normal CC: karlcow, koivisto, ntim, simon.fraser, webkit-bug-importer, zalan
Priority: P2 Keywords: BrowserCompat, InRadar
Version: Safari 16   
Hardware: Unspecified   
OS: Unspecified   
See Also: https://github.com/web-platform-tests/wpt/pull/39807
Attachments:
Description Flags
HTML with the bug reproduced, saved from CodePen none

Description Roman Komarov 2023-05-01 13:52:14 PDT
Created attachment 466160 [details]
HTML with the bug reproduced, saved from CodePen

Per specs, container query length units should be evaluated relative to the query container's **content box**, while currently they're evaluated relative to the border box.

Link to reproduce: https://codepen.io/kizu/pen/ExdwZaB — the square in it should be of a lime color, as with the content box of the container have 0x0 dimensions, but in Safari the units get evaluated related to the border box, so we can see the red square (the HTML from this example is also attached to this report as a file)

This example works correctly in Chrome and Firefox.

Spec quote from https://www.w3.org/TR/css-contain-3/#container-query-length

> For each element, container query length units are evaluated as container size queries on the relevant axis (or axes) described by the unit.

Spec quotes from https://www.w3.org/TR/css-contain-3/#container-size-query

> The width container feature queries the width of the query container’s content box.
> The height container feature queries the height of the query container’s content box.
> The inline-size container feature queries the size of the query container’s content box in the query container’s inline axis.
> The block-size container feature queries the size of the query container’s content box in the query container’s block axis.
Comment 1 Tim Nguyen (:ntim) 2023-05-01 13:59:51 PDT
Consider contributing this testcase to web platform tests as a reftest in case you haven't: https://github.com/web-platform-tests/wpt
Comment 2 Radar WebKit Bug Importer 2023-05-01 14:00:21 PDT
<rdar://problem/108754549>
Comment 3 Antti Koivisto 2023-05-02 09:07:43 PDT
Pull request: https://github.com/WebKit/WebKit/pull/13364
Comment 4 Antti Koivisto 2023-05-02 09:15:09 PDT
Submitted web-platform-tests pull request: https://github.com/web-platform-tests/wpt/pull/39807
Comment 5 EWS 2023-05-02 10:22:07 PDT
Committed 263595@main (e31e2eb9806e): <https://commits.webkit.org/263595@main>

Reviewed commits have been landed. Closing PR #13364 and removing active labels.