mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-05-04 02:08:53 +00:00
LibWeb: Merge background-position parsing into position code
Implemented by adding the extra 3-value syntax as its own case and only running it when parsing background-position. I'm sure it could be implemented in a smarter way but this is still a bunch less code than before. :^)
This commit is contained in:
parent
26d6ba6f58
commit
148f873321
Notes:
sideshowbarker
2024-07-17 03:45:48 +09:00
Author: https://github.com/AtkinsSJ
Commit: 148f873321
Pull-request: https://github.com/SerenityOS/serenity/pull/22001
5 changed files with 104 additions and 174 deletions
|
@ -21,7 +21,7 @@ void generate_bounds_checking_function(JsonObject& properties, SourceGenerator&
|
|||
static bool type_name_is_enum(StringView 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, "background-position"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, "position"sv, "ratio"sv, "rect"sv,
|
||||
"resolution"sv, "string"sv, "time"sv, "url"sv);
|
||||
}
|
||||
|
@ -168,6 +168,7 @@ NonnullRefPtr<StyleValue> property_initial_value(JS::Realm&, PropertyID);
|
|||
|
||||
enum class ValueType {
|
||||
Angle,
|
||||
BackgroundPosition,
|
||||
Color,
|
||||
CustomIdent,
|
||||
EasingFunction,
|
||||
|
@ -616,6 +617,8 @@ bool property_accepts_type(PropertyID property_id, ValueType value_type)
|
|||
|
||||
if (type_name == "angle") {
|
||||
property_generator.appendln(" case ValueType::Angle:");
|
||||
} else if (type_name == "background-position") {
|
||||
property_generator.appendln(" case ValueType::BackgroundPosition:");
|
||||
} else if (type_name == "color") {
|
||||
property_generator.appendln(" case ValueType::Color:");
|
||||
} else if (type_name == "custom-ident") {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue