Bug 1851946 - Remove outdated mac SDK-version checks. r=mac-reviewers,media-playback-reviewers,bradwerth,alwu

Now that the minimum supported version of the mac SDK is 13.3, all the
macro-based checks for SDK versions older than that are always false.
Remove them.

Differential Revision: https://phabricator.services.mozilla.com/D187639
This commit is contained in:
Mike Hommey 2023-09-08 01:44:07 +00:00
parent 6c109bc1b4
commit 633e2ac6ba
22 changed files with 111 additions and 341 deletions

View File

@ -5,8 +5,6 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "SDKDeclarations.h"
@protocol MOXTextMarkerSupport;
@protocol mozAccessible;

View File

@ -221,12 +221,7 @@ bool AppleDecoderModule::CanCreateHWDecoder(media::MediaCodec aCodec) {
/* static */
bool AppleDecoderModule::RegisterSupplementalVP9Decoder() {
static bool sRegisterIfAvailable = []() {
#if !defined(MAC_OS_VERSION_11_0) || \
MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_VERSION_11_0
if (nsCocoaFeatures::OnBigSurOrLater()) {
#else
if (__builtin_available(macos 11.0, *)) {
#endif
VTRegisterSupplementalVideoDecoderIfAvailable(kCMVideoCodecType_VP9);
return true;
}

View File

@ -29,7 +29,6 @@
#include "mozilla/Telemetry.h"
#include "mozilla/webrender/RenderMacIOSurfaceTextureHost.h"
#include "ScopedGLHelpers.h"
#include "SDKDeclarations.h"
@interface CALayer (PrivateSetContentsOpaque)
- (void)setContentsOpaque:(BOOL)opaque;

View File

@ -8,15 +8,6 @@
/* static */ CFStringRef gfxMacUtils::CFStringForTransferFunction(
mozilla::gfx::TransferFunction aTransferFunction) {
#if !defined(MAC_OS_VERSION_10_13) || \
MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_VERSION_10_13
CFStringRef kCVImageBufferTransferFunction_sRGB = CFSTR("IEC_sRGB");
CFStringRef kCVImageBufferTransferFunction_SMPTE_ST_2084_PQ =
CFSTR("SMPTE_ST_2084_PQ");
CFStringRef kCVImageBufferTransferFunction_ITU_R_2100_HLG =
CFSTR("ITU_R_2100_HLG");
#endif
switch (aTransferFunction) {
case mozilla::gfx::TransferFunction::BT709:
return kCVImageBufferTransferFunction_ITU_R_709_2;

View File

@ -384,13 +384,8 @@ void ProcessPendingGetURLAppleEvents() {
- (BOOL)application:(NSApplication*)application
continueUserActivity:(NSUserActivity*)userActivity
#if defined(MAC_OS_X_VERSION_10_14) && \
MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_14
restorationHandler:
(void (^)(NSArray<id<NSUserActivityRestoring>>*))restorationHandler {
#else
restorationHandler:(void (^)(NSArray*))restorationHandler {
#endif
if (![userActivity.activityType
isEqualToString:NSUserActivityTypeBrowsingWeb]) {
return NO;

View File

@ -32,7 +32,6 @@
#ifdef MOZ_UPDATER
# include "nsUpdateDriver.h"
#endif
#include "SDKDeclarations.h"
// For IOKit docs, see:
// https://developer.apple.com/documentation/iokit

View File

@ -12,7 +12,6 @@
#include "mozilla/StaticPrefs_widget.h"
#include "nsXULAppAPI.h"
#include "SDKDeclarations.h"
static void ToolbarThemePrefChanged(const char* aPref, void* aUserInfo);

View File

@ -17,7 +17,6 @@
#include "nsCocoaUtils.h"
#include "nsMenuX.h"
#include "nsObjCExceptions.h"
#include "SDKDeclarations.h"
static BOOL sNeedToUnwindForMenuClosing = NO;
@ -163,12 +162,7 @@ static BOOL sNeedToUnwindForMenuClosing = NO;
// option 5.
if (aAppearance) {
#if !defined(MAC_OS_VERSION_11_0) || \
MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_VERSION_11_0
if (nsCocoaFeatures::OnBigSurOrLater()) {
#else
if (@available(macOS 11.0, *)) {
#endif
// By default, NSMenu inherits its appearance from the opening NSEvent's
// window. If CSS has overridden it, on Big Sur + we can respect it with
// -[NSMenu setAppearance].

View File

@ -1,133 +0,0 @@
/* -*- Mode: c++; tab-width: 2; indent-tabs-mode: nil; -*- */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#ifndef SDKDefines_h
#define SDKDefines_h
#import <Cocoa/Cocoa.h>
/**
* This file contains header declarations from SDKs more recent than the minimum macOS SDK which we
* require for building Firefox, which is currently the macOS 10.12 SDK.
*/
#if !defined(MAC_OS_X_VERSION_10_12_2) || MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_12_2
@interface NSView (NSView10_12_2)
- (NSTouchBar*)makeTouchBar;
@end
#endif
#if !defined(MAC_OS_X_VERSION_10_13) || MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_13
using NSAppearanceName = NSString*;
@interface NSColor (NSColor10_13)
// "Available in 10.10", but not present in any SDK less than 10.13
@property(class, strong, readonly) NSColor* systemPurpleColor NS_AVAILABLE_MAC(10_10);
@end
@interface NSTask (NSTask10_13)
@property(copy) NSURL* executableURL NS_AVAILABLE_MAC(10_13);
@property(copy) NSArray<NSString*>* arguments;
- (BOOL)launchAndReturnError:(NSError**)error NS_AVAILABLE_MAC(10_13);
@end
enum : OSType {
kCVPixelFormatType_420YpCbCr10BiPlanarVideoRange = 'x420',
kCVPixelFormatType_420YpCbCr10BiPlanarFullRange = 'xf20',
};
#endif
#if !defined(MAC_OS_X_VERSION_10_14) || MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_14
const NSAppearanceName NSAppearanceNameDarkAqua = @"NSAppearanceNameDarkAqua";
@interface NSWindow (NSWindow10_14)
@property(weak) NSObject<NSAppearanceCustomization>* appearanceSource NS_AVAILABLE_MAC(10_14);
@end
@interface NSApplication (NSApplication10_14)
@property(strong) NSAppearance* appearance NS_AVAILABLE_MAC(10_14);
@property(readonly, strong) NSAppearance* effectiveAppearance NS_AVAILABLE_MAC(10_14);
@end
@interface NSAppearance (NSAppearance10_14)
- (NSAppearanceName)bestMatchFromAppearancesWithNames:(NSArray<NSAppearanceName>*)appearances
NS_AVAILABLE_MAC(10_14);
@end
@interface NSColor (NSColor10_14)
// Available in 10.10, but retroactively made public in 10.14.
@property(class, strong, readonly) NSColor* linkColor NS_AVAILABLE_MAC(10_10);
@end
enum {
NSVisualEffectMaterialToolTip NS_ENUM_AVAILABLE_MAC(10_14) = 17,
};
#endif
#if !defined(MAC_OS_VERSION_11_0) || MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_VERSION_11_0
// The declarations below do not have NS_AVAILABLE_MAC(11_0) on them because we're building with a
// pre-macOS 11 SDK, so macOS 11 identifies itself as 10.16, and @available(macOS 11.0, *) checks
// won't work. You'll need to use an annoying double-whammy check for these:
//
// #if !defined(MAC_OS_VERSION_11_0) || MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_VERSION_11_0
// if (nsCocoaFeatures::OnBigSurOrLater()) {
// #else
// if (@available(macOS 11.0, *)) {
// #endif
// ...
// }
//
typedef NS_ENUM(NSInteger, NSTitlebarSeparatorStyle) {
NSTitlebarSeparatorStyleAutomatic,
NSTitlebarSeparatorStyleNone,
NSTitlebarSeparatorStyleLine,
NSTitlebarSeparatorStyleShadow
};
@interface NSWindow (NSWindow11_0)
@property NSTitlebarSeparatorStyle titlebarSeparatorStyle;
@end
@interface NSMenu (NSMenu11_0)
// In reality, NSMenu implements the NSAppearanceCustomization protocol, and picks up the appearance
// property from that protocol. But we can't tack on protocol implementations, so we just declare
// the property setter here.
- (void)setAppearance:(NSAppearance*)appearance;
@end
#endif
#if !defined(MAC_OS_VERSION_12_0) || MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_VERSION_12_0
typedef CFTypeRef AXTextMarkerRef;
typedef CFTypeRef AXTextMarkerRangeRef;
extern "C" {
CFTypeID AXTextMarkerGetTypeID();
AXTextMarkerRef AXTextMarkerCreate(CFAllocatorRef allocator, const UInt8* bytes, CFIndex length);
const UInt8* AXTextMarkerGetBytePtr(AXTextMarkerRef text_marker);
CFIndex AXTextMarkerGetLength(AXTextMarkerRef text_marker);
CFTypeID AXTextMarkerRangeGetTypeID();
AXTextMarkerRangeRef AXTextMarkerRangeCreate(CFAllocatorRef allocator, AXTextMarkerRef start_marker,
AXTextMarkerRef end_marker);
AXTextMarkerRef AXTextMarkerRangeCopyStartMarker(AXTextMarkerRangeRef text_marker_range);
AXTextMarkerRef AXTextMarkerRangeCopyEndMarker(AXTextMarkerRangeRef text_marker_range);
}
@interface NSScreen (NSScreen12_0)
// https://developer.apple.com/documentation/appkit/nsscreen/3882821-safeareainsets?language=objc&changes=latest_major
@property(readonly) NSEdgeInsets safeAreaInsets;
@end
#endif
#endif // SDKDefines_h

View File

@ -9,7 +9,6 @@
#import <objc/message.h>
#include "nsChildView.h"
#include "SDKDeclarations.h"
using namespace mozilla;

View File

@ -27,7 +27,6 @@ EXPORTS += [
"nsChangeObserver.h",
"nsCocoaFeatures.h",
"nsCocoaUtils.h",
"SDKDeclarations.h",
]
UNIFIED_SOURCES += [

View File

@ -115,10 +115,6 @@ struct KeyBindingsCommand {
@end // NativeKeyBindingsRecorder
#if !defined(MAC_OS_X_VERSION_10_14) || MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_14
typedef NSString* AVMediaType;
#endif
class nsCocoaUtils {
typedef mozilla::gfx::SourceSurface SourceSurface;
typedef mozilla::LayoutDeviceIntPoint LayoutDeviceIntPoint;
@ -130,7 +126,8 @@ class nsCocoaUtils {
// Get the backing scale factor from an object that supports this selector
// (NSView/Window/Screen, on 10.7 or later), returning 1.0 if not supported
static CGFloat GetBackingScaleFactor(id aObject) {
if (HiDPIEnabled() && [aObject respondsToSelector:@selector(backingScaleFactor)]) {
if (HiDPIEnabled() &&
[aObject respondsToSelector:@selector(backingScaleFactor)]) {
return [aObject backingScaleFactor];
}
return 1.0;
@ -142,36 +139,41 @@ class nsCocoaUtils {
return NSToIntRound(aPts * aBackingScale);
}
static LayoutDeviceIntPoint CocoaPointsToDevPixels(const NSPoint& aPt, CGFloat aBackingScale) {
static LayoutDeviceIntPoint CocoaPointsToDevPixels(const NSPoint& aPt,
CGFloat aBackingScale) {
return LayoutDeviceIntPoint(NSToIntRound(aPt.x * aBackingScale),
NSToIntRound(aPt.y * aBackingScale));
}
static LayoutDeviceIntPoint CocoaPointsToDevPixelsRoundDown(const NSPoint& aPt,
CGFloat aBackingScale) {
static LayoutDeviceIntPoint CocoaPointsToDevPixelsRoundDown(
const NSPoint& aPt, CGFloat aBackingScale) {
return LayoutDeviceIntPoint(NSToIntFloor(aPt.x * aBackingScale),
NSToIntFloor(aPt.y * aBackingScale));
}
static LayoutDeviceIntRect CocoaPointsToDevPixels(const NSRect& aRect, CGFloat aBackingScale) {
static LayoutDeviceIntRect CocoaPointsToDevPixels(const NSRect& aRect,
CGFloat aBackingScale) {
return LayoutDeviceIntRect(NSToIntRound(aRect.origin.x * aBackingScale),
NSToIntRound(aRect.origin.y * aBackingScale),
NSToIntRound(aRect.size.width * aBackingScale),
NSToIntRound(aRect.size.height * aBackingScale));
}
static CGFloat DevPixelsToCocoaPoints(int32_t aPixels, CGFloat aBackingScale) {
static CGFloat DevPixelsToCocoaPoints(int32_t aPixels,
CGFloat aBackingScale) {
return (CGFloat)aPixels / aBackingScale;
}
static NSPoint DevPixelsToCocoaPoints(const mozilla::LayoutDeviceIntPoint& aPt,
CGFloat aBackingScale) {
return NSMakePoint((CGFloat)aPt.x / aBackingScale, (CGFloat)aPt.y / aBackingScale);
static NSPoint DevPixelsToCocoaPoints(
const mozilla::LayoutDeviceIntPoint& aPt, CGFloat aBackingScale) {
return NSMakePoint((CGFloat)aPt.x / aBackingScale,
(CGFloat)aPt.y / aBackingScale);
}
// Implements an NSPoint equivalent of -[NSWindow convertRectFromScreen:].
static NSPoint ConvertPointFromScreen(NSWindow* aWindow, const NSPoint& aPt) {
return [aWindow convertRectFromScreen:NSMakeRect(aPt.x, aPt.y, 0, 0)].origin;
return
[aWindow convertRectFromScreen:NSMakeRect(aPt.x, aPt.y, 0, 0)].origin;
}
// Implements an NSPoint equivalent of -[NSWindow convertRectToScreen:].
@ -179,8 +181,10 @@ class nsCocoaUtils {
return [aWindow convertRectToScreen:NSMakeRect(aPt.x, aPt.y, 0, 0)].origin;
}
static NSRect DevPixelsToCocoaPoints(const LayoutDeviceIntRect& aRect, CGFloat aBackingScale) {
return NSMakeRect((CGFloat)aRect.X() / aBackingScale, (CGFloat)aRect.Y() / aBackingScale,
static NSRect DevPixelsToCocoaPoints(const LayoutDeviceIntRect& aRect,
CGFloat aBackingScale) {
return NSMakeRect((CGFloat)aRect.X() / aBackingScale,
(CGFloat)aRect.Y() / aBackingScale,
(CGFloat)aRect.Width() / aBackingScale,
(CGFloat)aRect.Height() / aBackingScale);
}
@ -207,14 +211,14 @@ class nsCocoaUtils {
static NSPoint GeckoPointToCocoaPoint(const mozilla::DesktopPoint& aPoint);
// Converts aGeckoRect in dev pixels to points in Cocoa coordinates
static NSRect GeckoRectToCocoaRectDevPix(const mozilla::LayoutDeviceIntRect& aGeckoRect,
CGFloat aBackingScale);
static NSRect GeckoRectToCocoaRectDevPix(
const mozilla::LayoutDeviceIntRect& aGeckoRect, CGFloat aBackingScale);
// See explanation for geckoRectToCocoaRect, guess what this does...
static mozilla::DesktopIntRect CocoaRectToGeckoRect(const NSRect& cocoaRect);
static mozilla::LayoutDeviceIntRect CocoaRectToGeckoRectDevPix(const NSRect& aCocoaRect,
CGFloat aBackingScale);
static mozilla::LayoutDeviceIntRect CocoaRectToGeckoRectDevPix(
const NSRect& aCocoaRect, CGFloat aBackingScale);
// Gives the location for the event in screen coordinates. Do not call this
// unless the window the event was originally targeted at is still alive!
@ -225,10 +229,10 @@ class nsCocoaUtils {
// is for the window. Does not take window z-order into account.
static BOOL IsEventOverWindow(NSEvent* anEvent, NSWindow* aWindow);
// Events are set up so that their coordinates refer to the window to which they
// were originally sent. If we reroute the event somewhere else, we'll have
// to get the window coordinates this way. Do not call this unless the window
// the event was originally targeted at is still alive!
// Events are set up so that their coordinates refer to the window to which
// they were originally sent. If we reroute the event somewhere else, we'll
// have to get the window coordinates this way. Do not call this unless the
// window the event was originally targeted at is still alive!
static NSPoint EventLocationForWindow(NSEvent* anEvent, NSWindow* aWindow);
static BOOL IsMomentumScrollEvent(NSEvent* aEvent);
@ -248,12 +252,13 @@ class nsCocoaUtils {
static void PrepareForNativeAppModalDialog();
static void CleanUpAfterNativeAppModalDialog();
// 3 utility functions to go from a frame of imgIContainer to CGImage and then to NSImage
// Convert imgIContainer -> CGImageRef, caller owns result
// 3 utility functions to go from a frame of imgIContainer to CGImage and then
// to NSImage Convert imgIContainer -> CGImageRef, caller owns result
/** Creates a <code>CGImageRef</code> from a frame contained in an <code>imgIContainer</code>.
Copies the pixel data from the indicated frame of the <code>imgIContainer</code> into a new
<code>CGImageRef</code>. The caller owns the <code>CGImageRef</code>.
/** Creates a <code>CGImageRef</code> from a frame contained in an
<code>imgIContainer</code>. Copies the pixel data from the indicated frame
of the <code>imgIContainer</code> into a new <code>CGImageRef</code>. The
caller owns the <code>CGImageRef</code>.
@param aFrame the frame to convert
@param aResult the resulting CGImageRef
@param aIsEntirelyBlack an outparam that, if non-null, will be set to a
@ -261,44 +266,48 @@ class nsCocoaUtils {
pixels are zero
@return NS_OK if the conversion worked, NS_ERROR_FAILURE otherwise
*/
static nsresult CreateCGImageFromSurface(SourceSurface* aSurface, CGImageRef* aResult,
static nsresult CreateCGImageFromSurface(SourceSurface* aSurface,
CGImageRef* aResult,
bool* aIsEntirelyBlack = nullptr);
/** Creates a Cocoa <code>NSImage</code> from a <code>CGImageRef</code>.
Copies the pixel data from the <code>CGImageRef</code> into a new <code>NSImage</code>.
The caller owns the <code>NSImage</code>.
Copies the pixel data from the <code>CGImageRef</code> into a new
<code>NSImage</code>. The caller owns the <code>NSImage</code>.
@param aInputImage the image to convert
@param aResult the resulting NSImage
@return NS_OK if the conversion worked, NS_ERROR_FAILURE otherwise
*/
static nsresult CreateNSImageFromCGImage(CGImageRef aInputImage, NSImage** aResult);
static nsresult CreateNSImageFromCGImage(CGImageRef aInputImage,
NSImage** aResult);
/** Creates a Cocoa <code>NSImage</code> from a frame of an <code>imgIContainer</code>.
Combines the two methods above. The caller owns the <code>NSImage</code>.
/** Creates a Cocoa <code>NSImage</code> from a frame of an
<code>imgIContainer</code>. Combines the two methods above. The caller owns
the <code>NSImage</code>.
@param aImage the image to extract a frame from
@param aWhichFrame the frame to extract (see imgIContainer FRAME_*)
@param aComputedStyle the ComputedStyle of the element that the image is for, to support SVG
context paint properties, can be null
@param aComputedStyle the ComputedStyle of the element that the image is
for, to support SVG context paint properties, can be null
@param aResult the resulting NSImage
@param scaleFactor the desired scale factor of the NSImage (2 for a retina display)
@param scaleFactor the desired scale factor of the NSImage (2 for a retina
display)
@param aIsEntirelyBlack an outparam that, if non-null, will be set to a
bool that indicates whether the RGB values on all
pixels are zero
@return NS_OK if the conversion worked, NS_ERROR_FAILURE otherwise
*/
static nsresult CreateNSImageFromImageContainer(imgIContainer* aImage, uint32_t aWhichFrame,
const nsPresContext* aPresContext,
const mozilla::ComputedStyle* aComputedStyle,
NSImage** aResult, CGFloat scaleFactor,
bool* aIsEntirelyBlack = nullptr);
static nsresult CreateNSImageFromImageContainer(
imgIContainer* aImage, uint32_t aWhichFrame,
const nsPresContext* aPresContext,
const mozilla::ComputedStyle* aComputedStyle, NSImage** aResult,
CGFloat scaleFactor, bool* aIsEntirelyBlack = nullptr);
/** Creates a Cocoa <code>NSImage</code> from a frame of an <code>imgIContainer</code>.
The new <code>NSImage</code> will have both a regular and HiDPI representation.
The caller owns the <code>NSImage</code>.
/** Creates a Cocoa <code>NSImage</code> from a frame of an
<code>imgIContainer</code>. The new <code>NSImage</code> will have both a
regular and HiDPI representation. The caller owns the <code>NSImage</code>.
@param aImage the image to extract a frame from
@param aWhichFrame the frame to extract (see imgIContainer FRAME_*)
@param aComputedStyle the ComputedStyle of the element that the image is for, to support SVG
context paint properties, can be null
@param aComputedStyle the ComputedStyle of the element that the image is
for, to support SVG context paint properties, can be null
@param aResult the resulting NSImage
@param aIsEntirelyBlack an outparam that, if non-null, will be set to a
bool that indicates whether the RGB values on all
@ -306,7 +315,8 @@ class nsCocoaUtils {
@return NS_OK if the conversion worked, NS_ERROR_FAILURE otherwise
*/
static nsresult CreateDualRepresentationNSImageFromImageContainer(
imgIContainer* aImage, uint32_t aWhichFrame, const nsPresContext* aPresContext,
imgIContainer* aImage, uint32_t aWhichFrame,
const nsPresContext* aPresContext,
const mozilla::ComputedStyle* aComputedStyle, NSImage** aResult,
bool* aIsEntirelyBlack = nullptr);
@ -335,31 +345,35 @@ class nsCocoaUtils {
* Just copies values between the two types; it does no coordinate-system
* conversion, so both rects must have the same coordinate origin/direction.
*/
static void GeckoRectToNSRect(const nsIntRect& aGeckoRect, NSRect& aOutCocoaRect);
static void GeckoRectToNSRect(const nsIntRect& aGeckoRect,
NSRect& aOutCocoaRect);
/**
* Returns Gecko rect for aCocoaRect.
* Just copies values between the two types; it does no coordinate-system
* conversion, so both rects must have the same coordinate origin/direction.
*/
static void NSRectToGeckoRect(const NSRect& aCocoaRect, nsIntRect& aOutGeckoRect);
static void NSRectToGeckoRect(const NSRect& aCocoaRect,
nsIntRect& aOutGeckoRect);
/**
* Makes NSEvent instance for aEventTytpe and aEvent.
*/
static NSEvent* MakeNewCocoaEventWithType(NSEventType aEventType, NSEvent* aEvent);
static NSEvent* MakeNewCocoaEventWithType(NSEventType aEventType,
NSEvent* aEvent);
/**
* Makes a cocoa event from a widget keyboard event.
*/
static NSEvent* MakeNewCococaEventFromWidgetEvent(const mozilla::WidgetKeyboardEvent& aKeyEvent,
NSInteger aWindowNumber,
NSGraphicsContext* aContext);
static NSEvent* MakeNewCococaEventFromWidgetEvent(
const mozilla::WidgetKeyboardEvent& aKeyEvent, NSInteger aWindowNumber,
NSGraphicsContext* aContext);
/**
* Initializes WidgetInputEvent for aNativeEvent or aModifiers.
*/
static void InitInputEvent(mozilla::WidgetInputEvent& aInputEvent, NSEvent* aNativeEvent);
static void InitInputEvent(mozilla::WidgetInputEvent& aInputEvent,
NSEvent* aNativeEvent);
/**
* Converts the native modifiers from aNativeEvent into WidgetMouseEvent
@ -385,7 +399,8 @@ class nsCocoaUtils {
* commands based on selectors. This collects any such commands in the
* provided array.
*/
static void GetCommandsFromKeyEvent(NSEvent* aEvent, nsTArray<KeyBindingsCommand>& aCommands);
static void GetCommandsFromKeyEvent(NSEvent* aEvent,
nsTArray<KeyBindingsCommand>& aCommands);
/**
* Converts the string name of a Gecko key (like "VK_HOME") to the
@ -478,20 +493,23 @@ class nsCocoaUtils {
static mozilla::PanGestureInput CreatePanGestureEvent(
NSEvent* aNativeEvent, mozilla::TimeStamp aTimeStamp,
const mozilla::ScreenPoint& aPanStartPoint, const mozilla::ScreenPoint& aPreciseDelta,
const mozilla::gfx::IntPoint& aLineOrPageDelta, mozilla::Modifiers aModifiers);
const mozilla::ScreenPoint& aPanStartPoint,
const mozilla::ScreenPoint& aPreciseDelta,
const mozilla::gfx::IntPoint& aLineOrPageDelta,
mozilla::Modifiers aModifiers);
/**
* Return true if aAvailableType is a vaild NSPasteboard type.
*/
static bool IsValidPasteboardType(NSString* aAvailableType, bool aAllowFileURL);
static bool IsValidPasteboardType(NSString* aAvailableType,
bool aAllowFileURL);
/**
* Set data for specific type from NSPasteboardItem to Transferable.
*/
static void SetTransferDataForTypeFromPasteboardItem(nsITransferable* aTransferable,
const nsCString& aFlavor,
NSPasteboardItem* aItem);
static void SetTransferDataForTypeFromPasteboardItem(
nsITransferable* aTransferable, const nsCString& aFlavor,
NSPasteboardItem* aItem);
private:
/**
@ -519,21 +537,23 @@ class nsCocoaUtils {
* or ResolveVideoCapturePromises) to be used as
* the requestAccessForMediaType callback.
*/
static nsresult RequestCapturePermission(NSString* aType, RefPtr<Promise>& aPromise,
static nsresult RequestCapturePermission(NSString* aType,
RefPtr<Promise>& aPromise,
PromiseArray& aPromiseList,
void (^aHandler)(BOOL granted));
/**
* Resolves the pending promises that are waiting for a response
* to a request video or audio capture permission.
*/
static void ResolveMediaCapturePromises(bool aGranted, PromiseArray& aPromiseList);
static void ResolveMediaCapturePromises(bool aGranted,
PromiseArray& aPromiseList);
/**
* Get string data for a specific type from NSPasteboardItem.
*/
static NSString* GetStringForTypeFromPasteboardItem(NSPasteboardItem* aItem,
const NSString* aType,
bool aAllowFileURL = false);
static NSString* GetStringForTypeFromPasteboardItem(
NSPasteboardItem* aItem, const NSString* aType,
bool aAllowFileURL = false);
/**
* Get the file path from NSPasteboardItem.

View File

@ -23,7 +23,6 @@
#include "nsIInterfaceRequestorUtils.h"
#include "nsIAppWindow.h"
#include "nsToolkit.h"
#include "nsTouchBarNativeAPIDefines.h"
#include "nsPIDOMWindow.h"
#include "nsThreadUtils.h"
#include "nsMenuBarX.h"
@ -35,7 +34,6 @@
#include "nsCocoaFeatures.h"
#include "nsIScreenManager.h"
#include "nsIWidgetListener.h"
#include "SDKDeclarations.h"
#include "VibrancyManager.h"
#include "nsPresContext.h"
#include "nsDocShell.h"
@ -3948,12 +3946,7 @@ static const NSString* kStateWantsTitleDrawn = @"wantsTitleDrawn";
// NSWindows that this view is used in, including the floating full screen
// toolbar window. The drawing bug was filed as FB9056136. See bug 1700211
// for more details.
#if !defined(MAC_OS_VERSION_11_0) || \
MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_VERSION_11_0
if (nsCocoaFeatures::OnBigSurOrLater()) {
#else
if (@available(macOS 11.0, *)) {
#endif
aWindow.titlebarSeparatorStyle = NSTitlebarSeparatorStyleNone;
}
}
@ -4046,12 +4039,7 @@ static const NSString* kStateWantsTitleDrawn = @"wantsTitleDrawn";
mInitialTitlebarHeight = [self titlebarHeight];
[self setTitlebarAppearsTransparent:YES];
#if !defined(MAC_OS_VERSION_11_0) || \
MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_VERSION_11_0
if (nsCocoaFeatures::OnBigSurOrLater()) {
#else
if (@available(macOS 11.0, *)) {
#endif
self.titlebarSeparatorStyle = NSTitlebarSeparatorStyleNone;
}
[self updateTitlebarView];

View File

@ -19,7 +19,6 @@
#include "mozilla/StaticPrefs_widget.h"
#include "mozilla/Telemetry.h"
#include "mozilla/widget/WidgetMessageUtils.h"
#include "SDKDeclarations.h"
#import <Cocoa/Cocoa.h>
#import <AppKit/NSColor.h>

View File

@ -17,7 +17,6 @@
#include "nsGkAtoms.h"
#include "nsObjCExceptions.h"
#include "nsThreadUtils.h"
#include "nsTouchBarNativeAPIDefines.h"
#include "nsIContent.h"
#include "nsIWidget.h"

View File

@ -39,7 +39,6 @@
#include "mozilla/StaticPrefs_widget.h"
#include "nsLookAndFeel.h"
#include "MacThemeGeometryType.h"
#include "SDKDeclarations.h"
#include "VibrancyManager.h"
#include "gfxContext.h"

View File

@ -8,7 +8,6 @@
#import <Cocoa/Cocoa.h>
#include "SDKDeclarations.h"
#include "mozilla/ColorScheme.h"
enum ColorName {
@ -41,16 +40,17 @@ inline float NativeGreyColorAsFloat(ColorName name, BOOL isMain) {
return NativeGreyColorAsInt(name, isMain) / 255.0f;
}
inline void DrawNativeGreyColorInRect(CGContextRef context, ColorName name, CGRect rect,
BOOL isMain) {
inline void DrawNativeGreyColorInRect(CGContextRef context, ColorName name,
CGRect rect, BOOL isMain) {
float grey = NativeGreyColorAsFloat(name, isMain);
CGContextSetRGBFillColor(context, grey, grey, grey, 1.0f);
CGContextFillRect(context, rect);
}
inline NSAppearance* NSAppearanceForColorScheme(mozilla::ColorScheme aScheme) {
NSAppearanceName appearanceName =
aScheme == mozilla::ColorScheme::Light ? NSAppearanceNameAqua : NSAppearanceNameDarkAqua;
NSAppearanceName appearanceName = aScheme == mozilla::ColorScheme::Light
? NSAppearanceNameAqua
: NSAppearanceNameDarkAqua;
return [NSAppearance appearanceNamed:appearanceName];
}

View File

@ -9,9 +9,9 @@
#include "nsITouchBarHelper.h"
#include "nsTouchBarInput.h"
#include "nsTouchBarNativeAPIDefines.h"
const NSTouchBarItemIdentifier kTouchBarBaseIdentifier = @"com.mozilla.firefox.touchbar";
const NSTouchBarItemIdentifier kTouchBarBaseIdentifier =
@"com.mozilla.firefox.touchbar";
/**
* Our TouchBar is its own delegate. This is adequate for our purposes,
@ -34,7 +34,8 @@ const NSTouchBarItemIdentifier kTouchBarBaseIdentifier = @"com.mozilla.firefox.t
* Contains TouchBarInput representations of the inputs currently in
* the Touch Bar. Populated in `init` and updated by nsITouchBarUpdater.
*/
@property(strong) NSMutableDictionary<NSTouchBarItemIdentifier, TouchBarInput*>* mappedLayoutItems;
@property(strong) NSMutableDictionary<NSTouchBarItemIdentifier, TouchBarInput*>*
mappedLayoutItems;
/**
* Stores buttons displayed in a NSScrollView. They must be stored separately
@ -42,7 +43,8 @@ const NSTouchBarItemIdentifier kTouchBarBaseIdentifier = @"com.mozilla.firefox.t
* cannot be retrieved with [NSTouchBar itemForIdentifier].
*/
@property(strong)
NSMutableDictionary<NSTouchBarItemIdentifier, NSCustomTouchBarItem*>* scrollViewButtons;
NSMutableDictionary<NSTouchBarItemIdentifier, NSCustomTouchBarItem*>*
scrollViewButtons;
/**
* Returns an instance of nsTouchBar based on implementation details
@ -104,8 +106,10 @@ const NSTouchBarItemIdentifier kTouchBarBaseIdentifier = @"com.mozilla.firefox.t
withIdentifier:(NSTouchBarItemIdentifier)aIdentifier;
- (void)updateScrollView:(NSCustomTouchBarItem*)aScrollViewItem
withIdentifier:(NSTouchBarItemIdentifier)aIdentifier;
- (void)updateLabel:(NSTextField*)aLabel withIdentifier:(NSTouchBarItemIdentifier)aIdentifier;
- (NSTouchBarItem*)makeShareScrubberForIdentifier:(NSTouchBarItemIdentifier)aIdentifier;
- (void)updateLabel:(NSTextField*)aLabel
withIdentifier:(NSTouchBarItemIdentifier)aIdentifier;
- (NSTouchBarItem*)makeShareScrubberForIdentifier:
(NSTouchBarItemIdentifier)aIdentifier;
/**
* If aShowing is true, aPopover is shown. Otherwise, it is hidden.
@ -125,9 +129,10 @@ const NSTouchBarItemIdentifier kTouchBarBaseIdentifier = @"com.mozilla.firefox.t
- (NSArray*)itemsForSharingServicePickerTouchBarItem:
(NSSharingServicePickerTouchBarItem*)aPickerTouchBarItem;
- (NSArray<NSSharingService*>*)sharingServicePicker:(NSSharingServicePicker*)aSharingServicePicker
sharingServicesForItems:(NSArray*)aItems
proposedSharingServices:(NSArray<NSSharingService*>*)aProposedServices;
- (NSArray<NSSharingService*>*)
sharingServicePicker:(NSSharingServicePicker*)aSharingServicePicker
sharingServicesForItems:(NSArray*)aItems
proposedSharingServices:(NSArray<NSSharingService*>*)aProposedServices;
- (void)releaseJSObjects;

View File

@ -8,7 +8,6 @@
#import <Cocoa/Cocoa.h>
#include "nsITouchBarInput.h"
#include "nsTouchBarNativeAPIDefines.h"
#include "nsCOMPtr.h"
using namespace mozilla::dom;
@ -73,8 +72,10 @@ class nsTouchBarInputIcon;
* TouchBarInput's nativeIdentifier (e.g. nsTouchBarUpdater looking up a
* popover in mappedLayoutItems).
*/
+ (NSTouchBarItemIdentifier)nativeIdentifierWithType:(NSString*)aType withKey:(NSString*)aKey;
+ (NSTouchBarItemIdentifier)nativeIdentifierWithXPCOM:(nsCOMPtr<nsITouchBarInput>)aInput;
+ (NSTouchBarItemIdentifier)nativeIdentifierWithType:(NSString*)aType
withKey:(NSString*)aKey;
+ (NSTouchBarItemIdentifier)nativeIdentifierWithXPCOM:
(nsCOMPtr<nsITouchBarInput>)aInput;
// Non-JS scrubber implemention for the Share Scrubber,
// since it is defined by an Apple API.

View File

@ -14,7 +14,6 @@
#include "mozilla/widget/IconLoader.h"
#include "nsTouchBarInput.h"
#include "nsTouchBarNativeAPIDefines.h"
using namespace mozilla::dom;

View File

@ -1,67 +0,0 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#ifndef nsTouchBarNativeAPIDefines_h
#define nsTouchBarNativeAPIDefines_h
#import <Cocoa/Cocoa.h>
#if !defined(MAC_OS_X_VERSION_10_12_2) || MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_12_2
@interface NSApplication (TouchBarMenu)
- (IBAction)toggleTouchBarCustomizationPalette:(id)sender;
@end
typedef NSString* NSTouchBarItemIdentifier;
__attribute__((weak_import))
@interface NSTouchBarItem : NSObject
@property(readonly) NSView* view;
@property(readonly) NSString* customizationLabel;
- (instancetype)initWithIdentifier:(NSTouchBarItemIdentifier)aIdentifier;
@end
@protocol NSSharingServicePickerTouchBarItemDelegate
@end
__attribute__((weak_import))
@interface NSSharingServicePickerTouchBarItem : NSTouchBarItem
@property(strong) id<NSSharingServicePickerTouchBarItemDelegate> delegate;
@property(strong) NSImage* buttonImage;
@end
__attribute__((weak_import))
@interface NSCustomTouchBarItem : NSTouchBarItem
@property(strong) NSView* view;
@property(strong) NSString* customizationLabel;
@end
@protocol NSTouchBarDelegate
@end
typedef NSString* NSTouchBarCustomizationIdentifier;
__attribute__((weak_import))
@interface NSTouchBar : NSObject
@property(strong) NSArray<NSTouchBarItemIdentifier>* defaultItemIdentifiers;
@property(strong) id<NSTouchBarDelegate> delegate;
@property(strong) NSTouchBarCustomizationIdentifier customizationIdentifier;
@property(strong) NSArray<NSTouchBarItemIdentifier>* customizationAllowedItemIdentifiers;
- (NSTouchBarItem*)itemForIdentifier:(NSTouchBarItemIdentifier)aIdentifier;
@end
__attribute__((weak_import))
@interface NSPopoverTouchBarItem : NSTouchBarItem
@property(strong) NSString* customizationLabel;
@property(strong) NSView* collapsedRepresentation;
@property(strong) NSImage* collapsedRepresentationImage;
@property(strong) NSString* collapsedRepresentationLabel;
@property(strong) NSTouchBar* popoverTouchBar;
@property BOOL showsCloseButton;
- (void)showPopover:(id)sender;
- (void)dismissPopover:(id)sender;
@end
@interface NSButton (TouchBarButton)
@property(strong) NSColor* bezelColor;
@end
#endif // !defined(MAC_OS_X_VERSION_10_12_2)
#endif // nsTouchBarNativeAPIDefines_h

View File

@ -7,7 +7,6 @@
#include "nsTouchBar.h"
#include "nsTouchBarInput.h"
#include "nsTouchBarUpdater.h"
#include "nsTouchBarNativeAPIDefines.h"
#include "nsIBaseWindow.h"
#include "nsIWidget.h"
@ -15,13 +14,6 @@
// defined in nsCocoaWindow.mm.
extern BOOL sTouchBarIsInitialized;
#if !defined(MAC_OS_X_VERSION_10_12_2) || \
MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_12_2
@interface BaseWindow (NSTouchBarProvider)
@property(strong) NSTouchBar* touchBar;
@end
#endif
NS_IMPL_ISUPPORTS(nsTouchBarUpdater, nsITouchBarUpdater);
NS_IMETHODIMP