Merge pull request #2594 from atom/fix-rounded-corner
mac: Do not set rounded corner by adding layer
This commit is contained in:
commit
7f67cfb6a0
3 changed files with 17 additions and 46 deletions
|
@ -82,9 +82,6 @@ class NativeWindowMac : public NativeWindow {
|
||||||
// Called to handle a mouse event.
|
// Called to handle a mouse event.
|
||||||
void HandleMouseEvent(NSEvent* event);
|
void HandleMouseEvent(NSEvent* event);
|
||||||
|
|
||||||
// Clip web view to rounded corner.
|
|
||||||
void ClipWebView();
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
// NativeWindow:
|
// NativeWindow:
|
||||||
void HandleKeyboardEvent(
|
void HandleKeyboardEvent(
|
||||||
|
|
|
@ -22,9 +22,6 @@
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
// The radius of rounded corner.
|
|
||||||
const CGFloat kAtomWindowCornerRadius = 4.0;
|
|
||||||
|
|
||||||
// Prevents window from resizing during the scope.
|
// Prevents window from resizing during the scope.
|
||||||
class ScopedDisableResize {
|
class ScopedDisableResize {
|
||||||
public:
|
public:
|
||||||
|
@ -41,10 +38,6 @@ bool ScopedDisableResize::disable_resize_ = false;
|
||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
@interface NSView (PrivateMethods)
|
|
||||||
- (CGFloat)roundedCornerRadius;
|
|
||||||
@end
|
|
||||||
|
|
||||||
// This view always takes the size of its superview. It is intended to be used
|
// This view always takes the size of its superview. It is intended to be used
|
||||||
// as a NSWindow's contentView. It is needed because NSWindow's implementation
|
// as a NSWindow's contentView. It is needed because NSWindow's implementation
|
||||||
// explicitly resizes the contentView at inopportune times.
|
// explicitly resizes the contentView at inopportune times.
|
||||||
|
@ -153,9 +146,6 @@ bool ScopedDisableResize::disable_resize_ = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)windowDidResize:(NSNotification*)notification {
|
- (void)windowDidResize:(NSNotification*)notification {
|
||||||
if (!shell_->has_frame())
|
|
||||||
shell_->ClipWebView();
|
|
||||||
|
|
||||||
shell_->NotifyWindowResize();
|
shell_->NotifyWindowResize();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -613,8 +603,8 @@ void NativeWindowMac::Center() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void NativeWindowMac::SetTitle(const std::string& title) {
|
void NativeWindowMac::SetTitle(const std::string& title) {
|
||||||
// We don't want the title to show in transparent window.
|
// We don't want the title to show in transparent or frameless window.
|
||||||
if (transparent())
|
if (transparent() || !has_frame())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
[window_ setTitle:base::SysUTF8ToNSString(title)];
|
[window_ setTitle:base::SysUTF8ToNSString(title)];
|
||||||
|
@ -804,35 +794,27 @@ void NativeWindowMac::HandleKeyboardEvent(
|
||||||
}
|
}
|
||||||
|
|
||||||
void NativeWindowMac::InstallView() {
|
void NativeWindowMac::InstallView() {
|
||||||
|
// Make sure the bottom corner is rounded: http://crbug.com/396264.
|
||||||
|
[[window_ contentView] setWantsLayer:YES];
|
||||||
|
|
||||||
NSView* view = inspectable_web_contents()->GetView()->GetNativeView();
|
NSView* view = inspectable_web_contents()->GetView()->GetNativeView();
|
||||||
if (has_frame()) {
|
if (has_frame()) {
|
||||||
// Add layer with white background for the contents view.
|
|
||||||
base::scoped_nsobject<CALayer> layer([[CALayer alloc] init]);
|
|
||||||
[layer setBackgroundColor:CGColorGetConstantColor(kCGColorWhite)];
|
|
||||||
[view setLayer:layer];
|
|
||||||
[view setFrame:[[window_ contentView] bounds]];
|
[view setFrame:[[window_ contentView] bounds]];
|
||||||
[[window_ contentView] addSubview:view];
|
[[window_ contentView] addSubview:view];
|
||||||
} else {
|
} else {
|
||||||
if (base::mac::IsOSYosemiteOrLater()) {
|
// In OSX 10.10, adding subviews to the root view for the NSView hierarchy
|
||||||
// In OSX 10.10, adding subviews to the root view for the NSView hierarchy
|
// produces warnings. To eliminate the warnings, we resize the contentView
|
||||||
// produces warnings. To eliminate the warnings, we resize the contentView
|
// to fill the window, and add subviews to that.
|
||||||
// to fill the window, and add subviews to that.
|
// http://crbug.com/380412
|
||||||
// http://crbug.com/380412
|
content_view_.reset([[FullSizeContentView alloc] init]);
|
||||||
content_view_.reset([[FullSizeContentView alloc] init]);
|
[content_view_
|
||||||
[content_view_
|
setAutoresizingMask:NSViewWidthSizable | NSViewHeightSizable];
|
||||||
setAutoresizingMask:NSViewWidthSizable | NSViewHeightSizable];
|
[content_view_ setFrame:[[[window_ contentView] superview] bounds]];
|
||||||
[content_view_ setFrame:[[[window_ contentView] superview] bounds]];
|
[window_ setContentView:content_view_];
|
||||||
[window_ setContentView:content_view_];
|
|
||||||
|
|
||||||
[view setFrame:[content_view_ bounds]];
|
[view setFrame:[content_view_ bounds]];
|
||||||
[content_view_ addSubview:view];
|
[content_view_ addSubview:view];
|
||||||
} else {
|
|
||||||
NSView* frameView = [[window_ contentView] superview];
|
|
||||||
[view setFrame:[frameView bounds]];
|
|
||||||
[frameView addSubview:view];
|
|
||||||
}
|
|
||||||
|
|
||||||
ClipWebView();
|
|
||||||
InstallDraggableRegionView();
|
InstallDraggableRegionView();
|
||||||
|
|
||||||
[[window_ standardWindowButton:NSWindowZoomButton] setHidden:YES];
|
[[window_ standardWindowButton:NSWindowZoomButton] setHidden:YES];
|
||||||
|
@ -851,14 +833,6 @@ void NativeWindowMac::UninstallView() {
|
||||||
[view removeFromSuperview];
|
[view removeFromSuperview];
|
||||||
}
|
}
|
||||||
|
|
||||||
void NativeWindowMac::ClipWebView() {
|
|
||||||
if (!web_contents())
|
|
||||||
return;
|
|
||||||
NSView* webView = web_contents()->GetNativeView();
|
|
||||||
webView.layer.masksToBounds = YES;
|
|
||||||
webView.layer.cornerRadius = kAtomWindowCornerRadius;
|
|
||||||
}
|
|
||||||
|
|
||||||
void NativeWindowMac::InstallDraggableRegionView() {
|
void NativeWindowMac::InstallDraggableRegionView() {
|
||||||
NSView* webView = web_contents()->GetNativeView();
|
NSView* webView = web_contents()->GetNativeView();
|
||||||
base::scoped_nsobject<NSView> controlRegion(
|
base::scoped_nsobject<NSView> controlRegion(
|
||||||
|
|
2
vendor/brightray
vendored
2
vendor/brightray
vendored
|
@ -1 +1 @@
|
||||||
Subproject commit 5b2a73c68a986780e67eb2e738327d35c7c1c21e
|
Subproject commit 0bf81275795b15eb361a1fd213ae9c7c1f60bdea
|
Loading…
Reference in a new issue