[webkit-changes] [WebKit/WebKit] f5aa57: [Cocoa] Add a heuristic to detect and sample color...
Wenson Hsieh
noreply at github.com
Fri Feb 14 12:16:05 PST 2025
Branch: refs/heads/main
Home: https://github.com/WebKit/WebKit
Commit: f5aa57b6b88aa2ffca5cd1457a45c56723031bcd
https://github.com/WebKit/WebKit/commit/f5aa57b6b88aa2ffca5cd1457a45c56723031bcd
Author: Wenson Hsieh <wenson_hsieh at apple.com>
Date: 2025-02-14 (Fri, 14 Feb 2025)
Changed paths:
M Source/WebCore/Headers.cmake
M Source/WebCore/WebCore.xcodeproj/project.pbxproj
M Source/WebCore/page/LocalFrameView.cpp
M Source/WebCore/page/LocalFrameView.h
M Source/WebCore/page/PageColorSampler.cpp
M Source/WebCore/page/PageColorSampler.h
A Source/WebCore/platform/FixedContainerEdges.h
Log Message:
-----------
[Cocoa] Add a heuristic to detect and sample colors in fixed-position elements at the edges of the viewport
https://bugs.webkit.org/show_bug.cgi?id=287690
rdar://144839983
Reviewed by Abrar Rahman Protyasha.
Work towards rdar://144839983; see below for more details.
* Source/WebCore/Headers.cmake:
* Source/WebCore/WebCore.xcodeproj/project.pbxproj:
* Source/WebCore/page/LocalFrameView.cpp:
(WebCore::LocalFrameView::fixedContainerEdges const):
Add a helper method that returns the set of `FixedContainerEdges` (see the new header below), by
first hit-testing around all 4 edges of the layout viewport in search of elements with fixed-
position ancestors in the render tree; for each edge with a fixed ancestor, we then use the new
page color sampling helper below to extract the predominant color.
* Source/WebCore/page/LocalFrameView.h:
* Source/WebCore/page/PageColorSampler.cpp:
(WebCore::PageColorSampler::predominantColor):
Add a helper method that samples the predominant color in the given rect (in absolute coordinates)
by taking a snapshot, building a histogram of color frequencies, and checking whether the number of
similar colors represents a majority of all sampled colors.
* Source/WebCore/page/PageColorSampler.h:
* Source/WebCore/platform/FixedContainerEdges.h: Added.
Add a helper class, `FixedContainerEdges`, that represents two pieces of information about each of
the 4 edges of the layout viewport (top, left, bottom, right):
- Whether there's a fixed-position container near that edge.
- A sampled predominant color, or the invalid color if none is detected (e.g. due to too many
different colors).
Canonical link: https://commits.webkit.org/290411@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