Bug 1702898 - Remove some respondsToSelector checks that were only needed for old macOS versions. r=mac-reviewers,jgilbert,tnikkel,bradwerth

-[NSOpenGLContext pixelFormat] is 10.10+
-[NSScreen backingScaleFactor] is 10.7+
+[NSEvent isSwipeTrackingFromScrollEventsEnabled] is 10.7+

Differential Revision: https://phabricator.services.mozilla.com/D110772
This commit is contained in:
Markus Stange 2021-04-06 14:33:13 +00:00
Родитель 8754752264
Коммит 3c50594c6e
3 изменённых файлов: 3 добавлений и 18 удалений

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

@ -168,22 +168,13 @@ static bool IsSameGPU(CGOpenGLDisplayMask mask1, CGOpenGLDisplayMask mask2) {
return !mask1 && !mask2;
}
static NSOpenGLPixelFormat* GetPixelFormatForContext(NSOpenGLContext* aContext) {
// -[NSOpenGLContext pixelFormat] is macOS 10.10+
if ([aContext respondsToSelector:@selector(pixelFormat)]) {
return [aContext pixelFormat];
}
return [[[NSOpenGLPixelFormat alloc]
initWithCGLPixelFormatObj:CGLGetPixelFormat([aContext CGLContextObj])] autorelease];
}
void GLContextCGL::MigrateToActiveGPU() {
if (!mActiveGPUSwitchMayHaveOccurred.compareExchange(true, false)) {
return;
}
CGOpenGLDisplayMask newPreferredDisplayMask = GetFreshContextDisplayMask();
NSOpenGLPixelFormat* pixelFormat = GetPixelFormatForContext(mContext);
NSOpenGLPixelFormat* pixelFormat = [mContext pixelFormat];
GLint currentVirtualScreen = [mContext currentVirtualScreen];
GLint currentDisplayMask = 0;
[pixelFormat getValues:&currentDisplayMask

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

@ -725,12 +725,9 @@ bool nsCocoaUtils::HiDPIEnabled() {
if ([desc objectForKey:NSDeviceIsScreen] == nil) {
continue;
}
CGFloat scale = [screen respondsToSelector:@selector(backingScaleFactor)]
? [screen backingScaleFactor]
: 1.0;
// Currently, we only care about differentiating "1.0" and "2.0",
// so we set one of the two low bits to record which.
if (scale > 1.0) {
if ([screen backingScaleFactor] > 1.0) {
scaleFactors |= 2;
} else {
scaleFactors |= 1;

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

@ -480,10 +480,7 @@ nsresult nsLookAndFeel::NativeGetInt(IntID aID, int32_t& aResult) {
aResult = 0;
break;
case IntID::SwipeAnimationEnabled:
aResult = 0;
if ([NSEvent respondsToSelector:@selector(isSwipeTrackingFromScrollEventsEnabled)]) {
aResult = [NSEvent isSwipeTrackingFromScrollEventsEnabled];
}
aResult = NSEvent.isSwipeTrackingFromScrollEventsEnabled;
break;
case IntID::ContextMenuOffsetVertical:
aResult = -6;