- Revision
- 201065
- Author
- [email protected]
- Date
- 2016-05-17 19:07:11 -0700 (Tue, 17 May 2016)
Log Message
Add media query support for wide gamut displays on Mac
https://bugs.webkit.org/show_bug.cgi?id=157824
<rdar://problem/26333137>
Reviewed by Simon Fraser.
Source/WebCore:
Implement the Mac version of the color-gamut media query
by filling out the screenSupportsExtendedColor function.
On Yosemite, we always return false. On El Capitan, we
can check the ColorProfile via ColorSync to see if the
screen is wide gamut.
There is already a test in fast/media/mq-color-gamut.html
* css/MediaQueryEvaluator.cpp:
(WebCore::color_gamutMediaFeatureEval): Pass the mainFrame's view
to screenSupportsExtendedColor, so that it can fetch the NSScreen.
* platform/PlatformScreen.h: screenSupportsExtendedColor now takes
an optional Widget parameter.
* platform/ios/PlatformScreenIOS.mm:
(WebCore::screenSupportsExtendedColor): Add empty parameter.
* platform/mac/PlatformScreenMac.mm:
(WebCore::screenSupportsExtendedColor): Get the NSWindow, then the
NSScreen, then the ColorSpace, then the ColorSyncProfile, and
check if it is a wide gamut profile.
* platform/spi/cg/CoreGraphicsSPI.h: Add the SPI declarations.
LayoutTests:
Remove the check for sRGB, since it is confusingly false
on browsers that don't implement this query, and is likely
to be dropped from the specification.
Also, make the text readable.
* fast/media/mq-color-gamut-expected.html:
* fast/media/mq-color-gamut.html:
Modified Paths
Diff
Modified: trunk/LayoutTests/ChangeLog (201064 => 201065)
--- trunk/LayoutTests/ChangeLog 2016-05-18 01:26:11 UTC (rev 201064)
+++ trunk/LayoutTests/ChangeLog 2016-05-18 02:07:11 UTC (rev 201065)
@@ -1,3 +1,20 @@
+2016-05-17 Dean Jackson <[email protected]>
+
+ Add media query support for wide gamut displays on Mac
+ https://bugs.webkit.org/show_bug.cgi?id=157824
+ <rdar://problem/26333137>
+
+ Reviewed by Simon Fraser.
+
+ Remove the check for sRGB, since it is confusingly false
+ on browsers that don't implement this query, and is likely
+ to be dropped from the specification.
+
+ Also, make the text readable.
+
+ * fast/media/mq-color-gamut-expected.html:
+ * fast/media/mq-color-gamut.html:
+
2016-05-17 Joseph Pecoraro <[email protected]>
REGRESSION(r192855): Math.random() always produces the same first 7 decimal points the first two invocations
Modified: trunk/LayoutTests/fast/media/mq-color-gamut-expected.html (201064 => 201065)
--- trunk/LayoutTests/fast/media/mq-color-gamut-expected.html 2016-05-18 01:26:11 UTC (rev 201064)
+++ trunk/LayoutTests/fast/media/mq-color-gamut-expected.html 2016-05-18 02:07:11 UTC (rev 201065)
@@ -2,15 +2,13 @@
<head>
<title>CSS4 media query test: color-gamut.</title>
<style type="text/css">
-#a { background-color: green; }
-#b { background-color: blue; }
-#c { background-color: green; }
+#a { background-color: green; color: white; }
+#b { background-color: green; color: white; }
</style>
</head>
<body>
<p id="a">This paragraph should have a green background.</p>
- <p id="b">This paragraph should have a blue background on a device with a display that supports something close to sRGB, which is nearly all displays. Otherwise the background should be green.</p>
- <p id="c">This paragraph should have a blue background on a device with a display that supports something close to P3. Otherwise the background should be green.</p>
+ <p id="b">This paragraph should have a blue background on a device with a display that supports something close to P3. Otherwise the background should be green.</p>
<p>Note that the expected results of this test assume a display that is not significantly wider than sRGB.</p>
</body>
</html>
Modified: trunk/LayoutTests/fast/media/mq-color-gamut.html (201064 => 201065)
--- trunk/LayoutTests/fast/media/mq-color-gamut.html 2016-05-18 01:26:11 UTC (rev 201064)
+++ trunk/LayoutTests/fast/media/mq-color-gamut.html 2016-05-18 02:07:11 UTC (rev 201065)
@@ -2,23 +2,17 @@
<head>
<title>CSS4 media query test: color-gamut.</title>
<style type="text/css">
-#a { background-color: green; }
-#b { background-color: green; }
-#c { background-color: green; }
+#a { background-color: green; color: white; }
+#b { background-color: green; color: white; }
-@media (color-gamut: srgb) {
+@media (color-gamut: p3) {
#b { background-color: blue; }
}
-
-@media (color-gamut: p3) {
-#c { background-color: blue; }
-}
</style>
</head>
<body>
<p id="a">This paragraph should have a green background.</p>
- <p id="b">This paragraph should have a blue background on a device with a display that supports something close to sRGB, which is nearly all displays. Otherwise the background should be green.</p>
- <p id="c">This paragraph should have a blue background on a device with a display that supports something close to P3. Otherwise the background should be green.</p>
+ <p id="b">This paragraph should have a blue background on a device with a display that supports something close to P3. Otherwise the background should be green.</p>
<p>Note that the expected results of this test assume a display that is not significantly wider than sRGB.</p>
</body>
</html>
Modified: trunk/Source/WebCore/ChangeLog (201064 => 201065)
--- trunk/Source/WebCore/ChangeLog 2016-05-18 01:26:11 UTC (rev 201064)
+++ trunk/Source/WebCore/ChangeLog 2016-05-18 02:07:11 UTC (rev 201065)
@@ -1,3 +1,33 @@
+2016-05-17 Dean Jackson <[email protected]>
+
+ Add media query support for wide gamut displays on Mac
+ https://bugs.webkit.org/show_bug.cgi?id=157824
+ <rdar://problem/26333137>
+
+ Reviewed by Simon Fraser.
+
+ Implement the Mac version of the color-gamut media query
+ by filling out the screenSupportsExtendedColor function.
+
+ On Yosemite, we always return false. On El Capitan, we
+ can check the ColorProfile via ColorSync to see if the
+ screen is wide gamut.
+
+ There is already a test in fast/media/mq-color-gamut.html
+
+ * css/MediaQueryEvaluator.cpp:
+ (WebCore::color_gamutMediaFeatureEval): Pass the mainFrame's view
+ to screenSupportsExtendedColor, so that it can fetch the NSScreen.
+ * platform/PlatformScreen.h: screenSupportsExtendedColor now takes
+ an optional Widget parameter.
+ * platform/ios/PlatformScreenIOS.mm:
+ (WebCore::screenSupportsExtendedColor): Add empty parameter.
+ * platform/mac/PlatformScreenMac.mm:
+ (WebCore::screenSupportsExtendedColor): Get the NSWindow, then the
+ NSScreen, then the ColorSpace, then the ColorSyncProfile, and
+ check if it is a wide gamut profile.
+ * platform/spi/cg/CoreGraphicsSPI.h: Add the SPI declarations.
+
2016-05-17 Chris Dumez <[email protected]>
Unreviewed, fix Darin's post-mortem review comments for r201052.
Modified: trunk/Source/WebCore/css/MediaQueryEvaluator.cpp (201064 => 201065)
--- trunk/Source/WebCore/css/MediaQueryEvaluator.cpp 2016-05-18 01:26:11 UTC (rev 201064)
+++ trunk/Source/WebCore/css/MediaQueryEvaluator.cpp 2016-05-18 02:07:11 UTC (rev 201065)
@@ -246,7 +246,7 @@
return numberValue(value, number) && compareValue(0, static_cast<int>(number), op);
}
-static bool color_gamutMediaFeatureEval(CSSValue* value, const CSSToLengthConversionData&, Frame*, MediaFeaturePrefix)
+static bool color_gamutMediaFeatureEval(CSSValue* value, const CSSToLengthConversionData&, Frame* frame, MediaFeaturePrefix)
{
if (!value)
return true;
@@ -257,7 +257,7 @@
case CSSValueP3:
// FIXME: For the moment we'll just assume an "extended
// color" display is at least as good as P3.
- return screenSupportsExtendedColor();
+ return screenSupportsExtendedColor(frame->page()->mainFrame().view());
case CSSValueRec2020:
// FIXME: At some point we should start detecting displays that
// support more colors.
Modified: trunk/Source/WebCore/platform/PlatformScreen.h (201064 => 201065)
--- trunk/Source/WebCore/platform/PlatformScreen.h 2016-05-18 01:26:11 UTC (rev 201064)
+++ trunk/Source/WebCore/platform/PlatformScreen.h 2016-05-18 02:07:11 UTC (rev 201065)
@@ -63,7 +63,7 @@
FloatRect screenRect(Widget*);
FloatRect screenAvailableRect(Widget*);
- WEBCORE_EXPORT bool screenSupportsExtendedColor();
+ WEBCORE_EXPORT bool screenSupportsExtendedColor(Widget* widget = nullptr);
#if PLATFORM(MAC)
NSScreen *screenForWindow(NSWindow *);
Modified: trunk/Source/WebCore/platform/efl/PlatformScreenEfl.cpp (201064 => 201065)
--- trunk/Source/WebCore/platform/efl/PlatformScreenEfl.cpp 2016-05-18 01:26:11 UTC (rev 201064)
+++ trunk/Source/WebCore/platform/efl/PlatformScreenEfl.cpp 2016-05-18 02:07:11 UTC (rev 201065)
@@ -118,7 +118,7 @@
return screenRect(widget);
}
-bool screenSupportsExtendedColor()
+bool screenSupportsExtendedColor(Widget*)
{
return false;
}
Modified: trunk/Source/WebCore/platform/gtk/PlatformScreenGtk.cpp (201064 => 201065)
--- trunk/Source/WebCore/platform/gtk/PlatformScreenGtk.cpp 2016-05-18 01:26:11 UTC (rev 201064)
+++ trunk/Source/WebCore/platform/gtk/PlatformScreenGtk.cpp 2016-05-18 02:07:11 UTC (rev 201065)
@@ -130,7 +130,7 @@
}
-bool screenSupportsExtendedColor()
+bool screenSupportsExtendedColor(Widget*)
{
return false;
}
Modified: trunk/Source/WebCore/platform/ios/PlatformScreenIOS.mm (201064 => 201065)
--- trunk/Source/WebCore/platform/ios/PlatformScreenIOS.mm 2016-05-18 01:26:11 UTC (rev 201064)
+++ trunk/Source/WebCore/platform/ios/PlatformScreenIOS.mm 2016-05-18 02:07:11 UTC (rev 201065)
@@ -69,7 +69,7 @@
return UIAccessibilityIsInvertColorsEnabled();
}
-bool screenSupportsExtendedColor()
+bool screenSupportsExtendedColor(Widget*)
{
#if PLATFORM(IOS) && __IPHONE_OS_VERSION_MIN_REQUIRED >= 90300
return MGGetBoolAnswer(kMGQHasExtendedColorDisplay);
Modified: trunk/Source/WebCore/platform/mac/PlatformScreenMac.mm (201064 => 201065)
--- trunk/Source/WebCore/platform/mac/PlatformScreenMac.mm 2016-05-18 01:26:11 UTC (rev 201064)
+++ trunk/Source/WebCore/platform/mac/PlatformScreenMac.mm 2016-05-18 02:07:11 UTC (rev 201065)
@@ -26,10 +26,13 @@
#import "config.h"
#import "PlatformScreen.h"
+#import "CoreGraphicsSPI.h"
#import "FloatRect.h"
#import "FrameView.h"
#import "HostWindow.h"
+#import <ColorSync/ColorSync.h>
+
extern "C" {
bool CGDisplayUsesInvertedPolarity(void);
bool CGDisplayUsesForceToGray(void);
@@ -135,9 +138,30 @@
return nil;
}
-bool screenSupportsExtendedColor()
+bool screenSupportsExtendedColor(Widget* widget)
{
- return false; // FIXME: Update this to detect extended color screens.
+#if __MAC_OS_X_VERSION_MIN_REQUIRED < 101100
+ UNUSED_PARAM(widget);
+ return false;
+#else
+ if (!widget)
+ return false;
+
+ NSWindow *window = [widget->platformWidget() window];
+ NSScreen *screen = screenForWidget(widget, window);
+ CGColorSpaceRef colorSpace = screen.colorSpace.CGColorSpace;
+
+#if __MAC_OS_X_VERSION_MIN_REQUIRED >= 101200
+ return CGColorSpaceIsWideGamutRGB(colorSpace);
+#else
+ bool isWideGamut = false;
+ RetainPtr<CFDataRef> iccData = adoptCF(CGColorSpaceCopyICCProfile(colorSpace));
+ RetainPtr<ColorSyncProfileRef> profile = "" NULL));
+ if (profile)
+ isWideGamut = ColorSyncProfileIsWideGamut(profile.get());
+ return isWideGamut;
+#endif
+#endif
}
FloatRect toUserSpace(const NSRect& rect, NSWindow *destination)
Modified: trunk/Source/WebCore/platform/spi/cg/CoreGraphicsSPI.h (201064 => 201065)
--- trunk/Source/WebCore/platform/spi/cg/CoreGraphicsSPI.h 2016-05-18 01:26:11 UTC (rev 201064)
+++ trunk/Source/WebCore/platform/spi/cg/CoreGraphicsSPI.h 2016-05-18 02:07:11 UTC (rev 201065)
@@ -33,8 +33,13 @@
#include "IOSurfaceSPI.h"
#endif
+#if PLATFORM(MAC)
+#include <ColorSync/ColorSync.h>
+#endif
+
#if USE(APPLE_INTERNAL_SDK)
+#include <ColorSync/ColorSyncPriv.h>
#include <CoreGraphics/CGFontCache.h>
#include <CoreGraphics/CoreGraphicsPrivate.h>
@@ -195,6 +200,8 @@
CGError CGSSetConnectionProperty(CGSConnectionID, CGSConnectionID ownerCid, CFStringRef key, CFTypeRef value);
CGError CGSCopyConnectionProperty(CGSConnectionID, CGSConnectionID ownerCid, CFStringRef key, CFTypeRef *value);
CGError CGSGetScreenRectForWindow(CGSConnectionID, CGSWindowID, CGRect *);
+
+bool ColorSyncProfileIsWideGamut(ColorSyncProfileRef);
#endif
WTF_EXTERN_C_END
Modified: trunk/Source/WebCore/platform/win/PlatformScreenWin.cpp (201064 => 201065)
--- trunk/Source/WebCore/platform/win/PlatformScreenWin.cpp 2016-05-18 01:26:11 UTC (rev 201064)
+++ trunk/Source/WebCore/platform/win/PlatformScreenWin.cpp 2016-05-18 02:07:11 UTC (rev 201065)
@@ -101,7 +101,7 @@
return monitorInfo.rcWork;
}
-bool screenSupportsExtendedColor()
+bool screenSupportsExtendedColor(Widget*)
{
return false;
}