Commit a80afe50 authored by Alex Keng's avatar Alex Keng Committed by Commit Bot

Implement high contrast mode for <input type=text/number/password/button/submit>

This CL enables <input type=text/number/password/button/submit>
to render high contrast colors when high contrast mode is enabled.

test: web_tests\fast\forms\controls-new-ui-high-contrast\text_number_password_button_submit.html
Note the test is verifying if we are correctly using system colors
in high contrast mode and since we don't really change system setting
for HC in webtests, the results colors are still black/grey/white
(in higher contrast) instead of black/white/green.

Bug: 994219
Change-Id: I0a9653c3051eb9e7db01ef43ec024354518be950
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1763429
Commit-Queue: Alex Keng <shihken@microsoft.com>
Reviewed-by: default avatarElly Fong-Jones <ellyjones@chromium.org>
Reviewed-by: default avatarKevin Babbitt <kbabbitt@microsoft.com>
Cr-Commit-Position: refs/heads/master@{#689120}
parent 06874ee5
<input type=text value=abc>
<input type=text value=abc disabled><br><br>
<input type=number value=123>
<input type=number value=123 disabled><br><br>
<input type=password value=abc>
<input type=password value=abc disabled><br><br>
<input type=button value=click>
<input type=button value=click disabled><br><br>
<button>click</button>
<button disabled>click</button><br><br>
<input type=submit>
<input type=submit disabled>
<script>
if (window.testRunner)
testRunner.setUseMockTheme(false);
</script>
\ No newline at end of file
......@@ -597,12 +597,19 @@ void NativeThemeAura::PaintTextField(cc::PaintCanvas* canvas,
// Paint the border: 1px solid.
cc::PaintFlags stroke_flags;
if (state == kHovered) {
stroke_flags.setColor(kInputBorderHoveredColor);
} else if (state == kDisabled) {
stroke_flags.setColor(kInputBorderDisabledColor);
if (UsesHighContrastColors()) {
ColorId color_id = (state == kDisabled)
? NativeTheme::kColorId_ButtonDisabledColor
: NativeTheme::kColorId_ButtonEnabledColor;
stroke_flags.setColor(GetSystemColor(color_id, color_scheme));
} else {
stroke_flags.setColor(kInputBorderColor);
if (state == kHovered) {
stroke_flags.setColor(kInputBorderHoveredColor);
} else if (state == kDisabled) {
stroke_flags.setColor(kInputBorderDisabledColor);
} else {
stroke_flags.setColor(kInputBorderColor);
}
}
stroke_flags.setStyle(cc::PaintFlags::kStroke_Style);
stroke_flags.setStrokeWidth(borderWidth);
......@@ -624,12 +631,17 @@ void NativeThemeAura::PaintButton(cc::PaintCanvas* canvas,
SkRect skrect = gfx::RectToSkRect(rect);
SkColor background_color;
if (state == kHovered) {
background_color = kButtonBackgroundHoveredColor;
} else if (state == kDisabled) {
background_color = kButtonBackgroundDisabledColor;
if (UsesHighContrastColors()) {
background_color =
GetSystemColor(NativeTheme::kColorId_WindowBackground, color_scheme);
} else {
background_color = kButtonBackgroundColor;
if (state == kHovered) {
background_color = kButtonBackgroundHoveredColor;
} else if (state == kDisabled) {
background_color = kButtonBackgroundDisabledColor;
} else {
background_color = kButtonBackgroundColor;
}
}
flags.setAntiAlias(true);
......@@ -650,12 +662,19 @@ void NativeThemeAura::PaintButton(cc::PaintCanvas* canvas,
// Paint the border: 1px solid.
if (button.has_border) {
SkColor border_color;
if (state == kHovered) {
border_color = kButtonBorderHoveredColor;
} else if (state == kDisabled) {
border_color = kButtonBorderDisabledColor;
if (UsesHighContrastColors()) {
ColorId color_id = (state == kDisabled)
? NativeTheme::kColorId_ButtonDisabledColor
: NativeTheme::kColorId_ButtonEnabledColor;
border_color = GetSystemColor(color_id, color_scheme);
} else {
border_color = kButtonBorderColor;
if (state == kHovered) {
border_color = kButtonBorderHoveredColor;
} else if (state == kDisabled) {
border_color = kButtonBorderDisabledColor;
} else {
border_color = kButtonBorderColor;
}
}
flags.setStyle(cc::PaintFlags::kStroke_Style);
......
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