mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 09:38:11 +00:00
LibWeb: Port HTMLInputElement interface from DeprecatedString to String
This commit is contained in:
parent
f4bc1602e2
commit
938356da98
3 changed files with 14 additions and 13 deletions
|
@ -336,12 +336,12 @@ DeprecatedString HTMLInputElement::value() const
|
||||||
return m_value;
|
return m_value;
|
||||||
}
|
}
|
||||||
|
|
||||||
WebIDL::ExceptionOr<void> HTMLInputElement::set_value(DeprecatedString value)
|
WebIDL::ExceptionOr<void> HTMLInputElement::set_value(String const& value)
|
||||||
{
|
{
|
||||||
// https://html.spec.whatwg.org/multipage/input.html#dom-input-value-filename
|
// https://html.spec.whatwg.org/multipage/input.html#dom-input-value-filename
|
||||||
if (type_state() == TypeAttributeState::FileUpload) {
|
if (type_state() == TypeAttributeState::FileUpload) {
|
||||||
// On setting, if the new value is the empty string, empty the list of selected files; otherwise, throw an "InvalidStateError" DOMException.
|
// On setting, if the new value is the empty string, empty the list of selected files; otherwise, throw an "InvalidStateError" DOMException.
|
||||||
if (value != DeprecatedString::empty())
|
if (!value.is_empty())
|
||||||
return WebIDL::InvalidStateError::create(realm(), "Setting value of input type file to non-empty string"sv);
|
return WebIDL::InvalidStateError::create(realm(), "Setting value of input type file to non-empty string"sv);
|
||||||
m_selected_files = nullptr;
|
m_selected_files = nullptr;
|
||||||
return {};
|
return {};
|
||||||
|
@ -358,7 +358,7 @@ WebIDL::ExceptionOr<void> HTMLInputElement::set_value(DeprecatedString value)
|
||||||
m_dirty_value = true;
|
m_dirty_value = true;
|
||||||
|
|
||||||
// 4. Invoke the value sanitization algorithm, if the element's type attribute's current state defines one.
|
// 4. Invoke the value sanitization algorithm, if the element's type attribute's current state defines one.
|
||||||
m_value = value_sanitization_algorithm(move(value));
|
m_value = value_sanitization_algorithm(value.to_deprecated_string());
|
||||||
|
|
||||||
// 5. If the element's value (after applying the value sanitization algorithm) is different from oldValue,
|
// 5. If the element's value (after applying the value sanitization algorithm) is different from oldValue,
|
||||||
// and the element has a text entry cursor position, move the text entry cursor position to the end of the
|
// and the element has a text entry cursor position, move the text entry cursor position to the end of the
|
||||||
|
@ -602,8 +602,9 @@ HTMLInputElement::TypeAttributeState HTMLInputElement::parse_type_attribute(Stri
|
||||||
return HTMLInputElement::TypeAttributeState::Text;
|
return HTMLInputElement::TypeAttributeState::Text;
|
||||||
}
|
}
|
||||||
|
|
||||||
DeprecatedString HTMLInputElement::type() const
|
StringView HTMLInputElement::type() const
|
||||||
{
|
{
|
||||||
|
// FIXME: This should probably be `Reflect` in the IDL.
|
||||||
switch (m_type) {
|
switch (m_type) {
|
||||||
#define __ENUMERATE_HTML_INPUT_TYPE_ATTRIBUTE(keyword, state) \
|
#define __ENUMERATE_HTML_INPUT_TYPE_ATTRIBUTE(keyword, state) \
|
||||||
case TypeAttributeState::state: \
|
case TypeAttributeState::state: \
|
||||||
|
@ -615,7 +616,7 @@ DeprecatedString HTMLInputElement::type() const
|
||||||
VERIFY_NOT_REACHED();
|
VERIFY_NOT_REACHED();
|
||||||
}
|
}
|
||||||
|
|
||||||
WebIDL::ExceptionOr<void> HTMLInputElement::set_type(DeprecatedString const& type)
|
WebIDL::ExceptionOr<void> HTMLInputElement::set_type(String const& type)
|
||||||
{
|
{
|
||||||
return set_attribute(HTML::AttributeNames::type, type);
|
return set_attribute(HTML::AttributeNames::type, type);
|
||||||
}
|
}
|
||||||
|
@ -1058,7 +1059,7 @@ WebIDL::ExceptionOr<bool> HTMLInputElement::report_validity()
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://html.spec.whatwg.org/multipage/form-control-infrastructure.html#dom-cva-setcustomvalidity
|
// https://html.spec.whatwg.org/multipage/form-control-infrastructure.html#dom-cva-setcustomvalidity
|
||||||
void HTMLInputElement::set_custom_validity(DeprecatedString const& error)
|
void HTMLInputElement::set_custom_validity(String const& error)
|
||||||
{
|
{
|
||||||
dbgln("(STUBBED) HTMLInputElement::set_custom_validity(error={}). Called on: {}", error, debug_description());
|
dbgln("(STUBBED) HTMLInputElement::set_custom_validity(error={}). Called on: {}", error, debug_description());
|
||||||
return;
|
return;
|
||||||
|
@ -1072,7 +1073,7 @@ WebIDL::ExceptionOr<void> HTMLInputElement::select()
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://html.spec.whatwg.org/multipage/form-control-infrastructure.html#dom-textarea/input-setselectionrange
|
// https://html.spec.whatwg.org/multipage/form-control-infrastructure.html#dom-textarea/input-setselectionrange
|
||||||
WebIDL::ExceptionOr<void> HTMLInputElement::set_selection_range(u32 start, u32 end, DeprecatedString const& direction)
|
WebIDL::ExceptionOr<void> HTMLInputElement::set_selection_range(u32 start, u32 end, Optional<String> const& direction)
|
||||||
{
|
{
|
||||||
dbgln("(STUBBED) HTMLInputElement::set_selection_range(start={}, end={}, direction='{}'). Called on: {}", start, end, direction, debug_description());
|
dbgln("(STUBBED) HTMLInputElement::set_selection_range(start={}, end={}, direction='{}'). Called on: {}", start, end, direction, debug_description());
|
||||||
return {};
|
return {};
|
||||||
|
|
|
@ -56,15 +56,15 @@ public:
|
||||||
#undef __ENUMERATE_HTML_INPUT_TYPE_ATTRIBUTE
|
#undef __ENUMERATE_HTML_INPUT_TYPE_ATTRIBUTE
|
||||||
};
|
};
|
||||||
|
|
||||||
DeprecatedString type() const;
|
StringView type() const;
|
||||||
TypeAttributeState type_state() const { return m_type; }
|
TypeAttributeState type_state() const { return m_type; }
|
||||||
WebIDL::ExceptionOr<void> set_type(DeprecatedString const&);
|
WebIDL::ExceptionOr<void> set_type(String const&);
|
||||||
|
|
||||||
DeprecatedString default_value() const { return deprecated_attribute(HTML::AttributeNames::value); }
|
DeprecatedString default_value() const { return deprecated_attribute(HTML::AttributeNames::value); }
|
||||||
DeprecatedString name() const { return deprecated_attribute(HTML::AttributeNames::name); }
|
DeprecatedString name() const { return deprecated_attribute(HTML::AttributeNames::name); }
|
||||||
|
|
||||||
virtual DeprecatedString value() const override;
|
virtual DeprecatedString value() const override;
|
||||||
WebIDL::ExceptionOr<void> set_value(DeprecatedString);
|
WebIDL::ExceptionOr<void> set_value(String const&);
|
||||||
|
|
||||||
Optional<DeprecatedString> placeholder_value() const;
|
Optional<DeprecatedString> placeholder_value() const;
|
||||||
|
|
||||||
|
@ -94,10 +94,10 @@ public:
|
||||||
|
|
||||||
WebIDL::ExceptionOr<bool> check_validity();
|
WebIDL::ExceptionOr<bool> check_validity();
|
||||||
WebIDL::ExceptionOr<bool> report_validity();
|
WebIDL::ExceptionOr<bool> report_validity();
|
||||||
void set_custom_validity(DeprecatedString const&);
|
void set_custom_validity(String const&);
|
||||||
|
|
||||||
WebIDL::ExceptionOr<void> select();
|
WebIDL::ExceptionOr<void> select();
|
||||||
WebIDL::ExceptionOr<void> set_selection_range(u32 start, u32 end, DeprecatedString const& direction);
|
WebIDL::ExceptionOr<void> set_selection_range(u32 start, u32 end, Optional<String> const& direction = {});
|
||||||
|
|
||||||
WebIDL::ExceptionOr<void> show_picker();
|
WebIDL::ExceptionOr<void> show_picker();
|
||||||
|
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
#import <FileAPI/FileList.idl>
|
#import <FileAPI/FileList.idl>
|
||||||
|
|
||||||
// https://html.spec.whatwg.org/multipage/input.html#htmlinputelement
|
// https://html.spec.whatwg.org/multipage/input.html#htmlinputelement
|
||||||
[Exposed=Window, UseDeprecatedAKString]
|
[Exposed=Window]
|
||||||
interface HTMLInputElement : HTMLElement {
|
interface HTMLInputElement : HTMLElement {
|
||||||
|
|
||||||
[HTMLConstructor] constructor();
|
[HTMLConstructor] constructor();
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue