Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

browser(webkit): trim down mac embedder #1130

Merged
merged 1 commit into from
Feb 26, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion browser_patches/webkit/BUILD_NUMBER
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1159
1160
180 changes: 25 additions & 155 deletions browser_patches/webkit/patches/bootstrap.diff
Original file line number Diff line number Diff line change
Expand Up @@ -13661,10 +13661,10 @@ index 0000000000000000000000000000000000000000..00fb6b0006c743091a8bbf8edb18b211
+</Scheme>
diff --git a/Tools/Playwright/mac/AppDelegate.h b/Tools/Playwright/mac/AppDelegate.h
new file mode 100644
index 0000000000000000000000000000000000000000..d98c51764861371a35e78a8888bb6e81522951f4
index 0000000000000000000000000000000000000000..86e7b0c64df5fccdd66b87eecd995e0a10d57b83
--- /dev/null
+++ b/Tools/Playwright/mac/AppDelegate.h
@@ -0,0 +1,56 @@
@@ -0,0 +1,53 @@
+/*
+ * Copyright (C) 2010 Apple Inc. All rights reserved.
+ *
Expand Down Expand Up @@ -13711,9 +13711,6 @@ index 0000000000000000000000000000000000000000..d98c51764861371a35e78a8888bb6e81
+
+- (void)browserWindowWillClose:(NSWindow *)window;
+
+@property (readonly, nonatomic) WKUserContentController *userContentContoller;
+@property (readonly, nonatomic) WKPreferences *defaultPreferences;
+
+@end
+
+@interface NSApplication (PlaywrightApplicationExtensions)
Expand All @@ -13723,10 +13720,10 @@ index 0000000000000000000000000000000000000000..d98c51764861371a35e78a8888bb6e81
+@end
diff --git a/Tools/Playwright/mac/AppDelegate.m b/Tools/Playwright/mac/AppDelegate.m
new file mode 100644
index 0000000000000000000000000000000000000000..6d6c3a8c8e56e740ed37149e61f9daf58854a6c2
index 0000000000000000000000000000000000000000..f6157600282944225a1e18b4aaa3b6d34ade5be9
--- /dev/null
+++ b/Tools/Playwright/mac/AppDelegate.m
@@ -0,0 +1,492 @@
@@ -0,0 +1,398 @@
+/*
+ * Copyright (C) 2010-2016 Apple Inc. All rights reserved.
+ *
Expand Down Expand Up @@ -13768,13 +13765,6 @@ index 0000000000000000000000000000000000000000..6d6c3a8c8e56e740ed37149e61f9daf5
+#import <WebKit/_WKProcessPoolConfiguration.h>
+#import <WebKit/_WKWebsiteDataStoreConfiguration.h>
+
+enum {
+ WebKit1NewWindowTag = 1,
+ WebKit2NewWindowTag = 2,
+ WebKit1NewEditorTag = 3,
+ WebKit2NewEditorTag = 4
+};
+
+@implementation NSApplication (PlaywrightApplicationExtensions)
+
+- (BrowserAppDelegate *)browserAppDelegate
Expand Down Expand Up @@ -13922,11 +13912,6 @@ index 0000000000000000000000000000000000000000..6d6c3a8c8e56e740ed37149e61f9daf5
+ return configuration;
+}
+
+- (WKPreferences *)defaultPreferences
+{
+ return self.defaultConfiguration.preferences;
+}
+
+- (BrowserWindowController *)createBrowserWindowController:(id)sender
+{
+ if (_headless)
Expand All @@ -13939,53 +13924,20 @@ index 0000000000000000000000000000000000000000..6d6c3a8c8e56e740ed37149e61f9daf5
+ return controller;
+}
+
+- (IBAction)newWindow:(id)sender
+{
+ BrowserWindowController *controller = [self createBrowserWindowController:sender];
+ if (!controller)
+ return;
+
+ [[controller window] makeKeyAndOrderFront:sender];
+ [controller loadURLString:@"about:blank"];
+}
+
+- (IBAction)newPrivateWindow:(id)sender
+{
+ if (_headless)
+ return;
+
+ WKWebViewConfiguration *privateConfiguraton = [self.defaultConfiguration copy];
+ privateConfiguraton.websiteDataStore = [WKWebsiteDataStore nonPersistentDataStore];
+
+ BrowserWindowController *controller = [[BrowserWindowController alloc] initWithConfiguration:privateConfiguraton];
+ [privateConfiguraton release];
+
+ [[controller window] makeKeyAndOrderFront:sender];
+ [_browserWindowControllers addObject:controller];
+
+ [controller loadURLString:@"about:blank"];
+}
+
+- (void)browserWindowWillClose:(NSWindow *)window
+{
+ [_browserWindowControllers removeObject:window.windowController];
+}
+
+- (void)applicationDidFinishLaunching:(NSNotification *)aNotification
+{
+ if (_noStartupWindow) {
+ _initialURL = nil;
+ return;
+ }
+ if (!_headless)
+ [self _updateNewWindowKeyEquivalents];
+
+ if (_headless) {
+ [self createNewPage:0];
+ if (_noStartupWindow)
+ return;
+ }
+
+ [self _updateNewWindowKeyEquivalents];
+ if (!_initialURL)
+ [self newWindow:self];
+ [self createNewPage:0];
+ _initialURL = nil;
+}
+
Expand All @@ -14005,61 +13957,13 @@ index 0000000000000000000000000000000000000000..6d6c3a8c8e56e740ed37149e61f9daf5
+ return nil;
+}
+
+- (BOOL)application:(NSApplication *)theApplication openFile:(NSString *)filename
+{
+ BrowserWindowController *controller = [self createBrowserWindowController:nil];
+ if (!controller)
+ return NO;
+
+ [controller.window makeKeyAndOrderFront:self];
+ [controller loadURLString:_initialURL ? _initialURL : [NSURL fileURLWithPath:filename].absoluteString];
+ return YES;
+}
+
+- (IBAction)openDocument:(id)sender
+{
+ if (_headless)
+ return;
+
+ BrowserWindowController *browserWindowController = [self frontmostBrowserWindowController];
+
+ if (browserWindowController) {
+ NSOpenPanel *openPanel = [[NSOpenPanel openPanel] retain];
+ [openPanel beginSheetModalForWindow:browserWindowController.window completionHandler:^(NSInteger result) {
+ if (result != NSModalResponseOK)
+ return;
+
+ NSURL *url = [openPanel.URLs objectAtIndex:0];
+ [browserWindowController loadURLString:[url absoluteString]];
+ }];
+ return;
+ }
+
+ NSOpenPanel *openPanel = [NSOpenPanel openPanel];
+ [openPanel beginWithCompletionHandler:^(NSInteger result) {
+ if (result != NSModalResponseOK)
+ return;
+
+ BrowserWindowController *controller = [self createBrowserWindowController:nil];
+ [controller.window makeKeyAndOrderFront:self];
+
+ NSURL *url = [openPanel.URLs objectAtIndex:0];
+ [controller loadURLString:[url absoluteString]];
+ }];
+}
+
+- (void)_updateNewWindowKeyEquivalents
+{
+ NSString *normalWindowEquivalent = @"n";
+ _newWebKit2WindowItem.keyEquivalentModifierMask = NSEventModifierFlagCommand;
+ _newWebKit2WindowItem.keyEquivalent = normalWindowEquivalent;
+}
+
+- (WKUserContentController *)userContentContoller
+{
+ return self.defaultConfiguration.userContentController;
+}
+
+#pragma mark WKBrowserInspectorDelegate
+
+- (WKWebViewConfiguration *) sessionConfiguration:(uint64_t)sessionID
Expand All @@ -14077,20 +13981,26 @@ index 0000000000000000000000000000000000000000..6d6c3a8c8e56e740ed37149e61f9daf5
+
+- (WKWebView *)createNewPage:(uint64_t)sessionID
+{
+ NSString* urlString = _initialURL ? _initialURL : @"about:blank";
+ WKWebViewConfiguration *configuration = [self sessionConfiguration:sessionID];
+ if (_headless)
+ return [self createHeadlessPage:sessionID];
+ return [self createHeadlessPage:configuration withURL:urlString];
+ return [self createHeadfulPage:configuration withURL:urlString];
+}
+
+- (WKWebView *)createHeadfulPage:(WKWebViewConfiguration *)configuration withURL:(NSString*)urlString
+{
+
+ WKWebViewConfiguration *configuration = [self sessionConfiguration:sessionID];
+ BrowserWindowController *controller = [[[BrowserWindowController alloc] initWithConfiguration:configuration] autorelease];
+ if (!controller)
+ return nil;
+ [[controller window] makeKeyAndOrderFront:nil];
+ [_browserWindowControllers addObject:controller];
+ [controller loadURLString:@"about:blank"];
+ [controller loadURLString:urlString];
+ return [controller webView];
+}
+
+- (WKWebView *)createHeadlessWebView:(WKWebViewConfiguration *)configuration forPopup:(BOOL)popup
+- (WKWebView *)createHeadlessPage:(WKWebViewConfiguration *)configuration withURL:(NSString*)urlString
+{
+ NSRect rect = NSMakeRect(0, 0, 1024, 768);
+ NSScreen *firstScreen = [[NSScreen screens] objectAtIndex:0];
Expand All @@ -14104,22 +14014,15 @@ index 0000000000000000000000000000000000000000..6d6c3a8c8e56e740ed37149e61f9daf5
+
+ webView.autoresizingMask = NSViewWidthSizable | NSViewHeightSizable;
+ [window.contentView addSubview:webView];
+ if (!popup) {
+ NSURL *url = [NSURL _webkit_URLWithUserTypedString:_initialURL ? _initialURL : @"about:blank"];
+ _initialURL = nil;
+ [webView loadRequest:[NSURLRequest requestWithURL:url]];
+ if (urlString) {
+ NSURL *url = [NSURL _webkit_URLWithUserTypedString:urlString];
+ [webView loadRequest:[NSURLRequest requestWithURL:url]];
+ }
+ [_headlessWindows addObject:window];
+ webView.UIDelegate = self;
+ return [webView autorelease];
+}
+
+- (WKWebView *)createHeadlessPage:(uint64_t)sessionID
+{
+ WKWebViewConfiguration *configuration = [self sessionConfiguration:sessionID];
+ return [self createHeadlessWebView:configuration forPopup:NO];
+}
+
+- (_WKBrowserContext *)createBrowserContext
+{
+ _WKBrowserContext *browserContext = [[_WKBrowserContext alloc] init];
Expand Down Expand Up @@ -14215,7 +14118,7 @@ index 0000000000000000000000000000000000000000..6d6c3a8c8e56e740ed37149e61f9daf5
+
+- (nullable WKWebView *)webView:(WKWebView *)webView createWebViewWithConfiguration:(WKWebViewConfiguration *)configuration forNavigationAction:(WKNavigationAction *)navigationAction windowFeatures:(WKWindowFeatures *)windowFeatures
+{
+ return [self createHeadlessWebView:configuration forPopup:YES];
+ return [self createHeadlessPage:configuration withURL:nil];
+}
+
+@end
Expand Down Expand Up @@ -15377,10 +15280,10 @@ index 0000000000000000000000000000000000000000..4ed50c40f2f0dfd0ddf7c546b3451ab4
+</plist>
diff --git a/Tools/Playwright/mac/MainMenu.xib b/Tools/Playwright/mac/MainMenu.xib
new file mode 100644
index 0000000000000000000000000000000000000000..a291f32251271200132b8eb08d513f6936e5a0a5
index 0000000000000000000000000000000000000000..b16d639a1ad18354e058c613987d846acd70b361
--- /dev/null
+++ b/Tools/Playwright/mac/MainMenu.xib
@@ -0,0 +1,366 @@
@@ -0,0 +1,333 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="15505" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES">
+ <dependencies>
Expand Down Expand Up @@ -15453,34 +15356,6 @@ index 0000000000000000000000000000000000000000..a291f32251271200132b8eb08d513f69
+ <action selector="openLocation:" target="-1" id="575"/>
+ </connections>
+ </menuItem>
+ <menuItem title="New Window" tag="2" keyEquivalent="n" id="571">
+ <modifierMask key="keyEquivalentModifierMask" option="YES" command="YES"/>
+ <connections>
+ <action selector="newWindow:" target="-1" id="572"/>
+ </connections>
+ </menuItem>
+ <menuItem title="New Private Window" tag="2" id="Zqs-AO-XAX">
+ <modifierMask key="keyEquivalentModifierMask"/>
+ <connections>
+ <action selector="newPrivateWindow:" target="-1" id="mf5-zi-a5R"/>
+ </connections>
+ </menuItem>
+ <menuItem title="Open…" keyEquivalent="o" id="72">
+ <connections>
+ <action selector="openDocument:" target="-1" id="374"/>
+ </connections>
+ </menuItem>
+ <menuItem title="Open Recent" id="124">
+ <menu key="submenu" title="Open Recent" systemMenu="recentDocuments" id="125">
+ <items>
+ <menuItem title="Clear Menu" id="126">
+ <connections>
+ <action selector="clearRecentDocuments:" target="-1" id="127"/>
+ </connections>
+ </menuItem>
+ </items>
+ </menu>
+ </menuItem>
+ <menuItem isSeparatorItem="YES" id="79">
+ <modifierMask key="keyEquivalentModifierMask" command="YES"/>
+ </menuItem>
Expand Down Expand Up @@ -15739,12 +15614,7 @@ index 0000000000000000000000000000000000000000..a291f32251271200132b8eb08d513f69
+ </items>
+ <point key="canvasLocation" x="139" y="-50"/>
+ </menu>
+ <customObject id="494" customClass="BrowserAppDelegate">
+ <connections>
+ <outlet property="_newWebKit2WindowItem" destination="571" id="1Gv-mK-aul"/>
+ </connections>
+ </customObject>
+ <customObject id="420" customClass="NSFontManager"/>
+ <customObject id="494" customClass="BrowserAppDelegate"/>
+ </objects>
+</document>
diff --git a/Tools/Playwright/mac/Playwright_Prefix.pch b/Tools/Playwright/mac/Playwright_Prefix.pch
Expand Down