mirror of
https://github.com/RGBCube/serenity
synced 2025-05-29 04:15:12 +00:00
LibHTML: Flesh out the code to dump a StyleSheet object graph.
This commit is contained in:
parent
048705e1c2
commit
6469d7f043
3 changed files with 42 additions and 1 deletions
|
@ -70,4 +70,33 @@ void dump_tree(const LayoutNode& layout_node)
|
|||
void dump_sheet(const StyleSheet& sheet)
|
||||
{
|
||||
printf("StyleSheet{%p}: %d rule(s)\n", &sheet, sheet.rules().size());
|
||||
|
||||
for (auto& rule : sheet.rules()) {
|
||||
printf("Rule:\n");
|
||||
for (auto& selector : rule->selectors()) {
|
||||
printf(" Selector:\n");
|
||||
for (auto& component : selector.components()) {
|
||||
const char* type_description = "Unknown";
|
||||
switch (component.type) {
|
||||
case Selector::Component::Type::Invalid:
|
||||
type_description = "Invalid";
|
||||
break;
|
||||
case Selector::Component::Type::Id:
|
||||
type_description = "Id";
|
||||
break;
|
||||
case Selector::Component::Type::Class:
|
||||
type_description = "Class";
|
||||
break;
|
||||
case Selector::Component::Type::TagName:
|
||||
type_description = "TagName";
|
||||
break;
|
||||
}
|
||||
printf(" %s:%s", type_description, component.value.characters());
|
||||
}
|
||||
}
|
||||
printf(" Declarations:\n");
|
||||
rule->for_each_declaration([](auto& declaration) {
|
||||
printf(" '%s': '%s'\n", declaration.property_name().characters(), declaration.value().to_string().characters());
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue