2022-03-16 12:58:28 +01:00
|
|
|
/*
|
|
|
|
* Copyright (c) 2022, the SerenityOS developers.
|
|
|
|
*
|
|
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
|
|
|
*/
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
2022-03-21 20:02:40 -04:00
|
|
|
#include <AK/Variant.h>
|
2022-03-16 12:58:28 +01:00
|
|
|
#include <LibWeb/DOM/HTMLCollection.h>
|
2022-09-25 17:03:42 +01:00
|
|
|
#include <LibWeb/WebIDL/ExceptionOr.h>
|
2024-04-08 21:50:35 +02:00
|
|
|
#include <LibWeb/WebIDL/Types.h>
|
2022-03-16 12:58:28 +01:00
|
|
|
|
|
|
|
namespace Web::HTML {
|
|
|
|
|
2022-08-28 13:42:07 +02:00
|
|
|
using HTMLOptionOrOptGroupElement = Variant<JS::Handle<HTMLOptionElement>, JS::Handle<HTMLOptGroupElement>>;
|
|
|
|
using HTMLElementOrElementIndex = Variant<JS::Handle<HTMLElement>, i32>;
|
2022-03-21 20:02:40 -04:00
|
|
|
|
2022-03-16 12:58:28 +01:00
|
|
|
class HTMLOptionsCollection final : public DOM::HTMLCollection {
|
2022-09-01 20:50:16 +02:00
|
|
|
WEB_PLATFORM_OBJECT(HTMLOptionsCollection, DOM::HTMLCollection);
|
2023-11-19 19:47:52 +01:00
|
|
|
JS_DECLARE_ALLOCATOR(HTMLOptionsCollection);
|
2022-03-16 12:58:28 +01:00
|
|
|
|
2022-09-01 20:50:16 +02:00
|
|
|
public:
|
2023-08-13 13:05:26 +02:00
|
|
|
[[nodiscard]] static JS::NonnullGCPtr<HTMLOptionsCollection> create(DOM::ParentNode& root, Function<bool(DOM::Element const&)> filter);
|
2022-09-01 20:50:16 +02:00
|
|
|
virtual ~HTMLOptionsCollection() override;
|
2022-03-16 12:58:28 +01:00
|
|
|
|
2024-04-08 21:50:35 +02:00
|
|
|
WebIDL::ExceptionOr<void> set_length(WebIDL::UnsignedLong);
|
|
|
|
|
2022-09-25 17:03:42 +01:00
|
|
|
WebIDL::ExceptionOr<void> add(HTMLOptionOrOptGroupElement element, Optional<HTMLElementOrElementIndex> before = {});
|
2022-03-21 20:02:40 -04:00
|
|
|
|
2024-04-08 21:56:33 +02:00
|
|
|
void remove(WebIDL::Long);
|
|
|
|
|
2024-04-08 21:53:22 +02:00
|
|
|
WebIDL::Long selected_index() const;
|
|
|
|
void set_selected_index(WebIDL::Long);
|
|
|
|
|
2022-09-01 20:50:16 +02:00
|
|
|
private:
|
2022-03-16 12:58:28 +01:00
|
|
|
HTMLOptionsCollection(DOM::ParentNode& root, Function<bool(DOM::Element const&)> filter);
|
2023-01-10 06:28:20 -05:00
|
|
|
|
2023-08-07 08:41:28 +02:00
|
|
|
virtual void initialize(JS::Realm&) override;
|
2022-03-16 12:58:28 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|