Changeset 230356 in webkit


Ignore:
Timestamp:
Apr 6, 2018 3:54:37 PM (6 years ago)
Author:
Brent Fulgham
Message:

WebCore::screenSupportsExtendedColor improperly calls NSScreen functions in the WebContent process
https://bugs.webkit.org/show_bug.cgi?id=184364
<rdar://problem/39246314>

Reviewed by Per Arne Vollan.

The WebContent process is interacting directly with NSScreen to determine if the current screen
has extended color support. This should be brokered from the UIProcess.

Tested by fast/media/mq-color-gamut.html.

  • platform/ScreenProperties.h:

(WebCore::ScreenProperties::encode const): Add screenSupportsExtendedColor.
(WebCore::ScreenProperties::decode): Ditto.

  • platform/mac/PlatformScreenMac.mm:

(WebCore::getScreenProperties): Retrieve extended color support.
(WebCore::screenSupportsExtendedColor): Retrieve cached version when in the WebContent
process. Assert that NSScreen is not accessed in the WebContent process.

Location:
trunk/Source/WebCore
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r230355 r230356  
     12018-04-06  Brent Fulgham  <bfulgham@apple.com>
     2
     3        WebCore::screenSupportsExtendedColor improperly calls NSScreen functions in the WebContent process
     4        https://bugs.webkit.org/show_bug.cgi?id=184364
     5        <rdar://problem/39246314>
     6
     7        Reviewed by Per Arne Vollan.
     8
     9        The WebContent process is interacting directly with NSScreen to determine if the current screen
     10        has extended color support. This should be brokered from the UIProcess.
     11       
     12        Tested by fast/media/mq-color-gamut.html.
     13
     14        * platform/ScreenProperties.h:
     15        (WebCore::ScreenProperties::encode const): Add screenSupportsExtendedColor.
     16        (WebCore::ScreenProperties::decode): Ditto.
     17        * platform/mac/PlatformScreenMac.mm:
     18        (WebCore::getScreenProperties): Retrieve extended color support.
     19        (WebCore::screenSupportsExtendedColor): Retrieve cached version when in the WebContent
     20        process. Assert that NSScreen is not accessed in the WebContent process.
     21
    1222018-04-06  Fujii Hironori  <Hironori.Fujii@sony.com>
    223
  • trunk/Source/WebCore/platform/ScreenProperties.h

    r230351 r230356  
    4242    int screenDepth { 0 };
    4343    int screenDepthPerComponent { 0 };
     44    bool screenSupportsExtendedColor { false };
    4445    bool screenHasInvertedColors { false };
    4546    bool screenIsMonochrome { false };
     
    5859void ScreenProperties::encode(Encoder& encoder) const
    5960{
    60     encoder << screenAvailableRect << screenRect << screenDepth << screenDepthPerComponent << screenHasInvertedColors << screenIsMonochrome;
     61    encoder << screenAvailableRect << screenRect << screenDepth << screenDepthPerComponent << screenSupportsExtendedColor << screenHasInvertedColors << screenIsMonochrome;
    6162
    6263    if (colorSpace) {
     
    107108        return std::nullopt;
    108109
     110    std::optional<bool> screenSupportsExtendedColor;
     111    decoder >> screenSupportsExtendedColor;
     112    if (!screenSupportsExtendedColor)
     113        return std::nullopt;
     114
    109115    std::optional<bool> screenHasInvertedColors;
    110116    decoder >> screenHasInvertedColors;
     
    152158    }
    153159
    154     return { { WTFMove(*screenAvailableRect), WTFMove(*screenRect), WTFMove(cgColorSpace), WTFMove(*screenDepth), WTFMove(*screenDepthPerComponent), WTFMove(*screenHasInvertedColors), WTFMove(*screenIsMonochrome) } };
     160    return { { WTFMove(*screenAvailableRect), WTFMove(*screenRect), WTFMove(cgColorSpace), WTFMove(*screenDepth), WTFMove(*screenDepthPerComponent), WTFMove(*screenSupportsExtendedColor), WTFMove(*screenHasInvertedColors), WTFMove(*screenIsMonochrome) } };
    155161}
    156162
  • trunk/Source/WebCore/platform/mac/PlatformScreenMac.mm

    r230352 r230356  
    4949static PlatformDisplayID displayID(NSScreen *screen)
    5050{
    51     RELEASE_ASSERT(hasProcessPrivilege(ProcessPrivilege::CanCommunicateWithWindowServer));
     51    // FIXME: <https://webkit.org/b/184344> We should assert here if in WebContent process.
    5252    return [[[screen deviceDescription] objectForKey:@"NSScreenNumber"] intValue];
    5353}
     
    7272static NSScreen *firstScreen()
    7373{
    74     RELEASE_ASSERT(hasProcessPrivilege(ProcessPrivilege::CanCommunicateWithWindowServer));
     74    // FIXME: <https://webkit.org/b/184344> We should assert here if in WebContent process.
    7575    NSArray *screens = [NSScreen screens];
    7676    if (![screens count])
     
    113113        int screenDepth = NSBitsPerPixelFromDepth(screen.depth);
    114114        int screenDepthPerComponent = NSBitsPerSampleFromDepth(screen.depth);
     115        bool screenSupportsExtendedColor = [screen canRepresentDisplayGamut:NSDisplayGamutP3];
    115116        bool screenHasInvertedColors = CGDisplayUsesInvertedPolarity();
    116117        bool screenIsMonochrome = CGDisplayUsesForceToGray();
    117118
    118         screenProperties.set(WebCore::displayID(screen), ScreenProperties { screenAvailableRect, screenRect, colorSpace, screenDepth, screenDepthPerComponent, screenHasInvertedColors, screenIsMonochrome });
     119        screenProperties.set(WebCore::displayID(screen), ScreenProperties { screenAvailableRect, screenRect, colorSpace, screenDepth, screenDepthPerComponent, screenSupportsExtendedColor, screenHasInvertedColors, screenIsMonochrome });
    119120    }
    120121}
     
    230231        return false;
    231232
    232     // FIXME: <https://webkit.org/b/184364> We should assert here if in WebContent process.
     233    if (!screenProperties().isEmpty())
     234        return getScreenProperties(widget).screenSupportsExtendedColor;
     235
     236    RELEASE_ASSERT(hasProcessPrivilege(ProcessPrivilege::CanCommunicateWithWindowServer));
    233237    return [screen(widget) canRepresentDisplayGamut:NSDisplayGamutP3];
    234238}
Note: See TracChangeset for help on using the changeset viewer.