Revert "Make bottom corner more round"

This reverts commit f9a64dde5da537f615cd7080a335c6304c6a814e.
This commit is contained in:
Cheng Zhao 2015-08-26 15:56:39 +08:00
parent eb709a9a8f
commit c0b9fd415d
2 changed files with 1 additions and 80 deletions

View file

@ -5,8 +5,6 @@
#include "base/mac/scoped_nsobject.h" #include "base/mac/scoped_nsobject.h"
#include "ui/base/cocoa/base_view.h" #include "ui/base/cocoa/base_view.h"
@class CAShapeLayer;
namespace brightray { namespace brightray {
class InspectableWebContentsViewMac; class InspectableWebContentsViewMac;
} }
@ -21,9 +19,6 @@ using brightray::InspectableWebContentsViewMac;
BOOL devtools_visible_; BOOL devtools_visible_;
BOOL devtools_docked_; BOOL devtools_docked_;
// Weak reference to the mask of the hosted layer.
CAShapeLayer* layerMask_;
DevToolsContentsResizingStrategy strategy_; DevToolsContentsResizingStrategy strategy_;
} }

View file

@ -1,24 +1,14 @@
#include "browser/mac/bry_inspectable_web_contents_view.h" #include "browser/mac/bry_inspectable_web_contents_view.h"
#import <QuartzCore/QuartzCore.h>
#include "browser/inspectable_web_contents_impl.h" #include "browser/inspectable_web_contents_impl.h"
#include "browser/inspectable_web_contents_view_mac.h" #include "browser/inspectable_web_contents_view_mac.h"
#include "content/public/browser/render_widget_host_view.h" #include "content/public/browser/render_widget_host_view.h"
#include "ui/base/cocoa/animation_utils.h" #import "ui/base/cocoa/underlay_opengl_hosting_window.h"
#include "ui/base/cocoa/underlay_opengl_hosting_window.h"
#include "ui/gfx/mac/scoped_ns_disable_screen_updates.h" #include "ui/gfx/mac/scoped_ns_disable_screen_updates.h"
using namespace brightray; using namespace brightray;
namespace {
// The radius of the rounded corners.
const CGFloat kRoundedCornerRadius = 4;
} // namespace
@implementation BRYInspectableWebContentsView @implementation BRYInspectableWebContentsView
- (instancetype)initWithInspectableWebContentsViewMac:(InspectableWebContentsViewMac*)view { - (instancetype)initWithInspectableWebContentsViewMac:(InspectableWebContentsViewMac*)view {
@ -36,14 +26,8 @@ const CGFloat kRoundedCornerRadius = 4;
[self addSubview:contentsView]; [self addSubview:contentsView];
// See https://code.google.com/p/chromium/issues/detail?id=348490. // See https://code.google.com/p/chromium/issues/detail?id=348490.
ScopedCAActionDisabler disabler;
base::scoped_nsobject<CALayer> layer([[CALayer alloc] init]);
[self setLayer:layer];
[self setWantsLayer:YES]; [self setWantsLayer:YES];
// See https://code.google.com/p/chromium/issues/detail?id=396264.
[self updateLayerMask];
return self; return self;
} }
@ -51,12 +35,6 @@ const CGFloat kRoundedCornerRadius = 4;
[self adjustSubviews]; [self adjustSubviews];
} }
// Every time the frame's size changes, the layer mask needs to be updated.
- (void)setFrameSize:(NSSize)newSize {
[super setFrameSize:newSize];
[self updateLayerMask];
}
- (IBAction)showDevTools:(id)sender { - (IBAction)showDevTools:(id)sender {
inspectableWebContentsView_->inspectable_web_contents()->ShowDevTools(); inspectableWebContentsView_->inspectable_web_contents()->ShowDevTools();
} }
@ -178,58 +156,6 @@ const CGFloat kRoundedCornerRadius = 4;
[devtools_window_ setTitle:title]; [devtools_window_ setTitle:title];
} }
// Creates a path whose bottom two corners are rounded.
// Caller takes ownership of the path.
- (CGPathRef)createRoundedBottomCornersPath:(NSSize)size {
CGMutablePathRef path = CGPathCreateMutable();
CGFloat width = size.width;
CGFloat height = size.height;
CGFloat cornerRadius = kRoundedCornerRadius;
// Top left corner.
CGPathMoveToPoint(path, NULL, 0, height);
// Top right corner.
CGPathAddLineToPoint(path, NULL, width, height);
// Bottom right corner.
CGPathAddArc(path,
NULL,
width - cornerRadius,
cornerRadius,
cornerRadius,
0,
-M_PI_2,
true);
// Bottom left corner.
CGPathAddArc(path,
NULL,
cornerRadius,
cornerRadius,
cornerRadius,
-M_PI_2,
-M_PI,
true);
// Draw line back to top-left corner.
CGPathAddLineToPoint(path, NULL, 0, height);
CGPathCloseSubpath(path);
return path;
}
// Updates the path of the layer mask to have make window have round corner.
- (void)updateLayerMask {
if (![self layer].mask) {
layerMask_ = [CAShapeLayer layer];
[self layer].mask = layerMask_;
}
CGPathRef path = [self createRoundedBottomCornersPath:self.bounds.size];
layerMask_.path = path;
CGPathRelease(path);
}
#pragma mark - NSWindowDelegate #pragma mark - NSWindowDelegate
- (void)windowWillClose:(NSNotification*)notification { - (void)windowWillClose:(NSNotification*)notification {