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 {
......
...@@ -230,18 +230,10 @@ class NotificationBridge : public AppMenuIconController::Delegate { ...@@ -230,18 +230,10 @@ class NotificationBridge : public AppMenuIconController::Delegate {
@synthesize browser = browser_; @synthesize browser = browser_;
+ (CGFloat)locationBarHeight { + (CGFloat)locationBarHeight {
if (!ui::MaterialDesignController::IsModeMaterial()) {
return 29;
}
return kMaterialDesignLocationBarHeight; return kMaterialDesignLocationBarHeight;
} }
+ (CGFloat)appMenuLeftPadding { + (CGFloat)appMenuLeftPadding {
if (!ui::MaterialDesignController::IsModeMaterial()) {
return 3;
}
return kMaterialDesignElementPadding; return kMaterialDesignElementPadding;
} }
...@@ -302,141 +294,89 @@ class NotificationBridge : public AppMenuIconController::Delegate { ...@@ -302,141 +294,89 @@ class NotificationBridge : public AppMenuIconController::Delegate {
} }
// Make Material Design layout adjustments to the NIB items. // Make Material Design layout adjustments to the NIB items.
bool isModeMaterial = ui::MaterialDesignController::IsModeMaterial(); ToolbarView* toolbarView = [self toolbarView];
if (isModeMaterial) { NSRect toolbarBounds = [toolbarView bounds];
ToolbarView* toolbarView = [self toolbarView]; NSSize toolbarButtonSize = [ToolbarButton toolbarButtonSize];
NSRect toolbarBounds = [toolbarView bounds];
NSSize toolbarButtonSize = [ToolbarButton toolbarButtonSize]; // Set the toolbar height.
NSRect frame = [toolbarView frame];
// Set the toolbar height. frame.size.height = [self baseToolbarHeight];
NSRect frame = [toolbarView frame]; [toolbarView setFrame:frame];
frame.size.height = [self baseToolbarHeight];
[toolbarView setFrame:frame]; NSRect backButtonFrame = [backButton_ frame];
backButtonFrame.origin.x =
NSRect backButtonFrame = [backButton_ frame]; kMaterialDesignElementPadding + kMaterialDesignButtonInset;
backButtonFrame.origin.x = backButtonFrame.origin.y = NSMaxY(toolbarBounds) -
kMaterialDesignElementPadding + kMaterialDesignButtonInset; kMaterialDesignElementPadding - toolbarButtonSize.height;
backButtonFrame.origin.y = NSMaxY(toolbarBounds) - backButtonFrame.size = toolbarButtonSize;
kMaterialDesignElementPadding - toolbarButtonSize.height; [backButton_ setFrame:backButtonFrame];
backButtonFrame.size = toolbarButtonSize;
[backButton_ setFrame:backButtonFrame]; NSRect forwardButtonFrame = [forwardButton_ frame];
forwardButtonFrame.origin.x =
NSRect forwardButtonFrame = [forwardButton_ frame]; NSMaxX(backButtonFrame) + 2 * kMaterialDesignButtonInset;
forwardButtonFrame.origin.x = forwardButtonFrame.origin.y = backButtonFrame.origin.y;
NSMaxX(backButtonFrame) + 2 * kMaterialDesignButtonInset; forwardButtonFrame.size = toolbarButtonSize;
forwardButtonFrame.origin.y = backButtonFrame.origin.y; [forwardButton_ setFrame:forwardButtonFrame];
forwardButtonFrame.size = toolbarButtonSize;
[forwardButton_ setFrame:forwardButtonFrame]; NSRect reloadButtonFrame = [reloadButton_ frame];
reloadButtonFrame.origin.x =
NSRect reloadButtonFrame = [reloadButton_ frame]; NSMaxX(forwardButtonFrame) + 2 * kMaterialDesignButtonInset;
reloadButtonFrame.origin.x = reloadButtonFrame.origin.y = forwardButtonFrame.origin.y;
NSMaxX(forwardButtonFrame) + 2 * kMaterialDesignButtonInset; reloadButtonFrame.size = toolbarButtonSize;
reloadButtonFrame.origin.y = forwardButtonFrame.origin.y; [reloadButton_ setFrame:reloadButtonFrame];
reloadButtonFrame.size = toolbarButtonSize;
[reloadButton_ setFrame:reloadButtonFrame]; NSRect homeButtonFrame = [homeButton_ frame];
homeButtonFrame.origin.x =
NSRect homeButtonFrame = [homeButton_ frame]; NSMaxX(reloadButtonFrame) + 2 * kMaterialDesignButtonInset;
homeButtonFrame.origin.x = homeButtonFrame.origin.y = reloadButtonFrame.origin.y;
NSMaxX(reloadButtonFrame) + 2 * kMaterialDesignButtonInset; homeButtonFrame.size = toolbarButtonSize;
homeButtonFrame.origin.y = reloadButtonFrame.origin.y; [homeButton_ setFrame:homeButtonFrame];
homeButtonFrame.size = toolbarButtonSize;
[homeButton_ setFrame:homeButtonFrame]; // Replace the app button from the nib with an AppToolbarButton instance for
// Material Design.
// Replace the app button from the nib with an AppToolbarButton instance for AppToolbarButton* newMenuButton =
// Material Design. [[[AppToolbarButton alloc] initWithFrame:[appMenuButton_ frame]]
AppToolbarButton* newMenuButton = autorelease];
[[[AppToolbarButton alloc] initWithFrame:[appMenuButton_ frame]] [newMenuButton setAutoresizingMask:[appMenuButton_ autoresizingMask]];
autorelease]; [[appMenuButton_ superview] addSubview:newMenuButton];
[newMenuButton setAutoresizingMask:[appMenuButton_ autoresizingMask]]; [appMenuButton_ removeFromSuperview];
[[appMenuButton_ superview] addSubview:newMenuButton]; appMenuButton_ = newMenuButton;
[appMenuButton_ removeFromSuperview];
appMenuButton_ = newMenuButton; // Adjust the menu button's position.
NSRect menuButtonFrame = [appMenuButton_ frame];
// Adjust the menu button's position. CGFloat menuButtonFrameMaxX =
NSRect menuButtonFrame = [appMenuButton_ frame]; NSMaxX(toolbarBounds) - [ToolbarController appMenuLeftPadding];
CGFloat menuButtonFrameMaxX = menuButtonFrame.origin.x =
NSMaxX(toolbarBounds) - [ToolbarController appMenuLeftPadding]; menuButtonFrameMaxX - kMaterialDesignButtonInset -
menuButtonFrame.origin.x = toolbarButtonSize.width;
menuButtonFrameMaxX - kMaterialDesignButtonInset - menuButtonFrame.origin.y = homeButtonFrame.origin.y;
toolbarButtonSize.width; menuButtonFrame.size = toolbarButtonSize;
menuButtonFrame.origin.y = homeButtonFrame.origin.y; [appMenuButton_ setFrame:menuButtonFrame];
menuButtonFrame.size = toolbarButtonSize;
[appMenuButton_ setFrame:menuButtonFrame]; // Adjust the size and location on the location bar to take up the
// space between the reload and menu buttons.
// Adjust the size and location on the location bar to take up the NSRect locationBarFrame = [locationBar_ frame];
// space between the reload and menu buttons. locationBarFrame.origin.x = NSMaxX(homeButtonFrame) +
NSRect locationBarFrame = [locationBar_ frame]; kMaterialDesignButtonInset;
locationBarFrame.origin.x = NSMaxX(homeButtonFrame) + if (![homeButton_ isHidden]) {
kMaterialDesignButtonInset; // Ensure proper spacing between the home button and the location bar.
if (![homeButton_ isHidden]) { locationBarFrame.origin.x += kMaterialDesignElementPadding;
// Ensure proper spacing between the home button and the location bar.
locationBarFrame.origin.x += kMaterialDesignElementPadding;
}
locationBarFrame.origin.y = NSMaxY(toolbarBounds) -
kMaterialDesignLocationBarPadding - kMaterialDesignLocationBarHeight;
locationBarFrame.size.width =
menuButtonFrame.origin.x -
locationBarFrame.origin.x;
locationBarFrame.size.height = kMaterialDesignLocationBarHeight;
[locationBar_ setFrame:locationBarFrame];
// Correctly position the extension buttons' container view.
NSRect containerFrame = [browserActionsContainerView_ frame];
containerFrame.size.width += kMaterialDesignButtonInset;
containerFrame.origin.y =
locationBarFrame.origin.y + kMaterialDesignContainerYOffset;
containerFrame.size.height = toolbarButtonSize.height;
[browserActionsContainerView_ setFrame:containerFrame];
} else {
[[backButton_ cell] setImageID:IDR_BACK
forButtonState:image_button_cell::kDefaultState];
[[backButton_ cell] setImageID:IDR_BACK_H
forButtonState:image_button_cell::kHoverState];
[[backButton_ cell] setImageID:IDR_BACK_P
forButtonState:image_button_cell::kPressedState];
[[backButton_ cell] setImageID:IDR_BACK_D
forButtonState:image_button_cell::kDisabledState];
[[forwardButton_ cell] setImageID:IDR_FORWARD
forButtonState:image_button_cell::kDefaultState];
[[forwardButton_ cell] setImageID:IDR_FORWARD_H
forButtonState:image_button_cell::kHoverState];
[[forwardButton_ cell] setImageID:IDR_FORWARD_P
forButtonState:image_button_cell::kPressedState];
[[forwardButton_ cell] setImageID:IDR_FORWARD_D
forButtonState:image_button_cell::kDisabledState];
[[reloadButton_ cell] setImageID:IDR_RELOAD
forButtonState:image_button_cell::kDefaultState];
[[reloadButton_ cell] setImageID:IDR_RELOAD_H
forButtonState:image_button_cell::kHoverState];
[[reloadButton_ cell] setImageID:IDR_RELOAD_P
forButtonState:image_button_cell::kPressedState];
[[homeButton_ cell] setImageID:IDR_HOME
forButtonState:image_button_cell::kDefaultState];
[[homeButton_ cell] setImageID:IDR_HOME_H
forButtonState:image_button_cell::kHoverState];
[[homeButton_ cell] setImageID:IDR_HOME_P
forButtonState:image_button_cell::kPressedState];
[[appMenuButton_ cell] setImageID:IDR_TOOLS
forButtonState:image_button_cell::kDefaultState];
[[appMenuButton_ cell] setImageID:IDR_TOOLS_H
forButtonState:image_button_cell::kHoverState];
[[appMenuButton_ cell] setImageID:IDR_TOOLS_P
forButtonState:image_button_cell::kPressedState];
// Adjust the toolbar height if running on Retina - see the comment in
// -baseToolbarHeight.
CGFloat toolbarHeight = [self baseToolbarHeight];
ToolbarView* toolbarView = [self toolbarView];
NSRect toolbarFrame = [toolbarView frame];
if (toolbarFrame.size.height != toolbarHeight) {
toolbarFrame.size.height = toolbarHeight;
[toolbarView setFrame:toolbarFrame];
}
} }
locationBarFrame.origin.y = NSMaxY(toolbarBounds) -
kMaterialDesignLocationBarPadding - kMaterialDesignLocationBarHeight;
locationBarFrame.size.width =
menuButtonFrame.origin.x -
locationBarFrame.origin.x;
locationBarFrame.size.height = kMaterialDesignLocationBarHeight;
[locationBar_ setFrame:locationBarFrame];
// Correctly position the extension buttons' container view.
NSRect containerFrame = [browserActionsContainerView_ frame];
containerFrame.size.width += kMaterialDesignButtonInset;
containerFrame.origin.y =
locationBarFrame.origin.y + kMaterialDesignContainerYOffset;
containerFrame.size.height = toolbarButtonSize.height;
[browserActionsContainerView_ setFrame:containerFrame];
notificationBridge_.reset( notificationBridge_.reset(
new ToolbarControllerInternal::NotificationBridge(self)); new ToolbarControllerInternal::NotificationBridge(self));
...@@ -472,10 +412,6 @@ class NotificationBridge : public AppMenuIconController::Delegate { ...@@ -472,10 +412,6 @@ class NotificationBridge : public AppMenuIconController::Delegate {
relativeTo:locationBar_]; relativeTo:locationBar_];
} }
if (!isModeMaterial) {
[locationBar_ setFont:[NSFont systemFontOfSize:[NSFont systemFontSize]]];
}
// Register pref observers for the optional home and page/options buttons // Register pref observers for the optional home and page/options buttons
// and then add them to the toolbar based on those prefs. // and then add them to the toolbar based on those prefs.
PrefService* prefs = profile_->GetPrefs(); PrefService* prefs = profile_->GetPrefs();
...@@ -507,17 +443,17 @@ class NotificationBridge : public AppMenuIconController::Delegate { ...@@ -507,17 +443,17 @@ class NotificationBridge : public AppMenuIconController::Delegate {
NSTrackingActiveAlways NSTrackingActiveAlways
owner:self owner:self
userInfo:nil]); userInfo:nil]);
NSView* toolbarView = [self view]; NSView* parentView = [self view];
[toolbarView addTrackingArea:trackingArea_.get()]; [parentView addTrackingArea:trackingArea_.get()];
// If the user has any Browser Actions installed, the container view for them // If the user has any Browser Actions installed, the container view for them
// may have to be resized depending on the width of the toolbar frame. // may have to be resized depending on the width of the toolbar frame.
[toolbarView setPostsFrameChangedNotifications:YES]; [parentView setPostsFrameChangedNotifications:YES];
[[NSNotificationCenter defaultCenter] [[NSNotificationCenter defaultCenter]
addObserver:self addObserver:self
selector:@selector(toolbarFrameChanged) selector:@selector(toolbarFrameChanged)
name:NSViewFrameDidChangeNotification name:NSViewFrameDidChangeNotification
object:toolbarView]; object:parentView];
// Set ViewIDs for toolbar elements which don't have their dedicated class. // Set ViewIDs for toolbar elements which don't have their dedicated class.
// ViewIDs of |toolbarView|, |reloadButton_|, |locationBar_| and // ViewIDs of |toolbarView|, |reloadButton_|, |locationBar_| and
...@@ -800,12 +736,8 @@ class NotificationBridge : public AppMenuIconController::Delegate { ...@@ -800,12 +736,8 @@ class NotificationBridge : public AppMenuIconController::Delegate {
// since the frame edges of each button are right on top of each other. When // since the frame edges of each button are right on top of each other. When
// hiding the button, reverse the direction of the movement (to the left). // hiding the button, reverse the direction of the movement (to the left).
CGFloat moveX = [homeButton_ frame].size.width; CGFloat moveX = [homeButton_ frame].size.width;
if (!ui::MaterialDesignController::IsModeMaterial()) { // Ensure proper spacing between the home button and the location bar.
moveX -= 1.0; moveX += kMaterialDesignElementPadding;
} else {
// Ensure proper spacing between the home button and the location bar.
moveX += kMaterialDesignElementPadding;
}
if (hide) if (hide)
moveX *= -1; // Reverse the direction of the move. moveX *= -1; // Reverse the direction of the move.
...@@ -829,12 +761,6 @@ class NotificationBridge : public AppMenuIconController::Delegate { ...@@ -829,12 +761,6 @@ class NotificationBridge : public AppMenuIconController::Delegate {
- (void)updateAppMenuButtonSeverity:(AppMenuIconPainter::Severity)severity - (void)updateAppMenuButtonSeverity:(AppMenuIconPainter::Severity)severity
iconType:(AppMenuIconController::IconType)iconType iconType:(AppMenuIconController::IconType)iconType
animate:(BOOL)animate { animate:(BOOL)animate {
if (!ui::MaterialDesignController::IsModeMaterial()) {
AppToolbarButtonCell* cell =
base::mac::ObjCCastStrict<AppToolbarButtonCell>([appMenuButton_ cell]);
[cell setSeverity:severity shouldAnimate:animate];
return;
}
AppToolbarButton* appMenuButton = AppToolbarButton* appMenuButton =
base::mac::ObjCCastStrict<AppToolbarButton>(appMenuButton_); base::mac::ObjCCastStrict<AppToolbarButton>(appMenuButton_);
[appMenuButton setSeverity:severity iconType:iconType shouldAnimate:animate]; [appMenuButton setSeverity:severity iconType:iconType shouldAnimate:animate];
...@@ -927,9 +853,7 @@ class NotificationBridge : public AppMenuIconController::Delegate { ...@@ -927,9 +853,7 @@ class NotificationBridge : public AppMenuIconController::Delegate {
locationBarXPos; locationBarXPos;
// Equalize the distance between the location bar and the first extension // Equalize the distance between the location bar and the first extension
// button, and the distance between the location bar and home/reload button. // button, and the distance between the location bar and home/reload button.
if (ui::MaterialDesignController::IsModeMaterial()) { leftDistance -= kMaterialDesignButtonInset;
leftDistance -= kMaterialDesignButtonInset;
}
} }
if (leftDistance != 0.0) if (leftDistance != 0.0)
[self adjustLocationSizeBy:leftDistance animate:animate]; [self adjustLocationSizeBy:leftDistance animate:animate];
...@@ -960,20 +884,8 @@ class NotificationBridge : public AppMenuIconController::Delegate { ...@@ -960,20 +884,8 @@ class NotificationBridge : public AppMenuIconController::Delegate {
// it afterwards. // it afterwards.
[browserActionsContainerView_ stopAnimation]; [browserActionsContainerView_ stopAnimation];
NSRect containerFrame = [browserActionsContainerView_ frame]; NSRect containerFrame = [browserActionsContainerView_ frame];
if (!ui::MaterialDesignController::IsModeMaterial()) { containerFrame.origin.y =
CGFloat elementTopPadding = [locationBar_ frame].origin.y + kMaterialDesignContainerYOffset;
kMaterialDesignElementPadding + kMaterialDesignButtonInset;
// Pre-Material Design, this value is calculated from the values in
// Toolbar.xib: the height of the toolbar (35) minus the height of the
// child elements (29) minus the y-origin of the elements (4).
elementTopPadding = 2;
containerFrame.origin.y =
NSHeight([[self view] frame]) - NSHeight(containerFrame) -
elementTopPadding;
} else {
containerFrame.origin.y =
[locationBar_ frame].origin.y + kMaterialDesignContainerYOffset;
}
[browserActionsContainerView_ setFrame:containerFrame]; [browserActionsContainerView_ setFrame:containerFrame];
[self pinLocationBarToLeftOfBrowserActionsContainerAndAnimate:NO]; [self pinLocationBarToLeftOfBrowserActionsContainerAndAnimate:NO];
} }
...@@ -1078,26 +990,8 @@ class NotificationBridge : public AppMenuIconController::Delegate { ...@@ -1078,26 +990,8 @@ class NotificationBridge : public AppMenuIconController::Delegate {
- (CGFloat)baseToolbarHeight { - (CGFloat)baseToolbarHeight {
// Height of the toolbar in pixels when the bookmark bar is closed. // Height of the toolbar in pixels when the bookmark bar is closed.
const bool kIsModeMaterial = ui::MaterialDesignController::IsModeMaterial(); const CGFloat kBaseToolbarHeightNormal = 37;
const CGFloat kBaseToolbarHeightNormal = kIsModeMaterial ? 37 : 35; return kBaseToolbarHeightNormal;
// Not all lines are drawn at 2x normal height when running on Retina, which
// causes the toolbar controls to be visually 1pt too high within the toolbar
// area. It's not possible to adjust the control y-positions by 0.5pt and have
// them appear 0.5pt lower (they are still drawn at their original locations),
// so instead shave off 1pt from the bottom of the toolbar. Note that there's
// an offsetting change in -[BookmarkBarController preferredHeight] to
// maintain the proper spacing between bookmark icons and toolbar items. See
// https://crbug.com/326245 .
const CGFloat kLineWidth = [[self view] cr_lineWidth];
const BOOL kIsRetina = (kLineWidth < 1);
BOOL reduceHeight = NO;
// Only adjust the height if Retina and not Material Design.
reduceHeight = kIsRetina && !kIsModeMaterial;
return reduceHeight ? kBaseToolbarHeightNormal - 1
: kBaseToolbarHeightNormal;
} }
- (CGFloat)desiredHeightForCompression:(CGFloat)compressByHeight { - (CGFloat)desiredHeightForCompression:(CGFloat)compressByHeight {
......
...@@ -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