From af7df1dbbf77965ac032fdded42b77b411e3f58a Mon Sep 17 00:00:00 2001 From: Shannon Booth Date: Tue, 21 Nov 2023 10:39:54 +1300 Subject: [PATCH] LibWeb: Port CSSStyleDeclaration from DeprecatedString to String --- .../LibWeb/CSS/CSSStyleDeclaration.cpp | 20 +++++++++---------- .../LibWeb/CSS/CSSStyleDeclaration.h | 8 ++++---- .../Libraries/LibWeb/CSS/CSSStyleRule.cpp | 2 +- .../CSS/ResolvedCSSStyleDeclaration.cpp | 4 ++-- .../LibWeb/CSS/ResolvedCSSStyleDeclaration.h | 2 +- 5 files changed, 18 insertions(+), 18 deletions(-) diff --git a/Userland/Libraries/LibWeb/CSS/CSSStyleDeclaration.cpp b/Userland/Libraries/LibWeb/CSS/CSSStyleDeclaration.cpp index 6701378036..74e11fee9c 100644 --- a/Userland/Libraries/LibWeb/CSS/CSSStyleDeclaration.cpp +++ b/Userland/Libraries/LibWeb/CSS/CSSStyleDeclaration.cpp @@ -187,7 +187,7 @@ void ElementInlineCSSStyleDeclaration::update_style_attribute() m_updating = true; // 5. Set an attribute value for owner node using "style" and the result of serializing declaration block. - MUST(m_element->set_attribute(HTML::AttributeNames::style, MUST(String::from_deprecated_string(serialized())))); + MUST(m_element->set_attribute(HTML::AttributeNames::style, serialized())); // 6. Unset declaration block’s updating flag. m_updating = false; @@ -256,7 +256,7 @@ WebIDL::ExceptionOr CSSStyleDeclaration::remove_property(StringView prop } // https://drafts.csswg.org/cssom/#dom-cssstyledeclaration-csstext -DeprecatedString CSSStyleDeclaration::css_text() const +String CSSStyleDeclaration::css_text() const { // 1. If the computed flag is set, then return the empty string. // NOTE: See ResolvedCSSStyleDeclaration::serialized() @@ -266,7 +266,7 @@ DeprecatedString CSSStyleDeclaration::css_text() const } // https://www.w3.org/TR/cssom/#serialize-a-css-declaration -static DeprecatedString serialize_a_css_declaration(CSS::PropertyID property, DeprecatedString value, Important important) +static String serialize_a_css_declaration(CSS::PropertyID property, StringView value, Important important) { StringBuilder builder; @@ -288,14 +288,14 @@ static DeprecatedString serialize_a_css_declaration(CSS::PropertyID property, De builder.append(';'); // 7. Return s. - return builder.to_deprecated_string(); + return MUST(builder.to_string()); } // https://www.w3.org/TR/cssom/#serialize-a-css-declaration-block -DeprecatedString PropertyOwningCSSStyleDeclaration::serialized() const +String PropertyOwningCSSStyleDeclaration::serialized() const { // 1. Let list be an empty array. - Vector list; + Vector list; // 2. Let already serialized be an empty array. HashTable already_serialized; @@ -322,7 +322,7 @@ DeprecatedString PropertyOwningCSSStyleDeclaration::serialized() const // 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. // NOTE: We have to inline this here as the actual implementation does not accept custom properties. - DeprecatedString serialized_declaration = [&] { + String serialized_declaration = [&] { // https://www.w3.org/TR/cssom/#serialize-a-css-declaration StringBuilder builder; @@ -344,7 +344,7 @@ DeprecatedString PropertyOwningCSSStyleDeclaration::serialized() const builder.append(';'); // 7. Return s. - return builder.to_deprecated_string(); + return MUST(builder.to_string()); }(); // 7. Append serialized declaration to list. @@ -368,7 +368,7 @@ DeprecatedString PropertyOwningCSSStyleDeclaration::serialized() const // FIXME: 4. Shorthand loop: For each shorthand in shorthands, follow these substeps: ... // 5. Let value be the result of invoking serialize a CSS value of declaration. - auto value = declaration.value->to_string().to_deprecated_string(); + auto value = declaration.value->to_string(); // 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. @@ -384,7 +384,7 @@ DeprecatedString PropertyOwningCSSStyleDeclaration::serialized() const // 4. Return list joined with " " (U+0020). StringBuilder builder; builder.join(' ', list); - return builder.to_deprecated_string(); + return MUST(builder.to_string()); } static CSS::PropertyID property_id_from_name(StringView name) diff --git a/Userland/Libraries/LibWeb/CSS/CSSStyleDeclaration.h b/Userland/Libraries/LibWeb/CSS/CSSStyleDeclaration.h index 33423c0ce3..b485a6169d 100644 --- a/Userland/Libraries/LibWeb/CSS/CSSStyleDeclaration.h +++ b/Userland/Libraries/LibWeb/CSS/CSSStyleDeclaration.h @@ -6,7 +6,7 @@ #pragma once -#include +#include #include #include #include @@ -36,10 +36,10 @@ public: String get_property_value(StringView property) const; StringView get_property_priority(StringView property) const; - DeprecatedString css_text() const; + String css_text() const; virtual WebIDL::ExceptionOr set_css_text(StringView) = 0; - virtual DeprecatedString serialized() const = 0; + virtual String serialized() const = 0; virtual JS::ThrowCompletionOr internal_has_property(JS::PropertyKey const& name) const override; virtual JS::ThrowCompletionOr internal_get(JS::PropertyKey const&, JS::Value receiver, JS::CacheablePropertyMetadata*) const override; @@ -74,7 +74,7 @@ public: Optional custom_property(FlyString const& custom_property_name) const { return m_custom_properties.get(custom_property_name); } size_t custom_property_count() const { return m_custom_properties.size(); } - virtual DeprecatedString serialized() const final override; + virtual String serialized() const final override; virtual WebIDL::ExceptionOr set_css_text(StringView) override; protected: diff --git a/Userland/Libraries/LibWeb/CSS/CSSStyleRule.cpp b/Userland/Libraries/LibWeb/CSS/CSSStyleRule.cpp index faea1f9cd5..ac9e7cbc4a 100644 --- a/Userland/Libraries/LibWeb/CSS/CSSStyleRule.cpp +++ b/Userland/Libraries/LibWeb/CSS/CSSStyleRule.cpp @@ -55,7 +55,7 @@ String CSSStyleRule::serialized() const builder.append(" {"sv); // 2. Let decls be the result of performing serialize a CSS declaration block on the rule’s associated declarations, or null if there are no such declarations. - auto decls = declaration().length() > 0 ? declaration().serialized() : Optional(); + auto decls = declaration().length() > 0 ? declaration().serialized() : Optional(); // 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 rules; diff --git a/Userland/Libraries/LibWeb/CSS/ResolvedCSSStyleDeclaration.cpp b/Userland/Libraries/LibWeb/CSS/ResolvedCSSStyleDeclaration.cpp index e6eb36754e..0b2f71d216 100644 --- a/Userland/Libraries/LibWeb/CSS/ResolvedCSSStyleDeclaration.cpp +++ b/Userland/Libraries/LibWeb/CSS/ResolvedCSSStyleDeclaration.cpp @@ -567,14 +567,14 @@ WebIDL::ExceptionOr ResolvedCSSStyleDeclaration::remove_property(Propert return WebIDL::NoModificationAllowedError::create(realm(), "Cannot remove properties from result of getComputedStyle()"_fly_string); } -DeprecatedString ResolvedCSSStyleDeclaration::serialized() const +String ResolvedCSSStyleDeclaration::serialized() const { // https://www.w3.org/TR/cssom/#dom-cssstyledeclaration-csstext // If the computed flag is set, then return the empty string. // NOTE: ResolvedCSSStyleDeclaration is something you would only get from window.getComputedStyle(), // which returns what the spec calls "resolved style". The "computed flag" is always set here. - return DeprecatedString::empty(); + return String {}; } // https://drafts.csswg.org/cssom/#dom-cssstyledeclaration-csstext diff --git a/Userland/Libraries/LibWeb/CSS/ResolvedCSSStyleDeclaration.h b/Userland/Libraries/LibWeb/CSS/ResolvedCSSStyleDeclaration.h index f736277a64..a1a02febf5 100644 --- a/Userland/Libraries/LibWeb/CSS/ResolvedCSSStyleDeclaration.h +++ b/Userland/Libraries/LibWeb/CSS/ResolvedCSSStyleDeclaration.h @@ -25,7 +25,7 @@ public: virtual WebIDL::ExceptionOr set_property(PropertyID, StringView css_text, StringView priority) override; virtual WebIDL::ExceptionOr remove_property(PropertyID) override; - virtual DeprecatedString serialized() const override; + virtual String serialized() const override; virtual WebIDL::ExceptionOr set_css_text(StringView) override; private: