Truly independent web browser
LibWeb: Interpolate scrollbar-color by computed value
Andreas Klinge8c4eb315902
diff --git a/Libraries/LibWeb/Rust/src/css/animation.rs b/Libraries/LibWeb/Rust/src/css/animation.rsindex e780d0429d0..37f81bbf61e 100644--- a/Libraries/LibWeb/Rust/src/css/animation.rs+++ b/Libraries/LibWeb/Rust/src/css/animation.rs@@ -7442,6 +7442,39 @@ fn combine_four_sides(Some(owned(shortest_four_sides(sides)))}+fn combine_scrollbar_color(+ context: Option<&FfiAnimationContext>,+ from: &StyleValueData,+ to: &StyleValueData,+ combine: impl Fn(&StyleValueData, &StyleValueData) -> AnimationValueResult,+) -> Option<StyleValueData> {+ // https://drafts.csswg.org/css-scrollbars/#scrollbar-color+ // Computed value: specified keyword or two computed colors+ // Animation type: by computed value+ let (+ StyleValueData::ScrollbarColor {+ thumb_color: from_thumb_color,+ track_color: from_track_color,+ },+ StyleValueData::ScrollbarColor {+ thumb_color: to_thumb_color,+ track_color: to_track_color,+ },+ ) = (from, to)+ else {+ return None;+ };+ let combine_colors = |from: &RetainedStyleValueData, to: &RetainedStyleValueData| {+ let from = resolve_animation_color(context, from)?;+ let to = resolve_animation_color(context, to)?;+ combine(from.data(), to.data()).into_value()+ };+ Some(StyleValueData::ScrollbarColor {+ thumb_color: combine_colors(from_thumb_color, to_thumb_color)?,+ track_color: combine_colors(from_track_color, to_track_color)?,+ })+}+pub(crate) fn interpolate_value(context: Option<&FfiAnimationContext>,property_id: u16,@@ -7764,6 +7797,13 @@ pub(crate) fn interpolate_value(return discrete_value(context, from, to, delta);}assert_eq!(animation_type, ANIMATION_TYPE_BY_COMPUTED_VALUE);+ if property_id == crate::css::property_metadata::property_id::SCROLLBAR_COLOR+ && let Some(value) = combine_scrollbar_color(context, from, to, |from, to| {+ interpolate_scalar_value(property_id, from, to, delta, &[])+ })+ {+ return owned(value);+ }let result = if is_four_sided_property(property_id) {combine_four_sides(from, to, |from, to| {interpolate_scalar_value(property_id, from, to, delta, &[])@@ -7815,6 +7855,11 @@ fn composite_batch_value<'a>(| crate::css::property_metadata::property_id::TEXT_SHADOW) {composite_shadow_list(context, underlying, animated, operation)+ } else if property_id == crate::css::property_metadata::property_id::SCROLLBAR_COLOR {+ combine_scrollbar_color(Some(context), underlying, animated, |underlying, animated| {+ composite_scalar_value(underlying, animated, operation)+ })+ .map_or_else(handled_without_value, owned)} else if is_four_sided_property(property_id) {combine_four_sides(underlying, animated, |underlying, animated| {composite_scalar_value(underlying, animated, operation)diff --git a/Tests/LibWeb/Text/expected/wpt-import/web-animations/animation-model/animation-types/accumulation-per-property-002.txt b/Tests/LibWeb/Text/expected/wpt-import/web-animations/animation-model/animation-types/accumulation-per-property-002.txtindex a6fa21eca7f..2da1e4b7faf 100644--- a/Tests/LibWeb/Text/expected/wpt-import/web-animations/animation-model/animation-types/accumulation-per-property-002.txt+++ b/Tests/LibWeb/Text/expected/wpt-import/web-animations/animation-model/animation-types/accumulation-per-property-002.txt@@ -2,8 +2,8 @@ Harness status: OKFound 336 tests-321 Pass-15 Fail+326 Pass+10 FailPass SetupPass isolation (type: discrete) has testAccumulation functionPass isolation: "isolate" onto "auto"@@ -178,11 +178,11 @@ Pass scroll-snap-type: "x mandatory" onto "none"Pass scroll-snap-type: "none" onto "x mandatory"Pass scrollbar-color (type: colorPair) has testAccumulation functionFail scrollbar-color supports animating as color pair of rgb() with overflowed from and to values-Fail scrollbar-color supports animating as color pair of #RGB-Fail scrollbar-color supports animating as color pair of hsl()-Fail scrollbar-color supports animating as color pair of #RGBa-Fail scrollbar-color supports animating as color pair of rgba()-Fail scrollbar-color supports animating as color pair of hsla()+Pass scrollbar-color supports animating as color pair of #RGB+Pass scrollbar-color supports animating as color pair of hsl()+Pass scrollbar-color supports animating as color pair of #RGBa+Pass scrollbar-color supports animating as color pair of rgba()+Pass scrollbar-color supports animating as color pair of hsla()Pass scrollbar-gutter (type: discrete) has testAccumulation functionPass scrollbar-gutter: "stable" onto "auto"Pass scrollbar-gutter: "auto" onto "stable"diff --git a/Tests/LibWeb/Text/expected/wpt-import/web-animations/animation-model/animation-types/addition-per-property-002.txt b/Tests/LibWeb/Text/expected/wpt-import/web-animations/animation-model/animation-types/addition-per-property-002.txtindex 5733e11dfae..e39fba886d0 100644--- a/Tests/LibWeb/Text/expected/wpt-import/web-animations/animation-model/animation-types/addition-per-property-002.txt+++ b/Tests/LibWeb/Text/expected/wpt-import/web-animations/animation-model/animation-types/addition-per-property-002.txt@@ -2,8 +2,8 @@ Harness status: OKFound 332 tests-317 Pass-15 Fail+322 Pass+10 FailPass SetupPass isolation (type: discrete) has testAddition functionPass isolation: "isolate" onto "auto"@@ -178,11 +178,11 @@ Pass scroll-snap-type: "x mandatory" onto "none"Pass scroll-snap-type: "none" onto "x mandatory"Pass scrollbar-color (type: colorPair) has testAddition functionFail scrollbar-color supports animating as color pair of rgb() with overflowed from and to values-Fail scrollbar-color supports animating as color pair of #RGB-Fail scrollbar-color supports animating as color pair of hsl()-Fail scrollbar-color supports animating as color pair of #RGBa-Fail scrollbar-color supports animating as color pair of rgba()-Fail scrollbar-color supports animating as color pair of hsla()+Pass scrollbar-color supports animating as color pair of #RGB+Pass scrollbar-color supports animating as color pair of hsl()+Pass scrollbar-color supports animating as color pair of #RGBa+Pass scrollbar-color supports animating as color pair of rgba()+Pass scrollbar-color supports animating as color pair of hsla()Pass scrollbar-gutter (type: discrete) has testAddition functionPass scrollbar-gutter: "stable" onto "auto"Pass scrollbar-gutter: "auto" onto "stable"diff --git a/Tests/LibWeb/Text/expected/wpt-import/web-animations/animation-model/animation-types/interpolation-per-property-002.txt b/Tests/LibWeb/Text/expected/wpt-import/web-animations/animation-model/animation-types/interpolation-per-property-002.txtindex d9608ae66a4..77def3fe1bd 100644--- a/Tests/LibWeb/Text/expected/wpt-import/web-animations/animation-model/animation-types/interpolation-per-property-002.txt+++ b/Tests/LibWeb/Text/expected/wpt-import/web-animations/animation-model/animation-types/interpolation-per-property-002.txt@@ -2,8 +2,8 @@ Harness status: OKFound 411 tests-392 Pass-19 Fail+398 Pass+13 FailPass SetupPass isolation (type: discrete) has testInterpolation functionPass isolation uses discrete animation when animating between "auto" and "isolate" with linear easing@@ -213,12 +213,12 @@ Pass scroll-snap-type uses discrete animation when animating between "none" andPass scroll-snap-type uses discrete animation when animating between "none" and "x mandatory" with effect easingPass scroll-snap-type uses discrete animation when animating between "none" and "x mandatory" with keyframe easingPass scrollbar-color (type: colorPair) has testInterpolation function-Fail scrollbar-color supports animating as color pair of rgb()-Fail scrollbar-color supports animating as color pair of #RGB-Fail scrollbar-color supports animating as color pair of hsl()-Fail scrollbar-color supports animating as color pair of #RGBa-Fail scrollbar-color supports animating as color pair of rgba()-Fail scrollbar-color supports animating as color pair of hsla()+Pass scrollbar-color supports animating as color pair of rgb()+Pass scrollbar-color supports animating as color pair of #RGB+Pass scrollbar-color supports animating as color pair of hsl()+Pass scrollbar-color supports animating as color pair of #RGBa+Pass scrollbar-color supports animating as color pair of rgba()+Pass scrollbar-color supports animating as color pair of hsla()Pass scrollbar-gutter (type: discrete) has testInterpolation functionPass scrollbar-gutter uses discrete animation when animating between "auto" and "stable" with linear easingPass scrollbar-gutter uses discrete animation when animating between "auto" and "stable" with effect easing