OLD | NEW |
---|---|
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #import "ui/base/cocoa/underlay_opengl_hosting_window.h" | 5 #import "ui/base/cocoa/underlay_opengl_hosting_window.h" |
6 | 6 |
7 #import <objc/runtime.h> | 7 #import <objc/runtime.h> |
8 | 8 |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "base/mac/mac_util.h" | 10 #include "base/mac/mac_util.h" |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
80 reinterpret_cast<IMP>(&RootDidAddSubview), | 80 reinterpret_cast<IMP>(&RootDidAddSubview), |
81 method_getTypeEncoding(m)); | 81 method_getTypeEncoding(m)); |
82 DCHECK(didAdd); | 82 DCHECK(didAdd); |
83 } | 83 } |
84 } | 84 } |
85 | 85 |
86 - (id)initWithContentRect:(NSRect)contentRect | 86 - (id)initWithContentRect:(NSRect)contentRect |
87 styleMask:(NSUInteger)windowStyle | 87 styleMask:(NSUInteger)windowStyle |
88 backing:(NSBackingStoreType)bufferingType | 88 backing:(NSBackingStoreType)bufferingType |
89 defer:(BOOL)deferCreation { | 89 defer:(BOOL)deferCreation { |
90 // It is invalid to create windows with zero width or height. It screws things | |
91 // up royally: | |
92 // - It causes console spew: <http://crbug.com/78973> | |
93 // - It breaks Expose: <http://sourceforge.net/projects/heat-meteo/forums/foru m/268087/topic/4582610> | |
94 // | |
95 // This is a banned practice | |
96 // <http://www.chromium.org/developers/coding-style/cocoa-dos-and-donts>. Do | |
97 // not do this. Use kWindowSizeDeterminedLater in | |
98 // ui/base/cocoa/window_size_constants.h | |
Robert Sesek
2012/04/13 21:44:28
nit: no need to indent this special. Can also join
Avi (use Gerrit)
2012/04/17 14:21:17
Done.
| |
99 // instead. | |
100 // | |
101 // (This is checked here because UnderlayOpenGLHostingWindow is the base of | |
102 // most Chromium windows, not because this is related to its functionality.) | |
103 DCHECK(contentRect.size.width > 0 && | |
104 contentRect.size.height > 0); | |
90 if ((self = [super initWithContentRect:contentRect | 105 if ((self = [super initWithContentRect:contentRect |
91 styleMask:windowStyle | 106 styleMask:windowStyle |
92 backing:bufferingType | 107 backing:bufferingType |
93 defer:deferCreation])) { | 108 defer:deferCreation])) { |
94 // The invisible opaque area technique only works > 10.5. Fortunately, hole | 109 // The invisible opaque area technique only works > 10.5. Fortunately, hole |
95 // punching is used only when IOSurfaces are used to transport, and that's | 110 // punching is used only when IOSurfaces are used to transport, and that's |
96 // also only on > 10.5. Also, don't mess around with things if it's not a | 111 // also only on > 10.5. Also, don't mess around with things if it's not a |
97 // proper window with a title bar and all. | 112 // proper window with a title bar and all. |
98 if (base::mac::IsOSSnowLeopardOrLater() && | 113 if (base::mac::IsOSSnowLeopardOrLater() && |
99 windowStyle && NSTitledWindowMask) { | 114 windowStyle && NSTitledWindowMask) { |
(...skipping 19 matching lines...) Expand all Loading... | |
119 [rightOpaque setAutoresizingMask:NSViewMinXMargin | NSViewHeightSizable]; | 134 [rightOpaque setAutoresizingMask:NSViewMinXMargin | NSViewHeightSizable]; |
120 [rightOpaque setAlphaValue:kAlphaValueJustOpaqueEnough]; | 135 [rightOpaque setAlphaValue:kAlphaValueJustOpaqueEnough]; |
121 [rootView addSubview:rightOpaque]; | 136 [rootView addSubview:rightOpaque]; |
122 } | 137 } |
123 } | 138 } |
124 | 139 |
125 return self; | 140 return self; |
126 } | 141 } |
127 | 142 |
128 @end | 143 @end |
OLD | NEW |