mirror of
https://github.com/RGBCube/serenity
synced 2025-05-28 08:25:07 +00:00
LibWeb: Generate function for what properties resolve percentages to
This is required by "determine the type of a calculation". https://www.w3.org/TR/css-values-4/#determine-the-type-of-a-calculation
This commit is contained in:
parent
be7093ab0d
commit
38f954cba5
2 changed files with 106 additions and 25 deletions
|
@ -176,6 +176,7 @@ enum class ValueType {
|
|||
};
|
||||
bool property_accepts_type(PropertyID, ValueType);
|
||||
bool property_accepts_identifier(PropertyID, ValueID);
|
||||
Optional<ValueType> property_resolves_percentages_relative_to(PropertyID);
|
||||
|
||||
// These perform range-checking, but are also safe to call with properties that don't accept that type. (They'll just return false.)
|
||||
bool property_accepts_angle(PropertyID, Angle const&);
|
||||
|
@ -718,6 +719,31 @@ bool property_accepts_identifier(PropertyID property_id, ValueID identifier)
|
|||
}
|
||||
}
|
||||
|
||||
Optional<ValueType> property_resolves_percentages_relative_to(PropertyID property_id)
|
||||
{
|
||||
switch (property_id) {
|
||||
)~~~"));
|
||||
|
||||
TRY(properties.try_for_each_member([&](auto& name, auto& value) -> ErrorOr<void> {
|
||||
VERIFY(value.is_object());
|
||||
if (auto resolved_type = value.as_object().get_deprecated_string("percentages-resolve-to"sv); resolved_type.has_value()) {
|
||||
auto property_generator = TRY(generator.fork());
|
||||
TRY(property_generator.set("name:titlecase", TRY(title_casify(name))));
|
||||
TRY(property_generator.set("resolved_type:titlecase", TRY(title_casify(resolved_type.value()))));
|
||||
TRY(property_generator.try_append(R"~~~(
|
||||
case PropertyID::@name:titlecase@:
|
||||
return ValueType::@resolved_type:titlecase@;
|
||||
)~~~"));
|
||||
}
|
||||
return {};
|
||||
}));
|
||||
|
||||
TRY(generator.try_append(R"~~~(
|
||||
default:
|
||||
return {};
|
||||
}
|
||||
}
|
||||
|
||||
size_t property_maximum_value_count(PropertyID property_id)
|
||||
{
|
||||
switch (property_id) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue