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

@ -48,6 +48,7 @@
#include <LibWeb/Layout/CheckBox.h>
#include <LibWeb/Layout/ImageBox.h>
#include <LibWeb/Layout/RadioButton.h>
#include <LibWeb/Layout/TextInputBox.h>
#include <LibWeb/MimeSniff/MimeType.h>
#include <LibWeb/MimeSniff/Resource.h>
#include <LibWeb/Namespace.h>
@ -136,16 +137,28 @@ GC::Ptr<Layout::Node> HTMLInputElement::create_layout_node(GC::Ref<CSS::Computed
return Element::create_layout_node_for_display_type(document(), style->display(), style, this);
}
if (type_state() == TypeAttributeState::SubmitButton || type_state() == TypeAttributeState::Button || type_state() == TypeAttributeState::ResetButton)
switch (type_state()) {
case TypeAttributeState::SubmitButton:
case TypeAttributeState::Button:
case TypeAttributeState::ResetButton:
return heap().allocate<Layout::BlockContainer>(document(), this, move(style));
if (type_state() == TypeAttributeState::Checkbox)
case TypeAttributeState::Checkbox:
return heap().allocate<Layout::CheckBox>(document(), *this, move(style));
if (type_state() == TypeAttributeState::RadioButton)
case TypeAttributeState::RadioButton:
return heap().allocate<Layout::RadioButton>(document(), *this, move(style));
return Element::create_layout_node_for_display_type(document(), style->display(), style, this);
case TypeAttributeState::Text:
case TypeAttributeState::Search:
case TypeAttributeState::URL:
case TypeAttributeState::Telephone:
case TypeAttributeState::Email:
case TypeAttributeState::Password:
case TypeAttributeState::Number:
// FIXME: text padding issues
return heap().allocate<Layout::TextInputBox>(document(), *this, move(style));
default:
return Element::create_layout_node_for_display_type(document(), style->display(), style, this);
}
}
void HTMLInputElement::adjust_computed_style(CSS::ComputedProperties& style)