Skip to content

Commit

Permalink
small changes, big difference. fix DL crashes pre 10.10, errant toolt…
Browse files Browse the repository at this point in the history
…ips (centralle)

wow what a difference two changes made.

a lot of work went into their detection, but now there are no errant,
or empty tooltips when you mouseover menubuttons.

also downloads would crash after completing because the clang team
likes to engage in butthole play (being assholes ha), by failing
to backport newer enums that don't work on older systems. they
just don't care. APPUL pays their bills and probably encourages this
behaviour.
  • Loading branch information
i3roly committed Aug 11, 2024
1 parent feab71a commit 1849bde
Show file tree
Hide file tree
Showing 5 changed files with 42 additions and 9 deletions.
7 changes: 7 additions & 0 deletions widget/cocoa/VibrancyManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,13 @@ class VibrancyManager {

LayoutDeviceIntRegion GetUnionOfVibrantRegions() const;

/**
* Check whether the operating system supports vibrancy at all.
* You may only create a VibrancyManager instance if this returns true.
* @return Whether VibrancyManager can be used on this OS.
*/
static bool SystemSupportsVibrancy();

/**
* Create an NSVisualEffectView for the specified vibrancy type. The return
* value is not autoreleased. We return an object of type NSView* because we
Expand Down
14 changes: 14 additions & 0 deletions widget/cocoa/VibrancyManager.mm
Original file line number Diff line number Diff line change
Expand Up @@ -120,3 +120,17 @@ - (BOOL)allowsVibrancy {

}

static bool ComputeSystemSupportsVibrancy() {
#ifdef __x86_64__
return NSClassFromString(@"NSAppearance") && NSClassFromString(@"NSVisualEffectView");
#else
// objc_allocateClassPair doesn't work in 32 bit mode, so turn off vibrancy.
return false;
#endif
}

/* static */ bool VibrancyManager::SystemSupportsVibrancy() {
static bool supportsVibrancy = ComputeSystemSupportsVibrancy();
return supportsVibrancy;
}

6 changes: 6 additions & 0 deletions widget/cocoa/nsCocoaWindow.mm
Original file line number Diff line number Diff line change
Expand Up @@ -3320,6 +3320,10 @@ - (id)initWithContentRect:(NSRect)aContentRect
// Add an effect view wrapper if needed so that the OS draws the appropriate
// vibrancy effect and window border.
- (void)setEffectViewWrapperForStyle:(WindowShadow)aStyle {
if (!VibrancyManager::SystemSupportsVibrancy()) {
return;
}

NSView* wrapper = [&]() -> NSView* {
if (aStyle == WindowShadow::Menu || aStyle == WindowShadow::Tooltip) {
const bool isMenu = aStyle == WindowShadow::Menu;
Expand All @@ -3332,7 +3336,9 @@ - (void)setEffectViewWrapperForStyle:(WindowShadow)aStyle {
effectView.blendingMode = NSVisualEffectBlendingModeBehindWindow;
if (isMenu) {
// Turn on rounded corner masking.
if ([effectView respondsToSelector:@selector(setMaskImage:)]) {
effectView.maskImage = GetMenuMaskImage();
}
effectView.material = NSVisualEffectMaterialMenu;
} else {
if(@available(macOS 10.14, *)) {
Expand Down
14 changes: 6 additions & 8 deletions widget/cocoa/nsMacUserActivityUpdater.mm
Original file line number Diff line number Diff line change
Expand Up @@ -41,14 +41,12 @@
pageTitle = pageUrl.absoluteString;
}

if(__builtin_available(macOS 10.10, *)) {
NSUserActivity* userActivity = [[NSUserActivity alloc]
initWithActivityType:NSUserActivityTypeBrowsingWeb];
userActivity.webpageURL = pageUrl;
userActivity.title = pageTitle;
cocoaWin.userActivity = userActivity;
[userActivity release];
}
NSUserActivity* userActivity = [[NSUserActivity alloc]
initWithActivityType:NSUserActivityTypeBrowsingWeb];
userActivity.webpageURL = pageUrl;
userActivity.title = pageTitle;
cocoaWin.userActivity = userActivity;
[userActivity release];
}
return NS_OK;

Expand Down
10 changes: 9 additions & 1 deletion xpcom/io/CocoaFileUtils.mm
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */

#include "CocoaFileUtils.h"
#include "nsCocoaFeatures.h"
#include "nsCocoaUtils.h"
#include <Cocoa/Cocoa.h>
#include "nsObjCExceptions.h"
Expand Down Expand Up @@ -215,6 +216,13 @@ typedef OSStatus (*MDItemSetAttribute_type)(MDItemRef, CFStringRef,
::CFRelease(mdItem);
}

static CFStringRef GetQuarantinePropKey() {
if (nsCocoaFeatures::OnYosemiteOrLater()) {
return kCFURLQuarantinePropertiesKey;
}
return kLSItemQuarantineProperties;
}

// Can be called off of the main thread.
static CFMutableDictionaryRef CreateQuarantineDictionary(
const CFURLRef aFileURL, const bool aCreateProps) {
Expand All @@ -227,7 +235,7 @@ static CFMutableDictionaryRef CreateQuarantineDictionary(
&kCFTypeDictionaryValueCallBacks);
} else {
Boolean success = ::CFURLCopyResourcePropertyForKey(
aFileURL, kCFURLQuarantinePropertiesKey, &quarantineProps, NULL);
aFileURL, GetQuarantinePropKey(), &quarantineProps, NULL);
// If there aren't any quarantine properties then the user probably
// set up an exclusion and we don't need to add metadata.
if (!success || !quarantineProps) {
Expand Down

0 comments on commit 1849bde

Please sign in to comment.