HTMLOptionsCollection.h 973 B

12345678910111213141516171819202122232425262728293031
  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. public:
  16. static JS::NonnullGCPtr<HTMLOptionsCollection> create(DOM::ParentNode& root, Function<bool(DOM::Element const&)> filter);
  17. virtual ~HTMLOptionsCollection() override;
  18. WebIDL::ExceptionOr<void> add(HTMLOptionOrOptGroupElement element, Optional<HTMLElementOrElementIndex> before = {});
  19. private:
  20. HTMLOptionsCollection(DOM::ParentNode& root, Function<bool(DOM::Element const&)> filter);
  21. };
  22. }