[webkit-changes] [WebKit/WebKit] 69b703: [css-anchor-position-1] Implement scroll position ...

Antti Koivisto noreply at github.com
Fri Oct 18 05:20:48 PDT 2024


  Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: 69b703409e424497c2dfc96feed959984a9048bc
      https://github.com/WebKit/WebKit/commit/69b703409e424497c2dfc96feed959984a9048bc
  Author: Antti Koivisto <antti at apple.com>
  Date:   2024-10-18 (Fri, 18 Oct 2024)

  Changed paths:
    M LayoutTests/TestExpectations
    M LayoutTests/imported/w3c/web-platform-tests/css/css-anchor-position/anchor-scroll-002-expected.txt
    M LayoutTests/imported/w3c/web-platform-tests/css/css-anchor-position/anchor-scroll-004-expected.txt
    A LayoutTests/imported/w3c/web-platform-tests/css/css-anchor-position/anchor-scroll-cleanup-expected.txt
    A LayoutTests/imported/w3c/web-platform-tests/css/css-anchor-position/anchor-scroll-cleanup.html
    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-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-011-expected.txt
    M Source/WebCore/page/Page.cpp
    M Source/WebCore/page/Page.h
    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/RenderLayerCompositor.h
    M Source/WebCore/rendering/RenderLayerScrollableArea.cpp
    M Source/WebCore/rendering/RenderObject.cpp
    M Source/WebCore/style/AnchorPositionEvaluator.cpp
    M Source/WebCore/style/AnchorPositionEvaluator.h
    M Source/WebCore/style/StyleScope.cpp

  Log Message:
  -----------
  [css-anchor-position-1] Implement scroll position adjustments
https://bugs.webkit.org/show_bug.cgi?id=281139
rdar://137590987

Reviewed by Antoine Quint.

https://drafts.csswg.org/css-anchor-position-1/#scroll

Anchor positioned element may be on a different scroller than the anchor. In this case
adjustments are needed to keep the positions in sync.

This patch does not yet implement scrolling adjustments in the scrolling tree so
the exact anchoring can't be maintained in all cases during asynchronous scrolling.

* LayoutTests/TestExpectations:
* LayoutTests/imported/w3c/web-platform-tests/css/css-anchor-position/anchor-scroll-002-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/css/css-anchor-position/anchor-scroll-004-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/css/css-anchor-position/anchor-scroll-cleanup-expected.txt: Added.
* LayoutTests/imported/w3c/web-platform-tests/css/css-anchor-position/anchor-scroll-cleanup.html: Added.

Add a test for cleanups.

* 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-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-011-expected.txt:

Note that @position-try is not implemented so neither fails nor passes are meaningful.

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

Update the snapshotted scroll offsets on rendering update if needed.

(WebCore::operator<<):
* Source/WebCore/page/Page.h:
* Source/WebCore/rendering/RenderLayer.cpp:
(WebCore::RenderLayer::updateTransformFromStyle const):

Includes snapshotted scroll offset to the layer transform.
It is specified to be treated like another transform.

(WebCore::RenderLayer::updateTransform):
(WebCore::RenderLayer::setSnapshottedScrollOffsetForAnchorPositioning):
* Source/WebCore/rendering/RenderLayer.h:
* Source/WebCore/rendering/RenderLayerBacking.cpp:
(WebCore::RenderLayerBacking::updateTransform):
* Source/WebCore/rendering/RenderLayerCompositor.cpp:
(WebCore::RenderLayerCompositor::requiresCompositingLayer const):
(WebCore::RenderLayerCompositor::requiresOwnBackingStore const):
(WebCore::RenderLayerCompositor::reasonsForCompositing const):
(WebCore::compositingReasonToString):
(WebCore::RenderLayerCompositor::requiresCompositingForAnchorPositioning const):

Composite anchor positioned elements that require adjustments.

* Source/WebCore/rendering/RenderLayerCompositor.h:
* Source/WebCore/rendering/RenderLayerScrollableArea.cpp:
(WebCore::RenderLayerScrollableArea::scrollTo):

Update the snapshotted scroll offsets during scrolling if needed.

* Source/WebCore/rendering/RenderObject.cpp:
(WebCore::RenderObject::shouldUseTransformFromContainer const):
* Source/WebCore/style/AnchorPositionEvaluator.cpp:
(WebCore::Style::offsetFromAncestorContainer):

Substract away the effect so offset is as if all scrollers were on (0, 0) scroll position.

(WebCore::Style::scrollOffsetFromAncestorContainer):
(WebCore::Style::AnchorPositionEvaluator::updateSnapshottedScrollOffsets):
* Source/WebCore/style/AnchorPositionEvaluator.h:

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

Reset the offsets when clearing the state.
Currently we build these structures from scratch if anything changes.

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



To unsubscribe from these emails, change your notification settings at https://github.com/WebKit/WebKit/settings/notifications


More information about the webkit-changes mailing list