Chromium Code Reviews| 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 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 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(contentRect.size.width > 0 && | 102 DCHECK(contentRect.size.width > 0 && |
| 103 contentRect.size.height > 0); | 103 contentRect.size.height > 0); |
| 104 if ((self = [super initWithContentRect:contentRect | 104 if ((self = [super initWithContentRect:contentRect |
| 105 styleMask:windowStyle | 105 styleMask:windowStyle |
| 106 backing:bufferingType | 106 backing:bufferingType |
| 107 defer:deferCreation])) { | 107 defer:deferCreation])) { |
| 108 // The invisible opaque area technique only works > 10.5. Fortunately, hole | 108 if (base::mac::IsOSSnowLeopardOrLater()) { |
| 109 // punching is used only when IOSurfaces are used to transport, and that's | 109 // Hole punching is used when IOSurfaces are used to transport, which is |
| 110 // also only on > 10.5. Also, don't mess around with things if it's not a | 110 // only on > 10.5. Therefore, on > 10.5, the window must always be |
| 111 // proper window with a title bar and all. | 111 // non-opaque whether or not it's titled if we want hole punching to work. |
| 112 if (base::mac::IsOSSnowLeopardOrLater() && | |
| 113 windowStyle && NSTitledWindowMask) { | |
| 114 [self setOpaque:NO]; | 112 [self setOpaque:NO]; |
| 115 [self _setContentHasShadow:NO]; | |
| 116 | 113 |
| 117 NSView* rootView = [[self contentView] superview]; | 114 if (windowStyle && NSTitledWindowMask) { |
|
Nico
2012/04/18 16:08:34
you mean '&', not '&&', right? (did clang not warn
Avi (use Gerrit)
2012/04/18 16:14:48
Aaaaaaaaaa
| |
| 118 const NSRect rootBounds = [rootView bounds]; | 115 // Only fiddle with shadows if the window is a proper window with a |
| 116 // title bar and all. (The invisible opaque area technique only works on | |
| 117 // > 10.5, but that is guaranteed by this point.) | |
| 118 [self _setContentHasShadow:NO]; | |
| 119 | 119 |
| 120 const CGFloat kEdgeInset = 16; | 120 NSView* rootView = [[self contentView] superview]; |
| 121 const CGFloat kAlphaValueJustOpaqueEnough = 0.002; | 121 const NSRect rootBounds = [rootView bounds]; |
| 122 | 122 |
| 123 scoped_nsobject<NSView> leftOpaque([[OpaqueView alloc] initWithFrame: | 123 const CGFloat kEdgeInset = 16; |
| 124 NSMakeRect(NSMinX(rootBounds), NSMinY(rootBounds) + kEdgeInset, | 124 const CGFloat kAlphaValueJustOpaqueEnough = 0.002; |
| 125 1, NSHeight(rootBounds) - 2 * kEdgeInset)]); | |
| 126 [leftOpaque setAutoresizingMask:NSViewMaxXMargin | NSViewHeightSizable]; | |
| 127 [leftOpaque setAlphaValue:kAlphaValueJustOpaqueEnough]; | |
| 128 [rootView addSubview:leftOpaque]; | |
| 129 | 125 |
| 130 scoped_nsobject<NSView> rightOpaque([[OpaqueView alloc] initWithFrame: | 126 scoped_nsobject<NSView> leftOpaque([[OpaqueView alloc] initWithFrame: |
| 131 NSMakeRect(NSMaxX(rootBounds) - 1, NSMinY(rootBounds) + kEdgeInset, | 127 NSMakeRect(NSMinX(rootBounds), NSMinY(rootBounds) + kEdgeInset, |
| 132 1, NSHeight(rootBounds) - 2 * kEdgeInset)]); | 128 1, NSHeight(rootBounds) - 2 * kEdgeInset)]); |
| 133 [rightOpaque setAutoresizingMask:NSViewMinXMargin | NSViewHeightSizable]; | 129 [leftOpaque setAutoresizingMask:NSViewMaxXMargin | |
| 134 [rightOpaque setAlphaValue:kAlphaValueJustOpaqueEnough]; | 130 NSViewHeightSizable]; |
| 135 [rootView addSubview:rightOpaque]; | 131 [leftOpaque setAlphaValue:kAlphaValueJustOpaqueEnough]; |
| 132 [rootView addSubview:leftOpaque]; | |
| 133 | |
| 134 scoped_nsobject<NSView> rightOpaque([[OpaqueView alloc] initWithFrame: | |
| 135 NSMakeRect(NSMaxX(rootBounds) - 1, NSMinY(rootBounds) + kEdgeInset, | |
| 136 1, NSHeight(rootBounds) - 2 * kEdgeInset)]); | |
| 137 [rightOpaque setAutoresizingMask:NSViewMinXMargin | | |
| 138 NSViewHeightSizable]; | |
| 139 [rightOpaque setAlphaValue:kAlphaValueJustOpaqueEnough]; | |
| 140 [rootView addSubview:rightOpaque]; | |
| 141 } | |
| 136 } | 142 } |
| 137 } | 143 } |
| 138 | 144 |
| 139 return self; | 145 return self; |
| 140 } | 146 } |
| 141 | 147 |
| 142 @end | 148 @end |
| OLD | NEW |