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

LibWeb: Use FlyString where possible in NamedNodeMap

We cannot port over Optional<FlyString> until the IDL generator supports
passing that through as an argument (as opposed to an Optional<String>).

Change to FlyString where possible, and resolve any fallout as a result.
This commit is contained in:
Shannon Booth 2024-01-02 21:23:53 +13:00 committed by Andreas Kling
parent 0bb0c7dac2
commit f32185420d
8 changed files with 40 additions and 45 deletions

View file

@ -35,19 +35,19 @@ public:
// Methods defined by the spec for JavaScript:
Attr const* item(u32 index) const;
Attr const* get_named_item(StringView qualified_name) const;
Attr const* get_named_item_ns(Optional<String> const& namespace_, StringView local_name) const;
Attr const* get_named_item(FlyString const& qualified_name) const;
Attr const* get_named_item_ns(Optional<String> const& namespace_, FlyString const& local_name) const;
WebIDL::ExceptionOr<JS::GCPtr<Attr>> set_named_item(Attr& attribute);
WebIDL::ExceptionOr<JS::GCPtr<Attr>> set_named_item_ns(Attr& attribute);
WebIDL::ExceptionOr<Attr const*> remove_named_item(StringView qualified_name);
WebIDL::ExceptionOr<Attr const*> remove_named_item_ns(Optional<String> const& namespace_, StringView local_name);
WebIDL::ExceptionOr<Attr const*> remove_named_item(FlyString const& qualified_name);
WebIDL::ExceptionOr<Attr const*> remove_named_item_ns(Optional<String> const& namespace_, FlyString const& local_name);
// Methods defined by the spec for internal use:
// FIXME: These should be taking `FlyString const&' / 'Optional<FlyString> const&'
Attr* get_attribute(StringView qualified_name, size_t* item_index = nullptr);
Attr* get_attribute_ns(StringView namespace_, StringView local_name, size_t* item_index = nullptr);
Attr const* get_attribute(StringView qualified_name, size_t* item_index = nullptr) const;
Attr const* get_attribute_ns(StringView namespace_, StringView local_name, size_t* item_index = nullptr) const;
// FIXME: These should all be taking 'Optional<FlyString> const&' for namespace instead of a StringView
Attr* get_attribute(FlyString const& qualified_name, size_t* item_index = nullptr);
Attr* get_attribute_ns(StringView namespace_, FlyString const& local_name, size_t* item_index = nullptr);
Attr const* get_attribute(FlyString const& qualified_name, size_t* item_index = nullptr) const;
Attr const* get_attribute_ns(StringView namespace_, FlyString const& local_name, size_t* item_index = nullptr) const;
WebIDL::ExceptionOr<JS::GCPtr<Attr>> set_attribute(Attr& attribute);
void replace_attribute(Attr& old_attribute, Attr& new_attribute, size_t old_attribute_index);
void append_attribute(Attr& attribute);
@ -55,9 +55,8 @@ public:
Attr* get_attribute_ns(Optional<FlyString> const& namespace_, FlyString const& local_name, size_t* item_index = nullptr);
Attr const* get_attribute_ns(Optional<FlyString> const& namespace_, FlyString const& local_name, size_t* item_index = nullptr) const;
// FIXME: This should take a 'FlyString cosnt&'
Attr const* remove_attribute(StringView qualified_name);
Attr const* remove_attribute_ns(StringView namespace_, StringView local_name);
Attr const* remove_attribute(FlyString const& qualified_name);
Attr const* remove_attribute_ns(StringView namespace_, FlyString const& local_name);
private:
explicit NamedNodeMap(Element&);