Closed Bug 1989059 Opened 6 months ago Closed 3 months ago

Implement `position-try-order` for anchor fallbacks.

Categories

(Core :: CSS Parsing and Computation, enhancement)

enhancement
Points:
5

Tracking

()

RESOLVED FIXED
148 Branch
Tracking Status
relnote-firefox --- 148+
firefox147 --- fixed
firefox148 --- fixed

People

(Reporter: dshin, Assigned: jfkthame)

References

(Blocks 3 open bugs, )

Details

(Keywords: dev-doc-complete, Whiteboard: [anchorpositioning:continuation], [wptsync upstream])

Attachments

(6 files)

This property introduces a step where we compute inset-modified containing block of all fallbacks and sort fallbacks based on that. This implies resolution of all inset properties and position-area. Note that the grid area computed by position-area is considered IMCB, as per position-try-order-position-area.html.

InterOp 2025 WPT:

  • position-try-order-basic.html
  • position-try-order-position-area.html

Naive implementation of this shouldn't be hard - We have everything we need to resolve these. Since @position-try can change the default anchor, this could get expensive, though.

Main work will be to factor out function for computation of IMCB, resolving inset and position-area properties (& associated anchor references, plus position-anchor), which then can be used as a comparator to sort the fallbacks.

Whiteboard: [anchorpositioning:triage] → [anchorpositioning:reserve]
Whiteboard: [anchorpositioning:reserve] → [anchorpositioning:m3]
Whiteboard: [anchorpositioning:m3] → [anchorpositioning:m3][anchorpositioning:continuation]
Whiteboard: [anchorpositioning:m3][anchorpositioning:continuation] → [anchorpositioning:continuation]
Points: --- → 5

Although this is 5 points of effort, per the interop-2025 bug, this would get us quite a few points if it fixes all of these:

  • parsing/ (3 tests worth of points)
  • property-interpolations.html
  • position-try-order-basic.html
  • position-try-order-position-area.html
Whiteboard: [anchorpositioning:continuation] → [anchorpositioning:reserve]
Assignee: nobody → jfkthame
Status: NEW → ASSIGNED

This test seems questionable as written, because the anchored box fits at its "base" position
without overflowing the IMCB, and therefore there doesn't seem to be any justification for
applying fallbacks at all (see also https://github.com/w3c/csswg-drafts/issues/13268).

This patch forces fallbacks to be considered in all cases, by ensuring the base position always
overflows and then providing a fallback that matches the "original" (non-overflowing) base position;
then the browser will choose between this and the flipped fallback according to the specified
position-try-order and writing modes involved.

Blocks: 2007813
Pushed by jkew@mozilla.com: https://github.com/mozilla-firefox/firefox/commit/f9538b019e72 https://hg.mozilla.org/integration/autoland/rev/fa41b29265c4 Account for position-try-order when choosing position fallback. r=layout-anchor-positioning-reviewers,layout-reviewers,emilio https://github.com/mozilla-firefox/firefox/commit/a9184ac28d5d https://hg.mozilla.org/integration/autoland/rev/39886ca6f78a Fix up position-try-order-logical testcase to force overflow & fallback to happen. r=layout-anchor-positioning-reviewers,emilio https://github.com/mozilla-firefox/firefox/commit/b3c5c336322f https://hg.mozilla.org/integration/autoland/rev/b8e959d3f3c8 Enable the position-try-order property. r=layout-anchor-positioning-reviewers,emilio
Created web-platform-tests PR https://github.com/web-platform-tests/wpt/pull/56931 for changes under testing/web-platform/tests
Whiteboard: [anchorpositioning:reserve] → [anchorpositioning:reserve], [wptsync upstream]
Status: ASSIGNED → RESOLVED
Closed: 3 months ago
Resolution: --- → FIXED
Target Milestone: --- → 148 Branch
Whiteboard: [anchorpositioning:reserve], [wptsync upstream] → [anchorpositioning:continuation], [wptsync upstream]

[Why is this notable]: Part of CSS Anchor Positioning
[Affects Firefox for Android]: yes
[Suggested wording]: Introduced the position-try-order property, which is part of CSS Anchor Positioning and allows to change the order the position fallback options are tried.
[Links (documentation, blog post, etc)]:
https://developer.mozilla.org/en-US/docs/Web/CSS/Reference/Properties/position-try-order
https://developer.mozilla.org/en-US/docs/Web/CSS/Guides/Anchor_positioning
https://developer.mozilla.org/en-US/docs/Web/CSS/Guides/Anchor_positioning/Using

relnote-firefox: --- → ?
Keywords: dev-doc-needed

Thanks, added to the Fx148 nightly release notes, please allow 30 minutes for the site to update.
Keeping the relnote-firefox flag as ? to keep it on the radar for inclusion in the final Fx148 release notes.

Upstream PR merged by moz-wptsync-bot
QA Whiteboard: [qa-triage-done-c149/b148]
Attachment #9539530 - Flags: approval-mozilla-release?

This test seems questionable as written, because the anchored box fits at its "base" position
without overflowing the IMCB, and therefore there doesn't seem to be any justification for
applying fallbacks at all (see also https://github.com/w3c/csswg-drafts/issues/13268).

This patch forces fallbacks to be considered in all cases, by ensuring the base position always
overflows and then providing a fallback that matches the "original" (non-overflowing) base position;
then the browser will choose between this and the flipped fallback according to the specified
position-try-order and writing modes involved.

Original Revision: https://phabricator.services.mozilla.com/D277557

Attachment #9539531 - Flags: approval-mozilla-release?
Attachment #9539532 - Flags: approval-mozilla-release?
Attachment #9539530 - Flags: approval-mozilla-release? → approval-mozilla-release+
Attachment #9539531 - Flags: approval-mozilla-release? → approval-mozilla-release+
Attachment #9539532 - Flags: approval-mozilla-release? → approval-mozilla-release+

Added to the final Fx148 release notes

Associate Pull Requests

You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: