Skip to content

[Liquid Glass] [macOS] Blank gap above top fixed header when rubber-banding against top of page #47215

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 26, 2025

Conversation

whsieh
Copy link
Member

@whsieh whsieh commented Jun 26, 2025

ddea071

[Liquid Glass] [macOS] Blank gap above top fixed header when rubber-banding against top of page
https://bugs.webkit.org/show_bug.cgi?id=295001
rdar://151482288

Reviewed by Abrar Rahman Protyasha and Aditya Keerthi.

Currently, when rubber-banding against the top of a webpage in Safari with a fixed element near the
top of the viewport, the page background color shows up in the gap between the bottom of the color
extension view and the top edge of the fixed element.

To fill in this gap, we introduce a new `m_layerForTopOverhangColorExtension` whose background color
is updated to match the predominant sampled color of the fixed element near the top. We then place
this new layer above the existing overhang layer for the page's extended background color. The layer
becomes visible when rubber-banding past the top of the page.

* Source/WebCore/page/LocalFrameView.cpp:
(WebCore::LocalFrameView::setWantsLayerForTopOverhangColorExtension const):

Add a new helper method to create and install `m_layerForTopOverhangColorExtension` in the
`GraphicsLayer` hierarchy. This layer is inserted right before the existing
`m_layerForTopOverhangArea` (which has now been renamed to avoid confusion).

(WebCore::LocalFrameView::setWantsLayerForTopOverhangImage const):
(WebCore::LocalFrameView::setWantsLayerForTopOverHangArea const): Deleted.

Rename the existing `m_layerForTopOverhangArea` to `m_layerForTopOverhangImage`, to clarify that
it's only used to contain the image supplied by the injected bundle client via the SPI function
`WKBundlePageSetTopOverhangImage`. Note that this is only used by Safari's continuous reader mode.
This renaming is important to disambiguate it from this new `m_layerForTopOverhangColorExtension`,
which also sits inside the overhang area.

* Source/WebCore/page/LocalFrameView.h:
* Source/WebCore/page/Page.cpp:
(WebCore::Page::updateFixedContainerEdges):

Add or remove `m_layerForTopOverhangColorExtension` as needed (i.e., when there's a predominant
sampled color).

* Source/WebCore/rendering/RenderLayerCompositor.cpp:
(WebCore::RenderLayerCompositor::~RenderLayerCompositor):
(WebCore::RenderLayerCompositor::frameViewDidChangeSize):

Update the `m_layerForTopOverhangColorExtension`'s bounds, alongside the existing
`m_layerForOverhangAreas`.

(WebCore::RenderLayerCompositor::updateRootLayerPosition):
(WebCore::RenderLayerCompositor::updateLayerForTopOverhangImage):
(WebCore::RenderLayerCompositor::updateLayerForTopOverhangColorExtension):

Add logic to add or remove `m_layerForTopOverhangColorExtension` — note that this new layer is
inserted under `m_scrolledContentsLayer` (matching `m_layerForTopOverhangImage`), but goes beneath
`m_layerForTopOverhangImage` in sublayer order if that already exists.

(WebCore::RenderLayerCompositor::updateSizeAndPositionForOverhangAreaLayer):
(WebCore::RenderLayerCompositor::updateSizeAndPositionForTopOverhangColorExtensionLayer):
(WebCore::RenderLayerCompositor::updateLayerForTopOverhangArea): Deleted.
* Source/WebCore/rendering/RenderLayerCompositor.h:
* Source/WebKit/WebProcess/WebPage/mac/WebPageMac.mm:
(WebKit::WebPage::setTopOverhangImage):
* Tools/TestWebKitAPI/Tests/WebKitCocoa/ObscuredContentInsets.mm:
(TestWebKitAPI::TEST(ObscuredContentInsets, TopOverhangColorExtensionLayer)):

Add an API test that searches the layer hierarchy for this new `CALayer` (by name) and sanity checks
its bounds, position, and background color.

* Tools/TestWebKitAPI/cocoa/TestWKWebView.h:
* Tools/TestWebKitAPI/cocoa/TestWKWebView.mm:
(forEachCALayer):
(-[WKWebView forEachCALayer:]):

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

6073282

Misc iOS, visionOS, tvOS & watchOS macOS Linux Windows
❌ 🧪 style ✅ 🛠 ios ✅ 🛠 mac ✅ 🛠 wpe ✅ 🛠 win
✅ 🧪 bindings ✅ 🛠 ios-sim ✅ 🛠 mac-AS-debug ✅ 🧪 wpe-wk2 ⏳ 🧪 win-tests
✅ 🧪 webkitperl ✅ 🧪 ios-wk2 ✅ 🧪 api-mac ✅ 🧪 api-wpe
✅ 🧪 ios-wk2-wpt ✅ 🧪 mac-wk1 ✅ 🛠 wpe-cairo
✅ 🧪 api-ios ✅ 🧪 mac-wk2 ✅ 🛠 gtk
✅ 🛠 vision ✅ 🧪 mac-AS-debug-wk2 ✅ 🧪 gtk-wk2
✅ 🛠 vision-sim ✅ 🧪 mac-wk2-stress ❌ 🧪 api-gtk
✅ 🛠 🧪 merge ✅ 🧪 vision-wk2 ✅ 🧪 mac-intel-wk2 ✅ 🛠 playstation
✅ 🛠 tv ✅ 🛠 mac-safer-cpp
✅ 🛠 tv-sim
✅ 🛠 watch
✅ 🛠 watch-sim

@whsieh whsieh requested a review from cdumez as a code owner June 26, 2025 02:06
@whsieh whsieh self-assigned this Jun 26, 2025
@whsieh whsieh added the New Bugs Unclassified bugs are placed in this component until the correct component can be determined. label Jun 26, 2025
@whsieh whsieh marked this pull request as draft June 26, 2025 02:07
@whsieh whsieh marked this pull request as ready for review June 26, 2025 02:44
@whsieh whsieh added the merge-queue Applied to send a pull request to merge-queue label Jun 26, 2025
@whsieh
Copy link
Member Author

whsieh commented Jun 26, 2025

Thanks for the reviews!

…anding against top of page

https://bugs.webkit.org/show_bug.cgi?id=295001
rdar://151482288

Reviewed by Abrar Rahman Protyasha and Aditya Keerthi.

Currently, when rubber-banding against the top of a webpage in Safari with a fixed element near the
top of the viewport, the page background color shows up in the gap between the bottom of the color
extension view and the top edge of the fixed element.

To fill in this gap, we introduce a new `m_layerForTopOverhangColorExtension` whose background color
is updated to match the predominant sampled color of the fixed element near the top. We then place
this new layer above the existing overhang layer for the page's extended background color. The layer
becomes visible when rubber-banding past the top of the page.

* Source/WebCore/page/LocalFrameView.cpp:
(WebCore::LocalFrameView::setWantsLayerForTopOverhangColorExtension const):

Add a new helper method to create and install `m_layerForTopOverhangColorExtension` in the
`GraphicsLayer` hierarchy. This layer is inserted right before the existing
`m_layerForTopOverhangArea` (which has now been renamed to avoid confusion).

(WebCore::LocalFrameView::setWantsLayerForTopOverhangImage const):
(WebCore::LocalFrameView::setWantsLayerForTopOverHangArea const): Deleted.

Rename the existing `m_layerForTopOverhangArea` to `m_layerForTopOverhangImage`, to clarify that
it's only used to contain the image supplied by the injected bundle client via the SPI function
`WKBundlePageSetTopOverhangImage`. Note that this is only used by Safari's continuous reader mode.
This renaming is important to disambiguate it from this new `m_layerForTopOverhangColorExtension`,
which also sits inside the overhang area.

* Source/WebCore/page/LocalFrameView.h:
* Source/WebCore/page/Page.cpp:
(WebCore::Page::updateFixedContainerEdges):

Add or remove `m_layerForTopOverhangColorExtension` as needed (i.e., when there's a predominant
sampled color).

* Source/WebCore/rendering/RenderLayerCompositor.cpp:
(WebCore::RenderLayerCompositor::~RenderLayerCompositor):
(WebCore::RenderLayerCompositor::frameViewDidChangeSize):

Update the `m_layerForTopOverhangColorExtension`'s bounds, alongside the existing
`m_layerForOverhangAreas`.

(WebCore::RenderLayerCompositor::updateRootLayerPosition):
(WebCore::RenderLayerCompositor::updateLayerForTopOverhangImage):
(WebCore::RenderLayerCompositor::updateLayerForTopOverhangColorExtension):

Add logic to add or remove `m_layerForTopOverhangColorExtension` — note that this new layer is
inserted under `m_scrolledContentsLayer` (matching `m_layerForTopOverhangImage`), but goes beneath
`m_layerForTopOverhangImage` in sublayer order if that already exists.

(WebCore::RenderLayerCompositor::updateSizeAndPositionForOverhangAreaLayer):
(WebCore::RenderLayerCompositor::updateSizeAndPositionForTopOverhangColorExtensionLayer):
(WebCore::RenderLayerCompositor::updateLayerForTopOverhangArea): Deleted.
* Source/WebCore/rendering/RenderLayerCompositor.h:
* Source/WebKit/WebProcess/WebPage/mac/WebPageMac.mm:
(WebKit::WebPage::setTopOverhangImage):
* Tools/TestWebKitAPI/Tests/WebKitCocoa/ObscuredContentInsets.mm:
(TestWebKitAPI::TEST(ObscuredContentInsets, TopOverhangColorExtensionLayer)):

Add an API test that searches the layer hierarchy for this new `CALayer` (by name) and sanity checks
its bounds, position, and background color.

* Tools/TestWebKitAPI/cocoa/TestWKWebView.h:
* Tools/TestWebKitAPI/cocoa/TestWKWebView.mm:
(forEachCALayer):
(-[WKWebView forEachCALayer:]):

Canonical link: https://commits.webkit.org/296667@main
@webkit-commit-queue
Copy link
Collaborator

Committed 296667@main (ddea071): https://commits.webkit.org/296667@main

Reviewed commits have been landed. Closing PR #47215 and removing active labels.

@webkit-commit-queue webkit-commit-queue merged commit ddea071 into WebKit:main Jun 26, 2025
@webkit-commit-queue webkit-commit-queue removed the merge-queue Applied to send a pull request to merge-queue label Jun 26, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
New Bugs Unclassified bugs are placed in this component until the correct component can be determined.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants