Changeset 201065 in webkit


Ignore:
Timestamp:
May 17, 2016 7:07:11 PM (8 years ago)
Author:
dino@apple.com
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:
Location:
trunk
Files:
12 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r201053 r201065  
     12016-05-17  Dean Jackson  <dino@apple.com>
     2
     3        Add media query support for wide gamut displays on Mac
     4        https://bugs.webkit.org/show_bug.cgi?id=157824
     5        <rdar://problem/26333137>
     6
     7        Reviewed by Simon Fraser.
     8
     9        Remove the check for sRGB, since it is confusingly false
     10        on browsers that don't implement this query, and is likely
     11        to be dropped from the specification.
     12
     13        Also, make the text readable.
     14
     15        * fast/media/mq-color-gamut-expected.html:
     16        * fast/media/mq-color-gamut.html:
     17
    1182016-05-17  Joseph Pecoraro  <pecoraro@apple.com>
    219
  • trunk/LayoutTests/fast/media/mq-color-gamut-expected.html

    r199024 r201065  
    33<title>CSS4 media query test: color-gamut.</title>
    44<style type="text/css">
    5 #a { background-color: green; }
    6 #b { background-color: blue; }
    7 #c { background-color: green; }
     5#a { background-color: green; color: white; }
     6#b { background-color: green; color: white; }
    87</style>
    98</head>
    109<body>
    1110  <p id="a">This paragraph should have a green background.</p>
    12   <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>
    13   <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>
     11  <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>
    1412  <p>Note that the expected results of this test assume a display that is not significantly wider than sRGB.</p>
    1513</body>
  • trunk/LayoutTests/fast/media/mq-color-gamut.html

    r199024 r201065  
    33<title>CSS4 media query test: color-gamut.</title>
    44<style type="text/css">
    5 #a { background-color: green; }
    6 #b { background-color: green; }
    7 #c { background-color: green; }
    8 
    9 @media (color-gamut: srgb) {
    10 #b { background-color: blue; }
    11 }
     5#a { background-color: green; color: white; }
     6#b { background-color: green; color: white; }
    127
    138@media (color-gamut: p3) {
    14 #c { background-color: blue; }
     9#b { background-color: blue; }
    1510}
    1611</style>
     
    1813<body>
    1914  <p id="a">This paragraph should have a green background.</p>
    20   <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>
    21   <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>
     15  <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>
    2216  <p>Note that the expected results of this test assume a display that is not significantly wider than sRGB.</p>
    2317</body>
  • trunk/Source/WebCore/ChangeLog

    r201064 r201065  
     12016-05-17  Dean Jackson  <dino@apple.com>
     2
     3        Add media query support for wide gamut displays on Mac
     4        https://bugs.webkit.org/show_bug.cgi?id=157824
     5        <rdar://problem/26333137>
     6
     7        Reviewed by Simon Fraser.
     8
     9        Implement the Mac version of the color-gamut media query
     10        by filling out the screenSupportsExtendedColor function.
     11
     12        On Yosemite, we always return false. On El Capitan, we
     13        can check the ColorProfile via ColorSync to see if the
     14        screen is wide gamut.
     15
     16        There is already a test in fast/media/mq-color-gamut.html
     17
     18        * css/MediaQueryEvaluator.cpp:
     19        (WebCore::color_gamutMediaFeatureEval): Pass the mainFrame's view
     20        to screenSupportsExtendedColor, so that it can fetch the NSScreen.
     21        * platform/PlatformScreen.h: screenSupportsExtendedColor now takes
     22        an optional Widget parameter.
     23        * platform/ios/PlatformScreenIOS.mm:
     24        (WebCore::screenSupportsExtendedColor): Add empty parameter.
     25        * platform/mac/PlatformScreenMac.mm:
     26        (WebCore::screenSupportsExtendedColor): Get the NSWindow, then the
     27        NSScreen, then the ColorSpace, then the ColorSyncProfile, and
     28        check if it is a wide gamut profile.
     29        * platform/spi/cg/CoreGraphicsSPI.h: Add the SPI declarations.
     30
    1312016-05-17  Chris Dumez  <cdumez@apple.com>
    232
  • trunk/Source/WebCore/css/MediaQueryEvaluator.cpp

    r200336 r201065  
    247247}
    248248
    249 static bool color_gamutMediaFeatureEval(CSSValue* value, const CSSToLengthConversionData&, Frame*, MediaFeaturePrefix)
     249static bool color_gamutMediaFeatureEval(CSSValue* value, const CSSToLengthConversionData&, Frame* frame, MediaFeaturePrefix)
    250250{
    251251    if (!value)
     
    258258        // FIXME: For the moment we'll just assume an "extended
    259259        // color" display is at least as good as P3.
    260         return screenSupportsExtendedColor();
     260        return screenSupportsExtendedColor(frame->page()->mainFrame().view());
    261261    case CSSValueRec2020:
    262262        // FIXME: At some point we should start detecting displays that
  • trunk/Source/WebCore/platform/PlatformScreen.h

    r198719 r201065  
    6464    FloatRect screenAvailableRect(Widget*);
    6565
    66     WEBCORE_EXPORT bool screenSupportsExtendedColor();
     66    WEBCORE_EXPORT bool screenSupportsExtendedColor(Widget* widget = nullptr);
    6767
    6868#if PLATFORM(MAC)
  • trunk/Source/WebCore/platform/efl/PlatformScreenEfl.cpp

    r199024 r201065  
    119119}
    120120
    121 bool screenSupportsExtendedColor()
     121bool screenSupportsExtendedColor(Widget*)
    122122{
    123123    return false;
  • trunk/Source/WebCore/platform/gtk/PlatformScreenGtk.cpp

    r199024 r201065  
    131131}
    132132
    133 bool screenSupportsExtendedColor()
     133bool screenSupportsExtendedColor(Widget*)
    134134{
    135135    return false;
  • trunk/Source/WebCore/platform/ios/PlatformScreenIOS.mm

    r198719 r201065  
    7070}
    7171
    72 bool screenSupportsExtendedColor()
     72bool screenSupportsExtendedColor(Widget*)
    7373{
    7474#if PLATFORM(IOS) && __IPHONE_OS_VERSION_MIN_REQUIRED >= 90300
  • trunk/Source/WebCore/platform/mac/PlatformScreenMac.mm

    r198719 r201065  
    2727#import "PlatformScreen.h"
    2828
     29#import "CoreGraphicsSPI.h"
    2930#import "FloatRect.h"
    3031#import "FrameView.h"
    3132#import "HostWindow.h"
     33
     34#import <ColorSync/ColorSync.h>
    3235
    3336extern "C" {
     
    136139}
    137140
    138 bool screenSupportsExtendedColor()
     141bool screenSupportsExtendedColor(Widget* widget)
    139142{
    140     return false; // FIXME: Update this to detect extended color screens.
     143#if __MAC_OS_X_VERSION_MIN_REQUIRED < 101100
     144    UNUSED_PARAM(widget);
     145    return false;
     146#else
     147    if (!widget)
     148        return false;
     149
     150    NSWindow *window = [widget->platformWidget() window];
     151    NSScreen *screen = screenForWidget(widget, window);
     152    CGColorSpaceRef colorSpace = screen.colorSpace.CGColorSpace;
     153
     154#if __MAC_OS_X_VERSION_MIN_REQUIRED >= 101200
     155    return CGColorSpaceIsWideGamutRGB(colorSpace);
     156#else
     157    bool isWideGamut = false;
     158    RetainPtr<CFDataRef> iccData = adoptCF(CGColorSpaceCopyICCProfile(colorSpace));
     159    RetainPtr<ColorSyncProfileRef> profile = adoptCF(ColorSyncProfileCreate(iccData.get(), NULL));
     160    if (profile)
     161        isWideGamut = ColorSyncProfileIsWideGamut(profile.get());
     162    return isWideGamut;
     163#endif
     164#endif
    141165}
    142166
  • trunk/Source/WebCore/platform/spi/cg/CoreGraphicsSPI.h

    r199071 r201065  
    3434#endif
    3535
     36#if PLATFORM(MAC)
     37#include <ColorSync/ColorSync.h>
     38#endif
     39
    3640#if USE(APPLE_INTERNAL_SDK)
    3741
     42#include <ColorSync/ColorSyncPriv.h>
    3843#include <CoreGraphics/CGFontCache.h>
    3944#include <CoreGraphics/CoreGraphicsPrivate.h>
     
    196201CGError CGSCopyConnectionProperty(CGSConnectionID, CGSConnectionID ownerCid, CFStringRef key, CFTypeRef *value);
    197202CGError CGSGetScreenRectForWindow(CGSConnectionID, CGSWindowID, CGRect *);
     203
     204bool ColorSyncProfileIsWideGamut(ColorSyncProfileRef);
    198205#endif
    199206
  • trunk/Source/WebCore/platform/win/PlatformScreenWin.cpp

    r199024 r201065  
    102102}
    103103
    104 bool screenSupportsExtendedColor()
     104bool screenSupportsExtendedColor(Widget*)
    105105{
    106106    return false;
Note: See TracChangeset for help on using the changeset viewer.