LibWeb: Implement auto_content_box_size for textarea and input

This allows default and attribute-based sizing when an axis is auto,
without overriding extrinsic sizing.
This commit is contained in:
Jonathan Gamble 2026-01-11 01:56:52 -06:00 committed by Sam Atkins
parent 7c819460ce
commit d3cdeb3ac5
Notes: github-actions[bot] 2026-02-06 10:41:00 +00:00
29 changed files with 386 additions and 102 deletions

View file

@ -21,6 +21,7 @@
#include <LibWeb/HTML/HTMLTextAreaElement.h>
#include <LibWeb/HTML/Numbers.h>
#include <LibWeb/Infra/Strings.h>
#include <LibWeb/Layout/TextAreaBox.h>
#include <LibWeb/Namespace.h>
#include <LibWeb/Selection/Selection.h>
#include <LibWeb/UIEvents/InputEvent.h>
@ -50,11 +51,6 @@ void HTMLTextAreaElement::adjust_computed_style(CSS::ComputedProperties& style)
// This is required for the internal shadow tree to work correctly in layout.
if (style.display().is_inline_outside() && style.display().is_flow_inside())
style.set_property(CSS::PropertyID::Display, CSS::DisplayStyleValue::create(CSS::Display::from_short(CSS::Display::Short::InlineBlock)));
if (style.property(CSS::PropertyID::Width).has_auto())
style.set_property(CSS::PropertyID::Width, CSS::LengthStyleValue::create(CSS::Length(cols(), CSS::LengthUnit::Ch)));
if (style.property(CSS::PropertyID::Height).has_auto())
style.set_property(CSS::PropertyID::Height, CSS::LengthStyleValue::create(CSS::Length(rows(), CSS::LengthUnit::Lh)));
}
void HTMLTextAreaElement::initialize(JS::Realm& realm)
@ -481,4 +477,9 @@ bool HTMLTextAreaElement::is_mutable() const
return enabled() && !has_attribute(AttributeNames::readonly);
}
GC::Ptr<Layout::Node> HTMLTextAreaElement::create_layout_node(GC::Ref<CSS::ComputedProperties> style)
{
return heap().allocate<Layout::TextAreaBox>(document(), *this, style);
}
}