HTMLOptionsCollection.h 1.0 KB

123456789101112131415161718192021222324252627282930313233
  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. [[nodiscard]] 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. virtual void initialize(JS::Realm&) override;
  22. };
  23. }