HTMLOptionsCollection.h 1.1 KB

12345678910111213141516171819202122232425262728293031323334
  1. /*
  2. * Copyright (c) 2022, the SerenityOS developers.
  3. *
  4. * SPDX-License-Identifier: BSD-2-Clause
  5. */
  6. #pragma once
  7. #include <AK/Variant.h>
  8. #include <LibWeb/DOM/HTMLCollection.h>
  9. #include <LibWeb/WebIDL/ExceptionOr.h>
  10. namespace Web::HTML {
  11. using HTMLOptionOrOptGroupElement = Variant<JS::Handle<HTMLOptionElement>, JS::Handle<HTMLOptGroupElement>>;
  12. using HTMLElementOrElementIndex = Variant<JS::Handle<HTMLElement>, i32>;
  13. class HTMLOptionsCollection final : public DOM::HTMLCollection {
  14. WEB_PLATFORM_OBJECT(HTMLOptionsCollection, DOM::HTMLCollection);
  15. JS_DECLARE_ALLOCATOR(HTMLOptionsCollection);
  16. public:
  17. [[nodiscard]] static JS::NonnullGCPtr<HTMLOptionsCollection> create(DOM::ParentNode& root, Function<bool(DOM::Element const&)> filter);
  18. virtual ~HTMLOptionsCollection() override;
  19. WebIDL::ExceptionOr<void> add(HTMLOptionOrOptGroupElement element, Optional<HTMLElementOrElementIndex> before = {});
  20. private:
  21. HTMLOptionsCollection(DOM::ParentNode& root, Function<bool(DOM::Element const&)> filter);
  22. virtual void initialize(JS::Realm&) override;
  23. };
  24. }