Commit 9a59bbb6 authored by Nic Champagne Williamson's avatar Nic Champagne Williamson Committed by Commit Bot

Add Windows high contrast support to the ink drop.

This change begins adding high contrast support to the ink drop. This
work is behind the EnablePlatformHighContrastInkDrop flag, which is
disabled by default.

The InkDropHighlight will now use 1.0 opacity (completely opaque) when
in platform high contrast mode. This will ensure that the ink drop color
is fully visible in high contrast.

To start, the ink drop color is set to the correct high contrast color
for the toolbar buttons. Future work will set the ink drop color
correctly in more areas, and fix element layering to ensure the
foreground is always visible on top of the ink drop background.

Bug: 776871
Change-Id: Iecdbedc7f4d735096e650d2b65a53d3de64643f4
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2023362
Commit-Queue: Peter Kasting <pkasting@chromium.org>
Reviewed-by: default avatarPeter Kasting <pkasting@chromium.org>
Cr-Commit-Position: refs/heads/master@{#736050}
parent 5bda698c
......@@ -110,6 +110,9 @@ class ThemeProperties {
// shelf.
COLOR_TOOLBAR_VERTICAL_SEPARATOR,
// Opaque base color for toolbar button ink drops.
COLOR_TOOLBAR_INK_DROP,
// Color used for various 'shelves' and 'bars'.
COLOR_DOWNLOAD_SHELF,
COLOR_INFOBAR,
......
......@@ -666,6 +666,10 @@ SkColor ThemeService::GetDefaultColor(int id, bool incognito) const {
return SkColorSetA(GetColor(TP::COLOR_TOOLBAR_BUTTON_ICON, incognito),
0x4D);
}
case TP::COLOR_TOOLBAR_INK_DROP: {
return color_utils::GetColorWithMaxContrast(
GetColor(TP::COLOR_TOOLBAR, incognito));
}
case TP::COLOR_TOOLBAR_CONTENT_AREA_SEPARATOR:
if (UsingDefaultTheme())
break;
......
......@@ -14,6 +14,7 @@
#include "ui/gfx/color_utils.h"
#include "ui/gfx/geometry/safe_integer_conversions.h"
#include "ui/native_theme/native_theme.h"
#include "ui/views/views_features.h"
namespace {
......@@ -154,6 +155,11 @@ bool ThemeServiceWin::GetPlatformHighContrastColor(int id,
break;
// Highlight/Selected Background
case ThemeProperties::COLOR_TOOLBAR_INK_DROP:
if (!base::FeatureList::IsEnabled(
views::features::kEnablePlatformHighContrastInkDrop))
return false;
FALLTHROUGH;
case ThemeProperties::COLOR_OMNIBOX_RESULTS_BG_SELECTED:
case ThemeProperties::COLOR_OMNIBOX_RESULTS_BG_HOVERED:
system_theme_color = ui::NativeTheme::SystemThemeColor::kHighlight;
......
......@@ -69,12 +69,9 @@ std::unique_ptr<views::InkDropHighlight> CreateToolbarInkDropHighlight(
SkColor GetToolbarInkDropBaseColor(const views::View* host_view) {
const auto* theme_provider = host_view->GetThemeProvider();
// There may be no theme provider in unit tests.
if (theme_provider) {
return color_utils::GetColorWithMaxContrast(
theme_provider->GetColor(ThemeProperties::COLOR_TOOLBAR));
}
return gfx::kPlaceholderColor;
return theme_provider
? theme_provider->GetColor(ThemeProperties::COLOR_TOOLBAR_INK_DROP)
: gfx::kPlaceholderColor;
}
views::InstallableInkDropConfig GetToolbarInstallableInkDropConfig(
......
......@@ -10,6 +10,7 @@
#include "ui/compositor/layer.h"
#include "ui/views/animation/ink_drop_highlight.h"
#include "ui/views/animation/ink_drop_host_view.h"
#include "ui/views/animation/ink_drop_util.h"
#include "ui/views/animation/square_ink_drop_ripple.h"
#include "ui/views/style/platform_style.h"
......@@ -750,6 +751,11 @@ void InkDropImpl::CreateInkDropHighlight() {
highlight_ = ink_drop_host_->CreateInkDropHighlight();
DCHECK(highlight_);
// If the platform provides HC colors, we need to show them fully on hover and
// press.
if (views::UsingPlatformHighContrastInkDrop(ink_drop_host_))
highlight_->set_visible_opacity(1.0f);
highlight_->set_observer(this);
root_layer_->Add(highlight_->layer());
AddRootLayerToHostIfNeeded();
......
......@@ -11,6 +11,9 @@
#include "ui/gfx/geometry/safe_integer_conversions.h"
#include "ui/gfx/geometry/vector2d_f.h"
#include "ui/gfx/transform.h"
#include "ui/native_theme/native_theme.h"
#include "ui/views/view.h"
#include "ui/views/views_features.h"
namespace views {
......@@ -51,4 +54,13 @@ gfx::Transform GetTransformSubpixelCorrection(const gfx::Transform& transform,
return subpixel_correction;
}
bool UsingPlatformHighContrastInkDrop(const View* view) {
const ui::NativeTheme* theme = view->GetNativeTheme();
return theme &&
theme->GetDefaultSystemColorScheme() ==
ui::NativeTheme::ColorScheme::kPlatformHighContrast &&
base::FeatureList::IsEnabled(
features::kEnablePlatformHighContrastInkDrop);
}
} // namespace views
......@@ -12,6 +12,7 @@ class Transform;
} // namespace gfx
namespace views {
class View;
// A layer |transform| may add an offset to its layer relative to the parent
// layer. This offset does not take into consideration the subpixel positioning.
......@@ -22,6 +23,8 @@ VIEWS_EXPORT gfx::Transform GetTransformSubpixelCorrection(
const gfx::Transform& transform,
float device_scale_factor);
VIEWS_EXPORT bool UsingPlatformHighContrastInkDrop(const View* view);
} // namespace views
#endif // UI_VIEWS_ANIMATION_INK_DROP_UTIL_H_
......@@ -11,12 +11,17 @@ namespace features {
// Please keep alphabetized.
// Increases corner radius on Dialogs for the material design refresh.
// Increase corner radius on Dialogs for the material design refresh.
// TODO(tluk): Remove this feature flag when platform inconsistencies
// have been fixed as recorded on: https://crbug.com/932970
const base::Feature kEnableMDRoundedCornersOnDialogs{
"EnableMDRoundedCornersOnDialogs", base::FEATURE_DISABLED_BY_DEFAULT};
// Use a high-contrast style for ink drops when in platform high-contrast mode,
// including full opacity and a high-contrast color
const base::Feature kEnablePlatformHighContrastInkDrop{
"EnablePlatformHighContrastInkDrop", base::FEATURE_DISABLED_BY_DEFAULT};
// Only paint views that are invalidated/dirty (i.e. a paint was directly
// scheduled on those views) as opposed to painting all views that intersect
// an invalid rectangle on the layer.
......
......@@ -15,6 +15,7 @@ namespace features {
// Please keep alphabetized.
VIEWS_EXPORT extern const base::Feature kEnableMDRoundedCornersOnDialogs;
VIEWS_EXPORT extern const base::Feature kEnablePlatformHighContrastInkDrop;
VIEWS_EXPORT extern const base::Feature kEnableViewPaintOptimization;
} // namespace features
......
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