mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-12-07 21:59:54 +00:00
LibWeb: Move CSSRule dumping code into CSSRule classes
Having the dumping code in a separate Dump.cpp meant that it was often overlooked when the rules gained new features, and also limits dumping to publicly-accessible information.
This commit is contained in:
parent
285892b5dd
commit
180cd4b799
Notes:
github-actions[bot]
2025-12-04 16:25:53 +00:00
Author: https://github.com/AtkinsSJ
Commit: 180cd4b799
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/7018
32 changed files with 211 additions and 204 deletions
|
|
@ -11,6 +11,7 @@
|
|||
#include <LibWeb/Bindings/Intrinsics.h>
|
||||
#include <LibWeb/CSS/CSSFontFaceRule.h>
|
||||
#include <LibWeb/CSS/Serialize.h>
|
||||
#include <LibWeb/Dump.h>
|
||||
#include <LibWeb/WebIDL/ExceptionOr.h>
|
||||
|
||||
namespace Web::CSS {
|
||||
|
|
@ -146,4 +147,13 @@ void CSSFontFaceRule::visit_edges(Visitor& visitor)
|
|||
visitor.visit(m_style);
|
||||
}
|
||||
|
||||
void CSSFontFaceRule::dump(StringBuilder& builder, int indent_levels) const
|
||||
{
|
||||
Base::dump(builder, indent_levels);
|
||||
|
||||
dump_indent(builder, indent_levels + 1);
|
||||
builder.appendff("Valid: {}\n", is_valid());
|
||||
dump_descriptors(builder, descriptors(), indent_levels + 1);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -33,6 +33,7 @@ private:
|
|||
virtual void initialize(JS::Realm&) override;
|
||||
virtual String serialized() const override;
|
||||
virtual void visit_edges(Visitor&) override;
|
||||
virtual void dump(StringBuilder&, int indent_levels) const override;
|
||||
|
||||
GC::Ref<CSSFontFaceDescriptors> m_style;
|
||||
};
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
* Copyright (c) 2021, the SerenityOS developers.
|
||||
* Copyright (c) 2021-2024, Sam Atkins <sam@ladybird.org>
|
||||
* Copyright (c) 2021-2025, Sam Atkins <sam@ladybird.org>
|
||||
* Copyright (c) 2022-2024, Andreas Kling <andreas@ladybird.org>
|
||||
* Copyright (c) 2025, Lorenz Ackermann <me@lorenzackermann.xyz>
|
||||
*
|
||||
|
|
@ -18,6 +18,7 @@
|
|||
#include <LibWeb/CSS/StyleComputer.h>
|
||||
#include <LibWeb/DOM/Document.h>
|
||||
#include <LibWeb/DOMURL/DOMURL.h>
|
||||
#include <LibWeb/Dump.h>
|
||||
#include <LibWeb/Fetch/Infrastructure/HTTP/MIME.h>
|
||||
#include <LibWeb/Fetch/Infrastructure/HTTP/Responses.h>
|
||||
#include <LibWeb/HTML/Window.h>
|
||||
|
|
@ -213,4 +214,12 @@ Optional<String> CSSImportRule::supports_text() const
|
|||
return m_supports->to_string();
|
||||
}
|
||||
|
||||
void CSSImportRule::dump(StringBuilder& builder, int indent_levels) const
|
||||
{
|
||||
Base::dump(builder, indent_levels);
|
||||
|
||||
dump_indent(builder, indent_levels + 1);
|
||||
builder.appendff("Document URL: {}\n", url().to_string());
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -42,6 +42,7 @@ private:
|
|||
|
||||
virtual void initialize(JS::Realm&) override;
|
||||
virtual void visit_edges(Cell::Visitor&) override;
|
||||
virtual void dump(StringBuilder&, int indent_levels) const override;
|
||||
|
||||
virtual void set_parent_style_sheet(CSSStyleSheet*) override;
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
/*
|
||||
* Copyright (c) 2023, Ali Mohammad Pur <mpfard@serenityos.org>
|
||||
* Copyright (c) 2025, Sam Atkins <sam@ladybird.org>
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
|
@ -8,6 +9,7 @@
|
|||
#include <LibWeb/Bindings/CSSKeyframeRulePrototype.h>
|
||||
#include <LibWeb/Bindings/Intrinsics.h>
|
||||
#include <LibWeb/CSS/CSSRuleList.h>
|
||||
#include <LibWeb/Dump.h>
|
||||
|
||||
namespace Web::CSS {
|
||||
|
||||
|
|
@ -45,4 +47,13 @@ String CSSKeyframeRule::serialized() const
|
|||
return MUST(builder.to_string());
|
||||
}
|
||||
|
||||
void CSSKeyframeRule::dump(StringBuilder& builder, int indent_levels) const
|
||||
{
|
||||
Base::dump(builder, indent_levels);
|
||||
|
||||
dump_indent(builder, indent_levels + 1);
|
||||
builder.appendff("Key: {}\n"sv, key_text());
|
||||
dump_style_properties(builder, style(), indent_levels + 1);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -44,6 +44,7 @@ private:
|
|||
virtual void visit_edges(Visitor&) override;
|
||||
virtual void initialize(JS::Realm&) override;
|
||||
virtual String serialized() const override;
|
||||
virtual void dump(StringBuilder&, int indent_levels) const override;
|
||||
|
||||
CSS::Percentage m_key;
|
||||
GC::Ref<CSSStyleProperties> m_declarations;
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
/*
|
||||
* Copyright (c) 2023, Ali Mohammad Pur <mpfard@serenityos.org>
|
||||
* Copyright (c) 2024, Andreas Kling <andreas@ladybird.org>
|
||||
* Copyright (c) 2025, Sam Atkins <sam@ladybird.org>
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
|
@ -9,6 +10,7 @@
|
|||
#include <LibWeb/Bindings/Intrinsics.h>
|
||||
#include <LibWeb/CSS/CSSKeyframesRule.h>
|
||||
#include <LibWeb/CSS/CSSRuleList.h>
|
||||
#include <LibWeb/Dump.h>
|
||||
|
||||
namespace Web::CSS {
|
||||
|
||||
|
|
@ -58,4 +60,16 @@ WebIDL::UnsignedLong CSSKeyframesRule::length() const
|
|||
return m_rules->length();
|
||||
}
|
||||
|
||||
void CSSKeyframesRule::dump(StringBuilder& builder, int indent_levels) const
|
||||
{
|
||||
Base::dump(builder, indent_levels);
|
||||
|
||||
dump_indent(builder, indent_levels + 1);
|
||||
builder.appendff("Name: {}\n", name());
|
||||
dump_indent(builder, indent_levels + 1);
|
||||
builder.appendff("Keyframes ({}):\n", length());
|
||||
for (auto& rule : *css_rules())
|
||||
dump_rule(builder, rule, indent_levels + 2);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -40,6 +40,7 @@ private:
|
|||
|
||||
virtual void initialize(JS::Realm&) override;
|
||||
virtual String serialized() const override;
|
||||
virtual void dump(StringBuilder&, int indent_levels) const override;
|
||||
|
||||
FlyString m_name;
|
||||
GC::Ref<CSSRuleList> m_rules;
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 2024, Sam Atkins <sam@ladybird.org>
|
||||
* Copyright (c) 2024-2025, Sam Atkins <sam@ladybird.org>
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
|
@ -8,6 +8,7 @@
|
|||
#include <LibWeb/Bindings/CSSLayerBlockRulePrototype.h>
|
||||
#include <LibWeb/Bindings/Intrinsics.h>
|
||||
#include <LibWeb/CSS/Serialize.h>
|
||||
#include <LibWeb/Dump.h>
|
||||
|
||||
namespace Web::CSS {
|
||||
|
||||
|
|
@ -77,4 +78,16 @@ FlyString CSSLayerBlockRule::internal_qualified_name(Badge<StyleScope>) const
|
|||
return MUST(String::formatted("{}.{}", parent_name, m_name_internal));
|
||||
}
|
||||
|
||||
void CSSLayerBlockRule::dump(StringBuilder& builder, int indent_levels) const
|
||||
{
|
||||
Base::dump(builder, indent_levels);
|
||||
|
||||
dump_indent(builder, indent_levels + 1);
|
||||
builder.appendff("Name: `{}` (internal `{}`)\n", m_name, m_name_internal);
|
||||
dump_indent(builder, indent_levels + 1);
|
||||
builder.appendff("Rules ({}):\n", css_rules().length());
|
||||
for (auto& rule : css_rules())
|
||||
dump_rule(builder, rule, indent_levels + 2);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -31,6 +31,7 @@ private:
|
|||
|
||||
virtual void initialize(JS::Realm&) override;
|
||||
virtual String serialized() const override;
|
||||
virtual void dump(StringBuilder&, int indent_levels) const override;
|
||||
|
||||
FlyString m_name;
|
||||
FlyString m_name_internal;
|
||||
|
|
|
|||
|
|
@ -8,6 +8,7 @@
|
|||
#include <LibWeb/Bindings/CSSLayerStatementRulePrototype.h>
|
||||
#include <LibWeb/Bindings/Intrinsics.h>
|
||||
#include <LibWeb/CSS/CSSLayerBlockRule.h>
|
||||
#include <LibWeb/Dump.h>
|
||||
|
||||
namespace Web::CSS {
|
||||
|
||||
|
|
@ -54,4 +55,13 @@ Vector<FlyString> CSSLayerStatementRule::internal_qualified_name_list(Badge<Styl
|
|||
return qualified_layer_names;
|
||||
}
|
||||
|
||||
void CSSLayerStatementRule::dump(StringBuilder& builder, int indent_levels) const
|
||||
{
|
||||
Base::dump(builder, indent_levels);
|
||||
|
||||
dump_indent(builder, indent_levels + 1);
|
||||
builder.append("Names: "sv);
|
||||
builder.join(", "sv, name_list());
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -29,6 +29,7 @@ private:
|
|||
|
||||
virtual void initialize(JS::Realm&) override;
|
||||
virtual String serialized() const override;
|
||||
virtual void dump(StringBuilder&, int indent_levels) const override;
|
||||
|
||||
Vector<FlyString> m_name_list;
|
||||
};
|
||||
|
|
|
|||
|
|
@ -8,6 +8,7 @@
|
|||
#include <LibWeb/Bindings/Intrinsics.h>
|
||||
#include <LibWeb/CSS/CSSMarginRule.h>
|
||||
#include <LibWeb/CSS/CSSStyleProperties.h>
|
||||
#include <LibWeb/Dump.h>
|
||||
#include <LibWeb/WebIDL/ExceptionOr.h>
|
||||
|
||||
namespace Web::CSS {
|
||||
|
|
@ -53,6 +54,15 @@ void CSSMarginRule::visit_edges(Visitor& visitor)
|
|||
visitor.visit(m_style);
|
||||
}
|
||||
|
||||
void CSSMarginRule::dump(StringBuilder& builder, int indent_levels) const
|
||||
{
|
||||
Base::dump(builder, indent_levels);
|
||||
|
||||
dump_indent(builder, indent_levels + 1);
|
||||
builder.appendff("Name: {}\n", name());
|
||||
dump_style_properties(builder, style(), indent_levels + 1);
|
||||
}
|
||||
|
||||
// https://drafts.csswg.org/css-page-3/#syntax-page-selector
|
||||
bool is_margin_rule_name(StringView name)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -30,6 +30,7 @@ private:
|
|||
virtual void initialize(JS::Realm&) override;
|
||||
virtual String serialized() const override;
|
||||
virtual void visit_edges(Visitor&) override;
|
||||
virtual void dump(StringBuilder&, int indent_levels) const override;
|
||||
|
||||
FlyString m_name;
|
||||
GC::Ref<CSSStyleProperties> m_style;
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 2021, Sam Atkins <atkinssj@serenityos.org>
|
||||
* Copyright (c) 2021-2025, Sam Atkins <sam@ladybird.org>
|
||||
* Copyright (c) 2022, Andreas Kling <andreas@ladybird.org>
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
|
|
@ -9,6 +9,7 @@
|
|||
#include <LibWeb/Bindings/CSSMediaRulePrototype.h>
|
||||
#include <LibWeb/Bindings/Intrinsics.h>
|
||||
#include <LibWeb/CSS/CSSMediaRule.h>
|
||||
#include <LibWeb/Dump.h>
|
||||
|
||||
namespace Web::CSS {
|
||||
|
||||
|
|
@ -75,4 +76,16 @@ String CSSMediaRule::serialized() const
|
|||
return MUST(builder.to_string());
|
||||
}
|
||||
|
||||
void CSSMediaRule::dump(StringBuilder& builder, int indent_levels) const
|
||||
{
|
||||
Base::dump(builder, indent_levels);
|
||||
|
||||
dump_indent(builder, indent_levels + 1);
|
||||
builder.appendff("Media: {}\n", condition_text());
|
||||
dump_indent(builder, indent_levels + 1);
|
||||
builder.appendff("Rules ({}):\n", css_rules().length());
|
||||
for (auto& rule : css_rules())
|
||||
dump_rule(builder, rule, indent_levels + 2);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -38,6 +38,7 @@ private:
|
|||
virtual void initialize(JS::Realm&) override;
|
||||
virtual void visit_edges(Cell::Visitor&) override;
|
||||
virtual String serialized() const override;
|
||||
virtual void dump(StringBuilder&, int indent_levels) const override;
|
||||
|
||||
GC::Ref<MediaList> m_media;
|
||||
};
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
/*
|
||||
* Copyright (c) 2023, Jonah Shafran <jonahshafran@gmail.com>
|
||||
* Copyright (c) 2025, Sam Atkins <sam@ladybird.org>
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
|
@ -10,6 +11,7 @@
|
|||
#include <LibWeb/Bindings/Intrinsics.h>
|
||||
#include <LibWeb/CSS/CSSNamespaceRule.h>
|
||||
#include <LibWeb/CSS/Serialize.h>
|
||||
#include <LibWeb/Dump.h>
|
||||
#include <LibWeb/WebIDL/ExceptionOr.h>
|
||||
|
||||
namespace Web::CSS {
|
||||
|
|
@ -57,4 +59,16 @@ String CSSNamespaceRule::serialized() const
|
|||
return MUST(builder.to_string());
|
||||
}
|
||||
|
||||
void CSSNamespaceRule::dump(StringBuilder& builder, int indent_levels) const
|
||||
{
|
||||
Base::dump(builder, indent_levels);
|
||||
|
||||
dump_indent(builder, indent_levels + 1);
|
||||
builder.appendff("Namespace: {}\n", namespace_uri());
|
||||
if (!prefix().is_empty()) {
|
||||
dump_indent(builder, indent_levels + 1);
|
||||
builder.appendff("Prefix: {}\n", prefix());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -28,8 +28,9 @@ private:
|
|||
CSSNamespaceRule(JS::Realm&, Optional<FlyString> prefix, FlyString namespace_uri);
|
||||
|
||||
virtual void initialize(JS::Realm&) override;
|
||||
|
||||
virtual String serialized() const override;
|
||||
virtual void dump(StringBuilder&, int indent_levels) const override;
|
||||
|
||||
FlyString m_namespace_uri;
|
||||
FlyString m_prefix;
|
||||
};
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 2024, Sam Atkins <sam@ladybird.org>
|
||||
* Copyright (c) 2024-2025, Sam Atkins <sam@ladybird.org>
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
|
@ -8,6 +8,7 @@
|
|||
#include <LibWeb/Bindings/CSSNestedDeclarationsPrototype.h>
|
||||
#include <LibWeb/Bindings/Intrinsics.h>
|
||||
#include <LibWeb/CSS/CSSStyleRule.h>
|
||||
#include <LibWeb/Dump.h>
|
||||
|
||||
namespace Web::CSS {
|
||||
|
||||
|
|
@ -74,4 +75,11 @@ void CSSNestedDeclarations::clear_caches()
|
|||
m_parent_style_rule = nullptr;
|
||||
}
|
||||
|
||||
void CSSNestedDeclarations::dump(StringBuilder& builder, int indent_levels) const
|
||||
{
|
||||
Base::dump(builder, indent_levels);
|
||||
|
||||
dump_style_properties(builder, declaration(), indent_levels + 1);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -33,6 +33,7 @@ private:
|
|||
virtual void visit_edges(Cell::Visitor&) override;
|
||||
virtual String serialized() const override;
|
||||
virtual void clear_caches() override;
|
||||
virtual void dump(StringBuilder&, int indent_levels) const override;
|
||||
|
||||
GC::Ref<CSSStyleProperties> m_declaration;
|
||||
GC::Ptr<CSSStyleRule const> mutable m_parent_style_rule;
|
||||
|
|
|
|||
|
|
@ -7,9 +7,9 @@
|
|||
#include <LibWeb/Bindings/CSSPageRulePrototype.h>
|
||||
#include <LibWeb/Bindings/Intrinsics.h>
|
||||
#include <LibWeb/CSS/CSSPageRule.h>
|
||||
#include <LibWeb/CSS/DescriptorID.h>
|
||||
#include <LibWeb/CSS/Parser/Parser.h>
|
||||
#include <LibWeb/CSS/Serialize.h>
|
||||
#include <LibWeb/Dump.h>
|
||||
#include <LibWeb/WebIDL/ExceptionOr.h>
|
||||
|
||||
namespace Web::CSS {
|
||||
|
|
@ -95,4 +95,18 @@ void CSSPageRule::visit_edges(Visitor& visitor)
|
|||
visitor.visit(m_style);
|
||||
}
|
||||
|
||||
void CSSPageRule::dump(StringBuilder& builder, int indent_levels) const
|
||||
{
|
||||
Base::dump(builder, indent_levels);
|
||||
|
||||
dump_indent(builder, indent_levels + 1);
|
||||
builder.appendff("Selector: {}\n", selector_text());
|
||||
dump_descriptors(builder, descriptors(), indent_levels + 1);
|
||||
|
||||
dump_indent(builder, indent_levels + 1);
|
||||
builder.appendff("Rules ({}):\n", css_rules().length());
|
||||
for (auto& rule : css_rules())
|
||||
dump_rule(builder, rule, indent_levels + 2);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -34,6 +34,7 @@ private:
|
|||
virtual void initialize(JS::Realm&) override;
|
||||
virtual String serialized() const override;
|
||||
virtual void visit_edges(Visitor&) override;
|
||||
virtual void dump(StringBuilder&, int indent_levels) const override;
|
||||
|
||||
PageSelectorList m_selectors;
|
||||
GC::Ref<CSSPageDescriptors> m_style;
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
/*
|
||||
* Copyright (c) 2024, Alex Ungurianu <alex@ungurianu.com>
|
||||
* Copyright (c) 2025, Sam Atkins <sam@ladybird.org>
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
|
@ -8,6 +9,7 @@
|
|||
#include <LibWeb/Bindings/Intrinsics.h>
|
||||
#include <LibWeb/CSS/CSSPropertyRule.h>
|
||||
#include <LibWeb/CSS/Serialize.h>
|
||||
#include <LibWeb/Dump.h>
|
||||
|
||||
namespace Web::CSS {
|
||||
|
||||
|
|
@ -80,4 +82,23 @@ String CSSPropertyRule::serialized() const
|
|||
return MUST(builder.to_string());
|
||||
}
|
||||
|
||||
void CSSPropertyRule::dump(StringBuilder& builder, int indent_levels) const
|
||||
{
|
||||
Base::dump(builder, indent_levels);
|
||||
|
||||
dump_indent(builder, indent_levels + 1);
|
||||
builder.appendff("Name: {}\n", name());
|
||||
|
||||
dump_indent(builder, indent_levels + 1);
|
||||
builder.appendff("Syntax: {}\n", syntax());
|
||||
|
||||
dump_indent(builder, indent_levels + 1);
|
||||
builder.appendff("Inherits: {}\n", inherits());
|
||||
|
||||
if (initial_value().has_value()) {
|
||||
dump_indent(builder, indent_levels + 1);
|
||||
builder.appendff("Initial value: {}\n", initial_value().value());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -36,6 +36,7 @@ private:
|
|||
|
||||
virtual void initialize(JS::Realm&) override;
|
||||
virtual String serialized() const override;
|
||||
virtual void dump(StringBuilder&, int indent_levels) const override;
|
||||
|
||||
FlyString m_name;
|
||||
FlyString m_syntax;
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
* Copyright (c) 2021, the SerenityOS developers.
|
||||
* Copyright (c) 2022-2024, Sam Atkins <sam@ladybird.org>
|
||||
* Copyright (c) 2022-2025, Sam Atkins <sam@ladybird.org>
|
||||
* Copyright (c) 2022, Andreas Kling <andreas@ladybird.org>
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
|
|
@ -10,6 +10,7 @@
|
|||
#include <LibWeb/CSS/CSSLayerBlockRule.h>
|
||||
#include <LibWeb/CSS/CSSRule.h>
|
||||
#include <LibWeb/CSS/CSSStyleSheet.h>
|
||||
#include <LibWeb/Dump.h>
|
||||
|
||||
namespace Web::CSS {
|
||||
|
||||
|
|
@ -67,6 +68,12 @@ void CSSRule::set_parent_style_sheet(CSSStyleSheet* parent_style_sheet)
|
|||
clear_caches();
|
||||
}
|
||||
|
||||
void CSSRule::dump(StringBuilder& builder, int indent_levels) const
|
||||
{
|
||||
dump_indent(builder, indent_levels);
|
||||
builder.appendff("{}:\n", class_name());
|
||||
}
|
||||
|
||||
void CSSRule::clear_caches()
|
||||
{
|
||||
m_cached_layer_name.clear();
|
||||
|
|
|
|||
|
|
@ -61,6 +61,8 @@ public:
|
|||
// https://drafts.csswg.org/cssom-1/#serialize-a-css-rule
|
||||
virtual String serialized() const = 0;
|
||||
|
||||
virtual void dump(StringBuilder&, int indent_levels = 0) const;
|
||||
|
||||
virtual void clear_caches();
|
||||
|
||||
protected:
|
||||
|
|
|
|||
|
|
@ -13,6 +13,7 @@
|
|||
#include <LibWeb/CSS/Parser/Parser.h>
|
||||
#include <LibWeb/CSS/StyleComputer.h>
|
||||
#include <LibWeb/CSS/StylePropertyMap.h>
|
||||
#include <LibWeb/Dump.h>
|
||||
|
||||
namespace Web::CSS {
|
||||
|
||||
|
|
@ -239,4 +240,19 @@ CSSStyleRule const* CSSStyleRule::parent_style_rule() const
|
|||
return nullptr;
|
||||
}
|
||||
|
||||
void CSSStyleRule::dump(StringBuilder& builder, int indent_levels) const
|
||||
{
|
||||
Base::dump(builder, indent_levels);
|
||||
|
||||
for (auto& selector : selectors()) {
|
||||
dump_selector(builder, selector, indent_levels + 1);
|
||||
}
|
||||
dump_style_properties(builder, declaration(), indent_levels + 1);
|
||||
|
||||
dump_indent(builder, indent_levels + 1);
|
||||
builder.appendff("Child rules ({}):\n", css_rules().length());
|
||||
for (auto& child_rule : css_rules())
|
||||
dump_rule(builder, child_rule, indent_levels + 2);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -42,6 +42,7 @@ private:
|
|||
virtual void visit_edges(Cell::Visitor&) override;
|
||||
virtual void clear_caches() override;
|
||||
virtual String serialized() const override;
|
||||
virtual void dump(StringBuilder&, int indent_levels) const override;
|
||||
|
||||
virtual void set_parent_style_sheet(CSSStyleSheet*) override;
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 2021-2023, Sam Atkins <atkinssj@serenityos.org>
|
||||
* Copyright (c) 2021-2025, Sam Atkins <sam@ladybird.org>
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
|
@ -8,6 +8,7 @@
|
|||
#include <LibWeb/Bindings/Intrinsics.h>
|
||||
#include <LibWeb/CSS/CSSSupportsRule.h>
|
||||
#include <LibWeb/CSS/Parser/Parser.h>
|
||||
#include <LibWeb/Dump.h>
|
||||
|
||||
namespace Web::CSS {
|
||||
|
||||
|
|
@ -58,4 +59,18 @@ String CSSSupportsRule::serialized() const
|
|||
return MUST(builder.to_string());
|
||||
}
|
||||
|
||||
void CSSSupportsRule::dump(StringBuilder& builder, int indent_levels) const
|
||||
{
|
||||
Base::dump(builder, indent_levels);
|
||||
|
||||
dump_indent(builder, indent_levels + 1);
|
||||
builder.append("Supports:\n"sv);
|
||||
supports().dump(builder, indent_levels + 2);
|
||||
|
||||
dump_indent(builder, indent_levels + 1);
|
||||
builder.appendff("Rules ({}):\n", css_rules().length());
|
||||
for (auto& rule : css_rules())
|
||||
dump_rule(builder, rule, indent_levels + 2);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 2021-2022, Sam Atkins <atkinssj@serenityos.org>
|
||||
* Copyright (c) 2021-2025, Sam Atkins <sam@ladybird.org>
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
|
@ -36,6 +36,7 @@ private:
|
|||
|
||||
virtual void initialize(JS::Realm&) override;
|
||||
virtual String serialized() const override;
|
||||
virtual void dump(StringBuilder&, int indent_levels) const override;
|
||||
|
||||
NonnullRefPtr<Supports> m_supports;
|
||||
};
|
||||
|
|
|
|||
|
|
@ -661,159 +661,7 @@ void dump_rule(CSS::CSSRule const& rule)
|
|||
|
||||
void dump_rule(StringBuilder& builder, CSS::CSSRule const& rule, int indent_levels)
|
||||
{
|
||||
dump_indent(builder, indent_levels);
|
||||
builder.appendff("{}:\n", rule.class_name());
|
||||
|
||||
switch (rule.type()) {
|
||||
case CSS::CSSRule::Type::FontFace:
|
||||
dump_font_face_rule(builder, as<CSS::CSSFontFaceRule const>(rule), indent_levels);
|
||||
break;
|
||||
case CSS::CSSRule::Type::Import:
|
||||
dump_import_rule(builder, as<CSS::CSSImportRule const>(rule), indent_levels);
|
||||
break;
|
||||
case CSS::CSSRule::Type::Keyframe:
|
||||
dump_keyframe_rule(builder, as<CSS::CSSKeyframeRule const>(rule), indent_levels);
|
||||
break;
|
||||
case CSS::CSSRule::Type::Keyframes:
|
||||
dump_keyframes_rule(builder, as<CSS::CSSKeyframesRule const>(rule), indent_levels);
|
||||
break;
|
||||
case CSS::CSSRule::Type::LayerBlock:
|
||||
dump_layer_block_rule(builder, as<CSS::CSSLayerBlockRule const>(rule), indent_levels);
|
||||
break;
|
||||
case CSS::CSSRule::Type::LayerStatement:
|
||||
dump_layer_statement_rule(builder, as<CSS::CSSLayerStatementRule const>(rule), indent_levels);
|
||||
break;
|
||||
case CSS::CSSRule::Type::Margin:
|
||||
dump_margin_rule(builder, as<CSS::CSSMarginRule const>(rule), indent_levels);
|
||||
break;
|
||||
case CSS::CSSRule::Type::Media:
|
||||
dump_media_rule(builder, as<CSS::CSSMediaRule const>(rule), indent_levels);
|
||||
break;
|
||||
case CSS::CSSRule::Type::Namespace:
|
||||
dump_namespace_rule(builder, as<CSS::CSSNamespaceRule const>(rule), indent_levels);
|
||||
break;
|
||||
case CSS::CSSRule::Type::NestedDeclarations:
|
||||
dump_nested_declarations(builder, as<CSS::CSSNestedDeclarations const>(rule), indent_levels);
|
||||
break;
|
||||
case CSS::CSSRule::Type::Page:
|
||||
dump_page_rule(builder, as<CSS::CSSPageRule const>(rule), indent_levels);
|
||||
break;
|
||||
case CSS::CSSRule::Type::Property:
|
||||
dump_property_rule(builder, as<CSS::CSSPropertyRule const>(rule), indent_levels);
|
||||
break;
|
||||
case CSS::CSSRule::Type::Style:
|
||||
dump_style_rule(builder, as<CSS::CSSStyleRule const>(rule), indent_levels);
|
||||
break;
|
||||
case CSS::CSSRule::Type::Supports:
|
||||
dump_supports_rule(builder, as<CSS::CSSSupportsRule const>(rule), indent_levels);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void dump_font_face_rule(StringBuilder& builder, CSS::CSSFontFaceRule const& rule, int indent_levels)
|
||||
{
|
||||
dump_indent(builder, indent_levels + 1);
|
||||
builder.appendff("VALID: {}\n", rule.is_valid());
|
||||
dump_descriptors(builder, rule.descriptors(), indent_levels + 1);
|
||||
}
|
||||
|
||||
void dump_import_rule(StringBuilder& builder, CSS::CSSImportRule const& rule, int indent_levels)
|
||||
{
|
||||
dump_indent(builder, indent_levels);
|
||||
builder.appendff(" Document URL: {}\n", rule.url().to_string());
|
||||
}
|
||||
|
||||
void dump_keyframe_rule(StringBuilder& builder, CSS::CSSKeyframeRule const& keyframe, int indent_levels)
|
||||
{
|
||||
dump_indent(builder, indent_levels + 1);
|
||||
builder.appendff("Key: {}\n"sv, keyframe.key_text());
|
||||
dump_style_properties(builder, keyframe.style(), indent_levels + 1);
|
||||
}
|
||||
|
||||
void dump_keyframes_rule(StringBuilder& builder, CSS::CSSKeyframesRule const& keyframes, int indent_levels)
|
||||
{
|
||||
dump_indent(builder, indent_levels + 1);
|
||||
builder.appendff("Name: {}\n", keyframes.name());
|
||||
dump_indent(builder, indent_levels + 1);
|
||||
builder.appendff("Keyframes ({}):\n", keyframes.length());
|
||||
for (auto& rule : *keyframes.css_rules())
|
||||
dump_rule(builder, rule, indent_levels + 2);
|
||||
}
|
||||
|
||||
void dump_layer_block_rule(StringBuilder& builder, CSS::CSSLayerBlockRule const& layer_block, int indent_levels)
|
||||
{
|
||||
dump_indent(builder, indent_levels);
|
||||
builder.appendff(" Layer Block: `{}`\n", layer_block.internal_name());
|
||||
dump_indent(builder, indent_levels);
|
||||
builder.appendff(" Rules ({}):\n", layer_block.css_rules().length());
|
||||
for (auto& rule : layer_block.css_rules())
|
||||
dump_rule(builder, rule, indent_levels + 2);
|
||||
}
|
||||
|
||||
void dump_layer_statement_rule(StringBuilder& builder, CSS::CSSLayerStatementRule const& layer_statement, int indent_levels)
|
||||
{
|
||||
dump_indent(builder, indent_levels);
|
||||
builder.append(" Layer Statement: "sv);
|
||||
builder.join(", "sv, layer_statement.name_list());
|
||||
}
|
||||
|
||||
void dump_media_rule(StringBuilder& builder, CSS::CSSMediaRule const& media, int indent_levels)
|
||||
{
|
||||
dump_indent(builder, indent_levels);
|
||||
builder.appendff(" Media: {}\n", media.condition_text());
|
||||
dump_indent(builder, indent_levels);
|
||||
builder.appendff(" Rules ({}):\n", media.css_rules().length());
|
||||
|
||||
for (auto& rule : media.css_rules())
|
||||
dump_rule(builder, rule, indent_levels + 2);
|
||||
}
|
||||
|
||||
void dump_page_rule(StringBuilder& builder, CSS::CSSPageRule const& page, int indent_levels)
|
||||
{
|
||||
dump_indent(builder, indent_levels + 1);
|
||||
builder.appendff("selector: {}\n", page.selector_text());
|
||||
dump_descriptors(builder, page.descriptors(), indent_levels + 1);
|
||||
|
||||
dump_indent(builder, indent_levels + 1);
|
||||
builder.appendff(" Rules ({}):\n", page.css_rules().length());
|
||||
for (auto& rule : page.css_rules())
|
||||
dump_rule(builder, rule, indent_levels + 2);
|
||||
}
|
||||
|
||||
void dump_margin_rule(StringBuilder& builder, CSS::CSSMarginRule const& margin, int indent_levels)
|
||||
{
|
||||
dump_indent(builder, indent_levels + 1);
|
||||
builder.appendff("name: {}\n", margin.name());
|
||||
dump_style_properties(builder, margin.style(), indent_levels + 1);
|
||||
}
|
||||
|
||||
void dump_supports_rule(StringBuilder& builder, CSS::CSSSupportsRule const& supports, int indent_levels)
|
||||
{
|
||||
dump_indent(builder, indent_levels);
|
||||
builder.append(" Supports:\n"sv);
|
||||
supports.supports().dump(builder, indent_levels + 2);
|
||||
dump_indent(builder, indent_levels);
|
||||
builder.appendff(" Rules ({}):\n", supports.css_rules().length());
|
||||
|
||||
for (auto& rule : supports.css_rules())
|
||||
dump_rule(builder, rule, indent_levels + 2);
|
||||
}
|
||||
|
||||
void dump_property_rule(StringBuilder& builder, CSS::CSSPropertyRule const& property, int indent_levels)
|
||||
{
|
||||
dump_indent(builder, indent_levels + 1);
|
||||
builder.appendff("name: {}\n", property.name());
|
||||
|
||||
dump_indent(builder, indent_levels + 1);
|
||||
builder.appendff("syntax: {}\n", property.syntax());
|
||||
|
||||
dump_indent(builder, indent_levels + 1);
|
||||
builder.appendff("inherits: {}\n", property.inherits());
|
||||
|
||||
if (property.initial_value().has_value()) {
|
||||
dump_indent(builder, indent_levels + 1);
|
||||
builder.appendff("initial-value: {}\n", property.initial_value().value());
|
||||
}
|
||||
rule.dump(builder, indent_levels);
|
||||
}
|
||||
|
||||
void dump_style_properties(StringBuilder& builder, CSS::CSSStyleProperties const& declaration, int indent_levels)
|
||||
|
|
@ -847,19 +695,6 @@ void dump_descriptors(StringBuilder& builder, CSS::CSSDescriptors const& descrip
|
|||
}
|
||||
}
|
||||
|
||||
void dump_style_rule(StringBuilder& builder, CSS::CSSStyleRule const& rule, int indent_levels)
|
||||
{
|
||||
for (auto& selector : rule.selectors()) {
|
||||
dump_selector(builder, selector, indent_levels + 1);
|
||||
}
|
||||
dump_style_properties(builder, rule.declaration(), indent_levels + 1);
|
||||
|
||||
dump_indent(builder, indent_levels);
|
||||
builder.appendff(" Child rules ({}):\n", rule.css_rules().length());
|
||||
for (auto& child_rule : rule.css_rules())
|
||||
dump_rule(builder, child_rule, indent_levels + 2);
|
||||
}
|
||||
|
||||
void dump_sheet(CSS::StyleSheet const& sheet)
|
||||
{
|
||||
StringBuilder builder;
|
||||
|
|
@ -929,19 +764,4 @@ void dump_tree(StringBuilder& builder, Painting::Paintable const& paintable, boo
|
|||
}
|
||||
}
|
||||
|
||||
void dump_namespace_rule(StringBuilder& builder, CSS::CSSNamespaceRule const& namespace_, int indent_levels)
|
||||
{
|
||||
dump_indent(builder, indent_levels);
|
||||
builder.appendff(" Namespace: {}\n", namespace_.namespace_uri());
|
||||
if (!namespace_.prefix().is_empty())
|
||||
builder.appendff(" Prefix: {}\n", namespace_.prefix());
|
||||
}
|
||||
|
||||
void dump_nested_declarations(StringBuilder& builder, CSS::CSSNestedDeclarations const& declarations, int indent_levels)
|
||||
{
|
||||
dump_indent(builder, indent_levels);
|
||||
builder.append(" Nested declarations:\n"sv);
|
||||
dump_style_properties(builder, declarations.declaration(), indent_levels + 1);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -27,20 +27,6 @@ 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_keyframe_rule(StringBuilder&, CSS::CSSKeyframeRule const&, int indent_levels = 0);
|
||||
void dump_keyframes_rule(StringBuilder&, CSS::CSSKeyframesRule const&, int indent_levels = 0);
|
||||
void dump_media_rule(StringBuilder&, CSS::CSSMediaRule const&, int indent_levels = 0);
|
||||
void dump_page_rule(StringBuilder&, CSS::CSSPageRule const&, int indent_levels = 0);
|
||||
void dump_margin_rule(StringBuilder&, CSS::CSSMarginRule const&, int indent_levels = 0);
|
||||
void dump_style_rule(StringBuilder&, CSS::CSSStyleRule const&, int indent_levels = 0);
|
||||
void dump_supports_rule(StringBuilder&, CSS::CSSSupportsRule const&, int indent_levels = 0);
|
||||
void dump_property_rule(StringBuilder&, CSS::CSSPropertyRule const&, int indent_levels = 0);
|
||||
void dump_namespace_rule(StringBuilder&, CSS::CSSNamespaceRule const&, int indent_levels = 0);
|
||||
void dump_nested_declarations(StringBuilder&, CSS::CSSNestedDeclarations const&, int indent_levels = 0);
|
||||
void dump_layer_block_rule(StringBuilder&, CSS::CSSLayerBlockRule const&, int indent_levels = 0);
|
||||
void dump_layer_statement_rule(StringBuilder&, CSS::CSSLayerStatementRule const&, int indent_levels = 0);
|
||||
void dump_selector(StringBuilder&, CSS::Selector const&, int indent_levels = 0);
|
||||
void dump_selector(CSS::Selector const&);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue