Serenity Operating System
at master 64 lines 2.7 kB view raw
1/* 2 * Copyright (c) 2021-2023, Luke Wilde <lukew@serenityos.org> 3 * Copyright (c) 2022, Andreas Kling <kling@serenityos.org> 4 * 5 * SPDX-License-Identifier: BSD-2-Clause 6 */ 7 8#pragma once 9 10#include <LibWeb/Bindings/LegacyPlatformObject.h> 11#include <LibWeb/Forward.h> 12 13namespace Web::HTML { 14 15// https://html.spec.whatwg.org/multipage/dom.html#domstringmap 16class DOMStringMap final : public Bindings::LegacyPlatformObject { 17 WEB_PLATFORM_OBJECT(DOMStringMap, Bindings::LegacyPlatformObject); 18 19public: 20 static WebIDL::ExceptionOr<JS::NonnullGCPtr<DOMStringMap>> create(DOM::Element&); 21 22 virtual ~DOMStringMap() override; 23 24 DeprecatedString determine_value_of_named_property(DeprecatedString const&) const; 25 26 virtual WebIDL::ExceptionOr<void> set_value_of_new_named_property(DeprecatedString const&, JS::Value) override; 27 virtual WebIDL::ExceptionOr<void> set_value_of_existing_named_property(DeprecatedString const&, JS::Value) override; 28 29 virtual WebIDL::ExceptionOr<DidDeletionFail> delete_value(DeprecatedString const&) override; 30 31private: 32 explicit DOMStringMap(DOM::Element&); 33 34 virtual JS::ThrowCompletionOr<void> initialize(JS::Realm&) override; 35 virtual void visit_edges(Cell::Visitor&) override; 36 37 // ^LegacyPlatformObject 38 virtual WebIDL::ExceptionOr<JS::Value> named_item_value(DeprecatedFlyString const&) const override; 39 virtual Vector<DeprecatedString> supported_property_names() const override; 40 41 virtual bool supports_indexed_properties() const override { return false; } 42 virtual bool supports_named_properties() const override { return true; } 43 virtual bool has_indexed_property_setter() const override { return false; } 44 virtual bool has_named_property_setter() const override { return true; } 45 virtual bool has_named_property_deleter() const override { return true; } 46 virtual bool has_legacy_override_built_ins_interface_extended_attribute() const override { return true; } 47 virtual bool has_legacy_unenumerable_named_properties_interface_extended_attribute() const override { return false; } 48 virtual bool has_global_interface_extended_attribute() const override { return false; } 49 virtual bool indexed_property_setter_has_identifier() const override { return false; } 50 virtual bool named_property_setter_has_identifier() const override { return false; } 51 virtual bool named_property_deleter_has_identifier() const override { return false; } 52 53 struct NameValuePair { 54 DeprecatedString name; 55 DeprecatedString value; 56 }; 57 58 Vector<NameValuePair> get_name_value_pairs() const; 59 60 // https://html.spec.whatwg.org/multipage/dom.html#concept-domstringmap-element 61 JS::NonnullGCPtr<DOM::Element> m_associated_element; 62}; 63 64}