Bug 1401641: Avoid invalidations on macOS when setting window titles when titles aren't being displayed. r=mstange
authorStephen A Pohl <spohl.mozilla.bugs@gmail.com>
Thu, 21 Sep 2017 15:13:32 -0400
changeset 433107 2abc46cea00b3a44f2a0118fbd6851024290399b
parent 433106 60f397f57cd4809647dd8572ffebe704bd6f03e2
child 433108 0fbe00ad02037d84ac754ee943e69d2f22e92d06
push id8114
push userjlorenzo@mozilla.com
push dateThu, 02 Nov 2017 16:33:21 +0000
treeherdermozilla-beta@73e0d89a540f [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmstange
bugs1401641
milestone58.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1401641: Avoid invalidations on macOS when setting window titles when titles aren't being displayed. r=mstange
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)