Skip to content

Commit

Permalink
Bug 1736049 - Stop calling [[NSCursor currentCursor] set] on every …
Browse files Browse the repository at this point in the history
…mouse move. r=emilio

This was only necessary when we had binary plug-ins overriding the cursor from under us.
We no longer support plug-ins.

Calling -[NSCursor set] has a performance cost on macOS Monterey when
cursor accessibility coloring is enabled, so we want to avoid calling it
unnecessarily. It also leaks memory in the current Monterey Beta (see
bug 1735345), so calling it less often will leak less memory.

I have checked the testcases of bug 496601 and of bug 1423275, they still
work as expected with this fix.

Differential Revision: https://phabricator.services.mozilla.com/D128612
  • Loading branch information
mstange committed Oct 15, 2021
1 parent 262496d commit a2e24ac
Showing 1 changed file with 0 additions and 6 deletions.
6 changes: 0 additions & 6 deletions widget/cocoa/nsCursorManager.mm
Original file line number Diff line number Diff line change
Expand Up @@ -211,11 +211,6 @@ - (nsresult)setNonCustomCursor:(const nsIWidget::Cursor&)aCursor {
- (nsresult)setMacCursor:(nsMacCursor*)aMacCursor {
NS_OBJC_BEGIN_TRY_BLOCK_RETURN;

// Some plugins mess with our cursors and set a cursor that even
// [NSCursor currentCursor] doesn't know about. In case that happens, just
// reset the state.
[[NSCursor currentCursor] set];

nsCursor oldType = [mCurrentMacCursor type];
nsCursor newType = [aMacCursor type];
if (oldType != newType) {
Expand Down Expand Up @@ -245,7 +240,6 @@ - (nsresult)setCustomCursor:(const nsIWidget::Cursor&)aCursor

// As the user moves the mouse, this gets called repeatedly with the same aCursorImage
if (sCurrentCursor == aCursor && sCurrentCursorScaleFactor == scaleFactor && mCurrentMacCursor) {
[self setMacCursor:mCurrentMacCursor];
return NS_OK;
}

Expand Down

0 comments on commit a2e24ac

Please sign in to comment.