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 instead. |
| 99 // |
| 100 // (This is checked here because UnderlayOpenGLHostingWindow is the base of |
| 101 // most Chromium windows, not because this is related to its functionality.) |
| 102 DCHECK(contentRect.size.width > 0 && |
| 103 contentRect.size.height > 0); |
90 if ((self = [super initWithContentRect:contentRect | 104 if ((self = [super initWithContentRect:contentRect |
91 styleMask:windowStyle | 105 styleMask:windowStyle |
92 backing:bufferingType | 106 backing:bufferingType |
93 defer:deferCreation])) { | 107 defer:deferCreation])) { |
94 // The invisible opaque area technique only works > 10.5. Fortunately, hole | 108 // 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 | 109 // 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 | 110 // 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. | 111 // proper window with a title bar and all. |
98 if (base::mac::IsOSSnowLeopardOrLater() && | 112 if (base::mac::IsOSSnowLeopardOrLater() && |
99 windowStyle && NSTitledWindowMask) { | 113 windowStyle && NSTitledWindowMask) { |
(...skipping 19 matching lines...) Expand all Loading... |
119 [rightOpaque setAutoresizingMask:NSViewMinXMargin | NSViewHeightSizable]; | 133 [rightOpaque setAutoresizingMask:NSViewMinXMargin | NSViewHeightSizable]; |
120 [rightOpaque setAlphaValue:kAlphaValueJustOpaqueEnough]; | 134 [rightOpaque setAlphaValue:kAlphaValueJustOpaqueEnough]; |
121 [rootView addSubview:rightOpaque]; | 135 [rootView addSubview:rightOpaque]; |
122 } | 136 } |
123 } | 137 } |
124 | 138 |
125 return self; | 139 return self; |
126 } | 140 } |
127 | 141 |
128 @end | 142 @end |
OLD | NEW |