mirror of
https://github.com/RGBCube/serenity
synced 2025-05-27 23:55:09 +00:00
LibWeb: Use the cached HTMLInputElement type within associated getters
This commit is contained in:
parent
95b084a08f
commit
1a99cc4a14
2 changed files with 7 additions and 26 deletions
|
@ -239,34 +239,15 @@ void HTMLInputElement::did_remove_attribute(FlyString const& name)
|
||||||
|
|
||||||
String HTMLInputElement::type() const
|
String HTMLInputElement::type() const
|
||||||
{
|
{
|
||||||
auto value = attribute(HTML::AttributeNames::type);
|
switch (m_type) {
|
||||||
|
|
||||||
#define __ENUMERATE_HTML_INPUT_TYPE_ATTRIBUTE(keyword, _) \
|
|
||||||
if (value.equals_ignoring_case(#keyword)) \
|
|
||||||
return #keyword;
|
|
||||||
ENUMERATE_HTML_INPUT_TYPE_ATTRIBUTES
|
|
||||||
#undef __ENUMERATE_HTML_INPUT_TYPE_ATTRIBUTE
|
|
||||||
|
|
||||||
// The missing value default and the invalid value default are the Text state.
|
|
||||||
// https://html.spec.whatwg.org/multipage/input.html#the-input-element:missing-value-default
|
|
||||||
// https://html.spec.whatwg.org/multipage/input.html#the-input-element:invalid-value-default
|
|
||||||
return "text";
|
|
||||||
}
|
|
||||||
|
|
||||||
HTMLInputElement::TypeAttributeState HTMLInputElement::type_state() const
|
|
||||||
{
|
|
||||||
auto value = attribute(HTML::AttributeNames::type);
|
|
||||||
|
|
||||||
#define __ENUMERATE_HTML_INPUT_TYPE_ATTRIBUTE(keyword, state) \
|
#define __ENUMERATE_HTML_INPUT_TYPE_ATTRIBUTE(keyword, state) \
|
||||||
if (value.equals_ignoring_case(#keyword)) \
|
case TypeAttributeState::state: \
|
||||||
return HTMLInputElement::TypeAttributeState::state;
|
return #keyword##sv;
|
||||||
ENUMERATE_HTML_INPUT_TYPE_ATTRIBUTES
|
ENUMERATE_HTML_INPUT_TYPE_ATTRIBUTES
|
||||||
#undef __ENUMERATE_HTML_INPUT_TYPE_ATTRIBUTE
|
#undef __ENUMERATE_HTML_INPUT_TYPE_ATTRIBUTE
|
||||||
|
}
|
||||||
|
|
||||||
// The missing value default and the invalid value default are the Text state.
|
VERIFY_NOT_REACHED();
|
||||||
// https://html.spec.whatwg.org/multipage/input.html#the-input-element:missing-value-default
|
|
||||||
// https://html.spec.whatwg.org/multipage/input.html#the-input-element:invalid-value-default
|
|
||||||
return HTMLInputElement::TypeAttributeState::Text;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void HTMLInputElement::set_type(String const& type)
|
void HTMLInputElement::set_type(String const& type)
|
||||||
|
|
|
@ -53,7 +53,7 @@ public:
|
||||||
};
|
};
|
||||||
|
|
||||||
String type() const;
|
String type() const;
|
||||||
TypeAttributeState type_state() const;
|
TypeAttributeState type_state() const { return m_type; }
|
||||||
void set_type(String const&);
|
void set_type(String const&);
|
||||||
|
|
||||||
String default_value() const { return attribute(HTML::AttributeNames::value); }
|
String default_value() const { return attribute(HTML::AttributeNames::value); }
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue