HTMLOptionsCollection.h 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839
  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/ExceptionOr.h>
  9. #include <LibWeb/DOM/HTMLCollection.h>
  10. namespace Web::HTML {
  11. using HTMLOptionOrOptGroupElement = Variant<NonnullRefPtr<HTMLOptionElement>, NonnullRefPtr<HTMLOptGroupElement>>;
  12. using HTMLElementOrElementIndex = Variant<NonnullRefPtr<HTMLElement>, i32>;
  13. class HTMLOptionsCollection final : public DOM::HTMLCollection {
  14. public:
  15. using WrapperType = Bindings::HTMLOptionsCollectionWrapper;
  16. static NonnullRefPtr<HTMLOptionsCollection> create(DOM::ParentNode& root, Function<bool(DOM::Element const&)> filter)
  17. {
  18. return adopt_ref(*new HTMLOptionsCollection(root, move(filter)));
  19. }
  20. DOM::ExceptionOr<void> add(HTMLOptionOrOptGroupElement element, Optional<HTMLElementOrElementIndex> before = {});
  21. protected:
  22. HTMLOptionsCollection(DOM::ParentNode& root, Function<bool(DOM::Element const&)> filter);
  23. };
  24. }
  25. namespace Web::Bindings {
  26. HTMLOptionsCollectionWrapper* wrap(JS::GlobalObject&, HTML::HTMLOptionsCollection&);
  27. }