WebKit Bugzilla
Attachment 359181 Details for
Bug 161448
: AX: Cannot tab out of WKWebView for macOS
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
Patch
bug-161448-20190115110224.patch (text/plain), 35.41 KB, created by
Tim Horton
on 2019-01-15 11:02:25 PST
(
hide
)
Description:
Patch
Filename:
MIME Type:
Creator:
Tim Horton
Created:
2019-01-15 11:02:25 PST
Size:
35.41 KB
patch
obsolete
>Subversion Revision: 239973 >diff --git a/Source/WebCore/PAL/ChangeLog b/Source/WebCore/PAL/ChangeLog >index 78773903fb79e7545e5b185ac4aa8b8c6ef6a401..ffaf4f4ade15ddef1dd6fe8beef4529218c3d984 100644 >--- a/Source/WebCore/PAL/ChangeLog >+++ b/Source/WebCore/PAL/ChangeLog >@@ -1,3 +1,15 @@ >+2019-01-14 Tim Horton <timothy_horton@apple.com> >+ >+ Cannot tab out of WKWebView on macOS >+ https://bugs.webkit.org/show_bug.cgi?id=161448 >+ <rdar://problem/28100085> >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ * pal/spi/mac/NSViewSPI.h: >+ * pal/spi/mac/NSWindowSPI.h: >+ Move some SPI declarations in here from WebKitLegacy. >+ > 2019-01-14 Commit Queue <commit-queue@webkit.org> > > Unreviewed, rolling out r239901, r239909, r239910, r239912, >diff --git a/Source/WebKit/ChangeLog b/Source/WebKit/ChangeLog >index 8304a3f55258d28d96652ac073fb11bc8235aeae..daacfb2e57cc490d0d653e85d6d21c6605ea736b 100644 >--- a/Source/WebKit/ChangeLog >+++ b/Source/WebKit/ChangeLog >@@ -1,3 +1,38 @@ >+2019-01-14 Tim Horton <timothy_horton@apple.com> >+ >+ Cannot tab out of WKWebView on macOS >+ https://bugs.webkit.org/show_bug.cgi?id=161448 >+ <rdar://problem/28100085> >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ * 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. >+ > 2019-01-14 Tim Horton <timothy_horton@apple.com> > > Fix a style mistake in PageClientImplMac >diff --git a/Source/WebKitLegacy/mac/ChangeLog b/Source/WebKitLegacy/mac/ChangeLog >index 41e0d312829268999b3aa5f2cb1ef644aaca6ab0..8cfe496296d0a23dda35825478fa735aed0b3e2f 100644 >--- a/Source/WebKitLegacy/mac/ChangeLog >+++ b/Source/WebKitLegacy/mac/ChangeLog >@@ -1,3 +1,15 @@ >+2019-01-14 Tim Horton <timothy_horton@apple.com> >+ >+ Cannot tab out of WKWebView on macOS >+ https://bugs.webkit.org/show_bug.cgi?id=161448 >+ <rdar://problem/28100085> >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ * WebCoreSupport/WebChromeClient.mm: >+ * WebView/WebView.mm: >+ Make use of SPI headers. >+ > 2019-01-14 Commit Queue <commit-queue@webkit.org> > > Unreviewed, rolling out r239901, r239909, r239910, r239912, >diff --git a/Source/WebCore/PAL/pal/spi/mac/NSViewSPI.h b/Source/WebCore/PAL/pal/spi/mac/NSViewSPI.h >index 9eedb73c92349bbe5d8cd169bc0128416caf2fbb..d71ff6bde8279d00cd34a2dcb0b7be7061b7a2d2 100644 >--- a/Source/WebCore/PAL/pal/spi/mac/NSViewSPI.h >+++ b/Source/WebCore/PAL/pal/spi/mac/NSViewSPI.h >@@ -28,6 +28,9 @@ > #import <pal/spi/cocoa/QuartzCoreSPI.h> > > @interface NSView () <CALayerDelegate> >+ >+- (NSView *)_findLastViewInKeyViewLoop; >+ > @end > > #endif // PLATFORM(MAC) >diff --git a/Source/WebCore/PAL/pal/spi/mac/NSWindowSPI.h b/Source/WebCore/PAL/pal/spi/mac/NSWindowSPI.h >index 0bb2a998f47ce8e87fb55af778c6266dd61036ff..08af95a044ad69904206217a4c4a7500309a4a13 100644 >--- a/Source/WebCore/PAL/pal/spi/mac/NSWindowSPI.h >+++ b/Source/WebCore/PAL/pal/spi/mac/NSWindowSPI.h >@@ -37,6 +37,7 @@ > > @interface NSWindow () > >+- (id)_oldFirstResponderBeforeBecoming; > - (id)_newFirstResponderAfterResigning; > - (void)_setCursorForMouseLocation:(NSPoint)point; > >diff --git a/Source/WebKit/UIProcess/API/APIUIClient.h b/Source/WebKit/UIProcess/API/APIUIClient.h >index 43ff763b9048cc40a967d9456bbe03acbb95027c..08948e774f91706cf1a20138af90fdffb8e46ce8 100644 >--- a/Source/WebKit/UIProcess/API/APIUIClient.h >+++ b/Source/WebKit/UIProcess/API/APIUIClient.h >@@ -81,7 +81,7 @@ public: > virtual void hasVideoInPictureInPictureDidChange(WebKit::WebPageProxy*, bool) { } > virtual void close(WebKit::WebPageProxy*) { } > >- virtual void takeFocus(WebKit::WebPageProxy*, WKFocusDirection) { } >+ virtual bool takeFocus(WebKit::WebPageProxy*, WKFocusDirection) { return false; } > virtual void focus(WebKit::WebPageProxy*) { } > virtual void unfocus(WebKit::WebPageProxy*) { } > >diff --git a/Source/WebKit/UIProcess/API/C/WKPage.cpp b/Source/WebKit/UIProcess/API/C/WKPage.cpp >index d4ee8cc0b5fd9a853562dbe00d573137788c1fa8..6b40b9f3706d4f37853b39dd25460a764f0bbc85 100644 >--- a/Source/WebKit/UIProcess/API/C/WKPage.cpp >+++ b/Source/WebKit/UIProcess/API/C/WKPage.cpp >@@ -1553,12 +1553,13 @@ void WKPageSetPageUIClient(WKPageRef pageRef, const WKPageUIClientBase* wkClient > m_client.close(toAPI(page), m_client.base.clientInfo); > } > >- void takeFocus(WebPageProxy* page, WKFocusDirection direction) final >+ bool takeFocus(WebPageProxy* page, WKFocusDirection direction) final > { > if (!m_client.takeFocus) >- return; >+ return false; > > m_client.takeFocus(toAPI(page), direction, m_client.base.clientInfo); >+ return true; > } > > void focus(WebPageProxy* page) final >diff --git a/Source/WebKit/UIProcess/Cocoa/UIDelegate.h b/Source/WebKit/UIProcess/Cocoa/UIDelegate.h >index 38dd7ecbcfb5f2a60fc86c98be8b0f31a854ff86..6d68069acb6440091e08f1aa9eaba1200cf5168a 100644 >--- a/Source/WebKit/UIProcess/Cocoa/UIDelegate.h >+++ b/Source/WebKit/UIProcess/Cocoa/UIDelegate.h >@@ -95,7 +95,7 @@ private: > void exceededDatabaseQuota(WebPageProxy*, WebFrameProxy*, API::SecurityOrigin*, const WTF::String& databaseName, const WTF::String& displayName, unsigned long long currentQuota, unsigned long long currentOriginUsage, unsigned long long currentUsage, unsigned long long expectedUsage, Function<void(unsigned long long)>&& completionHandler) final; > void reachedApplicationCacheOriginQuota(WebPageProxy*, const WebCore::SecurityOrigin&, uint64_t currentQuota, uint64_t totalBytesNeeded, Function<void(unsigned long long)>&& completionHandler) final; > void didResignInputElementStrongPasswordAppearance(WebPageProxy&, API::Object*) final; >- void takeFocus(WebPageProxy*, WKFocusDirection) final; >+ bool takeFocus(WebPageProxy*, WKFocusDirection) final; > #if PLATFORM(MAC) > void showPage(WebPageProxy*) final; > void focus(WebPageProxy*) final; >diff --git a/Source/WebKit/UIProcess/Cocoa/UIDelegate.mm b/Source/WebKit/UIProcess/Cocoa/UIDelegate.mm >index c16853fa4db1ce492402afceeda510fb60cc62ee..daecab4ec85192acdcf5bd2bbf000c4cf083b508 100644 >--- a/Source/WebKit/UIProcess/Cocoa/UIDelegate.mm >+++ b/Source/WebKit/UIProcess/Cocoa/UIDelegate.mm >@@ -466,16 +466,17 @@ static inline _WKFocusDirection toWKFocusDirection(WKFocusDirection direction) > return _WKFocusDirectionForward; > } > >-void UIDelegate::UIClient::takeFocus(WebPageProxy*, WKFocusDirection direction) >+bool UIDelegate::UIClient::takeFocus(WebPageProxy*, WKFocusDirection direction) > { > if (!m_uiDelegate.m_delegateMethods.webViewTakeFocus) >- return; >+ return false; > > auto delegate = m_uiDelegate.m_delegate.get(); > if (!delegate) >- return; >+ return false; > > [(id <WKUIDelegatePrivate>)delegate _webView:m_uiDelegate.m_webView takeFocus:toWKFocusDirection(direction)]; >+ return true; > } > > #if PLATFORM(MAC) >diff --git a/Source/WebKit/UIProcess/Cocoa/WebViewImpl.h b/Source/WebKit/UIProcess/Cocoa/WebViewImpl.h >index f757d8724f267fd91a000248f48d4291b323517f..c68dbcc7ceab9124fb9ee95a52d68dee883ac77a 100644 >--- a/Source/WebKit/UIProcess/Cocoa/WebViewImpl.h >+++ b/Source/WebKit/UIProcess/Cocoa/WebViewImpl.h >@@ -32,6 +32,7 @@ > #include "WKDragDestinationAction.h" > #include "WKLayoutMode.h" > #include "_WKOverlayScrollbarStyle.h" >+#include <WebCore/FocusDirection.h> > #include <WebCore/ScrollTypes.h> > #include <WebCore/TextIndicatorWindow.h> > #include <WebCore/UserInterfaceLayoutDirection.h> >@@ -603,6 +604,8 @@ public: > void effectiveAppearanceDidChange(); > bool effectiveAppearanceIsDark(); > >+ void takeFocus(WebCore::FocusDirection); >+ > private: > #if HAVE(TOUCH_BAR) > void setUpTextTouchBar(NSTouchBar *); >diff --git a/Source/WebKit/UIProcess/Cocoa/WebViewImpl.mm b/Source/WebKit/UIProcess/Cocoa/WebViewImpl.mm >index da2e32f2548f1d56a60b6560adbef569376661d5..d51ef5d9fe172cc0616ca05fdd3f19a636d82f92 100644 >--- a/Source/WebKit/UIProcess/Cocoa/WebViewImpl.mm >+++ b/Source/WebKit/UIProcess/Cocoa/WebViewImpl.mm >@@ -112,6 +112,7 @@ > #import <pal/spi/mac/NSScrollerImpSPI.h> > #import <pal/spi/mac/NSSpellCheckerSPI.h> > #import <pal/spi/mac/NSTextFinderSPI.h> >+#import <pal/spi/mac/NSViewSPI.h> > #import <pal/spi/mac/NSWindowSPI.h> > #import <sys/stat.h> > #import <wtf/NeverDestroyed.h> >@@ -1570,6 +1571,20 @@ bool WebViewImpl::resignFirstResponder() > return true; > } > >+void WebViewImpl::takeFocus(WebCore::FocusDirection direction) >+{ >+ NSView *webView = m_view.getAutoreleased(); >+ >+ if (direction == FocusDirectionForward) { >+ // Since we're trying to move focus out of m_webView, and because >+ // m_webView may contain subviews within it, we ask it for the next key >+ // view of the last view in its key view loop. This makes m_webView >+ // behave as if it had no subviews, which is the behavior we want. >+ [webView.window selectKeyViewFollowingView:[webView _findLastViewInKeyViewLoop]]; >+ } else >+ [webView.window selectKeyViewPrecedingView:webView]; >+} >+ > void WebViewImpl::showSafeBrowsingWarning(const SafeBrowsingWarning& warning, CompletionHandler<void(Variant<ContinueUnsafeLoad, URL>&&)>&& completionHandler) > { > if (!m_view) >diff --git a/Source/WebKit/UIProcess/PageClient.h b/Source/WebKit/UIProcess/PageClient.h >index 149714ab1d2265a6834d57ef47b116ea4e29e351..aaabcc288c478892007531efe40a9201e9ea1deb 100644 >--- a/Source/WebKit/UIProcess/PageClient.h >+++ b/Source/WebKit/UIProcess/PageClient.h >@@ -33,6 +33,7 @@ > #include "WebPopupMenuProxy.h" > #include <WebCore/AlternativeTextClient.h> > #include <WebCore/EditorClient.h> >+#include <WebCore/FocusDirection.h> > #include <WebCore/UserInterfaceLayoutDirection.h> > #include <WebCore/ValidationBubble.h> > #include <wtf/CompletionHandler.h> >@@ -309,6 +310,8 @@ public: > virtual void exitAcceleratedCompositingMode() = 0; > virtual void updateAcceleratedCompositingMode(const LayerTreeContext&) = 0; > >+ virtual void takeFocus(WebCore::FocusDirection) { } >+ > #if PLATFORM(MAC) > virtual void pluginFocusOrWindowFocusChanged(uint64_t pluginComplexTextInputIdentifier, bool pluginHasFocusAndWindowHasFocus) = 0; > virtual void setPluginComplexTextInputState(uint64_t pluginComplexTextInputIdentifier, PluginComplexTextInputState) = 0; >diff --git a/Source/WebKit/UIProcess/WebPageProxy.cpp b/Source/WebKit/UIProcess/WebPageProxy.cpp >index c8ab70333b4039a8779c4ca3f31e1907563a3369..0c8a6876f25aaf4a000c5c20b23f94318c5dd18c 100644 >--- a/Source/WebKit/UIProcess/WebPageProxy.cpp >+++ b/Source/WebKit/UIProcess/WebPageProxy.cpp >@@ -5881,7 +5881,10 @@ void WebPageProxy::setFocus(bool focused) > > void WebPageProxy::takeFocus(uint32_t direction) > { >- m_uiClient->takeFocus(this, (static_cast<FocusDirection>(direction) == FocusDirectionForward) ? kWKFocusDirectionForward : kWKFocusDirectionBackward); >+ if (m_uiClient->takeFocus(this, (static_cast<FocusDirection>(direction) == FocusDirectionForward) ? kWKFocusDirectionForward : kWKFocusDirectionBackward)) >+ return; >+ >+ pageClient().takeFocus(static_cast<FocusDirection>(direction)); > } > > void WebPageProxy::setToolTip(const String& toolTip) >diff --git a/Source/WebKit/UIProcess/mac/PageClientImplMac.h b/Source/WebKit/UIProcess/mac/PageClientImplMac.h >index 7cfdc57777999f44c4cbb43cd106e3bfd9c3da5c..12dc25abcc33f4de5e6c6360ebd8c32d05a4ae75 100644 >--- a/Source/WebKit/UIProcess/mac/PageClientImplMac.h >+++ b/Source/WebKit/UIProcess/mac/PageClientImplMac.h >@@ -262,6 +262,8 @@ private: > void didRestoreScrollPosition() override; > bool windowIsFrontWindowUnderMouse(const NativeWebMouseEvent&) override; > >+ void takeFocus(WebCore::FocusDirection) override; >+ > NSView *m_view; > WeakPtr<WebViewImpl> m_impl; > #if USE(AUTOCORRECTION_PANEL) >diff --git a/Source/WebKit/UIProcess/mac/PageClientImplMac.mm b/Source/WebKit/UIProcess/mac/PageClientImplMac.mm >index a0cefdd73e9edc19cba4eb5876fadc937076fe53..5d7c238efd69f615abf5a7d555d48d23c476ee58 100644 >--- a/Source/WebKit/UIProcess/mac/PageClientImplMac.mm >+++ b/Source/WebKit/UIProcess/mac/PageClientImplMac.mm >@@ -957,6 +957,11 @@ bool PageClientImpl::effectiveAppearanceIsDark() const > return m_impl->effectiveAppearanceIsDark(); > } > >+void PageClientImpl::takeFocus(WebCore::FocusDirection direction) >+{ >+ m_impl->takeFocus(direction); >+} >+ > } // namespace WebKit > > #endif // PLATFORM(MAC) >diff --git a/Source/WebKitLegacy/mac/WebCoreSupport/WebChromeClient.mm b/Source/WebKitLegacy/mac/WebCoreSupport/WebChromeClient.mm >index 4c5d18dc02ccff2b7eab98050921a67a98f69cc5..3e0a5c2726f5816be90ffeac1279daebe6462350 100644 >--- a/Source/WebKitLegacy/mac/WebCoreSupport/WebChromeClient.mm >+++ b/Source/WebKitLegacy/mac/WebCoreSupport/WebChromeClient.mm >@@ -85,6 +85,7 @@ > #import <WebCore/SerializedCryptoKeyWrap.h> > #import <WebCore/Widget.h> > #import <WebCore/WindowFeatures.h> >+#import <pal/spi/mac/NSViewSPI.h> > #import <wtf/BlockObjCExceptions.h> > #import <wtf/RefPtr.h> > #import <wtf/Vector.h> >@@ -135,10 +136,6 @@ - (NSCursor *)_cursorRectCursor; > @end > #endif > >-@interface NSView (WebNSViewDetails) >-- (NSView *)_findLastViewInKeyViewLoop; >-@end >- > // For compatibility with old SPI. > @interface NSView (WebOldWebKitPlugInDetails) > - (void)setIsSelected:(BOOL)isSelected; >diff --git a/Source/WebKitLegacy/mac/WebView/WebView.mm b/Source/WebKitLegacy/mac/WebView/WebView.mm >index ab838453b32464e51e12a025360feb7b23859cfd..a5e411894afa98e412b6273ede6f01b713c1d007 100644 >--- a/Source/WebKitLegacy/mac/WebView/WebView.mm >+++ b/Source/WebKitLegacy/mac/WebView/WebView.mm >@@ -375,7 +375,6 @@ - (void)_windowChangedKeyState; > @end > > @interface NSWindow (WebNSWindowDetails) >-- (id)_oldFirstResponderBeforeBecoming; > - (void)_enableScreenUpdatesIfNeeded; > - (BOOL)_wrapsCarbonWindow; > - (BOOL)_hasKeyAppearance; >diff --git a/Tools/ChangeLog b/Tools/ChangeLog >index 97b27205c393c12ffdb163674a052b5701c659f9..f8ecc8b4ff9e6485205555c914a59c6d4c308610 100644 >--- a/Tools/ChangeLog >+++ b/Tools/ChangeLog >@@ -1,3 +1,32 @@ >+2019-01-14 Tim Horton <timothy_horton@apple.com> >+ >+ Cannot tab out of WKWebView on macOS >+ https://bugs.webkit.org/show_bug.cgi?id=161448 >+ <rdar://problem/28100085> >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ 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. >+ > 2019-01-14 Tim Horton <timothy_horton@apple.com> > > Move a test implementation file that got misplaced in the Xcode project >diff --git a/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj b/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj >index ccdd8eed392506b18d89f12f416bf003a15edbe0..7a1072acdaa2c2aa507cdb2fc2970810845c3f0a 100644 >--- a/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj >+++ b/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj >@@ -90,6 +90,8 @@ > 2D21FE591F04642900B58E7D /* WKPDFViewStablePresentationUpdateCallback.mm in Sources */ = {isa = PBXBuildFile; fileRef = 2D21FE581F04642800B58E7D /* WKPDFViewStablePresentationUpdateCallback.mm */; }; > 2D4CF8BD1D8360CC0001CE8D /* WKThumbnailView.mm in Sources */ = {isa = PBXBuildFile; fileRef = 2D4CF8BC1D8360CC0001CE8D /* WKThumbnailView.mm */; }; > 2D51A0C71C8BF00C00765C45 /* DOMHTMLVideoElementWrapper.mm in Sources */ = {isa = PBXBuildFile; fileRef = 2D51A0C51C8BF00400765C45 /* DOMHTMLVideoElementWrapper.mm */; }; >+ 2D70059621EDA0C6003463CB /* TabOutOfWebView.mm in Sources */ = {isa = PBXBuildFile; fileRef = 2D70059521EDA0C6003463CB /* TabOutOfWebView.mm */; }; >+ 2D70059921EDA4D0003463CB /* OffscreenWindow.mm in Sources */ = {isa = PBXBuildFile; fileRef = 2D70059721EDA4D0003463CB /* OffscreenWindow.mm */; }; > 2D838B1F1EEF3A5C009B980E /* WKContentViewEditingActions.mm in Sources */ = {isa = PBXBuildFile; fileRef = 2D838B1E1EEF3A5B009B980E /* WKContentViewEditingActions.mm */; }; > 2DADF26321CB8F32003D3E3A /* GetResourceData.mm in Sources */ = {isa = PBXBuildFile; fileRef = 2DADF26221CB8F32003D3E3A /* GetResourceData.mm */; }; > 2DB0232F1E4E871800707123 /* InteractionDeadlockAfterCrash.mm in Sources */ = {isa = PBXBuildFile; fileRef = 2DB0232E1E4E871800707123 /* InteractionDeadlockAfterCrash.mm */; }; >@@ -1403,6 +1405,9 @@ > 2D51A0C51C8BF00400765C45 /* DOMHTMLVideoElementWrapper.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = DOMHTMLVideoElementWrapper.mm; sourceTree = "<group>"; }; > 2D61EC3021B0B75C00A7D1CB /* PencilKitTestSPI.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = PencilKitTestSPI.h; sourceTree = "<group>"; }; > 2D640B5417875DFF00BFAF99 /* ScrollPinningBehaviors.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ScrollPinningBehaviors.cpp; sourceTree = "<group>"; }; >+ 2D70059521EDA0C6003463CB /* TabOutOfWebView.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = TabOutOfWebView.mm; sourceTree = "<group>"; }; >+ 2D70059721EDA4D0003463CB /* OffscreenWindow.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = OffscreenWindow.mm; sourceTree = "<group>"; }; >+ 2D70059821EDA4D0003463CB /* OffscreenWindow.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = OffscreenWindow.h; sourceTree = "<group>"; }; > 2D8104CB1BEC13E70020DA46 /* FindInPage.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = FindInPage.mm; sourceTree = "<group>"; }; > 2D838B1E1EEF3A5B009B980E /* WKContentViewEditingActions.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = WKContentViewEditingActions.mm; sourceTree = "<group>"; }; > 2D9A53AE1B31FA8D0074D5AA /* ShrinkToFit.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = ShrinkToFit.mm; sourceTree = "<group>"; }; >@@ -2558,6 +2563,7 @@ > CDC0932D21C993440030C4B0 /* StopSuspendResumeAllMedia.mm */, > 515BE1701D428BD100DD7C68 /* StoreBlobThenDelete.mm */, > 1C734B5220788C4800F430EA /* SystemColors.mm */, >+ 2D70059521EDA0C6003463CB /* TabOutOfWebView.mm */, > F4CD74C720FDB49600DE3794 /* TestURLSchemeHandler.h */, > F4CD74C820FDB49600DE3794 /* TestURLSchemeHandler.mm */, > 5CB40B4D1F4B98BE007DC7B9 /* UIDelegate.mm */, >@@ -3348,6 +3354,8 @@ > 2E7765CE16C4D81100BA2BB1 /* mainMac.mm */, > F442851B2140DF2900CCDA22 /* NSFontPanelTesting.h */, > F442851C2140DF2900CCDA22 /* NSFontPanelTesting.mm */, >+ 2D70059821EDA4D0003463CB /* OffscreenWindow.h */, >+ 2D70059721EDA4D0003463CB /* OffscreenWindow.mm */, > BC131884117114B600B69727 /* PlatformUtilitiesMac.mm */, > BC90955C125548AA00083756 /* PlatformWebViewMac.mm */, > C081224313FC19EC00DC39AE /* SyntheticBackingScaleFactorWindow.h */, >@@ -4115,6 +4123,7 @@ > A10F047E1E3AD29C00C95E19 /* NSFileManagerExtras.mm in Sources */, > F442851D2140DF2900CCDA22 /* NSFontPanelTesting.mm in Sources */, > 37A22AA71DCAA27200AFBFC4 /* ObservedRenderingProgressEventsAfterCrash.mm in Sources */, >+ 2D70059921EDA4D0003463CB /* OffscreenWindow.mm in Sources */, > 7CCE7F251A411AF600447C4C /* OpenAndCloseWindow.mm in Sources */, > CEBCA12F1E3A660100C73293 /* OverrideContentSecurityPolicy.mm in Sources */, > 7CCB4DA91C83AE7300CC6918 /* PageGroup.cpp in Sources */, >@@ -4209,6 +4218,7 @@ > 4433A396208044140091ED57 /* SynchronousTimeoutTests.mm in Sources */, > 7CCE7EA81A411A1900447C4C /* SyntheticBackingScaleFactorWindow.m in Sources */, > 1C734B5320788C4800F430EA /* SystemColors.mm in Sources */, >+ 2D70059621EDA0C6003463CB /* TabOutOfWebView.mm in Sources */, > 7CCE7F161A411AE600447C4C /* TerminateTwice.cpp in Sources */, > 7CCE7EA91A411A1D00447C4C /* TestBrowsingContextLoadDelegate.mm in Sources */, > F46128CB211D475100D9FADB /* TestDraggingInfo.mm in Sources */, >diff --git a/Tools/TestWebKitAPI/Tests/WebKitCocoa/CommandBackForward.mm b/Tools/TestWebKitAPI/Tests/WebKitCocoa/CommandBackForward.mm >index b3c5af907b2fb5d9c9350dde437cc427c289eefc..a48c7838eb2b19a5007717fb45b7e1676aa3aa1e 100644 >--- a/Tools/TestWebKitAPI/Tests/WebKitCocoa/CommandBackForward.mm >+++ b/Tools/TestWebKitAPI/Tests/WebKitCocoa/CommandBackForward.mm >@@ -27,6 +27,7 @@ > > #if PLATFORM(MAC) > >+#import "OffscreenWindow.h" > #import "PlatformUtilities.h" > #import "Test.h" > #import "TestNavigationDelegate.h" >@@ -36,20 +37,6 @@ > #import <wtf/RetainPtr.h> > #import <wtf/mac/AppKitCompatibilityDeclarations.h> > >-@interface CommandBackForwardOffscreenWindow : NSWindow >-@end >- >-@implementation CommandBackForwardOffscreenWindow >-- (BOOL)isKeyWindow >-{ >- return YES; >-} >-- (BOOL)isVisible >-{ >- return YES; >-} >-@end >- > enum ArrowDirection { > Left, > Right >@@ -96,11 +83,7 @@ public: > > virtual void SetUp() > { >- NSWindow *window = [[CommandBackForwardOffscreenWindow alloc] initWithContentRect:NSMakeRect(0, 0, 100, 100) styleMask:NSBorderlessWindowMask backing:NSBackingStoreBuffered defer:YES]; >- [window setColorSpace:[[NSScreen mainScreen] colorSpace]]; >- [window orderBack:nil]; >- [window setAutodisplay:NO]; >- [window setReleasedWhenClosed:NO]; >+ window = adoptNS([[OffscreenWindow alloc] initWithSize:CGSizeMake(100, 100)]); > } > }; > >diff --git a/Tools/TestWebKitAPI/Tests/WebKitCocoa/TabOutOfWebView.mm b/Tools/TestWebKitAPI/Tests/WebKitCocoa/TabOutOfWebView.mm >new file mode 100644 >index 0000000000000000000000000000000000000000..f007cad2b05b8b76fac8957494e73725452900d9 >--- /dev/null >+++ b/Tools/TestWebKitAPI/Tests/WebKitCocoa/TabOutOfWebView.mm >@@ -0,0 +1,140 @@ >+/* >+ * Copyright (C) 2019 Apple Inc. All rights reserved. >+ * >+ * Redistribution and use in source and binary forms, with or without >+ * modification, are permitted provided that the following conditions >+ * are met: >+ * 1. Redistributions of source code must retain the above copyright >+ * notice, this list of conditions and the following disclaimer. >+ * 2. Redistributions in binary form must reproduce the above copyright >+ * notice, this list of conditions and the following disclaimer in the >+ * documentation and/or other materials provided with the distribution. >+ * >+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' >+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, >+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR >+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS >+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR >+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF >+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS >+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN >+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) >+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF >+ * THE POSSIBILITY OF SUCH DAMAGE. >+ */ >+ >+#include "config.h" >+ >+#import "OffscreenWindow.h" >+#import "PlatformUtilities.h" >+#import "TestWKWebView.h" >+#import <Carbon/Carbon.h> >+#import <WebKit/WKWebViewPrivate.h> >+#import <wtf/RetainPtr.h> >+ >+enum class TabDirection : uint8_t { >+ Forward, >+ Backward, >+}; >+ >+@interface NSApplication () >+- (void)_setCurrentEvent:(NSEvent *)event; >+@end >+ >+@interface FocusableView : NSView >+@end >+ >+@implementation FocusableView >+ >+- (BOOL)canBecomeKeyView >+{ >+ return YES; >+} >+ >+@end >+ >+#if WK_API_ENABLED && PLATFORM(MAC) >+ >+TEST(WebKit, TabOutOfWebView) >+{ >+ RetainPtr<FocusableView> beforeView = adoptNS([[FocusableView alloc] initWithFrame:NSMakeRect(0, 200, 100, 100)]); >+ RetainPtr<WKWebViewConfiguration> configuration = adoptNS([[WKWebViewConfiguration alloc] init]); >+ RetainPtr<TestWKWebView> webView = adoptNS([[TestWKWebView alloc] initWithFrame:CGRectMake(0, 100, 100, 100) configuration:configuration.get() addToWindow:NO]); >+ RetainPtr<FocusableView> afterView = adoptNS([[FocusableView alloc] initWithFrame:NSMakeRect(0, 0, 100, 100)]); >+ RetainPtr<OffscreenWindow> window = adoptNS([[OffscreenWindow alloc] initWithSize:CGSizeMake(800, 600)]); >+ >+ [[window contentView] addSubview:beforeView.get()]; >+ [[window contentView] addSubview:webView.get()]; >+ [[window contentView] addSubview:afterView.get()]; >+ >+ [beforeView setNextKeyView:webView.get()]; >+ [webView setNextKeyView:afterView.get()]; >+ [afterView setNextKeyView:beforeView.get()]; >+ >+ auto simulateTabKeyPress = ^(TabDirection direction) { >+ NSString *characters; >+ unsigned short keyCode = kVK_Tab; >+ NSEventModifierFlags flags = 0; >+ >+ switch (direction) { >+ case TabDirection::Forward: >+ characters = @"\t"; >+ break; >+ case TabDirection::Backward: >+ characters = @"\x0019"; >+ flags = NSEventModifierFlagShift; >+ break; >+ } >+ >+ NSEvent *event = [NSEvent keyEventWithType:NSEventTypeKeyDown location:NSMakePoint(5, 5) modifierFlags:flags timestamp:GetCurrentEventTime() windowNumber:[window windowNumber] context:[NSGraphicsContext currentContext] characters:characters charactersIgnoringModifiers:characters isARepeat:NO keyCode:keyCode]; >+ >+ [NSApp _setCurrentEvent:event]; >+ [[window firstResponder] keyDown:event]; >+ [NSApp _setCurrentEvent:nil]; >+ >+ event = [NSEvent keyEventWithType:NSEventTypeKeyUp location:NSMakePoint(5, 5) modifierFlags:flags timestamp:GetCurrentEventTime() windowNumber:[window windowNumber] context:[NSGraphicsContext currentContext] characters:characters charactersIgnoringModifiers:characters isARepeat:NO keyCode:keyCode]; >+ >+ [NSApp _setCurrentEvent:event]; >+ [[window firstResponder] keyUp:event]; >+ [NSApp _setCurrentEvent:nil]; >+ >+ // Bounce through JavaScript so that asynchronous >+ // web content focus changes have definitely taken effect. >+ [webView stringByEvaluatingJavaScript:@""]; >+ }; >+ >+ [webView synchronouslyLoadHTMLString:@"<input id='one'><input id='two'>"]; >+ >+ // Focus the first view. >+ [window makeFirstResponder:beforeView.get()]; >+ EXPECT_EQ([window firstResponder], beforeView.get()); >+ >+ // Tab into the web view, which will focus the first input. >+ simulateTabKeyPress(TabDirection::Forward); >+ EXPECT_EQ([window firstResponder], webView.get()); >+ EXPECT_WK_STREQ("one", [webView stringByEvaluatingJavaScript:@"document.activeElement.id"]); >+ >+ // Tab from the first input to the second input. >+ simulateTabKeyPress(TabDirection::Forward); >+ EXPECT_EQ([window firstResponder], webView.get()); >+ EXPECT_WK_STREQ("two", [webView stringByEvaluatingJavaScript:@"document.activeElement.id"]); >+ >+ // Tab out of the web view. >+ simulateTabKeyPress(TabDirection::Forward); >+ EXPECT_EQ([window firstResponder], afterView.get()); >+ >+ // Reverse-tab back into the web view. >+ simulateTabKeyPress(TabDirection::Backward); >+ EXPECT_EQ([window firstResponder], webView.get()); >+ EXPECT_WK_STREQ("two", [webView stringByEvaluatingJavaScript:@"document.activeElement.id"]); >+ >+ // Reverse-tab from the second input to the first input. >+ simulateTabKeyPress(TabDirection::Backward); >+ EXPECT_WK_STREQ("one", [webView stringByEvaluatingJavaScript:@"document.activeElement.id"]); >+ >+ // Reverse-tab back out of the web view to the first view. >+ simulateTabKeyPress(TabDirection::Backward); >+ EXPECT_EQ([window firstResponder], beforeView.get()); >+} >+ >+#endif >diff --git a/Tools/TestWebKitAPI/mac/OffscreenWindow.h b/Tools/TestWebKitAPI/mac/OffscreenWindow.h >new file mode 100644 >index 0000000000000000000000000000000000000000..e4efe02b5b28f306ed6bbc291b6302de6e1ad0ed >--- /dev/null >+++ b/Tools/TestWebKitAPI/mac/OffscreenWindow.h >@@ -0,0 +1,42 @@ >+/* >+ * Copyright (C) 2019 Apple Inc. All rights reserved. >+ * >+ * Redistribution and use in source and binary forms, with or without >+ * modification, are permitted provided that the following conditions >+ * are met: >+ * 1. Redistributions of source code must retain the above copyright >+ * notice, this list of conditions and the following disclaimer. >+ * 2. Redistributions in binary form must reproduce the above copyright >+ * notice, this list of conditions and the following disclaimer in the >+ * documentation and/or other materials provided with the distribution. >+ * >+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' >+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, >+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR >+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS >+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR >+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF >+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS >+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN >+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) >+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF >+ * THE POSSIBILITY OF SUCH DAMAGE. >+ */ >+ >+#pragma once >+ >+#if PLATFORM(MAC) >+ >+#import <AppKit/AppKit.h> >+ >+@interface OffscreenWindow : NSWindow >+ >+- (instancetype)init NS_UNAVAILABLE; >+- (instancetype)initWithContentRect:(NSRect)contentRect styleMask:(NSWindowStyleMask)style backing:(NSBackingStoreType)backingStoreType defer:(BOOL)flag NS_UNAVAILABLE; >+- (instancetype)initWithContentRect:(NSRect)contentRect styleMask:(NSWindowStyleMask)style backing:(NSBackingStoreType)backingStoreType defer:(BOOL)flag screen:(NSScreen *)screen NS_UNAVAILABLE; >+ >+- (instancetype)initWithSize:(CGSize)size; >+ >+@end >+ >+#endif >diff --git a/Tools/TestWebKitAPI/mac/OffscreenWindow.mm b/Tools/TestWebKitAPI/mac/OffscreenWindow.mm >new file mode 100644 >index 0000000000000000000000000000000000000000..7a100f75e1eddb280e9c6c60eb04099a55df6602 >--- /dev/null >+++ b/Tools/TestWebKitAPI/mac/OffscreenWindow.mm >@@ -0,0 +1,57 @@ >+/* >+ * Copyright (C) 2019 Apple Inc. All rights reserved. >+ * >+ * Redistribution and use in source and binary forms, with or without >+ * modification, are permitted provided that the following conditions >+ * are met: >+ * 1. Redistributions of source code must retain the above copyright >+ * notice, this list of conditions and the following disclaimer. >+ * 2. Redistributions in binary form must reproduce the above copyright >+ * notice, this list of conditions and the following disclaimer in the >+ * documentation and/or other materials provided with the distribution. >+ * >+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' >+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, >+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR >+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS >+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR >+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF >+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS >+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN >+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) >+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF >+ * THE POSSIBILITY OF SUCH DAMAGE. >+ */ >+ >+#import "config.h" >+#import "OffscreenWindow.h" >+ >+@implementation OffscreenWindow >+ >+- (instancetype)initWithSize:(CGSize)size >+{ >+ NSRect rect = NSMakeRect(0, 0, size.width, size.height); >+ NSRect windowRect = NSOffsetRect(rect, -10000, [(NSScreen *)[[NSScreen screens] objectAtIndex:0] frame].size.height - rect.size.height + 10000); >+ self = [super initWithContentRect:windowRect styleMask:NSWindowStyleMaskBorderless backing:NSBackingStoreBuffered defer:YES]; >+ if (!self) >+ return nil; >+ >+ self.colorSpace = [[NSScreen mainScreen] colorSpace]; >+ [self orderBack:nil]; >+ self.autodisplay = NO; >+ self.releasedWhenClosed = NO; >+ >+ return self; >+} >+ >+- (BOOL)isKeyWindow >+{ >+ return YES; >+} >+ >+- (BOOL)isVisible >+{ >+ return YES; >+} >+ >+@end >diff --git a/Tools/TestWebKitAPI/mac/PlatformWebViewMac.mm b/Tools/TestWebKitAPI/mac/PlatformWebViewMac.mm >index cb1826dc69b7ba850c80df7a5a918df8803a04f5..40339de7af2eb7ea9af64a56c20bfa2ef412b0db 100644 >--- a/Tools/TestWebKitAPI/mac/PlatformWebViewMac.mm >+++ b/Tools/TestWebKitAPI/mac/PlatformWebViewMac.mm >@@ -26,25 +26,12 @@ > #import "config.h" > #import "PlatformWebView.h" > >+#import "OffscreenWindow.h" > #import <Carbon/Carbon.h> > #import <WebKit/WKRetainPtr.h> > #import <WebKit/WKViewPrivate.h> > #import <wtf/mac/AppKitCompatibilityDeclarations.h> > >-@interface ActiveOffscreenWindow : NSWindow >-@end >- >-@implementation ActiveOffscreenWindow >-- (BOOL)isKeyWindow >-{ >- return YES; >-} >-- (BOOL)isVisible >-{ >- return YES; >-} >-@end >- > namespace TestWebKitAPI { > > void PlatformWebView::initialize(WKPageConfigurationRef configuration, Class wkViewSubclass) >@@ -53,13 +40,8 @@ void PlatformWebView::initialize(WKPageConfigurationRef configuration, Class wkV > m_view = [[wkViewSubclass alloc] initWithFrame:rect configurationRef:configuration]; > [m_view setWindowOcclusionDetectionEnabled:NO]; > >- NSRect windowRect = NSOffsetRect(rect, -10000, [(NSScreen *)[[NSScreen screens] objectAtIndex:0] frame].size.height - rect.size.height + 10000); >- m_window = [[ActiveOffscreenWindow alloc] initWithContentRect:windowRect styleMask:NSWindowStyleMaskBorderless backing:NSBackingStoreBuffered defer:YES]; >- [m_window setColorSpace:[[NSScreen mainScreen] colorSpace]]; >+ m_window = [[OffscreenWindow alloc] initWithSize:NSSizeToCGSize(rect.size)]; > [[m_window contentView] addSubview:m_view]; >- [m_window orderBack:nil]; >- [m_window setAutodisplay:NO]; >- [m_window setReleasedWhenClosed:NO]; > } > > PlatformWebView::PlatformWebView(WKPageConfigurationRef configuration)
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Formatted Diff
|
Diff
Attachments on
bug 161448
:
359141
|
359181
|
359193