Commit d9756248 authored by Peter Kasting's avatar Peter Kasting Committed by Commit Bot

Revert "Add Windows high contrast support to the toolbar button icons"

This reverts commit 26a7b762.

Reason for revert: Likely caused http://crbug.com/1049486

Original change's description:
> Add Windows high contrast support to the toolbar button icons
> 
> This change adds different foreground icon colors to the toolbar buttons
> for the hovered and pressed states when the high contrast ink drop
> feature is enabled. This is to support the desired platform high contrast
> colors. Future work will add foreground color support to other buttons.
> 
> New theme properties were added to support the additional _HOVERED and
> _PRESSED state high contrast colors. When not in high contrast, these
> are the same as the normal icon color. In high contrast (+ flag) they
> return the selected text HC color. These new colors are used to create
> images in the toolbar buttons for the various button states.
> 
> New helper functions we added to ToolbarButton to simplify setting the
> images for the different button states, including one that just uses
> the standard colors returned by |GetForegroundColor|.
> 
> In the future, we might want to do work to allow icons to be separated
> from colors to allow for easier recoloring.
> 
> Bug: 776871
> Change-Id: Id72d8c60a23889f018044a5fcce7abd9359ad61a
> Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2029492
> Reviewed-by: Denis Kuznetsov [CET] <antrim@chromium.org>
> Reviewed-by: Peter Kasting <pkasting@chromium.org>
> Commit-Queue: Peter Kasting <pkasting@chromium.org>
> Cr-Commit-Position: refs/heads/master@{#738660}

TBR=pkasting@chromium.org,antrim@chromium.org,johnsm@microsoft.com,champnic@microsoft.com

Change-Id: Ide6174254819728c271a3ed059cee7132cd2c124
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: 776871
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2040029Reviewed-by: default avatarPeter Kasting <pkasting@chromium.org>
Commit-Queue: Peter Kasting <pkasting@chromium.org>
Cr-Commit-Position: refs/heads/master@{#738863}
parent 9f8031a1
...@@ -353,6 +353,10 @@ void SimpleWebViewDialog::LoadImages() { ...@@ -353,6 +353,10 @@ void SimpleWebViewDialog::LoadImages() {
tp->GetImageSkiaNamed(IDR_FORWARD_P)); tp->GetImageSkiaNamed(IDR_FORWARD_P));
forward_->SetImage(views::Button::STATE_DISABLED, forward_->SetImage(views::Button::STATE_DISABLED,
tp->GetImageSkiaNamed(IDR_FORWARD_D)); tp->GetImageSkiaNamed(IDR_FORWARD_D));
reload_->SetColors(
tp->GetColor(ThemeProperties::COLOR_TOOLBAR_BUTTON_ICON),
tp->GetColor(ThemeProperties::COLOR_TOOLBAR_BUTTON_ICON_INACTIVE));
} }
void SimpleWebViewDialog::UpdateButtons() { void SimpleWebViewDialog::UpdateButtons() {
......
...@@ -257,8 +257,6 @@ SkColor ThemeHelper::GetDefaultColor( ...@@ -257,8 +257,6 @@ SkColor ThemeHelper::GetDefaultColor(
return color_utils::GetColorWithMaxContrast( return color_utils::GetColorWithMaxContrast(
GetColor(TP::COLOR_OMNIBOX_BACKGROUND, incognito, theme_supplier)); GetColor(TP::COLOR_OMNIBOX_BACKGROUND, incognito, theme_supplier));
case TP::COLOR_TOOLBAR_BUTTON_ICON: case TP::COLOR_TOOLBAR_BUTTON_ICON:
case TP::COLOR_TOOLBAR_BUTTON_ICON_HOVERED:
case TP::COLOR_TOOLBAR_BUTTON_ICON_PRESSED:
return color_utils::HSLShift( return color_utils::HSLShift(
gfx::kChromeIconGrey, gfx::kChromeIconGrey,
GetTint(TP::TINT_BUTTONS, incognito, theme_supplier)); GetTint(TP::TINT_BUTTONS, incognito, theme_supplier));
......
...@@ -179,14 +179,6 @@ bool ThemeHelperWin::GetPlatformHighContrastColor(int id, ...@@ -179,14 +179,6 @@ bool ThemeHelperWin::GetPlatformHighContrastColor(int id,
break; break;
// Highlight/Selected Text Foreground // Highlight/Selected Text Foreground
case ThemeProperties::COLOR_TOOLBAR_BUTTON_ICON_HOVERED:
case ThemeProperties::COLOR_TOOLBAR_BUTTON_ICON_PRESSED:
if (!base::FeatureList::IsEnabled(
views::features::kEnablePlatformHighContrastInkDrop)) {
return GetPlatformHighContrastColor(
ThemeProperties::COLOR_TOOLBAR_BUTTON_ICON, color);
}
FALLTHROUGH;
case ThemeProperties::COLOR_TAB_TEXT: case ThemeProperties::COLOR_TAB_TEXT:
case ThemeProperties::COLOR_OMNIBOX_RESULTS_TEXT_SELECTED: case ThemeProperties::COLOR_OMNIBOX_RESULTS_TEXT_SELECTED:
case ThemeProperties::COLOR_OMNIBOX_RESULTS_TEXT_DIMMED_SELECTED: case ThemeProperties::COLOR_OMNIBOX_RESULTS_TEXT_DIMMED_SELECTED:
......
...@@ -96,10 +96,6 @@ class ThemeProperties { ...@@ -96,10 +96,6 @@ class ThemeProperties {
// contents. // contents.
COLOR_TOOLBAR_CONTENT_AREA_SEPARATOR, COLOR_TOOLBAR_CONTENT_AREA_SEPARATOR,
// The color of a toolbar button's icon when it is being hovered or pressed.
COLOR_TOOLBAR_BUTTON_ICON_HOVERED,
COLOR_TOOLBAR_BUTTON_ICON_PRESSED,
// The color of a disabled toolbar button's icon. // The color of a disabled toolbar button's icon.
COLOR_TOOLBAR_BUTTON_ICON_INACTIVE, COLOR_TOOLBAR_BUTTON_ICON_INACTIVE,
......
...@@ -195,8 +195,6 @@ SkColor SkColorFromColorId(ui::NativeTheme::ColorId color_id) { ...@@ -195,8 +195,6 @@ SkColor SkColorFromColorId(ui::NativeTheme::ColorId color_id) {
// Button // Button
case ui::NativeTheme::kColorId_ButtonEnabledColor: case ui::NativeTheme::kColorId_ButtonEnabledColor:
case ui::NativeTheme::kColorId_ButtonHoveredColor:
case ui::NativeTheme::kColorId_ButtonPressedColor:
case ui::NativeTheme::kColorId_ButtonUncheckedColor: case ui::NativeTheme::kColorId_ButtonUncheckedColor:
return GetFgColor("GtkButton#button.text-button GtkLabel"); return GetFgColor("GtkButton#button.text-button GtkLabel");
case ui::NativeTheme::kColorId_ButtonDisabledColor: case ui::NativeTheme::kColorId_ButtonDisabledColor:
......
...@@ -71,17 +71,17 @@ bool IsUnstableChannel() { ...@@ -71,17 +71,17 @@ bool IsUnstableChannel() {
// Returns the icon color based on |severity|. |promo_highlight_color|, if // Returns the icon color based on |severity|. |promo_highlight_color|, if
// specified, overrides the basic color when |severity| is NONE. // specified, overrides the basic color when |severity| is NONE.
SkColor GetIconColorForSeverity( SkColor GetIconColorForSeverity(AppMenuIconController::Delegate* delegate,
AppMenuIconController::Delegate* delegate, AppMenuIconController::Severity severity,
AppMenuIconController::Severity severity, base::Optional<SkColor> promo_highlight_color) {
const base::Optional<SkColor>& severity_none_color) {
ui::NativeTheme::ColorId color_id = ui::NativeTheme::ColorId color_id =
ui::NativeTheme::kColorId_AlertSeverityHigh; ui::NativeTheme::kColorId_AlertSeverityHigh;
switch (severity) { switch (severity) {
case AppMenuIconController::Severity::NONE: case AppMenuIconController::Severity::NONE:
return severity_none_color.value_or( if (promo_highlight_color)
delegate->GetViewThemeProvider()->GetColor( return promo_highlight_color.value();
ThemeProperties::COLOR_TOOLBAR_BUTTON_ICON)); return delegate->GetViewThemeProvider()->GetColor(
ThemeProperties::COLOR_TOOLBAR_BUTTON_ICON);
case AppMenuIconController::Severity::LOW: case AppMenuIconController::Severity::LOW:
color_id = ui::NativeTheme::kColorId_AlertSeverityLow; color_id = ui::NativeTheme::kColorId_AlertSeverityLow;
break; break;
...@@ -151,7 +151,7 @@ AppMenuIconController::GetTypeAndSeverity() const { ...@@ -151,7 +151,7 @@ AppMenuIconController::GetTypeAndSeverity() const {
gfx::ImageSkia AppMenuIconController::GetIconImage( gfx::ImageSkia AppMenuIconController::GetIconImage(
bool touch_ui, bool touch_ui,
const base::Optional<SkColor>& severity_none_color) const { base::Optional<SkColor> promo_highlight_color) const {
const auto type_and_severity = GetTypeAndSeverity(); const auto type_and_severity = GetTypeAndSeverity();
const gfx::VectorIcon* icon_id = const gfx::VectorIcon* icon_id =
touch_ui ? &kBrowserToolsTouchIcon : &kBrowserToolsIcon; touch_ui ? &kBrowserToolsTouchIcon : &kBrowserToolsIcon;
...@@ -169,13 +169,13 @@ gfx::ImageSkia AppMenuIconController::GetIconImage( ...@@ -169,13 +169,13 @@ gfx::ImageSkia AppMenuIconController::GetIconImage(
} }
return gfx::CreateVectorIcon( return gfx::CreateVectorIcon(
*icon_id, GetIconColorForSeverity(delegate_, type_and_severity.severity, *icon_id, GetIconColorForSeverity(delegate_, type_and_severity.severity,
severity_none_color)); promo_highlight_color));
} }
SkColor AppMenuIconController::GetIconColor( SkColor AppMenuIconController::GetIconColor(
const base::Optional<SkColor>& severity_none_color) const { base::Optional<SkColor> promo_highlight_color) const {
return GetIconColorForSeverity(delegate_, GetTypeAndSeverity().severity, return GetIconColorForSeverity(delegate_, GetTypeAndSeverity().severity,
severity_none_color); promo_highlight_color);
} }
void AppMenuIconController::OnGlobalErrorsChanged() { void AppMenuIconController::OnGlobalErrorsChanged() {
......
...@@ -83,17 +83,15 @@ class AppMenuIconController : public GlobalErrorObserver, ...@@ -83,17 +83,15 @@ class AppMenuIconController : public GlobalErrorObserver,
// Returns the image to be used for the app menu's icon and the upgrade item // Returns the image to be used for the app menu's icon and the upgrade item
// in the app menu (when the IconType is UPGRADE_NOTIFICATION). |touch_ui| // in the app menu (when the IconType is UPGRADE_NOTIFICATION). |touch_ui|
// indicates whether the touch-friendly variant is requested. // indicates whether the touch-friendly variant is requested.
// |severity_none_color|, if provided, will be used when the Severity is NONE. // |promo_highlight_color|, if provided, overrides the basic color when the
// Otherwise the basic toolbar button icon color will be used. // app menu icon's Severity is NONE.
gfx::ImageSkia GetIconImage( gfx::ImageSkia GetIconImage(
bool touch_ui, bool touch_ui,
const base::Optional<SkColor>& severity_none_color = base::nullopt) const; base::Optional<SkColor> promo_highlight_color = base::nullopt) const;
// Gets the color to be used for the app menu's icon. // Gets the color to be used for the app menu's icon. |promo_highlight_color|,
// |severity_none_color|, if provided, will be used when the Severity is NONE. // if provided, overrides the basic color when the icon's Severity is NONE.
// Otherwise the basic toolbar button icon color will be used. SkColor GetIconColor(base::Optional<SkColor> promo_highlight_color) const;
SkColor GetIconColor(
const base::Optional<SkColor>& severity_none_color) const;
private: private:
// GlobalErrorObserver: // GlobalErrorObserver:
......
...@@ -142,7 +142,30 @@ void MediaToolbarButtonView::UpdateIcon() { ...@@ -142,7 +142,30 @@ void MediaToolbarButtonView::UpdateIcon() {
const gfx::VectorIcon& icon = ui::MaterialDesignController::touch_ui() const gfx::VectorIcon& icon = ui::MaterialDesignController::touch_ui()
? kMediaToolbarButtonTouchIcon ? kMediaToolbarButtonTouchIcon
: kMediaToolbarButtonIcon; : kMediaToolbarButtonIcon;
UpdateIconsWithStandardColors(icon);
const SkColor normal_color =
GetThemeProvider()->GetColor(ThemeProperties::COLOR_TOOLBAR_BUTTON_ICON);
const SkColor disabled_color = GetThemeProvider()->GetColor(
ThemeProperties::COLOR_TOOLBAR_BUTTON_ICON_INACTIVE);
SetImage(views::Button::STATE_NORMAL,
gfx::CreateVectorIcon(icon, normal_color));
#if defined(OS_MACOSX)
// On Mac OS X, the toolbar is set to disabled any time the current window is
// not in focus. This causes the icon to look disabled in weird cases, such as
// when the dialog is open. Therefore on Mac we only set the disabled image
// when necessary.
if (GetEnabled()) {
SetImage(views::Button::STATE_DISABLED, gfx::ImageSkia());
} else {
SetImage(views::Button::STATE_DISABLED,
gfx::CreateVectorIcon(icon, disabled_color));
}
#else
SetImage(views::Button::STATE_DISABLED,
gfx::CreateVectorIcon(icon, disabled_color));
#endif // defined(OS_MACOSX)
} }
void MediaToolbarButtonView::ShowPromo() { void MediaToolbarButtonView::ShowPromo() {
......
...@@ -185,10 +185,8 @@ void CastToolbarButton::UpdateIcon() { ...@@ -185,10 +185,8 @@ void CastToolbarButton::UpdateIcon() {
if (!GetWidget()) if (!GetWidget())
return; return;
const gfx::VectorIcon& icon = GetCurrentIcon(); const gfx::VectorIcon& icon = GetCurrentIcon();
UpdateIconsWithColors(icon, GetIconColor(views::Button::STATE_NORMAL, &icon), SetImage(views::Button::STATE_NORMAL,
GetIconColor(views::Button::STATE_HOVERED, &icon), gfx::CreateVectorIcon(icon, GetIconColor(&icon)));
GetIconColor(views::Button::STATE_PRESSED, &icon),
GetIconColor(views::Button::STATE_DISABLED, &icon));
// This icon is smaller than the touchable-UI expected 24dp, so we need to pad // This icon is smaller than the touchable-UI expected 24dp, so we need to pad
// the insets to match. // the insets to match.
SetLayoutInsetDelta( SetLayoutInsetDelta(
...@@ -199,19 +197,21 @@ MediaRouterActionController* CastToolbarButton::GetActionController() const { ...@@ -199,19 +197,21 @@ MediaRouterActionController* CastToolbarButton::GetActionController() const {
return MediaRouterUIService::Get(profile_)->action_controller(); return MediaRouterUIService::Get(profile_)->action_controller();
} }
SkColor CastToolbarButton::GetIconColor(ButtonState state, SkColor CastToolbarButton::GetIconColor(const gfx::VectorIcon* icon_id) const {
const gfx::VectorIcon* icon_id) const { if (icon_id == &::vector_icons::kMediaRouterIdleIcon) {
if (icon_id == &::vector_icons::kMediaRouterIdleIcon) return GetThemeProvider()->GetColor(
return GetForegroundColor(state); ThemeProperties::COLOR_TOOLBAR_BUTTON_ICON);
if (icon_id == &::vector_icons::kMediaRouterActiveIcon) } else if (icon_id == &::vector_icons::kMediaRouterActiveIcon) {
return gfx::kGoogleBlue500; return gfx::kGoogleBlue500;
if (icon_id == &::vector_icons::kMediaRouterWarningIcon) { } else if (icon_id == &::vector_icons::kMediaRouterWarningIcon) {
return GetNativeTheme()->GetSystemColor( return GetNativeTheme()->GetSystemColor(
ui::NativeTheme::kColorId_AlertSeverityMedium); ui::NativeTheme::kColorId_AlertSeverityMedium);
} else if (icon_id == &::vector_icons::kMediaRouterErrorIcon) {
return GetNativeTheme()->GetSystemColor(
ui::NativeTheme::kColorId_AlertSeverityHigh);
} }
DCHECK(icon_id == &::vector_icons::kMediaRouterErrorIcon); NOTREACHED();
return GetNativeTheme()->GetSystemColor( return gfx::kPlaceholderColor;
ui::NativeTheme::kColorId_AlertSeverityHigh);
} }
} // namespace media_router } // namespace media_router
...@@ -76,7 +76,7 @@ class CastToolbarButton : public ToolbarButton, ...@@ -76,7 +76,7 @@ class CastToolbarButton : public ToolbarButton,
MediaRouterActionController* GetActionController() const; MediaRouterActionController* GetActionController() const;
SkColor GetIconColor(ButtonState state, const gfx::VectorIcon* icon_id) const; SkColor GetIconColor(const gfx::VectorIcon* icon_id) const;
Browser* const browser_; Browser* const browser_;
Profile* const profile_; Profile* const profile_;
......
...@@ -103,8 +103,7 @@ void AvatarToolbarButton::UpdateIcon() { ...@@ -103,8 +103,7 @@ void AvatarToolbarButton::UpdateIcon() {
return; return;
gfx::Image gaia_account_image = delegate_->GetGaiaAccountImage(); gfx::Image gaia_account_image = delegate_->GetGaiaAccountImage();
for (auto state : kButtonStates) SetImage(views::Button::STATE_NORMAL, GetAvatarIcon(gaia_account_image));
SetImage(state, GetAvatarIcon(state, gaia_account_image));
delegate_->ShowIdentityAnimation(gaia_account_image); delegate_->ShowIdentityAnimation(gaia_account_image);
} }
...@@ -251,12 +250,12 @@ base::string16 AvatarToolbarButton::GetAvatarTooltipText() const { ...@@ -251,12 +250,12 @@ base::string16 AvatarToolbarButton::GetAvatarTooltipText() const {
} }
gfx::ImageSkia AvatarToolbarButton::GetAvatarIcon( gfx::ImageSkia AvatarToolbarButton::GetAvatarIcon(
ButtonState state,
const gfx::Image& gaia_account_image) const { const gfx::Image& gaia_account_image) const {
const int icon_size = ui::MaterialDesignController::touch_ui() const int icon_size = ui::MaterialDesignController::touch_ui()
? kDefaultTouchableIconSize ? kDefaultTouchableIconSize
: kIconSizeForNonTouchUi; : kIconSizeForNonTouchUi;
SkColor icon_color = GetForegroundColor(state); SkColor icon_color =
GetThemeProvider()->GetColor(ThemeProperties::COLOR_TOOLBAR_BUTTON_ICON);
switch (delegate_->GetState()) { switch (delegate_->GetState()) {
case State::kIncognitoProfile: case State::kIncognitoProfile:
......
...@@ -80,8 +80,7 @@ class AvatarToolbarButton : public ToolbarButton, ...@@ -80,8 +80,7 @@ class AvatarToolbarButton : public ToolbarButton,
void OnHighlightChanged() override; void OnHighlightChanged() override;
base::string16 GetAvatarTooltipText() const; base::string16 GetAvatarTooltipText() const;
gfx::ImageSkia GetAvatarIcon(ButtonState state, gfx::ImageSkia GetAvatarIcon(const gfx::Image& profile_identity_image) const;
const gfx::Image& profile_identity_image) const;
void SetInsets(); void SetInsets();
......
...@@ -259,22 +259,20 @@ void BrowserAppMenuButton::OnThemeChanged() { ...@@ -259,22 +259,20 @@ void BrowserAppMenuButton::OnThemeChanged() {
} }
void BrowserAppMenuButton::UpdateIcon() { void BrowserAppMenuButton::UpdateIcon() {
bool touch_ui = ui::MaterialDesignController::touch_ui();
if (base::FeatureList::IsEnabled(features::kUseTextForUpdateButton)) { if (base::FeatureList::IsEnabled(features::kUseTextForUpdateButton)) {
const gfx::VectorIcon& icon = SetImage(
touch_ui ? kBrowserToolsTouchIcon : kBrowserToolsIcon; views::Button::STATE_NORMAL,
for (auto state : kButtonStates) { gfx::CreateVectorIcon(
SkColor icon_color = ui::MaterialDesignController::touch_ui() ? kBrowserToolsTouchIcon
toolbar_view_->app_menu_icon_controller()->GetIconColor( : kBrowserToolsIcon,
GetForegroundColor(state)); toolbar_view_->app_menu_icon_controller()->GetIconColor(
SetImage(state, gfx::CreateVectorIcon(icon, icon_color)); GetPromoHighlightColor())));
}
return; return;
} }
for (auto state : kButtonStates) { SetImage(
SetImage(state, toolbar_view_->app_menu_icon_controller()->GetIconImage( views::Button::STATE_NORMAL,
touch_ui, GetForegroundColor(state))); toolbar_view_->app_menu_icon_controller()->GetIconImage(
} ui::MaterialDesignController::touch_ui(), GetPromoHighlightColor()));
} }
void BrowserAppMenuButton::OnTouchUiChanged() { void BrowserAppMenuButton::OnTouchUiChanged() {
...@@ -287,10 +285,11 @@ const char* BrowserAppMenuButton::GetClassName() const { ...@@ -287,10 +285,11 @@ const char* BrowserAppMenuButton::GetClassName() const {
return "BrowserAppMenuButton"; return "BrowserAppMenuButton";
} }
SkColor BrowserAppMenuButton::GetForegroundColor(ButtonState state) const { base::Optional<SkColor> BrowserAppMenuButton::GetPromoHighlightColor() const {
return promo_feature_ if (promo_feature_)
? GetFeaturePromoHighlightColorForToolbar(GetThemeProvider()) return GetFeaturePromoHighlightColorForToolbar(GetThemeProvider());
: ToolbarButton::GetForegroundColor(state);
return base::nullopt;
} }
bool BrowserAppMenuButton::GetDropFormats( bool BrowserAppMenuButton::GetDropFormats(
...@@ -362,9 +361,9 @@ std::unique_ptr<views::InkDropMask> BrowserAppMenuButton::CreateInkDropMask() ...@@ -362,9 +361,9 @@ std::unique_ptr<views::InkDropMask> BrowserAppMenuButton::CreateInkDropMask()
} }
SkColor BrowserAppMenuButton::GetInkDropBaseColor() const { SkColor BrowserAppMenuButton::GetInkDropBaseColor() const {
return promo_feature_ auto promo_highlight_color = GetPromoHighlightColor();
? GetFeaturePromoHighlightColorForToolbar(GetThemeProvider()) return promo_highlight_color ? promo_highlight_color.value()
: AppMenuButton::GetInkDropBaseColor(); : AppMenuButton::GetInkDropBaseColor();
} }
base::string16 BrowserAppMenuButton::GetTooltipText(const gfx::Point& p) const { base::string16 BrowserAppMenuButton::GetTooltipText(const gfx::Point& p) const {
......
...@@ -61,12 +61,11 @@ class BrowserAppMenuButton : public AppMenuButton, ...@@ -61,12 +61,11 @@ class BrowserAppMenuButton : public AppMenuButton,
// ui::MaterialDesignControllerObserver: // ui::MaterialDesignControllerObserver:
void OnTouchUiChanged() override; void OnTouchUiChanged() override;
private:
// If the button is being used as an anchor for a promo, returns the best // If the button is being used as an anchor for a promo, returns the best
// promo color given the current background color. Otherwise, returns the // promo color given the current background color.
// standard ToolbarButton foreground color for the given |state|. base::Optional<SkColor> GetPromoHighlightColor() const;
SkColor GetForegroundColor(ButtonState state) const override;
private:
// AppMenuButton: // AppMenuButton:
const char* GetClassName() const override; const char* GetClassName() const override;
bool GetDropFormats(int* formats, bool GetDropFormats(int* formats,
......
...@@ -69,7 +69,9 @@ ReloadButton::ReloadButton(CommandUpdater* command_updater, ...@@ -69,7 +69,9 @@ ReloadButton::ReloadButton(CommandUpdater* command_updater,
icon_style_(icon_style), icon_style_(icon_style),
double_click_timer_delay_( double_click_timer_delay_(
base::TimeDelta::FromMilliseconds(views::GetDoubleClickInterval())), base::TimeDelta::FromMilliseconds(views::GetDoubleClickInterval())),
mode_switch_timer_delay_(base::TimeDelta::FromMilliseconds(1350)) {} mode_switch_timer_delay_(base::TimeDelta::FromMilliseconds(1350)),
normal_color_(gfx::kPlaceholderColor),
disabled_color_(gfx::kPlaceholderColor) {}
ReloadButton::~ReloadButton() {} ReloadButton::~ReloadButton() {}
...@@ -84,8 +86,8 @@ void ReloadButton::ChangeMode(Mode mode, bool force) { ...@@ -84,8 +86,8 @@ void ReloadButton::ChangeMode(Mode mode, bool force) {
: (visible_mode_ != Mode::kStop))) { : (visible_mode_ != Mode::kStop))) {
double_click_timer_.Stop(); double_click_timer_.Stop();
mode_switch_timer_.Stop(); mode_switch_timer_.Stop();
visible_mode_ = mode; if (mode != visible_mode_)
UpdateIcon(); ChangeModeInternal(mode);
SetEnabled(true); SetEnabled(true);
// We want to disable the button if we're preventing a change from stop to // We want to disable the button if we're preventing a change from stop to
...@@ -108,29 +110,7 @@ void ReloadButton::ChangeMode(Mode mode, bool force) { ...@@ -108,29 +110,7 @@ void ReloadButton::ChangeMode(Mode mode, bool force) {
void ReloadButton::SetColors(SkColor normal_color, SkColor disabled_color) { void ReloadButton::SetColors(SkColor normal_color, SkColor disabled_color) {
normal_color_ = normal_color; normal_color_ = normal_color;
disabled_color_ = disabled_color; disabled_color_ = disabled_color;
UpdateIcon(); ChangeModeInternal(visible_mode_);
}
void ReloadButton::OnThemeChanged() {
ToolbarButton::OnThemeChanged();
UpdateIcon();
}
void ReloadButton::UpdateIcon() {
// There's no reason to make graphical changes when we're not yet in a
// Widget. This function will be called again after widget addition.
if (!GetWidget())
return;
const gfx::VectorIcon& icon =
GetIconForMode(icon_style_, visible_mode_ == Mode::kReload);
DCHECK_EQ(normal_color_.has_value(), disabled_color_.has_value());
if (normal_color_.has_value()) {
UpdateIconsWithColors(icon, normal_color_.value(), normal_color_.value(),
normal_color_.value(), disabled_color_.value());
} else {
UpdateIconsWithStandardColors(icon);
}
} }
void ReloadButton::OnMouseExited(const ui::MouseEvent& event) { void ReloadButton::OnMouseExited(const ui::MouseEvent& event) {
...@@ -265,6 +245,18 @@ void ReloadButton::ExecuteBrowserCommand(int command, int event_flags) { ...@@ -265,6 +245,18 @@ void ReloadButton::ExecuteBrowserCommand(int command, int event_flags) {
command, ui::DispositionFromEventFlags(event_flags)); command, ui::DispositionFromEventFlags(event_flags));
} }
void ReloadButton::ChangeModeInternal(Mode mode) {
const gfx::VectorIcon& icon =
GetIconForMode(icon_style_, mode == Mode::kReload);
SetImage(views::Button::STATE_NORMAL,
gfx::CreateVectorIcon(icon, normal_color_));
SetImage(views::Button::STATE_DISABLED,
gfx::CreateVectorIcon(icon, disabled_color_));
visible_mode_ = mode;
SchedulePaint();
}
void ReloadButton::OnDoubleClickTimer() { void ReloadButton::OnDoubleClickTimer() {
if (!IsMenuShowing()) if (!IsMenuShowing())
ChangeMode(intended_mode_, false); ChangeMode(intended_mode_, false);
......
...@@ -46,9 +46,6 @@ class ReloadButton : public ToolbarButton, ...@@ -46,9 +46,6 @@ class ReloadButton : public ToolbarButton,
void SetColors(SkColor normal_color, SkColor disabled_color); void SetColors(SkColor normal_color, SkColor disabled_color);
// views::View:
void OnThemeChanged() override;
// ToolbarButton: // ToolbarButton:
void OnMouseExited(const ui::MouseEvent& event) override; void OnMouseExited(const ui::MouseEvent& event) override;
base::string16 GetTooltipText(const gfx::Point& p) const override; base::string16 GetTooltipText(const gfx::Point& p) const override;
...@@ -75,9 +72,7 @@ class ReloadButton : public ToolbarButton, ...@@ -75,9 +72,7 @@ class ReloadButton : public ToolbarButton,
std::unique_ptr<ui::SimpleMenuModel> CreateMenuModel(); std::unique_ptr<ui::SimpleMenuModel> CreateMenuModel();
void ExecuteBrowserCommand(int command, int event_flags); void ExecuteBrowserCommand(int command, int event_flags);
void ChangeModeInternal(Mode mode);
// Updates the icon images.
void UpdateIcon();
void OnDoubleClickTimer(); void OnDoubleClickTimer();
void OnStopToReloadTimer(); void OnStopToReloadTimer();
...@@ -104,9 +99,8 @@ class ReloadButton : public ToolbarButton, ...@@ -104,9 +99,8 @@ class ReloadButton : public ToolbarButton,
base::TimeDelta double_click_timer_delay_; base::TimeDelta double_click_timer_delay_;
base::TimeDelta mode_switch_timer_delay_; base::TimeDelta mode_switch_timer_delay_;
// The colors used for the icon if explicitly set by SetColors(). SkColor normal_color_;
base::Optional<SkColor> normal_color_; SkColor disabled_color_;
base::Optional<SkColor> disabled_color_;
// Indicates if reload menu is enabled. // Indicates if reload menu is enabled.
bool menu_enabled_ = false; bool menu_enabled_ = false;
......
...@@ -27,7 +27,6 @@ ...@@ -27,7 +27,6 @@
#include "ui/display/display.h" #include "ui/display/display.h"
#include "ui/display/screen.h" #include "ui/display/screen.h"
#include "ui/gfx/color_utils.h" #include "ui/gfx/color_utils.h"
#include "ui/gfx/paint_vector_icon.h"
#include "ui/gfx/text_utils.h" #include "ui/gfx/text_utils.h"
#include "ui/views/animation/ink_drop.h" #include "ui/views/animation/ink_drop.h"
#include "ui/views/animation/ink_drop_highlight.h" #include "ui/views/animation/ink_drop_highlight.h"
...@@ -185,57 +184,6 @@ void ToolbarButton::UpdateColorsAndInsets() { ...@@ -185,57 +184,6 @@ void ToolbarButton::UpdateColorsAndInsets() {
SetLabelSideSpacing(highlight_radius / 2); SetLabelSideSpacing(highlight_radius / 2);
} }
SkColor ToolbarButton::GetForegroundColor(ButtonState state) const {
const ui::ThemeProvider* tp = GetThemeProvider();
DCHECK(tp);
switch (state) {
case ButtonState::STATE_HOVERED:
return tp->GetColor(ThemeProperties::COLOR_TOOLBAR_BUTTON_ICON_HOVERED);
case ButtonState::STATE_PRESSED:
return tp->GetColor(ThemeProperties::COLOR_TOOLBAR_BUTTON_ICON_PRESSED);
case ButtonState::STATE_DISABLED:
return tp->GetColor(ThemeProperties::COLOR_TOOLBAR_BUTTON_ICON_INACTIVE);
case ButtonState::STATE_NORMAL:
return tp->GetColor(ThemeProperties::COLOR_TOOLBAR_BUTTON_ICON);
default:
NOTREACHED();
return gfx::kPlaceholderColor;
}
}
void ToolbarButton::UpdateIconsWithColors(const gfx::VectorIcon& icon,
SkColor normal_color,
SkColor hovered_color,
SkColor pressed_color,
SkColor disabled_color) {
SetImage(ButtonState::STATE_NORMAL,
gfx::CreateVectorIcon(icon, normal_color));
SetImage(ButtonState::STATE_HOVERED,
gfx::CreateVectorIcon(icon, hovered_color));
SetImage(ButtonState::STATE_PRESSED,
gfx::CreateVectorIcon(icon, pressed_color));
#if defined(OS_MACOSX)
// On Mac OS X, the toolbar is set to disabled any time the current window is
// not in focus. This causes the icon to look disabled in weird cases, such as
// when the dialog is open. Therefore on Mac we only set the disabled image
// when necessary.
if (GetEnabled()) {
SetImage(views::Button::STATE_DISABLED, gfx::ImageSkia());
return;
}
#endif // defined(OS_MACOSX)
SetImage(views::Button::STATE_DISABLED,
gfx::CreateVectorIcon(icon, disabled_color));
}
void ToolbarButton::UpdateIconsWithStandardColors(const gfx::VectorIcon& icon) {
UpdateIconsWithColors(icon, GetForegroundColor(ButtonState::STATE_NORMAL),
GetForegroundColor(ButtonState::STATE_HOVERED),
GetForegroundColor(ButtonState::STATE_PRESSED),
GetForegroundColor(ButtonState::STATE_DISABLED));
}
void ToolbarButton::SetLabelSideSpacing(int spacing) { void ToolbarButton::SetLabelSideSpacing(int spacing) {
gfx::Insets label_insets; gfx::Insets label_insets;
// Add the spacing only if text is non-empty. // Add the spacing only if text is non-empty.
......
...@@ -78,10 +78,6 @@ class ToolbarButton : public views::LabelButton, ...@@ -78,10 +78,6 @@ class ToolbarButton : public views::LabelButton,
void ClearPendingMenu(); void ClearPendingMenu();
bool IsMenuShowing() const; bool IsMenuShowing() const;
// Updates the images using the given icon and the default colors returned by
// GetForegroundColor().
void UpdateIconsWithStandardColors(const gfx::VectorIcon& icon);
// Sets |layout_insets_|, see comment there. // Sets |layout_insets_|, see comment there.
void SetLayoutInsets(const gfx::Insets& insets); void SetLayoutInsets(const gfx::Insets& insets);
...@@ -141,17 +137,6 @@ class ToolbarButton : public views::LabelButton, ...@@ -141,17 +137,6 @@ class ToolbarButton : public views::LabelButton,
void UpdateColorsAndInsets(); void UpdateColorsAndInsets();
// Returns the standard toolbar button foreground color for the given state.
// This color is typically used for the icon and text of toolbar buttons.
virtual SkColor GetForegroundColor(ButtonState state) const;
// Updates the images using the given icons and specific colors.
void UpdateIconsWithColors(const gfx::VectorIcon& icon,
SkColor normal_color,
SkColor hovered_color,
SkColor pressed_color,
SkColor disabled_color);
static constexpr int kDefaultIconSize = 16; static constexpr int kDefaultIconSize = 16;
static constexpr int kDefaultTouchableIconSize = 24; static constexpr int kDefaultTouchableIconSize = 24;
......
...@@ -894,24 +894,38 @@ views::View* ToolbarView::GetViewForDrop() { ...@@ -894,24 +894,38 @@ views::View* ToolbarView::GetViewForDrop() {
void ToolbarView::LoadImages() { void ToolbarView::LoadImages() {
DCHECK_EQ(display_mode_, DisplayMode::NORMAL); DCHECK_EQ(display_mode_, DisplayMode::NORMAL);
const ui::ThemeProvider* tp = GetThemeProvider();
const SkColor normal_color =
tp->GetColor(ThemeProperties::COLOR_TOOLBAR_BUTTON_ICON);
const SkColor disabled_color =
tp->GetColor(ThemeProperties::COLOR_TOOLBAR_BUTTON_ICON_INACTIVE);
if (browser_actions_) { if (browser_actions_) {
browser_actions_->SetSeparatorColor(GetThemeProvider()->GetColor( browser_actions_->SetSeparatorColor(
ThemeProperties::COLOR_TOOLBAR_VERTICAL_SEPARATOR)); tp->GetColor(ThemeProperties::COLOR_TOOLBAR_VERTICAL_SEPARATOR));
} }
const bool touch_ui = ui::MaterialDesignController::touch_ui(); const bool touch_ui = ui::MaterialDesignController::touch_ui();
const gfx::VectorIcon& back_image = const gfx::VectorIcon& back_image =
touch_ui ? kBackArrowTouchIcon : vector_icons::kBackArrowIcon; touch_ui ? kBackArrowTouchIcon : vector_icons::kBackArrowIcon;
back_->UpdateIconsWithStandardColors(back_image); back_->SetImage(views::Button::STATE_NORMAL,
gfx::CreateVectorIcon(back_image, normal_color));
back_->SetImage(views::Button::STATE_DISABLED,
gfx::CreateVectorIcon(back_image, disabled_color));
const gfx::VectorIcon& forward_image = const gfx::VectorIcon& forward_image =
touch_ui ? kForwardArrowTouchIcon : vector_icons::kForwardArrowIcon; touch_ui ? kForwardArrowTouchIcon : vector_icons::kForwardArrowIcon;
forward_->UpdateIconsWithStandardColors(forward_image); forward_->SetImage(views::Button::STATE_NORMAL,
gfx::CreateVectorIcon(forward_image, normal_color));
forward_->SetImage(views::Button::STATE_DISABLED,
gfx::CreateVectorIcon(forward_image, disabled_color));
const gfx::VectorIcon& home_image = const gfx::VectorIcon& home_image =
touch_ui ? kNavigateHomeTouchIcon : kNavigateHomeIcon; touch_ui ? kNavigateHomeTouchIcon : kNavigateHomeIcon;
home_->UpdateIconsWithStandardColors(home_image); home_->SetImage(views::Button::STATE_NORMAL,
gfx::CreateVectorIcon(home_image, normal_color));
if (extensions_container_) if (extensions_container_)
extensions_container_->UpdateAllIcons(); extensions_container_->UpdateAllIcons();
...@@ -934,6 +948,8 @@ void ToolbarView::LoadImages() { ...@@ -934,6 +948,8 @@ void ToolbarView::LoadImages() {
toolbar_account_icon_container_->UpdateAllIcons(); toolbar_account_icon_container_->UpdateAllIcons();
app_menu_button_->UpdateIcon(); app_menu_button_->UpdateIcon();
reload_->SetColors(normal_color, disabled_color);
} }
void ToolbarView::ShowCriticalNotification() { void ToolbarView::ShowCriticalNotification() {
......
...@@ -41,8 +41,6 @@ ...@@ -41,8 +41,6 @@
E(kColorButtonBorder, NativeTheme::kColorId_ButtonBorderColor) \ E(kColorButtonBorder, NativeTheme::kColorId_ButtonBorderColor) \
E(kColorButtonDisabledForeground, NativeTheme::kColorId_ButtonDisabledColor) \ E(kColorButtonDisabledForeground, NativeTheme::kColorId_ButtonDisabledColor) \
E(kColorButtonForeground, NativeTheme::kColorId_ButtonEnabledColor) \ E(kColorButtonForeground, NativeTheme::kColorId_ButtonEnabledColor) \
E(kColorButtonHoveredForeground, NativeTheme::kColorId_ButtonHoveredColor) \
E(kColorButtonPressedForeground, NativeTheme::kColorId_ButtonPressedColor) \
/* TODO(https://crbug.com/1003612): Map this to old color id. */ \ /* TODO(https://crbug.com/1003612): Map this to old color id. */ \
E_CPONLY(kColorButtonPressedBackground) \ E_CPONLY(kColorButtonPressedBackground) \
E(kColorButtonProminentBackground, \ E(kColorButtonProminentBackground, \
......
...@@ -21,8 +21,6 @@ void AddUiColorMixers(ColorProvider* provider) { ...@@ -21,8 +21,6 @@ void AddUiColorMixers(ColorProvider* provider) {
mixer[kColorButtonBorder] = {kColorBorderAndSeparatorForeground}; mixer[kColorButtonBorder] = {kColorBorderAndSeparatorForeground};
mixer[kColorButtonDisabledForeground] = {kColorDisabledForeground}; mixer[kColorButtonDisabledForeground] = {kColorDisabledForeground};
mixer[kColorButtonForeground] = {kColorAccent}; mixer[kColorButtonForeground] = {kColorAccent};
mixer[kColorButtonHoveredForeground] = {kColorButtonForeground};
mixer[kColorButtonPressedForeground] = {kColorButtonForeground};
mixer[kColorButtonPressedBackground] = {kColorButtonBackground}; mixer[kColorButtonPressedBackground] = {kColorButtonBackground};
mixer[kColorButtonProminentBackground] = {kColorAccent}; mixer[kColorButtonProminentBackground] = {kColorAccent};
mixer[kColorButtonProminentDisabledBackground] = mixer[kColorButtonProminentDisabledBackground] =
......
...@@ -67,8 +67,6 @@ SkColor GetAuraColor(NativeTheme::ColorId color_id, ...@@ -67,8 +67,6 @@ SkColor GetAuraColor(NativeTheme::ColorId color_id,
// Button // Button
case NativeTheme::kColorId_ButtonEnabledColor: case NativeTheme::kColorId_ButtonEnabledColor:
case NativeTheme::kColorId_ButtonHoveredColor:
case NativeTheme::kColorId_ButtonPressedColor:
case NativeTheme::kColorId_ProminentButtonColor: case NativeTheme::kColorId_ProminentButtonColor:
return gfx::kGoogleBlue300; return gfx::kGoogleBlue300;
case NativeTheme::kColorId_ButtonUncheckedColor: case NativeTheme::kColorId_ButtonUncheckedColor:
...@@ -195,8 +193,6 @@ SkColor GetAuraColor(NativeTheme::ColorId color_id, ...@@ -195,8 +193,6 @@ SkColor GetAuraColor(NativeTheme::ColorId color_id,
// Buttons // Buttons
case NativeTheme::kColorId_ButtonEnabledColor: case NativeTheme::kColorId_ButtonEnabledColor:
case NativeTheme::kColorId_ButtonHoveredColor:
case NativeTheme::kColorId_ButtonPressedColor:
return gfx::kGoogleBlue600; return gfx::kGoogleBlue600;
case NativeTheme::kColorId_ProminentButtonFocusedColor: { case NativeTheme::kColorId_ProminentButtonFocusedColor: {
const SkColor bg = base_theme->GetSystemColor( const SkColor bg = base_theme->GetSystemColor(
......
...@@ -330,11 +330,9 @@ class NATIVE_THEME_EXPORT NativeTheme { ...@@ -330,11 +330,9 @@ class NATIVE_THEME_EXPORT NativeTheme {
// FocusableBorder // FocusableBorder
kColorId_FocusedBorderColor, kColorId_FocusedBorderColor,
kColorId_UnfocusedBorderColor, kColorId_UnfocusedBorderColor,
// Button background // Button
kColorId_ButtonEnabledColor, kColorId_ButtonEnabledColor,
kColorId_ButtonDisabledColor, kColorId_ButtonDisabledColor,
kColorId_ButtonHoveredColor,
kColorId_ButtonPressedColor,
kColorId_ButtonPressedShade, kColorId_ButtonPressedShade,
kColorId_ButtonUncheckedColor, kColorId_ButtonUncheckedColor,
kColorId_ProminentButtonColor, kColorId_ProminentButtonColor,
......
...@@ -657,8 +657,6 @@ SkColor NativeThemeWin::GetPlatformHighContrastColor(ColorId color_id) const { ...@@ -657,8 +657,6 @@ SkColor NativeThemeWin::GetPlatformHighContrastColor(ColorId color_id) const {
return system_colors_[SystemThemeColor::kHighlight]; return system_colors_[SystemThemeColor::kHighlight];
// Highlight/Selected Text Foreground // Highlight/Selected Text Foreground
case kColorId_ButtonHoveredColor:
case kColorId_ButtonPressedColor:
case kColorId_TextOnProminentButtonColor: case kColorId_TextOnProminentButtonColor:
case kColorId_SelectedMenuItemForegroundColor: case kColorId_SelectedMenuItemForegroundColor:
case kColorId_TextfieldSelectionColor: case kColorId_TextfieldSelectionColor:
......
...@@ -119,9 +119,6 @@ bool Button::DefaultButtonControllerDelegate::InDrag() { ...@@ -119,9 +119,6 @@ bool Button::DefaultButtonControllerDelegate::InDrag() {
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
// static
constexpr Button::ButtonState Button::kButtonStates[STATE_COUNT];
// static // static
const Button* Button::AsButton(const views::View* view) { const Button* Button::AsButton(const views::View* view) {
return AsButton(const_cast<View*>(view)); return AsButton(const_cast<View*>(view));
......
...@@ -60,10 +60,6 @@ class VIEWS_EXPORT Button : public InkDropHostView, ...@@ -60,10 +60,6 @@ class VIEWS_EXPORT Button : public InkDropHostView,
STATE_COUNT, STATE_COUNT,
}; };
static constexpr ButtonState kButtonStates[STATE_COUNT] = {
ButtonState::STATE_NORMAL, ButtonState::STATE_HOVERED,
ButtonState::STATE_PRESSED, ButtonState::STATE_DISABLED};
// An enum describing the events on which a button should be clicked for a // An enum describing the events on which a button should be clicked for a
// given key event. // given key event.
enum class KeyClickAction { enum class KeyClickAction {
......
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