mirror of
https://github.com/RGBCube/serenity
synced 2025-07-23 10:17:41 +00:00
LibWeb: Port CSSRule::serialized from DeprecatedString to String
This commit is contained in:
parent
890cce6fbb
commit
d400291ad9
18 changed files with 30 additions and 30 deletions
|
@ -38,7 +38,7 @@ CSSStyleDeclaration* CSSFontFaceRule::style()
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://www.w3.org/TR/cssom/#ref-for-cssfontfacerule
|
// https://www.w3.org/TR/cssom/#ref-for-cssfontfacerule
|
||||||
DeprecatedString CSSFontFaceRule::serialized() const
|
String CSSFontFaceRule::serialized() const
|
||||||
{
|
{
|
||||||
StringBuilder builder;
|
StringBuilder builder;
|
||||||
// The result of concatenating the following:
|
// The result of concatenating the following:
|
||||||
|
@ -137,7 +137,7 @@ DeprecatedString CSSFontFaceRule::serialized() const
|
||||||
// 12. A single SPACE (U+0020), followed by the string "}", i.e., RIGHT CURLY BRACKET (U+007D).
|
// 12. A single SPACE (U+0020), followed by the string "}", i.e., RIGHT CURLY BRACKET (U+007D).
|
||||||
builder.append(" }"sv);
|
builder.append(" }"sv);
|
||||||
|
|
||||||
return builder.to_deprecated_string();
|
return MUST(builder.to_string());
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -30,7 +30,7 @@ private:
|
||||||
CSSFontFaceRule(JS::Realm&, FontFace&&);
|
CSSFontFaceRule(JS::Realm&, FontFace&&);
|
||||||
|
|
||||||
virtual void initialize(JS::Realm&) override;
|
virtual void initialize(JS::Realm&) override;
|
||||||
virtual DeprecatedString serialized() const override;
|
virtual String serialized() const override;
|
||||||
|
|
||||||
FontFace m_font_face;
|
FontFace m_font_face;
|
||||||
};
|
};
|
||||||
|
|
|
@ -56,7 +56,7 @@ void CSSImportRule::visit_edges(Cell::Visitor& visitor)
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://www.w3.org/TR/cssom/#serialize-a-css-rule
|
// https://www.w3.org/TR/cssom/#serialize-a-css-rule
|
||||||
DeprecatedString CSSImportRule::serialized() const
|
String CSSImportRule::serialized() const
|
||||||
{
|
{
|
||||||
StringBuilder builder;
|
StringBuilder builder;
|
||||||
// The result of concatenating the following:
|
// The result of concatenating the following:
|
||||||
|
@ -75,7 +75,7 @@ DeprecatedString CSSImportRule::serialized() const
|
||||||
// 4. The string ";", i.e., SEMICOLON (U+003B).
|
// 4. The string ";", i.e., SEMICOLON (U+003B).
|
||||||
builder.append(';');
|
builder.append(';');
|
||||||
|
|
||||||
return builder.to_deprecated_string();
|
return MUST(builder.to_string());
|
||||||
}
|
}
|
||||||
|
|
||||||
void CSSImportRule::resource_did_fail()
|
void CSSImportRule::resource_did_fail()
|
||||||
|
|
|
@ -44,7 +44,7 @@ private:
|
||||||
virtual void initialize(JS::Realm&) override;
|
virtual void initialize(JS::Realm&) override;
|
||||||
virtual void visit_edges(Cell::Visitor&) override;
|
virtual void visit_edges(Cell::Visitor&) override;
|
||||||
|
|
||||||
virtual DeprecatedString serialized() const override;
|
virtual String serialized() const override;
|
||||||
|
|
||||||
// ^ResourceClient
|
// ^ResourceClient
|
||||||
virtual void resource_did_fail() override;
|
virtual void resource_did_fail() override;
|
||||||
|
|
|
@ -30,11 +30,11 @@ void CSSKeyframeRule::initialize(JS::Realm& realm)
|
||||||
set_prototype(&Bindings::ensure_web_prototype<Bindings::CSSKeyframeRulePrototype>(realm, "CSSKeyframeRule"));
|
set_prototype(&Bindings::ensure_web_prototype<Bindings::CSSKeyframeRulePrototype>(realm, "CSSKeyframeRule"));
|
||||||
}
|
}
|
||||||
|
|
||||||
DeprecatedString CSSKeyframeRule::serialized() const
|
String CSSKeyframeRule::serialized() const
|
||||||
{
|
{
|
||||||
StringBuilder builder;
|
StringBuilder builder;
|
||||||
builder.appendff("{}% {{ {} }}", key().value(), style()->serialized());
|
builder.appendff("{}% {{ {} }}", key().value(), style()->serialized());
|
||||||
return builder.to_deprecated_string();
|
return MUST(builder.to_string());
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -50,7 +50,7 @@ private:
|
||||||
|
|
||||||
virtual void visit_edges(Visitor&) override;
|
virtual void visit_edges(Visitor&) override;
|
||||||
virtual void initialize(JS::Realm&) override;
|
virtual void initialize(JS::Realm&) override;
|
||||||
virtual DeprecatedString serialized() const override;
|
virtual String serialized() const override;
|
||||||
|
|
||||||
CSS::Percentage m_key;
|
CSS::Percentage m_key;
|
||||||
JS::NonnullGCPtr<CSSStyleDeclaration> m_declarations;
|
JS::NonnullGCPtr<CSSStyleDeclaration> m_declarations;
|
||||||
|
|
|
@ -30,17 +30,17 @@ void CSSKeyframesRule::initialize(JS::Realm& realm)
|
||||||
set_prototype(&Bindings::ensure_web_prototype<Bindings::CSSKeyframesRulePrototype>(realm, "CSSKeyframesRule"));
|
set_prototype(&Bindings::ensure_web_prototype<Bindings::CSSKeyframesRulePrototype>(realm, "CSSKeyframesRule"));
|
||||||
}
|
}
|
||||||
|
|
||||||
DeprecatedString CSSKeyframesRule::serialized() const
|
String CSSKeyframesRule::serialized() const
|
||||||
{
|
{
|
||||||
StringBuilder builder;
|
StringBuilder builder;
|
||||||
builder.appendff("@keyframes \"{}\"", name());
|
builder.appendff("@keyframes \"{}\"", name());
|
||||||
builder.append(" { "sv);
|
builder.append(" { "sv);
|
||||||
for (auto& keyframe : keyframes()) {
|
for (auto const& keyframe : keyframes()) {
|
||||||
builder.append(keyframe->css_text());
|
builder.append(keyframe->css_text());
|
||||||
builder.append(' ');
|
builder.append(' ');
|
||||||
}
|
}
|
||||||
builder.append('}');
|
builder.append('}');
|
||||||
return builder.to_deprecated_string();
|
return MUST(builder.to_string());
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -45,7 +45,7 @@ private:
|
||||||
virtual void visit_edges(Visitor&) override;
|
virtual void visit_edges(Visitor&) override;
|
||||||
|
|
||||||
virtual void initialize(JS::Realm&) override;
|
virtual void initialize(JS::Realm&) override;
|
||||||
virtual DeprecatedString serialized() const override;
|
virtual String serialized() const override;
|
||||||
|
|
||||||
FlyString m_name;
|
FlyString m_name;
|
||||||
Vector<JS::NonnullGCPtr<CSSKeyframeRule>> m_keyframes;
|
Vector<JS::NonnullGCPtr<CSSKeyframeRule>> m_keyframes;
|
||||||
|
|
|
@ -48,7 +48,7 @@ void CSSMediaRule::set_condition_text(String const& text)
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://www.w3.org/TR/cssom-1/#serialize-a-css-rule
|
// https://www.w3.org/TR/cssom-1/#serialize-a-css-rule
|
||||||
DeprecatedString CSSMediaRule::serialized() const
|
String CSSMediaRule::serialized() const
|
||||||
{
|
{
|
||||||
// The result of concatenating the following:
|
// The result of concatenating the following:
|
||||||
StringBuilder builder;
|
StringBuilder builder;
|
||||||
|
@ -70,7 +70,7 @@ DeprecatedString CSSMediaRule::serialized() const
|
||||||
// 5. A newline, followed by the string "}", i.e., RIGHT CURLY BRACKET (U+007D)
|
// 5. A newline, followed by the string "}", i.e., RIGHT CURLY BRACKET (U+007D)
|
||||||
builder.append("\n}"sv);
|
builder.append("\n}"sv);
|
||||||
|
|
||||||
return builder.to_deprecated_string();
|
return MUST(builder.to_string());
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -38,7 +38,7 @@ private:
|
||||||
|
|
||||||
virtual void initialize(JS::Realm&) override;
|
virtual void initialize(JS::Realm&) override;
|
||||||
virtual void visit_edges(Cell::Visitor&) override;
|
virtual void visit_edges(Cell::Visitor&) override;
|
||||||
virtual DeprecatedString serialized() const override;
|
virtual String serialized() const override;
|
||||||
|
|
||||||
JS::NonnullGCPtr<MediaList> m_media;
|
JS::NonnullGCPtr<MediaList> m_media;
|
||||||
};
|
};
|
||||||
|
|
|
@ -35,7 +35,7 @@ void CSSNamespaceRule::initialize(JS::Realm& realm)
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://www.w3.org/TR/cssom/#serialize-a-css-rule
|
// https://www.w3.org/TR/cssom/#serialize-a-css-rule
|
||||||
DeprecatedString CSSNamespaceRule::serialized() const
|
String CSSNamespaceRule::serialized() const
|
||||||
{
|
{
|
||||||
StringBuilder builder;
|
StringBuilder builder;
|
||||||
// The literal string "@namespace", followed by a single SPACE (U+0020),
|
// The literal string "@namespace", followed by a single SPACE (U+0020),
|
||||||
|
@ -54,7 +54,7 @@ DeprecatedString CSSNamespaceRule::serialized() const
|
||||||
// followed the character ";" (U+003B).
|
// followed the character ";" (U+003B).
|
||||||
builder.append(";"sv);
|
builder.append(";"sv);
|
||||||
|
|
||||||
return builder.to_deprecated_string();
|
return MUST(builder.to_string());
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -30,7 +30,7 @@ private:
|
||||||
|
|
||||||
virtual void initialize(JS::Realm&) override;
|
virtual void initialize(JS::Realm&) override;
|
||||||
|
|
||||||
virtual DeprecatedString serialized() const override;
|
virtual String serialized() const override;
|
||||||
DeprecatedString m_namespace_uri;
|
DeprecatedString m_namespace_uri;
|
||||||
DeprecatedString m_prefix;
|
DeprecatedString m_prefix;
|
||||||
};
|
};
|
||||||
|
|
|
@ -24,7 +24,7 @@ void CSSRule::visit_edges(Cell::Visitor& visitor)
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://www.w3.org/TR/cssom/#dom-cssrule-csstext
|
// https://www.w3.org/TR/cssom/#dom-cssrule-csstext
|
||||||
DeprecatedString CSSRule::css_text() const
|
String CSSRule::css_text() const
|
||||||
{
|
{
|
||||||
// The cssText attribute must return a serialization of the CSS rule.
|
// The cssText attribute must return a serialization of the CSS rule.
|
||||||
return serialized();
|
return serialized();
|
||||||
|
|
|
@ -35,7 +35,7 @@ public:
|
||||||
|
|
||||||
virtual Type type() const = 0;
|
virtual Type type() const = 0;
|
||||||
|
|
||||||
DeprecatedString css_text() const;
|
String css_text() const;
|
||||||
void set_css_text(StringView);
|
void set_css_text(StringView);
|
||||||
|
|
||||||
CSSRule* parent_rule() { return m_parent_rule.ptr(); }
|
CSSRule* parent_rule() { return m_parent_rule.ptr(); }
|
||||||
|
@ -50,7 +50,7 @@ public:
|
||||||
protected:
|
protected:
|
||||||
explicit CSSRule(JS::Realm&);
|
explicit CSSRule(JS::Realm&);
|
||||||
|
|
||||||
virtual DeprecatedString serialized() const = 0;
|
virtual String serialized() const = 0;
|
||||||
|
|
||||||
virtual void visit_edges(Cell::Visitor&) override;
|
virtual void visit_edges(Cell::Visitor&) override;
|
||||||
|
|
||||||
|
|
|
@ -45,7 +45,7 @@ CSSStyleDeclaration* CSSStyleRule::style()
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://www.w3.org/TR/cssom/#serialize-a-css-rule
|
// https://www.w3.org/TR/cssom/#serialize-a-css-rule
|
||||||
DeprecatedString CSSStyleRule::serialized() const
|
String CSSStyleRule::serialized() const
|
||||||
{
|
{
|
||||||
StringBuilder builder;
|
StringBuilder builder;
|
||||||
|
|
||||||
|
@ -58,12 +58,12 @@ DeprecatedString CSSStyleRule::serialized() const
|
||||||
auto decls = declaration().length() > 0 ? declaration().serialized() : Optional<DeprecatedString>();
|
auto decls = declaration().length() > 0 ? declaration().serialized() : Optional<DeprecatedString>();
|
||||||
|
|
||||||
// FIXME: 3. Let rules be the result of performing serialize a CSS rule on each rule in the rule’s cssRules list, or null if there are no such rules.
|
// FIXME: 3. Let rules be the result of performing serialize a CSS rule on each rule in the rule’s cssRules list, or null if there are no such rules.
|
||||||
Optional<DeprecatedString> rules;
|
Optional<String> rules;
|
||||||
|
|
||||||
// 4. If decls and rules are both null, append " }" to s (i.e. a single SPACE (U+0020) followed by RIGHT CURLY BRACKET (U+007D)) and return s.
|
// 4. If decls and rules are both null, append " }" to s (i.e. a single SPACE (U+0020) followed by RIGHT CURLY BRACKET (U+007D)) and return s.
|
||||||
if (!decls.has_value() && !rules.has_value()) {
|
if (!decls.has_value() && !rules.has_value()) {
|
||||||
builder.append(" }"sv);
|
builder.append(" }"sv);
|
||||||
return builder.to_deprecated_string();
|
return MUST(builder.to_string());
|
||||||
}
|
}
|
||||||
|
|
||||||
// 5. If rules is null:
|
// 5. If rules is null:
|
||||||
|
@ -75,7 +75,7 @@ DeprecatedString CSSStyleRule::serialized() const
|
||||||
// 3. Append " }" to s (i.e. a single SPACE (U+0020) followed by RIGHT CURLY BRACKET (U+007D)).
|
// 3. Append " }" to s (i.e. a single SPACE (U+0020) followed by RIGHT CURLY BRACKET (U+007D)).
|
||||||
builder.append(" }"sv);
|
builder.append(" }"sv);
|
||||||
// 4. Return s.
|
// 4. Return s.
|
||||||
return builder.to_deprecated_string();
|
return MUST(builder.to_string());
|
||||||
}
|
}
|
||||||
|
|
||||||
// FIXME: 6. Otherwise:
|
// FIXME: 6. Otherwise:
|
||||||
|
|
|
@ -38,7 +38,7 @@ private:
|
||||||
|
|
||||||
virtual void initialize(JS::Realm&) override;
|
virtual void initialize(JS::Realm&) override;
|
||||||
virtual void visit_edges(Cell::Visitor&) override;
|
virtual void visit_edges(Cell::Visitor&) override;
|
||||||
virtual DeprecatedString serialized() const override;
|
virtual String serialized() const override;
|
||||||
|
|
||||||
Vector<NonnullRefPtr<Selector>> m_selectors;
|
Vector<NonnullRefPtr<Selector>> m_selectors;
|
||||||
JS::NonnullGCPtr<CSSStyleDeclaration> m_declaration;
|
JS::NonnullGCPtr<CSSStyleDeclaration> m_declaration;
|
||||||
|
|
|
@ -42,7 +42,7 @@ void CSSSupportsRule::set_condition_text(String const& text)
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://www.w3.org/TR/cssom-1/#serialize-a-css-rule
|
// https://www.w3.org/TR/cssom-1/#serialize-a-css-rule
|
||||||
DeprecatedString CSSSupportsRule::serialized() const
|
String CSSSupportsRule::serialized() const
|
||||||
{
|
{
|
||||||
// Note: The spec doesn't cover this yet, so I'm roughly following the spec for the @media rule.
|
// Note: The spec doesn't cover this yet, so I'm roughly following the spec for the @media rule.
|
||||||
// It should be pretty close!
|
// It should be pretty close!
|
||||||
|
@ -61,7 +61,7 @@ DeprecatedString CSSSupportsRule::serialized() const
|
||||||
}
|
}
|
||||||
builder.append("\n}"sv);
|
builder.append("\n}"sv);
|
||||||
|
|
||||||
return builder.to_deprecated_string();
|
return MUST(builder.to_string());
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -34,7 +34,7 @@ private:
|
||||||
CSSSupportsRule(JS::Realm&, NonnullRefPtr<Supports>&&, CSSRuleList&);
|
CSSSupportsRule(JS::Realm&, NonnullRefPtr<Supports>&&, CSSRuleList&);
|
||||||
|
|
||||||
virtual void initialize(JS::Realm&) override;
|
virtual void initialize(JS::Realm&) override;
|
||||||
virtual DeprecatedString serialized() const override;
|
virtual String serialized() const override;
|
||||||
|
|
||||||
NonnullRefPtr<Supports> m_supports;
|
NonnullRefPtr<Supports> m_supports;
|
||||||
};
|
};
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue