mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 02:18:11 +00:00
LibWeb: Parse the CSS position type automatically
This means `object-position` will no longer incorrectly accept the 3-value background-position syntax. Remove the now-ambiguous and unused `position` enum while we're at it. (This enum only existed as a hack.)
This commit is contained in:
parent
19da17f07e
commit
26d6ba6f58
4 changed files with 9 additions and 19 deletions
|
@ -22,7 +22,7 @@ static bool type_name_is_enum(StringView type_name)
|
||||||
{
|
{
|
||||||
return !AK::first_is_one_of(type_name,
|
return !AK::first_is_one_of(type_name,
|
||||||
"angle"sv, "color"sv, "custom-ident"sv, "easing-function"sv, "flex"sv, "frequency"sv, "image"sv,
|
"angle"sv, "color"sv, "custom-ident"sv, "easing-function"sv, "flex"sv, "frequency"sv, "image"sv,
|
||||||
"integer"sv, "length"sv, "number"sv, "paint"sv, "percentage"sv, "ratio"sv, "rect"sv,
|
"integer"sv, "length"sv, "number"sv, "paint"sv, "percentage"sv, "position"sv, "ratio"sv, "rect"sv,
|
||||||
"resolution"sv, "string"sv, "time"sv, "url"sv);
|
"resolution"sv, "string"sv, "time"sv, "url"sv);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -638,6 +638,8 @@ bool property_accepts_type(PropertyID property_id, ValueType value_type)
|
||||||
property_generator.appendln(" case ValueType::Paint:");
|
property_generator.appendln(" case ValueType::Paint:");
|
||||||
} else if (type_name == "percentage") {
|
} else if (type_name == "percentage") {
|
||||||
property_generator.appendln(" case ValueType::Percentage:");
|
property_generator.appendln(" case ValueType::Percentage:");
|
||||||
|
} else if (type_name == "position") {
|
||||||
|
property_generator.appendln(" case ValueType::Position:");
|
||||||
} else if (type_name == "ratio") {
|
} else if (type_name == "ratio") {
|
||||||
property_generator.appendln(" case ValueType::Ratio:");
|
property_generator.appendln(" case ValueType::Ratio:");
|
||||||
} else if (type_name == "rect") {
|
} else if (type_name == "rect") {
|
||||||
|
|
|
@ -319,13 +319,6 @@
|
||||||
"all",
|
"all",
|
||||||
"none"
|
"none"
|
||||||
],
|
],
|
||||||
"position": [
|
|
||||||
"left",
|
|
||||||
"right",
|
|
||||||
"top",
|
|
||||||
"bottom",
|
|
||||||
"center"
|
|
||||||
],
|
|
||||||
"positioning": [
|
"positioning": [
|
||||||
"absolute",
|
"absolute",
|
||||||
"fixed",
|
"fixed",
|
||||||
|
|
|
@ -5930,12 +5930,6 @@ Parser::ParseErrorOr<NonnullRefPtr<StyleValue>> Parser::parse_css_value(Property
|
||||||
if (auto parsed_value = parse_math_depth_value(component_values))
|
if (auto parsed_value = parse_math_depth_value(component_values))
|
||||||
return parsed_value.release_nonnull();
|
return parsed_value.release_nonnull();
|
||||||
return ParseError::SyntaxError;
|
return ParseError::SyntaxError;
|
||||||
case PropertyID::ObjectPosition:
|
|
||||||
// FIXME: This should use a parse_position compatible to VALUES-4
|
|
||||||
// and not the background position, which is almost the same.
|
|
||||||
if (auto parsed_value = parse_comma_separated_value_list(component_values, [this](auto& tokens) { return parse_single_background_position_value(tokens); }))
|
|
||||||
return parsed_value.release_nonnull();
|
|
||||||
return ParseError::SyntaxError;
|
|
||||||
case PropertyID::Overflow:
|
case PropertyID::Overflow:
|
||||||
if (auto parsed_value = parse_overflow_value(component_values))
|
if (auto parsed_value = parse_overflow_value(component_values))
|
||||||
return parsed_value.release_nonnull();
|
return parsed_value.release_nonnull();
|
||||||
|
@ -6130,6 +6124,11 @@ Optional<Parser::PropertyAndValue> Parser::parse_css_value_for_properties(Readon
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (auto property = any_property_accepts_type(property_ids, ValueType::Position); property.has_value()) {
|
||||||
|
if (auto maybe_position = parse_position_value(tokens))
|
||||||
|
return PropertyAndValue { *property, maybe_position };
|
||||||
|
}
|
||||||
|
|
||||||
if (auto property = any_property_accepts_type(property_ids, ValueType::Ratio); property.has_value()) {
|
if (auto property = any_property_accepts_type(property_ids, ValueType::Ratio); property.has_value()) {
|
||||||
if (auto maybe_ratio = parse_ratio_value(tokens))
|
if (auto maybe_ratio = parse_ratio_value(tokens))
|
||||||
return PropertyAndValue { *property, maybe_ratio };
|
return PropertyAndValue { *property, maybe_ratio };
|
||||||
|
|
|
@ -1628,13 +1628,9 @@
|
||||||
"affects-layout": false,
|
"affects-layout": false,
|
||||||
"inherited": false,
|
"inherited": false,
|
||||||
"initial": "50% 50%",
|
"initial": "50% 50%",
|
||||||
"max-values": 2,
|
|
||||||
"valid-types": [
|
"valid-types": [
|
||||||
"length [-∞,∞]",
|
|
||||||
"percentage [-∞,∞]",
|
|
||||||
"position"
|
"position"
|
||||||
],
|
]
|
||||||
"percentages-resolve-to": "length"
|
|
||||||
},
|
},
|
||||||
"opacity": {
|
"opacity": {
|
||||||
"affects-layout": false,
|
"affects-layout": false,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue