| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/views/cocoa/bridged_native_widget.h" | 5 #import "ui/views/cocoa/bridged_native_widget.h" |
| 6 | 6 |
| 7 #import <objc/runtime.h> | 7 #import <objc/runtime.h> |
| 8 #include <stddef.h> | 8 #include <stddef.h> |
| 9 #include <stdint.h> | 9 #include <stdint.h> |
| 10 | 10 |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 78 - (void)setCurrentProgress:(NSAnimationProgress)progress { | 78 - (void)setCurrentProgress:(NSAnimationProgress)progress { |
| 79 [super setCurrentProgress:progress]; | 79 [super setCurrentProgress:progress]; |
| 80 [window_ invalidateShadow]; | 80 [window_ invalidateShadow]; |
| 81 } | 81 } |
| 82 @end | 82 @end |
| 83 | 83 |
| 84 namespace { | 84 namespace { |
| 85 | 85 |
| 86 const CGFloat kMavericksMenuOpacity = 251.0 / 255.0; | 86 const CGFloat kMavericksMenuOpacity = 251.0 / 255.0; |
| 87 const CGFloat kYosemiteMenuOpacity = 194.0 / 255.0; | 87 const CGFloat kYosemiteMenuOpacity = 194.0 / 255.0; |
| 88 const int kYosemiteMenuBlur = 80; | 88 // const int kYosemiteMenuBlur = 80; |
| 89 | 89 |
| 90 // Margin at edge and corners of the window that trigger resizing. These match | 90 // Margin at edge and corners of the window that trigger resizing. These match |
| 91 // actual Cocoa resize margins. | 91 // actual Cocoa resize margins. |
| 92 const int kResizeAreaEdgeSize = 3; | 92 const int kResizeAreaEdgeSize = 3; |
| 93 const int kResizeAreaCornerSize = 12; | 93 const int kResizeAreaCornerSize = 12; |
| 94 | 94 |
| 95 int kWindowPropertiesKey; | 95 int kWindowPropertiesKey; |
| 96 | 96 |
| 97 float GetDeviceScaleFactorFromView(NSView* view) { | 97 float GetDeviceScaleFactorFromView(NSView* view) { |
| 98 gfx::Display display = | 98 gfx::Display display = |
| (...skipping 1039 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1138 | 1138 |
| 1139 base::scoped_nsobject<CALayer> background_layer([[CALayer alloc] init]); | 1139 base::scoped_nsobject<CALayer> background_layer([[CALayer alloc] init]); |
| 1140 [background_layer | 1140 [background_layer |
| 1141 setAutoresizingMask:kCALayerWidthSizable | kCALayerHeightSizable]; | 1141 setAutoresizingMask:kCALayerWidthSizable | kCALayerHeightSizable]; |
| 1142 | 1142 |
| 1143 if (widget_type_ == Widget::InitParams::TYPE_MENU) { | 1143 if (widget_type_ == Widget::InitParams::TYPE_MENU) { |
| 1144 // Giving the canvas opacity messes up subpixel font rendering, so use a | 1144 // Giving the canvas opacity messes up subpixel font rendering, so use a |
| 1145 // solid background, but make the CALayer transparent. | 1145 // solid background, but make the CALayer transparent. |
| 1146 if (base::mac::IsOSYosemiteOrLater()) { | 1146 if (base::mac::IsOSYosemiteOrLater()) { |
| 1147 [background_layer setOpacity:kYosemiteMenuOpacity]; | 1147 [background_layer setOpacity:kYosemiteMenuOpacity]; |
| 1148 CGSSetWindowBackgroundBlurRadius( | 1148 |
| 1149 _CGSDefaultConnection(), [window_ windowNumber], kYosemiteMenuBlur); | 1149 // TODO(erikchen): Temporarily disabled. https://crbug.com/515627. |
| 1150 // CGSSetWindowBackgroundBlurRadius( |
| 1151 // _CGSDefaultConnection(), [window_ windowNumber], |
| 1152 // kYosemiteMenuBlur); |
| 1150 // The blur effect does not occur with a fully transparent (or fully | 1153 // The blur effect does not occur with a fully transparent (or fully |
| 1151 // layer-backed) window. Setting a window background will use square | 1154 // layer-backed) window. Setting a window background will use square |
| 1152 // corners, so ask the contentView to draw one instead. | 1155 // corners, so ask the contentView to draw one instead. |
| 1153 [bridged_view_ setDrawMenuBackgroundForBlur:YES]; | 1156 [bridged_view_ setDrawMenuBackgroundForBlur:YES]; |
| 1154 } else { | 1157 } else { |
| 1155 [background_layer setOpacity:kMavericksMenuOpacity]; | 1158 [background_layer setOpacity:kMavericksMenuOpacity]; |
| 1156 } | 1159 } |
| 1157 } | 1160 } |
| 1158 | 1161 |
| 1159 // Set the layer first to create a layer-hosting view (not layer-backed). | 1162 // Set the layer first to create a layer-hosting view (not layer-backed). |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1238 [bridged_view_ setMouseDownCanMoveWindow:draggable]; | 1241 [bridged_view_ setMouseDownCanMoveWindow:draggable]; |
| 1239 // AppKit will not update its cache of mouseDownCanMoveWindow unless something | 1242 // AppKit will not update its cache of mouseDownCanMoveWindow unless something |
| 1240 // changes. Previously we tried adding an NSView and removing it, but for some | 1243 // changes. Previously we tried adding an NSView and removing it, but for some |
| 1241 // reason it required reposting the mouse-down event, and didn't always work. | 1244 // reason it required reposting the mouse-down event, and didn't always work. |
| 1242 // Calling the below seems to be an effective solution. | 1245 // Calling the below seems to be an effective solution. |
| 1243 [window_ setMovableByWindowBackground:NO]; | 1246 [window_ setMovableByWindowBackground:NO]; |
| 1244 [window_ setMovableByWindowBackground:YES]; | 1247 [window_ setMovableByWindowBackground:YES]; |
| 1245 } | 1248 } |
| 1246 | 1249 |
| 1247 } // namespace views | 1250 } // namespace views |
| OLD | NEW |