commit 56eaa2dbf1ffc390574b98398c51f64cc67ef9a7
parent 0774d2bf0950e741640fd5fdb504cc1f4d51d5ec
Author: Markus Stange <mstange.moz@gmail.com>
Date: Thu, 23 Oct 2025 04:49:50 +0000
Bug 1820168 - Remove ObjC exception guards in nsCursorManager methods. r=mac-reviewers,bradwerth
These guards are only needed at the boundary to C++, see https://bugzilla.mozilla.org/show_bug.cgi?id=1693392 .
Differential Revision: https://phabricator.services.mozilla.com/D172479
Diffstat:
1 file changed, 0 insertions(+), 36 deletions(-)
diff --git a/widget/cocoa/nsCursorManager.mm b/widget/cocoa/nsCursorManager.mm
@@ -51,28 +51,18 @@ static constexpr nsCursor kCustomCursor = eCursorCount;
@implementation nsCursorManager
+ (nsCursorManager*)sharedInstance {
- NS_OBJC_BEGIN_TRY_BLOCK_RETURN;
-
if (!gInstance) {
gInstance = [[nsCursorManager alloc] init];
}
return gInstance;
-
- NS_OBJC_END_TRY_BLOCK_RETURN(nil);
}
+ (void)dispose {
- NS_OBJC_BEGIN_TRY_IGNORE_BLOCK;
-
[gInstance release];
gInstance = nil;
-
- NS_OBJC_END_TRY_IGNORE_BLOCK;
}
+ (nsMacCursor*)createCursor:(enum nsCursor)aCursor {
- NS_OBJC_BEGIN_TRY_BLOCK_RETURN;
-
switch (aCursor) {
case eCursor_standard:
return [nsMacCursor cursorWithCursor:[NSCursor arrowCursor] type:aCursor];
@@ -223,35 +213,23 @@ static constexpr nsCursor kCustomCursor = eCursorCount;
default:
return [nsMacCursor cursorWithCursor:[NSCursor arrowCursor] type:aCursor];
}
-
- NS_OBJC_END_TRY_BLOCK_RETURN(nil);
}
- (id)init {
- NS_OBJC_BEGIN_TRY_BLOCK_RETURN;
-
if ((self = [super init])) {
mCursors = [[NSMutableDictionary alloc] initWithCapacity:25];
}
return self;
-
- NS_OBJC_END_TRY_BLOCK_RETURN(nil);
}
- (nsresult)setNonCustomCursor:(const nsIWidget::Cursor&)aCursor {
- NS_OBJC_BEGIN_TRY_BLOCK_RETURN;
-
[self setMacCursor:[self getCursor:aCursor.mDefaultCursor]];
sCurrentCursor = aCursor;
return NS_OK;
-
- NS_OBJC_END_TRY_BLOCK_RETURN(NS_ERROR_FAILURE);
}
- (nsresult)setMacCursor:(nsMacCursor*)aMacCursor {
- NS_OBJC_BEGIN_TRY_BLOCK_RETURN;
-
nsCursor oldType = [mCurrentMacCursor type];
nsCursor newType = [aMacCursor type];
if (oldType != newType) {
@@ -271,15 +249,11 @@ static constexpr nsCursor kCustomCursor = eCursorCount;
}
return NS_OK;
-
- NS_OBJC_END_TRY_BLOCK_RETURN(NS_ERROR_FAILURE);
}
- (nsresult)setCustomCursor:(const nsIWidget::Cursor&)aCursor
widgetScaleFactor:(CGFloat)scaleFactor
forceUpdate:(bool)aForceUpdate {
- NS_OBJC_BEGIN_TRY_BLOCK_RETURN;
-
// As the user moves the mouse, this gets called repeatedly with the same
// aCursorImage
if (!aForceUpdate && sCurrentCursor == aCursor &&
@@ -328,13 +302,9 @@ static constexpr nsCursor kCustomCursor = eCursorCount;
type:kCustomCursor]];
[cursorImage release];
return NS_OK;
-
- NS_OBJC_END_TRY_BLOCK_RETURN(NS_ERROR_FAILURE);
}
- (nsMacCursor*)getCursor:(enum nsCursor)aCursor {
- NS_OBJC_BEGIN_TRY_BLOCK_RETURN;
-
nsMacCursor* result =
[mCursors objectForKey:[NSNumber numberWithInt:aCursor]];
if (!result) {
@@ -342,20 +312,14 @@ static constexpr nsCursor kCustomCursor = eCursorCount;
[mCursors setObject:result forKey:[NSNumber numberWithInt:aCursor]];
}
return result;
-
- NS_OBJC_END_TRY_BLOCK_RETURN(nil);
}
- (void)dealloc {
- NS_OBJC_BEGIN_TRY_IGNORE_BLOCK;
-
[mCurrentMacCursor unset];
[mCurrentMacCursor release];
[mCursors release];
sCurrentCursor = {};
[super dealloc];
-
- NS_OBJC_END_TRY_IGNORE_BLOCK;
}
@end