Truly independent web browser
LibWeb: Don't make a list item of a box in button layout
Andreas Kling962a61a2a4d6
diff --git a/Libraries/LibWeb/Rust/src/layout/tree_builder.rs b/Libraries/LibWeb/Rust/src/layout/tree_builder.rsindex dfc46aa9ec1..ae1f8069922 100644--- a/Libraries/LibWeb/Rust/src/layout/tree_builder.rs+++ b/Libraries/LibWeb/Rust/src/layout/tree_builder.rs@@ -2829,7 +2829,18 @@ fn construct_principal_layout_node(FfiElementLayoutKind::SvgClipPath => Some(NodeKind::SVGClipBox),FfiElementLayoutKind::SvgPattern => Some(NodeKind::SVGPatternBox),FfiElementLayoutKind::Normal => {- node_kind_for_element_box_kind(box_kind, facts.display, facts.appearance)+ use crate::css::style::bridge::element_construction_fact::USES_BUTTON_LAYOUT;+ let uses_button_layout = host+ .arena()+ .with_style_store(|engine| engine.element_construction_facts(update.identity))+ & USES_BUTTON_LAYOUT+ != 0;+ // NB: The anonymous button content box holds all the children of a box in button layout, which+ // leaves no place for an outside marker beside them, so such a box is not a list item.+ match node_kind_for_element_box_kind(box_kind, facts.display, facts.appearance) {+ Some(NodeKind::ListItemBox) if uses_button_layout => Some(NodeKind::BlockContainer),+ kind => kind,+ }}};if let Some(kind) = kind {diff --git a/Tests/LibWeb/Text/expected/css/display-list-item-on-a-button.txt b/Tests/LibWeb/Text/expected/css/display-list-item-on-a-button.txtnew file mode 100644index 00000000000..180c956abdc--- /dev/null+++ b/Tests/LibWeb/Text/expected/css/display-list-item-on-a-button.txt@@ -0,0 +1,6 @@+input color displays as list-item with a box: true+input file displays as list-item with a box: true+input button displays as list-item with a box: true+input button displays as list-item with a box: true+button submit displays as flow-root with a box: true+button submit displays as flow-root with a box: truediff --git a/Tests/LibWeb/Text/input/css/display-list-item-on-a-button.html b/Tests/LibWeb/Text/input/css/display-list-item-on-a-button.htmlnew file mode 100644index 00000000000..450680211f1--- /dev/null+++ b/Tests/LibWeb/Text/input/css/display-list-item-on-a-button.html@@ -0,0 +1,20 @@+<!DOCTYPE html>+<script src="../include.js"></script>+<style>+ .item { display: list-item; }+</style>+<body>+<input class="item" type="color">+<input class="item" type="file">+<input class="item" type="button" value="button">+<input class="item" type="button" value="button" style="appearance: none">+<button class="item">text</button>+<button class="item"><div>block</div></button>+<script>+ test(() => {+ for (const element of document.querySelectorAll(".item")) {+ const { height } = element.getBoundingClientRect();+ println(`${element.localName} ${element.type} displays as ${getComputedStyle(element).display} with a box: ${height > 0}`);+ }+ });+</script>