From 1d5d27aa228d82e539485ab16363f1bc768cc850 Mon Sep 17 00:00:00 2001 From: Sam Atkins Date: Tue, 30 Nov 2021 16:23:35 +0000 Subject: [PATCH] LibWeb: Include custom properties in CSS dump --- Userland/Libraries/LibWeb/CSS/CSSStyleDeclaration.h | 1 + Userland/Libraries/LibWeb/Dump.cpp | 10 +++++++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/Userland/Libraries/LibWeb/CSS/CSSStyleDeclaration.h b/Userland/Libraries/LibWeb/CSS/CSSStyleDeclaration.h index 7741e7fbb4..c0c0d153b0 100644 --- a/Userland/Libraries/LibWeb/CSS/CSSStyleDeclaration.h +++ b/Userland/Libraries/LibWeb/CSS/CSSStyleDeclaration.h @@ -65,6 +65,7 @@ public: virtual bool set_property(PropertyID, StringView css_text) override; const Vector& properties() const { return m_properties; } + const HashMap& custom_properties() const { return m_custom_properties; } Optional custom_property(const String& custom_property_name) const { return m_custom_properties.get(custom_property_name); } size_t custom_property_count() const { return m_custom_properties.size(); } diff --git a/Userland/Libraries/LibWeb/Dump.cpp b/Userland/Libraries/LibWeb/Dump.cpp index 0d8f2f6b7e..322095cd94 100644 --- a/Userland/Libraries/LibWeb/Dump.cpp +++ b/Userland/Libraries/LibWeb/Dump.cpp @@ -558,13 +558,21 @@ void dump_style_rule(StringBuilder& builder, CSS::CSSStyleRule const& rule, int } indent(builder, indent_levels); builder.append(" Declarations:\n"); - for (auto& property : verify_cast(rule.declaration()).properties()) { + auto& style_declaration = verify_cast(rule.declaration()); + for (auto& property : style_declaration.properties()) { indent(builder, indent_levels); builder.appendff(" {}: '{}'", CSS::string_from_property_id(property.property_id), property.value->to_string()); if (property.important) builder.append(" \033[31;1m!important\033[0m"); builder.append('\n'); } + for (auto& property : style_declaration.custom_properties()) { + indent(builder, indent_levels); + builder.appendff(" {}: '{}'", property.key, property.value.value->to_string()); + if (property.value.important) + builder.append(" \033[31;1m!important\033[0m"); + builder.append('\n'); + } } void dump_sheet(CSS::StyleSheet const& sheet)