fix: do not set layer explicitly for frameless window (#14730)

This commit is contained in:
Cheng Zhao 2018-09-21 01:24:55 +08:00 committed by Charles Kerr
parent 1d20057df3
commit 6f494b3c58

View file

@ -1349,10 +1349,16 @@ void NativeWindowMac::AddContentViewLayers() {
// http://crbug.com/396264. But do not enable it on OS X 10.9 for transparent // http://crbug.com/396264. But do not enable it on OS X 10.9 for transparent
// window, otherwise a semi-transparent frame would show. // window, otherwise a semi-transparent frame would show.
if (!(transparent() && base::mac::IsOS10_9()) && !is_modal()) { if (!(transparent() && base::mac::IsOS10_9()) && !is_modal()) {
base::scoped_nsobject<CALayer> background_layer([[CALayer alloc] init]); // For normal window, we need to explicitly set layer for contentView to
[background_layer // make setBackgroundColor work correctly.
setAutoresizingMask:kCALayerWidthSizable | kCALayerHeightSizable]; // There is no need to do so for frameless window, and doing so would make
[[window_ contentView] setLayer:background_layer]; // titleBarStyle stop working.
if (has_frame()) {
base::scoped_nsobject<CALayer> background_layer([[CALayer alloc] init]);
[background_layer
setAutoresizingMask:kCALayerWidthSizable | kCALayerHeightSizable];
[[window_ contentView] setLayer:background_layer];
}
[[window_ contentView] setWantsLayer:YES]; [[window_ contentView] setWantsLayer:YES];
} }