LibWeb: Port CSSStyleDeclaration from DeprecatedString to String

This commit is contained in:
Shannon Booth 2023-09-06 19:07:24 +12:00 committed by Andrew Kaster
parent fbc4370c44
commit f5efe9bb63
5 changed files with 21 additions and 21 deletions

View file

@ -38,11 +38,11 @@ PropertyOwningCSSStyleDeclaration::PropertyOwningCSSStyleDeclaration(JS::Realm&
{
}
DeprecatedString PropertyOwningCSSStyleDeclaration::item(size_t index) const
String PropertyOwningCSSStyleDeclaration::item(size_t index) const
{
if (index >= m_properties.size())
return {};
return CSS::string_from_property_id(m_properties[index].property_id);
return MUST(String::from_utf8(CSS::string_from_property_id(m_properties[index].property_id)));
}
JS::NonnullGCPtr<ElementInlineCSSStyleDeclaration> ElementInlineCSSStyleDeclaration::create(DOM::Element& element, Vector<StyleProperty> properties, HashMap<DeprecatedString, StyleProperty> custom_properties)
@ -128,7 +128,7 @@ WebIDL::ExceptionOr<void> PropertyOwningCSSStyleDeclaration::set_property(Proper
}
// https://drafts.csswg.org/cssom/#dom-cssstyledeclaration-removeproperty
WebIDL::ExceptionOr<DeprecatedString> PropertyOwningCSSStyleDeclaration::remove_property(PropertyID property_id)
WebIDL::ExceptionOr<String> PropertyOwningCSSStyleDeclaration::remove_property(PropertyID property_id)
{
// 1. If the computed flag is set, then throw a NoModificationAllowedError exception.
// NOTE: This is handled by the virtual override in ResolvedCSSStyleDeclaration.
@ -202,7 +202,7 @@ bool PropertyOwningCSSStyleDeclaration::set_a_css_declaration(PropertyID propert
return true;
}
DeprecatedString CSSStyleDeclaration::get_property_value(StringView property_name) const
String CSSStyleDeclaration::get_property_value(StringView property_name) const
{
auto property_id = property_id_from_string(property_name);
if (!property_id.has_value())
@ -210,11 +210,11 @@ DeprecatedString CSSStyleDeclaration::get_property_value(StringView property_nam
auto maybe_property = property(property_id.value());
if (!maybe_property.has_value())
return {};
return maybe_property->value->to_string().to_deprecated_string();
return maybe_property->value->to_string();
}
// https://drafts.csswg.org/cssom/#dom-cssstyledeclaration-getpropertypriority
DeprecatedString CSSStyleDeclaration::get_property_priority(StringView property_name) const
StringView CSSStyleDeclaration::get_property_priority(StringView property_name) const
{
auto property_id = property_id_from_string(property_name);
if (!property_id.has_value())
@ -222,7 +222,7 @@ DeprecatedString CSSStyleDeclaration::get_property_priority(StringView property_
auto maybe_property = property(property_id.value());
if (!maybe_property.has_value())
return {};
return maybe_property->important == Important::Yes ? "important" : "";
return maybe_property->important == Important::Yes ? "important"sv : ""sv;
}
WebIDL::ExceptionOr<void> CSSStyleDeclaration::set_property(StringView property_name, StringView css_text, StringView priority)
@ -233,11 +233,11 @@ WebIDL::ExceptionOr<void> CSSStyleDeclaration::set_property(StringView property_
return set_property(property_id.value(), css_text, priority);
}
WebIDL::ExceptionOr<DeprecatedString> CSSStyleDeclaration::remove_property(StringView property_name)
WebIDL::ExceptionOr<String> CSSStyleDeclaration::remove_property(StringView property_name)
{
auto property_id = property_id_from_string(property_name);
if (!property_id.has_value())
return DeprecatedString::empty();
return String {};
return remove_property(property_id.value());
}

View file

@ -22,18 +22,18 @@ public:
virtual void initialize(JS::Realm&) override;
virtual size_t length() const = 0;
virtual DeprecatedString item(size_t index) const = 0;
virtual String item(size_t index) const = 0;
virtual Optional<StyleProperty> property(PropertyID) const = 0;
virtual WebIDL::ExceptionOr<void> set_property(PropertyID, StringView css_text, StringView priority = ""sv) = 0;
virtual WebIDL::ExceptionOr<DeprecatedString> remove_property(PropertyID) = 0;
virtual WebIDL::ExceptionOr<String> remove_property(PropertyID) = 0;
WebIDL::ExceptionOr<void> set_property(StringView property_name, StringView css_text, StringView priority);
WebIDL::ExceptionOr<DeprecatedString> remove_property(StringView property_name);
WebIDL::ExceptionOr<String> remove_property(StringView property_name);
DeprecatedString get_property_value(StringView property) const;
DeprecatedString get_property_priority(StringView property) const;
String get_property_value(StringView property) const;
StringView get_property_priority(StringView property) const;
DeprecatedString css_text() const;
virtual WebIDL::ExceptionOr<void> set_css_text(StringView) = 0;
@ -59,12 +59,12 @@ public:
virtual ~PropertyOwningCSSStyleDeclaration() override = default;
virtual size_t length() const override;
virtual DeprecatedString item(size_t index) const override;
virtual String item(size_t index) const override;
virtual Optional<StyleProperty> property(PropertyID) const override;
virtual WebIDL::ExceptionOr<void> set_property(PropertyID, StringView css_text, StringView priority) override;
virtual WebIDL::ExceptionOr<DeprecatedString> remove_property(PropertyID) override;
virtual WebIDL::ExceptionOr<String> remove_property(PropertyID) override;
Vector<StyleProperty> const& properties() const { return m_properties; }
HashMap<DeprecatedString, StyleProperty> const& custom_properties() const { return m_custom_properties; }

View file

@ -1,5 +1,5 @@
// https://drafts.csswg.org/cssom/#cssstyledeclaration
[Exposed=Window, UseDeprecatedAKString]
[Exposed=Window]
interface CSSStyleDeclaration {
[CEReactions] attribute CSSOMString cssText;

View file

@ -72,7 +72,7 @@ size_t ResolvedCSSStyleDeclaration::length() const
return 0;
}
DeprecatedString ResolvedCSSStyleDeclaration::item(size_t index) const
String ResolvedCSSStyleDeclaration::item(size_t index) const
{
(void)index;
return {};
@ -944,7 +944,7 @@ WebIDL::ExceptionOr<void> ResolvedCSSStyleDeclaration::set_property(PropertyID,
}
// https://drafts.csswg.org/cssom/#dom-cssstyledeclaration-removeproperty
WebIDL::ExceptionOr<DeprecatedString> ResolvedCSSStyleDeclaration::remove_property(PropertyID)
WebIDL::ExceptionOr<String> ResolvedCSSStyleDeclaration::remove_property(PropertyID)
{
// 1. If the computed flag is set, then throw a NoModificationAllowedError exception.
return WebIDL::NoModificationAllowedError::create(realm(), "Cannot remove properties from result of getComputedStyle()"_fly_string);

View file

@ -19,10 +19,10 @@ public:
virtual ~ResolvedCSSStyleDeclaration() override = default;
virtual size_t length() const override;
virtual DeprecatedString item(size_t index) const override;
virtual String item(size_t index) const override;
virtual Optional<StyleProperty> property(PropertyID) const override;
virtual WebIDL::ExceptionOr<void> set_property(PropertyID, StringView css_text, StringView priority) override;
virtual WebIDL::ExceptionOr<DeprecatedString> remove_property(PropertyID) override;
virtual WebIDL::ExceptionOr<String> remove_property(PropertyID) override;
virtual DeprecatedString serialized() const override;
virtual WebIDL::ExceptionOr<void> set_css_text(StringView) override;