diff --git a/Userland/Libraries/LibWeb/HTML/HTMLTextAreaElement.cpp b/Userland/Libraries/LibWeb/HTML/HTMLTextAreaElement.cpp
index 92265a3b16..668a9d7cee 100644
--- a/Userland/Libraries/LibWeb/HTML/HTMLTextAreaElement.cpp
+++ b/Userland/Libraries/LibWeb/HTML/HTMLTextAreaElement.cpp
@@ -14,6 +14,7 @@
#include
#include
#include
+#include
#include
namespace Web::HTML {
@@ -95,6 +96,42 @@ void HTMLTextAreaElement::form_associated_element_was_removed(DOM::Node*)
set_shadow_root(nullptr);
}
+// https://html.spec.whatwg.org/multipage/form-elements.html#dom-textarea-cols
+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.
+ auto maybe_cols_string = get_attribute(HTML::AttributeNames::cols);
+ if (maybe_cols_string.has_value()) {
+ auto maybe_cols = parse_non_negative_integer(maybe_cols_string.value());
+ if (maybe_cols.has_value())
+ return maybe_cols.value();
+ }
+ return 20;
+}
+
+WebIDL::ExceptionOr HTMLTextAreaElement::set_cols(unsigned value)
+{
+ return set_attribute(HTML::AttributeNames::cols, MUST(String::number(value)));
+}
+
+// https://html.spec.whatwg.org/multipage/form-elements.html#dom-textarea-rows
+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.
+ auto maybe_rows_string = get_attribute(HTML::AttributeNames::rows);
+ if (maybe_rows_string.has_value()) {
+ auto maybe_rows = parse_non_negative_integer(maybe_rows_string.value());
+ if (maybe_rows.has_value())
+ return maybe_rows.value();
+ }
+ return 2;
+}
+
+WebIDL::ExceptionOr HTMLTextAreaElement::set_rows(unsigned value)
+{
+ return set_attribute(HTML::AttributeNames::rows, MUST(String::number(value)));
+}
+
void HTMLTextAreaElement::create_shadow_tree_if_needed()
{
if (shadow_root_internal())
diff --git a/Userland/Libraries/LibWeb/HTML/HTMLTextAreaElement.h b/Userland/Libraries/LibWeb/HTML/HTMLTextAreaElement.h
index f33bd10183..1a01a76709 100644
--- a/Userland/Libraries/LibWeb/HTML/HTMLTextAreaElement.h
+++ b/Userland/Libraries/LibWeb/HTML/HTMLTextAreaElement.h
@@ -69,6 +69,12 @@ public:
// https://www.w3.org/TR/html-aria/#el-textarea
virtual Optional default_role() const override { return ARIA::Role::textbox; }
+ unsigned cols() const;
+ WebIDL::ExceptionOr set_cols(unsigned value);
+
+ unsigned rows() const;
+ WebIDL::ExceptionOr set_rows(unsigned value);
+
private:
HTMLTextAreaElement(DOM::Document&, DOM::QualifiedName);
diff --git a/Userland/Libraries/LibWeb/HTML/HTMLTextAreaElement.idl b/Userland/Libraries/LibWeb/HTML/HTMLTextAreaElement.idl
index 1ef0a88ee9..3eebba5556 100644
--- a/Userland/Libraries/LibWeb/HTML/HTMLTextAreaElement.idl
+++ b/Userland/Libraries/LibWeb/HTML/HTMLTextAreaElement.idl
@@ -7,7 +7,7 @@ interface HTMLTextAreaElement : HTMLElement {
[HTMLConstructor] constructor();
[CEReactions, Reflect] attribute DOMString autocomplete;
- // FIXME: [CEReactions] attribute unsigned long cols;
+ [CEReactions] attribute unsigned long cols;
[CEReactions, Reflect=dirname] attribute DOMString dirName;
[CEReactions, Reflect] attribute boolean disabled;
readonly attribute HTMLFormElement? form;
@@ -17,7 +17,7 @@ interface HTMLTextAreaElement : HTMLElement {
[CEReactions, Reflect] attribute DOMString placeholder;
[CEReactions, Reflect=readonly] attribute boolean readOnly;
[CEReactions, Reflect] attribute boolean required;
- // FIXME: [CEReactions] attribute unsigned long rows;
+ [CEReactions] attribute unsigned long rows;
[CEReactions, Reflect] attribute DOMString wrap;
readonly attribute DOMString type;