LibHTML: Start building a simple code generator for CSS properties

Code for parsing and stringifying CSS properties is now generated based
on LibHTML/CSS/Properties.json

At the moment, the file tells us three things:

- The name of a property
- Its initial value
- Whether it's inherited

Also, for shorthand properties, it provides a list of all the longhand
properties it may expand too. This is not actually used in the engine
yet though.

This *finally* makes layout tree dumps show the names of CSS properties
in effect, instead of "CSS::PropertyID(32)" and such. :^)
This commit is contained in:
Andreas Kling 2019-11-18 11:12:58 +01:00
parent dcd10149fe
commit e6e41e4fb8
Notes: sideshowbarker 2024-07-19 11:09:57 +09:00
10 changed files with 529 additions and 115 deletions

View file

@ -1,4 +1,5 @@
#include <AK/Utf8View.h>
#include <LibHTML/CSS/PropertyID.h>
#include <LibHTML/CSS/StyleSheet.h>
#include <LibHTML/DOM/Comment.h>
#include <LibHTML/DOM/Document.h>
@ -128,7 +129,7 @@ void dump_tree(const LayoutNode& layout_node)
layout_node.style().for_each_property([&](auto property_id, auto& value) {
for (int i = 0; i < indent; ++i)
dbgprintf(" ");
dbgprintf(" (CSS::PropertyID(%u): %s)\n", (unsigned)property_id, value.to_string().characters());
dbgprintf(" (%s: %s)\n", CSS::string_from_property_id(property_id), value.to_string().characters());
});
++indent;