Branch: refs/heads/main Home: https://github.com/WebKit/WebKit Commit: ab202ed2ed76dfdfb62e74c77f8647d24f247a18 https://github.com/WebKit/WebKit/commit/ab202ed2ed76dfdfb62e74c77f8647d24f247a18 Author: Wenson Hsieh <wenson_hs...@apple.com> Date: 2025-04-28 (Mon, 28 Apr 2025)
Changed paths: M Source/WebCore/page/scrolling/ScrollingConstraints.cpp M Source/WebCore/page/scrolling/ScrollingConstraints.h M Source/WebCore/page/scrolling/ScrollingStateFixedNode.cpp M Source/WebCore/page/scrolling/ScrollingStateStickyNode.cpp M Source/WebCore/page/scrolling/ScrollingTreeFixedNode.cpp M Source/WebCore/page/scrolling/ScrollingTreeStickyNode.cpp M Source/WebCore/rendering/RenderLayerCompositor.cpp M Source/WebKit/Shared/WebCoreArgumentCoders.serialization.in M Source/WebKitLegacy/ios/WebCoreSupport/WebFixedPositionContent.mm Log Message: ----------- [Viewport Clipping] [Part 1/4] Refactor {Sticky|Fixed}PositionViewportConstraints to support adding a viewport-sized clip layer https://bugs.webkit.org/show_bug.cgi?id=292107 rdar://150115392 Reviewed by Abrar Rahman Protyasha. In preparation for supporting a configuration where sticky and fixed elements in the main frame are clipped to the bounds of the layout viewport, we refactor `StickyPositionViewportConstraints` and `FixedPositionViewportConstraints`; see comments below for more details. No change in behavior yet. * Source/WebCore/page/scrolling/ScrollingConstraints.cpp: (WebCore::ViewportConstraints::viewportRelativeLayerPosition const): Move `layerPositionForViewportRect` from `FixedPositionViewportConstraints` → `ViewportConstraints`, so that we can use it for `StickyPositionViewportConstraints` as well. In doing so, we also move the member variables `m_viewportRectAtLastLayout` and `m_layerPositionAtLastLayout` into the base `ViewportConstraints` class. Additionally, rename `layerPositionForViewportRect` to `viewportRelativeLayerPosition` to clarify that this refers to the layer whose position is adjusted when scrolling, in relation to the new viewport rect. (WebCore::StickyPositionViewportConstraints::anchorLayerPositionForConstrainingRect const): (WebCore::operator<<): (WebCore::FixedPositionViewportConstraints::layerPositionForViewportRect const): Deleted. Move this into `ViewportConstraints` (see above). (WebCore::StickyPositionViewportConstraints::layerPositionForConstrainingRect const): Deleted. Add `anchor` in front of this method name (see above). * Source/WebCore/page/scrolling/ScrollingConstraints.h: (WebCore::ViewportConstraints::viewportRectAtLastLayout const): (WebCore::ViewportConstraints::setViewportRectAtLastLayout): (WebCore::ViewportConstraints::layerPositionAtLastLayout const): (WebCore::ViewportConstraints::setLayerPositionAtLastLayout): Add getters/setters for `layerPositionAtLastLayout` and `viewportRectAtLastLayout`, which are now both on the base `ViewportConstraints`. (WebCore::ViewportConstraints::ViewportConstraints): (WebCore::FixedPositionViewportConstraints::FixedPositionViewportConstraints): (WebCore::StickyPositionViewportConstraints::StickyPositionViewportConstraints): (WebCore::StickyPositionViewportConstraints::m_anchorLayerOffsetAtLastLayout): (WebCore::StickyPositionViewportConstraints::anchorLayerOffsetAtLastLayout const): Add a new member, `m_anchorLayerOffsetAtLastLayout`, along with getters and setters. This represents the offset (at the time of the last layout) from the anchor layer and its parent layer — either the parent of the sticky node or the clipping layer. This is effectively unused at the moment, since it's always `(0, 0)`, but will be set in a future patch once the notion of `viewportClippingLayer` for fixed/sticky layers exists. (WebCore::StickyPositionViewportConstraints::setAnchorLayerOffsetAtLastLayout): (WebCore::FixedPositionViewportConstraints::viewportRectAtLastLayout const): Deleted. (WebCore::FixedPositionViewportConstraints::setViewportRectAtLastLayout): Deleted. (WebCore::FixedPositionViewportConstraints::layerPositionAtLastLayout const): Deleted. (WebCore::FixedPositionViewportConstraints::setLayerPositionAtLastLayout): Deleted. (WebCore::StickyPositionViewportConstraints::layerPositionAtLastLayout const): Deleted. (WebCore::StickyPositionViewportConstraints::setLayerPositionAtLastLayout): Deleted. Remove this redundant getter/setter and member variable, now that `layerPositionAtLastLayout` is in the base class. * Source/WebCore/page/scrolling/ScrollingStateFixedNode.cpp: (WebCore::ScrollingStateFixedNode::reconcileLayerPositionForViewportRect): * Source/WebCore/page/scrolling/ScrollingStateStickyNode.cpp: (WebCore::ScrollingStateStickyNode::computeLayerPosition const): * Source/WebCore/page/scrolling/ScrollingTreeFixedNode.cpp: (WebCore::ScrollingTreeFixedNode::computeLayerPosition const): * Source/WebCore/page/scrolling/ScrollingTreeStickyNode.cpp: (WebCore::ScrollingTreeStickyNode::computeLayerPosition const): * Source/WebCore/rendering/RenderLayerCompositor.cpp: (WebCore::RenderLayerCompositor::computeStickyViewportConstraints const): Set the new `viewportRectAtLastLayout` on sticky constraints. Note that we skip setting the new `anchorLayerOffsetAtLastLayout` for now, because the clipping layer hasn't been introduced yet. * Source/WebKit/Shared/WebCoreArgumentCoders.serialization.in: Add serialization for the two new members on `StickyPositionViewportConstraints`. Note that the serialization of `FixedPositionViewportConstraints` is unchanged here because all the same members still exist — they're just on `ViewportConstraints` now. * Source/WebKitLegacy/ios/WebCoreSupport/WebFixedPositionContent.mm: (-[WebFixedPositionContent scrollOrZoomChanged:]): (-[WebFixedPositionContent overflowScrollPositionForLayer:changedTo:]): Canonical link: https://commits.webkit.org/294230@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