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

LibWeb: Port Attr interface from DeprecatedString to String

There are an unfortunate number of DeprecatedString conversions required
here, but these should all fall away and look much more pretty again
when other places are also ported away from DeprecatedString.

Leaves only the Element IDL interface left :^)
This commit is contained in:
Shannon Booth 2023-09-10 16:06:58 +12:00 committed by Andreas Kling
parent a41f23a0fc
commit 3bd04d2c58
15 changed files with 172 additions and 117 deletions

View file

@ -18,22 +18,22 @@ class Attr final : public Node {
WEB_PLATFORM_OBJECT(Attr, Node);
public:
[[nodiscard]] static JS::NonnullGCPtr<Attr> create(Document&, QualifiedName, DeprecatedString value = "", Element* = nullptr);
[[nodiscard]] static JS::NonnullGCPtr<Attr> create(Document&, DeprecatedFlyString local_name, DeprecatedString value = "", Element* = nullptr);
[[nodiscard]] static JS::NonnullGCPtr<Attr> create(Document&, QualifiedName, String value = {}, Element* = nullptr);
[[nodiscard]] static JS::NonnullGCPtr<Attr> create(Document&, FlyString local_name, String value = {}, Element* = nullptr);
JS::NonnullGCPtr<Attr> clone(Document&);
virtual ~Attr() override = default;
virtual FlyString node_name() const override { return MUST(FlyString::from_deprecated_fly_string(name())); }
virtual FlyString node_name() const override { return name(); }
DeprecatedFlyString const& namespace_uri() const { return m_qualified_name.namespace_(); }
DeprecatedFlyString const& prefix() const { return m_qualified_name.prefix(); }
DeprecatedFlyString const& local_name() const { return m_qualified_name.local_name(); }
DeprecatedFlyString const& name() const { return m_qualified_name.as_string(); }
Optional<FlyString> const& namespace_uri() const { return m_qualified_name.namespace_(); }
Optional<FlyString> const& prefix() const { return m_qualified_name.prefix(); }
FlyString const& local_name() const { return m_qualified_name.local_name(); }
FlyString const& name() const { return m_qualified_name.as_string(); }
DeprecatedString const& value() const { return m_value; }
void set_value(DeprecatedString value);
void change_attribute(DeprecatedString value);
String const& value() const { return m_value; }
void set_value(String value);
void change_attribute(String value);
Element* owner_element();
Element const* owner_element() const;
@ -45,13 +45,13 @@ public:
void handle_attribute_changes(Element&, DeprecatedString const& old_value, DeprecatedString const& new_value);
private:
Attr(Document&, QualifiedName, DeprecatedString value, Element*);
Attr(Document&, QualifiedName, String value, Element*);
virtual void initialize(JS::Realm&) override;
virtual void visit_edges(Cell::Visitor&) override;
QualifiedName m_qualified_name;
DeprecatedString m_value;
String m_value;
JS::GCPtr<Element> m_owner_element;
};