1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-24 17:27:35 +00:00

LibWeb: Remove some to_deprecated_string() calls in the CSS code

This commit is contained in:
Sam Atkins 2023-12-01 16:45:31 +00:00 committed by Andreas Kling
parent 9c1c7720c5
commit 6dbc3044bd
9 changed files with 12 additions and 12 deletions

View file

@ -63,7 +63,7 @@ String CSSFontFaceRule::serialized() const
// 2. The result of invoking serialize a comma-separated list on performing serialize a URL or serialize a LOCAL for each source on the source list. // 2. The result of invoking serialize a comma-separated list on performing serialize a URL or serialize a LOCAL for each source on the source list.
serialize_a_comma_separated_list(builder, m_font_face.sources(), [&](StringBuilder& builder, FontFace::Source source) -> void { serialize_a_comma_separated_list(builder, m_font_face.sources(), [&](StringBuilder& builder, FontFace::Source source) -> void {
if (source.local_or_url.has<AK::URL>()) { if (source.local_or_url.has<AK::URL>()) {
serialize_a_url(builder, source.local_or_url.get<AK::URL>().to_deprecated_string()); serialize_a_url(builder, MUST(source.local_or_url.get<AK::URL>().to_string()));
} else { } else {
builder.appendff("local({})", source.local_or_url.get<String>()); builder.appendff("local({})", source.local_or_url.get<String>());
} }

View file

@ -39,7 +39,7 @@ void CSSMediaRule::visit_edges(Cell::Visitor& visitor)
String CSSMediaRule::condition_text() const String CSSMediaRule::condition_text() const
{ {
return String::from_deprecated_string(m_media->media_text().to_deprecated_string()).release_value(); return m_media->media_text();
} }
void CSSMediaRule::set_condition_text(String const& text) void CSSMediaRule::set_condition_text(String const& text)

View file

@ -317,7 +317,7 @@ String PropertyOwningCSSStyleDeclaration::serialized() const
// NOTE: There are no shorthands for custom properties. // NOTE: There are no shorthands for custom properties.
// 5. Let value be the result of invoking serialize a CSS value of declaration. // 5. Let value be the result of invoking serialize a CSS value of declaration.
auto value = declaration.value.value->to_string().to_deprecated_string(); auto value = declaration.value.value->to_string();
// 6. Let serialized declaration be the result of invoking serialize a CSS declaration with property name property, value value, // 6. Let serialized declaration be the result of invoking serialize a CSS declaration with property name property, value value,
// and the important flag set if declaration has its important flag set. // and the important flag set if declaration has its important flag set.
@ -419,7 +419,7 @@ JS::ThrowCompletionOr<JS::Value> CSSStyleDeclaration::internal_get(JS::PropertyK
if (property_id == CSS::PropertyID::Invalid) if (property_id == CSS::PropertyID::Invalid)
return Base::internal_get(name, receiver, cacheable_metadata); return Base::internal_get(name, receiver, cacheable_metadata);
if (auto maybe_property = property(property_id); maybe_property.has_value()) if (auto maybe_property = property(property_id); maybe_property.has_value())
return { JS::PrimitiveString::create(vm(), maybe_property->value->to_string().to_deprecated_string()) }; return { JS::PrimitiveString::create(vm(), maybe_property->value->to_string()) };
return { JS::PrimitiveString::create(vm(), String {}) }; return { JS::PrimitiveString::create(vm(), String {}) };
} }
@ -432,7 +432,7 @@ JS::ThrowCompletionOr<bool> CSSStyleDeclaration::internal_set(JS::PropertyKey co
if (property_id == CSS::PropertyID::Invalid) if (property_id == CSS::PropertyID::Invalid)
return Base::internal_set(name, value, receiver, cacheable_metadata); return Base::internal_set(name, value, receiver, cacheable_metadata);
auto css_text = TRY(value.to_deprecated_string(vm)); auto css_text = TRY(value.to_string(vm));
TRY(Bindings::throw_dom_exception_if_needed(vm, [&] { return set_property(property_id, css_text); })); TRY(Bindings::throw_dom_exception_if_needed(vm, [&] { return set_property(property_id, css_text); }));
return true; return true;

View file

@ -119,7 +119,7 @@ WebIDL::ExceptionOr<JS::Value> MediaList::item_value(size_t index) const
{ {
if (index >= m_media.size()) if (index >= m_media.size())
return JS::js_undefined(); return JS::js_undefined();
return JS::PrimitiveString::create(vm(), m_media[index]->to_string().to_deprecated_string()); return JS::PrimitiveString::create(vm(), m_media[index]->to_string());
} }
} }

View file

@ -113,7 +113,7 @@ void serialize_a_url(StringBuilder& builder, StringView url)
// To serialize a URL means to create a string represented by "url(", // To serialize a URL means to create a string represented by "url(",
// followed by the serialization of the URL as a string, followed by ")". // followed by the serialization of the URL as a string, followed by ")".
builder.append("url("sv); builder.append("url("sv);
serialize_a_string(builder, url.to_deprecated_string()); serialize_a_string(builder, url);
builder.append(')'); builder.append(')');
} }
@ -123,7 +123,7 @@ void serialize_a_local(StringBuilder& builder, StringView path)
// To serialize a LOCAL means to create a string represented by "local(", // To serialize a LOCAL means to create a string represented by "local(",
// followed by the serialization of the LOCAL as a string, followed by ")". // followed by the serialization of the LOCAL as a string, followed by ")".
builder.append("local("sv); builder.append("local("sv);
serialize_a_string(builder, path.to_deprecated_string()); serialize_a_string(builder, path);
builder.append(')'); builder.append(')');
} }

View file

@ -2374,7 +2374,7 @@ void StyleComputer::load_fonts_from_sheet(CSSStyleSheet const& sheet)
for (auto& source : font_face.sources()) { for (auto& source : font_face.sources()) {
// FIXME: These should be loaded relative to the stylesheet URL instead of the document URL. // FIXME: These should be loaded relative to the stylesheet URL instead of the document URL.
if (source.local_or_url.has<AK::URL>()) if (source.local_or_url.has<AK::URL>())
urls.append(m_document->parse_url(source.local_or_url.get<AK::URL>().to_deprecated_string())); urls.append(m_document->parse_url(MUST(source.local_or_url.get<AK::URL>().to_string())));
// FIXME: Handle local() // FIXME: Handle local()
} }

View file

@ -100,7 +100,7 @@ Gfx::ImmutableBitmap const* ImageStyleValue::bitmap(size_t frame_index, Gfx::Int
String ImageStyleValue::to_string() const String ImageStyleValue::to_string() const
{ {
return serialize_a_url(m_url.to_deprecated_string()); return serialize_a_url(MUST(m_url.to_string()));
} }
bool ImageStyleValue::equals(StyleValue const& other) const bool ImageStyleValue::equals(StyleValue const& other) const

View file

@ -14,7 +14,7 @@ namespace Web::CSS {
String ShadowStyleValue::to_string() const String ShadowStyleValue::to_string() const
{ {
StringBuilder builder; StringBuilder builder;
builder.appendff("{} {} {} {} {}", m_properties.color.to_deprecated_string(), m_properties.offset_x->to_string(), m_properties.offset_y->to_string(), m_properties.blur_radius->to_string(), m_properties.spread_distance->to_string()); builder.appendff("{} {} {} {} {}", m_properties.color.to_string(), m_properties.offset_x->to_string(), m_properties.offset_y->to_string(), m_properties.blur_radius->to_string(), m_properties.spread_distance->to_string());
if (m_properties.placement == ShadowPlacement::Inner) if (m_properties.placement == ShadowPlacement::Inner)
builder.append(" inset"sv); builder.append(" inset"sv);
return MUST(builder.to_string()); return MUST(builder.to_string());

View file

@ -27,7 +27,7 @@ public:
virtual String to_string() const override virtual String to_string() const override
{ {
return serialize_a_url(m_url.to_deprecated_string()); return serialize_a_url(MUST(m_url.to_string()));
} }
private: private: