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 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
97 // not do this. Use kWindowSizeDeterminedLater in | 97 // not do this. Use kWindowSizeDeterminedLater in |
98 // ui/base/cocoa/window_size_constants.h instead. | 98 // ui/base/cocoa/window_size_constants.h instead. |
99 // | 99 // |
100 // (This is checked here because UnderlayOpenGLHostingWindow is the base of | 100 // (This is checked here because UnderlayOpenGLHostingWindow is the base of |
101 // most Chromium windows, not because this is related to its functionality.) | 101 // most Chromium windows, not because this is related to its functionality.) |
102 DCHECK(!NSIsEmptyRect(contentRect)); | 102 DCHECK(!NSIsEmptyRect(contentRect)); |
103 if ((self = [super initWithContentRect:contentRect | 103 if ((self = [super initWithContentRect:contentRect |
104 styleMask:windowStyle | 104 styleMask:windowStyle |
105 backing:bufferingType | 105 backing:bufferingType |
106 defer:deferCreation])) { | 106 defer:deferCreation])) { |
107 if (base::mac::IsOSSnowLeopardOrLater()) { | 107 // Hole punching is used when IOSurfaces are used to transport. |
108 // Hole punching is used when IOSurfaces are used to transport, which is | 108 // Therefore the window must always be non-opaque whether or not it's |
109 // only on > 10.5. Therefore, on > 10.5, the window must always be | 109 // titled if we want hole punching to work. |
Avi (use Gerrit)
2012/08/10 20:29:07
This comment is now a little awkward. Try:
OpenGL
Nico
2012/08/10 20:40:12
Done.
| |
110 // non-opaque whether or not it's titled if we want hole punching to work. | 110 [self setOpaque:NO]; |
111 [self setOpaque:NO]; | |
112 | 111 |
113 if (windowStyle & NSTitledWindowMask) { | 112 if (windowStyle & NSTitledWindowMask) { |
114 // Only fiddle with shadows if the window is a proper window with a | 113 // Only fiddle with shadows if the window is a proper window with a |
115 // title bar and all. (The invisible opaque area technique only works on | 114 // title bar and all. (The invisible opaque area technique only works on |
116 // > 10.5, but that is guaranteed by this point.) | 115 // > 10.5, but that is guaranteed by this point.) |
Avi (use Gerrit)
2012/08/10 20:29:07
Remove the parenthesized sentence; it is obsolete
Nico
2012/08/10 20:40:12
Done.
| |
117 [self _setContentHasShadow:NO]; | 116 [self _setContentHasShadow:NO]; |
118 | 117 |
119 NSView* rootView = [[self contentView] superview]; | 118 NSView* rootView = [[self contentView] superview]; |
120 const NSRect rootBounds = [rootView bounds]; | 119 const NSRect rootBounds = [rootView bounds]; |
121 | 120 |
122 // On 10.7/8, the bottom corners of the window are rounded by magic at a | 121 // On 10.7/8, the bottom corners of the window are rounded by magic at a |
123 // deeper level than the NSThemeFrame, so it is OK to have the opaques | 122 // deeper level than the NSThemeFrame, so it is OK to have the opaques |
124 // go all the way to the bottom. | 123 // go all the way to the bottom. |
125 const CGFloat kTopEdgeInset = 16; | 124 const CGFloat kTopEdgeInset = 16; |
126 const CGFloat kAlphaValueJustOpaqueEnough = 0.002; | 125 const CGFloat kAlphaValueJustOpaqueEnough = 0.002; |
127 | 126 |
128 scoped_nsobject<NSView> leftOpaque([[OpaqueView alloc] initWithFrame: | 127 scoped_nsobject<NSView> leftOpaque([[OpaqueView alloc] initWithFrame: |
129 NSMakeRect(NSMinX(rootBounds), NSMinY(rootBounds), | 128 NSMakeRect(NSMinX(rootBounds), NSMinY(rootBounds), |
130 1, NSHeight(rootBounds) - kTopEdgeInset)]); | 129 1, NSHeight(rootBounds) - kTopEdgeInset)]); |
131 [leftOpaque setAutoresizingMask:NSViewMaxXMargin | | 130 [leftOpaque setAutoresizingMask:NSViewMaxXMargin | |
132 NSViewHeightSizable]; | 131 NSViewHeightSizable]; |
133 [leftOpaque setAlphaValue:kAlphaValueJustOpaqueEnough]; | 132 [leftOpaque setAlphaValue:kAlphaValueJustOpaqueEnough]; |
134 [rootView addSubview:leftOpaque]; | 133 [rootView addSubview:leftOpaque]; |
135 | 134 |
136 scoped_nsobject<NSView> rightOpaque([[OpaqueView alloc] initWithFrame: | 135 scoped_nsobject<NSView> rightOpaque([[OpaqueView alloc] initWithFrame: |
137 NSMakeRect(NSMaxX(rootBounds) - 1, NSMinY(rootBounds), | 136 NSMakeRect(NSMaxX(rootBounds) - 1, NSMinY(rootBounds), |
138 1, NSHeight(rootBounds) - kTopEdgeInset)]); | 137 1, NSHeight(rootBounds) - kTopEdgeInset)]); |
139 [rightOpaque setAutoresizingMask:NSViewMinXMargin | | 138 [rightOpaque setAutoresizingMask:NSViewMinXMargin | |
140 NSViewHeightSizable]; | 139 NSViewHeightSizable]; |
141 [rightOpaque setAlphaValue:kAlphaValueJustOpaqueEnough]; | 140 [rightOpaque setAlphaValue:kAlphaValueJustOpaqueEnough]; |
142 [rootView addSubview:rightOpaque]; | 141 [rootView addSubview:rightOpaque]; |
143 } | |
144 } | 142 } |
145 } | 143 } |
146 | 144 |
147 return self; | 145 return self; |
148 } | 146 } |
149 | 147 |
150 @end | 148 @end |
OLD | NEW |