DOMStringMap.h 2.6 KB

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