2020-01-18 05:38:21 -03:00
|
|
|
/*
|
2024-10-04 08:19:50 -03:00
|
|
|
* Copyright (c) 2018-2022, Andreas Kling <andreas@ladybird.org>
|
2022-02-17 18:22:36 -03:00
|
|
|
* Copyright (c) 2022, Adam Hodgen <ant1441@gmail.com>
|
2023-12-11 14:00:06 -03:00
|
|
|
* Copyright (c) 2023, Bastiaan van der Plaat <bastiaan.v.d.plaat@gmail.com>
|
2024-11-01 08:14:53 -03:00
|
|
|
* Copyright (c) 2024, Jelle Raaijmakers <jelle@ladybird.org>
|
2020-01-18 05:38:21 -03:00
|
|
|
*
|
2021-04-22 05:24:48 -03:00
|
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
2020-01-18 05:38:21 -03:00
|
|
|
*/
|
|
|
|
|
|
2019-11-25 17:21:55 -03:00
|
|
|
#pragma once
|
|
|
|
|
|
2024-02-18 23:12:14 -03:00
|
|
|
#include <LibWeb/DOM/DocumentLoadEventDelayer.h>
|
2023-08-30 10:38:58 -03:00
|
|
|
#include <LibWeb/DOM/Text.h>
|
2022-10-04 02:39:53 -03:00
|
|
|
#include <LibWeb/FileAPI/FileList.h>
|
2024-03-02 14:06:44 -03:00
|
|
|
#include <LibWeb/HTML/ColorPickerUpdateState.h>
|
2024-03-14 13:26:00 -03:00
|
|
|
#include <LibWeb/HTML/FileFilter.h>
|
2021-04-20 06:50:29 -03:00
|
|
|
#include <LibWeb/HTML/FormAssociatedElement.h>
|
2020-07-26 10:08:16 -03:00
|
|
|
#include <LibWeb/HTML/HTMLElement.h>
|
2024-02-18 23:12:14 -03:00
|
|
|
#include <LibWeb/Layout/ImageProvider.h>
|
2022-10-04 02:39:53 -03:00
|
|
|
#include <LibWeb/WebIDL/DOMException.h>
|
2024-03-01 04:49:04 -03:00
|
|
|
#include <LibWeb/WebIDL/Types.h>
|
2019-11-25 17:21:55 -03:00
|
|
|
|
2020-07-28 13:20:36 -03:00
|
|
|
namespace Web::HTML {
|
2020-03-07 06:27:02 -03:00
|
|
|
|
2022-02-17 18:22:36 -03:00
|
|
|
// https://html.spec.whatwg.org/multipage/input.html#attr-input-type
|
2022-02-17 20:05:46 -03:00
|
|
|
#define ENUMERATE_HTML_INPUT_TYPE_ATTRIBUTES \
|
2024-09-10 06:43:22 -03:00
|
|
|
__ENUMERATE_HTML_INPUT_TYPE_ATTRIBUTE("hidden", Hidden) \
|
|
|
|
|
__ENUMERATE_HTML_INPUT_TYPE_ATTRIBUTE("text", Text) \
|
|
|
|
|
__ENUMERATE_HTML_INPUT_TYPE_ATTRIBUTE("search", Search) \
|
|
|
|
|
__ENUMERATE_HTML_INPUT_TYPE_ATTRIBUTE("tel", Telephone) \
|
|
|
|
|
__ENUMERATE_HTML_INPUT_TYPE_ATTRIBUTE("url", URL) \
|
|
|
|
|
__ENUMERATE_HTML_INPUT_TYPE_ATTRIBUTE("email", Email) \
|
|
|
|
|
__ENUMERATE_HTML_INPUT_TYPE_ATTRIBUTE("password", Password) \
|
|
|
|
|
__ENUMERATE_HTML_INPUT_TYPE_ATTRIBUTE("date", Date) \
|
|
|
|
|
__ENUMERATE_HTML_INPUT_TYPE_ATTRIBUTE("month", Month) \
|
|
|
|
|
__ENUMERATE_HTML_INPUT_TYPE_ATTRIBUTE("week", Week) \
|
|
|
|
|
__ENUMERATE_HTML_INPUT_TYPE_ATTRIBUTE("time", Time) \
|
2022-02-17 20:05:46 -03:00
|
|
|
__ENUMERATE_HTML_INPUT_TYPE_ATTRIBUTE("datetime-local", LocalDateAndTime) \
|
2024-09-10 06:43:22 -03:00
|
|
|
__ENUMERATE_HTML_INPUT_TYPE_ATTRIBUTE("number", Number) \
|
|
|
|
|
__ENUMERATE_HTML_INPUT_TYPE_ATTRIBUTE("range", Range) \
|
|
|
|
|
__ENUMERATE_HTML_INPUT_TYPE_ATTRIBUTE("color", Color) \
|
|
|
|
|
__ENUMERATE_HTML_INPUT_TYPE_ATTRIBUTE("checkbox", Checkbox) \
|
|
|
|
|
__ENUMERATE_HTML_INPUT_TYPE_ATTRIBUTE("radio", RadioButton) \
|
|
|
|
|
__ENUMERATE_HTML_INPUT_TYPE_ATTRIBUTE("file", FileUpload) \
|
|
|
|
|
__ENUMERATE_HTML_INPUT_TYPE_ATTRIBUTE("submit", SubmitButton) \
|
|
|
|
|
__ENUMERATE_HTML_INPUT_TYPE_ATTRIBUTE("image", ImageButton) \
|
|
|
|
|
__ENUMERATE_HTML_INPUT_TYPE_ATTRIBUTE("reset", ResetButton) \
|
|
|
|
|
__ENUMERATE_HTML_INPUT_TYPE_ATTRIBUTE("button", Button)
|
2022-02-17 18:22:36 -03:00
|
|
|
|
2022-03-23 19:55:54 -03:00
|
|
|
class HTMLInputElement final
|
|
|
|
|
: public HTMLElement
|
2024-08-30 13:22:58 -03:00
|
|
|
, public FormAssociatedTextControlElement
|
2024-02-18 23:12:14 -03:00
|
|
|
, public Layout::ImageProvider {
|
2022-08-28 08:42:07 -03:00
|
|
|
WEB_PLATFORM_OBJECT(HTMLInputElement, HTMLElement);
|
2024-11-14 12:01:23 -03:00
|
|
|
GC_DECLARE_ALLOCATOR(HTMLInputElement);
|
2022-03-23 19:55:54 -03:00
|
|
|
FORM_ASSOCIATED_ELEMENT(HTMLElement, HTMLInputElement)
|
|
|
|
|
|
2019-11-25 17:21:55 -03:00
|
|
|
public:
|
|
|
|
|
virtual ~HTMLInputElement() override;
|
|
|
|
|
|
2024-11-14 12:01:23 -03:00
|
|
|
virtual GC::Ptr<Layout::Node> create_layout_node(CSS::StyleProperties) override;
|
2024-03-07 17:27:37 -03:00
|
|
|
virtual void adjust_computed_style(CSS::StyleProperties&) override;
|
2019-11-25 17:21:55 -03:00
|
|
|
|
2022-03-26 14:59:58 -03:00
|
|
|
enum class TypeAttributeState {
|
2022-02-17 20:05:46 -03:00
|
|
|
#define __ENUMERATE_HTML_INPUT_TYPE_ATTRIBUTE(_, state) state,
|
|
|
|
|
ENUMERATE_HTML_INPUT_TYPE_ATTRIBUTES
|
|
|
|
|
#undef __ENUMERATE_HTML_INPUT_TYPE_ATTRIBUTE
|
|
|
|
|
};
|
|
|
|
|
|
2023-09-03 01:27:10 -03:00
|
|
|
StringView type() const;
|
2022-03-16 08:46:17 -03:00
|
|
|
TypeAttributeState type_state() const { return m_type; }
|
2023-09-03 01:27:10 -03:00
|
|
|
WebIDL::ExceptionOr<void> set_type(String const&);
|
2022-02-17 09:12:01 -03:00
|
|
|
|
2024-01-16 15:04:45 -03:00
|
|
|
String default_value() const { return get_attribute_value(HTML::AttributeNames::value); }
|
2020-09-11 13:17:39 -03:00
|
|
|
|
2023-11-20 04:32:40 -03:00
|
|
|
virtual String value() const override;
|
2023-09-03 01:27:10 -03:00
|
|
|
WebIDL::ExceptionOr<void> set_value(String const&);
|
2021-02-10 14:26:07 -03:00
|
|
|
|
2024-08-30 13:22:58 -03:00
|
|
|
// https://html.spec.whatwg.org/multipage/form-control-infrastructure.html#concept-textarea/input-relevant-value
|
|
|
|
|
virtual String relevant_value() override { return value(); }
|
2024-08-30 13:22:58 -03:00
|
|
|
WebIDL::ExceptionOr<void> set_relevant_value(String const& value) override { return set_value(value); }
|
|
|
|
|
|
|
|
|
|
virtual void set_dirty_value_flag(bool flag) override { m_dirty_value = flag; }
|
2024-08-30 13:22:58 -03:00
|
|
|
|
2023-11-30 14:54:30 -03:00
|
|
|
void commit_pending_changes();
|
|
|
|
|
|
2023-12-10 15:33:37 -03:00
|
|
|
String placeholder() const;
|
2024-03-15 13:40:40 -03:00
|
|
|
Optional<String> placeholder_value() const;
|
2022-12-01 00:15:12 -03:00
|
|
|
|
2020-09-11 13:17:39 -03:00
|
|
|
bool checked() const { return m_checked; }
|
2022-02-15 15:16:57 -03:00
|
|
|
enum class ChangeSource {
|
|
|
|
|
Programmatic,
|
|
|
|
|
User,
|
|
|
|
|
};
|
2022-03-14 20:05:55 -03:00
|
|
|
void set_checked(bool, ChangeSource = ChangeSource::Programmatic);
|
2020-09-12 12:56:11 -03:00
|
|
|
|
2022-03-14 22:13:05 -03:00
|
|
|
bool checked_binding() const { return checked(); }
|
|
|
|
|
void set_checked_binding(bool);
|
|
|
|
|
|
2023-07-07 23:48:11 -03:00
|
|
|
bool indeterminate() const { return m_indeterminate; }
|
2023-03-20 05:34:43 -03:00
|
|
|
void set_indeterminate(bool);
|
|
|
|
|
|
2023-09-02 09:17:37 -03:00
|
|
|
bool is_mutable() const { return m_is_mutable; }
|
|
|
|
|
|
2024-03-02 14:06:44 -03:00
|
|
|
void did_pick_color(Optional<Color> picked_color, ColorPickerUpdateState state);
|
2024-02-25 15:02:47 -03:00
|
|
|
|
2024-10-10 21:10:37 -03:00
|
|
|
enum class MultipleHandling {
|
|
|
|
|
Replace,
|
|
|
|
|
Append,
|
|
|
|
|
};
|
|
|
|
|
void did_select_files(Span<SelectedFile> selected_files, MultipleHandling = MultipleHandling::Replace);
|
2023-09-04 06:32:40 -03:00
|
|
|
|
2024-11-14 12:01:23 -03:00
|
|
|
GC::Ptr<FileAPI::FileList> files();
|
|
|
|
|
void set_files(GC::Ptr<FileAPI::FileList>);
|
2022-10-04 02:39:53 -03:00
|
|
|
|
2024-03-14 13:26:00 -03:00
|
|
|
FileFilter parse_accept_attribute() const;
|
|
|
|
|
|
2022-10-04 02:39:53 -03:00
|
|
|
// NOTE: User interaction
|
|
|
|
|
// https://html.spec.whatwg.org/multipage/input.html#update-the-file-selection
|
2024-11-14 12:01:23 -03:00
|
|
|
void update_the_file_selection(GC::Ref<FileAPI::FileList>);
|
2022-10-04 02:39:53 -03:00
|
|
|
|
2024-03-01 04:49:04 -03:00
|
|
|
WebIDL::Long max_length() const;
|
|
|
|
|
WebIDL::ExceptionOr<void> set_max_length(WebIDL::Long);
|
|
|
|
|
|
|
|
|
|
WebIDL::Long min_length() const;
|
|
|
|
|
WebIDL::ExceptionOr<void> set_min_length(WebIDL::Long);
|
|
|
|
|
|
2024-11-28 11:33:53 -03:00
|
|
|
WebIDL::UnsignedLong size() const;
|
|
|
|
|
WebIDL::ExceptionOr<void> set_size(WebIDL::UnsignedLong value);
|
2023-11-24 13:37:53 -03:00
|
|
|
|
2024-11-29 14:56:24 -03:00
|
|
|
WebIDL::UnsignedLong height() const;
|
|
|
|
|
WebIDL::ExceptionOr<void> set_height(WebIDL::UnsignedLong value);
|
|
|
|
|
|
2024-11-29 14:45:07 -03:00
|
|
|
WebIDL::UnsignedLong width() const;
|
|
|
|
|
WebIDL::ExceptionOr<void> set_width(WebIDL::UnsignedLong value);
|
|
|
|
|
|
2024-02-19 02:21:27 -03:00
|
|
|
struct SelectedCoordinate {
|
2024-02-19 09:44:11 -03:00
|
|
|
int x { 0 };
|
|
|
|
|
int y { 0 };
|
2024-02-19 02:21:27 -03:00
|
|
|
};
|
|
|
|
|
SelectedCoordinate selected_coordinate() const { return m_selected_coordinate; }
|
|
|
|
|
|
2023-12-15 14:23:29 -03:00
|
|
|
JS::Object* value_as_date() const;
|
2024-11-14 12:01:23 -03:00
|
|
|
WebIDL::ExceptionOr<void> set_value_as_date(Optional<GC::Root<JS::Object>> const&);
|
2023-12-15 14:23:29 -03:00
|
|
|
|
|
|
|
|
double value_as_number() const;
|
2023-10-04 17:40:31 -03:00
|
|
|
WebIDL::ExceptionOr<void> set_value_as_number(double value);
|
|
|
|
|
|
2024-02-26 14:54:36 -03:00
|
|
|
WebIDL::ExceptionOr<void> step_up(WebIDL::Long n = 1);
|
|
|
|
|
WebIDL::ExceptionOr<void> step_down(WebIDL::Long n = 1);
|
2023-12-07 15:35:45 -03:00
|
|
|
|
2023-03-04 19:58:25 -03:00
|
|
|
WebIDL::ExceptionOr<bool> check_validity();
|
|
|
|
|
WebIDL::ExceptionOr<bool> report_validity();
|
2023-09-03 01:27:10 -03:00
|
|
|
void set_custom_validity(String const&);
|
2023-03-04 19:58:25 -03:00
|
|
|
|
2022-10-04 02:39:53 -03:00
|
|
|
WebIDL::ExceptionOr<void> show_picker();
|
|
|
|
|
|
2022-03-26 15:02:41 -03:00
|
|
|
// ^EventTarget
|
|
|
|
|
// https://html.spec.whatwg.org/multipage/interaction.html#the-tabindex-attribute:the-input-element
|
2024-11-02 15:17:20 -03:00
|
|
|
// https://html.spec.whatwg.org/multipage/interaction.html#focusable-area
|
|
|
|
|
// https://html.spec.whatwg.org/multipage/semantics-other.html#concept-element-disabled
|
|
|
|
|
virtual bool is_focusable() const override;
|
2022-02-06 15:27:10 -03:00
|
|
|
|
2022-03-01 18: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; }
|
|
|
|
|
|
2023-06-18 11:08:15 -03:00
|
|
|
// https://html.spec.whatwg.org/multipage/forms.html#concept-button
|
|
|
|
|
virtual bool is_button() const override;
|
|
|
|
|
|
|
|
|
|
// https://html.spec.whatwg.org/multipage/forms.html#concept-submit-button
|
|
|
|
|
virtual bool is_submit_button() const override;
|
|
|
|
|
|
2024-07-07 13:05:13 -03:00
|
|
|
bool is_single_line() const;
|
|
|
|
|
|
2022-12-22 21:33:37 -03:00
|
|
|
virtual void reset_algorithm() override;
|
2024-10-11 11:38:43 -03:00
|
|
|
virtual void clear_algorithm() override;
|
2022-12-22 21:33:37 -03:00
|
|
|
|
2022-03-23 19:55:54 -03:00
|
|
|
virtual void form_associated_element_was_inserted() override;
|
2023-11-29 20:22:16 -03:00
|
|
|
virtual void form_associated_element_was_removed(DOM::Node*) override;
|
2024-02-03 11:33:33 -03:00
|
|
|
virtual void form_associated_element_attribute_changed(FlyString const&, Optional<String> const&) override;
|
2022-03-23 19:55:54 -03:00
|
|
|
|
2024-08-21 08:19:37 -03:00
|
|
|
virtual WebIDL::ExceptionOr<void> cloned(Node&, bool) override;
|
|
|
|
|
|
2024-11-14 12:01:23 -03:00
|
|
|
GC::Ref<ValidityState const> validity() const;
|
2024-06-09 00:13:38 -03:00
|
|
|
|
2022-03-01 18:03:30 -03:00
|
|
|
// ^HTMLElement
|
|
|
|
|
// https://html.spec.whatwg.org/multipage/forms.html#category-label
|
|
|
|
|
virtual bool is_labelable() const override { return type_state() != TypeAttributeState::Hidden; }
|
|
|
|
|
|
2023-01-28 19:23:16 -03:00
|
|
|
virtual Optional<ARIA::Role> default_role() const override;
|
2022-11-28 20:58:13 -03:00
|
|
|
|
2024-11-14 12:01:23 -03:00
|
|
|
GC::Ptr<Element> placeholder_element() { return m_placeholder_element; }
|
|
|
|
|
GC::Ptr<Element const> placeholder_element() const { return m_placeholder_element; }
|
2023-05-25 07:34:54 -03:00
|
|
|
|
2023-11-18 06:48:09 -03:00
|
|
|
virtual bool has_activation_behavior() const override;
|
|
|
|
|
virtual void activation_behavior(DOM::Event const&) override;
|
|
|
|
|
|
2023-12-03 10:24:16 -03:00
|
|
|
bool has_input_activation_behavior() const;
|
|
|
|
|
bool change_event_applies() const;
|
2023-12-15 14:23:29 -03:00
|
|
|
bool value_as_date_applies() const;
|
2023-12-07 15:31:42 -03:00
|
|
|
bool value_as_number_applies() const;
|
2023-12-07 15:35:45 -03:00
|
|
|
bool step_applies() const;
|
|
|
|
|
bool step_up_or_down_applies() const;
|
2024-08-22 10:20:24 -03:00
|
|
|
bool select_applies() const;
|
2024-07-28 01:41:45 -03:00
|
|
|
bool selection_or_range_applies() const;
|
2024-10-04 08:12:39 -03:00
|
|
|
bool selection_direction_applies() const;
|
2024-09-18 11:34:40 -03:00
|
|
|
bool has_selectable_text() const;
|
2024-07-28 01:41:45 -03:00
|
|
|
|
2024-09-10 05:24:00 -03:00
|
|
|
static bool selection_or_range_applies_for_type_state(TypeAttributeState);
|
|
|
|
|
|
2024-10-04 08:12:39 -03:00
|
|
|
Optional<String> selection_direction_binding() { return selection_direction(); }
|
|
|
|
|
|
2024-11-06 12:46:50 -03:00
|
|
|
// ^FormAssociatedTextControlElement
|
|
|
|
|
virtual void did_edit_text_node() override;
|
2024-11-14 12:01:23 -03:00
|
|
|
virtual GC::Ptr<DOM::Text> form_associated_element_to_text_node() override { return m_text_node; }
|
2024-08-26 09:08:40 -03:00
|
|
|
|
2020-09-11 13:17:39 -03:00
|
|
|
private:
|
2022-08-28 08:42:07 -03:00
|
|
|
HTMLInputElement(DOM::Document&, DOM::QualifiedName);
|
|
|
|
|
|
2024-09-10 05:24:00 -03:00
|
|
|
void type_attribute_changed(TypeAttributeState old_state, TypeAttributeState new_state);
|
|
|
|
|
|
2024-10-01 13:26:01 -03:00
|
|
|
virtual void apply_presentational_hints(CSS::StyleProperties&) const override;
|
|
|
|
|
|
2023-03-10 17:16:18 -03:00
|
|
|
// ^DOM::Node
|
|
|
|
|
virtual bool is_html_input_element() const final { return true; }
|
|
|
|
|
|
2022-02-06 15:27:10 -03:00
|
|
|
// ^DOM::EventTarget
|
2023-05-29 13:41:32 -03:00
|
|
|
virtual void did_lose_focus() override;
|
2022-02-06 15:27:10 -03:00
|
|
|
virtual void did_receive_focus() override;
|
2022-03-14 20:05:55 -03:00
|
|
|
virtual void legacy_pre_activation_behavior() override;
|
|
|
|
|
virtual void legacy_cancelled_activation_behavior() override;
|
|
|
|
|
virtual void legacy_cancelled_activation_behavior_was_not_called() override;
|
2022-02-06 15:27:10 -03:00
|
|
|
|
2022-11-05 00:58:14 -03:00
|
|
|
// ^DOM::Element
|
|
|
|
|
virtual i32 default_tab_index_value() const override;
|
2024-07-11 17:47:25 -03:00
|
|
|
virtual void computed_css_values_changed() override;
|
2024-04-10 22:44:11 -03:00
|
|
|
|
|
|
|
|
// https://html.spec.whatwg.org/multipage/input.html#image-button-state-(type=image):dimension-attributes
|
|
|
|
|
virtual bool supports_dimension_attributes() const override { return type_state() == TypeAttributeState::ImageButton; }
|
2022-11-05 00:58:14 -03:00
|
|
|
|
2024-02-18 23:12:14 -03:00
|
|
|
// ^Layout::ImageProvider
|
|
|
|
|
virtual bool is_image_available() const override;
|
|
|
|
|
virtual Optional<CSSPixels> intrinsic_width() const override;
|
|
|
|
|
virtual Optional<CSSPixels> intrinsic_height() const override;
|
|
|
|
|
virtual Optional<CSSPixelFraction> intrinsic_aspect_ratio() const override;
|
|
|
|
|
virtual RefPtr<Gfx::ImmutableBitmap> current_image_bitmap(Gfx::IntSize = {}) const override;
|
|
|
|
|
virtual void set_visible_in_viewport(bool) override;
|
2024-11-14 12:01:23 -03:00
|
|
|
virtual GC::Ref<DOM::Element const> to_html_element() const override { return *this; }
|
2024-02-18 23:12:14 -03:00
|
|
|
|
2023-08-07 03:41:28 -03:00
|
|
|
virtual void initialize(JS::Realm&) override;
|
2022-08-28 08:42:07 -03:00
|
|
|
virtual void visit_edges(Cell::Visitor&) override;
|
|
|
|
|
|
2023-12-07 15:29:32 -03:00
|
|
|
Optional<double> convert_string_to_number(StringView input) const;
|
2024-04-03 13:17:24 -03:00
|
|
|
String convert_number_to_string(double input) const;
|
2023-12-07 15:29:32 -03:00
|
|
|
|
2024-11-14 12:01:23 -03:00
|
|
|
WebIDL::ExceptionOr<GC::Ptr<JS::Date>> convert_string_to_date(StringView input) const;
|
|
|
|
|
String covert_date_to_string(GC::Ref<JS::Date> input) const;
|
2023-12-15 14:23:29 -03:00
|
|
|
|
2023-12-07 15:35:45 -03:00
|
|
|
Optional<double> min() const;
|
|
|
|
|
Optional<double> max() const;
|
|
|
|
|
double default_step() const;
|
|
|
|
|
double step_scale_factor() const;
|
|
|
|
|
Optional<double> allowed_value_step() const;
|
|
|
|
|
double step_base() const;
|
2024-02-26 14:54:36 -03:00
|
|
|
WebIDL::ExceptionOr<void> step_up_or_down(bool is_down, WebIDL::Long n);
|
2023-12-07 15:35:45 -03:00
|
|
|
|
2022-03-16 08:44:21 -03:00
|
|
|
static TypeAttributeState parse_type_attribute(StringView);
|
2021-02-10 14:26:07 -03:00
|
|
|
void create_shadow_tree_if_needed();
|
2024-02-25 12:43:17 -03:00
|
|
|
void update_shadow_tree();
|
2024-06-13 14:04:41 -03:00
|
|
|
void create_button_input_shadow_tree();
|
2023-10-13 16:06:34 -03:00
|
|
|
void create_text_input_shadow_tree();
|
2023-10-14 07:00:40 -03:00
|
|
|
void create_color_input_shadow_tree();
|
2024-02-25 12:54:37 -03:00
|
|
|
void create_file_input_shadow_tree();
|
2023-12-11 14:00:06 -03:00
|
|
|
void create_range_input_shadow_tree();
|
2024-01-18 16:58:22 -03:00
|
|
|
WebIDL::ExceptionOr<void> run_input_activation_behavior(DOM::Event const&);
|
2022-03-14 20:05:55 -03:00
|
|
|
void set_checked_within_group();
|
2021-02-10 14:26:07 -03:00
|
|
|
|
2024-03-01 04:49:04 -03:00
|
|
|
void handle_maxlength_attribute();
|
2023-11-04 20:17:24 -03:00
|
|
|
void handle_readonly_attribute(Optional<String> const& value);
|
2024-04-04 13:56:37 -03:00
|
|
|
WebIDL::ExceptionOr<void> handle_src_attribute(String const& value);
|
2023-09-02 09:07:58 -03:00
|
|
|
|
2024-05-18 01:45:13 -03:00
|
|
|
void user_interaction_did_change_input_value();
|
|
|
|
|
|
2022-02-17 20:05:46 -03:00
|
|
|
// https://html.spec.whatwg.org/multipage/input.html#value-sanitization-algorithm
|
2023-11-20 04:32:40 -03:00
|
|
|
String value_sanitization_algorithm(String const&) const;
|
2022-02-17 20:05:46 -03:00
|
|
|
|
2024-02-17 18:27:41 -03:00
|
|
|
enum class ValueAttributeMode {
|
|
|
|
|
Value,
|
|
|
|
|
Default,
|
|
|
|
|
DefaultOn,
|
|
|
|
|
Filename,
|
|
|
|
|
};
|
2024-09-10 05:24:00 -03:00
|
|
|
static ValueAttributeMode value_attribute_mode_for_type_state(TypeAttributeState);
|
2024-02-17 18:27:41 -03:00
|
|
|
ValueAttributeMode value_attribute_mode() const;
|
|
|
|
|
|
2023-05-25 07:34:54 -03:00
|
|
|
void update_placeholder_visibility();
|
2024-11-14 12:01:23 -03:00
|
|
|
GC::Ptr<DOM::Element> m_placeholder_element;
|
|
|
|
|
GC::Ptr<DOM::Text> m_placeholder_text_node;
|
2023-05-25 07:34:54 -03:00
|
|
|
|
2024-04-04 13:37:27 -03:00
|
|
|
void update_text_input_shadow_tree();
|
2024-11-14 12:01:23 -03:00
|
|
|
GC::Ptr<DOM::Element> m_inner_text_element;
|
|
|
|
|
GC::Ptr<DOM::Text> m_text_node;
|
2020-09-11 13:17:39 -03:00
|
|
|
bool m_checked { false };
|
2022-02-15 15:16:57 -03:00
|
|
|
|
2024-01-18 16:17:47 -03:00
|
|
|
void update_color_well_element();
|
2024-11-14 12:01:23 -03:00
|
|
|
GC::Ptr<DOM::Element> m_color_well_element;
|
2024-01-18 16:17:47 -03:00
|
|
|
|
2024-02-25 12:54:37 -03:00
|
|
|
void update_file_input_shadow_tree();
|
2024-11-14 12:01:23 -03:00
|
|
|
GC::Ptr<DOM::Element> m_file_button;
|
|
|
|
|
GC::Ptr<DOM::Element> m_file_label;
|
2024-02-25 12:54:37 -03:00
|
|
|
|
2024-07-16 11:31:29 -03:00
|
|
|
void update_slider_shadow_tree_elements();
|
2024-11-14 12:01:23 -03:00
|
|
|
GC::Ptr<DOM::Element> m_slider_runnable_track;
|
|
|
|
|
GC::Ptr<DOM::Element> m_slider_progress_element;
|
|
|
|
|
GC::Ptr<DOM::Element> m_slider_thumb;
|
2023-12-11 14:00:06 -03:00
|
|
|
|
2024-11-14 12:01:23 -03:00
|
|
|
GC::Ptr<DecodedImageData> image_data() const;
|
|
|
|
|
GC::Ptr<SharedResourceRequest> m_resource_request;
|
2024-02-19 02:21:27 -03:00
|
|
|
SelectedCoordinate m_selected_coordinate;
|
2024-02-18 23:12:14 -03:00
|
|
|
|
|
|
|
|
Optional<DOM::DocumentLoadEventDelayer> m_load_event_delayer;
|
|
|
|
|
|
2023-03-20 05:34:43 -03:00
|
|
|
// https://html.spec.whatwg.org/multipage/input.html#dom-input-indeterminate
|
|
|
|
|
bool m_indeterminate { false };
|
|
|
|
|
|
2022-02-15 15:16:57 -03:00
|
|
|
// https://html.spec.whatwg.org/multipage/input.html#concept-input-checked-dirty-flag
|
|
|
|
|
bool m_dirty_checkedness { false };
|
2022-03-14 20:05:55 -03:00
|
|
|
|
2022-03-22 11:55:13 -03:00
|
|
|
// https://html.spec.whatwg.org/multipage/form-control-infrastructure.html#concept-fe-dirty
|
|
|
|
|
bool m_dirty_value { false };
|
|
|
|
|
|
2023-09-02 09:07:58 -03:00
|
|
|
// https://html.spec.whatwg.org/multipage/input.html#the-input-element:concept-fe-mutable
|
|
|
|
|
bool m_is_mutable { true };
|
|
|
|
|
|
2022-03-14 20:05:55 -03:00
|
|
|
// https://html.spec.whatwg.org/multipage/input.html#the-input-element:legacy-pre-activation-behavior
|
|
|
|
|
bool m_before_legacy_pre_activation_behavior_checked { false };
|
2023-03-20 05:34:43 -03:00
|
|
|
bool m_before_legacy_pre_activation_behavior_indeterminate { false };
|
2024-11-14 12:01:23 -03:00
|
|
|
GC::Ptr<HTMLInputElement> m_legacy_pre_activation_behavior_checked_element_in_group;
|
2022-03-16 08:44:21 -03:00
|
|
|
|
2022-10-04 02:39:53 -03:00
|
|
|
// https://html.spec.whatwg.org/multipage/input.html#concept-input-type-file-selected
|
2024-11-14 12:01:23 -03:00
|
|
|
GC::Ptr<FileAPI::FileList> m_selected_files;
|
2022-10-04 02:39:53 -03:00
|
|
|
|
2022-03-16 08:44:21 -03:00
|
|
|
TypeAttributeState m_type { TypeAttributeState::Text };
|
2023-11-20 04:32:40 -03:00
|
|
|
String m_value;
|
2023-11-30 14:54:30 -03:00
|
|
|
|
2024-04-04 13:56:37 -03:00
|
|
|
String m_last_src_value;
|
|
|
|
|
|
2023-11-30 14:54:30 -03:00
|
|
|
bool m_has_uncommitted_changes { false };
|
2019-11-25 17:21:55 -03:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
}
|
2023-03-10 17:16:18 -03:00
|
|
|
|
|
|
|
|
namespace Web::DOM {
|
|
|
|
|
template<>
|
|
|
|
|
inline bool Node::fast_is<HTML::HTMLInputElement>() const { return is_html_input_element(); }
|
|
|
|
|
}
|