From da637a527db4d997e36fbbe83f5fa4e111727adb Mon Sep 17 00:00:00 2001 From: Shannon Booth Date: Sun, 3 Sep 2023 14:19:49 +1200 Subject: [PATCH] LibWeb: Port CSSStyleSheet interface from DeprecatedString to String --- .../Libraries/LibWeb/CSS/CSSStyleSheet.cpp | 2 +- Userland/Libraries/LibWeb/CSS/CSSStyleSheet.h | 2 +- Userland/Libraries/LibWeb/CSS/StyleSheet.h | 20 +++++++++---------- Userland/Libraries/LibWeb/CSS/StyleSheet.idl | 2 +- .../LibWeb/DOM/StyleElementUtils.cpp | 12 ++++++++--- 5 files changed, 22 insertions(+), 16 deletions(-) diff --git a/Userland/Libraries/LibWeb/CSS/CSSStyleSheet.cpp b/Userland/Libraries/LibWeb/CSS/CSSStyleSheet.cpp index f0c3ba784d..5a70d837e5 100644 --- a/Userland/Libraries/LibWeb/CSS/CSSStyleSheet.cpp +++ b/Userland/Libraries/LibWeb/CSS/CSSStyleSheet.cpp @@ -25,7 +25,7 @@ CSSStyleSheet::CSSStyleSheet(JS::Realm& realm, CSSRuleList& rules, MediaList& me , m_rules(&rules) { if (location.has_value()) - set_location(location->to_deprecated_string()); + set_location(MUST(location->to_string())); for (auto& rule : *m_rules) rule->set_parent_style_sheet(this); diff --git a/Userland/Libraries/LibWeb/CSS/CSSStyleSheet.h b/Userland/Libraries/LibWeb/CSS/CSSStyleSheet.h index 7298ef9e82..9b30c87849 100644 --- a/Userland/Libraries/LibWeb/CSS/CSSStyleSheet.h +++ b/Userland/Libraries/LibWeb/CSS/CSSStyleSheet.h @@ -29,7 +29,7 @@ public: void set_owner_css_rule(CSSRule* rule) { m_owner_css_rule = rule; } - virtual DeprecatedString type() const override { return "text/css"; } + virtual String type() const override { return "text/css"_string; } CSSRuleList const& rules() const { return *m_rules; } CSSRuleList& rules() { return *m_rules; } diff --git a/Userland/Libraries/LibWeb/CSS/StyleSheet.h b/Userland/Libraries/LibWeb/CSS/StyleSheet.h index 99a6e7cfb1..6f7dc0c5af 100644 --- a/Userland/Libraries/LibWeb/CSS/StyleSheet.h +++ b/Userland/Libraries/LibWeb/CSS/StyleSheet.h @@ -19,20 +19,20 @@ class StyleSheet : public Bindings::PlatformObject { public: virtual ~StyleSheet() = default; - virtual DeprecatedString type() const = 0; + virtual String type() const = 0; DOM::Element* owner_node() { return m_owner_node; } void set_owner_node(DOM::Element*); - DeprecatedString href() const { return m_location; } + Optional href() const { return m_location; } - DeprecatedString location() const { return m_location; } - void set_location(DeprecatedString location) { m_location = move(location); } + Optional location() const { return m_location; } + void set_location(Optional location) { m_location = move(location); } - DeprecatedString title() const { return m_title; } - void set_title(DeprecatedString title) { m_title = move(title); } + Optional title() const { return m_title; } + void set_title(Optional title) { m_title = move(title); } - void set_type(DeprecatedString type) { m_type_string = move(type); } + void set_type(String type) { m_type_string = move(type); } MediaList* media() const { @@ -65,9 +65,9 @@ private: JS::GCPtr m_owner_node; JS::GCPtr m_parent_style_sheet; - DeprecatedString m_location; - DeprecatedString m_title; - DeprecatedString m_type_string; + Optional m_location; + Optional m_title; + String m_type_string; bool m_disabled { false }; bool m_alternate { false }; diff --git a/Userland/Libraries/LibWeb/CSS/StyleSheet.idl b/Userland/Libraries/LibWeb/CSS/StyleSheet.idl index 3ccc954612..5109cde785 100644 --- a/Userland/Libraries/LibWeb/CSS/StyleSheet.idl +++ b/Userland/Libraries/LibWeb/CSS/StyleSheet.idl @@ -3,7 +3,7 @@ #import // https://drafts.csswg.org/cssom/#stylesheet -[Exposed=Window, UseDeprecatedAKString] +[Exposed=Window] interface StyleSheet { readonly attribute Element? ownerNode; diff --git a/Userland/Libraries/LibWeb/DOM/StyleElementUtils.cpp b/Userland/Libraries/LibWeb/DOM/StyleElementUtils.cpp index de71d98ff4..6d0e2ddd12 100644 --- a/Userland/Libraries/LibWeb/DOM/StyleElementUtils.cpp +++ b/Userland/Libraries/LibWeb/DOM/StyleElementUtils.cpp @@ -94,12 +94,18 @@ void StyleElementUtils::create_a_css_style_sheet(DOM::Document& document, Deprec sheet.set_parent_css_style_sheet(parent_style_sheet); sheet.set_owner_css_rule(owner_rule); sheet.set_owner_node(owner_node); - sheet.set_type(move(type)); + sheet.set_type(MUST(String::from_deprecated_string(type))); sheet.set_media(move(media)); - sheet.set_title(move(title)); + if (title.is_null()) + sheet.set_title({}); + else + sheet.set_title(MUST(String::from_deprecated_string(title))); sheet.set_alternate(alternate); sheet.set_origin_clean(origin_clean); - sheet.set_location(move(location)); + if (location.is_null()) + sheet.set_location({}); + else + sheet.set_location(MUST(String::from_deprecated_string(location))); // 2. Then run the add a CSS style sheet steps for the newly created CSS style sheet. add_a_css_style_sheet(document, sheet);