From 2b33f768258f41432ba2d3889858a06bd1dd5997 Mon Sep 17 00:00:00 2001 From: Andrey Lushnikov Date: Thu, 9 Jun 2022 06:51:33 -0700 Subject: [PATCH] browser(webkit): support larger-than-screen window in headed WebKit (#14578) --- browser_patches/webkit/BUILD_NUMBER | 4 ++-- .../embedder/Playwright/mac/BrowserWindow.xib | 2 +- .../Playwright/mac/BrowserWindowController.h | 6 ++++++ .../Playwright/mac/BrowserWindowController.m | 12 +++++++++++ browser_patches/webkit/patches/bootstrap.diff | 20 +++++++++---------- 5 files changed, 31 insertions(+), 13 deletions(-) diff --git a/browser_patches/webkit/BUILD_NUMBER b/browser_patches/webkit/BUILD_NUMBER index 9771e1f17d..8e546aba02 100644 --- a/browser_patches/webkit/BUILD_NUMBER +++ b/browser_patches/webkit/BUILD_NUMBER @@ -1,2 +1,2 @@ -1659 -Changed: max@schmitt.mx Wed Jun 8 15:20:52 UTC 2022 +1660 +Changed: lushnikov@chromium.org Thu Jun 9 16:49:27 +03 2022 diff --git a/browser_patches/webkit/embedder/Playwright/mac/BrowserWindow.xib b/browser_patches/webkit/embedder/Playwright/mac/BrowserWindow.xib index a7cee4bcc4..3789c399d4 100644 --- a/browser_patches/webkit/embedder/Playwright/mac/BrowserWindow.xib +++ b/browser_patches/webkit/embedder/Playwright/mac/BrowserWindow.xib @@ -22,7 +22,7 @@ - + diff --git a/browser_patches/webkit/embedder/Playwright/mac/BrowserWindowController.h b/browser_patches/webkit/embedder/Playwright/mac/BrowserWindowController.h index ff9779c52a..dd9ff40910 100644 --- a/browser_patches/webkit/embedder/Playwright/mac/BrowserWindowController.h +++ b/browser_patches/webkit/embedder/Playwright/mac/BrowserWindowController.h @@ -25,6 +25,12 @@ @class WKWebView; +@interface CustomWindow : NSWindow + +- (NSRect)constrainFrameRect:(NSRect)frameRect toScreen:(NSScreen *)screen; + +@end + @interface BrowserWindowController : NSWindowController - (IBAction)goBack:(id)sender; diff --git a/browser_patches/webkit/embedder/Playwright/mac/BrowserWindowController.m b/browser_patches/webkit/embedder/Playwright/mac/BrowserWindowController.m index 6996296050..365920d2fb 100644 --- a/browser_patches/webkit/embedder/Playwright/mac/BrowserWindowController.m +++ b/browser_patches/webkit/embedder/Playwright/mac/BrowserWindowController.m @@ -63,6 +63,18 @@ static void* keyValueObservingContext = &keyValueObservingContext; @end +@implementation CustomWindow + +- (NSRect)constrainFrameRect:(NSRect)frameRect toScreen:(NSScreen *)screen +{ + // Retain the frame size, but make sure that + // the top of the window is always visible. + CGFloat yPos = NSHeight(self.screen.frame) - 100 - NSHeight(self.frame); + return NSMakeRect(frameRect.origin.x, yPos, frameRect.size.width, frameRect.size.height); +} + +@end + @interface BrowserWindowController () @end diff --git a/browser_patches/webkit/patches/bootstrap.diff b/browser_patches/webkit/patches/bootstrap.diff index 4ca5bd0fe9..2c38a47d37 100644 --- a/browser_patches/webkit/patches/bootstrap.diff +++ b/browser_patches/webkit/patches/bootstrap.diff @@ -2238,7 +2238,7 @@ diff --git a/Source/WebCore/Modules/speech/cocoa/WebSpeechRecognizerTask.mm b/So index a941d76a4f748718df1e3cff2a6c5e0827f48891..f62db5a27ac0e4c12430e7d19e60c83d768ace22 100644 --- a/Source/WebCore/Modules/speech/cocoa/WebSpeechRecognizerTask.mm +++ b/Source/WebCore/Modules/speech/cocoa/WebSpeechRecognizerTask.mm -@@ -198,6 +198,7 @@ - (void)sendEndIfNeeded +@@ -198,6 +198,7 @@ NS_ASSUME_NONNULL_BEGIN - (void)speechRecognizer:(SFSpeechRecognizer *)speechRecognizer availabilityDidChange:(BOOL)available { @@ -2246,7 +2246,7 @@ index a941d76a4f748718df1e3cff2a6c5e0827f48891..f62db5a27ac0e4c12430e7d19e60c83d ASSERT(isMainThread()); if (available || !_task) -@@ -211,6 +212,7 @@ - (void)speechRecognizer:(SFSpeechRecognizer *)speechRecognizer availabilityDidC +@@ -211,6 +212,7 @@ NS_ASSUME_NONNULL_BEGIN - (void)speechRecognitionTask:(SFSpeechRecognitionTask *)task didHypothesizeTranscription:(SFTranscription *)transcription { @@ -2254,7 +2254,7 @@ index a941d76a4f748718df1e3cff2a6c5e0827f48891..f62db5a27ac0e4c12430e7d19e60c83d ASSERT(isMainThread()); [self sendSpeechStartIfNeeded]; -@@ -219,6 +221,7 @@ - (void)speechRecognitionTask:(SFSpeechRecognitionTask *)task didHypothesizeTran +@@ -219,6 +221,7 @@ NS_ASSUME_NONNULL_BEGIN - (void)speechRecognitionTask:(SFSpeechRecognitionTask *)task didFinishRecognition:(SFSpeechRecognitionResult *)recognitionResult { @@ -2262,7 +2262,7 @@ index a941d76a4f748718df1e3cff2a6c5e0827f48891..f62db5a27ac0e4c12430e7d19e60c83d ASSERT(isMainThread()); [self callbackWithTranscriptions:recognitionResult.transcriptions isFinal:YES]; -@@ -230,6 +233,7 @@ - (void)speechRecognitionTask:(SFSpeechRecognitionTask *)task didFinishRecogniti +@@ -230,6 +233,7 @@ NS_ASSUME_NONNULL_BEGIN - (void)speechRecognitionTaskWasCancelled:(SFSpeechRecognitionTask *)task { @@ -8868,7 +8868,7 @@ diff --git a/Source/WebKit/NetworkProcess/cocoa/NetworkSessionCocoa.mm b/Source/ index 1d9c725383fa4ad497de378783e519b98451fb20..44fd5f3b958f8a7bd85b8657fff5bac058a86a69 100644 --- a/Source/WebKit/NetworkProcess/cocoa/NetworkSessionCocoa.mm +++ b/Source/WebKit/NetworkProcess/cocoa/NetworkSessionCocoa.mm -@@ -723,7 +723,7 @@ - (void)URLSession:(NSURLSession *)session task:(NSURLSessionTask *)task didRece +@@ -723,7 +723,7 @@ void NetworkSessionCocoa::setClientAuditToken(const WebCore::AuthenticationChall if ([challenge.protectionSpace.authenticationMethod isEqualToString:NSURLAuthenticationMethodServerTrust]) { sessionCocoa->setClientAuditToken(challenge); @@ -10291,7 +10291,7 @@ index b8bf936e2eb8ca4dc0f445099dfb899395950bdb..30a2af76de0daac450c7afbb8a2dfe81 #import #import #import -@@ -234,6 +235,11 @@ - (void)removeDataOfTypes:(NSSet *)dataTypes modifiedSince:(NSDate *)date comple +@@ -234,6 +235,11 @@ static WallTime toSystemClockTime(NSDate *date) }); } @@ -10470,7 +10470,7 @@ diff --git a/Source/WebKit/UIProcess/API/Cocoa/_WKProcessPoolConfiguration.mm b/ index 2e235bb880c638a0e74256b6d66cb0244ea0a3f1..3471eebb47e860f7c2071d0e7f2691c9f0a6355d 100644 --- a/Source/WebKit/UIProcess/API/Cocoa/_WKProcessPoolConfiguration.mm +++ b/Source/WebKit/UIProcess/API/Cocoa/_WKProcessPoolConfiguration.mm -@@ -257,6 +257,16 @@ - (BOOL)processSwapsOnNavigation +@@ -257,6 +257,16 @@ return _processPoolConfiguration->processSwapsOnNavigation(); } @@ -20721,7 +20721,7 @@ diff --git a/Source/WebKitLegacy/mac/WebView/WebHTMLView.mm b/Source/WebKitLegac index 725c6714b8f75365ba4cdb969df1bd1bbe4c69c1..562571835a5740c5df06e1bad8b6ce9077bf7d66 100644 --- a/Source/WebKitLegacy/mac/WebView/WebHTMLView.mm +++ b/Source/WebKitLegacy/mac/WebView/WebHTMLView.mm -@@ -4189,7 +4189,7 @@ - (void)mouseDown:(WebEvent *)event +@@ -4189,7 +4189,7 @@ static BOOL currentScrollIsBlit(NSView *clipView) _private->handlingMouseDownEvent = NO; } @@ -20734,7 +20734,7 @@ diff --git a/Source/WebKitLegacy/mac/WebView/WebView.mm b/Source/WebKitLegacy/ma index 59cecf9242ab834dadc904ef295365e1476f47f9..ca4cc96e62df62e92c22c3535f5972cc1fdc4cba 100644 --- a/Source/WebKitLegacy/mac/WebView/WebView.mm +++ b/Source/WebKitLegacy/mac/WebView/WebView.mm -@@ -4039,7 +4039,7 @@ + (void)_doNotStartObservingNetworkReachability +@@ -4039,7 +4039,7 @@ IGNORE_WARNINGS_END } #endif // PLATFORM(IOS_FAMILY) @@ -20743,7 +20743,7 @@ index 59cecf9242ab834dadc904ef295365e1476f47f9..ca4cc96e62df62e92c22c3535f5972cc - (NSArray *)_touchEventRegions { -@@ -4081,7 +4081,7 @@ - (NSArray *)_touchEventRegions +@@ -4081,7 +4081,7 @@ IGNORE_WARNINGS_END }).autorelease(); }