2021-09-26 15:24:41 +01:00
|
|
|
/*
|
2023-02-28 00:05:39 +00:00
|
|
|
* Copyright (c) 2021-2023, Luke Wilde <lukew@serenityos.org>
|
2024-10-04 13:19:50 +02:00
|
|
|
* Copyright (c) 2022, Andreas Kling <andreas@ladybird.org>
|
2021-09-26 15:24:41 +01:00
|
|
|
*
|
|
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
|
|
|
*/
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
2024-01-09 16:05:03 -07:00
|
|
|
#include <LibWeb/Bindings/PlatformObject.h>
|
2021-09-26 15:24:41 +01:00
|
|
|
#include <LibWeb/Forward.h>
|
|
|
|
|
|
|
|
namespace Web::HTML {
|
|
|
|
|
|
|
|
// https://html.spec.whatwg.org/multipage/dom.html#domstringmap
|
2024-01-09 16:05:03 -07:00
|
|
|
class DOMStringMap final : public Bindings::PlatformObject {
|
|
|
|
WEB_PLATFORM_OBJECT(DOMStringMap, Bindings::PlatformObject);
|
2024-11-15 04:01:23 +13:00
|
|
|
GC_DECLARE_ALLOCATOR(DOMStringMap);
|
2021-09-26 15:24:41 +01:00
|
|
|
|
2022-08-08 14:49:54 +02:00
|
|
|
public:
|
2024-11-15 04:01:23 +13:00
|
|
|
[[nodiscard]] static GC::Ref<DOMStringMap> create(DOM::Element&);
|
2021-09-26 15:24:41 +01:00
|
|
|
|
|
|
|
virtual ~DOMStringMap() override;
|
|
|
|
|
2023-11-22 09:03:44 +13:00
|
|
|
String determine_value_of_named_property(FlyString const&) const;
|
2021-09-26 15:24:41 +01:00
|
|
|
|
2023-11-21 12:15:56 +13:00
|
|
|
virtual WebIDL::ExceptionOr<void> set_value_of_new_named_property(String const&, JS::Value) override;
|
|
|
|
virtual WebIDL::ExceptionOr<void> set_value_of_existing_named_property(String const&, JS::Value) override;
|
2021-09-26 15:24:41 +01:00
|
|
|
|
2023-11-21 12:15:56 +13:00
|
|
|
virtual WebIDL::ExceptionOr<DidDeletionFail> delete_value(String const&) override;
|
2021-09-26 15:24:41 +01:00
|
|
|
|
|
|
|
private:
|
2022-08-28 13:42:07 +02:00
|
|
|
explicit DOMStringMap(DOM::Element&);
|
|
|
|
|
2023-08-07 08:41:28 +02:00
|
|
|
virtual void initialize(JS::Realm&) override;
|
2022-08-28 13:42:07 +02:00
|
|
|
virtual void visit_edges(Cell::Visitor&) override;
|
|
|
|
|
2024-01-09 16:05:03 -07:00
|
|
|
// ^PlatformObject
|
2024-07-25 17:36:10 +12:00
|
|
|
virtual JS::Value named_item_value(FlyString const&) const override;
|
2023-12-24 20:59:00 +01:00
|
|
|
virtual Vector<FlyString> supported_property_names() const override;
|
2022-10-08 12:58:56 +02:00
|
|
|
|
2021-09-26 15:24:41 +01:00
|
|
|
struct NameValuePair {
|
2023-11-22 09:03:44 +13:00
|
|
|
FlyString name;
|
|
|
|
String value;
|
2021-09-26 15:24:41 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
Vector<NameValuePair> get_name_value_pairs() const;
|
|
|
|
|
|
|
|
// https://html.spec.whatwg.org/multipage/dom.html#concept-domstringmap-element
|
2024-11-15 04:01:23 +13:00
|
|
|
GC::Ref<DOM::Element> m_associated_element;
|
2021-09-26 15:24:41 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|