diff --git a/Tests/LibWeb/Layout/expected/input-text-node-invalidation-on-value-change.txt b/Tests/LibWeb/Layout/expected/input-text-node-invalidation-on-value-change.txt index 390c5a7f22..9e4218415e 100644 --- a/Tests/LibWeb/Layout/expected/input-text-node-invalidation-on-value-change.txt +++ b/Tests/LibWeb/Layout/expected/input-text-node-invalidation-on-value-change.txt @@ -1,10 +1,10 @@ Viewport <#document> at (0,0) content-size 800x600 children: not-inline BlockContainer at (0,0) content-size 800x600 [BFC] children: not-inline BlockContainer at (8,8) content-size 784x21.46875 children: inline - line 0 width: 120, height: 21.46875, bottom: 21.46875, baseline: 13.53125 - frag 0 from BlockContainer start: 0, length: 0, rect: [9,9 118x19.46875] - BlockContainer at (9,9) content-size 118x19.46875 inline-block [BFC] children: not-inline - Box
at (11,10) content-size 114x17.46875 flex-container(row) [FFC] children: not-inline + line 0 width: 191.875, height: 21.46875, bottom: 21.46875, baseline: 13.53125 + frag 0 from BlockContainer start: 0, length: 0, rect: [9,9 189.875x19.46875] + BlockContainer at (9,9) content-size 189.875x19.46875 inline-block [BFC] children: not-inline + Box
at (11,10) content-size 185.875x17.46875 flex-container(row) [FFC] children: not-inline BlockContainer
at (11,10) content-size 49.734375x17.46875 flex-item [BFC] children: inline line 0 width: 49.734375, height: 17.46875, bottom: 17.46875, baseline: 13.53125 frag 0 from TextNode start: 0, length: 4, rect: [11,10 49.734375x17.46875] @@ -16,7 +16,7 @@ Viewport <#document> at (0,0) content-size 800x600 children: not-inline ViewportPaintable (Viewport<#document>) [0,0 800x600] PaintableWithLines (BlockContainer) [0,0 800x600] PaintableWithLines (BlockContainer) [8,8 784x21.46875] - PaintableWithLines (BlockContainer#foo) [8,8 120x21.46875] - PaintableBox (Box
) [9,9 118x19.46875] + PaintableWithLines (BlockContainer#foo) [8,8 191.875x21.46875] + PaintableBox (Box
) [9,9 189.875x19.46875] PaintableWithLines (BlockContainer
) [11,10 49.734375x17.46875] TextPaintable (TextNode<#text>) diff --git a/Userland/Libraries/LibWeb/CSS/Default.css b/Userland/Libraries/LibWeb/CSS/Default.css index 5bd1f55a65..d579f7e52d 100644 --- a/Userland/Libraries/LibWeb/CSS/Default.css +++ b/Userland/Libraries/LibWeb/CSS/Default.css @@ -28,9 +28,8 @@ label { /* FIXME: This is a temporary hack until we can render a native-looking frame for these. */ input:not([type=submit], input[type=button], input[type=reset], input[type=color], input[type=checkbox], input[type=radio]), textarea { border: 1px solid ButtonBorder; - min-width: 80px; min-height: 16px; - width: 120px; + width: attr(size ch, 20ch); cursor: text; overflow: hidden; } diff --git a/Userland/Libraries/LibWeb/HTML/HTMLInputElement.cpp b/Userland/Libraries/LibWeb/HTML/HTMLInputElement.cpp index a00b5d6a83..0023aa2556 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLInputElement.cpp +++ b/Userland/Libraries/LibWeb/HTML/HTMLInputElement.cpp @@ -18,6 +18,7 @@ #include #include #include +#include #include #include #include @@ -1158,6 +1159,24 @@ i32 HTMLInputElement::default_tab_index_value() const return 0; } +// https://html.spec.whatwg.org/multipage/input.html#the-size-attribute +unsigned HTMLInputElement::size() const +{ + // The size IDL attribute is limited to only positive numbers and has a default value of 20. + auto maybe_size_string = get_attribute(HTML::AttributeNames::size); + if (maybe_size_string.has_value()) { + auto maybe_size = parse_non_negative_integer(maybe_size_string.value()); + if (maybe_size.has_value()) + return maybe_size.value(); + } + return 20; +} + +WebIDL::ExceptionOr HTMLInputElement::set_size(unsigned value) +{ + return set_attribute(HTML::AttributeNames::size, MUST(String::number(value))); +} + // https://html.spec.whatwg.org/multipage/input.html#dom-input-valueasnumber WebIDL::ExceptionOr HTMLInputElement::value_as_number() const { diff --git a/Userland/Libraries/LibWeb/HTML/HTMLInputElement.h b/Userland/Libraries/LibWeb/HTML/HTMLInputElement.h index ccb22794d2..f205c4aa1b 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLInputElement.h +++ b/Userland/Libraries/LibWeb/HTML/HTMLInputElement.h @@ -97,6 +97,9 @@ public: // https://html.spec.whatwg.org/multipage/input.html#update-the-file-selection void update_the_file_selection(JS::NonnullGCPtr); + unsigned size() const; + WebIDL::ExceptionOr set_size(unsigned value); + WebIDL::ExceptionOr value_as_number() const; WebIDL::ExceptionOr set_value_as_number(double value); diff --git a/Userland/Libraries/LibWeb/HTML/HTMLInputElement.idl b/Userland/Libraries/LibWeb/HTML/HTMLInputElement.idl index cdc90655cc..7a15620636 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLInputElement.idl +++ b/Userland/Libraries/LibWeb/HTML/HTMLInputElement.idl @@ -34,7 +34,7 @@ interface HTMLInputElement : HTMLElement { [CEReactions, Reflect] attribute DOMString placeholder; [CEReactions, Reflect=readonly] attribute boolean readOnly; [CEReactions, Reflect] attribute boolean required; - // FIXME: [CEReactions] attribute unsigned long size; + [CEReactions] attribute unsigned long size; [CEReactions, Reflect] attribute DOMString src; [CEReactions, Reflect] attribute DOMString step; [CEReactions] attribute DOMString type;