Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: 90fc9aa7e180c7b0fb56c76a2cdb5b202a0c128a
      
https://github.com/WebKit/WebKit/commit/90fc9aa7e180c7b0fb56c76a2cdb5b202a0c128a
  Author: Elika Etemad <fantasai.b...@inkedblade.net>
  Date:   2025-08-15 (Fri, 15 Aug 2025)

  Changed paths:
    M LayoutTests/TestExpectations
    M 
LayoutTests/imported/w3c/web-platform-tests/css/css-anchor-position/anchor-scroll-chained-002-expected.html
    M 
LayoutTests/imported/w3c/web-platform-tests/css/css-anchor-position/anchor-scroll-js-expose-expected.txt
    M 
LayoutTests/imported/w3c/web-platform-tests/css/css-anchor-position/anchor-scroll-position-try-001-expected.txt
    M 
LayoutTests/imported/w3c/web-platform-tests/css/css-anchor-position/anchor-scroll-position-try-002-expected.txt
    M 
LayoutTests/imported/w3c/web-platform-tests/css/css-anchor-position/anchor-scroll-position-try-003-expected.txt
    M 
LayoutTests/imported/w3c/web-platform-tests/css/css-anchor-position/anchor-scroll-position-try-004-expected.txt
    M 
LayoutTests/imported/w3c/web-platform-tests/css/css-anchor-position/anchor-scroll-position-try-005-expected.txt
    M 
LayoutTests/imported/w3c/web-platform-tests/css/css-anchor-position/anchor-scroll-position-try-006-expected.txt
    M 
LayoutTests/imported/w3c/web-platform-tests/css/css-anchor-position/anchor-scroll-position-try-007-expected.txt
    M 
LayoutTests/imported/w3c/web-platform-tests/css/css-anchor-position/anchor-scroll-position-try-008-expected.txt
    M 
LayoutTests/imported/w3c/web-platform-tests/css/css-anchor-position/anchor-scroll-position-try-009-expected.txt
    M 
LayoutTests/imported/w3c/web-platform-tests/css/css-anchor-position/anchor-scroll-position-try-010-expected.txt
    M 
LayoutTests/imported/w3c/web-platform-tests/css/css-anchor-position/anchor-scroll-position-try-011-expected.txt
    M 
LayoutTests/imported/w3c/web-platform-tests/css/css-anchor-position/position-area-scrolling-002.tentative-expected.txt
    A 
LayoutTests/platform/mac-wk1/imported/w3c/web-platform-tests/css/css-anchor-position/anchor-scroll-position-try-002-expected.txt
    A 
LayoutTests/platform/mac-wk1/imported/w3c/web-platform-tests/css/css-anchor-position/anchor-scroll-position-try-004-expected.txt
    A 
LayoutTests/platform/mac-wk1/imported/w3c/web-platform-tests/css/css-anchor-position/anchor-scroll-position-try-005-expected.txt
    A 
LayoutTests/platform/mac-wk1/imported/w3c/web-platform-tests/css/css-anchor-position/anchor-scroll-position-try-006-expected.txt
    A 
LayoutTests/platform/mac-wk1/imported/w3c/web-platform-tests/css/css-anchor-position/anchor-scroll-position-try-007-expected.txt
    A 
LayoutTests/platform/mac-wk1/imported/w3c/web-platform-tests/css/css-anchor-position/anchor-scroll-position-try-008-expected.txt
    A 
LayoutTests/platform/mac-wk1/imported/w3c/web-platform-tests/css/css-anchor-position/anchor-scroll-position-try-009-expected.txt
    A 
LayoutTests/platform/mac-wk1/imported/w3c/web-platform-tests/css/css-anchor-position/anchor-scroll-position-try-010-expected.txt
    M Source/WebCore/page/LocalFrameView.cpp
    M Source/WebCore/page/LocalFrameViewLayoutContext.cpp
    M Source/WebCore/page/LocalFrameViewLayoutContext.h
    M Source/WebCore/page/Page.cpp
    M Source/WebCore/platform/graphics/LayoutPoint.h
    M Source/WebCore/platform/graphics/LayoutSize.h
    M Source/WebCore/rendering/PositionedLayoutConstraints.cpp
    M Source/WebCore/rendering/PositionedLayoutConstraints.h
    M Source/WebCore/rendering/RenderBlock.cpp
    M Source/WebCore/rendering/RenderBox.cpp
    M Source/WebCore/rendering/RenderElement.cpp
    M Source/WebCore/rendering/RenderLayer.cpp
    M Source/WebCore/rendering/RenderLayer.h
    M Source/WebCore/rendering/RenderLayerBacking.cpp
    M Source/WebCore/rendering/RenderLayerCompositor.cpp
    M Source/WebCore/rendering/RenderLayerInlines.h
    M Source/WebCore/rendering/RenderLayerScrollableArea.cpp
    M Source/WebCore/rendering/RenderObject.cpp
    M Source/WebCore/rendering/RenderObject.h
    M Source/WebCore/rendering/RenderObjectInlines.h
    M Source/WebCore/rendering/style/RenderStyle.h
    M Source/WebCore/rendering/style/RenderStyleSetters.h
    M Source/WebCore/style/AnchorPositionEvaluator.cpp
    M Source/WebCore/style/AnchorPositionEvaluator.h
    M Source/WebCore/style/StyleScope.cpp
    M Source/WebCore/style/StyleTreeResolver.cpp

  Log Message:
  -----------
  Make anchor positioning fallbacks respond to scrolling [css-anchor-position-1]
https://bugs.webkit.org/show_bug.cgi?id=295003
rdar://154349365

Reviewed by Antti Koivisto.

This patch rewrites are scroll handling for anchor positioning to incorporate
the current scroll position into layout so that anchored boxes can respond to
space available at the current scroll position.

In order to maintain responsiveness to scrolling, it caches scroll position
snapshots with each layout, which allows us to rapidly calculate adjustments
o the anchored box's scroll adjustment transform on changes to the scroll
position outside of layout as well as to trigger more invasive invalidation
when necessary in response to scroll position changes, e.g. for fallbacks.

* LayoutTests/TestExpectations:

Pass more tests.

* 
LayoutTests/imported/w3c/web-platform-tests/css/css-anchor-position/anchor-scroll-chained-002-expected.html:

Fix test reference.

* 
LayoutTests/imported/w3c/web-platform-tests/css/css-anchor-position/anchor-scroll-js-expose-expected.txt:
* 
LayoutTests/imported/w3c/web-platform-tests/css/css-anchor-position/anchor-scroll-position-try-001-expected.txt:
* 
LayoutTests/imported/w3c/web-platform-tests/css/css-anchor-position/anchor-scroll-position-try-002-expected.txt:
* 
LayoutTests/imported/w3c/web-platform-tests/css/css-anchor-position/anchor-scroll-position-try-003-expected.txt:
* 
LayoutTests/imported/w3c/web-platform-tests/css/css-anchor-position/anchor-scroll-position-try-004-expected.txt:
* 
LayoutTests/imported/w3c/web-platform-tests/css/css-anchor-position/anchor-scroll-position-try-005-expected.txt:

Pass more tests.

* 
LayoutTests/imported/w3c/web-platform-tests/css/css-anchor-position/anchor-scroll-position-try-006-expected.txt:
* 
LayoutTests/imported/w3c/web-platform-tests/css/css-anchor-position/anchor-scroll-position-try-007-expected.txt:
* 
LayoutTests/imported/w3c/web-platform-tests/css/css-anchor-position/anchor-scroll-position-try-008-expected.txt:
* 
LayoutTests/imported/w3c/web-platform-tests/css/css-anchor-position/anchor-scroll-position-try-009-expected.txt:
* 
LayoutTests/imported/w3c/web-platform-tests/css/css-anchor-position/anchor-scroll-position-try-010-expected.txt:
* 
LayoutTests/imported/w3c/web-platform-tests/css/css-anchor-position/anchor-scroll-position-try-011-expected.txt:
* 
LayoutTests/imported/w3c/web-platform-tests/css/css-anchor-position/position-area-scrolling-002.tentative-expected.txt:

Rebaseline.

* 
LayoutTests/platform/mac-wk1/imported/w3c/web-platform-tests/css/css-anchor-position/anchor-scroll-position-try-002-expected.txt:
* 
LayoutTests/platform/mac-wk1/imported/w3c/web-platform-tests/css/css-anchor-position/anchor-scroll-position-try-004-expected.txt:
* 
LayoutTests/platform/mac-wk1/imported/w3c/web-platform-tests/css/css-anchor-position/anchor-scroll-position-try-005-expected.txt:
* 
LayoutTests/platform/mac-wk1/imported/w3c/web-platform-tests/css/css-anchor-position/anchor-scroll-position-try-006-expected.txt:
* 
LayoutTests/platform/mac-wk1/imported/w3c/web-platform-tests/css/css-anchor-position/anchor-scroll-position-try-007-expected.txt:
* 
LayoutTests/platform/mac-wk1/imported/w3c/web-platform-tests/css/css-anchor-position/anchor-scroll-position-try-008-expected.txt:
* 
LayoutTests/platform/mac-wk1/imported/w3c/web-platform-tests/css/css-anchor-position/anchor-scroll-position-try-009-expected.txt:
* 
LayoutTests/platform/mac-wk1/imported/w3c/web-platform-tests/css/css-anchor-position/anchor-scroll-position-try-010-expected.txt:

Mark WK1 tests as still failing, to debug later per Antti's instructions.

* Source/WebCore/page/LocalFrameView.cpp:
(WebCore::LocalFrameView::updateAnchorPositionedAfterScroll):

Update anchor scroll adjustment call site.

* Source/WebCore/page/LocalFrameViewLayoutContext.cpp:
(WebCore::LocalFrameViewLayoutContext::anchorScrollAdjusterFor):
(WebCore::LocalFrameViewLayoutContext::registerAnchorScrollAdjuster):
(WebCore::LocalFrameViewLayoutContext::unregisterAnchorScrollAdjusterFor):
(WebCore::LocalFrameViewLayoutContext::invalidateAnchorDependenciesForScroller):
(WebCore::LocalFrameViewLayoutContext::removeScrollerFromAnchorScrollAdjusters):
* Source/WebCore/page/LocalFrameViewLayoutContext.h:

Set up storage for anchor scroll adjuster objects.

* Source/WebCore/page/Page.cpp:
(WebCore::Page::updateRendering):

Update anchor scroll adjustment call site.

* Source/WebCore/platform/graphics/LayoutPoint.h:
(WebCore::LayoutPointLimits::clamp):
(WebCore::LayoutPointLimits::fits):
(WebCore::LayoutPointLimits::distance):
* Source/WebCore/platform/graphics/LayoutSize.h:
(WebCore::LayoutSizeLimits::clamp):
(WebCore::LayoutSizeLimits::fits):
(WebCore::LayoutSizeLimits::distance):

Introduce some convenience objects / methods.

* Source/WebCore/rendering/PositionedLayoutConstraints.cpp:
(WebCore::PositionedLayoutConstraints::captureAnchorGeometry):

Adjust call parameters to computeAnchorRectRelativeToContainingBlock().

* Source/WebCore/rendering/PositionedLayoutConstraints.h:
(WebCore::PositionedLayoutConstraints::originalContainingRange const):
(WebCore::PositionedLayoutConstraints::insetModifiedContainingRange const):

Export more info.

* Source/WebCore/rendering/RenderBlock.cpp:
(WebCore::RenderBlock::simplifiedLayout):
(WebCore::RenderBlock::layoutOutOfFlowBox):

Call scroll snapshot capture method after layout.

* Source/WebCore/rendering/RenderBox.cpp:
(WebCore::RenderBox::willBeDestroyed):
(WebCore::RenderBox::styleDidChange):

Manage anchor scroll adjuster memory allocation and invalidation.

* Source/WebCore/rendering/RenderElement.cpp:
(WebCore::RenderElement::layoutIfNeeded):

Call scroll snapshot capture method after layout.

* Source/WebCore/rendering/RenderLayer.cpp:
(WebCore::RenderLayer::updateTransformFromStyle const):
(WebCore::RenderLayer::setAnchorScrollAdjustment):
(WebCore::RenderLayer::clearAnchorScrollAdjustment):
(WebCore::RenderLayer::setSnapshottedScrollOffsetForAnchorPositioning): Deleted.
(WebCore::RenderLayer::clearSnapshottedScrollOffsetForAnchorPositioning): 
Deleted.
* Source/WebCore/rendering/RenderLayer.h:
* Source/WebCore/rendering/RenderLayerBacking.cpp:
(WebCore::RenderLayerBacking::updateTransform):
* Source/WebCore/rendering/RenderLayerCompositor.cpp:
(WebCore::RenderLayerCompositor::requiresCompositingForAnchorPositioning const):
* Source/WebCore/rendering/RenderLayerInlines.h:
(WebCore::RenderLayer::isTransformed const):
* Source/WebCore/rendering/RenderObject.cpp:
(WebCore::RenderObject::shouldUseTransformFromContainer const):

Update terminology and tweak for new scroll adjustment system.

* Source/WebCore/rendering/RenderLayerScrollableArea.cpp:
(WebCore::RenderLayerScrollableArea::updateAnchorPositionedAfterScroll):

Update anchor scroll adjustment call site.

* Source/WebCore/rendering/RenderObject.h:
* Source/WebCore/rendering/RenderObjectInlines.h:
(WebCore::RenderObject::layoutContext const):

Allow non-const access to layoutContext.

* Source/WebCore/rendering/style/RenderStyle.h:
* Source/WebCore/rendering/style/RenderStyleSetters.h:
(WebCore::RenderStyle::setIsForceHidden):

Allow setting force-hidden to true or false.

* Source/WebCore/style/AnchorPositionEvaluator.cpp:
(WebCore::AnchorScrollSnapshot::AnchorScrollSnapshot):
(WebCore::AnchorScrollSnapshot::AnchorScrollSnapshot):
(WebCore::AnchorScrollSnapshot::adjustmentForCurrentScrollPosition):
(WebCore::AnchorScrollAdjuster::isEmpty const):
(WebCore::AnchorScrollAdjuster::AnchorScrollAdjuster):
(WebCore::AnchorScrollAdjuster::addSnapshot):
(WebCore::AnchorScrollAdjuster::addViewportSnapshot):
(WebCore::AnchorScrollAdjuster::adjustmentForViewport):
(WebCore::AnchorScrollAdjuster::accumulateAdjustments):
(WebCore::AnchorScrollAdjuster::setFallbackLimits):
(WebCore::AnchorScrollAdjuster::invalidateForScroller):

Implement new anchor scroll adjuster system.

(WebCore::Style::clearAnchorScrollSnapshots):
(WebCore::Style::AnchorPositionEvaluator::captureScrollSnapshots):
(WebCore::Style::AnchorPositionEvaluator::updateScrollAdjustments):

Rewrite anchor scrolling to use new anchor scroll adjuster system.

(WebCore::Style::offsetFromAncestorContainer):
(WebCore::Style::AnchorPositionEvaluator::computeAnchorRectRelativeToContainingBlock):
(WebCore::Style::computeInsetValue):

Incorporate scroll positions into anchor rect computation.

(WebCore::Style::AnchorPositionEvaluator::scrollOffsetFromAnchor): Deleted.
(WebCore::Style::AnchorPositionEvaluator::updateSnapshottedScrollOffsets): 
Deleted.
(WebCore::Style::AnchorPositionEvaluator::updatePositionsAfterScroll): Deleted.

Remove old scroll adjustment system.

* Source/WebCore/style/AnchorPositionEvaluator.h:
(WebCore::AnchorScrollAdjuster::anchored const):
(WebCore::AnchorScrollAdjuster::mayNeedAdjustment const):
(WebCore::AnchorScrollAdjuster::isHidden const):
(WebCore::AnchorScrollAdjuster::setHidden):
(WebCore::AnchorScrollAdjuster::hasFallbackLimits const):
(WebCore::AnchorScrollAdjuster::exceedsFallbackLimits):

Implement new anchor scroll adjuster system.

* Source/WebCore/style/StyleScope.cpp:
(WebCore::Style::Scope::invalidateForAnchorDependencies):

Don't trigger invalidation due to scroll adjustments.

(WebCore::Style::Scope::updateAnchorPositioningStateAfterStyleResolution):
* Source/WebCore/style/StyleTreeResolver.cpp:
(WebCore::Style::TreeResolver::updateForPositionVisibility):

Update anchor scroll adjustment call sites.

Canonical link: https://commits.webkit.org/298770@main



To unsubscribe from these emails, change your notification settings at 
https://github.com/WebKit/WebKit/settings/notifications
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to