Bug 1729879 - Start NSApp in AskUserIfWeShouldInstall alert. r=mstange

This is needed for platform accessibility support.

Differential Revision: https://phabricator.services.mozilla.com/D125280
This commit is contained in:
Eitan Isaacson 2021-09-10 21:56:37 +00:00
Родитель 153b43e7e2
Коммит 9923e78bac
1 изменённых файлов: 26 добавлений и 1 удалений

Просмотреть файл

@ -93,7 +93,32 @@ static bool AskUserIfWeShouldInstall() {
// to map the Escape key to it manually:
[dontInstallButton setKeyEquivalent:@"\e"];
NSInteger result = [alert runModal];
// We need to call run on NSApp to allow accessibility. We only run it
// for this specific alert which blocks the app's loop until the user
// responds, it then subsequently stops the app's loop.
//
// AskUserIfWeShouldInstall
// |
// | ---> [NSApp run]
// | |
// | | -----> task
// | | | -----------> [alert runModal]
// | | | | (User selects button)
// | | | <--------------- done
// | | |
// | | | -----------> [NSApp stop:nil]
// | | | <-----------
// | | <--------
// | <-------
// done
__block NSInteger result = -1;
dispatch_async(dispatch_get_main_queue(), ^{
result = [alert runModal];
[NSApp stop:nil];
});
[NSApp run];
MOZ_ASSERT(result != -1);
return result == NSAlertFirstButtonReturn;