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

LibWeb: Use Optional<FlyString> const& in Element and NamedNodeMap

This is enabled with the newly added IDL generator support for
FlyStrings.
This commit is contained in:
Shannon Booth 2024-01-02 23:49:13 +13:00 committed by Andreas Kling
parent 8ba3caf6ab
commit 285bca1633
6 changed files with 28 additions and 70 deletions

View file

@ -9,7 +9,6 @@
#pragma once
#include <AK/StringView.h>
#include <LibWeb/Bindings/LegacyPlatformObject.h>
#include <LibWeb/Forward.h>
#include <LibWeb/WebIDL/ExceptionOr.h>
@ -36,18 +35,15 @@ public:
// Methods defined by the spec for JavaScript:
Attr const* item(u32 index) 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;
Attr const* get_named_item_ns(Optional<FlyString> 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(FlyString const& qualified_name);
WebIDL::ExceptionOr<Attr const*> remove_named_item_ns(Optional<String> const& namespace_, FlyString const& local_name);
WebIDL::ExceptionOr<Attr const*> remove_named_item_ns(Optional<FlyString> const& namespace_, FlyString const& local_name);
// Methods defined by the spec for internal use:
// 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);
@ -56,7 +52,7 @@ public:
Attr const* get_attribute_ns(Optional<FlyString> const& namespace_, FlyString const& local_name, size_t* item_index = nullptr) const;
Attr const* remove_attribute(FlyString const& qualified_name);
Attr const* remove_attribute_ns(StringView namespace_, FlyString const& local_name);
Attr const* remove_attribute_ns(Optional<FlyString> const& namespace_, FlyString const& local_name);
private:
explicit NamedNodeMap(Element&);