Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: 27e72ea1a69bee0f87ea794f1f55e34c7d7c4650
      
https://github.com/WebKit/WebKit/commit/27e72ea1a69bee0f87ea794f1f55e34c7d7c4650
  Author: Wenson Hsieh <[email protected]>
  Date:   2025-04-30 (Wed, 30 Apr 2025)

  Changed paths:
    M LayoutTests/TestExpectations
    A LayoutTests/compositing/cocoa/clip-fixed-element-to-viewport-expected.html
    A LayoutTests/compositing/cocoa/clip-fixed-element-to-viewport.html
    A 
LayoutTests/compositing/cocoa/clip-sticky-element-to-viewport-expected.html
    A LayoutTests/compositing/cocoa/clip-sticky-element-to-viewport.html
    A 
LayoutTests/compositing/ios/immediate-scrolling-clip-fixed-element-to-viewport-expected.html
    A 
LayoutTests/compositing/ios/immediate-scrolling-clip-fixed-element-to-viewport.html
    A 
LayoutTests/compositing/ios/immediate-scrolling-clip-sticky-element-to-viewport-expected.html
    A 
LayoutTests/compositing/ios/immediate-scrolling-clip-sticky-element-to-viewport.html
    M LayoutTests/platform/ios/TestExpectations
    M LayoutTests/platform/mac-wk2/TestExpectations
    M Source/WebCore/rendering/RenderLayerBacking.cpp
    M Source/WebCore/rendering/RenderLayerBacking.h
    M Source/WebCore/rendering/RenderLayerCompositor.cpp
    M Source/WebCore/rendering/RenderLayerCompositor.h
    M Tools/WebKitTestRunner/ios/TestControllerIOS.mm
    M Tools/WebKitTestRunner/ios/UIScriptControllerIOS.mm

  Log Message:
  -----------
  [Viewport Clipping] [Part 4/4] Add the ability to clip fixed and sticky 
elements to the viewport
https://bugs.webkit.org/show_bug.cgi?id=292125
rdar://147964717

Reviewed by Abrar Rahman Protyasha and Simon Fraser.

Finish support for clipping fixed and sticky elements to the viewport, by 
(finally) introducing the
viewport clipping layer to `RenderLayerBacking`. This clipping layer sits above 
the current viewport
anchor layer (i.e. the transform layer) in the compositing hierarchy, and clips 
all fixed or sticky
content to the bounds of the viewport. This clipping layer is installed:

1. Only for fixed elements in the main frame, or
2. Sticky elements in the main frame that aren't also contained within an 
overflow scroller.

...and additionally requires the `ContentInsetBackgroundFill` setting to be 
enabled.

When scrolling with a viewport clipping layer, the fixed or sticky nodes in the 
scrolling tree now
blit the clipping layer instead of the anchor layer; in the case of sticky 
nodes, this also means we
counter-blit the anchor layer underneath as needed (in the case where the 
sticky node still scrolls
with page content instead of behaving as fixed).

See below for more details.

* LayoutTests/TestExpectations:
* LayoutTests/compositing/cocoa/clip-fixed-element-to-viewport-expected.html: 
Added.
* LayoutTests/compositing/cocoa/clip-fixed-element-to-viewport.html: Added.
* LayoutTests/compositing/cocoa/clip-sticky-element-to-viewport-expected.html: 
Added.
* LayoutTests/compositing/cocoa/clip-sticky-element-to-viewport.html: Added.

Add new ref tests to verify that fixed and sticky elements are clipped to the 
top of the viewport
when scrolling. The test pages both contain fixed and sticky elements that 
partially lie outside of
the viewport, while the refs contain fixed and sticky elements that are fully 
contained in the
viewport.

* 
LayoutTests/compositing/ios/immediate-scrolling-clip-fixed-element-to-viewport-expected.html:
 Added.
* 
LayoutTests/compositing/ios/immediate-scrolling-clip-fixed-element-to-viewport.html:
 Added.
* 
LayoutTests/compositing/ios/immediate-scrolling-clip-sticky-element-to-viewport-expected.html:
 Added.
* 
LayoutTests/compositing/ios/immediate-scrolling-clip-sticky-element-to-viewport.html:
 Added.

Add more ref tests to exercise the new clipping behavior after immediate 
scrolling, when scrolling
updates are disabled.

* LayoutTests/platform/ios/TestExpectations:
* LayoutTests/platform/mac-wk2/TestExpectations:
* Source/WebCore/rendering/RenderLayerBacking.cpp:
(WebCore::RenderLayerBacking::updateDebugIndicators):

Add a debug indicator to the new `m_viewportClippingLayer`.

(WebCore::RenderLayerBacking::destroyGraphicsLayers):
(WebCore::RenderLayerBacking::updateConfiguration):
(WebCore::RenderLayerBacking::updateGeometry):

Account for the presence of the viewport clipping layer by setting its size and 
position based on
the layout viewport rect.

(WebCore::RenderLayerBacking::updateInternalHierarchy):

Add the clipping layer as an ordered layer, above the existing viewport anchor 
layer.

(WebCore::RenderLayerBacking::updateViewportConstrainedSublayers):

Rename this to `-Sublayers`, to reflect the fact that this now updates both the 
viewport clipping
layer and the viewport anchor layer. Instead of a bool, this now also takes a 
new enum that
represents which layers are needed (i.e. anchor, clipping + anchor, or 
neither). See below for more
details.

(WebCore::RenderLayerBacking::updateViewportConstrainedAnchorLayer): Deleted.
* Source/WebCore/rendering/RenderLayerBacking.h:

Add `m_viewportClippingLayer`, and make `viewportClippingOrAnchorLayer()` 
return either the clipping
layer (if it exists) or the anchor layer.

* Source/WebCore/rendering/RenderLayerCompositor.cpp:
(WebCore::RenderLayerCompositor::viewportConstrainedSublayers const):

Replaces `isViewportConstrainedFixedOrStickyLayer`; see below for more details.

(WebCore::RenderLayerCompositor::coordinatedScrollingRolesForLayer const):
(WebCore::RenderLayerCompositor::isViewportConstrainedFixedOrStickyLayer 
const): Deleted.

Rename this to `viewportConstrainedSublayers`. Instead of returning a `bool`, 
return a new enum that
represents whether the `RenderLayer` should contain (above its child content 
layer):

- None                 no viewport constrained layers (e.g. not fixed or 
sticky).
- Anchor               a single viewport anchor layer (transform layer)
- ClippingAndAnchor    a viewport-sized clipping layer, with the clipping layer 
underneath.

* Source/WebCore/rendering/RenderLayerCompositor.h:
* Tools/WebKitTestRunner/ios/TestControllerIOS.mm:
(WTR::TestController::platformResetStateToConsistentValues):

Drive-by fix: check all content inset edges (not just the top) when resetting 
state between tests.

* Tools/WebKitTestRunner/ios/UIScriptControllerIOS.mm:
(WTR::UIScriptControllerIOS::setObscuredInsets):

Adjust this testing helper to additionally set content insets and adjust layout 
viewport dimensions
to better match obscured inset behavior in Safari and other apps.

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



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

Reply via email to