Commit ff6ab32f authored by estade's avatar estade Committed by Commit bot

Co-locate all NativeTheme Aura colors.

Before this patch, colors chosen to look good for Aura were split between
CommonThemeGetSystemColor and NativeThemeAura. This moves all the colors
to the former and changes the signature a bit.

There should be no effective change on any platform with this CL.

BUG=530645
TBR=sky@chromium.org

Review URL: https://codereview.chromium.org/1476663002

Cr-Commit-Position: refs/heads/master@{#362326}
parent d9aa1226
...@@ -80,7 +80,7 @@ void DownloadShelf::PaintDownloadProgress( ...@@ -80,7 +80,7 @@ void DownloadShelf::PaintDownloadProgress(
SkPaint bg_paint; SkPaint bg_paint;
bg_paint.setStyle(SkPaint::kFill_Style); bg_paint.setStyle(SkPaint::kFill_Style);
SkColor indicator_color = SkColor indicator_color =
theme_provider.GetColor(ThemeProperties::COLOR_THROBBER_SPINNING); theme_provider.GetColor(ThemeProperties::COLOR_TAB_THROBBER_SPINNING);
bg_paint.setColor(SkColorSetA(indicator_color, 0x33)); bg_paint.setColor(SkColorSetA(indicator_color, 0x33));
bg_paint.setAntiAlias(true); bg_paint.setAntiAlias(true);
const SkScalar kCenterPoint = kProgressIndicatorSize / 2.f; const SkScalar kCenterPoint = kProgressIndicatorSize / 2.f;
......
...@@ -86,6 +86,13 @@ class ThemeProperties { ...@@ -86,6 +86,13 @@ class ThemeProperties {
// 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,
// The throbber colors for tabs or anything on a toolbar (currently, only
// the download shelf). If you're adding a throbber elsewhere, such as in
// a dialog or bubble, you likely want
// NativeTheme::kColorId_ThrobberSpinningColor.
COLOR_TAB_THROBBER_SPINNING,
COLOR_TAB_THROBBER_WAITING,
// These colors don't have constant default values. They are derived from // These colors don't have constant default values. They are derived from
// the runtime value of other colors. // the runtime value of other colors.
COLOR_NTP_SECTION_HEADER_TEXT, COLOR_NTP_SECTION_HEADER_TEXT,
...@@ -93,8 +100,6 @@ class ThemeProperties { ...@@ -93,8 +100,6 @@ class ThemeProperties {
COLOR_NTP_SECTION_HEADER_RULE, COLOR_NTP_SECTION_HEADER_RULE,
COLOR_NTP_SECTION_HEADER_RULE_LIGHT, COLOR_NTP_SECTION_HEADER_RULE_LIGHT,
COLOR_NTP_TEXT_LIGHT, COLOR_NTP_TEXT_LIGHT,
COLOR_THROBBER_SPINNING,
COLOR_THROBBER_WAITING,
#if defined(ENABLE_SUPERVISED_USERS) #if defined(ENABLE_SUPERVISED_USERS)
COLOR_SUPERVISED_USER_LABEL, COLOR_SUPERVISED_USER_LABEL,
COLOR_SUPERVISED_USER_LABEL_BACKGROUND, COLOR_SUPERVISED_USER_LABEL_BACKGROUND,
......
...@@ -240,15 +240,13 @@ SkColor ThemeService::GetColor(int id) const { ...@@ -240,15 +240,13 @@ SkColor ThemeService::GetColor(int id) const {
return IncreaseLightness(GetColor(Properties::COLOR_NTP_TEXT), 0.86); return IncreaseLightness(GetColor(Properties::COLOR_NTP_TEXT), 0.86);
case Properties::COLOR_NTP_TEXT_LIGHT: case Properties::COLOR_NTP_TEXT_LIGHT:
return IncreaseLightness(GetColor(Properties::COLOR_NTP_TEXT), 0.40); return IncreaseLightness(GetColor(Properties::COLOR_NTP_TEXT), 0.40);
case Properties::COLOR_THROBBER_SPINNING: case Properties::COLOR_TAB_THROBBER_SPINNING:
case Properties::COLOR_THROBBER_WAITING: { case Properties::COLOR_TAB_THROBBER_WAITING: {
SkColor base_color; SkColor base_color =
bool found_color = ui::CommonThemeGetSystemColor( ui::GetAuraColor(id == Properties::COLOR_TAB_THROBBER_SPINNING
id == Properties::COLOR_THROBBER_SPINNING ? ui::NativeTheme::kColorId_ThrobberSpinningColor
? ui::NativeTheme::kColorId_ThrobberSpinningColor : ui::NativeTheme::kColorId_ThrobberWaitingColor,
: ui::NativeTheme::kColorId_ThrobberWaitingColor, nullptr);
&base_color);
DCHECK(found_color);
color_utils::HSL hsl = GetTint(Properties::TINT_BUTTONS); color_utils::HSL hsl = GetTint(Properties::TINT_BUTTONS);
return color_utils::HSLShift(base_color, hsl); return color_utils::HSLShift(base_color, hsl);
} }
......
...@@ -5,7 +5,6 @@ ...@@ -5,7 +5,6 @@
#include "base/bind.h" #include "base/bind.h"
#include "base/message_loop/message_loop.h" #include "base/message_loop/message_loop.h"
#include "base/strings/sys_string_conversions.h" #include "base/strings/sys_string_conversions.h"
#include "chrome/browser/themes/theme_properties.h"
#include "chrome/browser/ui/autofill/autofill_dialog_models.h" #include "chrome/browser/ui/autofill/autofill_dialog_models.h"
#include "chrome/browser/ui/autofill/autofill_dialog_types.h" #include "chrome/browser/ui/autofill/autofill_dialog_types.h"
#include "chrome/browser/ui/chrome_style.h" #include "chrome/browser/ui/chrome_style.h"
...@@ -29,7 +28,7 @@ ...@@ -29,7 +28,7 @@
#import "ui/base/cocoa/controls/hyperlink_button_cell.h" #import "ui/base/cocoa/controls/hyperlink_button_cell.h"
#include "ui/base/cocoa/window_size_constants.h" #include "ui/base/cocoa/window_size_constants.h"
#include "ui/base/l10n/l10n_util.h" #include "ui/base/l10n/l10n_util.h"
#include "ui/base/theme_provider.h" #include "ui/native_theme/native_theme_mac.h"
namespace { namespace {
...@@ -659,11 +658,9 @@ void CardUnmaskPromptViewBridge::PerformClose() { ...@@ -659,11 +658,9 @@ void CardUnmaskPromptViewBridge::PerformClose() {
[mainView addSubview:progressOverlayView_]; [mainView addSubview:progressOverlayView_];
progressOverlayLabel_.reset([constrained_window::CreateLabel() retain]); progressOverlayLabel_.reset([constrained_window::CreateLabel() retain]);
NSView* webContentView = bridge_->GetWebContents()->GetNativeView(); NSColor* throbberBlueColor = gfx::SkColorToCalibratedNSColor(
ui::ThemeProvider* themeProvider = [[webContentView window] themeProvider]; ui::NativeThemeMac::instance()->GetSystemColor(
DCHECK(themeProvider); ui::NativeTheme::kColorId_ThrobberSpinningColor));
NSColor* throbberBlueColor = themeProvider->GetNSColor(
ThemeProperties::COLOR_THROBBER_SPINNING);
[progressOverlayLabel_ setTextColor:throbberBlueColor]; [progressOverlayLabel_ setTextColor:throbberBlueColor];
[progressOverlayView_ addSubview:progressOverlayLabel_]; [progressOverlayView_ addSubview:progressOverlayLabel_];
......
...@@ -794,12 +794,10 @@ class ActiveProfileObserverBridge : public AvatarMenuObserver, ...@@ -794,12 +794,10 @@ class ActiveProfileObserverBridge : public AvatarMenuObserver,
backgroundColor:(NSColor*)backgroundColor { backgroundColor:(NSColor*)backgroundColor {
if ((self = [super initWithFrame:frameRect])) { if ((self = [super initWithFrame:frameRect])) {
backgroundColor_.reset([backgroundColor retain]); backgroundColor_.reset([backgroundColor retain]);
// Use a color from the common theme, since this button is not trying to // Use a color from Aura, since this button is not trying to look like a
// look like a native control. // native control.
SkColor hoverColor; SkColor hoverColor = ui::GetAuraColor(
bool found = ui::CommonThemeGetSystemColor( ui::NativeTheme::kColorId_ButtonHoverBackgroundColor, nullptr);
ui::NativeTheme::kColorId_ButtonHoverBackgroundColor, &hoverColor);
DCHECK(found);
hoverColor_.reset([gfx::SkColorToSRGBNSColor(hoverColor) retain]); hoverColor_.reset([gfx::SkColorToSRGBNSColor(hoverColor) retain]);
[self setBordered:NO]; [self setBordered:NO];
......
...@@ -1011,9 +1011,9 @@ void Gtk2UI::LoadGtkValues() { ...@@ -1011,9 +1011,9 @@ void Gtk2UI::LoadGtkValues() {
theme->GetSystemColor( theme->GetSystemColor(
ui::NativeTheme::kColorId_TextfieldReadOnlyColor); ui::NativeTheme::kColorId_TextfieldReadOnlyColor);
colors_[ThemeProperties::COLOR_THROBBER_SPINNING] = colors_[ThemeProperties::COLOR_TAB_THROBBER_SPINNING] =
theme->GetSystemColor(ui::NativeTheme::kColorId_ThrobberSpinningColor); theme->GetSystemColor(ui::NativeTheme::kColorId_ThrobberSpinningColor);
colors_[ThemeProperties::COLOR_THROBBER_WAITING] = colors_[ThemeProperties::COLOR_TAB_THROBBER_WAITING] =
theme->GetSystemColor(ui::NativeTheme::kColorId_ThrobberWaitingColor); theme->GetSystemColor(ui::NativeTheme::kColorId_ThrobberWaitingColor);
} }
......
...@@ -1324,17 +1324,18 @@ void Tab::PaintIcon(gfx::Canvas* canvas) { ...@@ -1324,17 +1324,18 @@ void Tab::PaintIcon(gfx::Canvas* canvas) {
waiting_state_.elapsed_time = waiting_state_.elapsed_time =
base::TimeTicks::Now() - waiting_start_time_; base::TimeTicks::Now() - waiting_start_time_;
gfx::PaintThrobberWaiting( gfx::PaintThrobberWaiting(
canvas, bounds, tp->GetColor(ThemeProperties::COLOR_THROBBER_WAITING), canvas, bounds,
tp->GetColor(ThemeProperties::COLOR_TAB_THROBBER_WAITING),
waiting_state_.elapsed_time); waiting_state_.elapsed_time);
} else { } else {
if (loading_start_time_ == base::TimeTicks()) if (loading_start_time_ == base::TimeTicks())
loading_start_time_ = base::TimeTicks::Now(); loading_start_time_ = base::TimeTicks::Now();
waiting_state_.color = waiting_state_.color =
tp->GetColor(ThemeProperties::COLOR_THROBBER_WAITING); tp->GetColor(ThemeProperties::COLOR_TAB_THROBBER_WAITING);
gfx::PaintThrobberSpinningAfterWaiting( gfx::PaintThrobberSpinningAfterWaiting(
canvas, bounds, canvas, bounds,
tp->GetColor(ThemeProperties::COLOR_THROBBER_SPINNING), tp->GetColor(ThemeProperties::COLOR_TAB_THROBBER_SPINNING),
base::TimeTicks::Now() - loading_start_time_, &waiting_state_); base::TimeTicks::Now() - loading_start_time_, &waiting_state_);
} }
} else { } else {
......
This diff is collapsed.
...@@ -18,10 +18,11 @@ namespace ui { ...@@ -18,10 +18,11 @@ namespace ui {
// Drawing code that is common for all platforms. // Drawing code that is common for all platforms.
// Returns true and |color| if |color_id| is found, or false otherwise. // Returns the color to use on Aura for |color_id|. For a few colors that are
bool NATIVE_THEME_EXPORT CommonThemeGetSystemColor( // theme-specific, |base_theme| must be non-null; consult the code to see which
NativeTheme::ColorId color_id, // color IDs fall into this category.
SkColor* color); SkColor NATIVE_THEME_EXPORT GetAuraColor(NativeTheme::ColorId color_id,
const NativeTheme* base_theme);
gfx::Size NATIVE_THEME_EXPORT CommonThemeGetPartSize( gfx::Size NATIVE_THEME_EXPORT CommonThemeGetPartSize(
NativeTheme::Part part, NativeTheme::Part part,
......
This diff is collapsed.
...@@ -32,9 +32,6 @@ SkColor NativeThemeDarkAura::GetSystemColor(ColorId color_id) const { ...@@ -32,9 +32,6 @@ SkColor NativeThemeDarkAura::GetSystemColor(ColorId color_id) const {
static const SkColor kResultsTableDimmedText = static const SkColor kResultsTableDimmedText =
SkColorSetA(kResultsTableText, 0x80); SkColorSetA(kResultsTableText, 0x80);
static const SkColor kThrobberSpinning = SK_ColorWHITE;
static const SkColor kThrobberWaiting = SkColorSetA(kThrobberSpinning, 0x80);
switch (color_id) { switch (color_id) {
// Button // Button
case kColorId_CallToActionColor: case kColorId_CallToActionColor:
...@@ -69,13 +66,6 @@ SkColor NativeThemeDarkAura::GetSystemColor(ColorId color_id) const { ...@@ -69,13 +66,6 @@ SkColor NativeThemeDarkAura::GetSystemColor(ColorId color_id) const {
case kColorId_ResultsTableSelectedDimmedText: case kColorId_ResultsTableSelectedDimmedText:
return kResultsTableDimmedText; return kResultsTableDimmedText;
// Colors for the material spinner (aka throbber).
case kColorId_ThrobberSpinningColor:
case kColorId_ThrobberLightColor:
return kThrobberSpinning;
case kColorId_ThrobberWaitingColor:
return kThrobberWaiting;
// Intentional pass-throughs to NativeThemeAura. // Intentional pass-throughs to NativeThemeAura.
case kColorId_ResultsTableHoveredBackground: case kColorId_ResultsTableHoveredBackground:
case kColorId_ResultsTableSelectedBackground: case kColorId_ResultsTableSelectedBackground:
......
...@@ -234,15 +234,9 @@ SkColor NativeThemeMac::GetSystemColor(ColorId color_id) const { ...@@ -234,15 +234,9 @@ SkColor NativeThemeMac::GetSystemColor(ColorId color_id) const {
return SkColorSetRGB(140, 140, 140); return SkColorSetRGB(140, 140, 140);
default: default:
break; // TODO(tapted): Handle all values and remove the default case. // TODO(tapted): Handle all values and remove the default case.
return GetAuraColor(color_id, this);
} }
SkColor color;
if (CommonThemeGetSystemColor(color_id, &color))
return color;
NOTIMPLEMENTED() << " Invalid color_id: " << color_id;
return SK_ColorRED;
} }
void NativeThemeMac::PaintScrollbarTrack( void NativeThemeMac::PaintScrollbarTrack(
......
...@@ -24,6 +24,7 @@ ...@@ -24,6 +24,7 @@
#include "third_party/skia/include/core/SkColorPriv.h" #include "third_party/skia/include/core/SkColorPriv.h"
#include "third_party/skia/include/core/SkShader.h" #include "third_party/skia/include/core/SkShader.h"
#include "ui/base/resource/material_design/material_design_controller.h" #include "ui/base/resource/material_design/material_design_controller.h"
#include "ui/gfx/color_palette.h"
#include "ui/gfx/color_utils.h" #include "ui/gfx/color_utils.h"
#include "ui/gfx/gdi_util.h" #include "ui/gfx/gdi_util.h"
#include "ui/gfx/geometry/rect.h" #include "ui/gfx/geometry/rect.h"
...@@ -452,7 +453,6 @@ void NativeThemeWin::PaintDirect(SkCanvas* canvas, ...@@ -452,7 +453,6 @@ void NativeThemeWin::PaintDirect(SkCanvas* canvas,
SkColor NativeThemeWin::GetSystemColor(ColorId color_id) const { SkColor NativeThemeWin::GetSystemColor(ColorId color_id) const {
// TODO: Obtain the correct colors using GetSysColor. // TODO: Obtain the correct colors using GetSysColor.
const SkColor kInvalidColorIdColor = SkColorSetRGB(255, 0, 128);
const SkColor kUrlTextColor = SkColorSetRGB(0x0b, 0x80, 0x43); const SkColor kUrlTextColor = SkColorSetRGB(0x0b, 0x80, 0x43);
// Dialogs: // Dialogs:
const SkColor kDialogBackgroundColor = SkColorSetRGB(251, 251, 251); const SkColor kDialogBackgroundColor = SkColorSetRGB(251, 251, 251);
...@@ -463,7 +463,10 @@ SkColor NativeThemeWin::GetSystemColor(ColorId color_id) const { ...@@ -463,7 +463,10 @@ SkColor NativeThemeWin::GetSystemColor(ColorId color_id) const {
const SkColor kButtonBackgroundColor = SkColorSetRGB(0xde, 0xde, 0xde); const SkColor kButtonBackgroundColor = SkColorSetRGB(0xde, 0xde, 0xde);
const SkColor kButtonHighlightColor = SkColorSetARGB(200, 255, 255, 255); const SkColor kButtonHighlightColor = SkColorSetARGB(200, 255, 255, 255);
const SkColor kButtonHoverColor = SkColorSetRGB(6, 45, 117); const SkColor kButtonHoverColor = SkColorSetRGB(6, 45, 117);
const SkColor kCallToActionColorInvert = gfx::kGoogleBlue300;
// MenuItem: // MenuItem:
const SkColor kMenuSchemeHighlightBackgroundColorInvert =
SkColorSetRGB(0x30, 0x30, 0x30);
// Link: // Link:
const SkColor kLinkPressedColor = SkColorSetRGB(200, 0, 0); const SkColor kLinkPressedColor = SkColorSetRGB(200, 0, 0);
// Table: // Table:
...@@ -538,7 +541,7 @@ SkColor NativeThemeWin::GetSystemColor(ColorId color_id) const { ...@@ -538,7 +541,7 @@ SkColor NativeThemeWin::GetSystemColor(ColorId color_id) const {
case kColorId_TooltipBackground: case kColorId_TooltipBackground:
case kColorId_TooltipText: case kColorId_TooltipText:
NOTREACHED(); NOTREACHED();
return kInvalidColorIdColor; return gfx::kPlaceholderColor;
// Tree // Tree
// NOTE: these aren't right for all themes, but as close as I could get. // NOTE: these aren't right for all themes, but as close as I could get.
...@@ -635,12 +638,18 @@ SkColor NativeThemeWin::GetSystemColor(ColorId color_id) const { ...@@ -635,12 +638,18 @@ SkColor NativeThemeWin::GetSystemColor(ColorId color_id) const {
break; break;
} }
SkColor color; if (color_utils::IsInvertedColorScheme()) {
if (CommonThemeGetSystemColor(color_id, &color)) switch (color_id) {
return color; case NativeTheme::kColorId_FocusedMenuItemBackgroundColor:
return kMenuSchemeHighlightBackgroundColorInvert;
case NativeTheme::kColorId_CallToActionColor:
return kCallToActionColorInvert;
default:
return color_utils::InvertColor(GetAuraColor(color_id, this));
}
}
NOTREACHED(); return GetAuraColor(color_id, this);
return kInvalidColorIdColor;
} }
void NativeThemeWin::PaintIndirect(SkCanvas* canvas, void NativeThemeWin::PaintIndirect(SkCanvas* canvas,
......
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