- Revision
- 266134
- Author
- [email protected]
- Date
- 2020-08-25 11:07:57 -0700 (Tue, 25 Aug 2020)
Log Message
[Mac] REGRESSION(r262322): Focusable elements are focused when exiting from video fullscreen mode.
https://bugs.webkit.org/show_bug.cgi?id=215660
<rdar://problem/65263150>
Reviewed by Darin Adler.
Source/WebKit:
API Test: Fullscreen.Focus.
The default behavior of NSWindow is to change its -keyViewSelectionDirection to NSSelectingNext when activating
and changing the firstResponder. This causes WKWebView to change it's focus in response to becoming first responder.
The cheap fix is to ensure WKWebView is already the firstResponder when the window is activated. Then NSWindow won't
try to change the firstResponder in response to activation.
* UIProcess/mac/WKFullScreenWindowController.mm:
(-[WKFullScreenWindowController beganEnterFullScreenWithInitialFrame:finalFrame:]):
Tools:
* TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj:
* TestWebKitAPI/Tests/mac/FullscreenFocus.mm: Added.
(-[FullscreenFocusUIDelegate _webViewDidEnterFullscreen:]):
(-[FullscreenFocusUIDelegate _webViewDidExitFullscreen:]):
(TestWebKitAPI::TEST):
Modified Paths
Added Paths
Diff
Modified: trunk/Source/WebKit/ChangeLog (266133 => 266134)
--- trunk/Source/WebKit/ChangeLog 2020-08-25 18:06:43 UTC (rev 266133)
+++ trunk/Source/WebKit/ChangeLog 2020-08-25 18:07:57 UTC (rev 266134)
@@ -1,3 +1,21 @@
+2020-08-25 Jer Noble <[email protected]>
+
+ [Mac] REGRESSION(r262322): Focusable elements are focused when exiting from video fullscreen mode.
+ https://bugs.webkit.org/show_bug.cgi?id=215660
+ <rdar://problem/65263150>
+
+ Reviewed by Darin Adler.
+
+ API Test: Fullscreen.Focus.
+
+ The default behavior of NSWindow is to change its -keyViewSelectionDirection to NSSelectingNext when activating
+ and changing the firstResponder. This causes WKWebView to change it's focus in response to becoming first responder.
+ The cheap fix is to ensure WKWebView is already the firstResponder when the window is activated. Then NSWindow won't
+ try to change the firstResponder in response to activation.
+
+ * UIProcess/mac/WKFullScreenWindowController.mm:
+ (-[WKFullScreenWindowController beganEnterFullScreenWithInitialFrame:finalFrame:]):
+
2020-08-25 Alex Christensen <[email protected]>
Clean up deprecated and unused SPI to set HSTS storage on ProcessPoolConfiguration
Modified: trunk/Source/WebKit/UIProcess/mac/WKFullScreenWindowController.mm (266133 => 266134)
--- trunk/Source/WebKit/UIProcess/mac/WKFullScreenWindowController.mm 2020-08-25 18:06:43 UTC (rev 266133)
+++ trunk/Source/WebKit/UIProcess/mac/WKFullScreenWindowController.mm 2020-08-25 18:07:57 UTC (rev 266134)
@@ -344,9 +344,9 @@
NSWindow* window = self.window;
NSWindowCollectionBehavior behavior = [window collectionBehavior];
[window setCollectionBehavior:(behavior | NSWindowCollectionBehaviorCanJoinAllSpaces)];
+ [window makeFirstResponder:_webView];
[window makeKeyAndOrderFront:self];
[window setCollectionBehavior:behavior];
- [window makeFirstResponder:_webView];
_page->setSuppressVisibilityUpdates(false);
ALLOW_DEPRECATED_DECLARATIONS_BEGIN
Modified: trunk/Tools/ChangeLog (266133 => 266134)
--- trunk/Tools/ChangeLog 2020-08-25 18:06:43 UTC (rev 266133)
+++ trunk/Tools/ChangeLog 2020-08-25 18:07:57 UTC (rev 266134)
@@ -1,3 +1,17 @@
+2020-08-25 Jer Noble <[email protected]>
+
+ [Mac] REGRESSION(r262322): Focusable elements are focused when exiting from video fullscreen mode.
+ https://bugs.webkit.org/show_bug.cgi?id=215660
+ <rdar://problem/65263150>
+
+ Reviewed by Darin Adler.
+
+ * TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj:
+ * TestWebKitAPI/Tests/mac/FullscreenFocus.mm: Added.
+ (-[FullscreenFocusUIDelegate _webViewDidEnterFullscreen:]):
+ (-[FullscreenFocusUIDelegate _webViewDidExitFullscreen:]):
+ (TestWebKitAPI::TEST):
+
2020-08-25 Youenn Fablet <[email protected]>
Refresh ReadableStream.pipeTo implementation up to spec
Modified: trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj (266133 => 266134)
--- trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj 2020-08-25 18:06:43 UTC (rev 266133)
+++ trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj 2020-08-25 18:07:57 UTC (rev 266134)
@@ -1008,6 +1008,7 @@
CDA3159D1ED5643F009F60D3 /* IOKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = CDA3159C1ED5643F009F60D3 /* IOKit.framework */; };
CDA4438E21F7A47700379489 /* ProcessSuspendMediaBuffering.mm in Sources */ = {isa = PBXBuildFile; fileRef = CDA4438D21F7A47700379489 /* ProcessSuspendMediaBuffering.mm */; };
CDA93DAD22F4F11E00490A69 /* FullscreenTouchSecheuristicTests.cpp in Sources */ = {isa = PBXBuildFile; fileRef = CDA93DAC22F4EC2200490A69 /* FullscreenTouchSecheuristicTests.cpp */; };
+ CDB213BD24EF522800FDE301 /* FullscreenFocus.mm in Sources */ = {isa = PBXBuildFile; fileRef = CDB213BC24EF522800FDE301 /* FullscreenFocus.mm */; };
CDB4115A1E0B00DB00EAD352 /* video-with-muted-audio.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = CDB411591E09DA8E00EAD352 /* video-with-muted-audio.html */; };
CDB5DFFF213610FA00D3E189 /* now-playing.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = CDB5DFFE21360ED800D3E189 /* now-playing.html */; };
CDBFCC451A9FF45300A7B691 /* FullscreenZoomInitialFrame.mm in Sources */ = {isa = PBXBuildFile; fileRef = CDBFCC431A9FF44800A7B691 /* FullscreenZoomInitialFrame.mm */; };
@@ -2696,6 +2697,7 @@
CDA3159C1ED5643F009F60D3 /* IOKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = IOKit.framework; path = System/Library/Frameworks/IOKit.framework; sourceTree = SDKROOT; };
CDA4438D21F7A47700379489 /* ProcessSuspendMediaBuffering.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = ProcessSuspendMediaBuffering.mm; sourceTree = "<group>"; };
CDA93DAC22F4EC2200490A69 /* FullscreenTouchSecheuristicTests.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = FullscreenTouchSecheuristicTests.cpp; sourceTree = "<group>"; };
+ CDB213BC24EF522800FDE301 /* FullscreenFocus.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = FullscreenFocus.mm; sourceTree = "<group>"; };
CDB411591E09DA8E00EAD352 /* video-with-muted-audio.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = "video-with-muted-audio.html"; sourceTree = "<group>"; };
CDB5DFFE21360ED800D3E189 /* now-playing.html */ = {isa = PBXFileReference; lastKnownFileType = text.html; path = "now-playing.html"; sourceTree = "<group>"; };
CDBFCC421A9FF44800A7B691 /* FullscreenZoomInitialFrame.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = FullscreenZoomInitialFrame.html; sourceTree = "<group>"; };
@@ -4401,6 +4403,7 @@
F456AB1B213EDBA300CB2CEF /* FontManagerTests.mm */,
1A7E8B33181208DE00AEB74A /* FragmentNavigation.mm */,
CDBFCC431A9FF44800A7B691 /* FullscreenZoomInitialFrame.mm */,
+ CDB213BC24EF522800FDE301 /* FullscreenFocus.mm */,
51EB125824C68589000CB030 /* HIDGamepads.mm */,
9B4F8FA3159D52B1002D9F94 /* HTMLCollectionNamedItem.mm */,
9B26FC6B159D061000CC3765 /* HTMLFormCollectionNamedItem.mm */,
@@ -5051,6 +5054,7 @@
46A911592108E6780078D40D /* CustomUserAgent.mm in Sources */,
751B05D61F8EAC410028A09E /* DatabaseTrackerTest.mm in Sources */,
2DC4CF771D2D9DD800ECCC94 /* DataDetection.mm in Sources */,
+ CDB213BD24EF522800FDE301 /* FullscreenFocus.mm in Sources */,
44077BB123144B5000179E2D /* DataDetectorsTestIOS.mm in Sources */,
9BAD7F3E22690F2000F8DA66 /* DeallocWebViewInEventListener.mm in Sources */,
518EE51D20A78D3600E024F3 /* DecidePolicyForNavigationAction.mm in Sources */,
Added: trunk/Tools/TestWebKitAPI/Tests/mac/FullscreenFocus.mm (0 => 266134)
--- trunk/Tools/TestWebKitAPI/Tests/mac/FullscreenFocus.mm (rev 0)
+++ trunk/Tools/TestWebKitAPI/Tests/mac/FullscreenFocus.mm 2020-08-25 18:07:57 UTC (rev 266134)
@@ -0,0 +1,90 @@
+/*
+ * Copyright (C) 2020 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"
+
+#if PLATFORM(MAC)
+
+#import "TestCocoa.h"
+#import "TestWKWebView.h"
+#import <WebKit/WKPreferencesPrivate.h>
+#import <WebKit/WKWebViewPrivate.h>
+#import <WebKit/_WKFullscreenDelegate.h>
+#import <wtf/RetainPtr.h>
+
+static bool didEnterFullscreen;
+static bool didExitFullscreen;
+
+@interface FullscreenFocusUIDelegate : NSObject <_WKFullscreenDelegate>
+@end
+
+@implementation FullscreenFocusUIDelegate
+
+- (void)_webViewDidEnterFullscreen:(WKWebView *)webView
+{
+ didEnterFullscreen = true;
+}
+
+- (void)_webViewDidExitFullscreen:(WKWebView *)webView
+{
+ didExitFullscreen = true;
+}
+@end
+
+namespace TestWebKitAPI {
+
+TEST(Fullscreen, Focus)
+{
+ auto configuration = adoptNS([[WKWebViewConfiguration alloc] init]);
+ [configuration preferences]._fullScreenEnabled = YES;
+ auto webView = adoptNS([[TestWKWebView alloc] initWithFrame:NSMakeRect(0, 0, 300, 300) configuration:configuration.get() addToWindow:YES]);
+ auto handler = adoptNS([[FullscreenFocusUIDelegate alloc] init]);
+ [webView _setFullscreenDelegate:handler.get()];
+
+ bool canplaythrough = false;
+ [webView performAfterReceivingMessage:@"canplaythrough" action:[&] { canplaythrough = true; }];
+ [webView synchronouslyLoadHTMLString:
+ @"<video id=\"one\" controls></video><video id=\"two\" controls></video>"
+ @"<script>"
+ @"one.addEventListener('canplaythrough', event => { window.webkit.messageHandlers.testHandler.postMessage('canplaythrough'); }, {once:true});"
+ @"one.src = "" = '';"
+ @"</script>"];
+
+ Util::run(&canplaythrough);
+
+ didEnterFullscreen = false;
+ [webView objectByEvaluatingJavaScriptWithUserGesture:@"one.webkitEnterFullscreen()"];
+ Util::run(&didEnterFullscreen);
+
+ didExitFullscreen = false;
+ [webView objectByEvaluatingJavaScript:@"one.webkitExitFullscreen()"];
+ Util::run(&didExitFullscreen);
+
+ EXPECT_WK_STREQ("[object HTMLBodyElement]", [webView stringByEvaluatingJavaScript:@"String(document.activeElement)"]);
+}
+
+}
+
+#endif