2020-01-18 09:38:21 +01:00
|
|
|
/*
|
2024-10-04 13:19:50 +02:00
|
|
|
* Copyright (c) 2018-2022, Andreas Kling <andreas@ladybird.org>
|
2022-02-17 21:22:36 +00:00
|
|
|
* Copyright (c) 2022, Adam Hodgen <ant1441@gmail.com>
|
2023-12-11 18:00:06 +01:00
|
|
|
* Copyright (c) 2023, Bastiaan van der Plaat <bastiaan.v.d.plaat@gmail.com>
|
2024-11-01 12:14:53 +01:00
|
|
|
* Copyright (c) 2024, Jelle Raaijmakers <jelle@ladybird.org>
|
2020-01-18 09:38:21 +01:00
|
|
|
*
|
2021-04-22 01:24:48 -07:00
|
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
2020-01-18 09:38:21 +01:00
|
|
|
*/
|
|
|
|
|
2019-11-25 21:21:55 +01:00
|
|
|
#pragma once
|
|
|
|
|
2025-02-27 10:13:52 +00:00
|
|
|
#include <LibRegex/Regex.h>
|
2024-02-18 21:12:14 -05:00
|
|
|
#include <LibWeb/DOM/DocumentLoadEventDelayer.h>
|
2023-08-30 14:38:58 +01:00
|
|
|
#include <LibWeb/DOM/Text.h>
|
2025-07-19 19:35:33 -07:00
|
|
|
#include <LibWeb/Export.h>
|
2022-10-03 23:39:53 -06:00
|
|
|
#include <LibWeb/FileAPI/FileList.h>
|
2025-02-09 15:56:54 +01:00
|
|
|
#include <LibWeb/HTML/AutocompleteElement.h>
|
2024-03-02 18:06:44 +01:00
|
|
|
#include <LibWeb/HTML/ColorPickerUpdateState.h>
|
2024-03-14 12:26:00 -04:00
|
|
|
#include <LibWeb/HTML/FileFilter.h>
|
2021-04-20 11:50:29 +02:00
|
|
|
#include <LibWeb/HTML/FormAssociatedElement.h>
|
2020-07-26 15:08:16 +02:00
|
|
|
#include <LibWeb/HTML/HTMLElement.h>
|
2025-01-14 15:15:38 +11:00
|
|
|
#include <LibWeb/HTML/PopoverInvokerElement.h>
|
2024-02-18 21:12:14 -05:00
|
|
|
#include <LibWeb/Layout/ImageProvider.h>
|
2022-10-03 23:39:53 -06:00
|
|
|
#include <LibWeb/WebIDL/DOMException.h>
|
2024-03-01 08:49:04 +01:00
|
|
|
#include <LibWeb/WebIDL/Types.h>
|
2019-11-25 21:21:55 +01:00
|
|
|
|
2020-07-28 18:20:36 +02:00
|
|
|
namespace Web::HTML {
|
2020-03-07 10:27:02 +01:00
|
|
|
|
2022-02-17 21:22:36 +00:00
|
|
|
// https://html.spec.whatwg.org/multipage/input.html#attr-input-type
|
2022-02-17 23:05:46 +00:00
|
|
|
#define ENUMERATE_HTML_INPUT_TYPE_ATTRIBUTES \
|
2024-09-10 10:43:22 +01: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 23:05:46 +00:00
|
|
|
__ENUMERATE_HTML_INPUT_TYPE_ATTRIBUTE("datetime-local", LocalDateAndTime) \
|
2024-09-10 10:43:22 +01: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 21:22:36 +00:00
|
|
|
|
2025-07-19 19:35:33 -07:00
|
|
|
class WEB_API HTMLInputElement final
|
2022-03-23 18:55:54 -04:00
|
|
|
: public HTMLElement
|
2024-08-30 17:22:58 +01:00
|
|
|
, public FormAssociatedTextControlElement
|
2025-01-14 15:15:38 +11:00
|
|
|
, public Layout::ImageProvider
|
2025-02-09 15:56:54 +01:00
|
|
|
, public PopoverInvokerElement
|
|
|
|
, public AutocompleteElement {
|
2022-08-28 13:42:07 +02:00
|
|
|
WEB_PLATFORM_OBJECT(HTMLInputElement, HTMLElement);
|
2024-11-15 04:01:23 +13:00
|
|
|
GC_DECLARE_ALLOCATOR(HTMLInputElement);
|
2025-02-09 15:56:54 +01:00
|
|
|
FORM_ASSOCIATED_ELEMENT(HTMLElement, HTMLInputElement);
|
|
|
|
AUTOCOMPLETE_ELEMENT(HTMLElement, HTMLInputElement);
|
2022-03-23 18:55:54 -04:00
|
|
|
|
2019-11-25 21:21:55 +01:00
|
|
|
public:
|
|
|
|
virtual ~HTMLInputElement() override;
|
|
|
|
|
2024-12-20 16:35:12 +01:00
|
|
|
virtual GC::Ptr<Layout::Node> create_layout_node(GC::Ref<CSS::ComputedProperties>) override;
|
2024-12-20 11:32:17 +01:00
|
|
|
virtual void adjust_computed_style(CSS::ComputedProperties&) override;
|
2019-11-25 21:21:55 +01:00
|
|
|
|
2022-03-26 17:59:58 +00:00
|
|
|
enum class TypeAttributeState {
|
2022-02-17 23:05:46 +00:00
|
|
|
#define __ENUMERATE_HTML_INPUT_TYPE_ATTRIBUTE(_, state) state,
|
|
|
|
ENUMERATE_HTML_INPUT_TYPE_ATTRIBUTES
|
|
|
|
#undef __ENUMERATE_HTML_INPUT_TYPE_ATTRIBUTE
|
|
|
|
};
|
|
|
|
|
2023-09-03 16:27:10 +12:00
|
|
|
StringView type() const;
|
2022-03-16 07:46:17 -04:00
|
|
|
TypeAttributeState type_state() const { return m_type; }
|
2023-09-03 16:27:10 +12:00
|
|
|
WebIDL::ExceptionOr<void> set_type(String const&);
|
2022-02-17 13:12:01 +01:00
|
|
|
|
2024-01-16 19:04:45 +01:00
|
|
|
String default_value() const { return get_attribute_value(HTML::AttributeNames::value); }
|
2020-09-11 18:17:39 +02:00
|
|
|
|
2025-07-26 12:19:56 -04:00
|
|
|
virtual Utf16String value() const override;
|
2025-07-08 11:28:10 +01:00
|
|
|
virtual Optional<String> optional_value() const override;
|
2025-07-26 12:19:56 -04:00
|
|
|
WebIDL::ExceptionOr<void> set_value(Utf16String const&);
|
2021-02-10 18:26:07 +01:00
|
|
|
|
2024-08-30 17:22:58 +01:00
|
|
|
// https://html.spec.whatwg.org/multipage/form-control-infrastructure.html#concept-textarea/input-relevant-value
|
2025-07-26 12:19:56 -04:00
|
|
|
virtual Utf16String relevant_value() override { return value(); }
|
|
|
|
WebIDL::ExceptionOr<void> set_relevant_value(Utf16String const& value) override { return set_value(value); }
|
2024-08-30 17:22:58 +01:00
|
|
|
|
|
|
|
virtual void set_dirty_value_flag(bool flag) override { m_dirty_value = flag; }
|
2024-08-30 17:22:58 +01:00
|
|
|
|
2025-02-02 20:41:23 +01:00
|
|
|
bool user_validity() const { return m_user_validity; }
|
|
|
|
void set_user_validity(bool flag) { m_user_validity = flag; }
|
|
|
|
|
2023-11-30 12:54:30 -05:00
|
|
|
void commit_pending_changes();
|
2025-02-02 20:41:23 +01:00
|
|
|
bool has_uncommitted_changes() { return m_has_uncommitted_changes; }
|
2023-11-30 12:54:30 -05:00
|
|
|
|
2023-12-10 19:33:37 +01:00
|
|
|
String placeholder() const;
|
2024-03-15 17:40:40 +01:00
|
|
|
Optional<String> placeholder_value() const;
|
2022-11-30 22:15:12 -05:00
|
|
|
|
2020-09-11 18:17:39 +02:00
|
|
|
bool checked() const { return m_checked; }
|
2025-01-05 20:50:09 +00:00
|
|
|
void set_checked(bool);
|
2020-09-12 17:56:11 +02:00
|
|
|
|
2022-03-15 01:13:05 +00:00
|
|
|
bool checked_binding() const { return checked(); }
|
|
|
|
void set_checked_binding(bool);
|
|
|
|
|
2023-07-07 22:48:11 -04:00
|
|
|
bool indeterminate() const { return m_indeterminate; }
|
2023-03-20 04:34:43 -04:00
|
|
|
void set_indeterminate(bool);
|
|
|
|
|
2025-05-16 09:22:38 +05:30
|
|
|
bool can_have_text_editing_cursor() const;
|
|
|
|
|
2025-03-03 15:23:48 +00:00
|
|
|
GC::Ptr<HTMLDataListElement const> list() const;
|
|
|
|
|
2024-03-02 18:06:44 +01:00
|
|
|
void did_pick_color(Optional<Color> picked_color, ColorPickerUpdateState state);
|
2024-02-25 13:02:47 -05:00
|
|
|
|
2024-10-10 20:10:37 -04:00
|
|
|
enum class MultipleHandling {
|
|
|
|
Replace,
|
|
|
|
Append,
|
|
|
|
};
|
|
|
|
void did_select_files(Span<SelectedFile> selected_files, MultipleHandling = MultipleHandling::Replace);
|
2023-09-04 11:32:40 +02:00
|
|
|
|
2024-11-15 04:01:23 +13:00
|
|
|
GC::Ptr<FileAPI::FileList> files();
|
|
|
|
void set_files(GC::Ptr<FileAPI::FileList>);
|
2022-10-03 23:39:53 -06:00
|
|
|
|
2024-03-14 12:26:00 -04:00
|
|
|
FileFilter parse_accept_attribute() const;
|
|
|
|
|
2022-10-03 23:39:53 -06:00
|
|
|
// NOTE: User interaction
|
|
|
|
// https://html.spec.whatwg.org/multipage/input.html#update-the-file-selection
|
2024-11-15 04:01:23 +13:00
|
|
|
void update_the_file_selection(GC::Ref<FileAPI::FileList>);
|
2022-10-03 23:39:53 -06:00
|
|
|
|
2024-03-01 08:49:04 +01: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 14:33:53 +00:00
|
|
|
WebIDL::UnsignedLong size() const;
|
|
|
|
WebIDL::ExceptionOr<void> set_size(WebIDL::UnsignedLong value);
|
2023-11-24 17:37:53 +01:00
|
|
|
|
2024-11-29 17:56:24 +00:00
|
|
|
WebIDL::UnsignedLong height() const;
|
|
|
|
WebIDL::ExceptionOr<void> set_height(WebIDL::UnsignedLong value);
|
|
|
|
|
2024-11-29 17:45:07 +00:00
|
|
|
WebIDL::UnsignedLong width() const;
|
|
|
|
WebIDL::ExceptionOr<void> set_width(WebIDL::UnsignedLong value);
|
|
|
|
|
2024-02-19 00:21:27 -05:00
|
|
|
struct SelectedCoordinate {
|
2024-02-19 07:44:11 -05:00
|
|
|
int x { 0 };
|
|
|
|
int y { 0 };
|
2024-02-19 00:21:27 -05:00
|
|
|
};
|
|
|
|
SelectedCoordinate selected_coordinate() const { return m_selected_coordinate; }
|
|
|
|
|
2023-12-15 18:23:29 +01:00
|
|
|
JS::Object* value_as_date() const;
|
2024-11-15 04:01:23 +13:00
|
|
|
WebIDL::ExceptionOr<void> set_value_as_date(Optional<GC::Root<JS::Object>> const&);
|
2023-12-15 18:23:29 +01:00
|
|
|
|
|
|
|
double value_as_number() const;
|
2023-10-04 22:40:31 +02:00
|
|
|
WebIDL::ExceptionOr<void> set_value_as_number(double value);
|
|
|
|
|
2024-02-26 18:54:36 +01:00
|
|
|
WebIDL::ExceptionOr<void> step_up(WebIDL::Long n = 1);
|
|
|
|
WebIDL::ExceptionOr<void> step_down(WebIDL::Long n = 1);
|
2023-12-07 19:35:45 +01:00
|
|
|
|
2022-10-03 23:39:53 -06:00
|
|
|
WebIDL::ExceptionOr<void> show_picker();
|
|
|
|
|
2022-03-26 18:02:41 +00:00
|
|
|
// ^EventTarget
|
|
|
|
// https://html.spec.whatwg.org/multipage/interaction.html#the-tabindex-attribute:the-input-element
|
2024-11-02 19:17:20 +01: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 19:27:10 +01:00
|
|
|
|
2022-03-01 21:03:30 +00: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
|
2025-05-26 16:21:29 +12:00
|
|
|
virtual bool is_autocapitalize_and_autocorrect_inheriting() const override { return true; }
|
2022-03-01 21:03:30 +00:00
|
|
|
|
2023-06-18 15:08:15 +01: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 11:05:13 -05:00
|
|
|
bool is_single_line() const;
|
|
|
|
|
2022-12-22 19:33:37 -05:00
|
|
|
virtual void reset_algorithm() override;
|
2024-10-11 10:38:43 -04:00
|
|
|
virtual void clear_algorithm() override;
|
2022-12-22 19:33:37 -05:00
|
|
|
|
2022-03-23 18:55:54 -04:00
|
|
|
virtual void form_associated_element_was_inserted() override;
|
2025-07-22 00:58:28 +02:00
|
|
|
virtual void form_associated_element_attribute_changed(FlyString const& name, Optional<String> const& old_value, Optional<String> const& value, Optional<FlyString> const& namespace_) override;
|
2022-03-23 18:55:54 -04:00
|
|
|
|
2025-01-11 17:37:08 +00:00
|
|
|
virtual WebIDL::ExceptionOr<void> cloned(Node&, bool) const override;
|
2024-08-21 12:19:37 +01:00
|
|
|
|
2022-03-01 21:03:30 +00: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 22:23:16 +00:00
|
|
|
virtual Optional<ARIA::Role> default_role() const override;
|
2022-11-28 17:58:13 -06:00
|
|
|
|
2024-11-15 04:01:23 +13:00
|
|
|
GC::Ptr<Element> placeholder_element() { return m_placeholder_element; }
|
|
|
|
GC::Ptr<Element const> placeholder_element() const { return m_placeholder_element; }
|
2023-05-25 12:34:54 +02:00
|
|
|
|
2023-11-18 10:48:09 +01:00
|
|
|
virtual bool has_activation_behavior() const override;
|
|
|
|
virtual void activation_behavior(DOM::Event const&) override;
|
|
|
|
|
2023-12-03 08:24:16 -05:00
|
|
|
bool has_input_activation_behavior() const;
|
|
|
|
bool change_event_applies() const;
|
2023-12-15 18:23:29 +01:00
|
|
|
bool value_as_date_applies() const;
|
2023-12-07 19:31:42 +01:00
|
|
|
bool value_as_number_applies() const;
|
2023-12-07 19:35:45 +01:00
|
|
|
bool step_applies() const;
|
|
|
|
bool step_up_or_down_applies() const;
|
2024-08-22 15:20:24 +02:00
|
|
|
bool select_applies() const;
|
2024-07-28 16:41:45 +12:00
|
|
|
bool selection_or_range_applies() const;
|
2024-10-04 12:12:39 +01:00
|
|
|
bool selection_direction_applies() const;
|
2025-02-27 10:13:52 +00:00
|
|
|
bool pattern_applies() const;
|
|
|
|
bool multiple_applies() const;
|
2025-04-30 10:23:46 +10:00
|
|
|
bool required_applies() const;
|
2025-05-24 15:24:38 +10:00
|
|
|
bool checked_applies() const;
|
2024-09-18 15:34:40 +01:00
|
|
|
bool has_selectable_text() const;
|
2024-07-28 16:41:45 +12:00
|
|
|
|
2025-01-31 15:34:34 +00:00
|
|
|
bool supports_a_picker() const;
|
|
|
|
bool is_open() const { return m_is_open; }
|
|
|
|
void set_is_open(bool);
|
|
|
|
|
2024-09-10 09:24:00 +01:00
|
|
|
static bool selection_or_range_applies_for_type_state(TypeAttributeState);
|
|
|
|
|
2024-10-04 12:12:39 +01:00
|
|
|
Optional<String> selection_direction_binding() { return selection_direction(); }
|
|
|
|
|
2024-11-06 16:46:50 +01:00
|
|
|
// ^FormAssociatedTextControlElement
|
|
|
|
virtual void did_edit_text_node() override;
|
2024-11-15 04:01:23 +13:00
|
|
|
virtual GC::Ptr<DOM::Text> form_associated_element_to_text_node() override { return m_text_node; }
|
2024-08-26 14:08:40 +02:00
|
|
|
|
2025-03-07 16:44:29 +09:00
|
|
|
// https://html.spec.whatwg.org/multipage/input.html#has-a-periodic-domain/
|
|
|
|
bool has_periodic_domain() const { return type_state() == HTMLInputElement::TypeAttributeState::Time; }
|
|
|
|
// https://html.spec.whatwg.org/multipage/input.html#has-a-reversed-range
|
|
|
|
bool has_reversed_range() const;
|
|
|
|
|
2025-02-02 20:41:23 +01:00
|
|
|
// https://html.spec.whatwg.org/multipage/form-control-infrastructure.html#definitions
|
|
|
|
virtual bool suffering_from_being_missing() const override;
|
|
|
|
virtual bool suffering_from_a_type_mismatch() const override;
|
|
|
|
virtual bool suffering_from_a_pattern_mismatch() const override;
|
|
|
|
virtual bool suffering_from_an_underflow() const override;
|
|
|
|
virtual bool suffering_from_an_overflow() const override;
|
|
|
|
virtual bool suffering_from_a_step_mismatch() const override;
|
|
|
|
virtual bool suffering_from_bad_input() const override;
|
|
|
|
|
2025-08-10 00:29:35 +02:00
|
|
|
virtual bool is_mutable() const override;
|
2025-08-15 09:42:52 +02:00
|
|
|
virtual bool uses_button_layout() const override;
|
2025-08-10 00:29:35 +02:00
|
|
|
|
2020-09-11 18:17:39 +02:00
|
|
|
private:
|
2022-08-28 13:42:07 +02:00
|
|
|
HTMLInputElement(DOM::Document&, DOM::QualifiedName);
|
|
|
|
|
2024-09-10 09:24:00 +01:00
|
|
|
void type_attribute_changed(TypeAttributeState old_state, TypeAttributeState new_state);
|
|
|
|
|
2024-12-23 17:51:10 +01:00
|
|
|
virtual bool is_presentational_hint(FlyString const&) const override;
|
LibWeb: Split StyleComputer work into two phases with separate outputs
Before this change, StyleComputer would essentially take a DOM element,
find all the CSS rules that apply to it, and resolve the computed value
for each CSS property for that element.
This worked great, but it meant we had to do all the work of selector
matching and cascading every time.
To enable new optimizations, this change introduces a break in the
middle of this process where we've produced a "CascadedProperties".
This object contains the result of the cascade, before we've begun
turning cascaded values into computed values.
The cascaded properties are now stored with each element, which will
later allow us to do partial updates without re-running the full
StyleComputer machine. This will be particularly valuable for
re-implementing CSS inheritance, which is extremely heavy today.
Note that CSS animations and CSS transitions operate entirely on the
computed values, even though the cascade order would have you believe
they happen earlier. I'm not confident we have the right architecture
for this, but that's a separate issue.
2024-12-12 10:06:29 +01:00
|
|
|
virtual void apply_presentational_hints(GC::Ref<CSS::CascadedProperties>) const override;
|
2024-10-01 17:26:01 +01:00
|
|
|
|
2023-03-10 21:16:18 +01:00
|
|
|
// ^DOM::Node
|
|
|
|
virtual bool is_html_input_element() const final { return true; }
|
|
|
|
|
2022-02-06 19:27:10 +01:00
|
|
|
// ^DOM::EventTarget
|
2023-05-29 18:41:32 +02:00
|
|
|
virtual void did_lose_focus() override;
|
2022-02-06 19:27:10 +01:00
|
|
|
virtual void did_receive_focus() override;
|
2022-03-14 23:05:55 +00: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 19:27:10 +01:00
|
|
|
|
2022-11-05 03:58:14 +00:00
|
|
|
// ^DOM::Element
|
|
|
|
virtual i32 default_tab_index_value() const override;
|
2024-04-10 21:44:11 -04: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 03:58:14 +00:00
|
|
|
|
2024-02-18 21:12:14 -05: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;
|
2025-08-28 11:21:46 -04:00
|
|
|
virtual RefPtr<Gfx::ImmutableBitmap> current_image_bitmap_sized(Gfx::IntSize) const override;
|
2024-02-18 21:12:14 -05:00
|
|
|
virtual void set_visible_in_viewport(bool) override;
|
2025-07-26 14:46:23 +02:00
|
|
|
virtual GC::Ptr<DOM::Element const> to_html_element() const override { return *this; }
|
2024-02-18 21:12:14 -05:00
|
|
|
|
2023-08-07 08:41:28 +02:00
|
|
|
virtual void initialize(JS::Realm&) override;
|
2022-08-28 13:42:07 +02:00
|
|
|
virtual void visit_edges(Cell::Visitor&) override;
|
|
|
|
|
2025-03-04 20:19:45 +09:00
|
|
|
Optional<double> convert_time_string_to_number(StringView input) const;
|
2023-12-07 19:29:32 +01:00
|
|
|
Optional<double> convert_string_to_number(StringView input) const;
|
2025-07-26 12:19:56 -04:00
|
|
|
Optional<double> convert_string_to_number(Utf16String const& input) const;
|
|
|
|
Utf16String convert_number_to_string(double input) const;
|
2023-12-07 19:29:32 +01:00
|
|
|
|
2024-11-15 04:01:23 +13:00
|
|
|
WebIDL::ExceptionOr<GC::Ptr<JS::Date>> convert_string_to_date(StringView input) const;
|
2025-07-26 12:19:56 -04:00
|
|
|
WebIDL::ExceptionOr<GC::Ptr<JS::Date>> convert_string_to_date(Utf16String const& input) const;
|
|
|
|
Utf16String convert_date_to_string(GC::Ref<JS::Date> input) const;
|
2023-12-15 18:23:29 +01:00
|
|
|
|
2023-12-07 19:35:45 +01: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 18:54:36 +01:00
|
|
|
WebIDL::ExceptionOr<void> step_up_or_down(bool is_down, WebIDL::Long n);
|
2023-12-07 19:35:45 +01:00
|
|
|
|
2022-03-16 07:44:21 -04:00
|
|
|
static TypeAttributeState parse_type_attribute(StringView);
|
2025-07-26 12:19:56 -04:00
|
|
|
|
|
|
|
Utf16String button_label() const;
|
|
|
|
|
2021-02-10 18:26:07 +01:00
|
|
|
void create_shadow_tree_if_needed();
|
2024-02-25 10:43:17 -05:00
|
|
|
void update_shadow_tree();
|
2024-06-13 20:04:41 +03:00
|
|
|
void create_button_input_shadow_tree();
|
2023-10-13 21:06:34 +02:00
|
|
|
void create_text_input_shadow_tree();
|
2023-10-14 12:00:40 +02:00
|
|
|
void create_color_input_shadow_tree();
|
2024-02-25 10:54:37 -05:00
|
|
|
void create_file_input_shadow_tree();
|
2023-12-11 18:00:06 +01:00
|
|
|
void create_range_input_shadow_tree();
|
2024-01-18 12:58:22 -07:00
|
|
|
WebIDL::ExceptionOr<void> run_input_activation_behavior(DOM::Event const&);
|
2022-03-14 23:05:55 +00:00
|
|
|
void set_checked_within_group();
|
2021-02-10 18:26:07 +01:00
|
|
|
|
2024-03-01 08:49:04 +01:00
|
|
|
void handle_maxlength_attribute();
|
2024-04-04 12:56:37 -04:00
|
|
|
WebIDL::ExceptionOr<void> handle_src_attribute(String const& value);
|
2023-09-03 00:07:58 +12:00
|
|
|
|
2024-05-18 05:45:13 +01:00
|
|
|
void user_interaction_did_change_input_value();
|
|
|
|
|
2022-02-17 23:05:46 +00:00
|
|
|
// https://html.spec.whatwg.org/multipage/input.html#value-sanitization-algorithm
|
2025-07-26 12:19:56 -04:00
|
|
|
Utf16String value_sanitization_algorithm(Utf16String const&) const;
|
2022-02-17 23:05:46 +00:00
|
|
|
|
2024-02-17 16:27:41 -05:00
|
|
|
enum class ValueAttributeMode {
|
|
|
|
Value,
|
|
|
|
Default,
|
|
|
|
DefaultOn,
|
|
|
|
Filename,
|
|
|
|
};
|
2024-09-10 09:24:00 +01:00
|
|
|
static ValueAttributeMode value_attribute_mode_for_type_state(TypeAttributeState);
|
2024-02-17 16:27:41 -05:00
|
|
|
ValueAttributeMode value_attribute_mode() const;
|
|
|
|
|
2023-05-25 12:34:54 +02:00
|
|
|
void update_placeholder_visibility();
|
2024-11-15 04:01:23 +13:00
|
|
|
GC::Ptr<DOM::Element> m_placeholder_element;
|
|
|
|
GC::Ptr<DOM::Text> m_placeholder_text_node;
|
2023-05-25 12:34:54 +02:00
|
|
|
|
2025-01-07 00:30:02 +01:00
|
|
|
void update_button_input_shadow_tree();
|
|
|
|
|
2024-04-04 12:37:27 -04:00
|
|
|
void update_text_input_shadow_tree();
|
2024-11-15 04:01:23 +13:00
|
|
|
GC::Ptr<DOM::Element> m_inner_text_element;
|
|
|
|
GC::Ptr<DOM::Text> m_text_node;
|
2020-09-11 18:17:39 +02:00
|
|
|
bool m_checked { false };
|
2022-02-15 19:16:57 +01:00
|
|
|
|
2024-01-18 20:17:47 +01:00
|
|
|
void update_color_well_element();
|
2024-11-15 04:01:23 +13:00
|
|
|
GC::Ptr<DOM::Element> m_color_well_element;
|
2024-01-18 20:17:47 +01:00
|
|
|
|
2024-02-25 10:54:37 -05:00
|
|
|
void update_file_input_shadow_tree();
|
2024-11-15 04:01:23 +13:00
|
|
|
GC::Ptr<DOM::Element> m_file_button;
|
|
|
|
GC::Ptr<DOM::Element> m_file_label;
|
2024-02-25 10:54:37 -05:00
|
|
|
|
2024-07-16 11:31:29 -03:00
|
|
|
void update_slider_shadow_tree_elements();
|
2024-11-15 04:01:23 +13: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 18:00:06 +01:00
|
|
|
|
2024-11-15 04:01:23 +13:00
|
|
|
GC::Ptr<DecodedImageData> image_data() const;
|
|
|
|
GC::Ptr<SharedResourceRequest> m_resource_request;
|
2024-02-19 00:21:27 -05:00
|
|
|
SelectedCoordinate m_selected_coordinate;
|
2024-02-18 21:12:14 -05:00
|
|
|
|
2025-02-27 10:13:52 +00:00
|
|
|
Optional<Regex<ECMA262>> compiled_pattern_regular_expression() const;
|
|
|
|
|
2025-03-03 15:23:48 +00:00
|
|
|
Optional<GC::Ref<HTMLDataListElement const>> suggestions_source_element() const;
|
|
|
|
|
2024-02-18 21:12:14 -05:00
|
|
|
Optional<DOM::DocumentLoadEventDelayer> m_load_event_delayer;
|
|
|
|
|
2023-03-20 04:34:43 -04:00
|
|
|
// https://html.spec.whatwg.org/multipage/input.html#dom-input-indeterminate
|
|
|
|
bool m_indeterminate { false };
|
|
|
|
|
2022-02-15 19:16:57 +01:00
|
|
|
// https://html.spec.whatwg.org/multipage/input.html#concept-input-checked-dirty-flag
|
|
|
|
bool m_dirty_checkedness { false };
|
2022-03-14 23:05:55 +00:00
|
|
|
|
2022-03-22 10:55:13 -04:00
|
|
|
// https://html.spec.whatwg.org/multipage/form-control-infrastructure.html#concept-fe-dirty
|
|
|
|
bool m_dirty_value { false };
|
|
|
|
|
2025-02-02 20:41:23 +01:00
|
|
|
// https://html.spec.whatwg.org/multipage/form-control-infrastructure.html#user-validity
|
|
|
|
bool m_user_validity { false };
|
|
|
|
|
2022-03-14 23:05:55 +00: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 04:34:43 -04:00
|
|
|
bool m_before_legacy_pre_activation_behavior_indeterminate { false };
|
2024-11-15 04:01:23 +13:00
|
|
|
GC::Ptr<HTMLInputElement> m_legacy_pre_activation_behavior_checked_element_in_group;
|
2022-03-16 07:44:21 -04:00
|
|
|
|
2022-10-03 23:39:53 -06:00
|
|
|
// https://html.spec.whatwg.org/multipage/input.html#concept-input-type-file-selected
|
2024-11-15 04:01:23 +13:00
|
|
|
GC::Ptr<FileAPI::FileList> m_selected_files;
|
2022-10-03 23:39:53 -06:00
|
|
|
|
2022-03-16 07:44:21 -04:00
|
|
|
TypeAttributeState m_type { TypeAttributeState::Text };
|
2025-07-26 12:19:56 -04:00
|
|
|
Utf16String m_value;
|
2023-11-30 12:54:30 -05:00
|
|
|
|
2024-04-04 12:56:37 -04:00
|
|
|
String m_last_src_value;
|
|
|
|
|
2023-11-30 12:54:30 -05:00
|
|
|
bool m_has_uncommitted_changes { false };
|
2025-01-31 15:34:34 +00:00
|
|
|
|
|
|
|
bool m_is_open { false };
|
2025-04-20 19:48:47 +02:00
|
|
|
|
|
|
|
void signal_a_type_change();
|
2025-08-10 22:35:28 +02:00
|
|
|
|
|
|
|
bool is_number_underflowing(double number) const;
|
|
|
|
bool is_number_overflowing(double number) const;
|
|
|
|
bool is_number_mismatching_step(double number) const;
|
2019-11-25 21:21:55 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|
2023-03-10 21:16:18 +01:00
|
|
|
|
|
|
|
namespace Web::DOM {
|
2025-05-13 07:06:33 -04:00
|
|
|
|
2023-03-10 21:16:18 +01:00
|
|
|
template<>
|
|
|
|
inline bool Node::fast_is<HTML::HTMLInputElement>() const { return is_html_input_element(); }
|
2025-05-13 07:06:33 -04:00
|
|
|
|
2023-03-10 21:16:18 +01:00
|
|
|
}
|