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

  Changed paths:
    M 
LayoutTests/fast/page-color-sampling/color-sampling-ignores-backdrop-filters-expected.txt
    M 
LayoutTests/fast/page-color-sampling/color-sampling-ignores-backdrop-filters.html
    A 
LayoutTests/fast/page-color-sampling/color-sampling-ignores-empty-container-expected.txt
    A 
LayoutTests/fast/page-color-sampling/color-sampling-ignores-empty-container.html
    M Source/WebCore/page/LocalFrameView.cpp
    M Source/WebCore/page/PageColorSampler.cpp
    M Source/WebCore/page/PageColorSampler.h
    M Source/WebCore/platform/BoxSides.h
    M Source/WebCore/platform/FixedContainerEdges.h
    M Source/WebKit/Shared/WebCoreArgumentCoders.serialization.in
    M Source/WebKit/UIProcess/API/Cocoa/WKWebView.mm
    M Source/WebKit/UIProcess/API/Cocoa/WKWebViewPrivate.h
    M Source/WebKit/UIProcess/API/Cocoa/WKWebViewPrivateForTesting.h
    M Tools/WebKitTestRunner/cocoa/UIScriptControllerCocoa.mm

  Log Message:
  -----------
  [Page color sampling] hulu.com: bottom fixed container is incorrectly treated 
as fixed container edge
https://bugs.webkit.org/show_bug.cgi?id=290963
rdar://146925724

Reviewed by Aditya Keerthi.

Currently, the `FixedContainerEdges` struct consists of two pieces of data:

1.  A flag on each rect edge, denoting whether there's a fixed container docked 
to that rect edge.
2.  A color on each rect edge, representing the primary color for that edge (or 
an invalid color in
    the case of either multiple colors, or if there is no visible color).

In the case where there's a fixed-position container docked to a viewport edge, 
hit-testing will
find the container and set the fixed edge flag on that edge. However, if the 
container doesn't
actually render any visible content near that edge (e.g. if it's completely 
transparent, with no
background and no children), we end up returning the invalid color from 
`predominantColor`, which
we then handle in the same way as having multiple visible colors — by filling 
the inset area with
the page background color.

Instead, we should simply treat this scenario has not having a fixed edge in 
the first place. To
achieve this, we add an early return in `PageColorSampler::predominantColor` if 
`colorDistribution`
is empty (i.e. there's no visible pixels).

We also refactor this code, to tighten `FixedContainerEdges` state: instead of 
using separate rect
edges representing the presence of fixed objects and the predominant color 
along each edge, we use
a single variant per edge that contains one of:

-   A `PredominantColorType` enum, which is either `None` (representing no 
fixed edge) or `Multiple`
    (representing a fixed edge with multiple colors).

-   A `Color` representing a single, solid predominant color along a fixed edge.

* 
LayoutTests/fast/page-color-sampling/color-sampling-ignores-backdrop-filters-expected.txt:
* 
LayoutTests/fast/page-color-sampling/color-sampling-ignores-backdrop-filters.html:

Adjust an existing layout test to account for the fact that multiple colors are 
now represented by
the string `"multiple"`.

* 
LayoutTests/fast/page-color-sampling/color-sampling-ignores-empty-container-expected.txt:
* 
LayoutTests/fast/page-color-sampling/color-sampling-ignores-empty-container.html:
* Source/WebCore/page/LocalFrameView.cpp:
(WebCore::LocalFrameView::fixedContainerEdges const):
* Source/WebCore/page/PageColorSampler.cpp:
(WebCore::PageColorSampler::predominantColor):

Refactor this entire method to reduce code duplication, by pulling all 
rect-edge-specific logic out
into separate lambdas, and then simply iterating over all requested 
`BoxSideFlag`s to set fixed
container edge data.

* Source/WebCore/page/PageColorSampler.h:

Make `predominantColor` return a variant of `PredominantColorType, Color`.

* Source/WebCore/platform/BoxSides.h:
(WebCore::boxSideFromFlag):

Add a `constexpr` helper to convert from `BoxSideFlag` to `BoxSide`.

* Source/WebCore/platform/FixedContainerEdges.h:
(WebCore::FixedContainerEdges::hasFixedEdge const):
(WebCore::FixedContainerEdges::predominantColor const):
* Source/WebKit/Shared/WebCoreArgumentCoders.serialization.in:
* Source/WebKit/UIProcess/API/Cocoa/WKWebView.mm:
(-[WKWebView _fixedContainerEdges]):
(sampledFixedPositionContentColor):
(-[WKWebView _sampledBottomFixedPositionContentColor]):
(-[WKWebView _sampledLeftFixedPositionContentColor]):
(-[WKWebView _sampledTopFixedPositionContentColor]):
(-[WKWebView _sampledRightFixedPositionContentColor]):
(-[WKWebView _updateFixedContainerEdges:]):
(-[WKWebView _updateFixedColorExtensionViews]):
(-[WKWebView _sampledBottomFixedPositionContentColor:]): Deleted.
(-[WKWebView _sampledLeftFixedPositionContentColor:]): Deleted.
(-[WKWebView _sampledTopFixedPositionContentColor:]): Deleted.
(-[WKWebView _sampledRightFixedPositionContentColor:]): Deleted.

Move several SPI methods that are no longer needed by internal clients into the 
testing-only
`WKWebView` category.

* Source/WebKit/UIProcess/API/Cocoa/WKWebViewPrivate.h:
* Source/WebKit/UIProcess/API/Cocoa/WKWebViewPrivateForTesting.h:
* Tools/WebKitTestRunner/cocoa/UIScriptControllerCocoa.mm:
(WTR::UIScriptControllerCocoa::fixedContainerEdgeColors const):

Make a slight adjustment to the testing helpers, to differentiate the "no fixed 
edge" case from the
"multiple colors" case. Multiple colors are now represented by the string 
"multiple", while not
having any fixed edge is represented with `null`.

Canonical link: https://commits.webkit.org/293146@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