From 205155a7abb9b9754cd0917901cfc04d86291820 Mon Sep 17 00:00:00 2001 From: Piotr Date: Tue, 29 Oct 2024 14:35:54 +0100 Subject: [PATCH] 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. --- Userland/Libraries/LibWeb/HTML/HTMLTextAreaElement.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Userland/Libraries/LibWeb/HTML/HTMLTextAreaElement.cpp b/Userland/Libraries/LibWeb/HTML/HTMLTextAreaElement.cpp index 60f8e53912..a9eb10ad9f 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLTextAreaElement.cpp +++ b/Userland/Libraries/LibWeb/HTML/HTMLTextAreaElement.cpp @@ -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;