Index: chrome/browser/ui/cocoa/version_independent_window.mm |
diff --git a/chrome/browser/ui/cocoa/version_independent_window.mm b/chrome/browser/ui/cocoa/version_independent_window.mm |
index 24284a490d064e8b943e5d236653544bd56db79c..cced7573b6823a3af0ed522eb268ce9ecbb8dc1a 100644 |
--- a/chrome/browser/ui/cocoa/version_independent_window.mm |
+++ b/chrome/browser/ui/cocoa/version_independent_window.mm |
@@ -7,6 +7,35 @@ |
#include "base/logging.h" |
#include "base/mac/mac_util.h" |
+// This view always takes the size of its superview. It is intended to be used |
+// as a NSWindow's contentView. It is needed because NSWindow's implementation |
+// explicitly resizes the contentView at inopportune times. |
+@interface FullSizeContentView : NSView |
+@end |
+ |
+namespace { |
+ |
+// Moves subclasses of FullSizeContentView to the back. Maintains the |
+// ordering of the other subviews. |
+// |context| should be an NSArray containing the subviews as they were |
+// previously ordered. |
+// The logic of this function does not work if there is more than 1 subclass of |
+// FullSizeContentView in the subviews being reordered. |
+int ReorderContentViewToBack(id firstView, id secondView, void* context) { |
+ NSArray* subviews = static_cast<NSArray*>(context); |
+ if ([firstView isKindOfClass:[FullSizeContentView class]]) |
Andre
2014/07/17 17:56:16
How about (firstView == [[firstView window] conten
erikchen
2014/07/17 18:22:45
Seems reasonable to me. Done.
|
+ return NSOrderedAscending; |
+ if ([secondView isKindOfClass:[FullSizeContentView class]]) |
+ return NSOrderedDescending; |
+ NSUInteger index1 = [subviews indexOfObject:firstView]; |
+ NSUInteger index2 = [subviews indexOfObject:secondView]; |
+ if (index1 < index2) |
+ return NSOrderedAscending; |
+ return NSOrderedDescending; |
Andre
2014/07/17 17:56:16
Suggestion: return (index1 < index2) ? NSOrderedAs
erikchen
2014/07/17 18:22:44
I see that you are a fan of the ternary operator.
|
+} |
+ |
+} // namespace |
+ |
@interface VersionIndependentWindow () |
+ (BOOL)shouldUseFullSizeContentViewForStyle:(NSUInteger)windowStyle; |
@@ -15,12 +44,6 @@ |
@end |
-// This view always takes the size of its superview. It is intended to be used |
-// as a NSWindow's contentView. It is needed because NSWindow's implementation |
-// explicitly resizes the contentView at inopportune times. |
-@interface FullSizeContentView : NSView |
-@end |
- |
@implementation FullSizeContentView |
// This method is directly called by NSWindow during a window resize on OSX |
@@ -81,6 +104,19 @@ |
setAutoresizingMask:NSViewWidthSizable | NSViewHeightSizable]; |
[chromeWindowView_ setFrame:[[[self contentView] superview] bounds]]; |
[self setContentView:chromeWindowView_]; |
+ |
+ // Move the content view to the back. |
+ // In Yosemite, the content view takes up the full size of the window, |
+ // and when it is in front of the zoom/fullscreen button, alt-clicking |
+ // the button has the wrong effect. |
+ // Adding subviews to the NSThemeFrame provokes a warning in Yosemite, so |
+ // we sort the subviews in place. |
+ // http://crbug.com/393808 |
+ |
+ NSView* superview = [[self contentView] superview]; |
+ NSArray* subviews = [[[superview subviews] copy] autorelease]; |
Andre
2014/07/17 17:56:16
Use scoped_nsobject?
erikchen
2014/07/17 18:22:44
Done.
|
+ [superview sortSubviewsUsingFunction:&ReorderContentViewToBack |
+ context:subviews]; |
} |
} |
return self; |