diff --git a/Libraries/LibWeb/CSS/CSSFontFaceRule.h b/Libraries/LibWeb/CSS/CSSFontFaceRule.h index 69c9308f6df..fdaf985a71c 100644 --- a/Libraries/LibWeb/CSS/CSSFontFaceRule.h +++ b/Libraries/LibWeb/CSS/CSSFontFaceRule.h @@ -24,7 +24,8 @@ public: bool is_valid() const; ParsedFontFace font_face() const; - CSSStyleDeclaration* style() { return m_style; } + GC::Ref style() { return m_style; } + GC::Ref descriptors() const { return m_style; } private: CSSFontFaceRule(JS::Realm&, GC::Ref); diff --git a/Libraries/LibWeb/Dump.cpp b/Libraries/LibWeb/Dump.cpp index d1e3b74af4d..87202e90a32 100644 --- a/Libraries/LibWeb/Dump.cpp +++ b/Libraries/LibWeb/Dump.cpp @@ -9,11 +9,13 @@ #include #include #include +#include #include #include #include #include #include +#include #include #include #include @@ -24,7 +26,6 @@ #include #include #include -#include #include #include #include @@ -704,93 +705,9 @@ void dump_rule(StringBuilder& builder, CSS::CSSRule const& rule, int indent_leve void dump_font_face_rule(StringBuilder& builder, CSS::CSSFontFaceRule const& rule, int indent_levels) { - auto const font_face = rule.font_face(); indent(builder, indent_levels + 1); builder.appendff("VALID: {}\n", rule.is_valid()); - - indent(builder, indent_levels + 1); - builder.appendff("font-family: {}\n", font_face.font_family()); - - if (font_face.weight().has_value()) { - indent(builder, indent_levels + 1); - builder.appendff("weight: {}\n", font_face.weight().value()); - } - - if (font_face.slope().has_value()) { - indent(builder, indent_levels + 1); - builder.appendff("slope: {}\n", font_face.slope().value()); - } - - if (font_face.width().has_value()) { - indent(builder, indent_levels + 1); - builder.appendff("width: {}\n", font_face.width().value()); - } - - indent(builder, indent_levels + 1); - builder.append("sources:\n"sv); - for (auto const& [local_or_url, format] : font_face.sources()) { - indent(builder, indent_levels + 2); - local_or_url.visit( - [&builder, &format](CSS::URL const& url) { - builder.appendff("url={}, format={}\n", url, format.value_or("???"_string)); - }, - [&builder](FlyString const& local) { - builder.appendff("local={}\n", local); - }); - } - - indent(builder, indent_levels + 1); - builder.append("unicode-ranges:\n"sv); - for (auto const& unicode_range : font_face.unicode_ranges()) { - indent(builder, indent_levels + 2); - builder.appendff("{}\n", unicode_range.to_string()); - } - - if (font_face.ascent_override().has_value()) { - indent(builder, indent_levels + 1); - builder.appendff("ascent-override: {}\n", font_face.ascent_override().value()); - } - if (font_face.descent_override().has_value()) { - indent(builder, indent_levels + 1); - builder.appendff("descent-override: {}\n", font_face.descent_override().value()); - } - if (font_face.line_gap_override().has_value()) { - indent(builder, indent_levels + 1); - builder.appendff("line-gap-override: {}\n", font_face.line_gap_override().value()); - } - - indent(builder, indent_levels + 1); - builder.appendff("display: {}\n", CSS::to_string(font_face.font_display())); - - if (font_face.font_named_instance().has_value()) { - indent(builder, indent_levels + 1); - builder.appendff("named-instance: {}\n", font_face.font_named_instance().value()); - } - - if (font_face.font_language_override().has_value()) { - indent(builder, indent_levels + 1); - builder.appendff("language-override: {}\n", font_face.font_language_override().value()); - } - - if (font_face.font_feature_settings().has_value()) { - indent(builder, indent_levels + 1); - builder.append("feature-settings:"sv); - auto const& entries = font_face.font_feature_settings().value(); - for (auto const& [name, value] : entries) { - builder.appendff(" {}={}", name, value); - } - builder.append("\n"sv); - } - - if (font_face.font_variation_settings().has_value()) { - indent(builder, indent_levels + 1); - builder.append("variation-settings:"sv); - auto const& entries = font_face.font_variation_settings().value(); - for (auto const& [name, value] : entries) { - builder.appendff(" {}={}", name, value); - } - builder.append("\n"sv); - } + dump_descriptors(builder, rule.descriptors(), indent_levels + 1); } void dump_import_rule(StringBuilder& builder, CSS::CSSImportRule const& rule, int indent_levels) @@ -876,6 +793,17 @@ void dump_style_properties(StringBuilder& builder, CSS::CSSStyleProperties const } } +void dump_descriptors(StringBuilder& builder, CSS::CSSDescriptors const& descriptors, int indent_levels) +{ + indent(builder, indent_levels); + builder.appendff("Declarations ({}):\n", descriptors.length()); + for (auto const& descriptor : descriptors.descriptors()) { + indent(builder, indent_levels); + builder.appendff(" {}: '{}'", CSS::to_string(descriptor.descriptor_id), descriptor.value->to_string(CSS::CSSStyleValue::SerializationMode::Normal)); + builder.append('\n'); + } +} + void dump_style_rule(StringBuilder& builder, CSS::CSSStyleRule const& rule, int indent_levels) { for (auto& selector : rule.selectors()) { diff --git a/Libraries/LibWeb/Dump.h b/Libraries/LibWeb/Dump.h index 9fd7746f888..5ed7b9edcb8 100644 --- a/Libraries/LibWeb/Dump.h +++ b/Libraries/LibWeb/Dump.h @@ -8,7 +8,6 @@ #pragma once #include -#include #include namespace Web { @@ -25,6 +24,7 @@ void dump_sheet(CSS::StyleSheet const&); void dump_rule(StringBuilder&, CSS::CSSRule const&, int indent_levels = 0); void dump_rule(CSS::CSSRule const&); void dump_style_properties(StringBuilder&, CSS::CSSStyleProperties const&, int indent_levels = 0); +void dump_descriptors(StringBuilder&, CSS::CSSDescriptors const&, int indent_levels = 0); void dump_font_face_rule(StringBuilder&, CSS::CSSFontFaceRule const&, int indent_levels = 0); void dump_import_rule(StringBuilder&, CSS::CSSImportRule const&, int indent_levels = 0); void dump_media_rule(StringBuilder&, CSS::CSSMediaRule const&, int indent_levels = 0);