summaryrefslogtreecommitdiff
path: root/Meta/Lagom
diff options
context:
space:
mode:
authorSam Atkins <atkinssj@serenityos.org>2022-01-27 15:13:19 +0000
committerAndreas Kling <kling@serenityos.org>2022-02-04 13:52:02 +0100
commite111e8e44ee07e2a63ff235d65b0f3037f7e7487 (patch)
tree71fd100d00970c3a2d4dcda716eca7e589b27fa7 /Meta/Lagom
parentb54cd17c1ee7eb0a46af8feac66ca4180df8416d (diff)
downloadserenity-e111e8e44ee07e2a63ff235d65b0f3037f7e7487.zip
LibWeb: Type-check calc() in in property_accepts_value()
This means only CalculatedStyleValues that would return the desired type will be accepted.
Diffstat (limited to 'Meta/Lagom')
-rw-r--r--Meta/Lagom/Tools/CodeGenerators/LibWeb/Generate_CSS_PropertyID_cpp.cpp12
1 files changed, 9 insertions, 3 deletions
diff --git a/Meta/Lagom/Tools/CodeGenerators/LibWeb/Generate_CSS_PropertyID_cpp.cpp b/Meta/Lagom/Tools/CodeGenerators/LibWeb/Generate_CSS_PropertyID_cpp.cpp
index baedbcbf39..9b8ad8b006 100644
--- a/Meta/Lagom/Tools/CodeGenerators/LibWeb/Generate_CSS_PropertyID_cpp.cpp
+++ b/Meta/Lagom/Tools/CodeGenerators/LibWeb/Generate_CSS_PropertyID_cpp.cpp
@@ -307,12 +307,14 @@ bool property_accepts_value(PropertyID property_id, StyleValue& style_value)
)~~~");
} else if (type_name == "length") {
property_generator.append(R"~~~(
- if (style_value.has_length() || style_value.is_calculated())
+ if (style_value.has_length()
+ || (style_value.is_calculated() && style_value.as_calculated().resolved_type() == CalculatedStyleValue::ResolvedType::Length))
return true;
)~~~");
} else if (type_name == "percentage") {
property_generator.append(R"~~~(
- if (style_value.is_percentage() || style_value.is_calculated())
+ if (style_value.is_percentage()
+ || (style_value.is_calculated() && style_value.as_calculated().resolved_type() == CalculatedStyleValue::ResolvedType::Percentage))
return true;
)~~~");
} else if (type_name == "number" || type_name == "integer") {
@@ -327,7 +329,7 @@ bool property_accepts_value(PropertyID property_id, StyleValue& style_value)
max_value = type_args.substring_view(comma_index + 1, type_args.length() - comma_index - 2);
}
test_generator.append(R"~~~(
- if (style_value.has_@numbertype@())~~~");
+ if ((style_value.has_@numbertype@())~~~");
if (!min_value.is_empty()) {
test_generator.set("minvalue", min_value);
test_generator.append(" && (style_value.to_@numbertype@() >= @minvalue@)");
@@ -337,6 +339,10 @@ bool property_accepts_value(PropertyID property_id, StyleValue& style_value)
test_generator.append(" && (style_value.to_@numbertype@() <= @maxvalue@)");
}
test_generator.append(R"~~~()
+ || (style_value.is_calculated() && (style_value.as_calculated().resolved_type() == CalculatedStyleValue::ResolvedType::Integer)~~~");
+ if (type_name == "number")
+ test_generator.append(R"~~~(|| style_value.as_calculated().resolved_type() == CalculatedStyleValue::ResolvedType::Number)~~~");
+ test_generator.append(R"~~~()))
return true;
)~~~");
} else if (type_name == "string") {