ladybird/Libraries/LibWeb/Layout/TextInputBox.h
Andreas Kling ec29db716c LibWeb: Size appearance-none text inputs for max-content
Use the text-control auto content size when calculating max-content
width for primitive text input widgets. CSS Sizing treats cyclic
percentage preferred sizes as initial values for non-replaced
max-content contributions, so an `appearance: none` input with
`width: 100%` should contribute its `width: auto` size instead of
collapsing to zero.

Keep the min-content path unchanged so the percentage-sized replaced
element rule can still compress non-button-like input controls for
flex automatic minimum sizing. Add coverage for an inline-flex
control matching the GitHub file search layout.
2026-05-20 22:31:38 +02:00

31 lines
939 B
C++

/*
* Copyright (c) 2025-2026, Jonathan Gamble <gamblej@gmail.com>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
#pragma once
#include <LibWeb/HTML/HTMLInputElement.h>
#include <LibWeb/Layout/BlockContainer.h>
namespace Web::Layout {
class TextInputBox : public BlockContainer {
GC_CELL(TextInputBox, BlockContainer);
GC_DECLARE_ALLOCATOR(TextInputBox);
public:
TextInputBox(DOM::Document&, GC::Ptr<DOM::Element>, GC::Ref<CSS::ComputedProperties>);
HTML::HTMLInputElement const& dom_node() const { return static_cast<HTML::HTMLInputElement const&>(*Box::dom_node()); }
static CSS::SizeWithAspectRatio auto_content_box_size_for_text_control(HTML::HTMLInputElement const&, Box const&);
virtual ~TextInputBox() override = default;
private:
virtual CSS::SizeWithAspectRatio compute_auto_content_box_size() const override;
virtual bool has_auto_content_box_size() const override { return true; }
};
}