2020-08-01 05:07:00 +03:00
|
|
|
/*
|
2021-04-28 23:46:44 +03:00
|
|
|
* Copyright (c) 2020, the SerenityOS developers.
|
2022-03-20 18:13:23 +03:00
|
|
|
* Copyright (c) 2021-2022, Andreas Kling <kling@serenityos.org>
|
2022-03-02 00:03:30 +03:00
|
|
|
* Copyright (c) 2022, Luke Wilde <lukew@serenityos.org>
|
2020-08-01 05:07:00 +03:00
|
|
|
*
|
2021-04-22 11:24:48 +03:00
|
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
2020-08-01 05:07:00 +03:00
|
|
|
*/
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
2021-04-20 23:52:55 +03:00
|
|
|
#include <LibWeb/HTML/FormAssociatedElement.h>
|
2020-08-01 05:07:00 +03:00
|
|
|
#include <LibWeb/HTML/HTMLElement.h>
|
2022-03-16 15:08:12 +03:00
|
|
|
#include <LibWeb/HTML/HTMLOptionsCollection.h>
|
2020-08-01 05:07:00 +03:00
|
|
|
|
|
|
|
namespace Web::HTML {
|
|
|
|
|
2022-03-24 01:55:54 +03:00
|
|
|
class HTMLSelectElement final
|
|
|
|
: public HTMLElement
|
|
|
|
, public FormAssociatedElement {
|
2022-08-28 14:42:07 +03:00
|
|
|
WEB_PLATFORM_OBJECT(HTMLSelectElement, HTMLElement);
|
2022-03-24 01:55:54 +03:00
|
|
|
FORM_ASSOCIATED_ELEMENT(HTMLElement, HTMLSelectElement)
|
|
|
|
|
2020-08-01 05:07:00 +03:00
|
|
|
public:
|
|
|
|
virtual ~HTMLSelectElement() override;
|
2021-04-20 23:52:55 +03:00
|
|
|
|
2022-09-01 21:50:16 +03:00
|
|
|
JS::GCPtr<HTMLOptionsCollection> const& options();
|
2022-03-16 15:08:12 +03:00
|
|
|
|
2022-10-18 11:22:55 +03:00
|
|
|
size_t length();
|
|
|
|
DOM::Element* item(size_t index);
|
2023-01-09 03:23:00 +03:00
|
|
|
DOM::Element* named_item(DeprecatedFlyString const& name);
|
2022-09-25 19:03:42 +03:00
|
|
|
WebIDL::ExceptionOr<void> add(HTMLOptionOrOptGroupElement element, Optional<HTMLElementOrElementIndex> before = {});
|
2022-03-22 03:03:37 +03:00
|
|
|
|
2022-03-20 18:13:23 +03:00
|
|
|
int selected_index() const;
|
|
|
|
void set_selected_index(int);
|
|
|
|
|
2022-08-28 14:42:07 +03:00
|
|
|
Vector<JS::Handle<HTMLOptionElement>> list_of_options() const;
|
2022-03-20 18:13:23 +03:00
|
|
|
|
2022-03-26 21:05:48 +03:00
|
|
|
// ^EventTarget
|
|
|
|
// https://html.spec.whatwg.org/multipage/interaction.html#the-tabindex-attribute:the-select-element
|
|
|
|
virtual bool is_focusable() const override { return true; }
|
|
|
|
|
2022-03-02 00:03:30 +03:00
|
|
|
// ^FormAssociatedElement
|
|
|
|
// https://html.spec.whatwg.org/multipage/forms.html#category-listed
|
|
|
|
virtual bool is_listed() const override { return true; }
|
|
|
|
|
|
|
|
// https://html.spec.whatwg.org/multipage/forms.html#category-submit
|
|
|
|
virtual bool is_submittable() const override { return true; }
|
|
|
|
|
|
|
|
// https://html.spec.whatwg.org/multipage/forms.html#category-reset
|
|
|
|
virtual bool is_resettable() const override { return true; }
|
|
|
|
|
|
|
|
// https://html.spec.whatwg.org/multipage/forms.html#category-autocapitalize
|
|
|
|
virtual bool is_auto_capitalize_inheriting() const override { return true; }
|
|
|
|
|
|
|
|
// ^HTMLElement
|
|
|
|
// https://html.spec.whatwg.org/multipage/forms.html#category-label
|
|
|
|
virtual bool is_labelable() const override { return true; }
|
2022-03-16 15:08:12 +03:00
|
|
|
|
2022-12-23 03:51:46 +03:00
|
|
|
virtual void reset_algorithm() override;
|
|
|
|
|
2022-12-04 21:02:33 +03:00
|
|
|
DeprecatedString const& type() const;
|
2022-11-05 07:51:42 +03:00
|
|
|
|
2023-01-29 21:12:00 +03:00
|
|
|
virtual Optional<DOM::ARIARoles::Role> default_role() const override;
|
2022-11-29 02:58:13 +03:00
|
|
|
|
2022-03-16 15:08:12 +03:00
|
|
|
private:
|
2022-08-28 14:42:07 +03:00
|
|
|
HTMLSelectElement(DOM::Document&, DOM::QualifiedName);
|
|
|
|
|
2023-01-28 20:33:35 +03:00
|
|
|
virtual JS::ThrowCompletionOr<void> initialize(JS::Realm&) override;
|
2022-09-01 21:50:16 +03:00
|
|
|
virtual void visit_edges(Cell::Visitor&) override;
|
|
|
|
|
2022-11-05 06:58:14 +03:00
|
|
|
// ^DOM::Element
|
|
|
|
virtual i32 default_tab_index_value() const override;
|
|
|
|
|
2022-09-01 21:50:16 +03:00
|
|
|
JS::GCPtr<HTMLOptionsCollection> m_options;
|
2020-08-01 05:07:00 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|