Commit c9c3008c authored by minch's avatar minch Committed by Commit Bot

dark_mode: Remove hard code colors under ash/system.

See doc linked at the crbug for the details.

Bug: 1134809
Change-Id: Ie001e5ec75729ac61f5f5ffd10e8289982151733
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2536754Reviewed-by: default avatarXiyuan Xia <xiyuan@chromium.org>
Commit-Queue: Min Chen <minch@chromium.org>
Cr-Commit-Position: refs/heads/master@{#827357}
parent 68410177
...@@ -226,15 +226,19 @@ SkColor AshColorProvider::GetContentLayerColor(ContentLayerType type) const { ...@@ -226,15 +226,19 @@ SkColor AshColorProvider::GetContentLayerColor(ContentLayerType type) const {
case ContentLayerType::kButtonLabelColorBlue: case ContentLayerType::kButtonLabelColorBlue:
case ContentLayerType::kSliderColorActive: case ContentLayerType::kSliderColorActive:
case ContentLayerType::kRadioColorActive: case ContentLayerType::kRadioColorActive:
case ContentLayerType::kSwitchAccessInnerStrokeColor:
return is_dark_mode ? gfx::kGoogleBlue300 : gfx::kGoogleBlue600; return is_dark_mode ? gfx::kGoogleBlue300 : gfx::kGoogleBlue600;
case ContentLayerType::kButtonLabelColorPrimary: case ContentLayerType::kButtonLabelColorPrimary:
case ContentLayerType::kButtonIconColorPrimary: case ContentLayerType::kButtonIconColorPrimary:
case ContentLayerType::kBatteryBadgeColor:
return is_dark_mode ? gfx::kGoogleGrey900 : gfx::kGoogleGrey200; return is_dark_mode ? gfx::kGoogleGrey900 : gfx::kGoogleGrey200;
case ContentLayerType::kAppStateIndicatorColorInactive: case ContentLayerType::kAppStateIndicatorColorInactive:
return GetDisabledColor( return GetDisabledColor(
GetContentLayerColor(ContentLayerType::kAppStateIndicatorColor)); GetContentLayerColor(ContentLayerType::kAppStateIndicatorColor));
case ContentLayerType::kCurrentDeskColor: case ContentLayerType::kCurrentDeskColor:
return is_dark_mode ? SK_ColorWHITE : SK_ColorBLACK; return is_dark_mode ? SK_ColorWHITE : SK_ColorBLACK;
case ContentLayerType::kSwitchAccessOuterStrokeColor:
return is_dark_mode ? SK_ColorBLACK : SK_ColorWHITE;
default: default:
return ResolveColor(type, is_dark_mode); return ResolveColor(type, is_dark_mode);
} }
......
...@@ -123,6 +123,13 @@ class ASH_EXPORT AshColorProvider : public SessionObserver { ...@@ -123,6 +123,13 @@ class ASH_EXPORT AshColorProvider : public SessionObserver {
// Color for current active desk's border. // Color for current active desk's border.
kCurrentDeskColor, kCurrentDeskColor,
// Color for the battery's badge (bolt, unreliable, X).
kBatteryBadgeColor,
// Color for the switch access's back button.
kSwitchAccessInnerStrokeColor,
kSwitchAccessOuterStrokeColor,
}; };
// Attributes of ripple, includes the base color, opacity of inkdrop and // Attributes of ripple, includes the base color, opacity of inkdrop and
......
...@@ -6,6 +6,7 @@ ...@@ -6,6 +6,7 @@
#include "ash/resources/vector_icons/vector_icons.h" #include "ash/resources/vector_icons/vector_icons.h"
#include "ash/strings/grit/ash_strings.h" #include "ash/strings/grit/ash_strings.h"
#include "ash/style/ash_color_provider.h"
#include "ash/system/accessibility/floating_menu_button.h" #include "ash/system/accessibility/floating_menu_button.h"
#include "ash/system/tray/tray_constants.h" #include "ash/system/tray/tray_constants.h"
#include "base/bind.h" #include "base/bind.h"
...@@ -81,23 +82,27 @@ int SwitchAccessBackButtonView::GetHeightForWidth(int w) const { ...@@ -81,23 +82,27 @@ int SwitchAccessBackButtonView::GetHeightForWidth(int w) const {
} }
void SwitchAccessBackButtonView::OnPaint(gfx::Canvas* canvas) { void SwitchAccessBackButtonView::OnPaint(gfx::Canvas* canvas) {
auto* color_provider = AshColorProvider::Get();
gfx::Rect rect(GetContentsBounds()); gfx::Rect rect(GetContentsBounds());
cc::PaintFlags flags; cc::PaintFlags flags;
flags.setAntiAlias(true); flags.setAntiAlias(true);
flags.setColor(gfx::kGoogleGrey800); flags.setColor(color_provider->GetBaseLayerColor(
AshColorProvider::BaseLayerType::kTransparent80));
flags.setStyle(cc::PaintFlags::kFill_Style); flags.setStyle(cc::PaintFlags::kFill_Style);
canvas->DrawCircle(gfx::PointF(rect.CenterPoint()), kRadiusDp, flags); canvas->DrawCircle(gfx::PointF(rect.CenterPoint()), kRadiusDp, flags);
if (!show_focus_ring_) if (!show_focus_ring_)
return; return;
flags.setColor(gfx::kGoogleBlue300); flags.setColor(color_provider->GetContentLayerColor(
AshColorProvider::ContentLayerType::kSwitchAccessInnerStrokeColor));
flags.setStyle(cc::PaintFlags::kStroke_Style); flags.setStyle(cc::PaintFlags::kStroke_Style);
flags.setStrokeWidth(kFocusRingSingleColorWidthDp); flags.setStrokeWidth(kFocusRingSingleColorWidthDp);
canvas->DrawCircle(gfx::PointF(rect.CenterPoint()), canvas->DrawCircle(gfx::PointF(rect.CenterPoint()),
kRadiusDp + kFocusRingSingleColorWidthDp, flags); kRadiusDp + kFocusRingSingleColorWidthDp, flags);
flags.setColor(SK_ColorBLACK); flags.setColor(color_provider->GetContentLayerColor(
AshColorProvider::ContentLayerType::kSwitchAccessOuterStrokeColor));
canvas->DrawCircle(gfx::PointF(rect.CenterPoint()), canvas->DrawCircle(gfx::PointF(rect.CenterPoint()),
kRadiusDp + (2 * kFocusRingSingleColorWidthDp), flags); kRadiusDp + (2 * kFocusRingSingleColorWidthDp), flags);
} }
......
...@@ -18,9 +18,6 @@ namespace { ...@@ -18,9 +18,6 @@ namespace {
// battery is present and has a charge greater than 0. // battery is present and has a charge greater than 0.
const int kMinVisualChargeLevel = 1; const int kMinVisualChargeLevel = 1;
// The color of the battery's badge (bolt, unreliable, X).
const SkColor kBatteryBadgeColor = gfx::kGoogleGrey900;
} // namespace } // namespace
namespace ash { namespace ash {
...@@ -74,7 +71,8 @@ void BatteryImageSource::Draw(gfx::Canvas* canvas) { ...@@ -74,7 +71,8 @@ void BatteryImageSource::Draw(gfx::Canvas* canvas) {
size().height() * dsf); size().height() * dsf);
canvas->ClipRect(clip_rect); canvas->ClipRect(clip_rect);
const SkColor alert_color = AshColorProvider::Get()->GetContentLayerColor( auto* color_provider = AshColorProvider::Get();
const SkColor alert_color = color_provider->GetContentLayerColor(
AshColorProvider::ContentLayerType::kIconColorAlert); AshColorProvider::ContentLayerType::kIconColorAlert);
const bool use_alert_color = const bool use_alert_color =
charge_level == min_charge_level && info_.alert_if_low; charge_level == min_charge_level && info_.alert_if_low;
...@@ -94,7 +92,10 @@ void BatteryImageSource::Draw(gfx::Canvas* canvas) { ...@@ -94,7 +92,10 @@ void BatteryImageSource::Draw(gfx::Canvas* canvas) {
const SkColor badge_color = const SkColor badge_color =
use_alert_color use_alert_color
? alert_color ? alert_color
: info_.charge_percent > 50 ? kBatteryBadgeColor : fg_color_; : info_.charge_percent > 50
? color_provider->GetContentLayerColor(
AshColorProvider::ContentLayerType::kBatteryBadgeColor)
: fg_color_;
PaintVectorIcon(canvas, *info_.icon_badge, badge_color); PaintVectorIcon(canvas, *info_.icon_badge, badge_color);
} }
......
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