DOMStringMap.h 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  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. #pragma once
  8. #include <LibWeb/Bindings/LegacyPlatformObject.h>
  9. #include <LibWeb/Forward.h>
  10. namespace Web::HTML {
  11. // https://html.spec.whatwg.org/multipage/dom.html#domstringmap
  12. class DOMStringMap final : public Bindings::LegacyPlatformObject {
  13. WEB_PLATFORM_OBJECT(DOMStringMap, Bindings::LegacyPlatformObject);
  14. JS_DECLARE_ALLOCATOR(DOMStringMap);
  15. public:
  16. [[nodiscard]] static JS::NonnullGCPtr<DOMStringMap> create(DOM::Element&);
  17. virtual ~DOMStringMap() override;
  18. DeprecatedString determine_value_of_named_property(DeprecatedString const&) const;
  19. virtual WebIDL::ExceptionOr<void> set_value_of_new_named_property(DeprecatedString const&, JS::Value) override;
  20. virtual WebIDL::ExceptionOr<void> set_value_of_existing_named_property(DeprecatedString const&, JS::Value) override;
  21. virtual WebIDL::ExceptionOr<DidDeletionFail> delete_value(DeprecatedString const&) override;
  22. private:
  23. explicit DOMStringMap(DOM::Element&);
  24. virtual void initialize(JS::Realm&) override;
  25. virtual void visit_edges(Cell::Visitor&) override;
  26. // ^LegacyPlatformObject
  27. virtual WebIDL::ExceptionOr<JS::Value> named_item_value(FlyString const&) const override;
  28. virtual Vector<String> supported_property_names() const override;
  29. virtual bool supports_indexed_properties() const override { return false; }
  30. virtual bool supports_named_properties() const override { return true; }
  31. virtual bool has_indexed_property_setter() const override { return false; }
  32. virtual bool has_named_property_setter() const override { return true; }
  33. virtual bool has_named_property_deleter() const override { return true; }
  34. virtual bool has_legacy_override_built_ins_interface_extended_attribute() const override { return true; }
  35. virtual bool has_legacy_unenumerable_named_properties_interface_extended_attribute() const override { return false; }
  36. virtual bool has_global_interface_extended_attribute() const override { return false; }
  37. virtual bool indexed_property_setter_has_identifier() const override { return false; }
  38. virtual bool named_property_setter_has_identifier() const override { return false; }
  39. virtual bool named_property_deleter_has_identifier() const override { return false; }
  40. struct NameValuePair {
  41. DeprecatedString name;
  42. DeprecatedString value;
  43. };
  44. Vector<NameValuePair> get_name_value_pairs() const;
  45. // https://html.spec.whatwg.org/multipage/dom.html#concept-domstringmap-element
  46. JS::NonnullGCPtr<DOM::Element> m_associated_element;
  47. };
  48. }