From 7540dfbeba00b68c27d9e8c97ae4df2f0e450468 Mon Sep 17 00:00:00 2001 From: Markus Stange Date: Mon, 22 Apr 2019 19:26:00 +0000 Subject: [PATCH] Bug 1533562 - Remove synchronous repaint capability of setTitlebarNeedsDisplayInRect:sync: and also remove the rect parameter because we always pass the same value to it. r=spohl The synchronous paint was only needed a long time ago when we were calling this method during drawRect. We're not doing that any more, we usually call it from viewWillDraw now. But even at the time, forcing a synchronous paint *within* a paint was extremely sketchy, so best just to remove the code. Differential Revision: https://phabricator.services.mozilla.com/D22642 --HG-- extra : moz-landing-system : lando --- widget/cocoa/nsCocoaWindow.h | 3 +-- widget/cocoa/nsCocoaWindow.mm | 22 +++++----------------- 2 files changed, 6 insertions(+), 19 deletions(-) diff --git a/widget/cocoa/nsCocoaWindow.h b/widget/cocoa/nsCocoaWindow.h index c2e4ff595c83..ad4327b1acc6 100644 --- a/widget/cocoa/nsCocoaWindow.h +++ b/widget/cocoa/nsCocoaWindow.h @@ -170,8 +170,7 @@ typedef struct _nsCocoaWindowList { - (CGFloat)unifiedToolbarHeight; - (CGFloat)titlebarHeight; - (NSRect)titlebarRect; -- (void)setTitlebarNeedsDisplayInRect:(NSRect)aRect sync:(BOOL)aSync; -- (void)setTitlebarNeedsDisplayInRect:(NSRect)aRect; +- (void)setTitlebarNeedsDisplay; - (void)setDrawsContentsIntoWindowFrame:(BOOL)aState; - (void)setSheetAttachmentPosition:(CGFloat)aY; - (CGFloat)sheetAttachmentPosition; diff --git a/widget/cocoa/nsCocoaWindow.mm b/widget/cocoa/nsCocoaWindow.mm index 4584c10fe792..4a087860a69f 100644 --- a/widget/cocoa/nsCocoaWindow.mm +++ b/widget/cocoa/nsCocoaWindow.mm @@ -3181,23 +3181,14 @@ static const NSString* kStateCollectionBehavior = @"collectionBehavior"; NS_OBJC_END_TRY_ABORT_BLOCK_NIL; } -- (void)setTitlebarNeedsDisplayInRect:(NSRect)aRect { - [self setTitlebarNeedsDisplayInRect:aRect sync:NO]; -} - -- (void)setTitlebarNeedsDisplayInRect:(NSRect)aRect sync:(BOOL)aSync { - NSRect titlebarRect = [self titlebarRect]; - NSRect rect = NSIntersectionRect(titlebarRect, aRect); +- (void)setTitlebarNeedsDisplay { + NSRect rect = [self titlebarRect]; if (NSIsEmptyRect(rect)) return; NSView* borderView = [[self contentView] superview]; if (!borderView) return; - if (aSync) { - [borderView displayRect:rect]; - } else { - [borderView setNeedsDisplayInRect:rect]; - } + [borderView setNeedsDisplayInRect:rect]; } - (NSRect)titlebarRect { @@ -3228,10 +3219,7 @@ static const NSString* kStateCollectionBehavior = @"collectionBehavior"; mUnifiedToolbarHeight = aHeight; if (![self drawsContentsIntoWindowFrame]) { - // Redraw the title bar. If we're inside painting, we'll do it right now, - // otherwise we'll just invalidate it. - BOOL needSyncRedraw = ([NSView focusView] != nil); - [self setTitlebarNeedsDisplayInRect:[self titlebarRect] sync:needSyncRedraw]; + [self setTitlebarNeedsDisplay]; } } @@ -3263,7 +3251,7 @@ static const NSString* kStateCollectionBehavior = @"collectionBehavior"; - (void)setWantsTitleDrawn:(BOOL)aDrawTitle { [super setWantsTitleDrawn:aDrawTitle]; - [self setTitlebarNeedsDisplayInRect:[self titlebarRect]]; + [self setTitlebarNeedsDisplay]; } - (void)setSheetAttachmentPosition:(CGFloat)aY {