DOMRectList.h 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. /*
  2. * Copyright (c) 2022, DerpyCrabs <derpycrabs@gmail.com>
  3. * Copyright (c) 2023, Luke Wilde <lukew@serenityos.org>
  4. *
  5. * SPDX-License-Identifier: BSD-2-Clause
  6. */
  7. #pragma once
  8. #include <AK/Vector.h>
  9. #include <LibWeb/Bindings/LegacyPlatformObject.h>
  10. #include <LibWeb/Geometry/DOMRect.h>
  11. namespace Web::Geometry {
  12. // https://drafts.fxtf.org/geometry-1/#DOMRectList
  13. class DOMRectList final : public Bindings::LegacyPlatformObject {
  14. WEB_PLATFORM_OBJECT(DOMRectList, Bindings::LegacyPlatformObject);
  15. public:
  16. static WebIDL::ExceptionOr<JS::NonnullGCPtr<DOMRectList>> create(JS::Realm&, Vector<JS::Handle<DOMRect>>);
  17. virtual ~DOMRectList() override;
  18. u32 length() const;
  19. DOMRect const* item(u32 index) const;
  20. virtual bool is_supported_property_index(u32) const override;
  21. virtual WebIDL::ExceptionOr<JS::Value> item_value(size_t index) const override;
  22. private:
  23. DOMRectList(JS::Realm&, Vector<JS::NonnullGCPtr<DOMRect>>);
  24. virtual JS::ThrowCompletionOr<void> initialize(JS::Realm&) override;
  25. // ^Bindings::LegacyPlatformObject
  26. virtual bool supports_indexed_properties() const override { return true; }
  27. virtual bool supports_named_properties() const override { return false; }
  28. virtual bool has_indexed_property_setter() const override { return false; }
  29. virtual bool has_named_property_setter() const override { return false; }
  30. virtual bool has_named_property_deleter() const override { return false; }
  31. virtual bool has_legacy_override_built_ins_interface_extended_attribute() const override { return false; }
  32. virtual bool has_legacy_unenumerable_named_properties_interface_extended_attribute() const override { return false; }
  33. virtual bool has_global_interface_extended_attribute() const override { return false; }
  34. virtual bool indexed_property_setter_has_identifier() const override { return false; }
  35. virtual bool named_property_setter_has_identifier() const override { return false; }
  36. virtual bool named_property_deleter_has_identifier() const override { return false; }
  37. Vector<JS::NonnullGCPtr<DOMRect>> m_rects;
  38. };
  39. }