Skip to content

Commit

Permalink
Backed out 3 changesets (bug 639707) for causing macOS build bustages…
Browse files Browse the repository at this point in the history
… on nsCocoaUtils.mm. CLOSED TREE

Backed out changeset 0e733d6ed42d (bug 639707)
Backed out changeset 23c4048448bf (bug 639707)
Backed out changeset a3f8bdd9e837 (bug 639707)
  • Loading branch information
Iulian Moraru committed Feb 2, 2023
1 parent 797345c commit 890afcc
Show file tree
Hide file tree
Showing 10 changed files with 14 additions and 116 deletions.
20 changes: 0 additions & 20 deletions toolkit/components/telemetry/Scalars.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6094,26 +6094,6 @@ startup:
record_in_processes:
- main

is_restored_by_macos:
bug_numbers:
- 639707
description: >
Recorded on every launch of a Firefox install on macOS, with a boolean
value indicating whether Firefox was restored by macOS or if it was
manually launched by a user.
expires: "116"
keyed: false
kind: boolean
notification_emails:
- [email protected]
operating_systems:
- mac
products:
- 'firefox'
record_in_processes:
- 'main'
release_channel_collection: opt-out

script.preloader:
mainthread_recompile:
bug_numbers:
Expand Down
2 changes: 1 addition & 1 deletion toolkit/xre/MacApplicationDelegate.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
#define MacApplicationDelegate_h_

void EnsureUseCocoaDockAPI(void);
void SetupMacApplicationDelegate(bool* gRestartedByOS);
void SetupMacApplicationDelegate(void);
void ProcessPendingGetURLAppleEvents(void);
void DisableAppNap(void);

Expand Down
5 changes: 1 addition & 4 deletions toolkit/xre/MacApplicationDelegate.mm
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@
#include "nsCommandLineServiceMac.h"
#include "nsCommandLine.h"
#include "nsStandaloneNativeMenu.h"
#include "nsCocoaUtils.h"

class AutoAutoreleasePool {
public:
Expand Down Expand Up @@ -79,7 +78,7 @@ void DisableAppNap() {
}];
}

void SetupMacApplicationDelegate(bool* gRestartedByOS) {
void SetupMacApplicationDelegate() {
NS_OBJC_BEGIN_TRY_IGNORE_BLOCK;

// this is called during startup, outside an event loop, and therefore
Expand All @@ -98,8 +97,6 @@ void SetupMacApplicationDelegate(bool* gRestartedByOS) {
id<NSApplicationDelegate> delegate = [[MacApplicationDelegate alloc] init];
[[GeckoNSApplication sharedApplication] setDelegate:delegate];

*gRestartedByOS = !!nsCocoaUtils::ShouldRestoreStateDueToLaunchAtLogin();

NS_OBJC_END_TRY_IGNORE_BLOCK;
}

Expand Down
2 changes: 1 addition & 1 deletion toolkit/xre/nsAppRunner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4192,7 +4192,7 @@ int XREMain::XRE_mainInit(bool* aExitFlag) {
// Set up ability to respond to system (Apple) events. This must occur before
// ProcessUpdates to ensure that links clicked in external applications aren't
// lost when updates are pending.
SetupMacApplicationDelegate(&gRestartedByOS);
SetupMacApplicationDelegate();

if (EnvHasValue("MOZ_LAUNCHED_CHILD")) {
// This is needed, on relaunch, to force the OS to use the "Cocoa Dock
Expand Down
10 changes: 0 additions & 10 deletions widget/cocoa/nsAppShell.mm
Original file line number Diff line number Diff line change
Expand Up @@ -196,8 +196,6 @@ @interface AppShellDelegate : NSObject {

- (id)initWithAppShell:(nsAppShell*)aAppShell;
- (void)applicationWillTerminate:(NSNotification*)aNotification;
- (BOOL)shouldSaveApplicationState:(NSCoder*)coder;
- (BOOL)shouldRestoreApplicationState:(NSCoder*)coder;
@end

// nsAppShell implementation
Expand Down Expand Up @@ -1047,14 +1045,6 @@ - (void)timezoneChanged:(NSNotification*)aNotification {
NS_OBJC_END_TRY_IGNORE_BLOCK;
}

- (BOOL)shouldSaveApplicationState:(NSCoder*)coder {
return YES;
}

- (BOOL)shouldRestoreApplicationState:(NSCoder*)coder {
return YES;
}

@end

// We hook terminate: in order to make OS-initiated termination work nicely
Expand Down
17 changes: 0 additions & 17 deletions widget/cocoa/nsCocoaUtils.h
Original file line number Diff line number Diff line change
Expand Up @@ -238,12 +238,6 @@ class nsCocoaUtils {

static nsIWidget* GetHiddenWindowWidget();

/**
* Should the application restore its state because it was launched by the OS
* at login?
*/
static BOOL ShouldRestoreStateDueToLaunchAtLogin();

static void PrepareForNativeAppModalDialog();
static void CleanUpAfterNativeAppModalDialog();

Expand Down Expand Up @@ -544,17 +538,6 @@ class nsCocoaUtils {
*/
static NSString* GetTitleForURLFromPasteboardItem(NSPasteboardItem* item);

/**
* Did the OS launch the application at login?
*/
static BOOL WasLaunchedAtLogin();

/**
* Should the application restore its state because it was launched by the OS
* at login?
*/
static BOOL ShouldRestoreStateDueToLaunchAtLoginImpl();

/**
* Array of promises waiting to be resolved due to a video capture request.
*/
Expand Down
50 changes: 0 additions & 50 deletions widget/cocoa/nsCocoaUtils.mm
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@
#include "mozilla/Logging.h"
#include "mozilla/MiscEvents.h"
#include "mozilla/Preferences.h"
#include "mozilla/Telemetry.h"
#include "mozilla/TextEvents.h"
#include "mozilla/StaticMutex.h"
#include "mozilla/StaticPrefs_media.h"
Expand Down Expand Up @@ -252,55 +251,6 @@ static float MenuBarScreenHeight() {
return hiddenWindowWidget;
}

BOOL nsCocoaUtils::WasLaunchedAtLogin() {
ProcessSerialNumber processSerialNumber = {0, kCurrentProcess};
ProcessInfoRec processInfoRec = {};
processInfoRec.processInfoLength = sizeof(processInfoRec);

// There is currently no replacement for ::GetProcessInformation, which has
// been deprecated since macOS 10.9.
if (::GetProcessInformation(&processSerialNumber, &processInfoRec) == noErr) {
ProcessInfoRec parentProcessInfo = {};
parentProcessInfo.processInfoLength = sizeof(parentProcessInfo);
if (::GetProcessInformation(&processInfoRec.processLauncher, &parentProcessInfo) == noErr) {
return parentProcessInfo.processSignature == 'lgnw';
}
}
return NO;
}

BOOL nsCocoaUtils::ShouldRestoreStateDueToLaunchAtLoginImpl() {
// Check if we were launched by macOS as a result of having
// "Reopen windows..." selected during a restart.
if (!WasLaunchedAtLogin()) {
return NO;
}

CFStringRef lgnwPlistName = CFSTR("com.apple.loginwindow");
CFStringRef saveStateKey = CFSTR("TALLogoutSavesState");
CFPropertyListRef lgnwPlist =
(CFPropertyListRef)(::CFPreferencesCopyAppValue(saveStateKey, lgnwPlistName));
// The .plist doesn't exist unless the user changed the "Reopen windows..."
// preference. If it doesn't exist, restore by default (as this is the macOS
// default).
// https://developer.apple.com/library/mac/documentation/macosx/conceptual/bpsystemstartup/chapters/CustomLogin.html
if (!lgnwPlist) {
return YES;
}

if (CFBooleanRef shouldRestoreState = static_cast<CFBooleanRef>(lgnwPlist)) {
return ::CFBooleanGetValue(shouldRestoreState);
}

return NO;
}

BOOL nsCocoaUtils::ShouldRestoreStateDueToLaunchAtLogin() {
BOOL shouldRestore = ShouldRestoreStateDueToLaunchAtLoginImpl();
Telemetry::ScalarSet(Telemetry::ScalarID::STARTUP_IS_RESTORED_BY_MACOS, shouldRestore);
return shouldRestore;
}

void nsCocoaUtils::PrepareForNativeAppModalDialog() {
NS_OBJC_BEGIN_TRY_IGNORE_BLOCK;

Expand Down
3 changes: 1 addition & 2 deletions widget/cocoa/nsCocoaWindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -366,8 +366,7 @@ class nsCocoaWindow final : public nsBaseWidget, public nsPIWidgetCocoa {
protected:
virtual ~nsCocoaWindow();

nsresult CreateNativeWindow(const NSRect& aRect, BorderStyle aBorderStyle, bool aRectIsFrameRect,
bool aIsPrivateBrowsing);
nsresult CreateNativeWindow(const NSRect& aRect, BorderStyle aBorderStyle, bool aRectIsFrameRect);
nsresult CreatePopupContentView(const LayoutDeviceIntRect& aRect, InitData*);
void DestroyNativeWindow();
void UpdateBounds();
Expand Down
15 changes: 6 additions & 9 deletions widget/cocoa/nsCocoaWindow.mm
Original file line number Diff line number Diff line change
Expand Up @@ -343,8 +343,8 @@ static DesktopRect GetWidgetScreenRectForChildren(nsIWidget* aWidget, NSView* aV

DesktopIntRect widgetRect = aRect + parentOrigin;

nsresult rv = CreateNativeWindow(nsCocoaUtils::GeckoRectToCocoaRect(widgetRect), mBorderStyle,
false, aInitData->mIsPrivate);
nsresult rv =
CreateNativeWindow(nsCocoaUtils::GeckoRectToCocoaRect(widgetRect), mBorderStyle, false);
NS_ENSURE_SUCCESS(rv, rv);

if (mWindowType == WindowType::Popup) {
Expand Down Expand Up @@ -407,7 +407,7 @@ static unsigned int WindowMaskForBorderStyle(BorderStyle aBorderStyle) {
// the bottom of the menubar and aRect.width/height specify the size of the
// content rect.
nsresult nsCocoaWindow::CreateNativeWindow(const NSRect& aRect, BorderStyle aBorderStyle,
bool aRectIsFrameRect, bool aIsPrivateBrowsing) {
bool aRectIsFrameRect) {
NS_OBJC_BEGIN_TRY_BLOCK_RETURN;

// We default to NSWindowStyleMaskBorderless, add features if needed.
Expand Down Expand Up @@ -504,10 +504,8 @@ static unsigned int WindowMaskForBorderStyle(BorderStyle aBorderStyle) {

// Make sure that window titles don't leak to disk in private browsing mode
// due to macOS' resume feature.
[mWindow setRestorable:!aIsPrivateBrowsing];
if (aIsPrivateBrowsing) {
[mWindow disableSnapshotRestoration];
}
[mWindow setRestorable:NO];
[mWindow disableSnapshotRestoration];

// setup our notification delegate. Note that setDelegate: does NOT retain.
mDelegate = [[WindowDelegate alloc] initWithGeckoWindow:this];
Expand Down Expand Up @@ -1499,8 +1497,7 @@ static CGSRemoveWindowsFromSpacesFunc GetCGSRemoveWindowsFromSpacesFunc() {
// Recreate the window with the right border style.
NSRect frameRect = [mWindow frame];
DestroyNativeWindow();
nsresult rv = CreateNativeWindow(frameRect, aShouldHide ? BorderStyle::None : mBorderStyle, true,
mWindow.restorable);
nsresult rv = CreateNativeWindow(frameRect, aShouldHide ? BorderStyle::None : mBorderStyle, true);
NS_ENSURE_SUCCESS_VOID(rv);

// Re-import state.
Expand Down
6 changes: 4 additions & 2 deletions xpfe/appshell/nsAppShellService.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -671,6 +671,10 @@ nsresult nsAppShellService::JustCreateTopWindow(

widgetInitData.mRTL = LocaleService::GetInstance()->IsAppLocaleRTL();

if (aChromeMask & nsIWebBrowserChrome::CHROME_PRIVATE_WINDOW) {
widgetInitData.mIsPrivate = true;
}

nsresult rv =
window->Initialize(parent, center ? aParent : nullptr, aInitialWidth,
aInitialHeight, aIsHiddenWindow, widgetInitData);
Expand All @@ -685,8 +689,6 @@ nsresult nsAppShellService::JustCreateTopWindow(
// Caller requested a private window
isPrivateBrowsingWindow = true;
}
widgetInitData.mIsPrivate = isPrivateBrowsingWindow;

nsCOMPtr<mozIDOMWindowProxy> domWin = do_GetInterface(aParent);
nsCOMPtr<nsIWebNavigation> webNav = do_GetInterface(domWin);
nsCOMPtr<nsILoadContext> parentContext = do_QueryInterface(webNav);
Expand Down

0 comments on commit 890afcc

Please sign in to comment.