|
24 | 24 | #include <LibWeb/CSS/StyleValues/KeywordStyleValue.h> |
25 | 25 | #include <LibWeb/CSS/StyleValues/LengthStyleValue.h> |
26 | 26 | #include <LibWeb/CSS/StyleValues/NumberStyleValue.h> |
| 27 | +#include <LibWeb/CSS/StyleValues/OpenTypeTaggedStyleValue.h> |
27 | 28 | #include <LibWeb/CSS/StyleValues/PercentageStyleValue.h> |
28 | 29 | #include <LibWeb/CSS/StyleValues/RatioStyleValue.h> |
29 | 30 | #include <LibWeb/CSS/StyleValues/RectStyleValue.h> |
@@ -635,6 +636,21 @@ ValueComparingRefPtr<StyleValue const> interpolate_property(DOM::Element& elemen |
635 | 636 | return interpolate_value(element, calculation_context, from_value, to_value, delta, allow_discrete); |
636 | 637 | } |
637 | 638 |
|
| 639 | + if (property_id == PropertyID::FontVariationSettings) { |
| 640 | + // https://drafts.csswg.org/css-fonts/#font-variation-settings-def |
| 641 | + // Two declarations of font-feature-settings can be animated between if they are "like". "Like" declarations |
| 642 | + // are ones where the same set of properties appear (in any order). Because successive duplicate properties |
| 643 | + // are applied instead of prior duplicate properties, two declarations can be "like" even if they have |
| 644 | + // differing number of properties. If two declarations are "like" then animation occurs pairwise between |
| 645 | + // corresponding values in the declarations. Otherwise, animation is not possible. |
| 646 | + if (!from->is_value_list() || !to->is_value_list()) |
| 647 | + return interpolate_discrete(from, to, delta, allow_discrete); |
| 648 | + |
| 649 | + // The values in these lists have already been deduplicated and sorted at this point, so we can use |
| 650 | + // interpolate_value() to interpolate them pairwise. |
| 651 | + return interpolate_value(element, calculation_context, from, to, delta, allow_discrete); |
| 652 | + } |
| 653 | + |
638 | 654 | // https://drafts.csswg.org/web-animations-1/#animating-visibility |
639 | 655 | if (property_id == PropertyID::Visibility) { |
640 | 656 | // For the visibility property, visible is interpolated as a discrete step where values of p between 0 and 1 map to visible and other values of p map to the closer endpoint. |
@@ -1574,6 +1590,16 @@ static RefPtr<StyleValue const> interpolate_value_impl(DOM::Element& element, Ca |
1574 | 1590 | auto interpolated_value = interpolate_raw(from.as_number().number(), to.as_number().number(), delta, calculation_context.accepted_type_ranges.get(ValueType::Number)); |
1575 | 1591 | return NumberStyleValue::create(interpolated_value); |
1576 | 1592 | } |
| 1593 | + case StyleValue::Type::OpenTypeTagged: { |
| 1594 | + auto& from_open_type_tagged = from.as_open_type_tagged(); |
| 1595 | + auto& to_open_type_tagged = to.as_open_type_tagged(); |
| 1596 | + if (from_open_type_tagged.tag() != to_open_type_tagged.tag()) |
| 1597 | + return {}; |
| 1598 | + auto interpolated_value = interpolate_value(element, calculation_context, from_open_type_tagged.value(), to_open_type_tagged.value(), delta, allow_discrete); |
| 1599 | + if (!interpolated_value) |
| 1600 | + return {}; |
| 1601 | + return OpenTypeTaggedStyleValue::create(OpenTypeTaggedStyleValue::Mode::FontVariationSettings, from_open_type_tagged.tag(), interpolated_value.release_nonnull()); |
| 1602 | + } |
1577 | 1603 | case StyleValue::Type::Percentage: { |
1578 | 1604 | auto interpolated_value = interpolate_raw(from.as_percentage().percentage().value(), to.as_percentage().percentage().value(), delta, calculation_context.accepted_type_ranges.get(ValueType::Percentage)); |
1579 | 1605 | return PercentageStyleValue::create(Percentage(interpolated_value)); |
|
0 commit comments