Changeset 230323 in webkit
- Timestamp:
- Apr 5, 2018 9:44:32 PM (6 years ago)
- Location:
- trunk/Source
- Files:
-
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r230319 r230323 1 2018-04-05 Brent Fulgham <bfulgham@apple.com> 2 3 WebContent process is calling CGDisplayUsesInvertedPolarity 4 https://bugs.webkit.org/show_bug.cgi?id=184337 5 <rdar://problem/39215702> 6 7 Reviewed by Zalan Bujtas. 8 9 The PlatformScreenMac code is still calling display-related routines directly, specifically 10 CGDisplayUsesInvertedPolarity and CGDisplayUsesForceToGray. These should be brokered from 11 the UIProcess. 12 13 There's also no reason to avoid the brokering behavior on current WebKit builds. Remove 14 the compile guards so all macOS builds use this behavior. 15 16 Finally, add some ProcessPrivilege assertions to guard against accidentally calling these 17 routines in the future. 18 19 Tested by existing regression tests. 20 21 * platform/PlatformScreen.h: 22 * platform/ScreenProperties.h: 23 (WebCore::ScreenProperties::encode const): Add new values. 24 (WebCore::ScreenProperties::decode): 25 * platform/mac/PlatformScreenMac.mm: 26 (WebCore::displayID): Add assertion that this is not calling display-related routines in 27 the WebContent process. 28 (WebCore::firstScreen): Ditto. 29 (WebCore::screenProperties): Moved higher in the file so it can be reused. Add calls to 30 CGDisplayUsesInvertedPolarity and CGDisplayUsesForceToGray. 31 (WebCore::getScreenProperties): Moved higher in the file so it can be reused. Stop 32 double-hashing displayID. 33 (WebCore::screenIsMonochrome): Use cached values in WebContent process. Assert if this 34 code attempts a display-related routine in the WebContent process. 35 (WebCore::screenHasInvertedColors): Ditto. 36 (WebCore::screenDepth): Add assertion that this is not calling display-related routines in 37 the WebContent process. 38 (WebCore::screenDepthPerComponent): Ditto. 39 (WebCore::screenRect): Ditto. 40 (WebCore::screenAvailableRect): Ditto. 41 (WebCore::screen): Ditto. 42 (WebCore::screenColorSpace): Ditto. 43 (WebCore::screenSupportsExtendedColor): Ditto. 44 1 45 2018-04-05 John Wilander <wilander@apple.com> 2 46 -
trunk/Source/WebCore/platform/PlatformScreen.h
r230059 r230323 1 1 /* 2 * Copyright (C) 2006 Apple Inc. All rights reserved.2 * Copyright (C) 2006-2018 Apple Inc. All rights reserved. 3 3 * 4 4 * Redistribution and use in source and binary forms, with or without … … 90 90 NSPoint flipScreenPoint(const NSPoint&, NSScreen *); 91 91 92 #if __MAC_OS_X_VERSION_MIN_REQUIRED >= 10140093 92 WEBCORE_EXPORT void getScreenProperties(HashMap<PlatformDisplayID, ScreenProperties>&); 94 93 WEBCORE_EXPORT void setScreenProperties(const HashMap<PlatformDisplayID, ScreenProperties>&); 95 #endif96 94 97 95 #endif -
trunk/Source/WebCore/platform/ScreenProperties.h
r228940 r230323 35 35 int screenDepth { 0 }; 36 36 int screenDepthPerComponent { 0 }; 37 bool screenHasInvertedColors { false }; 38 bool screenIsMonochrome { false }; 37 39 38 40 template<class Encoder> void encode(Encoder&) const; … … 43 45 void ScreenProperties::encode(Encoder& encoder) const 44 46 { 45 encoder << screenAvailableRect << screenRect << screenDepth << screenDepthPerComponent ;47 encoder << screenAvailableRect << screenRect << screenDepth << screenDepthPerComponent << screenHasInvertedColors << screenIsMonochrome; 46 48 } 47 49 … … 68 70 if (!screenDepthPerComponent) 69 71 return std::nullopt; 70 71 return { { WTFMove(*screenAvailableRect), WTFMove(*screenRect), WTFMove(*screenDepth), WTFMove(*screenDepthPerComponent) } }; 72 73 std::optional<bool> screenHasInvertedColors; 74 decoder >> screenHasInvertedColors; 75 if (!screenHasInvertedColors) 76 return std::nullopt; 77 78 std::optional<bool> screenIsMonochrome; 79 decoder >> screenIsMonochrome; 80 if (!screenIsMonochrome) 81 return std::nullopt; 82 83 return { { WTFMove(*screenAvailableRect), WTFMove(*screenRect), WTFMove(*screenDepth), WTFMove(*screenDepthPerComponent), WTFMove(*screenHasInvertedColors), WTFMove(*screenIsMonochrome) } }; 72 84 } 73 85 -
trunk/Source/WebCore/platform/mac/PlatformScreenMac.mm
r228940 r230323 1 1 /* 2 * Copyright (C) 2006 Apple Inc. All rights reserved.2 * Copyright (C) 2006-2018 Apple Inc. All rights reserved. 3 3 * 4 4 * Redistribution and use in source and binary forms, with or without … … 35 35 #import <ColorSync/ColorSync.h> 36 36 #import <pal/spi/cg/CoreGraphicsSPI.h> 37 #import <wtf/ProcessPrivilege.h> 37 38 38 39 extern "C" { … … 48 49 static PlatformDisplayID displayID(NSScreen *screen) 49 50 { 51 // FIXME: <http://webkit.org/b/184343> We should assert here if in WebContent process. 50 52 return [[[screen deviceDescription] objectForKey:@"NSScreenNumber"] intValue]; 51 53 } … … 70 72 static NSScreen *firstScreen() 71 73 { 74 // FIXME: <http://webkit.org/b/184343> We should assert here if in WebContent process. 72 75 NSArray *screens = [NSScreen screens]; 73 76 if (![screens count]) … … 92 95 } 93 96 94 bool screenIsMonochrome(Widget*) 95 { 96 // This is a system-wide accessibility setting, same on all screens. 97 return CGDisplayUsesForceToGray(); 98 } 99 100 bool screenHasInvertedColors() 101 { 102 // This is a system-wide accessibility setting, same on all screens. 103 return CGDisplayUsesInvertedPolarity(); 104 } 105 106 #if __MAC_OS_X_VERSION_MIN_REQUIRED >= 101400 97 static HashMap<PlatformDisplayID, ScreenProperties>& screenProperties() 98 { 99 static NeverDestroyed<HashMap<PlatformDisplayID, ScreenProperties>> screenProperties; 100 return screenProperties; 101 } 102 107 103 void getScreenProperties(HashMap<PlatformDisplayID, ScreenProperties>& screenProperties) 108 104 { … … 113 109 int screenDepth = NSBitsPerPixelFromDepth(screen.depth); 114 110 int screenDepthPerComponent = NSBitsPerSampleFromDepth(screen.depth); 115 screenProperties.set(WebCore::displayID(screen), ScreenProperties { screenAvailableRect, screenRect, screenDepth, screenDepthPerComponent }); 116 } 117 } 118 119 static HashMap<PlatformDisplayID, ScreenProperties>& screenProperties() 120 { 121 static NeverDestroyed<HashMap<PlatformDisplayID, ScreenProperties>> screenProperties; 122 return screenProperties; 111 bool screenHasInvertedColors = CGDisplayUsesInvertedPolarity(); 112 bool screenIsMonochrome = CGDisplayUsesForceToGray(); 113 114 screenProperties.set(WebCore::displayID(screen), ScreenProperties { screenAvailableRect, screenRect, screenDepth, screenDepthPerComponent, screenHasInvertedColors, screenIsMonochrome }); 115 } 123 116 } 124 117 … … 131 124 { 132 125 auto displayIDForWidget = displayID(widget); 133 if (displayIDForWidget && screenProperties().contains(displayIDForWidget)) 134 return screenProperties().get(displayIDForWidget); 126 if (displayIDForWidget) { 127 auto screenPropertiesForDisplay = screenProperties().find(displayIDForWidget); 128 if (screenPropertiesForDisplay != screenProperties().end()) 129 return screenPropertiesForDisplay->value; 130 } 131 135 132 // Return property of the first screen if the screen is not found in the map. 136 auto iter = screenProperties().begin(); 137 return screenProperties().get(iter->key); 138 } 139 #endif 133 return screenProperties().begin()->value; 134 } 135 136 bool screenIsMonochrome(Widget* widget) 137 { 138 if (!screenProperties().isEmpty()) 139 return getScreenProperties(widget).screenIsMonochrome; 140 141 // This is a system-wide accessibility setting, same on all screens. 142 RELEASE_ASSERT(hasProcessPrivilege(ProcessPrivilege::CanCommunicateWithWindowServer)); 143 return CGDisplayUsesForceToGray(); 144 } 145 146 bool screenHasInvertedColors() 147 { 148 if (!screenProperties().isEmpty()) 149 return screenProperties().begin()->value.screenHasInvertedColors; 150 151 // This is a system-wide accessibility setting, same on all screens. 152 RELEASE_ASSERT(hasProcessPrivilege(ProcessPrivilege::CanCommunicateWithWindowServer)); 153 return CGDisplayUsesInvertedPolarity(); 154 } 140 155 141 156 int screenDepth(Widget* widget) 142 157 { 143 #if __MAC_OS_X_VERSION_MIN_REQUIRED >= 101400144 158 if (!screenProperties().isEmpty()) { 145 ASSERT(getScreenProperties(widget).screenDepth); 146 return getScreenProperties(widget).screenDepth; 147 } 148 #endif 159 auto screenDepth = getScreenProperties(widget).screenDepth; 160 ASSERT(screenDepth); 161 return screenDepth; 162 } 163 164 RELEASE_ASSERT(hasProcessPrivilege(ProcessPrivilege::CanCommunicateWithWindowServer)); 149 165 return NSBitsPerPixelFromDepth(screen(widget).depth); 150 166 } … … 152 168 int screenDepthPerComponent(Widget* widget) 153 169 { 154 #if __MAC_OS_X_VERSION_MIN_REQUIRED >= 101400155 170 if (!screenProperties().isEmpty()) { 156 ASSERT(getScreenProperties(widget).screenDepthPerComponent); 157 return getScreenProperties(widget).screenDepthPerComponent; 158 } 159 #endif 171 auto depthPerComponent = getScreenProperties(widget).screenDepthPerComponent; 172 ASSERT(depthPerComponent); 173 return depthPerComponent; 174 } 175 176 RELEASE_ASSERT(hasProcessPrivilege(ProcessPrivilege::CanCommunicateWithWindowServer)); 160 177 return NSBitsPerSampleFromDepth(screen(widget).depth); 161 178 } … … 163 180 FloatRect screenRect(Widget* widget) 164 181 { 165 #if __MAC_OS_X_VERSION_MIN_REQUIRED >= 101400166 182 if (!screenProperties().isEmpty()) 167 183 return getScreenProperties(widget).screenRect; 168 #endif 184 185 RELEASE_ASSERT(hasProcessPrivilege(ProcessPrivilege::CanCommunicateWithWindowServer)); 169 186 return toUserSpace([screen(widget) frame], window(widget)); 170 187 } … … 172 189 FloatRect screenAvailableRect(Widget* widget) 173 190 { 174 #if __MAC_OS_X_VERSION_MIN_REQUIRED >= 101400 175 if (!screenProperties().isEmpty()) { 191 if (!screenProperties().isEmpty()) 176 192 return getScreenProperties(widget).screenAvailableRect; 177 } 178 #endif 193 194 RELEASE_ASSERT(hasProcessPrivilege(ProcessPrivilege::CanCommunicateWithWindowServer)); 179 195 return toUserSpace([screen(widget) visibleFrame], window(widget)); 180 196 } … … 182 198 NSScreen *screen(NSWindow *window) 183 199 { 200 RELEASE_ASSERT(hasProcessPrivilege(ProcessPrivilege::CanCommunicateWithWindowServer)); 184 201 return [window screen] ?: firstScreen(); 185 202 } … … 187 204 NSScreen *screen(PlatformDisplayID displayID) 188 205 { 206 // FIXME: <http://webkit.org/b/184344> We should assert here if in WebContent process. 189 207 for (NSScreen *screen in [NSScreen screens]) { 190 208 if (WebCore::displayID(screen) == displayID) … … 196 214 CGColorSpaceRef screenColorSpace(Widget* widget) 197 215 { 216 // FIXME: <http://webkit.org/b/184343> We should assert here if in WebContent process. 198 217 return screen(widget).colorSpace.CGColorSpace; 199 218 } … … 204 223 return false; 205 224 225 RELEASE_ASSERT(hasProcessPrivilege(ProcessPrivilege::CanCommunicateWithWindowServer)); 206 226 return [screen(widget) canRepresentDisplayGamut:NSDisplayGamutP3]; 207 227 } -
trunk/Source/WebKit/ChangeLog
r230315 r230323 1 2018-04-05 Brent Fulgham <bfulgham@apple.com> 2 3 WebContent process is calling CGDisplayUsesInvertedPolarity 4 https://bugs.webkit.org/show_bug.cgi?id=184337 5 <rdar://problem/39215702> 6 7 Reviewed by Zalan Bujtas. 8 9 The PlatformScreenMac code is still calling display-related routines directly, specifically 10 CGDisplayUsesInvertedPolarity and CGDisplayUsesForceToGray. These should be brokered from 11 the UIProcess. 12 13 There's also no reason to avoid the brokering behavior on current WebKit builds. Remove 14 the compile guards so all macOS builds use this behavior. 15 16 Finally, add some ProcessPrivilege assertions to guard against accidentally calling these 17 routines in the future. 18 19 * UIProcess/WebProcessPool.cpp: 20 (WebKit::WebProcessPool::initializeNewWebProcess): Activate screen brokering code for all builds. 21 * WebProcess/WebProcess.cpp: Ditto. 22 * WebProcess/WebProcess.h: Ditto. 23 * WebProcess/WebProcess.messages.in: Ditto. 24 1 25 2018-04-05 Brady Eidson <beidson@apple.com> 2 26 -
trunk/Source/WebKit/UIProcess/WebProcessPool.cpp
r230293 r230323 747 747 } 748 748 749 #if PLATFORM(MAC) && __MAC_OS_X_VERSION_MIN_REQUIRED >= 101400749 #if PLATFORM(MAC) 750 750 static void displayReconfigurationCallBack(CGDirectDisplayID display, CGDisplayChangeSummaryFlags flags, void *userInfo) 751 751 { … … 916 916 #endif 917 917 918 #if PLATFORM(MAC) && __MAC_OS_X_VERSION_MIN_REQUIRED >= 101400918 #if PLATFORM(MAC) 919 919 registerDisplayConfigurationCallback(); 920 920 -
trunk/Source/WebKit/WebProcess/WebProcess.cpp
r230290 r230323 1699 1699 #endif 1700 1700 1701 #if PLATFORM(MAC) && __MAC_OS_X_VERSION_MIN_REQUIRED >= 1014001701 #if PLATFORM(MAC) 1702 1702 void WebProcess::setScreenProperties(const HashMap<uint32_t, WebCore::ScreenProperties>& properties) 1703 1703 { -
trunk/Source/WebKit/WebProcess/WebProcess.h
r230290 r230323 35 35 #include "WebInspectorInterruptDispatcher.h" 36 36 #include <WebCore/ActivityState.h> 37 #if PLATFORM(MAC) && __MAC_OS_X_VERSION_MIN_REQUIRED >= 10140037 #if PLATFORM(MAC) 38 38 #include <WebCore/ScreenProperties.h> 39 39 #endif … … 372 372 void didReceiveSyncWebProcessMessage(IPC::Connection&, IPC::Decoder&, std::unique_ptr<IPC::Encoder>&); 373 373 374 #if PLATFORM(MAC) && __MAC_OS_X_VERSION_MIN_REQUIRED >= 101400374 #if PLATFORM(MAC) 375 375 void setScreenProperties(const HashMap<uint32_t, WebCore::ScreenProperties>&); 376 #if __MAC_OS_X_VERSION_MIN_REQUIRED >= 101400 376 377 void scrollerStylePreferenceChanged(bool useOverlayScrollbars); 378 #endif 377 379 #endif 378 380 -
trunk/Source/WebKit/WebProcess/WebProcess.messages.in
r229917 r230323 1 # Copyright (C) 2010 , 2016Apple Inc. All rights reserved.1 # Copyright (C) 2010-2018 Apple Inc. All rights reserved. 2 2 # 3 3 # Redistribution and use in source and binary forms, with or without … … 129 129 MessagesAvailableForPort(struct WebCore::MessagePortIdentifier port) 130 130 131 #if PLATFORM(MAC) && __MAC_OS_X_VERSION_MIN_REQUIRED >= 101400131 #if PLATFORM(MAC) 132 132 SetScreenProperties(HashMap<uint32_t, WebCore::ScreenProperties> screenProperties) 133 #if __MAC_OS_X_VERSION_MIN_REQUIRED >= 101400 133 134 ScrollerStylePreferenceChanged(bool useOvelayScrollbars) 134 135 #endif 136 #endif 135 137 }
Note: See TracChangeset
for help on using the changeset viewer.