Truly independent web browser
LibWeb: Keep block-level inputs clear of floats
sideshowbarker6f772b44eb60
diff --git a/Libraries/LibWeb/Rust/src/layout/node_facts.rs b/Libraries/LibWeb/Rust/src/layout/node_facts.rsindex bf061216f75..568597db32d 100644--- a/Libraries/LibWeb/Rust/src/layout/node_facts.rs+++ b/Libraries/LibWeb/Rust/src/layout/node_facts.rs@@ -555,6 +555,12 @@ pub(crate) fn node_creates_block_formatting_context(// "If the list item is a block container: the marker box is a block container"|| data.kind.get() == NodeKind::ListItemMarkerBox|| has_flag(data, NodeFlag::UsesButtonLayout)+ // https://www.w3.org/TR/CSS22/visuren.html#floats+ // "The border box of a table, a block-level replaced element, or an element in the normal flow that establishes+ // a new block formatting context [...] must not overlap the margin box of any floats in the same block+ // formatting context as the element itself."+ // NB: A native control whose box hosts its internal shadow tree is a replaced element all the same.+ || has_flag(data, NodeFlag::IsReplacedElement){return true;}diff --git a/Tests/LibWeb/Layout/expected/block-input-avoids-floats.txt b/Tests/LibWeb/Layout/expected/block-input-avoids-floats.txtnew file mode 100644index 00000000000..09c71f0ef18--- /dev/null+++ b/Tests/LibWeb/Layout/expected/block-input-avoids-floats.txt@@ -0,0 +1,12 @@+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 112 0+0+0] [BFC] children: not-inline+ BlockContainer <body> at [8,8] [8+0+0 300 0+0+492] [8+0+0 96 0+0+8] children: not-inline+ BlockContainer <div.float> at [8,8] floating [0+0+0 300 0+0+0] [0+0+0 40 0+0+20] [BFC] children: not-inline+ TextInputBox <input> at [13,71] [0+2+3 200 3+2+90] [0+2+1 30 1+2+0] [BFC] children: not-inline+ Box <div> at [13,71] flex-container(row) [0+0+0 200 0+0+0] [0+0+0 30 0+0+0] [FFC] children: not-inline+ BlockContainer <div> at [13,79] flex-item [0+0+0 200 0+0+0] [0+0+0 14 0+0+0] [BFC] children: inline+ frag 0 from TextNode start: 0, length: 0, rect: [13,79 0x14] baseline: 11+ TextNode <#text> (not painted)++SC for Viewport<#document> [0,0 800x600] (z-index: auto)+ SC for BlockContainer<HTML> [0,0 800x112] (z-index: auto)diff --git a/Tests/LibWeb/Layout/expected/css-line-height-zero.txt b/Tests/LibWeb/Layout/expected/css-line-height-zero.txtindex 63744e269bc..316c7f878dd 100644--- a/Tests/LibWeb/Layout/expected/css-line-height-zero.txt+++ b/Tests/LibWeb/Layout/expected/css-line-height-zero.txt@@ -1,19 +1,19 @@Viewport <#document> at [0,0] [0+0+0 800 0+0+0] [0+0+0 600 0+0+0] [BFC] children: not-inlineBlockContainer <html> at [0,0] [0+0+0 800 0+0+0] [0+0+0 68 0+0+0] [BFC] children: not-inlineBlockContainer <body> at [8,8] [8+0+0 784 0+0+8] [8+0+0 52 0+0+8] children: not-inline- TextInputBox <input#a> at [13,11] [0+2+3 159.6875 3+2+614.3125] [0+2+1 14 1+2+0] children: not-inline+ TextInputBox <input#a> at [13,11] [0+2+3 159.6875 3+2+614.3125] [0+2+1 14 1+2+0] [BFC] children: not-inlineBox <div> at [13,11] flex-container(row) [0+0+0 159.6875 0+0+0] [0+0+0 14 0+0+0] [FFC] children: not-inlineBlockContainer <div> at [13,11] flex-item [0+0+0 159.6875 0+0+0] [0+0+0 14 0+0+0] [BFC] children: inlinefrag 0 from TextNode start: 0, length: 11, rect: [13,11 76.609375x14] baseline: 11"Hello World"TextNode <#text> (not painted)- TextInputBox <input#b> at [13,31] [0+2+3 159.6875 3+2+614.3125] [0+2+1 0 1+2+0] children: not-inline+ TextInputBox <input#b> at [13,31] [0+2+3 159.6875 3+2+614.3125] [0+2+1 0 1+2+0] [BFC] children: not-inlineBox <div> at [13,31] flex-container(row) [0+0+0 159.6875 0+0+0] [0+0+0 0 0+0+0] [FFC] children: not-inlineBlockContainer <div> at [13,24] flex-item [0+0+0 159.6875 0+0+0] [0+0+0 14 0+0+0] [BFC] children: inlinefrag 0 from TextNode start: 0, length: 11, rect: [13,24 76.609375x14] baseline: 11"Hello World"TextNode <#text> (not painted)- TextInputBox <input#c> at [13,37] [0+2+3 159.6875 3+2+614.3125] [0+2+1 20 1+2+0] children: not-inline+ TextInputBox <input#c> at [13,37] [0+2+3 159.6875 3+2+614.3125] [0+2+1 20 1+2+0] [BFC] children: not-inlineBox <div> at [13,37] flex-container(row) [0+0+0 159.6875 0+0+0] [0+0+0 20 0+0+0] [FFC] children: not-inlineBlockContainer <div> at [13,37] flex-item [0+0+0 159.6875 0+0+0] [0+0+0 20 0+0+0] [BFC] children: inlinefrag 0 from TextNode start: 0, length: 11, rect: [13,40 76.609375x14] baseline: 11diff --git a/Tests/LibWeb/Layout/expected/range-input-thumb-centered-with-appearance-none.txt b/Tests/LibWeb/Layout/expected/range-input-thumb-centered-with-appearance-none.txtindex 2a1dfe8dc01..dbf52ad6cb4 100644--- a/Tests/LibWeb/Layout/expected/range-input-thumb-centered-with-appearance-none.txt+++ b/Tests/LibWeb/Layout/expected/range-input-thumb-centered-with-appearance-none.txt@@ -1,17 +1,17 @@Viewport <#document> at [0,0] [0+0+0 800 0+0+0] [0+0+0 600 0+0+0] [BFC] children: not-inlineBlockContainer <html> at [0,0] [0+0+0 800 0+0+0] [0+0+0 127 0+0+0] [BFC] children: not-inlineBlockContainer <body> at [8,8] [8+0+0 784 0+0+8] [8+0+0 111 0+0+8] children: not-inline- BlockContainer <input.custom> at [8,8] [0+0+0 200 0+0+584] [0+0+0 25 0+0+0] children: not-inline+ BlockContainer <input.custom> at [8,8] [0+0+0 200 0+0+584] [0+0+0 25 0+0+0] [BFC] children: not-inlineBox <div> at [8,8] flex-container(row) [0+0+0 200 0+0+0] [0+0+0 25 0+0+0] [FFC] children: not-inlineBlockContainer <div> at [8,8] positioned flex-item [0+0+0 200 0+0+0] [0+0+0 25 0+0+0] [BFC] children: not-inlineBlockContainer <div> at [8,8] positioned [0+0+0 100 0+0+0] [0+0+0 25 0+0+0] [BFC] children: not-inlineBlockContainer <div> at [108,8] positioned [100+0+0 25 0+0+75] [0+0+0 25 0+0+0] children: not-inline- BlockContainer <input.custom.tall> at [8,33] [0+0+0 200 0+0+584] [0+0+0 40 0+0+0] children: not-inline+ BlockContainer <input.custom.tall> at [8,33] [0+0+0 200 0+0+584] [0+0+0 40 0+0+0] [BFC] children: not-inlineBox <div> at [8,33] flex-container(row) [0+0+0 200 0+0+0] [0+0+0 40 0+0+0] [FFC] children: not-inlineBlockContainer <div> at [8,40.5] positioned flex-item [0+0+0 200 0+0+0] [0+0+0 25 0+0+0] [BFC] children: not-inlineBlockContainer <div> at [8,40.5] positioned [0+0+0 100 0+0+0] [0+0+0 25 0+0+0] [BFC] children: not-inlineBlockContainer <div> at [108,40.5] positioned [100+0+0 25 0+0+75] [0+0+0 25 0+0+0] children: not-inline- BlockContainer <input.custom.small-thumb> at [8,73] [0+0+0 200 0+0+584] [0+0+0 25 0+0+0] children: not-inline+ BlockContainer <input.custom.small-thumb> at [8,73] [0+0+0 200 0+0+584] [0+0+0 25 0+0+0] [BFC] children: not-inlineBox <div> at [8,73] flex-container(row) [0+0+0 200 0+0+0] [0+0+0 25 0+0+0] [FFC] children: not-inlineBlockContainer <div> at [8,80.5] positioned flex-item [0+0+0 200 0+0+0] [0+0+0 10 0+0+0] [BFC] children: not-inlineBlockContainer <div> at [8,80.5] positioned [0+0+0 100 0+0+0] [0+0+0 10 0+0+0] [BFC] children: not-inlinediff --git a/Tests/LibWeb/Layout/input/block-input-avoids-floats.html b/Tests/LibWeb/Layout/input/block-input-avoids-floats.htmlnew file mode 100644index 00000000000..abda1cda91e--- /dev/null+++ b/Tests/LibWeb/Layout/input/block-input-avoids-floats.html@@ -0,0 +1,8 @@+<!DOCTYPE html>+<style>+ body { width: 300px; }+ .float { float: left; width: 100%; height: 40px; margin-bottom: 20px; background: orange; }+ input { display: block; width: 200px; height: 30px; }+</style>+<div class="float"></div>+<input>