summaryrefslogtreecommitdiff
path: root/Meta/Lagom
diff options
context:
space:
mode:
authorSam Atkins <atkinssj@serenityos.org>2022-02-22 13:49:05 +0000
committerAndreas Kling <kling@serenityos.org>2022-02-24 08:04:25 +0100
commit53a3937c34bdc9d8a2a3df8b0cf474571c25d94c (patch)
tree6c45274d1986594a62f75b6330e2fdc817cc4660 /Meta/Lagom
parent5c8ea81d21f573e19a0d1a398b187e8fe9e956c6 (diff)
downloadserenity-53a3937c34bdc9d8a2a3df8b0cf474571c25d94c.zip
LibWeb: Allow Angle/Frequency/Resolution/Time values for CSS properties
Diffstat (limited to 'Meta/Lagom')
-rw-r--r--Meta/Lagom/Tools/CodeGenerators/LibWeb/Generate_CSS_PropertyID_cpp.cpp37
1 files changed, 30 insertions, 7 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 9b8ad8b006..6e106a0802 100644
--- a/Meta/Lagom/Tools/CodeGenerators/LibWeb/Generate_CSS_PropertyID_cpp.cpp
+++ b/Meta/Lagom/Tools/CodeGenerators/LibWeb/Generate_CSS_PropertyID_cpp.cpp
@@ -295,11 +295,23 @@ bool property_accepts_value(PropertyID property_id, StyleValue& style_value)
auto type_parts = type.as_string().split_view(' ');
auto type_name = type_parts.first();
auto type_args = type_parts.size() > 1 ? type_parts[1] : ""sv;
- if (type_name == "color") {
+ if (type_name == "angle") {
+ property_generator.append(R"~~~(
+ if (style_value.is_angle()
+ || (style_value.is_calculated() && style_value.as_calculated().resolved_type() == CalculatedStyleValue::ResolvedType::Angle))
+ return true;
+)~~~");
+ } else if (type_name == "color") {
property_generator.append(R"~~~(
if (style_value.has_color())
return true;
)~~~");
+ } else if (type_name == "frequency") {
+ property_generator.append(R"~~~(
+ if (style_value.is_frequency()
+ || (style_value.is_calculated() && style_value.as_calculated().resolved_type() == CalculatedStyleValue::ResolvedType::Frequency))
+ return true;
+)~~~");
} else if (type_name == "image") {
property_generator.append(R"~~~(
if (style_value.is_image())
@@ -311,12 +323,6 @@ bool property_accepts_value(PropertyID property_id, StyleValue& style_value)
|| (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() && style_value.as_calculated().resolved_type() == CalculatedStyleValue::ResolvedType::Percentage))
- return true;
-)~~~");
} else if (type_name == "number" || type_name == "integer") {
auto test_generator = property_generator.fork();
test_generator.set("numbertype", type_name);
@@ -345,11 +351,28 @@ bool property_accepts_value(PropertyID property_id, StyleValue& style_value)
test_generator.append(R"~~~()))
return true;
)~~~");
+ } else if (type_name == "percentage") {
+ property_generator.append(R"~~~(
+ if (style_value.is_percentage()
+ || (style_value.is_calculated() && style_value.as_calculated().resolved_type() == CalculatedStyleValue::ResolvedType::Percentage))
+ return true;
+)~~~");
+ } else if (type_name == "resolution") {
+ property_generator.append(R"~~~(
+ if (style_value.is_resolution())
+ return true;
+)~~~");
} else if (type_name == "string") {
property_generator.append(R"~~~(
if (style_value.is_string())
return true;
)~~~");
+ } else if (type_name == "time") {
+ property_generator.append(R"~~~(
+ if (style_value.is_time()
+ || (style_value.is_calculated() && style_value.as_calculated().resolved_type() == CalculatedStyleValue::ResolvedType::Time))
+ return true;
+)~~~");
} else if (type_name == "url") {
// FIXME: Handle urls!
} else {