1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-14 07:34:57 +00:00

LibWeb: Declare optional parse results inlined in if statements

This commit is contained in:
Bastiaan van der Plaat 2023-12-07 18:40:54 +01:00 committed by Tim Flynn
parent 1b9a961fb0
commit 3bfc2f5e95
5 changed files with 40 additions and 65 deletions

View file

@ -1166,11 +1166,9 @@ i32 HTMLInputElement::default_tab_index_value() const
unsigned HTMLInputElement::size() const
{
// The size IDL attribute is limited to only positive numbers and has a default value of 20.
auto maybe_size_string = get_attribute(HTML::AttributeNames::size);
if (maybe_size_string.has_value()) {
auto maybe_size = parse_non_negative_integer(maybe_size_string.value());
if (maybe_size.has_value())
return maybe_size.value();
if (auto size_string = get_attribute(HTML::AttributeNames::size); size_string.has_value()) {
if (auto size = parse_non_negative_integer(*size_string); size.has_value())
return *size;
}
return 20;
}