mirror of
https://github.com/RGBCube/serenity
synced 2025-07-24 16:17:34 +00:00
Meta/CodeGenerators+LibWeb: Add support for 'easing-function' CSS values
This commit makes it possible to let properties accept easing functions as values, which will be used in a later commit to implement animation-timing-function.
This commit is contained in:
parent
dd073b2711
commit
efa55673cd
3 changed files with 13 additions and 1 deletions
|
@ -20,7 +20,10 @@ ErrorOr<void> generate_bounds_checking_function(JsonObject& properties, SourceGe
|
||||||
|
|
||||||
static bool type_name_is_enum(StringView type_name)
|
static bool type_name_is_enum(StringView type_name)
|
||||||
{
|
{
|
||||||
return !AK::first_is_one_of(type_name, "angle"sv, "color"sv, "custom-ident"sv, "frequency"sv, "image"sv, "integer"sv, "length"sv, "number"sv, "paint"sv, "percentage"sv, "ratio"sv, "rect"sv, "resolution"sv, "string"sv, "time"sv, "url"sv);
|
return !AK::first_is_one_of(type_name,
|
||||||
|
"angle"sv, "color"sv, "custom-ident"sv, "easing-function"sv, "frequency"sv, "image"sv,
|
||||||
|
"integer"sv, "length"sv, "number"sv, "paint"sv, "percentage"sv, "ratio"sv, "rect"sv,
|
||||||
|
"resolution"sv, "string"sv, "time"sv, "url"sv);
|
||||||
}
|
}
|
||||||
|
|
||||||
ErrorOr<int> serenity_main(Main::Arguments arguments)
|
ErrorOr<int> serenity_main(Main::Arguments arguments)
|
||||||
|
@ -158,6 +161,7 @@ enum class ValueType {
|
||||||
Angle,
|
Angle,
|
||||||
Color,
|
Color,
|
||||||
CustomIdent,
|
CustomIdent,
|
||||||
|
EasingFunction,
|
||||||
FilterValueList,
|
FilterValueList,
|
||||||
Frequency,
|
Frequency,
|
||||||
Image,
|
Image,
|
||||||
|
@ -614,6 +618,8 @@ bool property_accepts_type(PropertyID property_id, ValueType value_type)
|
||||||
TRY(property_generator.try_appendln(" case ValueType::Color:"));
|
TRY(property_generator.try_appendln(" case ValueType::Color:"));
|
||||||
} else if (type_name == "custom-ident") {
|
} else if (type_name == "custom-ident") {
|
||||||
TRY(property_generator.try_appendln(" case ValueType::CustomIdent:"));
|
TRY(property_generator.try_appendln(" case ValueType::CustomIdent:"));
|
||||||
|
} else if (type_name == "easing-function") {
|
||||||
|
TRY(property_generator.try_appendln(" case ValueType::EasingFunction:"));
|
||||||
} else if (type_name == "frequency") {
|
} else if (type_name == "frequency") {
|
||||||
TRY(property_generator.try_appendln(" case ValueType::Frequency:"));
|
TRY(property_generator.try_appendln(" case ValueType::Frequency:"));
|
||||||
} else if (type_name == "image") {
|
} else if (type_name == "image") {
|
||||||
|
|
|
@ -33,6 +33,7 @@ Optional<CSSNumericType::BaseType> CSSNumericType::base_type_from_value_type(Val
|
||||||
|
|
||||||
case ValueType::Color:
|
case ValueType::Color:
|
||||||
case ValueType::CustomIdent:
|
case ValueType::CustomIdent:
|
||||||
|
case ValueType::EasingFunction:
|
||||||
case ValueType::FilterValueList:
|
case ValueType::FilterValueList:
|
||||||
case ValueType::Image:
|
case ValueType::Image:
|
||||||
case ValueType::Integer:
|
case ValueType::Integer:
|
||||||
|
|
|
@ -8329,6 +8329,11 @@ ErrorOr<Parser::PropertyAndValue> Parser::parse_css_value_for_properties(Readonl
|
||||||
|
|
||||||
auto& peek_token = tokens.peek_token();
|
auto& peek_token = tokens.peek_token();
|
||||||
|
|
||||||
|
if (auto property = any_property_accepts_type(property_ids, ValueType::EasingFunction); property.has_value()) {
|
||||||
|
if (auto maybe_easing_function = TRY(parse_easing_value(tokens)))
|
||||||
|
return PropertyAndValue { *property, maybe_easing_function };
|
||||||
|
}
|
||||||
|
|
||||||
if (peek_token.is(Token::Type::Ident)) {
|
if (peek_token.is(Token::Type::Ident)) {
|
||||||
// NOTE: We do not try to parse "CSS-wide keywords" here. https://www.w3.org/TR/css-values-4/#common-keywords
|
// NOTE: We do not try to parse "CSS-wide keywords" here. https://www.w3.org/TR/css-values-4/#common-keywords
|
||||||
// These are only valid on their own, and so should be parsed directly in `parse_css_value()`.
|
// These are only valid on their own, and so should be parsed directly in `parse_css_value()`.
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue