Skip to content

Commit

Permalink
[scroll-anchoring] Contract owning scroller rect for scroll padding
Browse files Browse the repository at this point in the history
https://bugs.webkit.org/show_bug.cgi?id=262342
rdar://116209834

Reviewed by Simon Fraser.

Contract owning scroller rect for scroll padding.

* LayoutTests/imported/w3c/web-platform-tests/css/css-scroll-anchoring/scroll-padding-affects-anchoring-expected.txt:
* Source/WebCore/page/scrolling/ScrollAnchoringController.cpp:
(WebCore::ScrollAnchoringController::examineCandidate):

Canonical link: https://commits.webkit.org/270483@main
  • Loading branch information
nmoucht committed Nov 9, 2023
1 parent 385868a commit fd98410
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@

FAIL scroll anchoring accounts for scroll-padding assert_equals: Shouldn't anchor to #changer, since it's covered by scroll-padding expected 150 but got 50
PASS scroll anchoring accounts for scroll-padding

9 changes: 9 additions & 0 deletions Source/WebCore/page/scrolling/ScrollAnchoringController.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,15 @@ CandidateExaminationResult ScrollAnchoringController::examineCandidate(Element&
auto containingRect = boundingRectForScrollableArea(m_owningScrollableArea);
auto* document = frameView().frame().document();

if (auto* element = elementForScrollableArea(m_owningScrollableArea)) {
if (auto* box = element->renderBox()) {
LayoutRect paddedLayerBounds(containingRect);
paddedLayerBounds.contract(box->scrollPaddingForViewportRect(paddedLayerBounds));
LOG_WITH_STREAM(ScrollAnchoring, stream << "ScrollAnchoringController::examineCandidate() contracted rect: "<< IntRect(paddedLayerBounds));
containingRect = IntRect(paddedLayerBounds);
}
}

if (auto renderer = element.renderer()) {
// TODO: we need to think about position: absolute
// TODO: figure out how to get scrollable area for renderer to check if it is maintaining scroll anchor
Expand Down

0 comments on commit fd98410

Please sign in to comment.