[webkit-changes] [WebKit/WebKit] 1285af: Handle suppress-HDR notifications for videos

Gerald Squelart noreply at github.com
Fri Feb 28 14:53:19 PST 2025


  Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: 1285af2e9967b3e26c6c8b67a60f73d1b3f9594e
      https://github.com/WebKit/WebKit/commit/1285af2e9967b3e26c6c8b67a60f73d1b3f9594e
  Author: Gerald Squelart <g_squelart at apple.com>
  Date:   2025-02-28 (Fri, 28 Feb 2025)

  Changed paths:
    A LayoutTests/media/video-suppress-hdr-dynamic-range-limit-expected.txt
    A LayoutTests/media/video-suppress-hdr-dynamic-range-limit.html
    A LayoutTests/media/video-suppress-hdr-expected.txt
    A LayoutTests/media/video-suppress-hdr.html
    M Source/WebCore/dom/Document.cpp
    M Source/WebCore/dom/Document.h
    M Source/WebCore/html/HTMLMediaElement.cpp
    M Source/WebCore/html/HTMLMediaElement.h
    M Source/WebCore/page/Page.cpp
    M Source/WebCore/page/Page.h
    M Source/WebCore/testing/Internals.cpp
    M Source/WebCore/testing/Internals.h
    M Source/WebCore/testing/Internals.idl
    M Source/WebKit/Platform/spi/mac/AppKitSPI.h
    M Source/WebKit/UIProcess/API/ios/WKWebViewIOS.mm
    M Source/WebKit/UIProcess/Cocoa/WebProcessPoolCocoa.mm
    M Source/WebKit/UIProcess/WebPageProxy.cpp
    M Source/WebKit/UIProcess/WebPageProxy.h
    M Source/WebKit/UIProcess/WebProcessPool.h
    M Source/WebKit/WebProcess/WebPage/WebPage.cpp
    M Source/WebKit/WebProcess/WebPage/WebPage.h
    M Source/WebKit/WebProcess/WebPage/WebPage.messages.in
    M Source/WebKit/WebProcess/WebProcess.cpp
    M Source/WebKit/WebProcess/WebProcess.h
    M Source/WebKit/WebProcess/WebProcess.messages.in

  Log Message:
  -----------
  Handle suppress-HDR notifications for videos
https://bugs.webkit.org/show_bug.cgi?id=288690
rdar://145717196

Reviewed by Simon Fraser.

This patch observes notifications or trait changes that
request the application or view to suppress HDR content
in videos (by constraining it).

This signal gets combined with the existing CSS
`dynamic-range-limit` to enforce the minimum of the two
constraints.

* Source/WebKit/UIProcess/API/ios/WKWebViewIOS.mm:
(-[WKWebView _registerForNotifications]):
(-[WKWebView _UITraitHDRHeadroomUsageDidChange]):
Trait change entry point on iOS, forwarded to WebPageProxy.
The initial value is also sent.

* Source/WebKit/UIProcess/WebPageProxy.cpp:
(WebKit::WebPageProxy::setShouldSuppressHDR):
* Source/WebKit/UIProcess/WebPageProxy.h:
Forwarded to WebPage. (To be continued further below...)

* Source/WebKit/UIProcess/WebProcessPool.h:
* Source/WebKit/UIProcess/Cocoa/WebProcessPoolCocoa.mm:
(WebKit::WebProcessPool::registerNotificationObservers):
(WebKit::WebProcessPool::unregisterNotificationObservers):
Notification entry point on macOS, forwarded to all WebProcess'es.

* Source/WebKit/WebProcess/WebProcess.cpp:
(WebKit::WebProcess::createWebPage):
(WebKit::WebProcess::setShouldSuppressHDR):
* Source/WebKit/WebProcess/WebProcess.h:
* Source/WebKit/WebProcess/WebProcess.messages.in:
Cache the shouldSuppressHDR flag (for future page creations),
and forward to WebPage's.

* Source/WebKit/WebProcess/WebPage/WebPage.cpp:
(WebKit::WebPage::setShouldSuppressHDR):
* Source/WebKit/WebProcess/WebPage/WebPage.h:
* Source/WebKit/WebProcess/WebPage/WebPage.messages.in:
Meeting point between iOS trait changes and macOS notifications.
Forward to Page.

* Source/WebCore/page/Page.cpp:
(WebCore::Page::setShouldSuppressHDR):
* Source/WebCore/page/Page.h:
(WebCore::Page::shouldSuppressHDR const):
Store the flag (for use by document and elements).
Notify Document if the flag changed.

* Source/WebCore/dom/Document.cpp:
(WebCore::Document::shouldSuppressHDRDidChange):
* Source/WebCore/dom/Document.h:
Notify all media elements.

* Source/WebCore/html/HTMLMediaElement.cpp:
(WebCore::HTMLMediaElement::computePlayerDynamicRangeLimit const):
(WebCore::HTMLMediaElement::dynamicRangeLimitDidChange):
(WebCore::HTMLMediaElement::shouldSuppressHDRDidChange):
* Source/WebCore/html/HTMLMediaElement.h:
On notification (or dynamic-range-limit change), combine Page's
suppress-HDR with dynamic-range-limit, and update MediaPlayer's
effective dynamic range limit (already implemented in previous patch).

* Source/WebKit/Platform/spi/mac/AppKitSPI.h:
Add include relevant to notifications.

* Source/WebCore/testing/Internals.cpp:
(WebCore::Internals::effectiveDynamicRangeLimitValue):
(WebCore::Internals::setPageShouldSuppressHDR):
* Source/WebCore/testing/Internals.h:
* Source/WebCore/testing/Internals.idl:
Simulate notifications at the Page level, examine effective
dynamic range limit in media elements.

* LayoutTests/media/video-suppress-hdr-dynamic-range-limit-expected.txt: Added.
* LayoutTests/media/video-suppress-hdr-dynamic-range-limit.html: Added.
* LayoutTests/media/video-suppress-hdr-expected.txt: Added.
* LayoutTests/media/video-suppress-hdr.html: Added.
Test combinations of notifications and video creations.

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