Commit b247d53f authored by Sidney San Martín's avatar Sidney San Martín Committed by Commit Bot

Delete the MacViews "construction stripes".

They served their purpose well.

Change-Id: I8e93e25f8ab08ed2b2e3832f1f578a40561b2a22
Reviewed-on: https://chromium-review.googlesource.com/1067649
Commit-Queue: Avi Drissman <avi@chromium.org>
Reviewed-by: default avatarAvi Drissman <avi@chromium.org>
Reviewed-by: default avatarElly Fong-Jones <ellyjones@chromium.org>
Cr-Commit-Position: refs/heads/master@{#560903}
parent 11b61e95
...@@ -142,13 +142,8 @@ size_t CountVisibleWindows() { ...@@ -142,13 +142,8 @@ size_t CountVisibleWindows() {
} }
// Returns how many visible NSWindows are expected for a given count of browser // Returns how many visible NSWindows are expected for a given count of browser
// windows. On non-official builds in Views mode, there's an extra window // windows.
// because of the "construction stripes" decoration.
size_t ExpectedWindowCountForBrowserCount(size_t browsers) { size_t ExpectedWindowCountForBrowserCount(size_t browsers) {
#if !defined(GOOGLE_CHROME_BUILD)
if (!views_mode_controller::IsViewsBrowserCocoa())
return browsers * 2;
#endif
return browsers; return browsers;
} }
......
...@@ -2493,16 +2493,6 @@ split_static_library("ui") { ...@@ -2493,16 +2493,6 @@ split_static_library("ui") {
"views/tabs/window_finder_mac.mm", "views/tabs/window_finder_mac.mm",
] ]
# MacViews browser windows are loudly marked in Chromium builds so that
# developers notice when they're being used. See comment in
# macviews_under_construction_window_mac.h for details.
if (!is_chrome_branded) {
sources += [
"views/frame/macviews_under_construction_window_mac.h",
"views/frame/macviews_under_construction_window_mac.mm",
]
}
deps += [ "//extensions/components/native_app_window" ] deps += [ "//extensions/components/native_app_window" ]
# Truly cocoa-browser-specific sources. These are secondary UI pieces that # Truly cocoa-browser-specific sources. These are secondary UI pieces that
......
...@@ -4,10 +4,6 @@ ...@@ -4,10 +4,6 @@
#import "chrome/browser/ui/views/frame/browser_native_widget_window_mac.h" #import "chrome/browser/ui/views/frame/browser_native_widget_window_mac.h"
#if !defined(GOOGLE_CHROME_BUILD)
#import "chrome/browser/ui/views/frame/macviews_under_construction_window_mac.h"
#endif
#import <AppKit/AppKit.h> #import <AppKit/AppKit.h>
namespace { namespace {
...@@ -109,14 +105,4 @@ WEAK_IMPORT_ATTRIBUTE ...@@ -109,14 +105,4 @@ WEAK_IMPORT_ATTRIBUTE
return NO; return NO;
} }
// NSWindow overrides.
- (void)orderWindow:(NSWindowOrderingMode)place relativeTo:(NSInteger)otherWin {
[super orderWindow:place relativeTo:otherWin];
#if !defined(GOOGLE_CHROME_BUILD)
if (place != NSWindowOut)
[MacViewsUnderConstructionWindow attachToWindow:self];
#endif
}
@end @end
// Copyright 2018 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef CHROME_BROWSER_UI_VIEWS_FRAME_MACVIEWS_UNDER_CONSTRUCTION_WINDOW_MAC_H_
#define CHROME_BROWSER_UI_VIEWS_FRAME_MACVIEWS_UNDER_CONSTRUCTION_WINDOW_MAC_H_
#import <AppKit/AppKit.h>
// MacViewsUnderConstructionWindow displays a striped yellow bar above a
// window. It's used by MacViews browser windows to make life easier for
// developers who occasionally forget to launch Chromium with the right flags,
// and to make it clear to external developers that MacViews browser windows
// aren't quite ready to ship. It can be deleted once Chrome uses MacViews
// browser windows by default.
@interface MacViewsUnderConstructionWindow : NSWindow
+ (void)attachToWindow:(NSWindow*)window;
- (instancetype)initWithContentRect:(NSRect)contentRect
styleMask:(NSWindowStyleMask)style
backing:(NSBackingStoreType)bufferingType
defer:(BOOL)flag NS_UNAVAILABLE;
@end
#endif // CHROME_BROWSER_UI_VIEWS_FRAME_MACVIEWS_UNDER_CONSTRUCTION_WINDOW_MAC_H_
// Copyright 2018 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#import "chrome/browser/ui/views/frame/macviews_under_construction_window_mac.h"
#import <objc/runtime.h>
namespace {
constexpr CGFloat kUnderConstructionWindowMinWidth = 40;
constexpr CGFloat kUnderConstructionWindowHeight = 15;
constexpr CGFloat kUnderConstructionWindowXInset = 10;
constexpr CGFloat kUnderConstructionWindowYInset = 5;
} // namespace
@implementation MacViewsUnderConstructionWindow {
NSView* stripesView_; // weak
}
+ (void)attachToWindow:(NSWindow*)window {
MacViewsUnderConstructionWindow* underConstructionWindow =
objc_getAssociatedObject(window, _cmd);
if (!underConstructionWindow) {
underConstructionWindow = [[[self alloc] init] autorelease];
objc_setAssociatedObject(window, _cmd, underConstructionWindow,
OBJC_ASSOCIATION_RETAIN_NONATOMIC);
}
[window addChildWindow:underConstructionWindow ordered:NSWindowBelow];
}
- (instancetype)init {
if ((self = [super initWithContentRect:NSZeroRect
styleMask:NSWindowStyleMaskBorderless
backing:NSBackingStoreBuffered
defer:NO])) {
self.opaque = NO;
self.backgroundColor = NSColor.clearColor;
self.hasShadow = YES;
self.contentView.wantsLayer = YES;
CALayer* layer = self.contentView.layer;
layer.opaque = YES;
layer.cornerRadius = 5;
layer.backgroundColor = CGColorGetConstantColor(kCGColorWhite);
layer.shadowColor = CGColorGetConstantColor(kCGColorBlack);
layer.shadowRadius = 5;
layer.shadowOpacity = 1;
NSImage* stripesImage = [NSImage
imageWithSize:NSMakeSize(40, 40)
flipped:NO
drawingHandler:^(NSRect rect) {
[[NSColor colorWithCalibratedRed:1 green:0.8 blue:0 alpha:1] setFill];
NSRectFill(rect);
NSBezierPath* stripePath = [NSBezierPath bezierPath];
[stripePath moveToPoint:NSMakePoint(0, 0)];
[stripePath lineToPoint:NSMakePoint(40, 40)];
[stripePath lineToPoint:NSMakePoint(40, 20)];
[stripePath lineToPoint:NSMakePoint(20, 0)];
[stripePath closePath];
[NSColor.blackColor setFill];
[stripePath fill];
NSAffineTransform* shiftTransform = [NSAffineTransform transform];
[shiftTransform translateXBy:-20 yBy:20];
[stripePath transformUsingAffineTransform:shiftTransform];
[stripePath fill];
return YES;
}];
stripesView_ =
[[[NSView alloc] initWithFrame:self.contentView.bounds] autorelease];
stripesView_.autoresizingMask = NSViewWidthSizable | NSViewHeightSizable;
stripesView_.wantsLayer = YES;
stripesView_.layer.backgroundColor =
[NSColor colorWithPatternImage:stripesImage].CGColor;
[self.contentView addSubview:stripesView_];
}
return self;
}
- (void)setParentWindow:(NSWindow*)window {
if (self.parentWindow) {
[NSNotificationCenter.defaultCenter removeObserver:self];
}
[super setParentWindow:window];
if (window) {
[NSNotificationCenter.defaultCenter
addObserver:self
selector:@selector(parentWindowDidChangeSize)
name:NSWindowDidResizeNotification
object:window];
[NSNotificationCenter.defaultCenter
addObserver:self
selector:@selector(parentWindowDidChangeMain)
name:NSWindowDidBecomeMainNotification
object:window];
[NSNotificationCenter.defaultCenter
addObserver:self
selector:@selector(parentWindowDidChangeMain)
name:NSWindowDidResignMainNotification
object:window];
[self parentWindowDidChangeMain];
[self parentWindowDidChangeSize];
}
}
- (void)parentWindowDidChangeMain {
stripesView_.alphaValue = self.parentWindow.isMainWindow ? 1 : 0.5;
}
- (void)parentWindowDidChangeSize {
const NSRect parentFrame = self.parentWindow.frame;
[self
setFrame:NSMakeRect(NSMinX(parentFrame) + kUnderConstructionWindowXInset,
NSMaxY(parentFrame) - kUnderConstructionWindowYInset,
MAX(kUnderConstructionWindowMinWidth,
NSWidth(parentFrame) -
kUnderConstructionWindowXInset * 2),
kUnderConstructionWindowHeight)
display:NO];
}
@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