RESOLVED FIXED Bug 218076
Make scroll-margin independent of scroll snapping and have it apply when scrolling to anchors
https://bugs.webkit.org/show_bug.cgi?id=218076
Summary Make scroll-margin independent of scroll snapping and have it apply when scro...
Martin Robinson
Reported 2020-10-22 03:45:35 PDT
The latest version of the CSS Scroll Snap specification says that scroll-margin should be available independently of scroll snap and it should apply when scrolling to anchors and targets of scrollIntoView(). See https://drafts.csswg.org/css-scroll-snap-1/#scroll-margin.
Attachments
Patch (25.19 KB, patch)
2020-10-28 04:50 PDT, Martin Robinson
no flags
Patch (26.58 KB, patch)
2020-10-28 05:07 PDT, Martin Robinson
ews-feeder: commit-queue-
Patch (26.75 KB, patch)
2020-10-28 06:26 PDT, Martin Robinson
no flags
Patch (28.87 KB, patch)
2020-10-29 01:40 PDT, Martin Robinson
no flags
Patch (29.17 KB, patch)
2020-10-29 03:51 PDT, Martin Robinson
no flags
Martin Robinson
Comment 1 2020-10-28 04:50:15 PDT
Martin Robinson
Comment 2 2020-10-28 05:07:33 PDT
Martin Robinson
Comment 3 2020-10-28 06:26:51 PDT
Simon Fraser (smfr)
Comment 4 2020-10-28 09:29:14 PDT
Comment on attachment 412524 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=412524&action=review > Source/WebCore/rendering/RenderBox.cpp:5070 > + const LayoutSize boxSize = size(); > + const LayoutBoxExtent margin( > + valueForLength(scrollMargin.top(), boxSize.height()), > + valueForLength(scrollMargin.right(), boxSize.width()), > + valueForLength(scrollMargin.bottom(), boxSize.height()), > + valueForLength(scrollMargin.left(), boxSize.width())); > + anchorRect.expand(margin); This doesn't take into account transforms in the ancestor chain. Seems like you need to take margins into account before the localToAbsolute computation, I think? What's the expected behavior with transforms?
Martin Robinson
Comment 5 2020-10-28 09:33:17 PDT
(In reply to Simon Fraser (smfr) from comment #4) > Comment on attachment 412524 [details] > Patch > > View in context: > https://bugs.webkit.org/attachment.cgi?id=412524&action=review > > > Source/WebCore/rendering/RenderBox.cpp:5070 > > + const LayoutSize boxSize = size(); > > + const LayoutBoxExtent margin( > > + valueForLength(scrollMargin.top(), boxSize.height()), > > + valueForLength(scrollMargin.right(), boxSize.width()), > > + valueForLength(scrollMargin.bottom(), boxSize.height()), > > + valueForLength(scrollMargin.left(), boxSize.width())); > > + anchorRect.expand(margin); > > This doesn't take into account transforms in the ancestor chain. Seems like > you need to take margins into account before the localToAbsolute > computation, I think? What's the expected behavior with transforms? I was a bit surprised by this at first, but, unless I am misunderstanding, it seems like this margin should be added in the coordinate system of the scroll container. The scroll-margin spec [1] says: "Values represent outsets defining the scroll snap area that is used for snapping this box to the snapport. The scroll snap area is determined by taking the transformed border box, finding its rectangular bounding box (axis-aligned in the scroll container’s coordinate space), then adding the specified outsets." 1. https://drafts.csswg.org/css-scroll-snap-1/#scroll-margin
Simon Fraser (smfr)
Comment 6 2020-10-28 09:47:06 PDT
Comment on attachment 412524 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=412524&action=review >>> Source/WebCore/rendering/RenderBox.cpp:5070 >>> + anchorRect.expand(margin); >> >> This doesn't take into account transforms in the ancestor chain. Seems like you need to take margins into account before the localToAbsolute computation, I think? What's the expected behavior with transforms? > > I was a bit surprised by this at first, but, unless I am misunderstanding, it seems like this margin should be added in the coordinate system of the scroll container. The scroll-margin spec [1] says: > > "Values represent outsets defining the scroll snap area that is used for snapping this box to the snapport. The scroll snap area is determined by taking the transformed border box, finding its rectangular bounding box (axis-aligned in the scroll container’s coordinate space), then adding the specified outsets." > > 1. https://drafts.csswg.org/css-scroll-snap-1/#scroll-margin Huh, I guess that's clear. Probably add a comment linking to that then.
Martin Robinson
Comment 7 2020-10-29 01:40:57 PDT
Radar WebKit Bug Importer
Comment 8 2020-10-29 03:46:16 PDT
Martin Robinson
Comment 9 2020-10-29 03:51:45 PDT
EWS
Comment 10 2020-10-29 04:02:16 PDT
EWS
Comment 11 2020-10-29 04:37:25 PDT
Committed r269144: <https://trac.webkit.org/changeset/269144> All reviewed patches have been landed. Closing bug and clearing flags on attachment 412631 [details].
dakur
Comment 12 2020-10-29 05:16:29 PDT
Thank you guys very much for finally quick fix! Any ideas when it may land in user lands?
Note You need to log in before you can comment on or make changes to this bug.