Closed Bug 1914178 Opened 1 year ago Closed 1 year ago

scroll-snap not working on empty sized generated content

Categories

(Core :: Layout: Scrolling and Overflow, defect, P3)

Firefox 131
defect

Tracking

()

RESOLVED FIXED
132 Branch
Tracking Status
firefox132 --- fixed

People

(Reporter: bramus, Assigned: hiro)

Details

Attachments

(2 files)

User Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/127.0.0.0 Safari/537.36

Steps to reproduce:

The scroll-snap spec includes ^1 the following example on how to make sure an element remains snapped at the bottom

.log {
  scroll-snap-type: y proximity;
  align-content: end;
}
.log::after {
  display: block;
  content: "";
  scroll-snap-align: end;
}

Actual results:

When building a demo that uses this CSS ^2, it does not seem to work in Firefox – see attached recording - whereas in other browsers (Chrome/Safari) it does.

Expected results:

As per spec, this example should work.

Noteworthy is that when changing the snapping from ::after to :last-child ^3, it does work fine. This leads me to the conclusion that scrol-snapping does not work properly on generated content.

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

For more information, please visit BugBot documentation.

Flags: needinfo?(hikezoe.birchill)

Thanks Bramus for filing this issue.

To be precise what the real problem is that the generated content in question is empty sized because of content: "", if the property is something like content: "after", then things work fine.

The problem in code is here in ScrollSnapInfo::ForEachValidTargetFor, we use BaseRect::Intersects which unfortunately returns false for empty size rectangle.

Flags: needinfo?(hikezoe.birchill)
Summary: scroll-snap not working on generated content → scroll-snap not working on empty sized generated content

Also this change treats edge cases
(e.g. snappedPort.x == target.mSnapArea.XMost()) as valid, I think it would be
better results.

Assignee: nobody → hikezoe.birchill
Status: UNCONFIRMED → ASSIGNED
Ever confirmed: true
Severity: -- → S3
Priority: -- → P3

Thanks for digging into this, Hiroyuki. It’s clear to me now that authors can add something like min-height: 1px to the generated content in order to work around this bug.

Pushed by hikezoe.birchill@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/4901f46fe69d Handle empty sized contents as valid targtes for CSS scroll snap. r=emilio
Created web-platform-tests PR https://github.com/web-platform-tests/wpt/pull/48092 for changes under testing/web-platform/tests
Status: ASSIGNED → RESOLVED
Closed: 1 year ago
Resolution: --- → FIXED
Target Milestone: --- → 132 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: