Changeset 244545 in webkit


Ignore:
Timestamp:
Apr 23, 2019 9:25:30 AM (5 years ago)
Author:
commit-queue@webkit.org
Message:

Fix layout issues occuring when entering full screen mode.
https://bugs.webkit.org/show_bug.cgi?id=197086
<rdar://problem/47733671>.

Patch by Remy Demarest <rdemarest@apple.com> on 2019-04-23
Reviewed by Darin Adler.

This issue is the result of changing the style mask of the window after entering
full screen mode. Safari adds an invisible toolbar to display the URL of the page
which ends up breaking the layout. Having that window use a style that includes a
titlebar fixes the bug.

Source/WebCore:

  • platform/mac/WebCoreFullScreenWindow.mm:

(-[WebCoreFullScreenWindow constrainFrameRect:toScreen:]): Ensure that the window
can fill the entire screen including the underlapping the menu bar, so that the
window does not resize when the animation is done.
(-[WebCoreFullScreenWindow canBecomeMainWindow]): Borderless windows cannot become
main by default, adding the titlebar allows it to become main, prevent this from
happening at all to preserve the existing behavior.

Source/WebKit:

  • Platform/spi/mac/AppKitSPI.h:

Declare an SPI to be used in WKFullScreenWindowController.

  • UIProcess/Cocoa/WebViewImpl.mm:

(WebKit::WebViewImpl::fullScreenWindow): Make the full screen window show a titlebar
and make the content view underlap the titlebar to match the current behavior.
Remove NSWindowStyleMaskBorderless which has no effects since it is equal to zero.

  • UIProcess/mac/WKFullScreenWindowController.mm:

(-[WKFullScreenWindowController initWithWindow:webView:page:]): Hide the titlebar
before beginning the animation to full screen.
(-[WKFullScreenWindowController finishedEnterFullScreenAnimation:]): Show the title
bar when in full screen instead of a blank bar.
(-[WKFullScreenWindowController finishedExitFullScreenAnimation:]): Hide the title
bar to restore the initial setting.

Location:
trunk/Source
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r244540 r244545  
     12019-04-23  Remy Demarest  <rdemarest@apple.com>
     2
     3        Fix layout issues occuring when entering full screen mode.
     4        https://bugs.webkit.org/show_bug.cgi?id=197086
     5        <rdar://problem/47733671>.
     6
     7        Reviewed by Darin Adler.
     8
     9        This issue is the result of changing the style mask of the window after entering
     10        full screen mode. Safari adds an invisible toolbar to display the URL of the page
     11        which ends up breaking the layout. Having that window use a style that includes a
     12        titlebar fixes the bug.
     13
     14        * platform/mac/WebCoreFullScreenWindow.mm:
     15        (-[WebCoreFullScreenWindow constrainFrameRect:toScreen:]): Ensure that the window
     16        can fill the entire screen including the underlapping the menu bar, so that the
     17        window does not resize when the animation is done.
     18        (-[WebCoreFullScreenWindow canBecomeMainWindow]): Borderless windows cannot become
     19        main by default, adding the titlebar allows it to become main, prevent this from
     20        happening at all to preserve the existing behavior.
     21
    1222019-04-23  Chris Dumez  <cdumez@apple.com>
    223
  • trunk/Source/WebCore/platform/mac/WebCoreFullScreenWindow.mm

    r237266 r244545  
    5454}
    5555
     56- (NSRect)constrainFrameRect:(NSRect)frameRect toScreen:(NSScreen *)screen
     57{
     58    UNUSED_PARAM(screen);
     59    return frameRect;
     60}
     61
     62- (BOOL)canBecomeMainWindow
     63{
     64    return NO;
     65}
     66
    5667- (BOOL)canBecomeKeyWindow
    5768{
  • trunk/Source/WebKit/ChangeLog

    r244544 r244545  
     12019-04-23  Remy Demarest  <rdemarest@apple.com>
     2
     3        Fix layout issues occuring when entering full screen mode.
     4        https://bugs.webkit.org/show_bug.cgi?id=197086
     5        <rdar://problem/47733671>.
     6
     7        Reviewed by Darin Adler.
     8
     9        This issue is the result of changing the style mask of the window after entering
     10        full screen mode. Safari adds an invisible toolbar to display the URL of the page
     11        which ends up breaking the layout. Having that window use a style that includes a
     12        titlebar fixes the bug.
     13
     14        * Platform/spi/mac/AppKitSPI.h:
     15        Declare an SPI to be used in WKFullScreenWindowController.
     16
     17        * UIProcess/Cocoa/WebViewImpl.mm:
     18        (WebKit::WebViewImpl::fullScreenWindow): Make the full screen window show a titlebar
     19        and make the content view underlap the titlebar to match the current behavior.
     20        Remove NSWindowStyleMaskBorderless which has no effects since it is equal to zero.
     21
     22        * UIProcess/mac/WKFullScreenWindowController.mm:
     23        (-[WKFullScreenWindowController initWithWindow:webView:page:]): Hide the titlebar
     24        before beginning the animation to full screen.
     25        (-[WKFullScreenWindowController finishedEnterFullScreenAnimation:]): Show the title
     26        bar when in full screen instead of a blank bar.
     27        (-[WKFullScreenWindowController finishedExitFullScreenAnimation:]): Hide the title
     28        bar to restore the initial setting.
     29
    1302019-04-23  John Wilander  <wilander@apple.com>
    231
  • trunk/Source/WebKit/Platform/spi/mac/AppKitSPI.h

    r236724 r244545  
    4848@end
    4949
     50@interface NSWindow (FullScreenSupport)
     51@property CGFloat titlebarAlphaValue;
     52@end
     53
    5054#endif
    5155
  • trunk/Source/WebKit/UIProcess/Cocoa/WebViewImpl.mm

    r244089 r244545  
    26112611{
    26122612#if ENABLE(FULLSCREEN_API)
    2613     return [[[WebCoreFullScreenWindow alloc] initWithContentRect:[[NSScreen mainScreen] frame] styleMask:(NSWindowStyleMaskBorderless | NSWindowStyleMaskResizable) backing:NSBackingStoreBuffered defer:NO] autorelease];
     2613    return [[[WebCoreFullScreenWindow alloc] initWithContentRect:[[NSScreen mainScreen] frame] styleMask:(NSWindowStyleMaskTitled | NSWindowStyleMaskUnifiedTitleAndToolbar | NSWindowStyleMaskFullSizeContentView | NSWindowStyleMaskResizable) backing:NSBackingStoreBuffered defer:NO] autorelease];
    26142614#else
    26152615    return nil;
  • trunk/Source/WebKit/UIProcess/mac/WKFullScreenWindowController.mm

    r239689 r244545  
    3030#import "WKFullScreenWindowController.h"
    3131
     32#import "AppKitSPI.h"
    3233#import "LayerTreeContext.h"
    3334#import "VideoFullscreenManagerProxy.h"
     
    127128    [window setCollectionBehavior:([window collectionBehavior] | NSWindowCollectionBehaviorFullScreenPrimary)];
    128129
     130    // Hide the titlebar during the animation to full screen so that only the WKWebView content is visible.
     131    window.titlebarAlphaValue = 0;
     132
    129133    NSView *contentView = [window contentView];
    130134    contentView.hidden = YES;
     
    342346        minContentSize.width = minVideoWidth;
    343347        self.window.contentMinSize = minContentSize;
     348
     349        // Always show the titlebar in full screen mode.
     350        self.window.titlebarAlphaValue = 1;
    344351    } else {
    345352        // Transition to fullscreen failed. Clean up.
     
    475482        return;
    476483    _fullScreenState = NotInFullScreen;
     484
     485    // Hide the titlebar at the end of the animation so that it can slide away without turning blank.
     486    self.window.titlebarAlphaValue = 0;
    477487
    478488    NSResponder *firstResponder = [[self window] firstResponder];
Note: See TracChangeset for help on using the changeset viewer.