Skip to content

Commit aa2ecde

Browse files
dgozmanpavelfeldman
authored andcommitted
browser(webkit): make popups functional in mac embedder (#689)
1 parent ee9c2b0 commit aa2ecde

File tree

2 files changed

+22
-28
lines changed

2 files changed

+22
-28
lines changed

browser_patches/webkit/BUILD_NUMBER

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
1116
1+
1117

browser_patches/webkit/patches/bootstrap.diff

Lines changed: 21 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -13089,10 +13089,10 @@ index 0000000000000000000000000000000000000000..41b5751cab626971cd12c5066218c6d1
1308913089
+@end
1309013090
diff --git a/Tools/Playwright/mac/AppDelegate.m b/Tools/Playwright/mac/AppDelegate.m
1309113091
new file mode 100644
13092-
index 0000000000000000000000000000000000000000..84e0cd9c2d20111e936e4b16519d20bcd5aa37db
13092+
index 0000000000000000000000000000000000000000..828d172381e12ea0455045fdc098dfa7726ae040
1309313093
--- /dev/null
1309413094
+++ b/Tools/Playwright/mac/AppDelegate.m
13095-
@@ -0,0 +1,486 @@
13095+
@@ -0,0 +1,488 @@
1309613096
+/*
1309713097
+ * Copyright (C) 2010-2016 Apple Inc. All rights reserved.
1309813098
+ *
@@ -13453,7 +13453,7 @@ index 0000000000000000000000000000000000000000..84e0cd9c2d20111e936e4b16519d20bc
1345313453
+ return [controller webView];
1345413454
+}
1345513455
+
13456-
+- (WKWebView *)createHeadlessWebView:(WKWebViewConfiguration *)configuration
13456+
+- (WKWebView *)createHeadlessWebView:(WKWebViewConfiguration *)configuration forPopup:(BOOL)popup
1345713457
+{
1345813458
+ NSRect rect = NSMakeRect(0, 0, 1024, 768);
1345913459
+ NSScreen *firstScreen = [[NSScreen screens] objectAtIndex:0];
@@ -13467,9 +13467,11 @@ index 0000000000000000000000000000000000000000..84e0cd9c2d20111e936e4b16519d20bc
1346713467
+
1346813468
+ webView.autoresizingMask = NSViewWidthSizable | NSViewHeightSizable;
1346913469
+ [window.contentView addSubview:webView];
13470-
+ NSURL *url = [NSURL _webkit_URLWithUserTypedString:_initialURL ? _initialURL : @"about:blank"];
13471-
+ _initialURL = nil;
13472-
+ [webView loadRequest:[NSURLRequest requestWithURL:url]];
13470+
+ if (!popup) {
13471+
+ NSURL *url = [NSURL _webkit_URLWithUserTypedString:_initialURL ? _initialURL : @"about:blank"];
13472+
+ _initialURL = nil;
13473+
+ [webView loadRequest:[NSURLRequest requestWithURL:url]];
13474+
+ }
1347313475
+ [_headlessWindows addObject:window];
1347413476
+ webView.UIDelegate = self;
1347513477
+ return [webView autorelease];
@@ -13478,7 +13480,7 @@ index 0000000000000000000000000000000000000000..84e0cd9c2d20111e936e4b16519d20bc
1347813480
+- (WKWebView *)createHeadlessPage:(uint64_t)sessionID
1347913481
+{
1348013482
+ WKWebViewConfiguration *configuration = [self sessionConfiguration:sessionID];
13481-
+ return [self createHeadlessWebView:configuration];
13483+
+ return [self createHeadlessWebView:configuration forPopup:NO];
1348213484
+}
1348313485
+
1348413486
+- (_WKBrowserContext *)createBrowserContext
@@ -13575,7 +13577,7 @@ index 0000000000000000000000000000000000000000..84e0cd9c2d20111e936e4b16519d20bc
1357513577
+
1357613578
+- (nullable WKWebView *)webView:(WKWebView *)webView createWebViewWithConfiguration:(WKWebViewConfiguration *)configuration forNavigationAction:(WKNavigationAction *)navigationAction windowFeatures:(WKWindowFeatures *)windowFeatures
1357713579
+{
13578-
+ return [self createHeadlessWebView:configuration];
13580+
+ return [self createHeadlessWebView:configuration forPopup:YES];
1357913581
+}
1358013582
+
1358113583
+@end
@@ -13792,10 +13794,10 @@ index 0000000000000000000000000000000000000000..4dbf13c8fb31a745ae8e1965a457d4fb
1379213794
+@end
1379313795
diff --git a/Tools/Playwright/mac/BrowserWindowController.m b/Tools/Playwright/mac/BrowserWindowController.m
1379413796
new file mode 100644
13795-
index 0000000000000000000000000000000000000000..7a745879d076017df30afd77ded881ddbc19bb45
13797+
index 0000000000000000000000000000000000000000..033c4fcda83002cda5d069205d4f605d02f1e1f5
1379613798
--- /dev/null
1379713799
+++ b/Tools/Playwright/mac/BrowserWindowController.m
13798-
@@ -0,0 +1,834 @@
13800+
@@ -0,0 +1,826 @@
1379913801
+/*
1380013802
+ * Copyright (C) 2010-2016 Apple Inc. All rights reserved.
1380113803
+ *
@@ -13946,8 +13948,6 @@ index 0000000000000000000000000000000000000000..7a745879d076017df30afd77ded881dd
1394613948
+
1394713949
+- (void)awakeFromNib
1394813950
+{
13949-
+ self.window.styleMask &= ~NSWindowStyleMaskFullSizeContentView;
13950-
+
1395113951
+ _webView = [[WKWebView alloc] initWithFrame:[containerView bounds] configuration:_configuration];
1395213952
+ _webView._windowOcclusionDetectionEnabled = NO;
1395313953
+
@@ -13994,13 +13994,14 @@ index 0000000000000000000000000000000000000000..7a745879d076017df30afd77ded881dd
1399413994
+ return nil;
1399513995
+ _configuration = [configuration copy];
1399613996
+ _isPrivateBrowsingWindow = !_configuration.websiteDataStore.isPersistent;
13997+
+ self.window.styleMask &= ~NSWindowStyleMaskFullSizeContentView;
1399713998
+ return self;
1399813999
+}
1399914000
+
1400014001
+- (void)dealloc
1400114002
+{
1400214003
+ [[NSNotificationCenter defaultCenter] removeObserver:self];
14003-
+
14004+
+
1400414005
+ [progressIndicator unbind:NSHiddenBinding];
1400514006
+ [progressIndicator unbind:NSValueBinding];
1400614007
+
@@ -14079,7 +14080,7 @@ index 0000000000000000000000000000000000000000..7a745879d076017df30afd77ded881dd
1407914080
+ return [self canZoomOut];
1408014081
+ if (action == @selector(resetZoom:))
1408114082
+ return [self canResetZoom];
14082-
+
14083+
+
1408314084
+ if (action == @selector(toggleZoomMode:))
1408414085
+ [menuItem setState:_zoomTextOnly ? NSControlStateValueOn : NSControlStateValueOff];
1408514086
+ else if (action == @selector(showHideWebInspector:))
@@ -14258,7 +14259,6 @@ index 0000000000000000000000000000000000000000..7a745879d076017df30afd77ded881dd
1425814259
+- (nullable WKWebView *)webView:(WKWebView *)webView createWebViewWithConfiguration:(WKWebViewConfiguration *)configuration forNavigationAction:(WKNavigationAction *)navigationAction windowFeatures:(WKWindowFeatures *)windowFeatures
1425914260
+{
1426014261
+ BrowserWindowController *controller = [[BrowserWindowController alloc] initWithConfiguration:configuration];
14261-
+ [controller awakeFromNib];
1426214262
+ [controller.window makeKeyAndOrderFront:self];
1426314263
+
1426414264
+ return controller->_webView;
@@ -14286,7 +14286,7 @@ index 0000000000000000000000000000000000000000..7a745879d076017df30afd77ded881dd
1428614286
+
1428714287
+ [alert setMessageText:[NSString stringWithFormat:@"JavaScript confirm dialog from %@.", [frame.request.URL absoluteString]]];
1428814288
+ [alert setInformativeText:message];
14289-
+
14289+
+
1429014290
+ [alert addButtonWithTitle:@"OK"];
1429114291
+ [alert addButtonWithTitle:@"Cancel"];
1429214292
+
@@ -14304,14 +14304,14 @@ index 0000000000000000000000000000000000000000..7a745879d076017df30afd77ded881dd
1430414304
+
1430514305
+ [alert setMessageText:[NSString stringWithFormat:@"JavaScript prompt dialog from %@.", [frame.request.URL absoluteString]]];
1430614306
+ [alert setInformativeText:prompt];
14307-
+
14307+
+
1430814308
+ [alert addButtonWithTitle:@"OK"];
1430914309
+ [alert addButtonWithTitle:@"Cancel"];
14310-
+
14310+
+
1431114311
+ NSTextField* input = [[NSTextField alloc] initWithFrame:NSMakeRect(0, 0, 200, 24)];
1431214312
+ [input setStringValue:defaultText];
1431314313
+ [alert setAccessoryView:input];
14314-
+
14314+
+
1431514315
+ _alert = alert;
1431614316
+ [alert beginSheetModalForWindow:self.window completionHandler:^void (NSModalResponse response) {
1431714317
+ [input validateEditing];
@@ -14438,12 +14438,6 @@ index 0000000000000000000000000000000000000000..7a745879d076017df30afd77ded881dd
1443814438
+ decisionHandler(WKNavigationActionPolicyAllow);
1443914439
+ return;
1444014440
+ }
14441-
+
14442-
+ if (navigationAction._userInitiatedAction && !navigationAction._userInitiatedAction.isConsumed) {
14443-
+ [navigationAction._userInitiatedAction consume];
14444-
+ [[NSWorkspace sharedWorkspace] openURL:navigationAction.request.URL];
14445-
+ }
14446-
+
1444714441
+ decisionHandler(WKNavigationActionPolicyCancel);
1444814442
+}
1444914443
+
@@ -14487,7 +14481,7 @@ index 0000000000000000000000000000000000000000..7a745879d076017df30afd77ded881dd
1448714481
+ NSView *container = [[[NSView alloc] initWithFrame:NSMakeRect(0, 0, 200, 48)] autorelease];
1448814482
+ NSTextField *userInput = [[[NSTextField alloc] initWithFrame:NSMakeRect(0, 24, 200, 24)] autorelease];
1448914483
+ NSTextField *passwordInput = [[[NSSecureTextField alloc] initWithFrame:NSMakeRect(0, 0, 200, 24)] autorelease];
14490-
+
14484+
+
1449114485
+ [alert setMessageText:[NSString stringWithFormat:@"Log in to %@:%lu.", challenge.protectionSpace.host, challenge.protectionSpace.port]];
1449214486
+ [alert addButtonWithTitle:@"Log in"];
1449314487
+ [alert addButtonWithTitle:@"Cancel"];
@@ -14496,7 +14490,7 @@ index 0000000000000000000000000000000000000000..7a745879d076017df30afd77ded881dd
1449614490
+ [alert setAccessoryView:container];
1449714491
+ [userInput setNextKeyView:passwordInput];
1449814492
+ [alert.window setInitialFirstResponder:userInput];
14499-
+
14493+
+
1450014494
+ [alert beginSheetModalForWindow:self.window completionHandler:^(NSModalResponse response) {
1450114495
+ [userInput validateEditing];
1450214496
+ if (response == NSAlertFirstButtonReturn)

0 commit comments

Comments
 (0)