browser(webkit): make popups functional in mac embedder (#689)

This commit is contained in:
Dmitry Gozman 2020-01-27 15:41:01 -08:00 committed by Pavel Feldman
parent ee9c2b0c41
commit aa2ecde20f
2 changed files with 22 additions and 28 deletions

View file

@ -1 +1 @@
1116 1117

View file

@ -13089,10 +13089,10 @@ index 0000000000000000000000000000000000000000..41b5751cab626971cd12c5066218c6d1
+@end +@end
diff --git a/Tools/Playwright/mac/AppDelegate.m b/Tools/Playwright/mac/AppDelegate.m diff --git a/Tools/Playwright/mac/AppDelegate.m b/Tools/Playwright/mac/AppDelegate.m
new file mode 100644 new file mode 100644
index 0000000000000000000000000000000000000000..84e0cd9c2d20111e936e4b16519d20bcd5aa37db index 0000000000000000000000000000000000000000..828d172381e12ea0455045fdc098dfa7726ae040
--- /dev/null --- /dev/null
+++ b/Tools/Playwright/mac/AppDelegate.m +++ b/Tools/Playwright/mac/AppDelegate.m
@@ -0,0 +1,486 @@ @@ -0,0 +1,488 @@
+/* +/*
+ * Copyright (C) 2010-2016 Apple Inc. All rights reserved. + * Copyright (C) 2010-2016 Apple Inc. All rights reserved.
+ * + *
@ -13453,7 +13453,7 @@ index 0000000000000000000000000000000000000000..84e0cd9c2d20111e936e4b16519d20bc
+ return [controller webView]; + return [controller webView];
+} +}
+ +
+- (WKWebView *)createHeadlessWebView:(WKWebViewConfiguration *)configuration +- (WKWebView *)createHeadlessWebView:(WKWebViewConfiguration *)configuration forPopup:(BOOL)popup
+{ +{
+ NSRect rect = NSMakeRect(0, 0, 1024, 768); + NSRect rect = NSMakeRect(0, 0, 1024, 768);
+ NSScreen *firstScreen = [[NSScreen screens] objectAtIndex:0]; + NSScreen *firstScreen = [[NSScreen screens] objectAtIndex:0];
@ -13467,9 +13467,11 @@ index 0000000000000000000000000000000000000000..84e0cd9c2d20111e936e4b16519d20bc
+ +
+ webView.autoresizingMask = NSViewWidthSizable | NSViewHeightSizable; + webView.autoresizingMask = NSViewWidthSizable | NSViewHeightSizable;
+ [window.contentView addSubview:webView]; + [window.contentView addSubview:webView];
+ NSURL *url = [NSURL _webkit_URLWithUserTypedString:_initialURL ? _initialURL : @"about:blank"]; + if (!popup) {
+ _initialURL = nil; + NSURL *url = [NSURL _webkit_URLWithUserTypedString:_initialURL ? _initialURL : @"about:blank"];
+ [webView loadRequest:[NSURLRequest requestWithURL:url]]; + _initialURL = nil;
+ [webView loadRequest:[NSURLRequest requestWithURL:url]];
+ }
+ [_headlessWindows addObject:window]; + [_headlessWindows addObject:window];
+ webView.UIDelegate = self; + webView.UIDelegate = self;
+ return [webView autorelease]; + return [webView autorelease];
@ -13478,7 +13480,7 @@ index 0000000000000000000000000000000000000000..84e0cd9c2d20111e936e4b16519d20bc
+- (WKWebView *)createHeadlessPage:(uint64_t)sessionID +- (WKWebView *)createHeadlessPage:(uint64_t)sessionID
+{ +{
+ WKWebViewConfiguration *configuration = [self sessionConfiguration:sessionID]; + WKWebViewConfiguration *configuration = [self sessionConfiguration:sessionID];
+ return [self createHeadlessWebView:configuration]; + return [self createHeadlessWebView:configuration forPopup:NO];
+} +}
+ +
+- (_WKBrowserContext *)createBrowserContext +- (_WKBrowserContext *)createBrowserContext
@ -13575,7 +13577,7 @@ index 0000000000000000000000000000000000000000..84e0cd9c2d20111e936e4b16519d20bc
+ +
+- (nullable WKWebView *)webView:(WKWebView *)webView createWebViewWithConfiguration:(WKWebViewConfiguration *)configuration forNavigationAction:(WKNavigationAction *)navigationAction windowFeatures:(WKWindowFeatures *)windowFeatures +- (nullable WKWebView *)webView:(WKWebView *)webView createWebViewWithConfiguration:(WKWebViewConfiguration *)configuration forNavigationAction:(WKNavigationAction *)navigationAction windowFeatures:(WKWindowFeatures *)windowFeatures
+{ +{
+ return [self createHeadlessWebView:configuration]; + return [self createHeadlessWebView:configuration forPopup:YES];
+} +}
+ +
+@end +@end
@ -13792,10 +13794,10 @@ index 0000000000000000000000000000000000000000..4dbf13c8fb31a745ae8e1965a457d4fb
+@end +@end
diff --git a/Tools/Playwright/mac/BrowserWindowController.m b/Tools/Playwright/mac/BrowserWindowController.m diff --git a/Tools/Playwright/mac/BrowserWindowController.m b/Tools/Playwright/mac/BrowserWindowController.m
new file mode 100644 new file mode 100644
index 0000000000000000000000000000000000000000..7a745879d076017df30afd77ded881ddbc19bb45 index 0000000000000000000000000000000000000000..033c4fcda83002cda5d069205d4f605d02f1e1f5
--- /dev/null --- /dev/null
+++ b/Tools/Playwright/mac/BrowserWindowController.m +++ b/Tools/Playwright/mac/BrowserWindowController.m
@@ -0,0 +1,834 @@ @@ -0,0 +1,826 @@
+/* +/*
+ * Copyright (C) 2010-2016 Apple Inc. All rights reserved. + * Copyright (C) 2010-2016 Apple Inc. All rights reserved.
+ * + *
@ -13946,8 +13948,6 @@ index 0000000000000000000000000000000000000000..7a745879d076017df30afd77ded881dd
+ +
+- (void)awakeFromNib +- (void)awakeFromNib
+{ +{
+ self.window.styleMask &= ~NSWindowStyleMaskFullSizeContentView;
+
+ _webView = [[WKWebView alloc] initWithFrame:[containerView bounds] configuration:_configuration]; + _webView = [[WKWebView alloc] initWithFrame:[containerView bounds] configuration:_configuration];
+ _webView._windowOcclusionDetectionEnabled = NO; + _webView._windowOcclusionDetectionEnabled = NO;
+ +
@ -13994,6 +13994,7 @@ index 0000000000000000000000000000000000000000..7a745879d076017df30afd77ded881dd
+ return nil; + return nil;
+ _configuration = [configuration copy]; + _configuration = [configuration copy];
+ _isPrivateBrowsingWindow = !_configuration.websiteDataStore.isPersistent; + _isPrivateBrowsingWindow = !_configuration.websiteDataStore.isPersistent;
+ self.window.styleMask &= ~NSWindowStyleMaskFullSizeContentView;
+ return self; + return self;
+} +}
+ +
@ -14258,7 +14259,6 @@ index 0000000000000000000000000000000000000000..7a745879d076017df30afd77ded881dd
+- (nullable WKWebView *)webView:(WKWebView *)webView createWebViewWithConfiguration:(WKWebViewConfiguration *)configuration forNavigationAction:(WKNavigationAction *)navigationAction windowFeatures:(WKWindowFeatures *)windowFeatures +- (nullable WKWebView *)webView:(WKWebView *)webView createWebViewWithConfiguration:(WKWebViewConfiguration *)configuration forNavigationAction:(WKNavigationAction *)navigationAction windowFeatures:(WKWindowFeatures *)windowFeatures
+{ +{
+ BrowserWindowController *controller = [[BrowserWindowController alloc] initWithConfiguration:configuration]; + BrowserWindowController *controller = [[BrowserWindowController alloc] initWithConfiguration:configuration];
+ [controller awakeFromNib];
+ [controller.window makeKeyAndOrderFront:self]; + [controller.window makeKeyAndOrderFront:self];
+ +
+ return controller->_webView; + return controller->_webView;
@ -14438,12 +14438,6 @@ index 0000000000000000000000000000000000000000..7a745879d076017df30afd77ded881dd
+ decisionHandler(WKNavigationActionPolicyAllow); + decisionHandler(WKNavigationActionPolicyAllow);
+ return; + return;
+ } + }
+
+ if (navigationAction._userInitiatedAction && !navigationAction._userInitiatedAction.isConsumed) {
+ [navigationAction._userInitiatedAction consume];
+ [[NSWorkspace sharedWorkspace] openURL:navigationAction.request.URL];
+ }
+
+ decisionHandler(WKNavigationActionPolicyCancel); + decisionHandler(WKNavigationActionPolicyCancel);
+} +}
+ +