Commit 038300d6 authored by Oscar Johansson's avatar Oscar Johansson Committed by Commit Bot

Make variable names unique (mac)

When building using jumbo, files gets merged and
variables with the same name may end up in the same
scope. This commit renames such varaibles to something
more descriptive or file specific.

Bug: 803406
Change-Id: Ia43af0d95b0693ce917722397bc23db655441c29
Reviewed-on: https://chromium-review.googlesource.com/1141579Reviewed-by: default avatarAvi Drissman <avi@chromium.org>
Commit-Queue: Oscar Johansson <oscarj@opera.com>
Cr-Commit-Position: refs/heads/master@{#576139}
parent f998ad7f
...@@ -58,7 +58,7 @@ CGFloat kTooltipInset = 10; ...@@ -58,7 +58,7 @@ CGFloat kTooltipInset = 10;
hints:nil]; hints:nil];
} }
- (void)setHoverState:(HoverState)state { - (void)setHoverState:(CloseButtonHoverState)state {
[super setHoverState:state]; [super setHoverState:state];
[tooltipController_ updateTooltipDisplayState]; [tooltipController_ updateTooltipDisplayState];
} }
......
...@@ -32,7 +32,7 @@ ...@@ -32,7 +32,7 @@
// |hoverButton_| using this state information. This serialization is to // |hoverButton_| using this state information. This serialization is to
// avoid race conditions where one hover button is being opened while another // avoid race conditions where one hover button is being opened while another
// is closing. // is closing.
enum HoverState { enum BookmarkBarButtonHoverState {
kHoverStateClosed = 0, kHoverStateClosed = 0,
kHoverStateOpening = 1, kHoverStateOpening = 1,
kHoverStateOpen = 2, kHoverStateOpen = 2,
...@@ -47,7 +47,7 @@ ...@@ -47,7 +47,7 @@
// We model hover state as a state machine with specific allowable // We model hover state as a state machine with specific allowable
// transitions. |hoverState_| is the state of this machine at any // transitions. |hoverState_| is the state of this machine at any
// given time. // given time.
HoverState hoverState_; BookmarkBarButtonHoverState hoverState_;
} }
// Designated initializer. // Designated initializer.
...@@ -77,7 +77,7 @@ ...@@ -77,7 +77,7 @@
@interface BookmarkBarFolderHoverState(TestingAPI) @interface BookmarkBarFolderHoverState(TestingAPI)
// Accessors and setters for button and hover state. // Accessors and setters for button and hover state.
- (BookmarkButton*)hoverButton; - (BookmarkButton*)hoverButton;
- (HoverState)hoverState; - (BookmarkBarButtonHoverState)hoverState;
@end @end
#endif // CHROME_BROWSER_UI_COCOA_BOOKMARKS_BOOKMARK_BAR_FOLDER_HOVER_STATE_H_ #endif // CHROME_BROWSER_UI_COCOA_BOOKMARKS_BOOKMARK_BAR_FOLDER_HOVER_STATE_H_
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
#import "chrome/browser/ui/cocoa/bookmarks/bookmark_bar_controller.h" #import "chrome/browser/ui/cocoa/bookmarks/bookmark_bar_controller.h"
@interface BookmarkBarFolderHoverState(Private) @interface BookmarkBarFolderHoverState(Private)
- (void)setHoverState:(HoverState)state; - (void)setHoverState:(BookmarkBarButtonHoverState)state;
- (void)closeBookmarkFolderOnHoverButton:(BookmarkButton*)button; - (void)closeBookmarkFolderOnHoverButton:(BookmarkButton*)button;
- (void)openBookmarkFolderOnHoverButton:(BookmarkButton*)button; - (void)openBookmarkFolderOnHoverButton:(BookmarkButton*)button;
@end @end
...@@ -129,7 +129,7 @@ ...@@ -129,7 +129,7 @@
} }
// Hover state accessor. For testing only. // Hover state accessor. For testing only.
- (HoverState)hoverState { - (BookmarkBarButtonHoverState)hoverState {
return hoverState_; return hoverState_;
} }
...@@ -139,7 +139,7 @@ ...@@ -139,7 +139,7 @@
// pending open must complete before scheduling a close, and vice versa. And // pending open must complete before scheduling a close, and vice versa. And
// it is not possible to make a transition directly from open to closed, and // it is not possible to make a transition directly from open to closed, and
// vice versa. // vice versa.
- (void)setHoverState:(HoverState)state { - (void)setHoverState:(BookmarkBarButtonHoverState)state {
DCHECK( DCHECK(
(hoverState_ == kHoverStateClosed && state == kHoverStateOpening) || (hoverState_ == kHoverStateClosed && state == kHoverStateOpening) ||
(hoverState_ == kHoverStateOpening && state == kHoverStateClosed) || (hoverState_ == kHoverStateOpening && state == kHoverStateClosed) ||
......
...@@ -19,7 +19,7 @@ class BookmarkBarFolderHoverStateTest : public CocoaTest { ...@@ -19,7 +19,7 @@ class BookmarkBarFolderHoverStateTest : public CocoaTest {
// Hover state machine interface. // Hover state machine interface.
// A strict call order is implied with these calls. It is ONLY valid to make // A strict call order is implied with these calls. It is ONLY valid to make
// these specific state transitions. // these specific state transitions.
TEST_F(BookmarkBarFolderHoverStateTest, HoverState) { TEST_F(BookmarkBarFolderHoverStateTest, BookmarkBarButtonHoverState) {
base::MessageLoopForUI message_loop; base::MessageLoopForUI message_loop;
base::scoped_nsobject<BookmarkBarFolderHoverState> bbfhs; base::scoped_nsobject<BookmarkBarFolderHoverState> bbfhs;
bbfhs.reset([[BookmarkBarFolderHoverState alloc] init]); bbfhs.reset([[BookmarkBarFolderHoverState alloc] init]);
......
...@@ -30,7 +30,7 @@ NSString* const kBrowserActionsContainerKeyEventKey = ...@@ -30,7 +30,7 @@ NSString* const kBrowserActionsContainerKeyEventKey =
@"BrowserActionsContainerKeyEventKey"; @"BrowserActionsContainerKeyEventKey";
namespace { namespace {
const CGFloat kAnimationDuration = 0.2; const CGFloat kBrowserActionsResizeAnimationDuration = 0.2;
const CGFloat kGrippyWidth = 3.0; const CGFloat kGrippyWidth = 3.0;
} // namespace } // namespace
...@@ -59,7 +59,7 @@ const CGFloat kGrippyWidth = 3.0; ...@@ -59,7 +59,7 @@ const CGFloat kGrippyWidth = 3.0;
resizable_ = YES; resizable_ = YES;
resizeAnimation_.reset([[NSViewAnimation alloc] init]); resizeAnimation_.reset([[NSViewAnimation alloc] init]);
[resizeAnimation_ setDuration:kAnimationDuration]; [resizeAnimation_ setDuration:kBrowserActionsResizeAnimationDuration];
[resizeAnimation_ setAnimationBlockingMode:NSAnimationNonblocking]; [resizeAnimation_ setAnimationBlockingMode:NSAnimationNonblocking];
[resizeAnimation_ setDelegate:self]; [resizeAnimation_ setDelegate:self];
......
...@@ -37,7 +37,7 @@ using extensions::ExtensionViewHost; ...@@ -37,7 +37,7 @@ using extensions::ExtensionViewHost;
namespace { namespace {
// The duration for any animations that might be invoked by this controller. // The duration for any animations that might be invoked by this controller.
const NSTimeInterval kAnimationDuration = 0.2; const NSTimeInterval kPopupAnimationDuration = 0.2;
// There should only be one extension popup showing at one time. Keep a // There should only be one extension popup showing at one time. Keep a
// reference to it here. // reference to it here.
...@@ -378,7 +378,7 @@ class ExtensionPopupNotificationBridge : ...@@ -378,7 +378,7 @@ class ExtensionPopupNotificationBridge :
([animator alphaValue] != targetAlpha || ([animator alphaValue] != targetAlpha ||
!NSEqualRects([window frame], [animator frame]))) { !NSEqualRects([window frame], [animator frame]))) {
[NSAnimationContext beginGrouping]; [NSAnimationContext beginGrouping];
[[NSAnimationContext currentContext] setDuration:kAnimationDuration]; [[NSAnimationContext currentContext] setDuration:kPopupAnimationDuration];
[animator setAlphaValue:targetAlpha]; [animator setAlphaValue:targetAlpha];
[animator setFrame:frame display:YES]; [animator setFrame:frame display:YES];
[NSAnimationContext endGrouping]; [NSAnimationContext endGrouping];
......
...@@ -10,7 +10,7 @@ ...@@ -10,7 +10,7 @@
#import "ui/base/cocoa/menu_controller.h" #import "ui/base/cocoa/menu_controller.h"
#include "ui/base/resource/resource_bundle.h" #include "ui/base/resource/resource_bundle.h"
const CGFloat kCheckboxMargin = 10; const CGFloat kGalleryEntryCheckboxMargin = 10;
ui::MenuModel* MediaGalleryListEntryController::GetContextMenu( ui::MenuModel* MediaGalleryListEntryController::GetContextMenu(
MediaGalleryPrefId pref_id) { MediaGalleryPrefId pref_id) {
...@@ -147,13 +147,13 @@ ui::MenuModel* MediaGalleryListEntryController::GetContextMenu( ...@@ -147,13 +147,13 @@ ui::MenuModel* MediaGalleryListEntryController::GetContextMenu(
[details_ sizeToFit]; [details_ sizeToFit];
// Auto size everything and lay it out horizontally. // Auto size everything and lay it out horizontally.
CGFloat xPos = kCheckboxMargin; CGFloat xPos = kGalleryEntryCheckboxMargin;
for (NSView* view in [self subviews]) { for (NSView* view in [self subviews]) {
NSRect viewFrame = [view frame]; NSRect viewFrame = [view frame];
viewFrame.origin.x = xPos; viewFrame.origin.x = xPos;
viewFrame.size.height = std::min(NSHeight(bounds), NSHeight(viewFrame)); viewFrame.size.height = std::min(NSHeight(bounds), NSHeight(viewFrame));
[view setFrame:viewFrame]; [view setFrame:viewFrame];
xPos = NSMaxX([view frame]) + kCheckboxMargin; xPos = NSMaxX([view frame]) + kGalleryEntryCheckboxMargin;
} }
// Size the views. If all the elements don't naturally fit, the checkbox // Size the views. If all the elements don't naturally fit, the checkbox
...@@ -161,16 +161,16 @@ ui::MenuModel* MediaGalleryListEntryController::GetContextMenu( ...@@ -161,16 +161,16 @@ ui::MenuModel* MediaGalleryListEntryController::GetContextMenu(
// squish too much so it gets at least half of the max width and the details // squish too much so it gets at least half of the max width and the details
// text should elide as well in that case. // text should elide as well in that case.
if (xPos > NSWidth(bounds)) { if (xPos > NSWidth(bounds)) {
CGFloat maxRHSContent = NSWidth(bounds) / 2 - kCheckboxMargin; CGFloat maxRHSContent = NSWidth(bounds) / 2 - kGalleryEntryCheckboxMargin;
NSRect detailsFrame = [details_ frame]; NSRect detailsFrame = [details_ frame];
NSRect checkboxFrame = [checkbox_ frame]; NSRect checkboxFrame = [checkbox_ frame];
if (NSMaxX(detailsFrame) - NSMaxX(checkboxFrame) > maxRHSContent) { if (NSMaxX(detailsFrame) - NSMaxX(checkboxFrame) > maxRHSContent) {
detailsFrame.size.width = std::max( detailsFrame.size.width = std::max(
maxRHSContent - (NSMinX(detailsFrame) - NSMaxX(checkboxFrame)), maxRHSContent - (NSMinX(detailsFrame) - NSMaxX(checkboxFrame)),
NSWidth(bounds) - kCheckboxMargin - NSMinX(detailsFrame)); NSWidth(bounds) - kGalleryEntryCheckboxMargin - NSMinX(detailsFrame));
[details_ setFrameSize:detailsFrame.size]; [details_ setFrameSize:detailsFrame.size];
xPos = NSMaxX(detailsFrame) + kCheckboxMargin; xPos = NSMaxX(detailsFrame) + kGalleryEntryCheckboxMargin;
} }
CGFloat overflow = xPos - NSWidth(bounds); CGFloat overflow = xPos - NSWidth(bounds);
if (overflow > 0) { if (overflow > 0) {
...@@ -188,7 +188,7 @@ ui::MenuModel* MediaGalleryListEntryController::GetContextMenu( ...@@ -188,7 +188,7 @@ ui::MenuModel* MediaGalleryListEntryController::GetContextMenu(
for (NSView* view in [self subviews]) { for (NSView* view in [self subviews]) {
frame = NSUnionRect(frame, [view frame]); frame = NSUnionRect(frame, [view frame]);
} }
frame.size.width += kCheckboxMargin; frame.size.width += kGalleryEntryCheckboxMargin;
[super setFrameSize:frame.size]; [super setFrameSize:frame.size];
} }
} }
......
...@@ -13,7 +13,7 @@ ...@@ -13,7 +13,7 @@
namespace { namespace {
NSColor* GetBackgroundColor(HoverState state, BOOL dark_theme) { NSColor* GetBackgroundColor(CloseButtonHoverState state, BOOL dark_theme) {
if (dark_theme) { if (dark_theme) {
switch (state) { switch (state) {
case kHoverStateNone: case kHoverStateNone:
...@@ -43,28 +43,28 @@ NSColor* GetShadowColor() { ...@@ -43,28 +43,28 @@ NSColor* GetShadowColor() {
return NSColor.blackColor; return NSColor.blackColor;
} }
constexpr CGFloat kFontSize = 12; constexpr CGFloat kHarmonyButtonFontSize = 12;
constexpr CGFloat kTextAlpha = 0x8A / (CGFloat)0xFF; constexpr CGFloat kHarmonyButtonTextAlpha = 0x8A / (CGFloat)0xFF;
constexpr CGSize kNormalShadowOffset{0, 0}; constexpr CGSize kHarmonyButtonNormalShadowOffset{0, 0};
constexpr CGSize kMouseOverShadowOffset{0, 1}; constexpr CGSize kHarmonyButtonMouseOverShadowOffset{0, 1};
constexpr CGFloat kNormalShadowOpacity = 0; constexpr CGFloat kHarmonyButtonNormalShadowOpacity = 0;
constexpr CGFloat kMouseOverShadowOpacity = 0.1; constexpr CGFloat kHarmonyButtonMouseOverShadowOpacity = 0.1;
constexpr CGFloat kNormalShadowRadius = 0; constexpr CGFloat kHarmonyButtonNormalShadowRadius = 0;
constexpr CGFloat kMouseOverShadowRadius = 2; constexpr CGFloat kHarmonyButtonMouseOverShadowRadius = 2;
constexpr CGFloat kCornerRadius = 3; constexpr CGFloat kHarmonyButtonCornerRadius = 3;
constexpr CGFloat kXPadding = 16; constexpr CGFloat kHarmonyButtonXPadding = 16;
constexpr CGFloat kMinWidth = 64; constexpr CGFloat kHarmonyButtonMinWidth = 64;
constexpr CGFloat kHeight = 28; constexpr CGFloat kHarmonyButtonHeight = 28;
// The text is a bit too low by default; offset the title rect to center it. // The text is a bit too low by default; offset the title rect to center it.
constexpr CGFloat kTextYOffset = 1; constexpr CGFloat kHarmonyButtonTextYOffset = 1;
constexpr NSTimeInterval kTransitionDuration = 0.25; constexpr NSTimeInterval kHarmonyButtonTransitionDuration = 0.25;
} // namespace } // namespace
...@@ -73,7 +73,7 @@ constexpr NSTimeInterval kTransitionDuration = 0.25; ...@@ -73,7 +73,7 @@ constexpr NSTimeInterval kTransitionDuration = 0.25;
@implementation HarmonyButtonCell @implementation HarmonyButtonCell
- (NSRect)titleRectForBounds:(NSRect)rect { - (NSRect)titleRectForBounds:(NSRect)rect {
rect.origin.y -= kTextYOffset; rect.origin.y -= kHarmonyButtonTextYOffset;
return rect; return rect;
} }
@end @end
...@@ -102,7 +102,7 @@ constexpr NSTimeInterval kTransitionDuration = 0.25; ...@@ -102,7 +102,7 @@ constexpr NSTimeInterval kTransitionDuration = 0.25;
self.wantsLayer = YES; self.wantsLayer = YES;
CALayer* layer = self.layer; CALayer* layer = self.layer;
layer.shadowColor = GetShadowColor().CGColor; layer.shadowColor = GetShadowColor().CGColor;
layer.cornerRadius = kCornerRadius; layer.cornerRadius = kHarmonyButtonCornerRadius;
[self updateBorderWidth]; [self updateBorderWidth];
[self updateHoverButtonAppearanceAnimated:NO]; [self updateHoverButtonAppearanceAnimated:NO];
} }
...@@ -125,22 +125,22 @@ constexpr NSTimeInterval kTransitionDuration = 0.25; ...@@ -125,22 +125,22 @@ constexpr NSTimeInterval kTransitionDuration = 0.25;
[NSAnimationContext beginGrouping]; [NSAnimationContext beginGrouping];
NSAnimationContext* context = [NSAnimationContext currentContext]; NSAnimationContext* context = [NSAnimationContext currentContext];
context.allowsImplicitAnimation = YES; context.allowsImplicitAnimation = YES;
context.duration = kTransitionDuration; context.duration = kHarmonyButtonTransitionDuration;
} else { } else {
[layer removeAllAnimations]; [layer removeAllAnimations];
} }
switch (self.hoverState) { switch (self.hoverState) {
case kHoverStateNone: case kHoverStateNone:
layer.shadowOffset = kNormalShadowOffset; layer.shadowOffset = kHarmonyButtonNormalShadowOffset;
layer.shadowOpacity = kNormalShadowOpacity; layer.shadowOpacity = kHarmonyButtonNormalShadowOpacity;
layer.shadowRadius = kNormalShadowRadius; layer.shadowRadius = kHarmonyButtonNormalShadowRadius;
break; break;
case kHoverStateMouseOver: case kHoverStateMouseOver:
case kHoverStateMouseDown: case kHoverStateMouseDown:
layer.shadowOffset = kMouseOverShadowOffset; layer.shadowOffset = kHarmonyButtonMouseOverShadowOffset;
layer.shadowOpacity = kMouseOverShadowOpacity; layer.shadowOpacity = kHarmonyButtonMouseOverShadowOpacity;
layer.shadowRadius = kMouseOverShadowRadius; layer.shadowRadius = kHarmonyButtonMouseOverShadowRadius;
break; break;
} }
...@@ -158,7 +158,7 @@ constexpr NSTimeInterval kTransitionDuration = 0.25; ...@@ -158,7 +158,7 @@ constexpr NSTimeInterval kTransitionDuration = 0.25;
// HoverButtonCocoa overrides. // HoverButtonCocoa overrides.
- (void)setHoverState:(HoverState)state { - (void)setHoverState:(CloseButtonHoverState)state {
if (state == hoverState_) { if (state == hoverState_) {
return; return;
} }
...@@ -175,18 +175,19 @@ constexpr NSTimeInterval kTransitionDuration = 0.25; ...@@ -175,18 +175,19 @@ constexpr NSTimeInterval kTransitionDuration = 0.25;
if (const ui::ThemeProvider* themeProvider = [self.window themeProvider]) { if (const ui::ThemeProvider* themeProvider = [self.window themeProvider]) {
textColor = themeProvider->GetNSColor(ThemeProperties::COLOR_TAB_TEXT); textColor = themeProvider->GetNSColor(ThemeProperties::COLOR_TAB_TEXT);
if (!themeProvider->ShouldIncreaseContrast()) if (!themeProvider->ShouldIncreaseContrast())
textColor = [textColor colorWithAlphaComponent:kTextAlpha]; textColor = [textColor colorWithAlphaComponent:kHarmonyButtonTextAlpha];
} else { } else {
textColor = [NSColor controlTextColor]; textColor = [NSColor controlTextColor];
} }
NSFont* font; NSFont* font;
if (@available(macOS 10.11, *)) { if (@available(macOS 10.11, *)) {
font = [NSFont systemFontOfSize:kFontSize weight:NSFontWeightMedium]; font = [NSFont systemFontOfSize:kHarmonyButtonFontSize
weight:NSFontWeightMedium];
} else { } else {
font = [[NSFontManager sharedFontManager] font = [[NSFontManager sharedFontManager]
convertWeight:YES convertWeight:YES
ofFont:[NSFont systemFontOfSize:kFontSize]]; ofFont:[NSFont systemFontOfSize:kHarmonyButtonFontSize]];
} }
base::scoped_nsobject<NSMutableParagraphStyle> paragraphStyle( base::scoped_nsobject<NSMutableParagraphStyle> paragraphStyle(
...@@ -208,12 +209,14 @@ constexpr NSTimeInterval kTransitionDuration = 0.25; ...@@ -208,12 +209,14 @@ constexpr NSTimeInterval kTransitionDuration = 0.25;
- (void)sizeToFit { - (void)sizeToFit {
NSSize size = self.attributedTitle.size; NSSize size = self.attributedTitle.size;
size.width += kXPadding * 2; size.width += kHarmonyButtonXPadding * 2;
size = [self backingAlignedRect:NSMakeRect(0, 0, size.width, size.height) size = [self backingAlignedRect:NSMakeRect(0, 0, size.width, size.height)
options:NSAlignAllEdgesOutward] options:NSAlignAllEdgesOutward]
.size; .size;
[self setFrameSize:NSMakeSize(size.width > kMinWidth ? size.width : kMinWidth, [self setFrameSize:NSMakeSize(size.width > kHarmonyButtonMinWidth
kHeight)]; ? size.width
: kHarmonyButtonMinWidth,
kHarmonyButtonHeight)];
} }
// NSView overrides. // NSView overrides.
......
...@@ -17,7 +17,7 @@ ...@@ -17,7 +17,7 @@
@interface HoverCloseButton : HoverButtonCocoa<NSAnimationDelegate> { @interface HoverCloseButton : HoverButtonCocoa<NSAnimationDelegate> {
@private @private
GTMKeyValueAnimation* fadeOutAnimation_; GTMKeyValueAnimation* fadeOutAnimation_;
HoverState previousState_; CloseButtonHoverState previousState_;
} }
// The color of the icon in its idle (not-hovering) state. // The color of the icon in its idle (not-hovering) state.
......
...@@ -42,7 +42,7 @@ const SkColor kDefaultIconColor = SkColorSetARGB(0xA0, 0x00, 0x00, 0x00); ...@@ -42,7 +42,7 @@ const SkColor kDefaultIconColor = SkColorSetARGB(0xA0, 0x00, 0x00, 0x00);
- (void)setFadeOutValue:(CGFloat)value; - (void)setFadeOutValue:(CGFloat)value;
// Gets the image for the given hover state. // Gets the image for the given hover state.
- (NSImage*)imageForHoverState:(HoverState)hoverState; - (NSImage*)imageForHoverState:(CloseButtonHoverState)hoverState;
@end @end
...@@ -153,7 +153,7 @@ const SkColor kDefaultIconColor = SkColorSetARGB(0xA0, 0x00, 0x00, 0x00); ...@@ -153,7 +153,7 @@ const SkColor kDefaultIconColor = SkColorSetARGB(0xA0, 0x00, 0x00, 0x00);
[self setNeedsDisplay]; [self setNeedsDisplay];
} }
- (NSImage*)imageForHoverState:(HoverState)hoverState { - (NSImage*)imageForHoverState:(CloseButtonHoverState)hoverState {
const gfx::VectorIcon* vectorHighlightIcon = nullptr; const gfx::VectorIcon* vectorHighlightIcon = nullptr;
SkColor vectorIconColor = gfx::kPlaceholderColor; SkColor vectorIconColor = gfx::kPlaceholderColor;
...@@ -186,7 +186,7 @@ const SkColor kDefaultIconColor = SkColorSetARGB(0xA0, 0x00, 0x00, 0x00); ...@@ -186,7 +186,7 @@ const SkColor kDefaultIconColor = SkColorSetARGB(0xA0, 0x00, 0x00, 0x00);
return NSImageFromImageSkia(iconImage); return NSImageFromImageSkia(iconImage);
} }
- (void)setHoverState:(HoverState)state { - (void)setHoverState:(CloseButtonHoverState)state {
if (state != self.hoverState) { if (state != self.hoverState) {
previousState_ = self.hoverState; previousState_ = self.hoverState;
[super setHoverState:state]; [super setHoverState:state];
...@@ -250,7 +250,7 @@ const SkColor kDefaultIconColor = SkColorSetARGB(0xA0, 0x00, 0x00, 0x00); ...@@ -250,7 +250,7 @@ const SkColor kDefaultIconColor = SkColorSetARGB(0xA0, 0x00, 0x00, 0x00);
@implementation WebUIHoverCloseButton @implementation WebUIHoverCloseButton
- (NSImage*)imageForHoverState:(HoverState)hoverState { - (NSImage*)imageForHoverState:(CloseButtonHoverState)hoverState {
int imageID = IDR_CLOSE_DIALOG; int imageID = IDR_CLOSE_DIALOG;
switch (hoverState) { switch (hoverState) {
case kHoverStateNone: case kHoverStateNone:
......
...@@ -22,8 +22,7 @@ ...@@ -22,8 +22,7 @@
#include "ui/gfx/scoped_ns_graphics_context_save_gstate_mac.h" #include "ui/gfx/scoped_ns_graphics_context_save_gstate_mac.h"
namespace { namespace {
const CGFloat kAnimationDuration = 0.2; const CGFloat kResizeAnimationDuration = 0.2;
} }
@implementation AutocompleteTextField @implementation AutocompleteTextField
...@@ -45,7 +44,7 @@ const CGFloat kAnimationDuration = 0.2; ...@@ -45,7 +44,7 @@ const CGFloat kAnimationDuration = 0.2;
[[self cell] setLineBreakMode:NSLineBreakByTruncatingTail]; [[self cell] setLineBreakMode:NSLineBreakByTruncatingTail];
currentToolTips_.reset([[NSMutableArray alloc] init]); currentToolTips_.reset([[NSMutableArray alloc] init]);
resizeAnimation_.reset([[NSViewAnimation alloc] init]); resizeAnimation_.reset([[NSViewAnimation alloc] init]);
[resizeAnimation_ setDuration:kAnimationDuration]; [resizeAnimation_ setDuration:kResizeAnimationDuration];
[resizeAnimation_ setAnimationBlockingMode:NSAnimationNonblocking]; [resizeAnimation_ setAnimationBlockingMode:NSAnimationNonblocking];
[self setAlignment:cocoa_l10n_util::ShouldDoExperimentalRTLLayout() [self setAlignment:cocoa_l10n_util::ShouldDoExperimentalRTLLayout()
? NSRightTextAlignment ? NSRightTextAlignment
......
...@@ -19,10 +19,11 @@ ...@@ -19,10 +19,11 @@
namespace { namespace {
// Layout and color values for the vertical divider. // Layout and color values for the vertical divider.
const CGFloat kDividerHeight = 16.0; const CGFloat kDecorationDividerHeight = 16.0;
const CGFloat kDividerPadding = 6.0; // Between the divider and label. const CGFloat kDecorationDividerPadding =
const CGFloat kDividerGray = 0xFFA6A6A6; 6.0; // Between the divider and label.
const CGFloat kDividerGrayIncognito = 0xFFCCCCCC; const CGFloat kDecorationDividerGray = 0xFFA6A6A6;
const CGFloat kDecorationDividerGrayIncognito = 0xFFCCCCCC;
// Color values for the hover and pressed background. // Color values for the hover and pressed background.
const SkColor kHoverBackgroundColor = 0x14000000; const SkColor kHoverBackgroundColor = 0x14000000;
...@@ -165,7 +166,7 @@ LocationBarDecoration::~LocationBarDecoration() { ...@@ -165,7 +166,7 @@ LocationBarDecoration::~LocationBarDecoration() {
} }
CGFloat LocationBarDecoration::DividerPadding() const { CGFloat LocationBarDecoration::DividerPadding() const {
return kDividerPadding; return kDecorationDividerPadding;
} }
bool LocationBarDecoration::IsVisible() const { bool LocationBarDecoration::IsVisible() const {
...@@ -469,7 +470,7 @@ void LocationBarDecoration::DrawDivider(NSView* control_view, ...@@ -469,7 +470,7 @@ void LocationBarDecoration::DrawDivider(NSView* control_view,
// the line between the label and URL. // the line between the label and URL.
divider_origin.x -= line_width / 2.; divider_origin.x -= line_width / 2.;
CGFloat divider_y_frame_offset = CGFloat divider_y_frame_offset =
(NSHeight(decoration_frame) - kDividerHeight) / 2.0; (NSHeight(decoration_frame) - kDecorationDividerHeight) / 2.0;
divider_origin.y = NSMinY(decoration_frame) + divider_y_frame_offset; divider_origin.y = NSMinY(decoration_frame) + divider_y_frame_offset;
// Adjust the divider origin by 1/2 a point to visually center the // Adjust the divider origin by 1/2 a point to visually center the
// divider vertically on Retina. // divider vertically on Retina.
...@@ -477,15 +478,15 @@ void LocationBarDecoration::DrawDivider(NSView* control_view, ...@@ -477,15 +478,15 @@ void LocationBarDecoration::DrawDivider(NSView* control_view,
divider_origin.y -= 0.5; divider_origin.y -= 0.5;
} }
[line moveToPoint:divider_origin]; [line moveToPoint:divider_origin];
[line relativeLineToPoint:NSMakePoint(0, kDividerHeight)]; [line relativeLineToPoint:NSMakePoint(0, kDecorationDividerHeight)];
NSColor* divider_color = nil; NSColor* divider_color = nil;
bool location_bar_is_dark = bool location_bar_is_dark =
[[control_view window] inIncognitoModeWithSystemTheme]; [[control_view window] inIncognitoModeWithSystemTheme];
if (location_bar_is_dark) { if (location_bar_is_dark) {
divider_color = skia::SkColorToSRGBNSColor(kDividerGrayIncognito); divider_color = skia::SkColorToSRGBNSColor(kDecorationDividerGrayIncognito);
} else { } else {
divider_color = skia::SkColorToSRGBNSColor(kDividerGray); divider_color = skia::SkColorToSRGBNSColor(kDecorationDividerGray);
} }
if (alpha < 1) { if (alpha < 1) {
......
...@@ -14,9 +14,9 @@ ...@@ -14,9 +14,9 @@
#include "ui/gfx/paint_vector_icon.h" #include "ui/gfx/paint_vector_icon.h"
namespace { namespace {
constexpr int kDefaultIconSize = 16; constexpr int kMDHoverButtonDefaultIconSize = 16;
constexpr SkAlpha kIconAlpha = 0x8A; constexpr SkAlpha kMDHoverButtonIconAlpha = 0x8A;
constexpr CGFloat kHoverAnimationDuration = 0.25; constexpr CGFloat kMDHoverButtonHoverAnimationDuration = 0.25;
NSColor* GetHoveringColor(BOOL dark_theme) { NSColor* GetHoveringColor(BOOL dark_theme) {
return [NSColor colorWithWhite:dark_theme ? 1 : 0 alpha:0.08]; return [NSColor colorWithWhite:dark_theme ? 1 : 0 alpha:0.08];
...@@ -37,7 +37,7 @@ NSColor* GetActiveColor(BOOL dark_theme) { ...@@ -37,7 +37,7 @@ NSColor* GetActiveColor(BOOL dark_theme) {
- (instancetype)initWithFrame:(NSRect)frameRect { - (instancetype)initWithFrame:(NSRect)frameRect {
if ((self = [super initWithFrame:frameRect])) { if ((self = [super initWithFrame:frameRect])) {
iconSize_ = kDefaultIconSize; iconSize_ = kMDHoverButtonDefaultIconSize;
self.bezelStyle = NSRoundedBezelStyle; self.bezelStyle = NSRoundedBezelStyle;
self.bordered = NO; self.bordered = NO;
self.wantsLayer = YES; self.wantsLayer = YES;
...@@ -67,7 +67,7 @@ NSColor* GetActiveColor(BOOL dark_theme) { ...@@ -67,7 +67,7 @@ NSColor* GetActiveColor(BOOL dark_theme) {
return gfx::kPlaceholderColor; return gfx::kPlaceholderColor;
return SkColorSetA( return SkColorSetA(
[[self window] hasDarkTheme] ? SK_ColorWHITE : SK_ColorBLACK, [[self window] hasDarkTheme] ? SK_ColorWHITE : SK_ColorBLACK,
provider->ShouldIncreaseContrast() ? 0xFF : kIconAlpha); provider->ShouldIncreaseContrast() ? 0xFF : kMDHoverButtonIconAlpha);
} }
- (void)updateIcon { - (void)updateIcon {
...@@ -102,7 +102,7 @@ NSColor* GetActiveColor(BOOL dark_theme) { ...@@ -102,7 +102,7 @@ NSColor* GetActiveColor(BOOL dark_theme) {
return; return;
} }
[NSAnimationContext runAnimationGroup:^(NSAnimationContext* context) { [NSAnimationContext runAnimationGroup:^(NSAnimationContext* context) {
context.duration = kHoverAnimationDuration; context.duration = kMDHoverButtonHoverAnimationDuration;
CABasicAnimation* animation = CABasicAnimation* animation =
[CABasicAnimation animationWithKeyPath:@"backgroundColor"]; [CABasicAnimation animationWithKeyPath:@"backgroundColor"];
self.layer.backgroundColor = targetBackgroundColor; self.layer.backgroundColor = targetBackgroundColor;
...@@ -113,7 +113,7 @@ NSColor* GetActiveColor(BOOL dark_theme) { ...@@ -113,7 +113,7 @@ NSColor* GetActiveColor(BOOL dark_theme) {
// HoverButtonCocoa overrides. // HoverButtonCocoa overrides.
- (void)setHoverState:(HoverState)state { - (void)setHoverState:(CloseButtonHoverState)state {
if (state == hoverState_) if (state == hoverState_)
return; return;
const BOOL animated = const BOOL animated =
......
...@@ -32,14 +32,14 @@ ...@@ -32,14 +32,14 @@
namespace { namespace {
constexpr SkColor kButtonHoverColor = SkColorSetARGB(20, 0, 0, 0); constexpr SkColor kAvatarButtonHoverColor = SkColorSetARGB(20, 0, 0, 0);
constexpr SkColor kButtonPressedColor = SkColorSetARGB(31, 0, 0, 0); constexpr SkColor kAvatarButtonPressedColor = SkColorSetARGB(31, 0, 0, 0);
const CGFloat kButtonHeight = 24; const CGFloat kAvatarButtonHeight = 24;
// NSButtons have a default padding of 5px. Buttons should have a padding of // NSButtons have a default padding of 5px. Buttons should have a padding of
// 6px. // 6px.
const CGFloat kButtonExtraPadding = 6 - 5; const CGFloat kAvatarButtonExtraPadding = 6 - 5;
// Extra padding for the signed out avatar button. // Extra padding for the signed out avatar button.
const CGFloat kSignedOutWidthPadding = 2; const CGFloat kSignedOutWidthPadding = 2;
...@@ -80,15 +80,15 @@ const CGFloat kFrameColorDarkUpperBound = 0.33; ...@@ -80,15 +80,15 @@ const CGFloat kFrameColorDarkUpperBound = 0.33;
// is square. Otherwise, we are displaying the profile's name and an // is square. Otherwise, we are displaying the profile's name and an
// optional authentication error icon. // optional authentication error icon.
if ([self image] && !hasError_) if ([self image] && !hasError_)
buttonSize.width = kButtonHeight + kSignedOutWidthPadding; buttonSize.width = kAvatarButtonHeight + kSignedOutWidthPadding;
else else
buttonSize.width += 2 * kButtonExtraPadding; buttonSize.width += 2 * kAvatarButtonExtraPadding;
buttonSize.height = kButtonHeight; buttonSize.height = kAvatarButtonHeight;
return buttonSize; return buttonSize;
} }
- (void)drawInteriorWithFrame:(NSRect)frame inView:(NSView*)controlView { - (void)drawInteriorWithFrame:(NSRect)frame inView:(NSView*)controlView {
NSRect frameAfterPadding = NSInsetRect(frame, kButtonExtraPadding, 0); NSRect frameAfterPadding = NSInsetRect(frame, kAvatarButtonExtraPadding, 0);
[super drawInteriorWithFrame:frameAfterPadding inView:controlView]; [super drawInteriorWithFrame:frameAfterPadding inView:controlView];
} }
...@@ -106,13 +106,13 @@ const CGFloat kFrameColorDarkUpperBound = 0.33; ...@@ -106,13 +106,13 @@ const CGFloat kFrameColorDarkUpperBound = 0.33;
inView:(NSView*)controlView { inView:(NSView*)controlView {
AvatarButtonCocoa* button = AvatarButtonCocoa* button =
base::mac::ObjCCastStrict<AvatarButtonCocoa>(controlView); base::mac::ObjCCastStrict<AvatarButtonCocoa>(controlView);
HoverState hoverState = [button hoverState]; CloseButtonHoverState hoverState = [button hoverState];
NSColor* backgroundColor = nil; NSColor* backgroundColor = nil;
if (hoverState == kHoverStateMouseDown || [button isActive]) { if (hoverState == kHoverStateMouseDown || [button isActive]) {
backgroundColor = skia::SkColorToSRGBNSColor(kButtonPressedColor); backgroundColor = skia::SkColorToSRGBNSColor(kAvatarButtonPressedColor);
} else if (hoverState == kHoverStateMouseOver) { } else if (hoverState == kHoverStateMouseOver) {
backgroundColor = skia::SkColorToSRGBNSColor(kButtonHoverColor); backgroundColor = skia::SkColorToSRGBNSColor(kAvatarButtonHoverColor);
} }
if (backgroundColor) { if (backgroundColor) {
......
...@@ -32,10 +32,10 @@ ...@@ -32,10 +32,10 @@
namespace { namespace {
const int kWindowHeight = 18; const int kStatusBubbleWindowHeight = 18;
// The width of the bubble in relation to the width of the parent window. // The width of the bubble in relation to the width of the parent window.
const CGFloat kWindowWidthPercent = 1.0 / 3.0; const CGFloat kStatusBubbleWindowWidthPercent = 1.0 / 3.0;
// How close the mouse can get to the infobubble before it starts sliding // How close the mouse can get to the infobubble before it starts sliding
// off-screen. // off-screen.
...@@ -759,13 +759,13 @@ NSRect StatusBubbleMac::CalculateWindowFrame(bool expanded_width) { ...@@ -759,13 +759,13 @@ NSRect StatusBubbleMac::CalculateWindowFrame(bool expanded_width) {
screenRect = [parent_ frame]; screenRect = [parent_ frame];
} }
NSSize size = NSMakeSize(0, kWindowHeight); NSSize size = NSMakeSize(0, kStatusBubbleWindowHeight);
size = [[parent_ contentView] convertSize:size toView:nil]; size = [[parent_ contentView] convertSize:size toView:nil];
if (expanded_width) { if (expanded_width) {
size.width = screenRect.size.width; size.width = screenRect.size.width;
} else { } else {
size.width = kWindowWidthPercent * screenRect.size.width; size.width = kStatusBubbleWindowWidthPercent * screenRect.size.width;
} }
screenRect.size = size; screenRect.size = size;
......
...@@ -106,7 +106,7 @@ const CGFloat kMaxTopMargin = 130; ...@@ -106,7 +106,7 @@ const CGFloat kMaxTopMargin = 130;
[message_.textStorage [message_.textStorage
appendAttributedString:[[[NSAttributedString alloc] appendAttributedString:[[[NSAttributedString alloc]
initWithString:l10n_util::GetNSString( initWithString:l10n_util::GetNSString(
sadTab->GetMessage()) sadTab->GetInfoMessage())
attributes:@{ attributes:@{
NSFontAttributeName : messageFont, NSFontAttributeName : messageFont,
NSForegroundColorAttributeName : NSForegroundColorAttributeName :
......
...@@ -128,7 +128,7 @@ int SadTab::GetTitle() { ...@@ -128,7 +128,7 @@ int SadTab::GetTitle() {
return 0; return 0;
} }
int SadTab::GetMessage() { int SadTab::GetInfoMessage() {
switch (kind_) { switch (kind_) {
#if defined(OS_CHROMEOS) #if defined(OS_CHROMEOS)
case SAD_TAB_KIND_KILLED_BY_OOM: case SAD_TAB_KIND_KILLED_BY_OOM:
......
...@@ -46,7 +46,7 @@ class SadTab { ...@@ -46,7 +46,7 @@ class SadTab {
// different for each sad tab. (Right now, the first sad tab in a session // different for each sad tab. (Right now, the first sad tab in a session
// suggests reloading and subsequent ones suggest sending feedback.) // suggests reloading and subsequent ones suggest sending feedback.)
int GetTitle(); int GetTitle();
int GetMessage(); int GetInfoMessage();
int GetButtonTitle(); int GetButtonTitle();
int GetHelpLinkTitle(); int GetHelpLinkTitle();
......
...@@ -107,7 +107,7 @@ SadTabView::SadTabView(content::WebContents* web_contents, SadTabKind kind) ...@@ -107,7 +107,7 @@ SadTabView::SadTabView(content::WebContents* web_contents, SadTabKind kind)
unrelated_vertical_spacing_large); unrelated_vertical_spacing_large);
layout->AddView(title_, 2, 1.0); layout->AddView(title_, 2, 1.0);
message_ = CreateFormattedLabel(l10n_util::GetStringUTF16(GetMessage())); message_ = CreateFormattedLabel(l10n_util::GetStringUTF16(GetInfoMessage()));
layout->StartRowWithPadding(views::GridLayout::kFixedSize, column_set_id, layout->StartRowWithPadding(views::GridLayout::kFixedSize, column_set_id,
views::GridLayout::kFixedSize, views::GridLayout::kFixedSize,
kTitleBottomSpacing); kTitleBottomSpacing);
......
...@@ -107,7 +107,7 @@ const int kFontSizeDelta = ui::ResourceBundle::kSmallFontDelta; ...@@ -107,7 +107,7 @@ const int kFontSizeDelta = ui::ResourceBundle::kSmallFontDelta;
NSColor* centerColor; NSColor* centerColor;
NSColor* innerColor; NSColor* innerColor;
NSColor* outerColor; NSColor* outerColor;
HoverState hoverState = CloseButtonHoverState hoverState =
[base::mac::ObjCCastStrict<HoverButtonCocoa>(controlView) hoverState]; [base::mac::ObjCCastStrict<HoverButtonCocoa>(controlView) hoverState];
// Leave a sliver of height 1 for the button drop shadow. // Leave a sliver of height 1 for the button drop shadow.
frame.size.height -= 1; frame.size.height -= 1;
......
...@@ -33,13 +33,13 @@ UI_BASE_EXPORT ...@@ -33,13 +33,13 @@ UI_BASE_EXPORT
@protected @protected
// Enumeration of the hover states that the close button can be in at any one // Enumeration of the hover states that the close button can be in at any one
// time. The button cannot be in more than one hover state at a time. // time. The button cannot be in more than one hover state at a time.
enum HoverState { enum CloseButtonHoverState {
kHoverStateNone = 0, kHoverStateNone = 0,
kHoverStateMouseOver = 1, kHoverStateMouseOver = 1,
kHoverStateMouseDown = 2 kHoverStateMouseDown = 2
}; };
HoverState hoverState_; CloseButtonHoverState hoverState_;
@private @private
// Tracking area for button mouseover states. Nil if not enabled. // Tracking area for button mouseover states. Nil if not enabled.
...@@ -48,7 +48,7 @@ UI_BASE_EXPORT ...@@ -48,7 +48,7 @@ UI_BASE_EXPORT
BOOL sendActionOnMouseDown_; BOOL sendActionOnMouseDown_;
} }
@property(nonatomic) HoverState hoverState; @property(nonatomic) CloseButtonHoverState hoverState;
// Enables or disables the tracking for the button. // Enables or disables the tracking for the button.
@property(nonatomic) BOOL trackingEnabled; @property(nonatomic) BOOL trackingEnabled;
......
...@@ -192,7 +192,7 @@ constexpr CGFloat kDragDistance = 5; ...@@ -192,7 +192,7 @@ constexpr CGFloat kDragDistance = 5;
} }
} }
- (void)setHoverState:(HoverState)hoverState { - (void)setHoverState:(CloseButtonHoverState)hoverState {
if (hoverState == hoverState_) if (hoverState == hoverState_)
return; return;
hoverState_ = hoverState; hoverState_ = hoverState;
......
...@@ -73,7 +73,7 @@ class HoverButtonTest : public ui::CocoaTest { ...@@ -73,7 +73,7 @@ class HoverButtonTest : public ui::CocoaTest {
} }
protected: protected:
void HoverAndExpect(HoverState hoverState) { void HoverAndExpect(CloseButtonHoverState hoverState) {
EXPECT_EQ(kHoverStateNone, button_.hoverState); EXPECT_EQ(kHoverStateNone, button_.hoverState);
[button_ mouseEntered:cocoa_test_event_utils::EnterEvent()]; [button_ mouseEntered:cocoa_test_event_utils::EnterEvent()];
EXPECT_EQ(hoverState, button_.hoverState); EXPECT_EQ(hoverState, button_.hoverState);
......
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