Bug 1401641 - Avoid invalidations on macOS when setting window titles when titles aren't being displayed. r=mstange, a=sledru
authorStephen A Pohl <spohl.mozilla.bugs@gmail.com>
Thu, 21 Sep 2017 15:13:32 -0400
changeset 431762 e4c1277e5d2cb18fd16ba6b0d22d3a652bf030f6
parent 431761 a747acffe3e8d71975d3548289691fce8cf87672
child 431763 0d4f0c6d3fd205d5da5d1d53079ea5cdd638d521
push id7801
push userryanvm@gmail.com
push dateFri, 22 Sep 2017 16:55:06 +0000
treeherdermozilla-beta@0d4f0c6d3fd2 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmstange, sledru
bugs1401641
milestone57.0
Bug 1401641 - Avoid invalidations on macOS when setting window titles when titles aren't being displayed. r=mstange, a=sledru
widget/cocoa/nsCocoaWindow.mm
--- a/widget/cocoa/nsCocoaWindow.mm
+++ b/widget/cocoa/nsCocoaWindow.mm
@@ -1857,17 +1857,24 @@ nsCocoaWindow::SetTitle(const nsAString&
   if (!mWindow) {
     return NS_OK;
   }
 
   const nsString& strTitle = PromiseFlatString(aTitle);
   const unichar* uniTitle = reinterpret_cast<const unichar*>(strTitle.get());
   NSString* title = [NSString stringWithCharacters:uniTitle
                                             length:strTitle.Length()];
-  [mWindow setTitle:title];
+  if ([mWindow drawsContentsIntoWindowFrame] && ![mWindow wantsTitleDrawn]) {
+    // Don't cause invalidations when the title isn't displayed.
+    [mWindow disableSetNeedsDisplay];
+    [mWindow setTitle:title];
+    [mWindow enableSetNeedsDisplay];
+  } else {
+    [mWindow setTitle:title];
+  }
 
   return NS_OK;
 
   NS_OBJC_END_TRY_ABORT_BLOCK_NSRESULT;
 }
 
 void
 nsCocoaWindow::Invalidate(const LayoutDeviceIntRect& aRect)