mirror of
https://github.com/fergalmoran/ladybird.git
synced 2026-01-03 15:16:14 +00:00
LibWeb: Set textarea rows and cols default value if 0
The cols and rows attributes are limited to only positive numbers with fallback. The cols IDL attribute's default value is 20. The rows IDL attribute's default value is 2. The default value was returned only for the negative number. I added an additional check for the case when the attribute is 0 to match the specification.
This commit is contained in:
@@ -291,7 +291,7 @@ unsigned HTMLTextAreaElement::cols() const
|
||||
{
|
||||
// The cols and rows attributes are limited to only positive numbers with fallback. The cols IDL attribute's default value is 20.
|
||||
if (auto cols_string = get_attribute(HTML::AttributeNames::cols); cols_string.has_value()) {
|
||||
if (auto cols = parse_non_negative_integer(*cols_string); cols.has_value())
|
||||
if (auto cols = parse_non_negative_integer(*cols_string); cols.has_value() && *cols > 0)
|
||||
return *cols;
|
||||
}
|
||||
return 20;
|
||||
@@ -307,7 +307,7 @@ unsigned HTMLTextAreaElement::rows() const
|
||||
{
|
||||
// The cols and rows attributes are limited to only positive numbers with fallback. The rows IDL attribute's default value is 2.
|
||||
if (auto rows_string = get_attribute(HTML::AttributeNames::rows); rows_string.has_value()) {
|
||||
if (auto rows = parse_non_negative_integer(*rows_string); rows.has_value())
|
||||
if (auto rows = parse_non_negative_integer(*rows_string); rows.has_value() && *rows > 0)
|
||||
return *rows;
|
||||
}
|
||||
return 2;
|
||||
|
||||
Reference in New Issue
Block a user