Skip to content

Commit

Permalink
Add CSS system colors Mark and MarkText.
Browse files Browse the repository at this point in the history
CSS Color Module Level 4 defines new system colors
(https://www.w3.org/TR/css-color-4/#css-system-colors).
This CL implements Mark and MarkText.

Bug: 1299441
Change-Id: Id184ee58c49e7d55a32b3776e5d0d9489eb4e9cb
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3536909
Reviewed-by: Stephen Chenney <schenney@chromium.org>
Commit-Queue: Stephen Chenney <schenney@chromium.org>
Cr-Commit-Position: refs/heads/main@{#983348}
  • Loading branch information
Jan Keitel authored and Chromium LUCI CQ committed Mar 21, 2022
1 parent 4173878 commit 6a3d0c8
Show file tree
Hide file tree
Showing 12 changed files with 91 additions and 8 deletions.
2 changes: 2 additions & 0 deletions third_party/blink/renderer/core/css/css.dict
Expand Up @@ -204,6 +204,8 @@
"inactivecaptiontext"
"infobackground"
"infotext"
"mark"
"marktext"
"menutext"
"scrollbar"
"threeddarkshadow"
Expand Down
2 changes: 2 additions & 0 deletions third_party/blink/renderer/core/css/css_value_keywords.json5
Expand Up @@ -214,6 +214,8 @@
"infobackground",
"infotext",
"linktext",
"mark",
"marktext",
"menutext",
"scrollbar",
"threeddarkshadow",
Expand Down
5 changes: 3 additions & 2 deletions third_party/blink/renderer/core/css/style_color.cc
Expand Up @@ -73,8 +73,7 @@ bool StyleColor::IsSystemColorIncludingDeprecated(CSSValueID id) {

bool StyleColor::IsSystemColor(CSSValueID id) {
switch (id) {
// SelectedItem, SelectedItemText, Mark, MarkText not
// understood yet.
// SelectedItem, SelectedItemText not understood yet.
case CSSValueID::kCanvas:
case CSSValueID::kCanvastext:
case CSSValueID::kLinktext:
Expand All @@ -88,6 +87,8 @@ bool StyleColor::IsSystemColor(CSSValueID id) {
case CSSValueID::kHighlight:
case CSSValueID::kHighlighttext:
case CSSValueID::kGraytext:
case CSSValueID::kMark:
case CSSValueID::kMarktext:
return true;
default:
return false;
Expand Down
4 changes: 2 additions & 2 deletions third_party/blink/renderer/core/html/resources/html.css
Expand Up @@ -1123,8 +1123,8 @@ pre, xmp, plaintext, listing {
}

mark {
background-color: yellow;
color: black
background-color: Mark;
color: MarkText;
}

big {
Expand Down
4 changes: 4 additions & 0 deletions third_party/blink/renderer/core/layout/layout_theme.cc
Expand Up @@ -652,6 +652,10 @@ Color LayoutTheme::DefaultSystemColor(
: 0xFF000000;
case CSSValueID::kLinktext:
return 0xFF0000EE;
case CSSValueID::kMark:
return 0xFFFFFF00;
case CSSValueID::kMarktext:
return 0xFF000000;
case CSSValueID::kMenu:
return color_scheme == mojom::blink::ColorScheme::kDark ? 0xFF404040
: 0xFFF7F7F7;
Expand Down
Expand Up @@ -11,6 +11,8 @@ PASS e.style['color'] = "GrayText" should set the property value
PASS e.style['color'] = "Highlight" should set the property value
PASS e.style['color'] = "HighlightText" should set the property value
PASS e.style['color'] = "LinkText" should set the property value
PASS e.style['color'] = "Mark" should set the property value
PASS e.style['color'] = "MarkText" should set the property value
PASS e.style['color'] = "VisitedText" should set the property value
FAIL e.style['color'] = "SelectedItem" should set the property value assert_not_equals: property should be set got disallowed value ""
FAIL e.style['color'] = "SelectedItemText" should set the property value assert_not_equals: property should be set got disallowed value ""
Expand Down
Expand Up @@ -23,6 +23,8 @@
test_valid_value("color", "Highlight", "highlight");
test_valid_value("color", "HighlightText", "highlighttext");
test_valid_value("color", "LinkText", "linktext");
test_valid_value("color", "Mark", "mark");
test_valid_value("color", "MarkText", "marktext");
test_valid_value("color", "VisitedText", "visitedtext");
test_valid_value("color", "SelectedItem", "selecteditem");
test_valid_value("color", "SelectedItemText", "selecteditemtext");
Expand Down
Expand Up @@ -19,12 +19,16 @@
<div id="buttons">
<button name="button"></button><input type="submit" name="submit button"><input type="reset" name="reset button">
</div>
<mark id="mark">Marked text</mark>
<script>
for (let element of document.getElementById("buttons").children) {
style = document.defaultView.getComputedStyle(element);
test_computed_value(`color`, `ButtonText`, style.getPropertyValue('color'), 'has the same color as text on a ' + element.name);
}
// Test with no specified target contrast
// Mark and MarkText
style = document.defaultView.getComputedStyle(document.getElementById('mark'));
test_computed_value('color', 'Mark', style.getPropertyValue('background-color'), 'has the same color as the background-color of a mark element');
test_computed_value('color', 'MarkText', style.getPropertyValue('color'), 'has the same color as the color of a mark element');
</script>
</body>

Expand Down
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
32 changes: 31 additions & 1 deletion third_party/blink/web_tests/svg/css/css-systemcolors.svg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Expand Up @@ -76,6 +76,12 @@ PASS computedStyleText.stroke is computedStyleDiv.get('color').toString()
Testing system colorLinkText
PASS computedStyleText.fill is computedStyleDiv.get('color').toString()
PASS computedStyleText.stroke is computedStyleDiv.get('color').toString()
Testing system colorMark
PASS computedStyleText.fill is computedStyleDiv.get('color').toString()
PASS computedStyleText.stroke is computedStyleDiv.get('color').toString()
Testing system colorMarkText
PASS computedStyleText.fill is computedStyleDiv.get('color').toString()
PASS computedStyleText.stroke is computedStyleDiv.get('color').toString()
Testing system colorMenu
PASS computedStyleText.fill is computedStyleDiv.get('color').toString()
PASS computedStyleText.stroke is computedStyleDiv.get('color').toString()
Expand Down
Expand Up @@ -28,7 +28,7 @@ var systemColors = new Array("ActiveBorder", "ActiveCaption", "ActiveText", "App
"ButtonFace", "ButtonHighlight", "ButtonShadow", "ButtonText", "Canvas", "CanvasText",
"CaptionText", "Field", "FieldText", "GrayText", "Highlight", "HighlightText",
"InactiveBorder", "InactiveCaption", "InactiveCaptionText", "InfoBackground",
"InfoText", "LinkText", "Menu", "MenuText", "Scrollbar", "ThreeDDarkShadow",
"InfoText", "LinkText", "Mark", "MarkText", "Menu", "MenuText", "Scrollbar", "ThreeDDarkShadow",
"ThreeDFace", "ThreeDHighlight", "ThreeDLightShadow", "ThreeDShadow", "VisitedText",
"Window", "WindowFrame", "WindowText");
var svgElement = document.getElementsByTagName("svg")[0];
Expand Down

0 comments on commit 6a3d0c8

Please sign in to comment.