Commit 9cceb8fa authored by ellyjones's avatar ellyjones Committed by Commit bot

cocoa browser: remove non-material toolbar support

This is part 1 of removing non-material top chrome support.

BUG=649368

Review-Url: https://codereview.chromium.org/2361153002
Cr-Commit-Position: refs/heads/master@{#420593}
parent cfa01627
...@@ -52,7 +52,6 @@ class AppMenuButtonIconPainterDelegateMac : ...@@ -52,7 +52,6 @@ class AppMenuButtonIconPainterDelegateMac :
} }
- (gfx::VectorIconId)vectorIconId { - (gfx::VectorIconId)vectorIconId {
CHECK(ui::MaterialDesignController::IsModeMaterial());
switch (type_) { switch (type_) {
case AppMenuIconController::IconType::NONE: case AppMenuIconController::IconType::NONE:
DCHECK_EQ(severity_, AppMenuIconPainter::SEVERITY_NONE); DCHECK_EQ(severity_, AppMenuIconPainter::SEVERITY_NONE);
......
...@@ -89,39 +89,8 @@ const int kReloadMenuCommands[] = { ...@@ -89,39 +89,8 @@ const int kReloadMenuCommands[] = {
// Forcibly remove any stale tooltip which is being displayed. // Forcibly remove any stale tooltip which is being displayed.
[self removeAllToolTips]; [self removeAllToolTips];
id cell = [self cell];
[self setTag:anInt]; [self setTag:anInt];
// The old way of doing things.
if (!ui::MaterialDesignController::IsModeMaterial()) {
if (anInt == IDC_RELOAD) {
[cell setImageID:IDR_RELOAD
forButtonState:image_button_cell::kDefaultState];
[cell setImageID:IDR_RELOAD_H
forButtonState:image_button_cell::kHoverState];
[cell setImageID:IDR_RELOAD_P
forButtonState:image_button_cell::kPressedState];
// The stop button has a disabled image but the reload button doesn't. To
// unset it we have to explicilty change the image ID to 0.
[cell setImageID:0
forButtonState:image_button_cell::kDisabledState];
[self setToolTip:l10n_util::GetNSStringWithFixup(IDS_TOOLTIP_RELOAD)];
} else if (anInt == IDC_STOP) {
[cell setImageID:IDR_STOP
forButtonState:image_button_cell::kDefaultState];
[cell setImageID:IDR_STOP_H
forButtonState:image_button_cell::kHoverState];
[cell setImageID:IDR_STOP_P
forButtonState:image_button_cell::kPressedState];
[cell setImageID:IDR_STOP_D
forButtonState:image_button_cell::kDisabledState];
[self setToolTip:l10n_util::GetNSStringWithFixup(IDS_TOOLTIP_STOP)];
} else {
NOTREACHED();
}
return;
}
[self resetButtonStateImages]; [self resetButtonStateImages];
if (anInt == IDC_RELOAD) { if (anInt == IDC_RELOAD) {
[self setToolTip:l10n_util::GetNSStringWithFixup(IDS_TOOLTIP_RELOAD)]; [self setToolTip:l10n_util::GetNSStringWithFixup(IDS_TOOLTIP_RELOAD)];
...@@ -154,28 +123,16 @@ const int kReloadMenuCommands[] = { ...@@ -154,28 +123,16 @@ const int kReloadMenuCommands[] = {
} else if ([self tag] == IDC_STOP && } else if ([self tag] == IDC_STOP &&
!pendingReloadTimer_ && !pendingReloadTimer_ &&
[[self cell] isMouseInside]) { [[self cell] isMouseInside]) {
id cell = [self cell]; [self resetButtonStateImages];
if (ui::MaterialDesignController::IsModeMaterial()) { NSImage* disabledStopImage =
[self resetButtonStateImages]; [[self cell] imageForState:image_button_cell::kDisabledState
NSImage* disabledStopImage = view:self];
[[self cell] imageForState:image_button_cell::kDisabledState [[self cell] setImage:disabledStopImage
view:self];
[cell setImage:disabledStopImage
forButtonState:image_button_cell::kDefaultState];
[cell setImage:disabledStopImage
forButtonState:image_button_cell::kHoverState];
[cell setImage:disabledStopImage
forButtonState:image_button_cell::kPressedState];
} else {
[cell setImageID:IDR_STOP_D
forButtonState:image_button_cell::kDefaultState]; forButtonState:image_button_cell::kDefaultState];
[cell setImageID:IDR_STOP_D [[self cell] setImage:disabledStopImage
forButtonState:image_button_cell::kDisabledState];
[cell setImageID:IDR_STOP_D
forButtonState:image_button_cell::kHoverState]; forButtonState:image_button_cell::kHoverState];
[cell setImageID:IDR_STOP_D [[self cell] setImage:disabledStopImage
forButtonState:image_button_cell::kPressedState]; forButtonState:image_button_cell::kPressedState];
}
pendingReloadTimer_ = pendingReloadTimer_ =
[NSTimer timerWithTimeInterval:kPendingReloadTimeout [NSTimer timerWithTimeInterval:kPendingReloadTimeout
target:self target:self
......
...@@ -153,10 +153,6 @@ const NSSize kMDButtonIconSize = NSMakeSize(16, 16); ...@@ -153,10 +153,6 @@ const NSSize kMDButtonIconSize = NSMakeSize(16, 16);
@synthesize handleMiddleClick = handleMiddleClick_; @synthesize handleMiddleClick = handleMiddleClick_;
+ (NSSize)toolbarButtonSize { + (NSSize)toolbarButtonSize {
if (!ui::MaterialDesignController::IsModeMaterial()) {
return NSMakeSize(29, 29);
}
return kMDButtonBounds.size; return kMDButtonBounds.size;
} }
...@@ -235,11 +231,7 @@ const NSSize kMDButtonIconSize = NSMakeSize(16, 16); ...@@ -235,11 +231,7 @@ const NSSize kMDButtonIconSize = NSMakeSize(16, 16);
[[BrowserToolsImageRep alloc] [[BrowserToolsImageRep alloc]
initWithDrawSelector:@selector(drawBrowserToolsIcon:) initWithDrawSelector:@selector(drawBrowserToolsIcon:)
delegate:[BrowserToolsImageRep class]]); delegate:[BrowserToolsImageRep class]]);
if (!ui::MaterialDesignController::IsModeMaterial()) { [imageRep setFillColor:skia::SkColorToSRGBNSColor(fillColor)];
[imageRep setFillColor:skia::SkColorToCalibratedNSColor(fillColor)];
} else {
[imageRep setFillColor:skia::SkColorToSRGBNSColor(fillColor)];
}
// Create the image from the image rep. // Create the image from the image rep.
NSImage* browserToolsIcon = NSImage* browserToolsIcon =
...@@ -271,19 +263,11 @@ const NSSize kMDButtonIconSize = NSMakeSize(16, 16); ...@@ -271,19 +263,11 @@ const NSSize kMDButtonIconSize = NSMakeSize(16, 16);
} }
- (NSImage*)image { - (NSImage*)image {
if (!ui::MaterialDesignController::IsModeMaterial()) {
return [super image];
}
// setImage: stores the image in an ivar. // setImage: stores the image in an ivar.
return image_.get(); return image_.get();
} }
- (void)setImage:(NSImage*)anImage { - (void)setImage:(NSImage*)anImage {
if (!ui::MaterialDesignController::IsModeMaterial()) {
[super setImage:anImage];
return;
}
// We want to set the default image as the image for kDefaultState. Setting it // We want to set the default image as the image for kDefaultState. Setting it
// as the default image (via setImage:) can cause ghosting from the two // as the default image (via setImage:) can cause ghosting from the two
// default images being drawn over each other. However we also need to keep // default images being drawn over each other. However we also need to keep
...@@ -294,8 +278,6 @@ const NSSize kMDButtonIconSize = NSMakeSize(16, 16); ...@@ -294,8 +278,6 @@ const NSSize kMDButtonIconSize = NSMakeSize(16, 16);
} }
- (void)resetButtonStateImages { - (void)resetButtonStateImages {
DCHECK(ui::MaterialDesignController::IsModeMaterial());
NSImage* normalIcon = nil; NSImage* normalIcon = nil;
NSImage* disabledIcon = nil; NSImage* disabledIcon = nil;
BOOL isDarkTheme = NO; BOOL isDarkTheme = NO;
...@@ -383,7 +365,7 @@ const NSSize kMDButtonIconSize = NSMakeSize(16, 16); ...@@ -383,7 +365,7 @@ const NSSize kMDButtonIconSize = NSMakeSize(16, 16);
// In Material Design we want to catch when the button is attached to its // In Material Design we want to catch when the button is attached to its
// window so that we can configure its appearance based on the window's // window so that we can configure its appearance based on the window's
// theme. // theme.
if ([self window] && ui::MaterialDesignController::IsModeMaterial()) { if ([self window]) {
[self resetButtonStateImages]; [self resetButtonStateImages];
} }
} }
...@@ -392,9 +374,7 @@ const NSSize kMDButtonIconSize = NSMakeSize(16, 16); ...@@ -392,9 +374,7 @@ const NSSize kMDButtonIconSize = NSMakeSize(16, 16);
- (void)windowDidChangeTheme { - (void)windowDidChangeTheme {
// Update the hover and pressed image backgrounds to match the current theme. // Update the hover and pressed image backgrounds to match the current theme.
if (ui::MaterialDesignController::IsModeMaterial()) { [self resetButtonStateImages];
[self resetButtonStateImages];
}
} }
- (void)windowDidChangeActive { - (void)windowDidChangeActive {
......
...@@ -21,15 +21,6 @@ ...@@ -21,15 +21,6 @@
[self drawBackground:dirtyRect]; [self drawBackground:dirtyRect];
} }
// Override of |-[BackgroundGradientView strokeColor]|; make it respect opacity.
- (NSColor*)strokeColor {
// Only return a transparent color if not Material Design.
if (!ui::MaterialDesignController::IsModeMaterial()) {
return [[super strokeColor] colorWithAlphaComponent:[self dividerOpacity]];
}
return [super strokeColor];
}
- (BOOL)accessibilityIsIgnored { - (BOOL)accessibilityIsIgnored {
return NO; return NO;
} }
......
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