Truly independent web browser
LibWeb: Apply min/max-height to inline form controls with auto height
Andreas Klingc3b46b7365f9
diff --git a/Libraries/LibWeb/Rust/src/layout/sizing_context.rs b/Libraries/LibWeb/Rust/src/layout/sizing_context.rsindex d239cb0e7a6..7843165793c 100644--- a/Libraries/LibWeb/Rust/src/layout/sizing_context.rs+++ b/Libraries/LibWeb/Rust/src/layout/sizing_context.rs@@ -582,11 +582,18 @@ impl<'pass> SizingContext<'pass> {// an intrinsic height, then that intrinsic height is the used value of 'height'.// NB: The automatic height a calc-size() height resolves against is the intrinsic one, not one that follows// the width, which itself follows the resolved height.+ // NB: A min-height or max-height can stand in for 'height' here, so a length of theirs is not taken as 'auto'+ // although the box's own height is. An intrinsic sizing keyword of theirs is the intrinsic height.+ let block_size_takes_intrinsic_height = || match computed_block_size.calc_size() {+ Some(_) => computed_block_size.is_auto(),+ None => {+ (computed_block_size.is_auto() || computed_block_size.is_intrinsic_sizing_constraint())+ && self.should_treat_block_size_as_auto(node, available_space, constraints)+ }+ };if self.should_treat_inline_size_as_auto(node, available_space)&& self.style(node).width().calc_size().is_none()- && ((self.should_treat_block_size_as_auto(node, available_space, constraints)- && computed_block_size.calc_size().is_none())- || (computed_block_size.is_auto() && computed_block_size.calc_size().is_some()))+ && block_size_takes_intrinsic_height()&& let Some(height) = intrinsic.height{return height;diff --git a/Tests/LibWeb/Layout/expected/input-max-height-border-box.txt b/Tests/LibWeb/Layout/expected/input-max-height-border-box.txtindex e31040c7fe9..f6e1bd3dd4e 100644--- a/Tests/LibWeb/Layout/expected/input-max-height-border-box.txt+++ b/Tests/LibWeb/Layout/expected/input-max-height-border-box.txt@@ -1,13 +1,13 @@Viewport <#document> at [0,0] [0+0+0 800 0+0+0] [0+0+0 600 0+0+0] [BFC] children: not-inline- BlockContainer <html> at [0,0] [0+0+0 800 0+0+0] [0+0+0 49 0+0+0] [BFC] children: not-inline- BlockContainer <body> at [8,8] [8+0+0 784 0+0+8] [8+0+0 33 0+0+8] children: inline- frag 0 from TextInputBox start: 0, length: 0, rect: [12,22 60x5] baseline: 19- TextInputBox <input> at [12,22] inline-block [0+4+0 60 0+4+0] [0+4+10 5 10+4+0] [BFC] children: not-inline- Box <div> at [12,22] flex-container(row) [0+0+0 60 0+0+0] [0+0+0 5 0+0+0] [FFC] children: not-inline- BlockContainer <div> at [12,22] flex-item [0+0+0 60 0+0+0] [0+0+0 5 0+0+0] [BFC] children: inline- frag 0 from TextNode start: 0, length: 0, rect: [12,22 0x5] baseline: 4+ BlockContainer <html> at [0,0] [0+0+0 800 0+0+0] [0+0+0 48 0+0+0] [BFC] children: not-inline+ BlockContainer <body> at [8,8] [8+0+0 784 0+0+8] [8+0+0 32 0+0+8] children: inline+ frag 0 from TextInputBox start: 0, length: 0, rect: [12,22 60x4] baseline: 18.5+ TextInputBox <input> at [12,22] inline-block [0+4+0 60 0+4+0] [0+4+10 4 10+4+0] [BFC] children: not-inline+ Box <div> at [12,22] flex-container(row) [0+0+0 60 0+0+0] [0+0+0 4 0+0+0] [FFC] children: not-inline+ BlockContainer <div> at [12,21.5] flex-item [0+0+0 60 0+0+0] [0+0+0 5 0+0+0] [BFC] children: inline+ frag 0 from TextNode start: 0, length: 0, rect: [12,21.5 0x5] baseline: 4TextNode <#text> (not painted)TextNode <#text> (not painted)SC for Viewport<#document> [0,0 800x600] (z-index: auto)- SC for BlockContainer<HTML> [0,0 800x49] (z-index: auto)+ SC for BlockContainer<HTML> [0,0 800x48] (z-index: auto)diff --git a/Tests/LibWeb/Layout/expected/input-max-width-border-box.txt b/Tests/LibWeb/Layout/expected/input-max-width-border-box.txtindex a96110e5832..434a8516e2a 100644--- a/Tests/LibWeb/Layout/expected/input-max-width-border-box.txt+++ b/Tests/LibWeb/Layout/expected/input-max-width-border-box.txt@@ -1,13 +1,13 @@Viewport <#document> at [0,0] [0+0+0 800 0+0+0] [0+0+0 600 0+0+0] [BFC] children: not-inline- BlockContainer <html> at [0,0] [0+0+0 800 0+0+0] [0+0+0 33 0+0+0] [BFC] children: not-inline- BlockContainer <body> at [8,8] [8+0+0 784 0+0+8] [8+0+0 17 0+0+8] children: inline- frag 0 from TextInputBox start: 0, length: 0, rect: [23,15 20x5] baseline: 10- TextInputBox <input> at [23,15] inline-block [0+5+10 20 10+5+0] [0+5+0 5 0+5+0] [BFC] children: not-inline- Box <div> at [23,15] flex-container(row) [0+0+0 20 0+0+0] [0+0+0 5 0+0+0] [FFC] children: not-inline- BlockContainer <div> at [23,15] flex-item [0+0+0 20 0+0+0] [0+0+0 5 0+0+0] [BFC] children: inline- frag 0 from TextNode start: 0, length: 0, rect: [23,15 0x5] baseline: 4+ BlockContainer <html> at [0,0] [0+0+0 800 0+0+0] [0+0+0 34 0+0+0] [BFC] children: not-inline+ BlockContainer <body> at [8,8] [8+0+0 784 0+0+8] [8+0+0 18 0+0+8] children: inline+ frag 0 from TextInputBox start: 0, length: 0, rect: [23,15 20x6] baseline: 10.5+ TextInputBox <input> at [23,15] inline-block [0+5+10 20 10+5+0] [0+5+0 6 0+5+0] [BFC] children: not-inline+ Box <div> at [23,15] flex-container(row) [0+0+0 20 0+0+0] [0+0+0 6 0+0+0] [FFC] children: not-inline+ BlockContainer <div> at [23,15.5] flex-item [0+0+0 20 0+0+0] [0+0+0 5 0+0+0] [BFC] children: inline+ frag 0 from TextNode start: 0, length: 0, rect: [23,15.5 0x5] baseline: 4TextNode <#text> (not painted)TextNode <#text> (not painted)SC for Viewport<#document> [0,0 800x600] (z-index: auto)- SC for BlockContainer<HTML> [0,0 800x33] (z-index: auto)+ SC for BlockContainer<HTML> [0,0 800x34] (z-index: auto)diff --git a/Tests/LibWeb/Layout/expected/input-min-height-border-box.txt b/Tests/LibWeb/Layout/expected/input-min-height-border-box.txtindex 51f912bf5d7..550a9a4acf8 100644--- a/Tests/LibWeb/Layout/expected/input-min-height-border-box.txt+++ b/Tests/LibWeb/Layout/expected/input-min-height-border-box.txt@@ -1,13 +1,13 @@Viewport <#document> at [0,0] [0+0+0 800 0+0+0] [0+0+0 600 0+0+0] [BFC] children: not-inline- BlockContainer <html> at [0,0] [0+0+0 800 0+0+0] [0+0+0 43 0+0+0] [BFC] children: not-inline- BlockContainer <body> at [8,8] [8+0+0 784 0+0+8] [8+0+0 27 0+0+8] children: inline- frag 0 from TextInputBox start: 0, length: 0, rect: [11,19 60x5] baseline: 16- TextInputBox <input> at [11,19] inline-block [0+3+0 60 0+3+0] [0+3+8 5 8+3+0] [BFC] children: not-inline- Box <div> at [11,19] flex-container(row) [0+0+0 60 0+0+0] [0+0+0 5 0+0+0] [FFC] children: not-inline- BlockContainer <div> at [11,19] flex-item [0+0+0 60 0+0+0] [0+0+0 5 0+0+0] [BFC] children: inline- frag 0 from TextNode start: 0, length: 0, rect: [11,19 0x5] baseline: 4+ BlockContainer <html> at [0,0] [0+0+0 800 0+0+0] [0+0+0 66 0+0+0] [BFC] children: not-inline+ BlockContainer <body> at [8,8] [8+0+0 784 0+0+8] [8+0+0 50 0+0+8] children: inline+ frag 0 from TextInputBox start: 0, length: 0, rect: [11,19 60x28] baseline: 27.5+ TextInputBox <input> at [11,19] inline-block [0+3+0 60 0+3+0] [0+3+8 28 8+3+0] [BFC] children: not-inline+ Box <div> at [11,19] flex-container(row) [0+0+0 60 0+0+0] [0+0+0 28 0+0+0] [FFC] children: not-inline+ BlockContainer <div> at [11,30.5] flex-item [0+0+0 60 0+0+0] [0+0+0 5 0+0+0] [BFC] children: inline+ frag 0 from TextNode start: 0, length: 0, rect: [11,30.5 0x5] baseline: 4TextNode <#text> (not painted)TextNode <#text> (not painted)SC for Viewport<#document> [0,0 800x600] (z-index: auto)- SC for BlockContainer<HTML> [0,0 800x43] (z-index: auto)+ SC for BlockContainer<HTML> [0,0 800x66] (z-index: auto)diff --git a/Tests/LibWeb/Text/expected/css/inline-form-control-min-height.txt b/Tests/LibWeb/Text/expected/css/inline-form-control-min-height.txtnew file mode 100644index 00000000000..130517c98df--- /dev/null+++ b/Tests/LibWeb/Text/expected/css/inline-form-control-min-height.txt@@ -0,0 +1,5 @@+inline-input: 40px+inline-textarea: 40px+block-input: 40px+floating-input: 40px+min-content-min-height: 12pxdiff --git a/Tests/LibWeb/Text/input/css/inline-form-control-min-height.html b/Tests/LibWeb/Text/input/css/inline-form-control-min-height.htmlnew file mode 100644index 00000000000..eadd94ea6a6--- /dev/null+++ b/Tests/LibWeb/Text/input/css/inline-form-control-min-height.html@@ -0,0 +1,19 @@+<!DOCTYPE html>+<style>+ input, textarea {+ min-height: 40px;+ font: 12px SerenitySans;+ }+</style>+<input id="inline-input" value="abc">+<textarea id="inline-textarea" rows="1"></textarea>+<input id="block-input" style="display: block" value="abc">+<input id="floating-input" style="float: left" value="abc">+<input id="min-content-min-height" style="min-height: min-content" value="abc">+<script src="../include.js"></script>+<script>+ test(() => {+ for (const element of document.querySelectorAll("input, textarea"))+ println(`${element.id}: ${getComputedStyle(element).height}`);+ });+</script>