Skip to content
Permalink
Browse files
[Mac] Adopt -[NSScreen safeAreaInsets]
https://bugs.webkit.org/show_bug.cgi?id=234291
<rdar://85805895>

Reviewed by Eric Carlson.

Source/WebCore:

Adopt -safeAreaInsets and rename screenRectAvoidingMenuBar() to safeScreenFrame().

* platform/PlatformScreen.h:
* platform/mac/PlatformScreenMac.mm:
(WebCore::safeScreenFrame): Renamed from screenRectAvoidingMenuBar.

Source/WebKit:

Drive-by fix: use the safeAreaFrame() when determining where to place the exit
fullscreen placeholder image.

* UIProcess/mac/WKFullScreenWindowController.mm:
(-[WKFullScreenWindowController enterFullScreen:]):
(-[WKFullScreenWindowController finishedExitFullScreenAnimationAndExitImmediately:]):

Source/WTF:

* wtf/PlatformHave.h:



Canonical link: https://commits.webkit.org/245286@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@287094 268f45cc-cd09-0410-ab3c-d52691b4dbfc
  • Loading branch information
jernoble committed Dec 15, 2021
1 parent 0246519 commit b9a9969e2f86811b9f5ee8a4f775f76082991365
Showing 7 changed files with 54 additions and 13 deletions.
@@ -1,3 +1,13 @@
2021-12-15 Jer Noble <jer.noble@apple.com>

[Mac] Adopt -[NSScreen safeAreaInsets]
https://bugs.webkit.org/show_bug.cgi?id=234291
<rdar://85805895>

Reviewed by Eric Carlson.

* wtf/PlatformHave.h:

2021-12-15 Chris Dumez <cdumez@apple.com>

Move SWServers from NetworkProcess to NetworkSession
@@ -1120,3 +1120,7 @@
#if ((PLATFORM(IOS) || PLATFORM(MACCATALYST)) && __IPHONE_OS_VERSION_MIN_REQUIRED >= 160000)
#define HAVE_UIFINDINTERACTION 1
#endif

#if PLATFORM(MAC) && __MAC_OS_X_VERSION_MIN_REQUIRED >= 120000
#define HAVE_NSSCREEN_SAFE_AREA 1
#endif
@@ -1,3 +1,17 @@
2021-12-15 Jer Noble <jer.noble@apple.com>

[Mac] Adopt -[NSScreen safeAreaInsets]
https://bugs.webkit.org/show_bug.cgi?id=234291
<rdar://85805895>

Reviewed by Eric Carlson.

Adopt -safeAreaInsets and rename screenRectAvoidingMenuBar() to safeScreenFrame().

* platform/PlatformScreen.h:
* platform/mac/PlatformScreenMac.mm:
(WebCore::safeScreenFrame): Renamed from screenRectAvoidingMenuBar.

2021-12-15 Alex Christensen <achristensen@webkit.org>

More cleanup after PluginProcess removal
@@ -140,7 +140,7 @@ IORegistryGPUID primaryGPUID();
IORegistryGPUID gpuIDForDisplay(PlatformDisplayID);
IORegistryGPUID gpuIDForDisplayMask(uint32_t);

WEBCORE_EXPORT FloatRect screenRectAvoidingMenuBar(NSScreen *);
WEBCORE_EXPORT FloatRect safeScreenFrame(NSScreen *);

#endif // !PLATFORM(MAC)

@@ -44,10 +44,6 @@
#import <pal/cocoa/MediaToolboxSoftLink.h>
#endif

#if USE(APPLE_INTERNAL_SDK) && __has_include(<WebKitAdditions/PlatformScreenMac.h>)
#import <WebKitAdditions/PlatformScreenMac.h>
#endif

namespace WebCore {

// These functions scale between screen and page coordinates because JavaScript/DOM operations
@@ -419,14 +415,16 @@ NSPoint flipScreenPoint(const NSPoint& screenPoint, NSScreen *screen)
return flippedPoint;
}

#if USE(APPLE_INTERNAL_SDK) && __has_include(<WebKitAdditions/PlatformScreenMac.mm>)
#import <WebKitAdditions/PlatformScreenMac.mm>
#else
FloatRect screenRectAvoidingMenuBar(NSScreen* screen)
FloatRect safeScreenFrame(NSScreen* screen)
{
return screen.frame;
}
FloatRect frame = screen.frame;
#if HAVE(NSSCREEN_SAFE_AREA)
auto insets = screen.safeAreaInsets;
frame.contract(insets.left + insets.right, insets.top + insets.bottom);
frame.move(insets.left, insets.bottom);
#endif
return frame;
}


} // namespace WebCore
@@ -1,3 +1,18 @@
2021-12-15 Jer Noble <jer.noble@apple.com>

[Mac] Adopt -[NSScreen safeAreaInsets]
https://bugs.webkit.org/show_bug.cgi?id=234291
<rdar://85805895>

Reviewed by Eric Carlson.

Drive-by fix: use the safeAreaFrame() when determining where to place the exit
fullscreen placeholder image.

* UIProcess/mac/WKFullScreenWindowController.mm:
(-[WKFullScreenWindowController enterFullScreen:]):
(-[WKFullScreenWindowController finishedExitFullScreenAnimationAndExitImmediately:]):

2021-12-15 Alex Christensen <achristensen@webkit.org>

More cleanup after PluginProcess removal
@@ -228,7 +228,7 @@ - (void)enterFullScreen:(NSScreen *)screen
if (!screen)
screen = [NSScreen mainScreen];

NSRect screenFrame = WebCore::screenRectAvoidingMenuBar(screen);
NSRect screenFrame = WebCore::safeScreenFrame(screen);
NSRect webViewFrame = convertRectToScreen([_webView window], [_webView convertRect:[_webView frame] toView:nil]);

// Flip coordinate system:
@@ -520,7 +520,7 @@ - (void)finishedExitFullScreenAnimationAndExitImmediately:(bool)immediately
[CATransaction begin];
[CATransaction setDisableActions:YES];
NSRect exitPlaceholderScreenRect = _initialFrame;
exitPlaceholderScreenRect.origin.y = NSMaxY([[[NSScreen screens] objectAtIndex:0] frame]) - NSMaxY(exitPlaceholderScreenRect);
exitPlaceholderScreenRect.origin.y = NSMaxY(WebCore::safeScreenFrame([[NSScreen screens] objectAtIndex:0])) - NSMaxY(exitPlaceholderScreenRect);

RetainPtr<CGImageRef> webViewContents = takeWindowSnapshot([[_webView window] windowNumber], true);
webViewContents = adoptCF(CGImageCreateWithImageInRect(webViewContents.get(), NSRectToCGRect(exitPlaceholderScreenRect)));

0 comments on commit b9a9969

Please sign in to comment.