Skip to content

Truly independent web browser

LibWeb: Add the forced-color-adjust property

Andreas Klingb707983dc623
diff --git a/Libraries/LibWeb/CSS/Enums.json b/Libraries/LibWeb/CSS/Enums.json
index 1d36107e254..b4921454046 100644
--- a/Libraries/LibWeb/CSS/Enums.json
+++ b/Libraries/LibWeb/CSS/Enums.json
@@ -685,6 +685,11 @@
"extra-expanded",
"ultra-expanded"
],
+ "forced-color-adjust": [
+ "auto",
+ "none",
+ "preserve-parent-color"
+ ],
"generic-font-family": [
"serif",
"sans-serif",
diff --git a/Libraries/LibWeb/CSS/Keywords.json b/Libraries/LibWeb/CSS/Keywords.json
index 45753521d9a..f3d1626d6c5 100644
--- a/Libraries/LibWeb/CSS/Keywords.json
+++ b/Libraries/LibWeb/CSS/Keywords.json
@@ -573,6 +573,7 @@
"preserve",
"preserve-3d",
"preserve-breaks",
+ "preserve-parent-color",
"preserve-spaces",
"pretty",
"progress",
diff --git a/Libraries/LibWeb/CSS/Properties.json b/Libraries/LibWeb/CSS/Properties.json
index 2f9f5e0a0f7..5e708f8ce54 100644
--- a/Libraries/LibWeb/CSS/Properties.json
+++ b/Libraries/LibWeb/CSS/Properties.json
@@ -2643,6 +2643,17 @@
"font-width"
]
},
+ "forced-color-adjust": {
+ "style-group": "InheritedUIValues",
+ "affects-layout": false,
+ "animation-type": "discrete",
+ "inherited": true,
+ "initial": "auto",
+ "requires-computation": "never",
+ "valid-types": [
+ "forced-color-adjust"
+ ]
+ },
"gap": {
"initial": "normal",
"valid-types": [
diff --git a/Libraries/LibWeb/Rust/src/css/computed_value_types.rs b/Libraries/LibWeb/Rust/src/css/computed_value_types.rs
index be49924dab3..7f7999b5161 100644
--- a/Libraries/LibWeb/Rust/src/css/computed_value_types.rs
+++ b/Libraries/LibWeb/Rust/src/css/computed_value_types.rs
@@ -903,6 +903,7 @@ pub struct InheritedUIValues {
pub accent_color: ComputedColorOrAuto,
pub cursor: RetainedComputedCursorList,
pub pointer_events: u8,
+ pub forced_color_adjust: u8,
pub interpolate_size: u8,
pub scrollbar_color: ComputedScrollbarColor,
pub color_scheme: u8,
diff --git a/Libraries/LibWeb/Rust/src/css/computed_values.rs b/Libraries/LibWeb/Rust/src/css/computed_values.rs
index db46ceaaa9c..81d17f41460 100644
--- a/Libraries/LibWeb/Rust/src/css/computed_values.rs
+++ b/Libraries/LibWeb/Rust/src/css/computed_values.rs
@@ -906,6 +906,7 @@ impl_computed_payload_clone_and_eq!(InheritedUIValues {
accent_color,
cursor,
pointer_events,
+ forced_color_adjust,
interpolate_size,
scrollbar_color,
color_scheme,
@@ -2173,6 +2174,7 @@ pub(crate) fn group_field_descriptors(group: usize) -> &'static [GroupFieldDescr
ACCENT_COLOR => RequireKeyword(k::AUTO),
CURSOR => RequireKeyword(k::AUTO),
POINTER_EVENTS @ pointer_events => EnumKeyword(enums::keyword_to_pointer_events),
+ FORCED_COLOR_ADJUST @ forced_color_adjust => EnumKeyword(enums::keyword_to_forced_color_adjust),
INTERPOLATE_SIZE @ interpolate_size => EnumKeyword(enums::keyword_to_interpolate_size),
SCROLLBAR_COLOR => RequireKeyword(k::AUTO),
COLOR_SCHEME @ color_scheme => ResolvedU8,
@@ -3207,6 +3209,7 @@ impl InheritedUIValues {
predefined: crate::css::css_enums::cursor_predefined::AUTO,
}]),
pointer_events: crate::css::css_enums::pointer_events::AUTO,
+ forced_color_adjust: crate::css::css_enums::forced_color_adjust::AUTO,
interpolate_size: crate::css::css_enums::interpolate_size::NUMERIC_ONLY,
scrollbar_color: crate::css::computed_value_types::ComputedScrollbarColor {
thumb_color: 0,
diff --git a/Tests/LibWeb/Text/expected/css/CSSStyleDeclaration-has-indexed-property-getter.txt b/Tests/LibWeb/Text/expected/css/CSSStyleDeclaration-has-indexed-property-getter.txt
index d455805c2fc..98e8e788404 100644
--- a/Tests/LibWeb/Text/expected/css/CSSStyleDeclaration-has-indexed-property-getter.txt
+++ b/Tests/LibWeb/Text/expected/css/CSSStyleDeclaration-has-indexed-property-getter.txt
@@ -38,6 +38,7 @@ All properties associated with getComputedStyle(document.body):
"font-variation-settings",
"font-weight",
"font-width",
+ "forced-color-adjust",
"image-rendering",
"interpolate-size",
"letter-spacing",
diff --git a/Tests/LibWeb/Text/expected/css/CSSStyleProperties-all-supported-properties-and-default-values.txt b/Tests/LibWeb/Text/expected/css/CSSStyleProperties-all-supported-properties-and-default-values.txt
index fd9d1b9ec14..cf91c1b63c9 100644
--- a/Tests/LibWeb/Text/expected/css/CSSStyleProperties-all-supported-properties-and-default-values.txt
+++ b/Tests/LibWeb/Text/expected/css/CSSStyleProperties-all-supported-properties-and-default-values.txt
@@ -567,6 +567,8 @@ All supported properties and their default values exposed from CSSStylePropertie
'font-weight': '400'
'fontWidth': '100%'
'font-width': '100%'
+'forcedColorAdjust': 'auto'
+'forced-color-adjust': 'auto'
'gap': 'normal'
'grid': 'none'
'gridArea': 'auto'
diff --git a/Tests/LibWeb/Text/expected/css/getComputedStyle-print-all.txt b/Tests/LibWeb/Text/expected/css/getComputedStyle-print-all.txt
index 69e21ef9fa8..af0171148be 100644
--- a/Tests/LibWeb/Text/expected/css/getComputedStyle-print-all.txt
+++ b/Tests/LibWeb/Text/expected/css/getComputedStyle-print-all.txt
@@ -36,6 +36,7 @@ font-variant-position: normal
font-variation-settings: normal
font-weight: 400
font-width: 100%
+forced-color-adjust: auto
image-rendering: auto
interpolate-size: numeric-only
letter-spacing: normal
diff --git a/Tests/LibWeb/Text/expected/wpt-import/css/css-cascade/all-prop-revert-layer.txt b/Tests/LibWeb/Text/expected/wpt-import/css/css-cascade/all-prop-revert-layer.txt
index a2fac2f831c..03a95732cf9 100644
--- a/Tests/LibWeb/Text/expected/wpt-import/css/css-cascade/all-prop-revert-layer.txt
+++ b/Tests/LibWeb/Text/expected/wpt-import/css/css-cascade/all-prop-revert-layer.txt
@@ -1,8 +1,8 @@
Harness status: OK
-Found 337 tests
+Found 338 tests
-333 Pass
+334 Pass
4 Fail
Pass accent-color
Pass border-collapse
@@ -39,6 +39,7 @@ Pass font-variant-position
Pass font-variation-settings
Pass font-weight
Pass font-width
+Pass forced-color-adjust
Pass image-rendering
Pass letter-spacing
Pass line-height
diff --git a/Tests/LibWeb/Text/expected/wpt-import/css/css-color-adjust/animation/forced-color-adjust-no-interpolation.txt b/Tests/LibWeb/Text/expected/wpt-import/css/css-color-adjust/animation/forced-color-adjust-no-interpolation.txt
new file mode 100644
index 00000000000..acfc771adb7
--- /dev/null
+++ b/Tests/LibWeb/Text/expected/wpt-import/css/css-color-adjust/animation/forced-color-adjust-no-interpolation.txt
@@ -0,0 +1,47 @@
+Harness status: OK
+
+Found 42 tests
+
+42 Pass
+Pass CSS Transitions with transition-behavior:allow-discrete: property <forced-color-adjust> from [initial] to [none] at (-0.3) should be [initial]
+Pass CSS Transitions with transition-behavior:allow-discrete: property <forced-color-adjust> from [initial] to [none] at (0) should be [initial]
+Pass CSS Transitions with transition-behavior:allow-discrete: property <forced-color-adjust> from [initial] to [none] at (0.3) should be [initial]
+Pass CSS Transitions with transition-behavior:allow-discrete: property <forced-color-adjust> from [initial] to [none] at (0.5) should be [none]
+Pass CSS Transitions with transition-behavior:allow-discrete: property <forced-color-adjust> from [initial] to [none] at (0.6) should be [none]
+Pass CSS Transitions with transition-behavior:allow-discrete: property <forced-color-adjust> from [initial] to [none] at (1) should be [none]
+Pass CSS Transitions with transition-behavior:allow-discrete: property <forced-color-adjust> from [initial] to [none] at (1.5) should be [none]
+Pass CSS Transitions with transition-property:all and transition-behavor:allow-discrete: property <forced-color-adjust> from [initial] to [none] at (-0.3) should be [initial]
+Pass CSS Transitions with transition-property:all and transition-behavor:allow-discrete: property <forced-color-adjust> from [initial] to [none] at (0) should be [initial]
+Pass CSS Transitions with transition-property:all and transition-behavor:allow-discrete: property <forced-color-adjust> from [initial] to [none] at (0.3) should be [initial]
+Pass CSS Transitions with transition-property:all and transition-behavor:allow-discrete: property <forced-color-adjust> from [initial] to [none] at (0.5) should be [none]
+Pass CSS Transitions with transition-property:all and transition-behavor:allow-discrete: property <forced-color-adjust> from [initial] to [none] at (0.6) should be [none]
+Pass CSS Transitions with transition-property:all and transition-behavor:allow-discrete: property <forced-color-adjust> from [initial] to [none] at (1) should be [none]
+Pass CSS Transitions with transition-property:all and transition-behavor:allow-discrete: property <forced-color-adjust> from [initial] to [none] at (1.5) should be [none]
+Pass CSS Transitions: property <forced-color-adjust> from [initial] to [none] at (-0.3) should be [none]
+Pass CSS Transitions: property <forced-color-adjust> from [initial] to [none] at (0) should be [none]
+Pass CSS Transitions: property <forced-color-adjust> from [initial] to [none] at (0.3) should be [none]
+Pass CSS Transitions: property <forced-color-adjust> from [initial] to [none] at (0.5) should be [none]
+Pass CSS Transitions: property <forced-color-adjust> from [initial] to [none] at (0.6) should be [none]
+Pass CSS Transitions: property <forced-color-adjust> from [initial] to [none] at (1) should be [none]
+Pass CSS Transitions: property <forced-color-adjust> from [initial] to [none] at (1.5) should be [none]
+Pass CSS Transitions with transition: all: property <forced-color-adjust> from [initial] to [none] at (-0.3) should be [none]
+Pass CSS Transitions with transition: all: property <forced-color-adjust> from [initial] to [none] at (0) should be [none]
+Pass CSS Transitions with transition: all: property <forced-color-adjust> from [initial] to [none] at (0.3) should be [none]
+Pass CSS Transitions with transition: all: property <forced-color-adjust> from [initial] to [none] at (0.5) should be [none]
+Pass CSS Transitions with transition: all: property <forced-color-adjust> from [initial] to [none] at (0.6) should be [none]
+Pass CSS Transitions with transition: all: property <forced-color-adjust> from [initial] to [none] at (1) should be [none]
+Pass CSS Transitions with transition: all: property <forced-color-adjust> from [initial] to [none] at (1.5) should be [none]
+Pass CSS Animations: property <forced-color-adjust> from [initial] to [none] at (-0.3) should be [initial]
+Pass CSS Animations: property <forced-color-adjust> from [initial] to [none] at (0) should be [initial]
+Pass CSS Animations: property <forced-color-adjust> from [initial] to [none] at (0.3) should be [initial]
+Pass CSS Animations: property <forced-color-adjust> from [initial] to [none] at (0.5) should be [none]
+Pass CSS Animations: property <forced-color-adjust> from [initial] to [none] at (0.6) should be [none]
+Pass CSS Animations: property <forced-color-adjust> from [initial] to [none] at (1) should be [none]
+Pass CSS Animations: property <forced-color-adjust> from [initial] to [none] at (1.5) should be [none]
+Pass Web Animations: property <forced-color-adjust> from [initial] to [none] at (-0.3) should be [initial]
+Pass Web Animations: property <forced-color-adjust> from [initial] to [none] at (0) should be [initial]
+Pass Web Animations: property <forced-color-adjust> from [initial] to [none] at (0.3) should be [initial]
+Pass Web Animations: property <forced-color-adjust> from [initial] to [none] at (0.5) should be [none]
+Pass Web Animations: property <forced-color-adjust> from [initial] to [none] at (0.6) should be [none]
+Pass Web Animations: property <forced-color-adjust> from [initial] to [none] at (1) should be [none]
+Pass Web Animations: property <forced-color-adjust> from [initial] to [none] at (1.5) should be [none]
\ No newline at end of file
diff --git a/Tests/LibWeb/Text/input/wpt-import/css/css-color-adjust/animation/forced-color-adjust-no-interpolation.html b/Tests/LibWeb/Text/input/wpt-import/css/css-color-adjust/animation/forced-color-adjust-no-interpolation.html
new file mode 100644
index 00000000000..ef6b6aaa724
--- /dev/null
+++ b/Tests/LibWeb/Text/input/wpt-import/css/css-color-adjust/animation/forced-color-adjust-no-interpolation.html
@@ -0,0 +1,17 @@
+<!DOCTYPE html>
+<link rel=author href="mailto:[email protected]">
+<link rel=help href="https://github.com/w3c/csswg-drafts/issues/4441">
+<link rel=help href="https://drafts.csswg.org/css-color-adjust/#forced-color-adjust-prop">
+<link rel=help href="https://drafts.csswg.org/css-transitions-2/#transition-property-property">
+<script src="../../../resources/testharness.js"></script>
+<script src="../../../resources/testharnessreport.js"></script>
+<script src="../../../css/support/interpolation-testcommon.js"></script>
+
+<body>
+<script>
+test_no_interpolation({
+ property: 'forced-color-adjust',
+ from: 'initial',
+ to: 'none'
+});
+</script>