Changeset 240010 in webkit


Ignore:
Timestamp:
Jan 15, 2019 2:53:39 PM (5 years ago)
Author:
timothy_horton@apple.com
Message:

Cannot tab out of WKWebView on macOS
https://bugs.webkit.org/show_bug.cgi?id=161448
<rdar://problem/28100085>

Reviewed by Dean Jackson.

Source/WebCore/PAL:

  • pal/spi/mac/NSViewSPI.h:
  • pal/spi/mac/NSWindowSPI.h:

Move some SPI declarations in here from WebKitLegacy.

Source/WebKit:

  • UIProcess/WebPageProxy.cpp:

(WebKit::WebPageProxy::takeFocus):
If the UIDelegate doesn't implement takeFocus, provide a simple default
implementation that just uses AppKit's key view loop to move the focus.

  • UIProcess/API/APIUIClient.h:

(API::UIClient::takeFocus):

  • UIProcess/API/C/WKPage.cpp:

(WKPageSetPageUIClient):

  • UIProcess/Cocoa/UIDelegate.h:
  • UIProcess/Cocoa/UIDelegate.mm:

(WebKit::UIDelegate::UIClient::takeFocus):
Make API::UIClient's takeFocus return a bool indicating whether the
client implements it or not.

  • UIProcess/PageClient.h:
  • UIProcess/mac/PageClientImplMac.h:
  • UIProcess/mac/PageClientImplMac.mm:

(WebKit::PageClientImpl::takeFocus):
Plumb takeFocus to WebViewImpl.

  • UIProcess/Cocoa/WebViewImpl.h:
  • UIProcess/Cocoa/WebViewImpl.mm:

(WebKit::WebViewImpl::takeFocus):
Borrow the relevant portion of WebKitLegacy's implementation of takeFocus,
shifting focus to the next/previous key view in the window.

Source/WebKitLegacy/mac:

  • WebCoreSupport/WebChromeClient.mm:
  • WebView/WebView.mm:

Make use of SPI headers.

Tools:

Add a test that tabbing into and out of WKWebView works correctly.

  • TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj:
  • TestWebKitAPI/Tests/WebKitCocoa/CommandBackForward.mm:

(WebKit2_CommandBackForwardTest::SetUp):
(-[CommandBackForwardOffscreenWindow isKeyWindow]): Deleted.
(-[CommandBackForwardOffscreenWindow isVisible]): Deleted.

  • TestWebKitAPI/Tests/WebKitCocoa/TabOutOfWebView.mm: Added.

(-[FocusableView canBecomeKeyView]):
(TEST):

  • TestWebKitAPI/mac/OffscreenWindow.h: Added.
  • TestWebKitAPI/mac/OffscreenWindow.mm: Added.

(-[OffscreenWindow initWithSize:]):
(-[OffscreenWindow isKeyWindow]):
(-[OffscreenWindow isVisible]):

  • TestWebKitAPI/mac/PlatformWebViewMac.mm:

(TestWebKitAPI::PlatformWebView::initialize):
(-[ActiveOffscreenWindow isKeyWindow]): Deleted.
(-[ActiveOffscreenWindow isVisible]): Deleted.
Factor ActiveOffscreenWindow out into OffscreenWindow and share it.

Location:
trunk
Files:
1 added
21 edited
2 copied

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/PAL/ChangeLog

    r239948 r240010  
     12019-01-15  Tim Horton  <timothy_horton@apple.com>
     2
     3        Cannot tab out of WKWebView on macOS
     4        https://bugs.webkit.org/show_bug.cgi?id=161448
     5        <rdar://problem/28100085>
     6
     7        Reviewed by Dean Jackson.
     8
     9        * pal/spi/mac/NSViewSPI.h:
     10        * pal/spi/mac/NSWindowSPI.h:
     11        Move some SPI declarations in here from WebKitLegacy.
     12
    1132019-01-14  Commit Queue  <commit-queue@webkit.org>
    214
  • trunk/Source/WebCore/PAL/pal/spi/mac/NSViewSPI.h

    r220979 r240010  
    2929
    3030@interface NSView () <CALayerDelegate>
     31
     32- (NSView *)_findLastViewInKeyViewLoop;
     33
    3134@end
    3235
  • trunk/Source/WebCore/PAL/pal/spi/mac/NSWindowSPI.h

    r236846 r240010  
    3838@interface NSWindow ()
    3939
     40- (id)_oldFirstResponderBeforeBecoming;
    4041- (id)_newFirstResponderAfterResigning;
    4142- (void)_setCursorForMouseLocation:(NSPoint)point;
  • trunk/Source/WebKit/ChangeLog

    r240009 r240010  
     12019-01-15  Tim Horton  <timothy_horton@apple.com>
     2
     3        Cannot tab out of WKWebView on macOS
     4        https://bugs.webkit.org/show_bug.cgi?id=161448
     5        <rdar://problem/28100085>
     6
     7        Reviewed by Dean Jackson.
     8
     9        * UIProcess/WebPageProxy.cpp:
     10        (WebKit::WebPageProxy::takeFocus):
     11        If the UIDelegate doesn't implement takeFocus, provide a simple default
     12        implementation that just uses AppKit's key view loop to move the focus.
     13
     14        * UIProcess/API/APIUIClient.h:
     15        (API::UIClient::takeFocus):
     16        * UIProcess/API/C/WKPage.cpp:
     17        (WKPageSetPageUIClient):
     18        * UIProcess/Cocoa/UIDelegate.h:
     19        * UIProcess/Cocoa/UIDelegate.mm:
     20        (WebKit::UIDelegate::UIClient::takeFocus):
     21        Make API::UIClient's takeFocus return a bool indicating whether the
     22        client implements it or not.
     23
     24        * UIProcess/PageClient.h:
     25        * UIProcess/mac/PageClientImplMac.h:
     26        * UIProcess/mac/PageClientImplMac.mm:
     27        (WebKit::PageClientImpl::takeFocus):
     28        Plumb takeFocus to WebViewImpl.
     29
     30        * UIProcess/Cocoa/WebViewImpl.h:
     31        * UIProcess/Cocoa/WebViewImpl.mm:
     32        (WebKit::WebViewImpl::takeFocus):
     33        Borrow the relevant portion of WebKitLegacy's implementation of takeFocus,
     34        shifting focus to the next/previous key view in the window.
     35
    1362019-01-15  Youenn Fablet  <youenn@apple.com>
    237
  • trunk/Source/WebKit/UIProcess/API/APIUIClient.h

    r239134 r240010  
    8282    virtual void close(WebKit::WebPageProxy*) { }
    8383
    84     virtual void takeFocus(WebKit::WebPageProxy*, WKFocusDirection) { }
     84    virtual bool takeFocus(WebKit::WebPageProxy*, WKFocusDirection) { return false; }
    8585    virtual void focus(WebKit::WebPageProxy*) { }
    8686    virtual void unfocus(WebKit::WebPageProxy*) { }
  • trunk/Source/WebKit/UIProcess/API/C/WKPage.cpp

    r239840 r240010  
    15541554        }
    15551555
    1556         void takeFocus(WebPageProxy* page, WKFocusDirection direction) final
     1556        bool takeFocus(WebPageProxy* page, WKFocusDirection direction) final
    15571557        {
    15581558            if (!m_client.takeFocus)
    1559                 return;
     1559                return false;
    15601560
    15611561            m_client.takeFocus(toAPI(page), direction, m_client.base.clientInfo);
     1562            return true;
    15621563        }
    15631564
  • trunk/Source/WebKit/UIProcess/Cocoa/UIDelegate.h

    r239134 r240010  
    9696        void reachedApplicationCacheOriginQuota(WebPageProxy*, const WebCore::SecurityOrigin&, uint64_t currentQuota, uint64_t totalBytesNeeded, Function<void(unsigned long long)>&& completionHandler) final;
    9797        void didResignInputElementStrongPasswordAppearance(WebPageProxy&, API::Object*) final;
    98         void takeFocus(WebPageProxy*, WKFocusDirection) final;
     98        bool takeFocus(WebPageProxy*, WKFocusDirection) final;
    9999#if PLATFORM(MAC)
    100100        void showPage(WebPageProxy*) final;
  • trunk/Source/WebKit/UIProcess/Cocoa/UIDelegate.mm

    r239625 r240010  
    467467}
    468468
    469 void UIDelegate::UIClient::takeFocus(WebPageProxy*, WKFocusDirection direction)
     469bool UIDelegate::UIClient::takeFocus(WebPageProxy*, WKFocusDirection direction)
    470470{
    471471    if (!m_uiDelegate.m_delegateMethods.webViewTakeFocus)
    472         return;
    473    
    474     auto delegate = m_uiDelegate.m_delegate.get();
    475     if (!delegate)
    476         return;
     472        return false;
     473   
     474    auto delegate = m_uiDelegate.m_delegate.get();
     475    if (!delegate)
     476        return false;
    477477   
    478478    [(id <WKUIDelegatePrivate>)delegate _webView:m_uiDelegate.m_webView takeFocus:toWKFocusDirection(direction)];
     479    return true;
    479480}
    480481
  • trunk/Source/WebKit/UIProcess/Cocoa/WebViewImpl.h

    r239558 r240010  
    3333#include "WKLayoutMode.h"
    3434#include "_WKOverlayScrollbarStyle.h"
     35#include <WebCore/FocusDirection.h>
    3536#include <WebCore/ScrollTypes.h>
    3637#include <WebCore/TextIndicatorWindow.h>
     
    604605    bool effectiveAppearanceIsDark();
    605606
     607    void takeFocus(WebCore::FocusDirection);
     608
    606609private:
    607610#if HAVE(TOUCH_BAR)
  • trunk/Source/WebKit/UIProcess/Cocoa/WebViewImpl.mm

    r239948 r240010  
    113113#import <pal/spi/mac/NSSpellCheckerSPI.h>
    114114#import <pal/spi/mac/NSTextFinderSPI.h>
     115#import <pal/spi/mac/NSViewSPI.h>
    115116#import <pal/spi/mac/NSWindowSPI.h>
    116117#import <sys/stat.h>
     
    15691570   
    15701571    return true;
     1572}
     1573
     1574void WebViewImpl::takeFocus(WebCore::FocusDirection direction)
     1575{
     1576    NSView *webView = m_view.getAutoreleased();
     1577
     1578    if (direction == FocusDirectionForward) {
     1579        // Since we're trying to move focus out of m_webView, and because
     1580        // m_webView may contain subviews within it, we ask it for the next key
     1581        // view of the last view in its key view loop. This makes m_webView
     1582        // behave as if it had no subviews, which is the behavior we want.
     1583        [webView.window selectKeyViewFollowingView:[webView _findLastViewInKeyViewLoop]];
     1584    } else
     1585        [webView.window selectKeyViewPrecedingView:webView];
    15711586}
    15721587
  • trunk/Source/WebKit/UIProcess/PageClient.h

    r239993 r240010  
    3434#include <WebCore/AlternativeTextClient.h>
    3535#include <WebCore/EditorClient.h>
     36#include <WebCore/FocusDirection.h>
    3637#include <WebCore/UserInterfaceLayoutDirection.h>
    3738#include <WebCore/ValidationBubble.h>
     
    311312    virtual void updateAcceleratedCompositingMode(const LayerTreeContext&) = 0;
    312313
     314    virtual void takeFocus(WebCore::FocusDirection) { }
     315
    313316#if PLATFORM(MAC)
    314317    virtual void pluginFocusOrWindowFocusChanged(uint64_t pluginComplexTextInputIdentifier, bool pluginHasFocusAndWindowHasFocus) = 0;
  • trunk/Source/WebKit/UIProcess/WebPageProxy.cpp

    r239993 r240010  
    58625862void WebPageProxy::takeFocus(uint32_t direction)
    58635863{
    5864     m_uiClient->takeFocus(this, (static_cast<FocusDirection>(direction) == FocusDirectionForward) ? kWKFocusDirectionForward : kWKFocusDirectionBackward);
     5864    if (m_uiClient->takeFocus(this, (static_cast<FocusDirection>(direction) == FocusDirectionForward) ? kWKFocusDirectionForward : kWKFocusDirectionBackward))
     5865        return;
     5866
     5867    pageClient().takeFocus(static_cast<FocusDirection>(direction));
    58655868}
    58665869
  • trunk/Source/WebKit/UIProcess/mac/PageClientImplMac.h

    r239972 r240010  
    263263    bool windowIsFrontWindowUnderMouse(const NativeWebMouseEvent&) override;
    264264
     265    void takeFocus(WebCore::FocusDirection) override;
     266
    265267    NSView *m_view;
    266268    WeakPtr<WebViewImpl> m_impl;
  • trunk/Source/WebKit/UIProcess/mac/PageClientImplMac.mm

    r239689 r240010  
    958958}
    959959
     960void PageClientImpl::takeFocus(WebCore::FocusDirection direction)
     961{
     962    m_impl->takeFocus(direction);
     963}
     964
    960965} // namespace WebKit
    961966
  • trunk/Source/WebKitLegacy/mac/ChangeLog

    r239948 r240010  
     12019-01-15  Tim Horton  <timothy_horton@apple.com>
     2
     3        Cannot tab out of WKWebView on macOS
     4        https://bugs.webkit.org/show_bug.cgi?id=161448
     5        <rdar://problem/28100085>
     6
     7        Reviewed by Dean Jackson.
     8
     9        * WebCoreSupport/WebChromeClient.mm:
     10        * WebView/WebView.mm:
     11        Make use of SPI headers.
     12
    1132019-01-14  Commit Queue  <commit-queue@webkit.org>
    214
  • trunk/Source/WebKitLegacy/mac/WebCoreSupport/WebChromeClient.mm

    r238771 r240010  
    8686#import <WebCore/Widget.h>
    8787#import <WebCore/WindowFeatures.h>
     88#import <pal/spi/mac/NSViewSPI.h>
    8889#import <wtf/BlockObjCExceptions.h>
    8990#import <wtf/RefPtr.h>
     
    135136@end
    136137#endif
    137 
    138 @interface NSView (WebNSViewDetails)
    139 - (NSView *)_findLastViewInKeyViewLoop;
    140 @end
    141138
    142139// For compatibility with old SPI.
  • trunk/Source/WebKitLegacy/mac/WebView/WebView.mm

    r239904 r240010  
    376376
    377377@interface NSWindow (WebNSWindowDetails)
    378 - (id)_oldFirstResponderBeforeBecoming;
    379378- (void)_enableScreenUpdatesIfNeeded;
    380379- (BOOL)_wrapsCarbonWindow;
  • trunk/Tools/ChangeLog

    r240006 r240010  
     12019-01-15  Tim Horton  <timothy_horton@apple.com>
     2
     3        Cannot tab out of WKWebView on macOS
     4        https://bugs.webkit.org/show_bug.cgi?id=161448
     5        <rdar://problem/28100085>
     6
     7        Reviewed by Dean Jackson.
     8
     9        Add a test that tabbing into and out of WKWebView works correctly.
     10
     11        * TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj:
     12        * TestWebKitAPI/Tests/WebKitCocoa/CommandBackForward.mm:
     13        (WebKit2_CommandBackForwardTest::SetUp):
     14        (-[CommandBackForwardOffscreenWindow isKeyWindow]): Deleted.
     15        (-[CommandBackForwardOffscreenWindow isVisible]): Deleted.
     16        * TestWebKitAPI/Tests/WebKitCocoa/TabOutOfWebView.mm: Added.
     17        (-[FocusableView canBecomeKeyView]):
     18        (TEST):
     19        * TestWebKitAPI/mac/OffscreenWindow.h: Added.
     20        * TestWebKitAPI/mac/OffscreenWindow.mm: Added.
     21        (-[OffscreenWindow initWithSize:]):
     22        (-[OffscreenWindow isKeyWindow]):
     23        (-[OffscreenWindow isVisible]):
     24        * TestWebKitAPI/mac/PlatformWebViewMac.mm:
     25        (TestWebKitAPI::PlatformWebView::initialize):
     26        (-[ActiveOffscreenWindow isKeyWindow]): Deleted.
     27        (-[ActiveOffscreenWindow isVisible]): Deleted.
     28        Factor ActiveOffscreenWindow out into OffscreenWindow and share it.
     29
    1302019-01-15  Ryan Haddad  <ryanhaddad@apple.com>
    231
  • trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj

    r239973 r240010  
    9191                2D4CF8BD1D8360CC0001CE8D /* WKThumbnailView.mm in Sources */ = {isa = PBXBuildFile; fileRef = 2D4CF8BC1D8360CC0001CE8D /* WKThumbnailView.mm */; };
    9292                2D51A0C71C8BF00C00765C45 /* DOMHTMLVideoElementWrapper.mm in Sources */ = {isa = PBXBuildFile; fileRef = 2D51A0C51C8BF00400765C45 /* DOMHTMLVideoElementWrapper.mm */; };
     93                2D70059621EDA0C6003463CB /* TabOutOfWebView.mm in Sources */ = {isa = PBXBuildFile; fileRef = 2D70059521EDA0C6003463CB /* TabOutOfWebView.mm */; };
     94                2D70059921EDA4D0003463CB /* OffscreenWindow.mm in Sources */ = {isa = PBXBuildFile; fileRef = 2D70059721EDA4D0003463CB /* OffscreenWindow.mm */; };
    9395                2D838B1F1EEF3A5C009B980E /* WKContentViewEditingActions.mm in Sources */ = {isa = PBXBuildFile; fileRef = 2D838B1E1EEF3A5B009B980E /* WKContentViewEditingActions.mm */; };
    9496                2DADF26321CB8F32003D3E3A /* GetResourceData.mm in Sources */ = {isa = PBXBuildFile; fileRef = 2DADF26221CB8F32003D3E3A /* GetResourceData.mm */; };
     
    14041406                2D61EC3021B0B75C00A7D1CB /* PencilKitTestSPI.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = PencilKitTestSPI.h; sourceTree = "<group>"; };
    14051407                2D640B5417875DFF00BFAF99 /* ScrollPinningBehaviors.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ScrollPinningBehaviors.cpp; sourceTree = "<group>"; };
     1408                2D70059521EDA0C6003463CB /* TabOutOfWebView.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = TabOutOfWebView.mm; sourceTree = "<group>"; };
     1409                2D70059721EDA4D0003463CB /* OffscreenWindow.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = OffscreenWindow.mm; sourceTree = "<group>"; };
     1410                2D70059821EDA4D0003463CB /* OffscreenWindow.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = OffscreenWindow.h; sourceTree = "<group>"; };
    14061411                2D8104CB1BEC13E70020DA46 /* FindInPage.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = FindInPage.mm; sourceTree = "<group>"; };
    14071412                2D838B1E1EEF3A5B009B980E /* WKContentViewEditingActions.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = WKContentViewEditingActions.mm; sourceTree = "<group>"; };
     
    25592564                                515BE1701D428BD100DD7C68 /* StoreBlobThenDelete.mm */,
    25602565                                1C734B5220788C4800F430EA /* SystemColors.mm */,
     2566                                2D70059521EDA0C6003463CB /* TabOutOfWebView.mm */,
    25612567                                F4CD74C720FDB49600DE3794 /* TestURLSchemeHandler.h */,
    25622568                                F4CD74C820FDB49600DE3794 /* TestURLSchemeHandler.mm */,
     
    33493355                                F442851B2140DF2900CCDA22 /* NSFontPanelTesting.h */,
    33503356                                F442851C2140DF2900CCDA22 /* NSFontPanelTesting.mm */,
     3357                                2D70059821EDA4D0003463CB /* OffscreenWindow.h */,
     3358                                2D70059721EDA4D0003463CB /* OffscreenWindow.mm */,
    33513359                                BC131884117114B600B69727 /* PlatformUtilitiesMac.mm */,
    33523360                                BC90955C125548AA00083756 /* PlatformWebViewMac.mm */,
     
    41164124                                F442851D2140DF2900CCDA22 /* NSFontPanelTesting.mm in Sources */,
    41174125                                37A22AA71DCAA27200AFBFC4 /* ObservedRenderingProgressEventsAfterCrash.mm in Sources */,
     4126                                2D70059921EDA4D0003463CB /* OffscreenWindow.mm in Sources */,
    41184127                                7CCE7F251A411AF600447C4C /* OpenAndCloseWindow.mm in Sources */,
    41194128                                CEBCA12F1E3A660100C73293 /* OverrideContentSecurityPolicy.mm in Sources */,
     
    42104219                                7CCE7EA81A411A1900447C4C /* SyntheticBackingScaleFactorWindow.m in Sources */,
    42114220                                1C734B5320788C4800F430EA /* SystemColors.mm in Sources */,
     4221                                2D70059621EDA0C6003463CB /* TabOutOfWebView.mm in Sources */,
    42124222                                7CCE7F161A411AE600447C4C /* TerminateTwice.cpp in Sources */,
    42134223                                7CCE7EA91A411A1D00447C4C /* TestBrowsingContextLoadDelegate.mm in Sources */,
  • trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/CommandBackForward.mm

    r239631 r240010  
    2828#if PLATFORM(MAC)
    2929
     30#import "OffscreenWindow.h"
    3031#import "PlatformUtilities.h"
    3132#import "Test.h"
     
    3637#import <wtf/RetainPtr.h>
    3738#import <wtf/mac/AppKitCompatibilityDeclarations.h>
    38 
    39 @interface CommandBackForwardOffscreenWindow : NSWindow
    40 @end
    41 
    42 @implementation CommandBackForwardOffscreenWindow
    43 - (BOOL)isKeyWindow
    44 {
    45     return YES;
    46 }
    47 - (BOOL)isVisible
    48 {
    49     return YES;
    50 }
    51 @end
    5239
    5340enum ArrowDirection {
     
    9784    virtual void SetUp()
    9885    {
    99         NSWindow *window = [[CommandBackForwardOffscreenWindow alloc] initWithContentRect:NSMakeRect(0, 0, 100, 100) styleMask:NSBorderlessWindowMask backing:NSBackingStoreBuffered defer:YES];
    100         [window setColorSpace:[[NSScreen mainScreen] colorSpace]];
    101         [window orderBack:nil];
    102         [window setAutodisplay:NO];
    103         [window setReleasedWhenClosed:NO];
     86        window = adoptNS([[OffscreenWindow alloc] initWithSize:CGSizeMake(100, 100)]);
    10487    }
    10588};
  • trunk/Tools/TestWebKitAPI/mac/OffscreenWindow.h

    r240009 r240010  
    11/*
    2  * Copyright (C) 2015-2017 Apple Inc. All rights reserved.
     2 * Copyright (C) 2019 Apple Inc. All rights reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
     
    2424 */
    2525
    26 #import <wtf/Platform.h>
     26#pragma once
    2727
    2828#if PLATFORM(MAC)
    2929
    30 #if USE(APPLE_INTERNAL_SDK)
     30#import <AppKit/AppKit.h>
    3131
    32 #import <AppKit/NSWindow_Private.h>
     32@interface OffscreenWindow : NSWindow
    3333
    34 #else
     34- (instancetype)init NS_UNAVAILABLE;
     35- (instancetype)initWithContentRect:(NSRect)contentRect styleMask:(NSWindowStyleMask)style backing:(NSBackingStoreType)backingStoreType defer:(BOOL)flag NS_UNAVAILABLE;
     36- (instancetype)initWithContentRect:(NSRect)contentRect styleMask:(NSWindowStyleMask)style backing:(NSBackingStoreType)backingStoreType defer:(BOOL)flag screen:(NSScreen *)screen NS_UNAVAILABLE;
    3537
    36 #import <AppKit/NSWindow.h>
    37 
    38 @interface NSWindow ()
    39 
    40 - (id)_newFirstResponderAfterResigning;
    41 - (void)_setCursorForMouseLocation:(NSPoint)point;
     38- (instancetype)initWithSize:(CGSize)size;
    4239
    4340@end
    4441
    45 enum {
    46     NSSideUtilityWindowMask = 1 << 9,
    47     NSSmallWindowMask = 1 << 10,
    48     _NSCarbonWindowMask = 1 << 25,
    49 };
    50 
    5142#endif
    52 
    53 extern NSString *NSWindowWillOrderOnScreenNotification;
    54 extern NSString *NSWindowWillOrderOffScreenNotification;
    55 
    56 #endif // PLATFORM(MAC)
  • trunk/Tools/TestWebKitAPI/mac/OffscreenWindow.mm

    r240009 r240010  
    11/*
    2  * Copyright (C) 2015-2017 Apple Inc. All rights reserved.
     2 * Copyright (C) 2019 Apple Inc. All rights reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
     
    2424 */
    2525
    26 #import <wtf/Platform.h>
     26#import "config.h"
     27#import "OffscreenWindow.h"
    2728
    28 #if PLATFORM(MAC)
     29@implementation OffscreenWindow
    2930
    30 #if USE(APPLE_INTERNAL_SDK)
     31- (instancetype)initWithSize:(CGSize)size
     32{
     33    NSRect rect = NSMakeRect(0, 0, size.width, size.height);
     34    NSRect windowRect = NSOffsetRect(rect, -10000, [(NSScreen *)[[NSScreen screens] objectAtIndex:0] frame].size.height - rect.size.height + 10000);
     35    self = [super initWithContentRect:windowRect styleMask:NSWindowStyleMaskBorderless backing:NSBackingStoreBuffered defer:YES];
     36    if (!self)
     37        return nil;
    3138
    32 #import <AppKit/NSWindow_Private.h>
     39    self.colorSpace = [[NSScreen mainScreen] colorSpace];
     40    [self orderBack:nil];
     41    self.autodisplay = NO;
     42    self.releasedWhenClosed = NO;
    3343
    34 #else
     44    return self;
     45}
    3546
    36 #import <AppKit/NSWindow.h>
     47- (BOOL)isKeyWindow
     48{
     49    return YES;
     50}
    3751
    38 @interface NSWindow ()
    39 
    40 - (id)_newFirstResponderAfterResigning;
    41 - (void)_setCursorForMouseLocation:(NSPoint)point;
     52- (BOOL)isVisible
     53{
     54    return YES;
     55}
    4256
    4357@end
    44 
    45 enum {
    46     NSSideUtilityWindowMask = 1 << 9,
    47     NSSmallWindowMask = 1 << 10,
    48     _NSCarbonWindowMask = 1 << 25,
    49 };
    50 
    51 #endif
    52 
    53 extern NSString *NSWindowWillOrderOnScreenNotification;
    54 extern NSString *NSWindowWillOrderOffScreenNotification;
    55 
    56 #endif // PLATFORM(MAC)
  • trunk/Tools/TestWebKitAPI/mac/PlatformWebViewMac.mm

    r215790 r240010  
    2727#import "PlatformWebView.h"
    2828
     29#import "OffscreenWindow.h"
    2930#import <Carbon/Carbon.h>
    3031#import <WebKit/WKRetainPtr.h>
     
    3233#import <wtf/mac/AppKitCompatibilityDeclarations.h>
    3334
    34 @interface ActiveOffscreenWindow : NSWindow
    35 @end
    36 
    37 @implementation ActiveOffscreenWindow
    38 - (BOOL)isKeyWindow
    39 {
    40     return YES;
    41 }
    42 - (BOOL)isVisible
    43 {
    44     return YES;
    45 }
    46 @end
    47 
    4835namespace TestWebKitAPI {
    4936
     
    5441    [m_view setWindowOcclusionDetectionEnabled:NO];
    5542
    56     NSRect windowRect = NSOffsetRect(rect, -10000, [(NSScreen *)[[NSScreen screens] objectAtIndex:0] frame].size.height - rect.size.height + 10000);
    57     m_window = [[ActiveOffscreenWindow alloc] initWithContentRect:windowRect styleMask:NSWindowStyleMaskBorderless backing:NSBackingStoreBuffered defer:YES];
    58     [m_window setColorSpace:[[NSScreen mainScreen] colorSpace]];
     43    m_window = [[OffscreenWindow alloc] initWithSize:NSSizeToCGSize(rect.size)];
    5944    [[m_window contentView] addSubview:m_view];
    60     [m_window orderBack:nil];
    61     [m_window setAutodisplay:NO];
    62     [m_window setReleasedWhenClosed:NO];
    6345}
    6446
Note: See TracChangeset for help on using the changeset viewer.