Closed Bug 1924786 Opened 2 years ago Closed 10 months ago

Extend anchor positioning support to work in CSS grid

Categories

(Core :: Layout, enhancement, P3)

enhancement

Tracking

()

VERIFIED FIXED
148 Branch
Tracking Status
firefox147 --- verified
firefox148 --- verified

People

(Reporter: jwatt, Assigned: emilio)

References

(Blocks 1 open bug)

Details

(Whiteboard: [anchorpositioning:2026], [wptsync upstream])

Attachments

(5 files, 1 external file, 1 obsolete file)

There is some specific code in grid that will need some work.

Note that the effective containing block rectangle modifications due to Anchor Positioning are to be applied after any changes that grid-placement properties make to the containing block rectangle:

https://drafts.csswg.org/css-position/#original-cb

Whiteboard: [anchorpositioning:m1]
Whiteboard: [anchorpositioning:m1] → [anchorpositioning:pickup]
Whiteboard: [anchorpositioning:pickup] → [anchorpositioning:m1][anchorpositioning:pickup]
Whiteboard: [anchorpositioning:m1][anchorpositioning:pickup] → [anchorpositioning:m2][anchorpositioning:pickup]
Attached file Demonstrative case —

(Still need additional work to properly take this account, as demonstrated by the attached testcase)

OTOH, alignment area adjustment for grid seems to work ok with anchor positioning.

Whiteboard: [anchorpositioning:m2][anchorpositioning:pickup] → [anchorpositioning:backlog][anchorpositioning:pickup]
Duplicate of this bug: 1990901
Duplicate of this bug: 1991710
Assignee: nobody → mozmail
Whiteboard: [anchorpositioning:backlog][anchorpositioning:pickup] → [anchorpositioning:m3][anchorpositioning:pickup]
Status: NEW → ASSIGNED
Blocks: 2003745
Assignee: mozmail → emilio

As per https://drafts.csswg.org/css-position/#original-cb they should
happen later (and thus take priority).

Give a reasonable CB (the grid container's padding rect) down from grid
layout now that we might not use the actual grid CB.

As per https://drafts.csswg.org/css-position/#original-cb they should
happen later (and thus take priority).

Give a reasonable CB (the grid container's padding rect) down from grid
layout now that we might not use the actual grid CB.

Remove a check for fallbacks that isn't needed since part 1 of
bug 1991929.

Attachment #9531326 - Attachment is obsolete: true
Blocks: 2004596
Pushed by ealvarez@mozilla.com: https://github.com/mozilla-firefox/firefox/commit/bc04f15c3ab9 https://hg.mozilla.org/integration/autoland/rev/4cc06d49690f Make position-area and default-anchor adjustments take priority over CSS grid CB. r=layout-anchor-positioning-reviewers,layout-reviewers,dshin
Pushed by nfay@mozilla.com: https://github.com/mozilla-firefox/firefox/commit/e64ec5367997 https://hg.mozilla.org/integration/autoland/rev/e5686d435ec5 Revert "Bug 1924786 - Make position-area and default-anchor adjustments take priority over CSS grid CB. r=layout-anchor-positioning-reviewers,layout-reviewers,dshin" for causing wpt failures on align-self-default-overflow-htb-ltr-htb.html

Backed out for causing wpt failures on align-self-default-overflow-htb-ltr-htb.html

Backout link

Push with failures

Failure log

Edit: Changeset relanded as the culprit is another bug.

Flags: needinfo?(emilio)
Flags: needinfo?(emilio)
Pushed by chorotan@mozilla.com: https://github.com/mozilla-firefox/firefox/commit/36a152949e5e https://hg.mozilla.org/integration/autoland/rev/12c7da0e492f Make position-area and default-anchor adjustments take priority over CSS grid CB. r=layout-anchor-positioning-reviewers,layout-reviewers,dshin
Created web-platform-tests PR https://github.com/web-platform-tests/wpt/pull/56558 for changes under testing/web-platform/tests
Whiteboard: [anchorpositioning:m3][anchorpositioning:pickup] → [anchorpositioning:m3][anchorpositioning:pickup], [wptsync upstream]
Duplicate of this bug: 2004544
Status: ASSIGNED → RESOLVED
Closed: 10 months ago
Resolution: --- → FIXED
Target Milestone: --- → 148 Branch
Upstream PR merged by moz-wptsync-bot

Comment on attachment 9531327 [details]
Bug 1924786 - Make position-area and default-anchor adjustments take priority over CSS grid CB. r=#anchor-pos,#layout

Beta/Release Uplift Approval Request

  • User impact if declined/Reason for urgency: Fixes anchor positioning broken sites. This didn't make it before the soft-freeze because of backout.
  • Is this code covered by automated tests?: Yes
  • Has the fix been verified in Nightly?: Yes
  • Needs manual test from QE?: Yes
  • If yes, steps to reproduce: See blocked bugs.
  • List of other uplifts needed: none
  • Risk to taking this patch: Low
  • Why is the change risky/not risky? (and alternatives if risky): Trivial, anchor-positioning-specific change.
  • String changes made/needed: none
  • Is Android affected?: Yes
Attachment #9531327 - Flags: approval-mozilla-beta?
Flags: qe-verify+
Flags: in-testsuite+

Comment on attachment 9531327 [details]
Bug 1924786 - Make position-area and default-anchor adjustments take priority over CSS grid CB. r=#anchor-pos,#layout

Approved for 147.0b2.

Attachment #9531327 - Flags: approval-mozilla-beta? → approval-mozilla-beta+
QA Whiteboard: [uplift] [qa-ver-needed-c148/b147]

Hi Emilio,
Could you provide QA Android team some steps to verify this?
Thank you!

Flags: needinfo?(emilio)

Sure, see bug 2003745. Before this change the blue element always takes the whole space. Note that it still won't match other browsers (because of bug 1991929), but with this patch the site works better.

Flags: needinfo?(emilio)
Attached image 1924786.jpg —

Verified as fixed on the Firefox for Android Nightly 148.0a1 from 12/9 using a Samsung Galaxy A56 (Android 16), following these steps"

  1. Navigate to: https://chrome.dev/anchor-tool/.
  2. Observe the "Hello, I am the positioned element!" area.

I've attached a screenshot from beta, for comparison.

Verified as fixed also on Firefox for Android Beta 147.0b2 with a Samsung Galaxy Note 8 (Android 9), and Xiaomi Poco X7 Pro (Android 15).

Status: RESOLVED → VERIFIED
Flags: qe-verify+

Also tested on Firefox Desktop, latest Nightly 148.0a1 and 147 Beta 2. Here are the results:

  • TC 1, TC 2 and TC 3 are now correctly displayed (compared with Firefox 146RC and Chrome)
  • https://anchor-tool.com/ no longer shows " Your browser does not support the CSS anchor positioning API. This tool is for demonstration purposes only. " warning, the blue element takes more space than before, and the "?" is now right under it.

Emilio, could you please take a look at the attached screenshot? Apart from the blue "Hello, I am the positioned element!" blue element, which takes more space when the browser width is not reduced (normal window), everything looks fine from QA perspective.
Thank you!

Flags: needinfo?(emilio)

That's expected, and covered by bug 1991929. Thanks!

Flags: needinfo?(emilio)

(In reply to Emilio Cobos Álvarez [:emilio] from comment #24)

That's expected, and covered by bug 1991929. Thanks!

Thank you! Verification is now complete on Firefox 147 beta 2 and Nightly 148.0a1 across platforms.

I can confirm that latest Nightly 148.0a1 (20251211210236) contains the fix for the blue element.

QA Whiteboard: [uplift] [qa-ver-needed-c148/b147] → [uplift] [qa-ver-done-c148/b147]
Whiteboard: [anchorpositioning:m3][anchorpositioning:pickup], [wptsync upstream] → [anchorpositioning:2026], [wptsync upstream]
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: