Title: [255881] trunk/Source
Revision
255881
Author
[email protected]
Date
2020-02-05 17:03:01 -0800 (Wed, 05 Feb 2020)

Log Message

Adopt MTOverrideShouldPlayHDRVideo()
https://bugs.webkit.org/show_bug.cgi?id=207275
<rdar://problem/58837093>

Reviewed by Eric Carlson.

Source/WebCore:

* platform/PlatformScreen.h:
* platform/mac/PlatformScreenMac.mm:
(WebCore::setShouldOverrideScreenSupportsHighDynamicRange):

Source/WebCore/PAL:

* pal/cocoa/MediaToolboxSoftLink.cpp:
* pal/cocoa/MediaToolboxSoftLink.h:

Source/WebKit:

The WebProcess sandbox can block access to the services necessary for MediaToolbox to determine whether
the current display is capable of displaying HDR. Rather than opening up the sandbox, provide the information
gathered by the UIProcess by way of MTOverrideShouldPlayHDRVideo().

* WebProcess/WebPage/WebPage.cpp:
(WebKit::WebPage::windowScreenDidChange):
(WebKit::WebPage::displayID const):
* WebProcess/WebPage/WebPage.h:
* WebProcess/WebProcess.cpp:
(WebKit::WebProcess::setScreenProperties): Deleted.
* WebProcess/WebProcess.h:
* WebProcess/cocoa/WebProcessCocoa.mm:
(WebKit::WebProcess::setScreenProperties):
(WebKit::WebProcess::updatePageScreenProperties):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (255880 => 255881)


--- trunk/Source/WebCore/ChangeLog	2020-02-06 00:56:29 UTC (rev 255880)
+++ trunk/Source/WebCore/ChangeLog	2020-02-06 01:03:01 UTC (rev 255881)
@@ -1,3 +1,15 @@
+2020-02-05  Jer Noble  <[email protected]>
+
+        Adopt MTOverrideShouldPlayHDRVideo()
+        https://bugs.webkit.org/show_bug.cgi?id=207275
+        <rdar://problem/58837093>
+
+        Reviewed by Eric Carlson.
+
+        * platform/PlatformScreen.h:
+        * platform/mac/PlatformScreenMac.mm:
+        (WebCore::setShouldOverrideScreenSupportsHighDynamicRange):
+
 2020-02-05  Chris Dumez  <[email protected]>
 
         [IPC hardening] Fail IPC decoding of invalid ClientOrigin objects

Modified: trunk/Source/WebCore/PAL/ChangeLog (255880 => 255881)


--- trunk/Source/WebCore/PAL/ChangeLog	2020-02-06 00:56:29 UTC (rev 255880)
+++ trunk/Source/WebCore/PAL/ChangeLog	2020-02-06 01:03:01 UTC (rev 255881)
@@ -1,3 +1,14 @@
+2020-02-05  Jer Noble  <[email protected]>
+
+        Adopt MTOverrideShouldPlayHDRVideo()
+        https://bugs.webkit.org/show_bug.cgi?id=207275
+        <rdar://problem/58837093>
+
+        Reviewed by Eric Carlson.
+
+        * pal/cocoa/MediaToolboxSoftLink.cpp:
+        * pal/cocoa/MediaToolboxSoftLink.h:
+
 2020-02-05  Commit Queue  <[email protected]>
 
         Unreviewed, rolling out r255818.

Modified: trunk/Source/WebCore/PAL/pal/cocoa/MediaToolboxSoftLink.cpp (255880 => 255881)


--- trunk/Source/WebCore/PAL/pal/cocoa/MediaToolboxSoftLink.cpp	2020-02-06 00:56:29 UTC (rev 255880)
+++ trunk/Source/WebCore/PAL/pal/cocoa/MediaToolboxSoftLink.cpp	2020-02-06 01:03:01 UTC (rev 255881)
@@ -33,5 +33,6 @@
 SOFT_LINK_FRAMEWORK_FOR_SOURCE_WITH_EXPORT(PAL, MediaToolbox, PAL_EXPORT)
 
 SOFT_LINK_FUNCTION_MAY_FAIL_FOR_SOURCE_WITH_EXPORT(PAL, MediaToolbox, MTShouldPlayHDRVideo, Boolean, (CFArrayRef displayList), (displayList), PAL_EXPORT)
+SOFT_LINK_FUNCTION_MAY_FAIL_FOR_SOURCE_WITH_EXPORT(PAL, MediaToolbox, MTOverrideShouldPlayHDRVideo, void, (Boolean override, Boolean playHDRVideo), (override, playHDRVideo), PAL_EXPORT)
 
 #endif

Modified: trunk/Source/WebCore/PAL/pal/cocoa/MediaToolboxSoftLink.h (255880 => 255881)


--- trunk/Source/WebCore/PAL/pal/cocoa/MediaToolboxSoftLink.h	2020-02-06 00:56:29 UTC (rev 255880)
+++ trunk/Source/WebCore/PAL/pal/cocoa/MediaToolboxSoftLink.h	2020-02-06 01:03:01 UTC (rev 255881)
@@ -33,5 +33,6 @@
 SOFT_LINK_FRAMEWORK_FOR_HEADER(PAL, MediaToolbox)
 
 SOFT_LINK_FUNCTION_MAY_FAIL_FOR_HEADER(PAL, MediaToolbox, MTShouldPlayHDRVideo, Boolean, (CFArrayRef displayList), (displayList))
+SOFT_LINK_FUNCTION_MAY_FAIL_FOR_HEADER(PAL, MediaToolbox, MTOverrideShouldPlayHDRVideo, void, (Boolean override, Boolean playHDRVideo), (override, playHDRVideo))
 
 #endif

Modified: trunk/Source/WebCore/platform/PlatformScreen.h (255880 => 255881)


--- trunk/Source/WebCore/platform/PlatformScreen.h	2020-02-06 00:56:29 UTC (rev 255880)
+++ trunk/Source/WebCore/platform/PlatformScreen.h	2020-02-06 01:03:01 UTC (rev 255881)
@@ -76,7 +76,7 @@
 WEBCORE_EXPORT bool screenSupportsExtendedColor(Widget* = nullptr);
 
 #if PLATFORM(MAC) || PLATFORM(IOS_FAMILY)
-bool screenSupportsHighDynamicRange(Widget* = nullptr);
+WEBCORE_EXPORT bool screenSupportsHighDynamicRange(Widget* = nullptr);
 #else
 constexpr bool screenSupportsHighDynamicRange(Widget* = nullptr) { return false; }
 #endif
@@ -105,6 +105,8 @@
 WEBCORE_EXPORT ScreenProperties collectScreenProperties();
 WEBCORE_EXPORT void setScreenProperties(const ScreenProperties&);
 
+WEBCORE_EXPORT void setShouldOverrideScreenSupportsHighDynamicRange(bool shouldOverride, bool supportsHighDynamicRange);
+
 WEBCORE_EXPORT PlatformDisplayID primaryScreenDisplayID();
 
 uint32_t primaryOpenGLDisplayMask();

Modified: trunk/Source/WebCore/platform/mac/PlatformScreenMac.mm (255880 => 255881)


--- trunk/Source/WebCore/platform/mac/PlatformScreenMac.mm	2020-02-06 00:56:29 UTC (rev 255880)
+++ trunk/Source/WebCore/platform/mac/PlatformScreenMac.mm	2020-02-06 01:03:01 UTC (rev 255881)
@@ -156,6 +156,12 @@
     screenProperties() = properties;
 }
 
+void setShouldOverrideScreenSupportsHighDynamicRange(bool shouldOverride, bool supportsHighDynamicRange)
+{
+    if (PAL::canLoad_MediaToolbox_MTOverrideShouldPlayHDRVideo())
+        PAL::softLink_MediaToolbox_MTOverrideShouldPlayHDRVideo(shouldOverride, supportsHighDynamicRange);
+}
+
 static ScreenData screenData(PlatformDisplayID screendisplayID)
 {
     RELEASE_ASSERT(!screenProperties().screenDataMap.isEmpty());

Modified: trunk/Source/WebKit/ChangeLog (255880 => 255881)


--- trunk/Source/WebKit/ChangeLog	2020-02-06 00:56:29 UTC (rev 255880)
+++ trunk/Source/WebKit/ChangeLog	2020-02-06 01:03:01 UTC (rev 255881)
@@ -1,3 +1,26 @@
+2020-02-05  Jer Noble  <[email protected]>
+
+        Adopt MTOverrideShouldPlayHDRVideo()
+        https://bugs.webkit.org/show_bug.cgi?id=207275
+        <rdar://problem/58837093>
+
+        Reviewed by Eric Carlson.
+
+        The WebProcess sandbox can block access to the services necessary for MediaToolbox to determine whether
+        the current display is capable of displaying HDR. Rather than opening up the sandbox, provide the information
+        gathered by the UIProcess by way of MTOverrideShouldPlayHDRVideo().
+
+        * WebProcess/WebPage/WebPage.cpp:
+        (WebKit::WebPage::windowScreenDidChange):
+        (WebKit::WebPage::displayID const):
+        * WebProcess/WebPage/WebPage.h:
+        * WebProcess/WebProcess.cpp:
+        (WebKit::WebProcess::setScreenProperties): Deleted.
+        * WebProcess/WebProcess.h:
+        * WebProcess/cocoa/WebProcessCocoa.mm:
+        (WebKit::WebProcess::setScreenProperties):
+        (WebKit::WebProcess::updatePageScreenProperties):
+
 2020-02-05  Wenson Hsieh  <[email protected]>
 
         [macCatalyst] Incorrect IBeam cursor when selecting text on Wikipedia

Modified: trunk/Source/WebKit/WebProcess/WebPage/WebPage.cpp (255880 => 255881)


--- trunk/Source/WebKit/WebProcess/WebPage/WebPage.cpp	2020-02-06 00:56:29 UTC (rev 255880)
+++ trunk/Source/WebKit/WebProcess/WebPage/WebPage.cpp	2020-02-06 01:03:01 UTC (rev 255881)
@@ -1993,6 +1993,10 @@
 void WebPage::windowScreenDidChange(uint32_t displayID)
 {
     m_page->chrome().windowScreenDidChange(static_cast<PlatformDisplayID>(displayID));
+
+#if PLATFORM(MAC)
+    WebProcess::singleton().updatePageScreenProperties();
+#endif
 }
 
 void WebPage::scalePage(double scale, const IntPoint& origin)

Modified: trunk/Source/WebKit/WebProcess/WebProcess.cpp (255880 => 255881)


--- trunk/Source/WebKit/WebProcess/WebProcess.cpp	2020-02-06 00:56:29 UTC (rev 255880)
+++ trunk/Source/WebKit/WebProcess/WebProcess.cpp	2020-02-06 01:03:01 UTC (rev 255881)
@@ -1877,15 +1877,6 @@
 }
 #endif
 
-#if PLATFORM(MAC)
-void WebProcess::setScreenProperties(const WebCore::ScreenProperties& properties)
-{
-    WebCore::setScreenProperties(properties);
-    for (auto& page : m_pageMap.values())
-        page->screenPropertiesDidChange();
-}
-#endif
-
 #if ENABLE(MEDIA_STREAM)
 void WebProcess::addMockMediaDevice(const WebCore::MockMediaDevice& device)
 {

Modified: trunk/Source/WebKit/WebProcess/WebProcess.h (255880 => 255881)


--- trunk/Source/WebKit/WebProcess/WebProcess.h	2020-02-06 00:56:29 UTC (rev 255880)
+++ trunk/Source/WebKit/WebProcess/WebProcess.h	2020-02-06 01:03:01 UTC (rev 255881)
@@ -323,6 +323,10 @@
     void revokeAccessToAssetServices();
 #endif
 
+#if PLATFORM(MAC)
+    void updatePageScreenProperties();
+#endif
+
 private:
     WebProcess();
     ~WebProcess();

Modified: trunk/Source/WebKit/WebProcess/cocoa/WebProcessCocoa.mm (255880 => 255881)


--- trunk/Source/WebKit/WebProcess/cocoa/WebProcessCocoa.mm	2020-02-06 00:56:29 UTC (rev 255880)
+++ trunk/Source/WebKit/WebProcess/cocoa/WebProcessCocoa.mm	2020-02-06 01:03:01 UTC (rev 255881)
@@ -78,6 +78,7 @@
 #import <pal/spi/mac/NSApplicationSPI.h>
 #import <stdio.h>
 #import <wtf/FileSystem.h>
+#import <wtf/ProcessPrivilege.h>
 #import <wtf/cocoa/NSURLExtras.h>
 
 #if PLATFORM(IOS)
@@ -929,6 +930,29 @@
 }
 #endif
 
+#if PLATFORM(MAC)
+void WebProcess::setScreenProperties(const ScreenProperties& properties)
+{
+    WebCore::setScreenProperties(properties);
+    for (auto& page : m_pageMap.values())
+        page->screenPropertiesDidChange();
+    updatePageScreenProperties();
+}
+
+void WebProcess::updatePageScreenProperties()
+{
+    if (hasProcessPrivilege(ProcessPrivilege::CanCommunicateWithWindowServer)) {
+        setShouldOverrideScreenSupportsHighDynamicRange(false, false);
+        return;
+    }
+
+    bool allPagesAreOnHDRScreens = allOf(m_pageMap.values(), [] (auto& page) {
+        return screenSupportsHighDynamicRange(page->mainFrameView());
+    });
+    setShouldOverrideScreenSupportsHighDynamicRange(true, allPagesAreOnHDRScreens);
+}
+#endif
+
 } // namespace WebKit
 
 #undef RELEASE_LOG_SESSION_ID
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to