Closed Bug 1835179 Opened 1 year ago Closed 1 year ago

Container query units incorrectly cached based on their values, not on their containers

Categories

(Core :: Layout, defect)

Firefox 113
defect

Tracking

()

RESOLVED FIXED
116 Branch
Tracking Status
firefox116 --- fixed

People

(Reporter: kizmarh, Assigned: emilio, NeedInfo)

Details

Attachments

(3 files)

User Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:109.0) Gecko/20100101 Firefox/113.0

Steps to reproduce:

Add several containers with different sizes, with elements inside having the same dimensions set with container query length units.

CodePen to reproduce: https://codepen.io/kizu/pen/mdzoGeP (also attaching the saved html page to this report)

Example code:

<div style="width: 100px; height: 50px; container-type: size; border: 1px solid;">
  <div style="background: pink; width: 100cqi; height: 100cqb"></div>
</div>

<div style="width: 200px; height: 75px; container-type: size; border: 1px solid;">
  <div style="background: pink; width: 100cqi; height: 100cqb"></div>
</div>

Actual results:

When the same values for the container query length units are used for elements in different containers, it seems that they share the cache based on the units, but not based on containers, making it so elements that should have different dimensions get the same dimensions.

Expected results:

Elements with the same dimensions expressed in container query length units should have different dimensions when placed into different containers.

Attaching the screenshot showing the result in Chrome on the left (expected) and in Firefox on the right (buggy).

As an additional note: found a workaround for this issue by adding an animation that runs once for the element with the container query units — changes to the element seem to “fix” the issue, so maybe this “caching” is only done the first time the elements are rendered?

Flags: needinfo?(emilio)

At least when the containers are different.

For now check that by doing a somewhat simplified test (checking
sibling-ness).

The new flag can be useful to optimize container query restyles on
resizes too, in the future.

Assignee: nobody → emilio
Status: UNCONFIRMED → ASSIGNED
Ever confirmed: true

So the minimal test-case it's already fixed on Nightly, that's bug 1832481. But there seems to be an extra issue, due to style reuse from the style sharing cache. Fixing is straight-forward.

Flags: needinfo?(emilio)

The severity field is not set for this bug.
:dholbert, could you have a look please?

For more information, please visit BugBot documentation.

Flags: needinfo?(dholbert)
Pushed by ealvarez@mozilla.com:
https://hg.mozilla.org/integration/autoland/rev/ea7bbf2bed81
Container units should prevent us from sharing style by rule node. r=dshin
Created web-platform-tests PR https://github.com/web-platform-tests/wpt/pull/40533 for changes under testing/web-platform/tests
Status: ASSIGNED → RESOLVED
Closed: 1 year ago
Resolution: --- → FIXED
Target Milestone: --- → 116 Branch
Upstream PR merged by moz-wptsync-bot
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: