Skip to content

Commit

Permalink
Enable ARC for MiniBrowser
Browse files Browse the repository at this point in the history
https://bugs.webkit.org/show_bug.cgi?id=247354

Reviewed by Aditya Keerthi.

* Tools/MiniBrowser/Configurations/Base.xcconfig:
* Tools/MiniBrowser/mac/AppDelegate.m:
(-[BrowserAppDelegate awakeFromNib]):
(persistentDataStore):
(-[BrowserAppDelegate defaultConfiguration]):
(-[BrowserAppDelegate newPrivateWindow:]):
(-[BrowserAppDelegate applicationDidFinishLaunching:]):
(-[BrowserAppDelegate openDocument:]):
* Tools/MiniBrowser/mac/BrowserWindowController.m:
(-[BrowserWindowController sharingService:transitionImageForShareItem:contentRect:]):
* Tools/MiniBrowser/mac/ExtensionManagerWindowController.m:
(-[ExtensionManagerWindowController add:]):
(-[ExtensionManagerWindowController remove:]):
* Tools/MiniBrowser/mac/SettingsController.m:
(addItemToMenuWithTarget):
(addSubmenuToMenu):
(-[SettingsController togglePerWindowWebProcessesDisabled:]):
* Tools/MiniBrowser/mac/WK1BrowserWindowController.m:
(-[WK1BrowserWindowController dealloc]):
(-[WK1BrowserWindowController windowWillClose:]):
(-[WK1BrowserWindowController webView:runJavaScriptAlertPanelWithMessage:initiatedByFrame:]):
(-[WK1BrowserWindowController webView:runBeforeUnloadConfirmPanelWithMessage:initiatedByFrame:]):
* Tools/MiniBrowser/mac/WK2BrowserWindowController.m:
(-[WK2BrowserWindowController dealloc]):
(-[WK2BrowserWindowController logAccessibilityTrees:]):
(-[WK2BrowserWindowController windowWillClose:]):
(-[WK2BrowserWindowController webView:runJavaScriptAlertPanelWithMessage:initiatedByFrame:completionHandler:]):
(-[WK2BrowserWindowController webView:runJavaScriptConfirmPanelWithMessage:initiatedByFrame:completionHandler:]):
(-[WK2BrowserWindowController webView:runJavaScriptTextInputPanelWithPrompt:defaultText:initiatedByFrame:completionHandler:]):
(-[WK2BrowserWindowController _webView:runBeforeUnloadConfirmPanelWithMessage:initiatedByFrame:completionHandler:]):
(-[WK2BrowserWindowController fetchAndClearWebsiteData:]):
(-[WK2BrowserWindowController webView:didReceiveAuthenticationChallenge:completionHandler:]):
(-[WK2BrowserWindowController saveAsPDF:]):
(-[WK2BrowserWindowController saveAsWebArchive:]):
(-[MiniBrowserNSTextFinder dealloc]): Deleted.

Canonical link: https://commits.webkit.org/256280@main
  • Loading branch information
hortont424 committed Nov 3, 2022
1 parent 3b4b837 commit 548e185
Show file tree
Hide file tree
Showing 7 changed files with 22 additions and 56 deletions.
1 change: 1 addition & 0 deletions Tools/MiniBrowser/Configurations/Base.xcconfig
Expand Up @@ -39,6 +39,7 @@ ENABLE_BITCODE = NO;
PREBINDING = NO
GCC_C_LANGUAGE_STANDARD = gnu99
GCC_ENABLE_CPP_EXCEPTIONS = NO;
CLANG_ENABLE_OBJC_ARC = YES;
GCC_PRECOMPILE_PREFIX_HEADER = YES
ENABLE_STRICT_OBJC_MSGSEND = YES;
GCC_TREAT_WARNINGS_AS_ERRORS = YES
Expand Down
12 changes: 4 additions & 8 deletions Tools/MiniBrowser/mac/AppDelegate.m
Expand Up @@ -84,8 +84,6 @@ - (void)awakeFromNib
if ([_settingsController usesGameControllerFramework])
[WKProcessPool _forceGameControllerFramework];

// [[NSApp mainMenu] insertItem:[item autorelease] atIndex:[[NSApp mainMenu] indexOfItemWithTitle:@"Debug"]];

if ([NSApp respondsToSelector:@selector(setAutomaticCustomizeTouchBarMenuItemEnabled:)])
[NSApp setAutomaticCustomizeTouchBarMenuItemEnabled:YES];
}
Expand All @@ -95,7 +93,7 @@ - (void)awakeFromNib
static WKWebsiteDataStore *dataStore;

if (!dataStore) {
_WKWebsiteDataStoreConfiguration *configuration = [[[_WKWebsiteDataStoreConfiguration alloc] init] autorelease];
_WKWebsiteDataStoreConfiguration *configuration = [[_WKWebsiteDataStoreConfiguration alloc] init];
configuration.networkCacheSpeculativeValidationEnabled = YES;

// FIXME: When built-in notifications are enabled, WebKit doesn't yet gracefully handle a missing webpushd service
Expand All @@ -116,13 +114,13 @@ - (WKWebViewConfiguration *)defaultConfiguration
configuration = [[WKWebViewConfiguration alloc] init];
configuration.websiteDataStore = persistentDataStore();

_WKProcessPoolConfiguration *processConfiguration = [[[_WKProcessPoolConfiguration alloc] init] autorelease];
_WKProcessPoolConfiguration *processConfiguration = [[_WKProcessPoolConfiguration alloc] init];
if (_settingsController.perWindowWebProcessesDisabled)
processConfiguration.usesSingleWebProcess = YES;
if (_settingsController.processSwapOnWindowOpenWithOpenerEnabled)
processConfiguration.processSwapsOnWindowOpenWithOpener = true;

configuration.processPool = [[[WKProcessPool alloc] _initWithConfiguration:processConfiguration] autorelease];
configuration.processPool = [[WKProcessPool alloc] _initWithConfiguration:processConfiguration];

NSArray<_WKExperimentalFeature *> *experimentalFeatures = [WKPreferences _experimentalFeatures];
for (_WKExperimentalFeature *feature in experimentalFeatures) {
Expand Down Expand Up @@ -208,7 +206,6 @@ - (IBAction)newPrivateWindow:(id)sender
privateConfiguraton.websiteDataStore = [WKWebsiteDataStore nonPersistentDataStore];

BrowserWindowController *controller = [[WK2BrowserWindowController alloc] initWithConfiguration:privateConfiguraton];
[privateConfiguraton release];

[[controller window] makeKeyAndOrderFront:sender];
[_browserWindowControllers addObject:controller];
Expand All @@ -235,7 +232,6 @@ - (void)applicationDidFinishLaunching:(NSNotification *)aNotification
{
WebHistory *webHistory = [[WebHistory alloc] init];
[WebHistory setOptionalSharedHistory:webHistory];
[webHistory release];

[self _updateNewWindowKeyEquivalents];

Expand Down Expand Up @@ -281,7 +277,7 @@ - (IBAction)openDocument:(id)sender
BrowserWindowController *browserWindowController = [self frontmostBrowserWindowController];

if (browserWindowController) {
NSOpenPanel *openPanel = [[NSOpenPanel openPanel] retain];
NSOpenPanel *openPanel = [NSOpenPanel openPanel];
[openPanel beginSheetModalForWindow:browserWindowController.window completionHandler:^(NSInteger result) {
if (result != NSModalResponseOK)
return;
Expand Down
2 changes: 1 addition & 1 deletion Tools/MiniBrowser/mac/BrowserWindowController.m
Expand Up @@ -318,7 +318,7 @@ - (NSImage *)sharingService:(NSSharingService *)sharingService transitionImageFo
NSImage *image = [[NSImage alloc] initWithCGImage:imageRef size:NSZeroSize];
CGImageRelease(imageRef);

return [image autorelease];
return image;
}

- (nullable NSWindow *)sharingService:(NSSharingService *)sharingService sourceWindowForShareItems:(NSArray *)items sharingContentScope:(NSSharingContentScope *)sharingContentScope
Expand Down
8 changes: 3 additions & 5 deletions Tools/MiniBrowser/mac/ExtensionManagerWindowController.m
Expand Up @@ -67,7 +67,7 @@ - (void)windowDidLoad

- (IBAction)add:(id)sender
{
NSOpenPanel *openPanel = [[NSOpenPanel openPanel] retain];
NSOpenPanel *openPanel = [NSOpenPanel openPanel];
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
openPanel.allowedFileTypes = @[ @"public.json" ];
Expand Down Expand Up @@ -102,9 +102,8 @@ - (IBAction)add:(id)sender

[mutableInstalledContentExtensions addObject:identifier];
[defaults setObject:mutableInstalledContentExtensions forKey:@"InstalledContentExtensions"];
[mutableInstalledContentExtensions release];

[arrayController addObject:identifier];
[self->arrayController addObject:identifier];

BrowserAppDelegate* appDelegate = [[NSApplication sharedApplication] browserAppDelegate];
[appDelegate.userContentContoller addContentRuleList:list];
Expand Down Expand Up @@ -132,9 +131,8 @@ - (IBAction)remove:(id)sender
NSMutableArray *installedContentExtensions = [[defaults arrayForKey:@"InstalledContentExtensions"] mutableCopy];
[installedContentExtensions removeObject:identifierToRemove];
[defaults setObject:installedContentExtensions forKey:@"InstalledContentExtensions"];
[installedContentExtensions release];

[arrayController removeObjectAtArrangedObjectIndex:index];
[self->arrayController removeObjectAtArrangedObjectIndex:index];
BrowserAppDelegate* appDelegate = [[NSApplication sharedApplication] browserAppDelegate];
[appDelegate.userContentContoller _removeUserContentFilter:identifierToRemove];
}];
Expand Down
10 changes: 4 additions & 6 deletions Tools/MiniBrowser/mac/SettingsController.m
Expand Up @@ -112,7 +112,7 @@ - (instancetype)initWithMenu:(NSMenu *)menu

static NSMenuItem *addItemToMenuWithTarget(NSMenu *menu, NSString *title, id target, SEL action, BOOL indent, NSInteger tag)
{
NSMenuItem *item = [[[NSMenuItem alloc] initWithTitle:title action:action keyEquivalent:@""] autorelease];
NSMenuItem *item = [[NSMenuItem alloc] initWithTitle:title action:action keyEquivalent:@""];
if (action)
item.target = target;
if (tag)
Expand All @@ -130,8 +130,8 @@ static void addSeparatorToMenu(NSMenu *menu)

static NSMenu *addSubmenuToMenu(NSMenu *menu, NSString *title)
{
NSMenuItem *submenuItem = [[[NSMenuItem alloc] initWithTitle:title action:nil keyEquivalent:@""] autorelease];
NSMenu *submenu = [[[NSMenu alloc] initWithTitle:title] autorelease];
NSMenuItem *submenuItem = [[NSMenuItem alloc] initWithTitle:title action:nil keyEquivalent:@""];
NSMenu *submenu = [[NSMenu alloc] initWithTitle:title];
[submenuItem setSubmenu:submenu];
[menu addItem:submenuItem];
return submenu;
Expand Down Expand Up @@ -450,9 +450,7 @@ - (void)togglePerWindowWebProcessesDisabled:(id)sender
[alert addButtonWithTitle:@"Switch and Quit"];
[alert addButtonWithTitle:@"Cancel"];

NSModalResponse response = [alert runModal];
[alert release];

NSModalResponse response = [alert runModal];
if (response != NSAlertFirstButtonReturn)
return;

Expand Down
8 changes: 0 additions & 8 deletions Tools/MiniBrowser/mac/WK1BrowserWindowController.m
Expand Up @@ -76,9 +76,6 @@ - (void)dealloc
[_webView setFrameLoadDelegate:nil];
[_webView setUIDelegate:nil];
[_webView setResourceLoadDelegate:nil];
[_webView release];

[super dealloc];
}

- (void)userAgentDidChange:(NSNotification *)notification
Expand Down Expand Up @@ -214,7 +211,6 @@ - (BOOL)windowShouldClose:(id)sender
- (void)windowWillClose:(NSNotification *)notification
{
[[[NSApplication sharedApplication] browserAppDelegate] browserWindowWillClose:self.window];
[self autorelease];
}

- (double)currentZoomFactor
Expand Down Expand Up @@ -448,7 +444,6 @@ - (void)webView:(WebView *)sender runJavaScriptAlertPanelWithMessage:(NSString *
alert.informativeText = message;

[alert runModal];
[alert release];
}

- (BOOL)webView:(WebView *)sender runBeforeUnloadConfirmPanelWithMessage:(NSString *)message initiatedByFrame:(WebFrame *)frame
Expand All @@ -462,9 +457,6 @@ - (BOOL)webView:(WebView *)sender runBeforeUnloadConfirmPanelWithMessage:(NSStri
[alert addButtonWithTitle:@"Stay On Page"];

NSModalResponse response = [alert runModal];

[alert release];

return response == NSAlertFirstButtonReturn;
}

Expand Down
37 changes: 9 additions & 28 deletions Tools/MiniBrowser/mac/WK2BrowserWindowController.m
Expand Up @@ -57,12 +57,6 @@ @interface MiniBrowserNSTextFinder : NSTextFinder

@implementation MiniBrowserNSTextFinder

- (void)dealloc
{
[_hideInterfaceCallback release];
[super dealloc];
}

- (void)performAction:(NSTextFinderAction)op
{
[super performAction:op];
Expand Down Expand Up @@ -172,13 +166,6 @@ - (void)dealloc

[progressIndicator unbind:NSHiddenBinding];
[progressIndicator unbind:NSValueBinding];

[_textFinder release];

[_webView release];
[_configuration release];

[super dealloc];
}

- (void)userAgentDidChange:(NSNotification *)notification
Expand Down Expand Up @@ -316,7 +303,7 @@ - (IBAction)logAccessibilityTrees:(id)sender
#pragma clang diagnostic pop
[panel beginSheetModalForWindow:self.window completionHandler:^(NSInteger result) {
if (result == NSModalResponseOK) {
[_webView _retrieveAccessibilityTreeData:^(NSData *data, NSError *error) {
[self->_webView _retrieveAccessibilityTreeData:^(NSData *data, NSError *error) {
[data writeToURL:[panel URL] options:0 error:nil];
}];
}
Expand Down Expand Up @@ -442,7 +429,6 @@ - (BOOL)windowShouldClose:(id)sender
- (void)windowWillClose:(NSNotification *)notification
{
[[[NSApplication sharedApplication] browserAppDelegate] browserWindowWillClose:self.window];
[self autorelease];
}

#define DefaultMinimumZoomFactor (.5)
Expand Down Expand Up @@ -599,7 +585,6 @@ - (void)webView:(WKWebView *)webView runJavaScriptAlertPanelWithMessage:(NSStrin

[alert beginSheetModalForWindow:self.window completionHandler:^void (NSModalResponse response) {
completionHandler();
[alert release];
}];
}

Expand All @@ -615,7 +600,6 @@ - (void)webView:(WKWebView *)webView runJavaScriptConfirmPanelWithMessage:(NSStr

[alert beginSheetModalForWindow:self.window completionHandler:^void (NSModalResponse response) {
completionHandler(response == NSAlertFirstButtonReturn);
[alert release];
}];
}

Expand All @@ -636,7 +620,6 @@ - (void)webView:(WKWebView *)webView runJavaScriptTextInputPanelWithPrompt:(NSSt
[alert beginSheetModalForWindow:self.window completionHandler:^void (NSModalResponse response) {
[input validateEditing];
completionHandler(response == NSAlertFirstButtonReturn ? [input stringValue] : nil);
[alert release];
}];
}

Expand Down Expand Up @@ -674,7 +657,6 @@ - (void)_webView:(WebView *)sender runBeforeUnloadConfirmPanelWithMessage:(NSStr

[alert beginSheetModalForWindow:self.window completionHandler:^void (NSModalResponse response) {
completionHandler(response == NSAlertFirstButtonReturn);
[alert release];
}];
}

Expand Down Expand Up @@ -729,8 +711,8 @@ - (IBAction)fetchWebsiteData:(id)sender
- (IBAction)fetchAndClearWebsiteData:(id)sender
{
[_configuration.websiteDataStore fetchDataRecordsOfTypes:dataTypes() completionHandler:^(NSArray *websiteDataRecords) {
[_configuration.websiteDataStore removeDataOfTypes:dataTypes() forDataRecords:websiteDataRecords completionHandler:^{
[_configuration.websiteDataStore fetchDataRecordsOfTypes:dataTypes() completionHandler:^(NSArray *websiteDataRecords) {
[self->_configuration.websiteDataStore removeDataOfTypes:dataTypes() forDataRecords:websiteDataRecords completionHandler:^{
[self->_configuration.websiteDataStore fetchDataRecordsOfTypes:dataTypes() completionHandler:^(NSArray *websiteDataRecords) {
NSLog(@"did clear website data, after clearing data is %@.", websiteDataRecords);
}];
}];
Expand Down Expand Up @@ -812,9 +794,9 @@ - (void)webView:(WKWebView *)webView didReceiveAuthenticationChallenge:(NSURLAut
LOG(@"didReceiveAuthenticationChallenge: %@", challenge);
if ([challenge.protectionSpace.authenticationMethod isEqualToString:NSURLAuthenticationMethodHTTPBasic]) {
NSAlert *alert = [[NSAlert alloc] init];
NSView *container = [[[NSView alloc] initWithFrame:NSMakeRect(0, 0, 200, 48)] autorelease];
NSTextField *userInput = [[[NSTextField alloc] initWithFrame:NSMakeRect(0, 24, 200, 24)] autorelease];
NSTextField *passwordInput = [[[NSSecureTextField alloc] initWithFrame:NSMakeRect(0, 0, 200, 24)] autorelease];
NSView *container = [[NSView alloc] initWithFrame:NSMakeRect(0, 0, 200, 48)];
NSTextField *userInput = [[NSTextField alloc] initWithFrame:NSMakeRect(0, 24, 200, 24)];
NSTextField *passwordInput = [[NSSecureTextField alloc] initWithFrame:NSMakeRect(0, 0, 200, 24)];

[alert setMessageText:[NSString stringWithFormat:@"Log in to %@:%lu.", challenge.protectionSpace.host, challenge.protectionSpace.port]];
[alert addButtonWithTitle:@"Log in"];
Expand All @@ -828,10 +810,9 @@ - (void)webView:(WKWebView *)webView didReceiveAuthenticationChallenge:(NSURLAut
[alert beginSheetModalForWindow:self.window completionHandler:^(NSModalResponse response) {
[userInput validateEditing];
if (response == NSAlertFirstButtonReturn)
completionHandler(NSURLSessionAuthChallengeUseCredential, [[[NSURLCredential alloc] initWithUser:[userInput stringValue] password:[passwordInput stringValue] persistence:NSURLCredentialPersistenceForSession] autorelease]);
completionHandler(NSURLSessionAuthChallengeUseCredential, [[NSURLCredential alloc] initWithUser:[userInput stringValue] password:[passwordInput stringValue] persistence:NSURLCredentialPersistenceForSession]);
else
completionHandler(NSURLSessionAuthChallengeRejectProtectionSpace, nil);
[alert release];
}];
return;
}
Expand Down Expand Up @@ -927,7 +908,7 @@ - (IBAction)saveAsPDF:(id)sender
#pragma clang diagnostic pop
[panel beginSheetModalForWindow:self.window completionHandler:^(NSInteger result) {
if (result == NSModalResponseOK) {
[_webView createPDFWithConfiguration:nil completionHandler:^(NSData *pdfSnapshotData, NSError *error) {
[self->_webView createPDFWithConfiguration:nil completionHandler:^(NSData *pdfSnapshotData, NSError *error) {
[pdfSnapshotData writeToURL:[panel URL] options:0 error:nil];
}];
}
Expand All @@ -944,7 +925,7 @@ - (IBAction)saveAsWebArchive:(id)sender
#pragma clang diagnostic pop
[panel beginSheetModalForWindow:self.window completionHandler:^(NSInteger result) {
if (result == NSModalResponseOK) {
[_webView createWebArchiveDataWithCompletionHandler:^(NSData *archiveData, NSError *error) {
[self->_webView createWebArchiveDataWithCompletionHandler:^(NSData *archiveData, NSError *error) {
[archiveData writeToURL:[panel URL] options:0 error:nil];
}];
}
Expand Down

0 comments on commit 548e185

Please sign in to comment.