mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-04-26 22:38:51 +00:00
LibWeb: Convert usages of type() to type_state()
This doesn't have any performance benefit yet as we still do string comparisons everytime, but it should improve once type_state() has a better implementation.
This commit is contained in:
parent
57a85b1017
commit
d2a99eded7
Notes:
sideshowbarker
2024-07-17 17:20:32 +09:00
Author: https://github.com/sin-ack
Commit: d2a99eded7
Pull-request: https://github.com/SerenityOS/serenity/pull/13052
Reviewed-by: https://github.com/Lubrsi
Reviewed-by: https://github.com/awesomekling
Reviewed-by: https://github.com/linusg ✅
Reviewed-by: https://github.com/trflynn89
1 changed files with 7 additions and 7 deletions
|
@ -39,16 +39,16 @@ HTMLInputElement::~HTMLInputElement()
|
|||
|
||||
RefPtr<Layout::Node> HTMLInputElement::create_layout_node(NonnullRefPtr<CSS::StyleProperties> style)
|
||||
{
|
||||
if (type() == "hidden")
|
||||
if (type_state() == TypeAttributeState::Hidden)
|
||||
return nullptr;
|
||||
|
||||
if (type() == "submit" || type() == "button" || type() == "reset")
|
||||
if (type_state() == TypeAttributeState::SubmitButton || type_state() == TypeAttributeState::Button || type_state() == TypeAttributeState::ResetButton)
|
||||
return adopt_ref(*new Layout::ButtonBox(document(), *this, move(style)));
|
||||
|
||||
if (type() == "checkbox")
|
||||
if (type_state() == TypeAttributeState::Checkbox)
|
||||
return adopt_ref(*new Layout::CheckBox(document(), *this, move(style)));
|
||||
|
||||
if (type() == "radio")
|
||||
if (type_state() == TypeAttributeState::RadioButton)
|
||||
return adopt_ref(*new Layout::RadioButton(document(), *this, move(style)));
|
||||
|
||||
auto layout_node = adopt_ref(*new Layout::BlockContainer(document(), this, move(style)));
|
||||
|
@ -72,7 +72,7 @@ void HTMLInputElement::set_checked(bool checked, ChangeSource change_source)
|
|||
|
||||
void HTMLInputElement::set_checked_binding(bool checked)
|
||||
{
|
||||
if (type() == "radio") {
|
||||
if (type_state() == TypeAttributeState::RadioButton) {
|
||||
if (checked)
|
||||
set_checked_within_group();
|
||||
else
|
||||
|
@ -85,7 +85,7 @@ void HTMLInputElement::set_checked_binding(bool checked)
|
|||
// https://html.spec.whatwg.org/multipage/input.html#input-activation-behavior
|
||||
void HTMLInputElement::run_input_activation_behavior()
|
||||
{
|
||||
if (type() == "checkbox" || type() == "radio") {
|
||||
if (type_state() == TypeAttributeState::Checkbox || type_state() == TypeAttributeState::RadioButton) {
|
||||
// 1. If the element is not connected, then return.
|
||||
if (!is_connected())
|
||||
return;
|
||||
|
@ -100,7 +100,7 @@ void HTMLInputElement::run_input_activation_behavior()
|
|||
auto change_event = DOM::Event::create(HTML::EventNames::change);
|
||||
change_event->set_bubbles(true);
|
||||
dispatch_event(move(change_event));
|
||||
} else if (type() == "submit") {
|
||||
} else if (type_state() == TypeAttributeState::SubmitButton) {
|
||||
RefPtr<HTMLFormElement> form;
|
||||
// 1. If the element does not have a form owner, then return.
|
||||
if (!(form = this->form()))
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue