Title: [228940] trunk/Source/WebCore
- Revision
- 228940
- Author
- [email protected]
- Date
- 2018-02-22 16:17:38 -0800 (Thu, 22 Feb 2018)
Log Message
The WebContent process should not use NSScreen in the screenDepth implementation.
https://bugs.webkit.org/show_bug.cgi?id=183048
Reviewed by Brent Fulgham.
NSScreen method calls should be done in the UIProcess, since these calls will communicate with
the WindowServer. The screen depth property can be retrieved in the UIProcess, and sent to the
WebContent process, where it is cached. Whenever screen properties change, the UIProcess will
send the new screen properties to the WebProcess.
No new tests, covered by existing tests.
* platform/ScreenProperties.h:
(WebCore::ScreenProperties::encode const):
(WebCore::ScreenProperties::decode):
* platform/mac/PlatformScreenMac.mm:
(WebCore::getScreenProperties):
(WebCore::screenDepth):
(WebCore::screenDepthPerComponent):
(WebCore::screenRect):
(WebCore::screenAvailableRect):
Modified Paths
Diff
Modified: trunk/Source/WebCore/ChangeLog (228939 => 228940)
--- trunk/Source/WebCore/ChangeLog 2018-02-23 00:10:48 UTC (rev 228939)
+++ trunk/Source/WebCore/ChangeLog 2018-02-23 00:17:38 UTC (rev 228940)
@@ -1,3 +1,27 @@
+2018-02-22 Per Arne Vollan <[email protected]>
+
+ The WebContent process should not use NSScreen in the screenDepth implementation.
+ https://bugs.webkit.org/show_bug.cgi?id=183048
+
+ Reviewed by Brent Fulgham.
+
+ NSScreen method calls should be done in the UIProcess, since these calls will communicate with
+ the WindowServer. The screen depth property can be retrieved in the UIProcess, and sent to the
+ WebContent process, where it is cached. Whenever screen properties change, the UIProcess will
+ send the new screen properties to the WebProcess.
+
+ No new tests, covered by existing tests.
+
+ * platform/ScreenProperties.h:
+ (WebCore::ScreenProperties::encode const):
+ (WebCore::ScreenProperties::decode):
+ * platform/mac/PlatformScreenMac.mm:
+ (WebCore::getScreenProperties):
+ (WebCore::screenDepth):
+ (WebCore::screenDepthPerComponent):
+ (WebCore::screenRect):
+ (WebCore::screenAvailableRect):
+
2018-02-22 Zalan Bujtas <[email protected]>
[RenderTreeBuilder] Rename insertChild() -> attach(), takeChild() -> detach() and removeAndDestroy() -> destroy()
Modified: trunk/Source/WebCore/platform/ScreenProperties.h (228939 => 228940)
--- trunk/Source/WebCore/platform/ScreenProperties.h 2018-02-23 00:10:48 UTC (rev 228939)
+++ trunk/Source/WebCore/platform/ScreenProperties.h 2018-02-23 00:17:38 UTC (rev 228940)
@@ -32,6 +32,8 @@
struct ScreenProperties {
FloatRect screenAvailableRect;
FloatRect screenRect;
+ int screenDepth { 0 };
+ int screenDepthPerComponent { 0 };
template<class Encoder> void encode(Encoder&) const;
template<class Decoder> static std::optional<ScreenProperties> decode(Decoder&);
@@ -40,7 +42,7 @@
template<class Encoder>
void ScreenProperties::encode(Encoder& encoder) const
{
- encoder << screenAvailableRect << screenRect;
+ encoder << screenAvailableRect << screenRect << screenDepth << screenDepthPerComponent;
}
template<class Decoder>
@@ -56,7 +58,18 @@
if (!screenRect)
return std::nullopt;
- return { { WTFMove(*screenAvailableRect), WTFMove(*screenRect) } };
+ std::optional<int> screenDepth;
+ decoder >> screenDepth;
+ if (!screenDepth)
+ return std::nullopt;
+
+ std::optional<int> screenDepthPerComponent;
+ decoder >> screenDepthPerComponent;
+ if (!screenDepthPerComponent)
+ return std::nullopt;
+
+ return { { WTFMove(*screenAvailableRect), WTFMove(*screenRect), WTFMove(*screenDepth), WTFMove(*screenDepthPerComponent) } };
}
} // namespace WebCore
+
Modified: trunk/Source/WebCore/platform/mac/PlatformScreenMac.mm (228939 => 228940)
--- trunk/Source/WebCore/platform/mac/PlatformScreenMac.mm 2018-02-23 00:10:48 UTC (rev 228939)
+++ trunk/Source/WebCore/platform/mac/PlatformScreenMac.mm 2018-02-23 00:17:38 UTC (rev 228940)
@@ -91,16 +91,6 @@
return screen(displayID(widget));
}
-int screenDepth(Widget* widget)
-{
- return NSBitsPerPixelFromDepth(screen(widget).depth);
-}
-
-int screenDepthPerComponent(Widget* widget)
-{
- return NSBitsPerSampleFromDepth(screen(widget).depth);
-}
-
bool screenIsMonochrome(Widget*)
{
// This is a system-wide accessibility setting, same on all screens.
@@ -120,7 +110,9 @@
FloatRect screenAvailableRect = [screen visibleFrame];
screenAvailableRect.setY(NSMaxY([screen frame]) - (screenAvailableRect.y() + screenAvailableRect.height())); // flip
FloatRect screenRect = [screen frame];
- screenProperties.set(WebCore::displayID(screen), ScreenProperties { screenAvailableRect, screenRect});
+ int screenDepth = NSBitsPerPixelFromDepth(screen.depth);
+ int screenDepthPerComponent = NSBitsPerSampleFromDepth(screen.depth);
+ screenProperties.set(WebCore::displayID(screen), ScreenProperties { screenAvailableRect, screenRect, screenDepth, screenDepthPerComponent });
}
}
@@ -134,20 +126,46 @@
{
screenProperties() = properties;
}
+
+static ScreenProperties getScreenProperties(Widget* widget)
+{
+ auto displayIDForWidget = displayID(widget);
+ if (displayIDForWidget && screenProperties().contains(displayIDForWidget))
+ return screenProperties().get(displayIDForWidget);
+ // Return property of the first screen if the screen is not found in the map.
+ auto iter = screenProperties().begin();
+ return screenProperties().get(iter->key);
+}
#endif
-FloatRect screenRect(Widget* widget)
+int screenDepth(Widget* widget)
{
#if __MAC_OS_X_VERSION_MIN_REQUIRED >= 101400
if (!screenProperties().isEmpty()) {
- auto displayIDForWidget = displayID(widget);
- if (displayIDForWidget && screenProperties().contains(displayIDForWidget))
- return screenProperties().get(displayIDForWidget).screenRect;
- // Return property of the first screen if the screen is not found in the map.
- auto iter = screenProperties().begin();
- return screenProperties().get(iter->key).screenRect;
+ ASSERT(getScreenProperties(widget).screenDepth);
+ return getScreenProperties(widget).screenDepth;
}
#endif
+ return NSBitsPerPixelFromDepth(screen(widget).depth);
+}
+
+int screenDepthPerComponent(Widget* widget)
+{
+#if __MAC_OS_X_VERSION_MIN_REQUIRED >= 101400
+ if (!screenProperties().isEmpty()) {
+ ASSERT(getScreenProperties(widget).screenDepthPerComponent);
+ return getScreenProperties(widget).screenDepthPerComponent;
+ }
+#endif
+ return NSBitsPerSampleFromDepth(screen(widget).depth);
+}
+
+FloatRect screenRect(Widget* widget)
+{
+#if __MAC_OS_X_VERSION_MIN_REQUIRED >= 101400
+ if (!screenProperties().isEmpty())
+ return getScreenProperties(widget).screenRect;
+#endif
return toUserSpace([screen(widget) frame], window(widget));
}
@@ -155,12 +173,7 @@
{
#if __MAC_OS_X_VERSION_MIN_REQUIRED >= 101400
if (!screenProperties().isEmpty()) {
- auto displayIDForWidget = displayID(widget);
- if (displayIDForWidget && screenProperties().contains(displayIDForWidget))
- return screenProperties().get(displayIDForWidget).screenAvailableRect;
- // Return property of the first screen if the screen is not found in the map.
- auto iter = screenProperties().begin();
- return screenProperties().get(iter->key).screenAvailableRect;
+ return getScreenProperties(widget).screenAvailableRect;
}
#endif
return toUserSpace([screen(widget) visibleFrame], window(widget));
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes