diff --git a/Libraries/LibWeb/CSS/Interpolation.cpp b/Libraries/LibWeb/CSS/Interpolation.cpp index e68d82c2101..7d148e29141 100644 --- a/Libraries/LibWeb/CSS/Interpolation.cpp +++ b/Libraries/LibWeb/CSS/Interpolation.cpp @@ -15,6 +15,7 @@ #include #include #include +#include #include #include #include @@ -161,6 +162,13 @@ ValueComparingRefPtr interpolate_property(DOM::Element& ele if (property_id == PropertyID::BoxShadow) return interpolate_box_shadow(element, calculation_context, from, to, delta); + if (property_id == PropertyID::FontStyle) { + auto static oblique_0deg_value = FontStyleStyleValue::create(FontStyle::Oblique, AngleStyleValue::create(Angle::make_degrees(0))); + auto from_value = from->as_font_style().font_style() == FontStyle::Normal ? oblique_0deg_value : from; + auto to_value = to->as_font_style().font_style() == FontStyle::Normal ? oblique_0deg_value : to; + return interpolate_value(element, calculation_context, from_value, to_value, delta); + } + if (property_id == PropertyID::Scale) return interpolate_scale(element, calculation_context, from, to, delta); @@ -689,6 +697,17 @@ static RefPtr interpolate_value_impl(DOM::Element& element, return delta >= 0.5f ? to : from; } + case CSSStyleValue::Type::FontStyle: { + auto const& from_font_style = from.as_font_style(); + auto const& to_font_style = to.as_font_style(); + auto interpolated_font_style = interpolate_value(element, calculation_context, CSSKeywordValue::create(to_keyword(from_font_style.font_style())), CSSKeywordValue::create(to_keyword(to_font_style.font_style())), delta); + if (from_font_style.angle() && to_font_style.angle()) { + auto interpolated_angle = interpolate_value(element, calculation_context, *from_font_style.angle(), *to_font_style.angle(), delta); + return FontStyleStyleValue::create(*keyword_to_font_style(interpolated_font_style->to_keyword()), interpolated_angle); + } + + return FontStyleStyleValue::create(*keyword_to_font_style(interpolated_font_style->to_keyword())); + } case CSSStyleValue::Type::Integer: { // https://drafts.csswg.org/css-values/#combine-integers // Interpolation of is defined as Vresult = round((1 - p) × VA + p × VB); diff --git a/Tests/LibWeb/Text/expected/wpt-import/css/css-fonts/animations/font-style-interpolation.txt b/Tests/LibWeb/Text/expected/wpt-import/css/css-fonts/animations/font-style-interpolation.txt new file mode 100644 index 00000000000..3383b93d56c --- /dev/null +++ b/Tests/LibWeb/Text/expected/wpt-import/css/css-fonts/animations/font-style-interpolation.txt @@ -0,0 +1,135 @@ +Harness status: OK + +Found 129 tests + +116 Pass +13 Fail +Pass CSS Transitions: property from [normal] to [oblique 10deg] at (-2) should be [oblique -20deg] +Pass CSS Transitions: property from [normal] to [oblique 10deg] at (-0.25) should be [oblique -2.5deg] +Pass CSS Transitions: property from [normal] to [oblique 10deg] at (0) should be [normal] +Pass CSS Transitions: property from [normal] to [oblique 10deg] at (0.3) should be [oblique 3deg] +Pass CSS Transitions: property from [normal] to [oblique 10deg] at (0.6) should be [oblique 6deg] +Pass CSS Transitions: property from [normal] to [oblique 10deg] at (1) should be [oblique 10deg] +Pass CSS Transitions: property from [normal] to [oblique 10deg] at (1.5) should be [oblique 15deg] +Pass CSS Transitions with transition: all: property from [normal] to [oblique 10deg] at (-2) should be [oblique -20deg] +Pass CSS Transitions with transition: all: property from [normal] to [oblique 10deg] at (-0.25) should be [oblique -2.5deg] +Pass CSS Transitions with transition: all: property from [normal] to [oblique 10deg] at (0) should be [normal] +Pass CSS Transitions with transition: all: property from [normal] to [oblique 10deg] at (0.3) should be [oblique 3deg] +Pass CSS Transitions with transition: all: property from [normal] to [oblique 10deg] at (0.6) should be [oblique 6deg] +Pass CSS Transitions with transition: all: property from [normal] to [oblique 10deg] at (1) should be [oblique 10deg] +Pass CSS Transitions with transition: all: property from [normal] to [oblique 10deg] at (1.5) should be [oblique 15deg] +Pass CSS Animations: property from [normal] to [oblique 10deg] at (-2) should be [oblique -20deg] +Pass CSS Animations: property from [normal] to [oblique 10deg] at (-0.25) should be [oblique -2.5deg] +Pass CSS Animations: property from [normal] to [oblique 10deg] at (0) should be [normal] +Pass CSS Animations: property from [normal] to [oblique 10deg] at (0.3) should be [oblique 3deg] +Pass CSS Animations: property from [normal] to [oblique 10deg] at (0.6) should be [oblique 6deg] +Pass CSS Animations: property from [normal] to [oblique 10deg] at (1) should be [oblique 10deg] +Pass CSS Animations: property from [normal] to [oblique 10deg] at (1.5) should be [oblique 15deg] +Pass Web Animations: property from [normal] to [oblique 10deg] at (-2) should be [oblique -20deg] +Pass Web Animations: property from [normal] to [oblique 10deg] at (-0.25) should be [oblique -2.5deg] +Pass Web Animations: property from [normal] to [oblique 10deg] at (0) should be [normal] +Pass Web Animations: property from [normal] to [oblique 10deg] at (0.3) should be [oblique 3deg] +Pass Web Animations: property from [normal] to [oblique 10deg] at (0.6) should be [oblique 6deg] +Pass Web Animations: property from [normal] to [oblique 10deg] at (1) should be [oblique 10deg] +Pass Web Animations: property from [normal] to [oblique 10deg] at (1.5) should be [oblique 15deg] +Pass CSS Transitions: property from [oblique 5deg] to [oblique 15deg] at (-2) should be [oblique -15deg] +Pass CSS Transitions: property from [oblique 5deg] to [oblique 15deg] at (-0.25) should be [oblique 2.5deg] +Pass CSS Transitions: property from [oblique 5deg] to [oblique 15deg] at (0) should be [oblique 5deg] +Pass CSS Transitions: property from [oblique 5deg] to [oblique 15deg] at (0.3) should be [oblique 8deg] +Pass CSS Transitions: property from [oblique 5deg] to [oblique 15deg] at (0.6) should be [oblique 11deg] +Pass CSS Transitions: property from [oblique 5deg] to [oblique 15deg] at (1) should be [oblique 15deg] +Pass CSS Transitions: property from [oblique 5deg] to [oblique 15deg] at (1.5) should be [oblique 20deg] +Pass CSS Transitions with transition: all: property from [oblique 5deg] to [oblique 15deg] at (-2) should be [oblique -15deg] +Pass CSS Transitions with transition: all: property from [oblique 5deg] to [oblique 15deg] at (-0.25) should be [oblique 2.5deg] +Pass CSS Transitions with transition: all: property from [oblique 5deg] to [oblique 15deg] at (0) should be [oblique 5deg] +Pass CSS Transitions with transition: all: property from [oblique 5deg] to [oblique 15deg] at (0.3) should be [oblique 8deg] +Pass CSS Transitions with transition: all: property from [oblique 5deg] to [oblique 15deg] at (0.6) should be [oblique 11deg] +Pass CSS Transitions with transition: all: property from [oblique 5deg] to [oblique 15deg] at (1) should be [oblique 15deg] +Pass CSS Transitions with transition: all: property from [oblique 5deg] to [oblique 15deg] at (1.5) should be [oblique 20deg] +Pass CSS Animations: property from [oblique 5deg] to [oblique 15deg] at (-2) should be [oblique -15deg] +Pass CSS Animations: property from [oblique 5deg] to [oblique 15deg] at (-0.25) should be [oblique 2.5deg] +Pass CSS Animations: property from [oblique 5deg] to [oblique 15deg] at (0) should be [oblique 5deg] +Pass CSS Animations: property from [oblique 5deg] to [oblique 15deg] at (0.3) should be [oblique 8deg] +Pass CSS Animations: property from [oblique 5deg] to [oblique 15deg] at (0.6) should be [oblique 11deg] +Pass CSS Animations: property from [oblique 5deg] to [oblique 15deg] at (1) should be [oblique 15deg] +Pass CSS Animations: property from [oblique 5deg] to [oblique 15deg] at (1.5) should be [oblique 20deg] +Pass Web Animations: property from [oblique 5deg] to [oblique 15deg] at (-2) should be [oblique -15deg] +Pass Web Animations: property from [oblique 5deg] to [oblique 15deg] at (-0.25) should be [oblique 2.5deg] +Pass Web Animations: property from [oblique 5deg] to [oblique 15deg] at (0) should be [oblique 5deg] +Pass Web Animations: property from [oblique 5deg] to [oblique 15deg] at (0.3) should be [oblique 8deg] +Pass Web Animations: property from [oblique 5deg] to [oblique 15deg] at (0.6) should be [oblique 11deg] +Pass Web Animations: property from [oblique 5deg] to [oblique 15deg] at (1) should be [oblique 15deg] +Pass Web Animations: property from [oblique 5deg] to [oblique 15deg] at (1.5) should be [oblique 20deg] +Pass CSS Transitions: property from [initial] to [inherit] at (-2) should be [oblique -40deg] +Pass CSS Transitions: property from [initial] to [inherit] at (-0.25) should be [oblique -5deg] +Pass CSS Transitions: property from [initial] to [inherit] at (0) should be [normal] +Pass CSS Transitions: property from [initial] to [inherit] at (0.3) should be [oblique 6deg] +Pass CSS Transitions: property from [initial] to [inherit] at (0.6) should be [oblique 12deg] +Pass CSS Transitions: property from [initial] to [inherit] at (1) should be [oblique 20deg] +Pass CSS Transitions: property from [initial] to [inherit] at (1.5) should be [oblique 30deg] +Pass CSS Transitions with transition: all: property from [initial] to [inherit] at (-2) should be [oblique -40deg] +Pass CSS Transitions with transition: all: property from [initial] to [inherit] at (-0.25) should be [oblique -5deg] +Pass CSS Transitions with transition: all: property from [initial] to [inherit] at (0) should be [normal] +Pass CSS Transitions with transition: all: property from [initial] to [inherit] at (0.3) should be [oblique 6deg] +Pass CSS Transitions with transition: all: property from [initial] to [inherit] at (0.6) should be [oblique 12deg] +Pass CSS Transitions with transition: all: property from [initial] to [inherit] at (1) should be [oblique 20deg] +Pass CSS Transitions with transition: all: property from [initial] to [inherit] at (1.5) should be [oblique 30deg] +Pass CSS Animations: property from [initial] to [inherit] at (-2) should be [oblique -40deg] +Pass CSS Animations: property from [initial] to [inherit] at (-0.25) should be [oblique -5deg] +Pass CSS Animations: property from [initial] to [inherit] at (0) should be [normal] +Pass CSS Animations: property from [initial] to [inherit] at (0.3) should be [oblique 6deg] +Pass CSS Animations: property from [initial] to [inherit] at (0.6) should be [oblique 12deg] +Pass CSS Animations: property from [initial] to [inherit] at (1) should be [oblique 20deg] +Pass CSS Animations: property from [initial] to [inherit] at (1.5) should be [oblique 30deg] +Pass Web Animations: property from [initial] to [inherit] at (-2) should be [oblique -40deg] +Pass Web Animations: property from [initial] to [inherit] at (-0.25) should be [oblique -5deg] +Pass Web Animations: property from [initial] to [inherit] at (0) should be [normal] +Pass Web Animations: property from [initial] to [inherit] at (0.3) should be [oblique 6deg] +Pass Web Animations: property from [initial] to [inherit] at (0.6) should be [oblique 12deg] +Pass Web Animations: property from [initial] to [inherit] at (1) should be [oblique 20deg] +Pass Web Animations: property from [initial] to [inherit] at (1.5) should be [oblique 30deg] +Pass CSS Transitions: property from [oblique 20deg] to [normal] at (-1) should be [oblique 40deg] +Pass CSS Transitions: property from [oblique 20deg] to [normal] at (0) should be [oblique 20deg] +Pass CSS Transitions: property from [oblique 20deg] to [normal] at (0.5) should be [oblique 10deg] +Pass CSS Transitions: property from [oblique 20deg] to [normal] at (1) should be [normal] +Pass CSS Transitions: property from [oblique 20deg] to [normal] at (1.5) should be [oblique -10deg] +Pass CSS Transitions with transition: all: property from [oblique 20deg] to [normal] at (-1) should be [oblique 40deg] +Pass CSS Transitions with transition: all: property from [oblique 20deg] to [normal] at (0) should be [oblique 20deg] +Pass CSS Transitions with transition: all: property from [oblique 20deg] to [normal] at (0.5) should be [oblique 10deg] +Pass CSS Transitions with transition: all: property from [oblique 20deg] to [normal] at (1) should be [normal] +Pass CSS Transitions with transition: all: property from [oblique 20deg] to [normal] at (1.5) should be [oblique -10deg] +Pass CSS Animations: property from [oblique 20deg] to [normal] at (-1) should be [oblique 40deg] +Pass CSS Animations: property from [oblique 20deg] to [normal] at (0) should be [oblique 20deg] +Pass CSS Animations: property from [oblique 20deg] to [normal] at (0.5) should be [oblique 10deg] +Pass CSS Animations: property from [oblique 20deg] to [normal] at (1) should be [normal] +Pass CSS Animations: property from [oblique 20deg] to [normal] at (1.5) should be [oblique -10deg] +Pass Web Animations: property from [oblique 20deg] to [normal] at (-1) should be [oblique 40deg] +Pass Web Animations: property from [oblique 20deg] to [normal] at (0) should be [oblique 20deg] +Pass Web Animations: property from [oblique 20deg] to [normal] at (0.5) should be [oblique 10deg] +Pass Web Animations: property from [oblique 20deg] to [normal] at (1) should be [normal] +Pass Web Animations: property from [oblique 20deg] to [normal] at (1.5) should be [oblique -10deg] +Fail CSS Transitions: property from [oblique -90deg] to [oblique 90deg] at (-2) should be [oblique -90deg] +Fail CSS Transitions: property from [oblique -90deg] to [oblique 90deg] at (-1) should be [oblique -90deg] +Pass CSS Transitions: property from [oblique -90deg] to [oblique 90deg] at (0) should be [oblique -90deg] +Pass CSS Transitions: property from [oblique -90deg] to [oblique 90deg] at (0.5) should be [normal] +Pass CSS Transitions: property from [oblique -90deg] to [oblique 90deg] at (1) should be [oblique 90deg] +Fail CSS Transitions: property from [oblique -90deg] to [oblique 90deg] at (1.5) should be [oblique 90deg] +Fail CSS Transitions with transition: all: property from [oblique -90deg] to [oblique 90deg] at (-2) should be [oblique -90deg] +Fail CSS Transitions with transition: all: property from [oblique -90deg] to [oblique 90deg] at (-1) should be [oblique -90deg] +Pass CSS Transitions with transition: all: property from [oblique -90deg] to [oblique 90deg] at (0) should be [oblique -90deg] +Pass CSS Transitions with transition: all: property from [oblique -90deg] to [oblique 90deg] at (0.5) should be [normal] +Pass CSS Transitions with transition: all: property from [oblique -90deg] to [oblique 90deg] at (1) should be [oblique 90deg] +Fail CSS Transitions with transition: all: property from [oblique -90deg] to [oblique 90deg] at (1.5) should be [oblique 90deg] +Fail CSS Animations: property from [oblique -90deg] to [oblique 90deg] at (-2) should be [oblique -90deg] +Fail CSS Animations: property from [oblique -90deg] to [oblique 90deg] at (-1) should be [oblique -90deg] +Pass CSS Animations: property from [oblique -90deg] to [oblique 90deg] at (0) should be [oblique -90deg] +Pass CSS Animations: property from [oblique -90deg] to [oblique 90deg] at (0.5) should be [normal] +Pass CSS Animations: property from [oblique -90deg] to [oblique 90deg] at (1) should be [oblique 90deg] +Fail CSS Animations: property from [oblique -90deg] to [oblique 90deg] at (1.5) should be [oblique 90deg] +Fail Web Animations: property from [oblique -90deg] to [oblique 90deg] at (-2) should be [oblique -90deg] +Fail Web Animations: property from [oblique -90deg] to [oblique 90deg] at (-1) should be [oblique -90deg] +Pass Web Animations: property from [oblique -90deg] to [oblique 90deg] at (0) should be [oblique -90deg] +Pass Web Animations: property from [oblique -90deg] to [oblique 90deg] at (0.5) should be [normal] +Pass Web Animations: property from [oblique -90deg] to [oblique 90deg] at (1) should be [oblique 90deg] +Fail Web Animations: property from [oblique -90deg] to [oblique 90deg] at (1.5) should be [oblique 90deg] +Fail An interpolation to inherit updates correctly on a parent style change. \ No newline at end of file diff --git a/Tests/LibWeb/Text/input/wpt-import/css/css-fonts/animations/font-style-interpolation.html b/Tests/LibWeb/Text/input/wpt-import/css/css-fonts/animations/font-style-interpolation.html new file mode 100644 index 00000000000..3af5ef499ec --- /dev/null +++ b/Tests/LibWeb/Text/input/wpt-import/css/css-fonts/animations/font-style-interpolation.html @@ -0,0 +1,122 @@ + + +font-style interpolation + + + + + + + + + + + + + +
TT
+
+ + + +