summaryrefslogtreecommitdiff
path: root/Meta
diff options
context:
space:
mode:
authorSam Atkins <atkinssj@serenityos.org>2021-09-23 19:54:19 +0100
committerAndreas Kling <kling@serenityos.org>2021-09-24 15:01:43 +0200
commit4b554ba92a3ddefdeae73444c69ca771e2df6c19 (patch)
tree179d3bc488096a35715183ebc215536b0a6acff3 /Meta
parent1ae0781ce1a0590e95c499d47ac37e8346d2cc0b (diff)
downloadserenity-4b554ba92a3ddefdeae73444c69ca771e2df6c19.zip
LibWeb: Clarify StyleValue API with new naming scheme
This does a few things, that are hard to separate. For a while now, it's been confuzing what `StyleValue::is_foo()` actually means. It sometimes was used to check the type, and sometimes to see if it could return a certain value type. The new naming scheme is: - `is_length()` - is it a LengthStyleValue? - `as_length()` - casts it to LengthStyleValue - `has_length()` - can it return a Length? - `to_length()` - gets the internal value out (eg, Length) This also means, no more `static_cast<LengthStyleValue const&>(*this)` stuff when dealing with StyleValues. :^) Hopefully this will be a bit clearer going forward. There are lots of places using the original methods, so I'll be going through them to hopefully catch any issues.
Diffstat (limited to 'Meta')
-rw-r--r--Meta/Lagom/Tools/CodeGenerators/LibWeb/Generate_CSS_PropertyID_cpp.cpp10
1 files changed, 5 insertions, 5 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 6553dfc49e..2b197e043c 100644
--- a/Meta/Lagom/Tools/CodeGenerators/LibWeb/Generate_CSS_PropertyID_cpp.cpp
+++ b/Meta/Lagom/Tools/CodeGenerators/LibWeb/Generate_CSS_PropertyID_cpp.cpp
@@ -284,7 +284,7 @@ bool property_accepts_value(PropertyID property_id, StyleValue& style_value)
auto type_args = type_parts.size() > 1 ? type_parts[1] : ""sv;
if (type_name == "color") {
property_generator.append(R"~~~(
- if (style_value.is_color())
+ if (style_value.has_color())
return true;
)~~~");
} else if (type_name == "image") {
@@ -295,7 +295,7 @@ bool property_accepts_value(PropertyID property_id, StyleValue& style_value)
} else if (type_name == "length" || type_name == "percentage") {
// FIXME: Handle lengths and percentages separately
property_generator.append(R"~~~(
- if (style_value.is_length() || style_value.is_calculated())
+ if (style_value.has_length() || style_value.is_calculated())
return true;
)~~~");
} else if (type_name == "number" || type_name == "integer") {
@@ -309,14 +309,14 @@ 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);
}
property_generator.append(R"~~~(
- if (style_value.is_numeric())~~~");
+ if (style_value.has_number())~~~");
if (!min_value.is_empty()) {
property_generator.set("minvalue", min_value);
- property_generator.append(" && (style_value.as_number() >= (float)@minvalue@)");
+ property_generator.append(" && (style_value.to_number() >= (float)@minvalue@)");
}
if (!max_value.is_empty()) {
property_generator.set("maxvalue", max_value);
- property_generator.append(" && (style_value.as_number() <= (float)@maxvalue@)");
+ property_generator.append(" && (style_value.to_number() <= (float)@maxvalue@)");
}
property_generator.append(R"~~~()
return true;