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

LibWeb: Port CSSStyleSheet interface from DeprecatedString to String

This commit is contained in:
Shannon Booth 2023-09-03 14:19:49 +12:00 committed by Tim Flynn
parent d93e916d0c
commit da637a527d
5 changed files with 22 additions and 16 deletions

View file

@ -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);

View file

@ -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; }

View file

@ -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<String> href() const { return m_location; }
DeprecatedString location() const { return m_location; }
void set_location(DeprecatedString location) { m_location = move(location); }
Optional<String> location() const { return m_location; }
void set_location(Optional<String> location) { m_location = move(location); }
DeprecatedString title() const { return m_title; }
void set_title(DeprecatedString title) { m_title = move(title); }
Optional<String> title() const { return m_title; }
void set_title(Optional<String> 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<DOM::Element> m_owner_node;
JS::GCPtr<CSSStyleSheet> m_parent_style_sheet;
DeprecatedString m_location;
DeprecatedString m_title;
DeprecatedString m_type_string;
Optional<String> m_location;
Optional<String> m_title;
String m_type_string;
bool m_disabled { false };
bool m_alternate { false };

View file

@ -3,7 +3,7 @@
#import <DOM/Element.idl>
// https://drafts.csswg.org/cssom/#stylesheet
[Exposed=Window, UseDeprecatedAKString]
[Exposed=Window]
interface StyleSheet {
readonly attribute Element? ownerNode;

View file

@ -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);