Closed Bug 2050613 Opened 4 days ago Closed 2 days ago

position-area block-axis center not scroll-compensated in position-try fit check (copy-paste in GetScrollCompensatedSidesFor)

Categories

(Core :: Layout: Positioned, defect)

defect

Tracking

()

RESOLVED FIXED
154 Branch
Tracking Status
firefox154 --- fixed

People

(Reporter: Sylvestre, Assigned: Sylvestre)

References

(Blocks 1 open bug)

Details

Attachments

(4 files)

GetScrollCompensatedSidesFor (layout/generic/AbsoluteContainingBlock.cpp) has a copy-paste error: the block-axis Center branch tests aPositionArea.first instead of aPositionArea.second (the two branches above it correctly test .second).

So when a position-area uses center on the block axis with a non-center inline keyword (e.g. left center), eTopBottom is never added to mScrollCompensatedSides. That field feeds FitsInContainingBlock (the position-try fit check): after the anchor scrolls, the element is measured against the full containing-block height instead of the center band, so an oversized anchored element is wrongly judged to fit and the position-try fallback that should apply is skipped.

Fix: test aPositionArea.second in the Center branch. Added a WPT regression test (css/css-anchor-position/anchor-position-area-center-scroll-fallback.html); verified on local builds that it fails before the fix and passes after, and matches Chrome's behavior.

Found by Coverity (CID 1678404).

Attached image fx nightly
Attached image chromium
Assignee: nobody → sledru
Attached file test case

The vertical-axis Center branch tested aPositionArea.first (copy-pasted
from the horizontal block) instead of aPositionArea.second, so a vertical
center was never detected for anchor-positioned elements.
+add a test

Pushed by sledru@mozilla.com: https://github.com/mozilla-firefox/firefox/commit/f78bb5507e15 https://hg.mozilla.org/integration/autoland/rev/d6d3de961526 Fix axis mixup in GetScrollCompensatedSidesFor (Coverity CID 1678404) r=layout-reviewers,dshin

Created web-platform-tests PR https://github.com/web-platform-tests/wpt/pull/60935 for changes under testing/web-platform/tests

Status: NEW → RESOLVED
Closed: 2 days ago
Resolution: --- → FIXED
Target Milestone: --- → 154 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

Created:
Updated:
Size: