summaryrefslogtreecommitdiff
path: root/Userland
diff options
context:
space:
mode:
Diffstat (limited to 'Userland')
-rw-r--r--Userland/Libraries/LibWeb/CodeGenerators/Generate_CSS_PropertyID_cpp.cpp32
-rw-r--r--Userland/Libraries/LibWeb/CodeGenerators/Generate_CSS_PropertyID_h.cpp2
2 files changed, 34 insertions, 0 deletions
diff --git a/Userland/Libraries/LibWeb/CodeGenerators/Generate_CSS_PropertyID_cpp.cpp b/Userland/Libraries/LibWeb/CodeGenerators/Generate_CSS_PropertyID_cpp.cpp
index 22937da989..9852fd57d9 100644
--- a/Userland/Libraries/LibWeb/CodeGenerators/Generate_CSS_PropertyID_cpp.cpp
+++ b/Userland/Libraries/LibWeb/CodeGenerators/Generate_CSS_PropertyID_cpp.cpp
@@ -45,7 +45,9 @@ int main(int argc, char** argv)
generator.append(R"~~~(
#include <AK/Assertions.h>
+#include <LibWeb/CSS/Parser/Parser.h>
#include <LibWeb/CSS/PropertyID.h>
+#include <LibWeb/CSS/StyleValue.h>
namespace Web::CSS {
@@ -153,6 +155,36 @@ bool is_pseudo_property(PropertyID property_id)
}
}
+RefPtr<StyleValue> property_initial_value(PropertyID property_id)
+{
+ static HashMap<PropertyID, NonnullRefPtr<StyleValue>> initial_values;
+ if (initial_values.is_empty()) {
+ ParsingContext parsing_context;
+)~~~");
+
+ json.value().as_object().for_each_member([&](auto& name, auto& value) {
+ VERIFY(value.is_object());
+
+ if (value.as_object().has("initial")) {
+ auto& initial_value = value.as_object().get("initial");
+ VERIFY(initial_value.is_string());
+ auto initial_value_string = initial_value.as_string();
+
+ auto member_generator = generator.fork();
+ member_generator.set("name:titlecase", title_casify(name));
+ member_generator.set("initial_value_string", initial_value_string);
+ member_generator.append(R"~~~(
+ if (auto parsed_value = Parser(parsing_context, "@initial_value_string@").parse_as_css_value(PropertyID::@name:titlecase@))
+ initial_values.set(PropertyID::@name:titlecase@, parsed_value.release_nonnull());
+)~~~");
+ }
+ });
+
+ generator.append(R"~~~(
+ }
+ return initial_values.get(property_id).value_or(nullptr);
+}
+
} // namespace Web::CSS
)~~~");
diff --git a/Userland/Libraries/LibWeb/CodeGenerators/Generate_CSS_PropertyID_h.cpp b/Userland/Libraries/LibWeb/CodeGenerators/Generate_CSS_PropertyID_h.cpp
index 89ad93c4d1..355d77b28f 100644
--- a/Userland/Libraries/LibWeb/CodeGenerators/Generate_CSS_PropertyID_h.cpp
+++ b/Userland/Libraries/LibWeb/CodeGenerators/Generate_CSS_PropertyID_h.cpp
@@ -47,6 +47,7 @@ int main(int argc, char** argv)
#include <AK/StringView.h>
#include <AK/Traits.h>
+#include <LibWeb/Forward.h>
namespace Web::CSS {
@@ -73,6 +74,7 @@ PropertyID property_id_from_string(const StringView&);
const char* string_from_property_id(PropertyID);
bool is_inherited_property(PropertyID);
bool is_pseudo_property(PropertyID);
+RefPtr<StyleValue> property_initial_value(PropertyID);
} // namespace Web::CSS