diff --git a/Tests/LibWeb/Layout/expected/input-image.txt b/Tests/LibWeb/Layout/expected/input-image.txt index 74263a5254..9f06c1d7f3 100644 --- a/Tests/LibWeb/Layout/expected/input-image.txt +++ b/Tests/LibWeb/Layout/expected/input-image.txt @@ -1,17 +1,31 @@ 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 784x120 children: not-inline - BlockContainer
at (8,8) content-size 784x120 children: inline - frag 0 from ImageBox start: 0, length: 0, rect: [8,8 120x120] baseline: 120 + BlockContainer at (8,8) content-size 784x259 children: not-inline + BlockContainer at (8,8) content-size 784x259 children: inline + frag 0 from ImageBox start: 0, length: 0, rect: [8,216 48x48] baseline: 48 + frag 1 from TextNode start: 0, length: 1, rect: [56,250 8x17] baseline: 13.296875 + " " + frag 2 from ImageBox start: 0, length: 0, rect: [64,200 64x64] baseline: 64 + frag 3 from TextNode start: 0, length: 1, rect: [128,250 8x17] baseline: 13.296875 + " " + frag 4 from ImageBox start: 0, length: 0, rect: [136,8 128x256] baseline: 256 TextNode <#text> - ImageBox at (8,8) content-size 120x120 inline-block children: not-inline + ImageBox at (8,216) content-size 48x48 inline-block children: not-inline TextNode <#text> - BlockContainer <(anonymous)> at (8,144) content-size 784x0 children: inline + ImageBox at (64,200) content-size 64x64 inline-block children: not-inline + TextNode <#text> + ImageBox at (136,8) content-size 128x256 inline-block children: not-inline + TextNode <#text> + BlockContainer <(anonymous)> at (8,283) content-size 784x0 children: inline TextNode <#text> ViewportPaintable (Viewport<#document>) [0,0 800x600] PaintableWithLines (BlockContainer) [0,0 800x600] - PaintableWithLines (BlockContainer) [8,8 784x120] overflow: [8,8 784x136] - PaintableWithLines (BlockContainer) [8,8 784x120] - ImagePaintable (ImageBox) [8,8 120x120] - PaintableWithLines (BlockContainer(anonymous)) [8,144 784x0] + PaintableWithLines (BlockContainer) [8,8 784x259] overflow: [8,8 784x275] + PaintableWithLines (BlockContainer) [8,8 784x259] + ImagePaintable (ImageBox) [8,216 48x48] + TextPaintable (TextNode<#text>) + ImagePaintable (ImageBox) [64,200 64x64] + TextPaintable (TextNode<#text>) + ImagePaintable (ImageBox) [136,8 128x256] + PaintableWithLines (BlockContainer(anonymous)) [8,283 784x0] diff --git a/Tests/LibWeb/Layout/input/input-image.html b/Tests/LibWeb/Layout/input/input-image.html index 34fb390aa5..4a108a8f3a 100644 --- a/Tests/LibWeb/Layout/input/input-image.html +++ b/Tests/LibWeb/Layout/input/input-image.html @@ -1,3 +1,5 @@ + +
diff --git a/Userland/Libraries/LibWeb/HTML/HTMLInputElement.cpp b/Userland/Libraries/LibWeb/HTML/HTMLInputElement.cpp index d623b19626..597caec823 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLInputElement.cpp +++ b/Userland/Libraries/LibWeb/HTML/HTMLInputElement.cpp @@ -26,6 +26,7 @@ #include #include #include +#include #include #include #include @@ -1311,6 +1312,24 @@ i32 HTMLInputElement::default_tab_index_value() const return 0; } +// https://html.spec.whatwg.org/multipage/input.html#image-button-state-(type=image):the-input-element-11 +void HTMLInputElement::apply_presentational_hints(CSS::StyleProperties& style) const +{ + // The input element supports dimension attributes. + if (type_state() != TypeAttributeState::ImageButton) + return; + + for_each_attribute([&](auto& name, auto& value) { + if (name == HTML::AttributeNames::width) { + if (auto parsed_value = parse_dimension_value(value)) + style.set_property(CSS::PropertyID::Width, parsed_value.release_nonnull()); + } else if (name == HTML::AttributeNames::height) { + if (auto parsed_value = parse_dimension_value(value)) + style.set_property(CSS::PropertyID::Height, parsed_value.release_nonnull()); + } + }); +} + // https://html.spec.whatwg.org/multipage/input.html#the-size-attribute unsigned HTMLInputElement::size() const { diff --git a/Userland/Libraries/LibWeb/HTML/HTMLInputElement.h b/Userland/Libraries/LibWeb/HTML/HTMLInputElement.h index 4fa885efdf..d7b60fb8aa 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLInputElement.h +++ b/Userland/Libraries/LibWeb/HTML/HTMLInputElement.h @@ -194,6 +194,7 @@ private: // ^DOM::Element virtual i32 default_tab_index_value() const override; + virtual void apply_presentational_hints(CSS::StyleProperties&) const override; // ^Layout::ImageProvider virtual bool is_image_available() const override;