Bug 1097354 - Silence "adding an unknown subview" warning by calling _addKnownSubview. r=smichaud
authorMarkus Stange <mstange@themasta.com>
Tue, 18 Nov 2014 11:36:07 -0500
changeset 240624 9509628adfe45b496b7b25cce7ce954b7881013f
parent 240623 c7eefbcb8e13a5df76f972bdaae1a5d8181c65a2
child 240625 0092a5e1467dc33582890f06f5a46a95d966ff49
push id4311
push userraliiev@mozilla.com
push dateMon, 12 Jan 2015 19:37:41 +0000
treeherdermozilla-beta@150c9fed433b [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssmichaud
bugs1097354
milestone36.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 1097354 - Silence "adding an unknown subview" warning by calling _addKnownSubview. r=smichaud
widget/cocoa/nsCocoaWindow.mm
--- a/widget/cocoa/nsCocoaWindow.mm
+++ b/widget/cocoa/nsCocoaWindow.mm
@@ -2574,16 +2574,23 @@ GetDPI(NSWindow* aWindow)
 @end
 
 static NSMutableSet *gSwizzledFrameViewClasses = nil;
 
 @interface NSWindow(PrivateSetNeedsDisplayInRectMethod)
  - (void)_setNeedsDisplayInRect:(NSRect)aRect;
 @end
 
+// This method is on NSThemeFrame starting with 10.10, but since NSThemeFrame
+// is not a public class, we declare the method on NSView instead. We only have
+// this declaration in order to avoid compiler warnings.
+@interface NSView(PrivateAddKnownSubviewMethod)
+ - (void)_addKnownSubview:(id)arg1 positioned:(long long)arg2 relativeTo:(id)arg3;
+@end
+
 @interface BaseWindow(Private)
 - (void)removeTrackingArea;
 - (void)cursorUpdated:(NSEvent*)aEvent;
 - (void)updateContentViewSize;
 - (void)reflowTitlebarElements;
 @end
 
 @implementation BaseWindow
@@ -2942,17 +2949,23 @@ static const NSString* kStateShowsToolba
 - (void)setContentView:(NSView*)aView
 {
   [super setContentView:aView];
 
   // Now move the contentView to the bottommost layer so that it's guaranteed
   // to be under the window buttons.
   NSView* frameView = [aView superview];
   [aView removeFromSuperview];
-  [frameView addSubview:aView positioned:NSWindowBelow relativeTo:nil];
+  if ([frameView respondsToSelector:@selector(_addKnownSubview:positioned:relativeTo:)]) {
+    // 10.10 prints a warning when we call addSubview on the frame view, so we
+    // silence the warning by calling a private method instead.
+    [frameView _addKnownSubview:aView positioned:NSWindowBelow relativeTo:nil];
+  } else {
+    [frameView addSubview:aView positioned:NSWindowBelow relativeTo:nil];
+  }
 }
 
 - (NSArray*)titlebarControls
 {
   // Return all subviews of the frameView which are not the content view.
   NSView* frameView = [[self contentView] superview];
   NSMutableArray* array = [[[frameView subviews] mutableCopy] autorelease];
   [array removeObject:[self contentView]];