Skip to content

Commit

Permalink
Connect font-palette-values at rule parsing to StyleEngine
Browse files Browse the repository at this point in the history
Enable StyleEngine and CSS machinery to detect @font-palette-values
rules and maintain their lifecycle.

The CL does not contain the functional parts of applying
font-palette-values rules to the output font rendering yet.

Parsing of such at rules is gated by the FontPalette
RuntimeEnabledFeatures flag.

Passes *font-palette* tests in css/css-fonts/parsing/. Adapted
css/css-fonts/parsing/font-palette-values-valid.html to differences in
how different user agents serialize color values in css text, and
account for differences in support for lab() and color() functions.

Bug: 1170794
Change-Id: I5ec5526f8d6e6f2897d17c9eb58d05fa8cd299f2
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3447227
Reviewed-by: Xiaocheng Hu <[email protected]>
Commit-Queue: Dominik Röttsches <[email protected]>
Cr-Commit-Position: refs/heads/main@{#969925}
  • Loading branch information
drott authored and chromium-wpt-export-bot committed Feb 11, 2022
1 parent 0ca450b commit 64ec12d
Showing 1 changed file with 28 additions and 12 deletions.
40 changes: 28 additions & 12 deletions css/css-fonts/parsing/font-palette-values-valid.html
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,10 @@
<body>
<script>
let rules = document.getElementById("style").sheet.cssRules;
let supports_lab = CSS.supports('color', 'lab(29.2345% 39.3825 20.0664)');
let supports_display_p3_color_space =
CSS.supports('color', 'color(display-p3 100% 100% 100%)');

test(function() {
let text = rules[0].cssText;
assert_not_equals(text.indexOf("@font-palette-values "), -1);
Expand Down Expand Up @@ -259,7 +263,8 @@
test(function() {
let text = rules[9].cssText;
assert_not_equals(text.indexOf("override-colors"), -1);
assert_not_equals(text.indexOf("rgb(0, 128, 0)"), -1);
assert_true(text.includes("rgb(0, 128, 0)") ||
text.includes("green"));
});

test(function() {
Expand All @@ -268,13 +273,15 @@
assert_equals(rule.fontFamily, "");
assert_equals(rule.basePalette, "");
assert_equals(rule.overrideColors.indexOf("),"), -1);
assert_not_equals(rule.overrideColors.indexOf("rgb(0, 128, 0)"), -1);
assert_true(rule.overrideColors.includes("rgb(0, 128, 0)") ||
rule.overrideColors.includes("green"))
});

test(function() {
let text = rules[10].cssText;
assert_not_equals(text.indexOf("override-colors"), -1);
assert_not_equals(text.indexOf("rgba(0, 0, 0, 0)"), -1);
assert_true(text.includes("rgba(0, 0, 0, 0)") ||
text.includes("transparent"));
});

test(function() {
Expand All @@ -283,7 +290,8 @@
assert_equals(rule.fontFamily, "");
assert_equals(rule.basePalette, "");
assert_equals(rule.overrideColors.indexOf("),"), -1);
assert_not_equals(rule.overrideColors.indexOf("rgba(0, 0, 0, 0)"), -1);
assert_true(rule.overrideColors.includes("rgba(0, 0, 0, 0)") ||
rule.overrideColors.includes("transparent"));
});

test(function() {
Expand All @@ -303,32 +311,40 @@

test(function() {
let text = rules[12].cssText;
assert_not_equals(text.indexOf("override-colors"), -1);
assert_not_equals(text.indexOf("29"), -1);
if (supports_lab) {
assert_not_equals(text.indexOf("override-colors"), -1);
assert_not_equals(text.indexOf("29"), -1);
}
});

test(function() {
let rule = rules[12];
assert_equals(rule.name, "--M");
assert_equals(rule.fontFamily, "");
assert_equals(rule.basePalette, "");
assert_equals(rule.overrideColors.indexOf("),"), -1);
assert_not_equals(rule.overrideColors.indexOf("lab"), -1);
if (supports_lab) {
assert_equals(rule.overrideColors.indexOf("),"), -1);
assert_not_equals(rule.overrideColors.indexOf("lab"), -1);
}
});

test(function() {
let text = rules[13].cssText;
assert_not_equals(text.indexOf("override-colors"), -1);
assert_not_equals(text.indexOf("display-p3"), -1);
if (supports_display_p3_color_space) {
assert_not_equals(text.indexOf("override-colors"), -1);
assert_not_equals(text.indexOf("display-p3"), -1);
}
});

test(function() {
let rule = rules[13];
assert_equals(rule.name, "--N");
assert_equals(rule.fontFamily, "");
assert_equals(rule.basePalette, "");
assert_equals(rule.overrideColors.indexOf("),"), -1);
assert_not_equals(rule.overrideColors.indexOf("display-p3"), -1);
if (supports_display_p3_color_space) {
assert_equals(rule.overrideColors.indexOf("),"), -1);
assert_not_equals(rule.overrideColors.indexOf("display-p3"), -1);
}
});

test(function() {
Expand Down

0 comments on commit 64ec12d

Please sign in to comment.