Commit 4e8a2925 authored by erikchen's avatar erikchen Committed by Commit bot

Revert of Mac: Fix rounded corners on browser windows on retina display....

Revert of Mac: Fix rounded corners on browser windows on retina display. (patchset #4 id:80001 of https://codereview.chromium.org/463263002/)

Reason for revert:
When the download bar is present, the rounded corners are on the wrong view.

https://code.google.com/p/chromium/issues/detail?id=412580

Original issue's description:
> Mac: Fix rounded corners on browser windows on retina display.
>
> When a window's bottom corner is covered by a layer on a retina display, the
> corner is incorrectly rounded. I added a layer mask to do the corner rounding
> ourselves.
>
> BUG=396264
>
> Committed: https://src.chromium.org/viewvc/chrome?view=rev&revision=289811

TBR=andresantoso@chromium.org,ccameron@chromium.org,shess@chromium.org
NOTREECHECKS=true
NOTRY=true
BUG=396264

Review URL: https://codereview.chromium.org/560913004

Cr-Commit-Position: refs/heads/master@{#294265}
parent 9160b5dc
......@@ -92,9 +92,6 @@
// sends a message to the renderer to resize.
- (void)layoutTabContentArea:(NSRect)frame;
// Updates whether the bottom two corners are rounded.
- (void)updateRoundedBottomCorners;
// Sets the toolbar's height to a value appropriate for the given compression.
// Also adjusts the bookmark bar's height by the opposite amount in order to
// keep the total height of the two views constant.
......
......@@ -520,10 +520,6 @@ willPositionSheet:(NSWindow*)sheet
}
}
- (void)updateRoundedBottomCorners {
[[self tabContentArea] setRoundedBottomCorners:![self isInAnyFullscreenMode]];
}
- (void)adjustToolbarAndBookmarkBarForCompression:(CGFloat)compression {
CGFloat newHeight =
[toolbarController_ desiredHeightForCompression:compression];
......@@ -920,7 +916,6 @@ willPositionSheet:(NSWindow*)sheet
[self showFullscreenExitBubbleIfNecessary];
browser_->WindowFullscreenStateChanged();
[[[self window] cr_windowView] setWantsLayer:windowViewWantsLayer_];
[self updateRoundedBottomCorners];
}
- (void)windowWillExitFullScreen:(NSNotification*)notification {
......@@ -934,7 +929,6 @@ willPositionSheet:(NSWindow*)sheet
if (notification) // For System Fullscreen when non-nil.
[self deregisterForContentViewResizeNotifications];
browser_->WindowFullscreenStateChanged();
[self updateRoundedBottomCorners];
}
- (void)windowDidFailToEnterFullScreen:(NSWindow*)window {
......
......@@ -7,22 +7,10 @@
#import <Cocoa/Cocoa.h>
@class CAShapeLayer;
// A Cocoa view originally created to support fast re-painting to white on
// resize. This is done by CoreAnimation now, so this view remains only as the
// first opaque ancestor of accelerated web contents views.
@interface FastResizeView : NSView {
@private
// Whether the bottom corners should be rounded.
BOOL roundedBottomCorners_;
// Weak reference to the mask of the hosted layer.
CAShapeLayer* layerMask_;
}
// Changes whether the bottom two corners are rounded.
- (void)setRoundedBottomCorners:(BOOL)roundedBottomCorners;
@interface FastResizeView : NSView
@end
......
......@@ -10,23 +10,6 @@
#include "base/mac/scoped_nsobject.h"
#include "ui/base/cocoa/animation_utils.h"
namespace {
// The radius of the rounded corners.
const CGFloat kRoundedCornerRadius = 4;
} // namespace
@interface FastResizeView (PrivateMethods)
// Creates a path whose bottom two corners are rounded.
// Caller takes ownership of the path.
- (CGPathRef)createRoundedBottomCornersPath:(NSSize)size;
// Updates the path of the layer mask to reflect the current value of
// roundedBottomCorners_.
- (void)updateLayerMask;
@end
@implementation FastResizeView
- (id)initWithFrame:(NSRect)frameRect {
......@@ -36,9 +19,6 @@ const CGFloat kRoundedCornerRadius = 4;
[layer setBackgroundColor:CGColorGetConstantColor(kCGColorWhite)];
[self setLayer:layer];
[self setWantsLayer:YES];
roundedBottomCorners_ = YES;
[self updateLayerMask];
}
return self;
}
......@@ -47,77 +27,5 @@ const CGFloat kRoundedCornerRadius = 4;
return YES;
}
- (void)setRoundedBottomCorners:(BOOL)roundedBottomCorners {
if (roundedBottomCorners == roundedBottomCorners_)
return;
roundedBottomCorners_ = roundedBottomCorners;
[self updateLayerMask];
}
// Every time the frame's size changes, the layer mask needs to be updated.
- (void)setFrameSize:(NSSize)newSize {
[super setFrameSize:newSize];
[self updateLayerMask];
}
@end
@implementation FastResizeView (PrivateMethods)
- (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;
}
- (void)updateLayerMask {
if (!roundedBottomCorners_) {
[self layer].mask = nil;
layerMask_ = nil;
return;
}
if (![self layer].mask) {
layerMask_ = [CAShapeLayer layer];
[self layer].mask = layerMask_;
}
CGPathRef path = [self createRoundedBottomCornersPath:self.bounds.size];
layerMask_.path = path;
CGPathRelease(path);
}
@end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment