Branch: refs/heads/main
Home: https://github.com/WebKit/WebKit
Commit: 5ef25ef2658b96afe8e64feb13b42129cf5c8d1d
https://github.com/WebKit/WebKit/commit/5ef25ef2658b96afe8e64feb13b42129cf5c8d1d
Author: Wenson Hsieh <[email protected]>
Date: 2025-05-12 (Mon, 12 May 2025)
Changed paths:
M
LayoutTests/fast/page-color-sampling/basic-fixed-container-edge-sampling.html
M
LayoutTests/fast/page-color-sampling/color-sampling-fixed-ancestor-with-relative-container.html
M
LayoutTests/fast/page-color-sampling/color-sampling-fixed-container-under-subscroller.html
M
LayoutTests/fast/page-color-sampling/color-sampling-fixed-descendant-in-relative-container.html
M
LayoutTests/fast/page-color-sampling/color-sampling-ignores-backdrop-filters.html
M
LayoutTests/fast/page-color-sampling/color-sampling-ignores-empty-container.html
M LayoutTests/fast/page-color-sampling/color-sampling-ignores-images.html
M
LayoutTests/fast/page-color-sampling/color-sampling-ignores-non-fixed-content.html
M
LayoutTests/fast/page-color-sampling/color-sampling-ignores-subscrollers.html
M LayoutTests/fast/page-color-sampling/color-sampling-ignores-text.html
M
LayoutTests/fast/page-color-sampling/color-sampling-ignores-transparent-pointer-events-none-container.html
M
LayoutTests/fast/page-color-sampling/color-sampling-in-position-sticky.html
M
LayoutTests/fast/page-color-sampling/color-sampling-includes-subframes.html
M
LayoutTests/fast/page-color-sampling/color-sampling-while-rubber-banding.html
A
LayoutTests/fast/page-color-sampling/maintain-sampled-color-when-scrolled-to-top-expected.txt
A
LayoutTests/fast/page-color-sampling/maintain-sampled-color-when-scrolled-to-top.html
M
LayoutTests/fast/page-color-sampling/page-color-sampling-skips-border-top.html
M
LayoutTests/fast/page-color-sampling/page-color-sampling-skips-small-elements.html
M Source/WebCore/page/LocalFrameView.cpp
M Source/WebCore/page/Page.cpp
M Source/WebCore/page/Page.h
M Source/WebCore/page/PageColorSampler.cpp
M Source/WebCore/page/PageColorSampler.h
M Source/WebKit/WebProcess/WebPage/WebPage.cpp
M Tools/WebKitTestRunner/TestOptions.cpp
M Tools/WebKitTestRunner/TestOptions.h
M Tools/WebKitTestRunner/cocoa/TestControllerCocoa.mm
Log Message:
-----------
[Page color sampling] Fall back to sampled page top color when scrolling
against the top of the page
https://bugs.webkit.org/show_bug.cgi?id=292876
rdar://150782380
Reviewed by Abrar Rahman Protyasha.
Make some more adjustments to the page color sampling heuristic, for
compatibility with the
following websites:
• http://showcase.commercialtype.com
• https://www.mocanashville.org
• https://www.amazon.com
See below for more details.
* LayoutTests/fast/page-color-sampling/basic-fixed-container-edge-sampling.html:
*
LayoutTests/fast/page-color-sampling/color-sampling-fixed-ancestor-with-relative-container.html:
*
LayoutTests/fast/page-color-sampling/color-sampling-fixed-container-under-subscroller.html:
*
LayoutTests/fast/page-color-sampling/color-sampling-fixed-descendant-in-relative-container.html:
*
LayoutTests/fast/page-color-sampling/color-sampling-ignores-backdrop-filters.html:
*
LayoutTests/fast/page-color-sampling/color-sampling-ignores-empty-container.html:
* LayoutTests/fast/page-color-sampling/color-sampling-ignores-images.html:
*
LayoutTests/fast/page-color-sampling/color-sampling-ignores-non-fixed-content.html:
* LayoutTests/fast/page-color-sampling/color-sampling-ignores-subscrollers.html:
* LayoutTests/fast/page-color-sampling/color-sampling-ignores-text.html:
*
LayoutTests/fast/page-color-sampling/color-sampling-ignores-transparent-pointer-events-none-container.html:
* LayoutTests/fast/page-color-sampling/color-sampling-in-position-sticky.html:
* LayoutTests/fast/page-color-sampling/color-sampling-includes-subframes.html:
* LayoutTests/fast/page-color-sampling/color-sampling-while-rubber-banding.html:
Adjust existing layout tests — add `pageTopColorSamplingEnabled=true` to ensure
that we're
exercising the full extent of the fixed container edge sampling heuristic.
*
LayoutTests/fast/page-color-sampling/maintain-sampled-color-when-scrolled-to-top-expected.txt:
Added.
*
LayoutTests/fast/page-color-sampling/maintain-sampled-color-when-scrolled-to-top.html:
Added.
Add a new layout test that only makes the top header element fixed when the
user is not scrolled to
the top of the page.
*
LayoutTests/fast/page-color-sampling/page-color-sampling-skips-border-top.html:
*
LayoutTests/fast/page-color-sampling/page-color-sampling-skips-small-elements.html:
* Source/WebCore/page/LocalFrameView.cpp:
(WebCore::LocalFrameView::fixedContainerEdges const):
Implement two main adjustments here:
1. Be a bit more restrictive when collecting elements with background colors,
such that we ignore
any elements that are do not (nearly) span the entire width or height of
the layout viewport,
depending on which side we're sampling for. This prevents top fixed colors
from thrashing on
showcase.commercialtype.com, and also prevents a flash of white when
scrolling down on
www.amazon.com due to the fact that the text field (with a white
background) briefly takes up
most of the sampled pixels.
2. On various websites (www.amazon.com, www.mocanashville.org, and several
others), a site nav or
fixed top header will only be fixed when the user is scrolled; when the
scroll offset is 0, the
header becomes non-viewport-constrained, or otherwise undergoes style
changes that cause it to
be ignored by the fixed sampling strategy.
To mitigate a flash from fixed element background to page background color
in cases like this,
we leverage existing logic to sample the top of the page (including
non-fixed, non-sticky
elements and respecting images, text, etc.), and fall back on this page top
color in cases where
the last known top fixed container color is similar to the page top sampled
color, and we're
scrolled to (or past) the top of the page.
* Source/WebCore/page/Page.cpp:
(WebCore::Page::didCommitLoad):
* Source/WebCore/page/Page.h:
(WebCore::Page::setLastTopFixedContainerColor):
(WebCore::Page::lastTopFixedContainerColor const):
* Source/WebCore/page/PageColorSampler.cpp:
(WebCore::PageColorSampler::colorsAreSimilar):
Pull this helper lambda out into a static method, so that we can use it in
`fixedContainerEdges`
above.
(WebCore::PageColorSampler::predominantColor):
Also adjust a parameter representing the predominant sampled color min. ratio
(0.5); this leads to
some false positives on CommercialType's home page. This predominance ratio was
initially set to
this (fairly) low value, because page color sampling found text, images, and
other replaced objects.
Since we no longer paint those in the sampling snapshot (i.e. the sampling
heuristic is way more
accurate), we can raise this bar.
* Source/WebCore/page/PageColorSampler.h:
* Source/WebKit/WebProcess/WebPage/WebPage.cpp:
(WebKit::WebPage::willCommitLayerTree):
Add logic to keep track of the last top fixed container edge background color,
if present. This is
cleared out in `didCommitLoad` (above), and consulted in `fixedContainerEdges`
(above).
* Tools/WebKitTestRunner/TestOptions.cpp:
(WTR::TestOptions::defaults):
(WTR::TestOptions::keyTypeMapping):
* Tools/WebKitTestRunner/TestOptions.h:
(WTR::TestOptions::pageTopColorSamplingEnabled const):
* Tools/WebKitTestRunner/cocoa/TestControllerCocoa.mm:
(WTR::TestController::platformCreateWebView):
(WTR::TestController::configureWebpagePreferences):
Add a new `TestOption` for `pageTopColorSamplingEnabled`, which (when `true`)
sets both of the
following properties on the web view configuration:
```
-_sampledPageTopColorMaxDifference -> 30
-_sampledPageTopColorMinHeight -> 5
```
…note that these numbers are chosen for consistency with Safari. If needed, we
could split this out
into separate test options if an individual layout tests needs to exercise
different values, but for
now this is a bit cleaner, since each test doesn't need to specify its own
sampling parameters.
Also move logic to set `allowsInlinePredictions` out of
`configureWebpagePreferences` (which should
just be about `WKWebpagePreferences`) and into the call site instead.
Canonical link: https://commits.webkit.org/294820@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