Skip to content

Truly independent web browser

LibWeb: Stop the quirks percentage-height search at a button

sideshowbarker572f20c8937a
diff --git a/Libraries/LibWeb/Rust/src/layout/sizing_context.rs b/Libraries/LibWeb/Rust/src/layout/sizing_context.rs
index 29c3aaf0a54..54039f6eebc 100644
--- a/Libraries/LibWeb/Rust/src/layout/sizing_context.rs
+++ b/Libraries/LibWeb/Rust/src/layout/sizing_context.rs
@@ -1234,6 +1234,12 @@ impl<'pass, 'container> SizingContext<'pass, 'container> {
facts.is_anonymous_button_content_wrapper() || facts.is_anonymous_button_content_box()
}
+ // Whether node is a button whose content sits in the anonymous wrapper that lays it out.
+ fn hosts_anonymous_button_content(&self, node: Node) -> bool {
+ let wrapper = self.first_child(node);
+ !wrapper.is_invalid() && self.facts(wrapper).is_anonymous_button_content_wrapper()
+ }
+
fn anonymous_button_content_box(&self, button: Node) -> Option<Node> {
let wrapper = self.first_child(button);
if wrapper.is_invalid() {
@@ -1370,6 +1376,10 @@ impl<'pass, 'container> SizingContext<'pass, 'container> {
|| facts.is_table_wrapper()
{
Some(metrics.content_block_size())
+ } else if self.hosts_anonymous_button_content(containing_block) {
+ // NB: A button lays out its content as a flex container rather than as a block container, so step 4 ends
+ // the search at it, where an auto block size leaves its content no basis.
+ None
} else if facts.lays_out_in_columns() {
None
} else if facts.parent_is_flex_or_grid_container() && metrics.has_definite_block_size() {
diff --git a/Tests/LibWeb/Layout/expected/quirks-button-min-height.txt b/Tests/LibWeb/Layout/expected/quirks-button-min-height.txt
new file mode 100644
index 00000000000..47c84ded98d
--- /dev/null
+++ b/Tests/LibWeb/Layout/expected/quirks-button-min-height.txt
@@ -0,0 +1,11 @@
+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 600 0+0+0] [BFC] children: not-inline
+ BlockContainer <body> at [8,8] [8+0+0 784 0+0+8] [8+0+0 584 0+0+8] children: inline
+ frag 0 from BlockContainer start: 0, length: 0, rect: [42,22 0x12] baseline: 26
+ BlockContainer <button> at [42,22] inline-block [0+2+32 0 32+2+0] [0+2+12 12 12+2+0] [BFC] children: not-inline
+ BlockContainer <(anonymous)> at [42,22] flex-container(column) [0+0+0 0 0+0+0] [0+0+0 12 0+0+0] [FFC] children: not-inline
+ BlockContainer <(anonymous)> (not painted) [BFC] children: not-inline
+ TextNode <#text> (not painted)
+
+SC for Viewport<#document> [0,0 800x600] (z-index: auto)
+ SC for BlockContainer<HTML> [0,0 800x600] (z-index: auto)
diff --git a/Tests/LibWeb/Layout/input/quirks-button-min-height.html b/Tests/LibWeb/Layout/input/quirks-button-min-height.html
new file mode 100644
index 00000000000..819f047ac10
--- /dev/null
+++ b/Tests/LibWeb/Layout/input/quirks-button-min-height.html
@@ -0,0 +1,8 @@
+<!DOCTYPE quirks>
+<style>
+ button {
+ min-height: 40px;
+ padding: 9pt 2pc;
+ }
+</style>
+<button></button>