Chromium Code Reviews| Index: ui/views/cocoa/bridged_native_widget.mm |
| diff --git a/ui/views/cocoa/bridged_native_widget.mm b/ui/views/cocoa/bridged_native_widget.mm |
| index 6f5dec0f96864ede56c8a7cf940de5ebf964aa92..e3df3e51ff19bb5b716f002f3a91ce2a0f16ca4a 100644 |
| --- a/ui/views/cocoa/bridged_native_widget.mm |
| +++ b/ui/views/cocoa/bridged_native_widget.mm |
| @@ -4,6 +4,7 @@ |
| #import "ui/views/cocoa/bridged_native_widget.h" |
| +#import <Quartz/Quartz.h> |
| #import <objc/runtime.h> |
| #include <stddef.h> |
| #include <stdint.h> |
| @@ -13,6 +14,7 @@ |
| #include "base/mac/mac_util.h" |
| #import "base/mac/sdk_forward_declarations.h" |
| #include "base/thread_task_runner_handle.h" |
| +#import "third_party/google_toolbox_for_mac/src/AppKit/GTMNSBezierPath+CGPath.h" |
| #include "ui/accelerated_widget_mac/window_resize_helper_mac.h" |
| #import "ui/base/cocoa/constrained_window/constrained_window_animation.h" |
| #include "ui/base/hit_test.h" |
| @@ -683,13 +685,7 @@ void BridgedNativeWidget::OnSizeChanged() { |
| MaybeWaitForFrame(new_size); |
| } |
| - // 10.9 is unable to generate a window shadow from the composited CALayer, so |
| - // use Quartz. |
| - // We don't update the window mask during a live resize, instead it is done |
| - // after the resize is completed in viewDidEndLiveResize: in |
| - // BridgedContentView. |
| - if (base::mac::IsOSMavericksOrEarlier() && ![window_ inLiveResize]) |
| - [bridged_view_ updateWindowMask]; |
| + UpdateMaskPath(); |
| } |
| void BridgedNativeWidget::OnVisibilityChanged() { |
| @@ -1244,4 +1240,33 @@ void BridgedNativeWidget::SetDraggable(bool draggable) { |
| [window_ setMovableByWindowBackground:YES]; |
| } |
| +// TODO(karandeepb): Add tests to verify mask layer is correctly set up. |
|
tapted
2016/03/04 04:15:01
we don't usually have TODO: add tests in code comm
|
| +void BridgedNativeWidget::UpdateMaskPath() { |
| + [bridged_view_ updateWindowMask]; |
| + |
| + // We only set the mask layer for windows with non-rectangular masks. |
| + if (![bridged_view_ windowMask]) { |
| + // Removing a mask after adding one isn't currently supported. |
| + DCHECK(![[compositor_superview_ layer] mask]); |
| + return; |
| + } |
| + |
| + CAShapeLayer* mask_layer = base::mac::ObjCCastStrict<CAShapeLayer>( |
| + [[compositor_superview_ layer] mask]); |
| + if (mask_layer) { |
| + [mask_layer setPath:[[bridged_view_ windowMask] gtm_CGPath]]; |
| + return; |
| + } |
| + |
| + // If mask layer does not exist yet, create one and set it as the background |
| + // layer's mask. Clipping will be done based on the alpha channel of the mask |
| + // layer. |
| + mask_layer = [CAShapeLayer layer]; |
| + [mask_layer setPath:[[bridged_view_ windowMask] gtm_CGPath]]; |
| + |
| + CALayer* background_layer = [compositor_superview_ layer]; |
| + [background_layer setMask:mask_layer]; |
| + [background_layer setMasksToBounds:YES]; |
| +} |
| + |
| } // namespace views |