Truly independent web browser
LibWeb: Place an outside list marker outside the list item’s border box
sideshowbarker3e4468fcec63
diff --git a/Libraries/LibWeb/Rust/src/layout/block_formatting_context.rs b/Libraries/LibWeb/Rust/src/layout/block_formatting_context.rsindex 6aeaa3e9f0a..40c8a68cd91 100644--- a/Libraries/LibWeb/Rust/src/layout/block_formatting_context.rs+++ b/Libraries/LibWeb/Rust/src/layout/block_formatting_context.rs@@ -3029,10 +3029,19 @@ impl<'pass> BlockFormattingContext<'pass> {let marker_block_size = marker_metrics.content_block_size();let marker_inline_size = marker_metrics.content_inline_size();let list_item_style = self.style(list_item.node);+ // https://drafts.csswg.org/css-lists-3/#valdef-list-style-position-outside+ // "If the list item is an inline box: [...] Otherwise, the marker box is placed outside the principal block+ // box".+ // NB: So the marker ends at the start of the list item's border box, rather than of its content box: Padding+ // and borders at the start of the list item move its contents, but not its marker.+ let collapsed = list_item.cells.uses_collapsing_borders_model();let marker_inline_offset = if list_item_style.direction() == direction::LTR {- inline_space_used_before_list_item_elements_formatted.left - marker_inline_size+ inline_space_used_before_list_item_elements_formatted.left+ - list_item.cells.border_box_left(collapsed)+ - marker_inline_size} else {- list_item.cells.content_inline_size - inline_space_used_before_list_item_elements_formatted.right+ list_item.cells.content_inline_size + list_item.cells.border_box_right(collapsed)+ - inline_space_used_before_list_item_elements_formatted.right};let marker_block_offset = if let Some(list_item_first_baseline) = list_item_first_baseline&& let Some(marker_first_baseline) = marker_box.baselines.firstdiff --git a/Tests/LibWeb/Ref/expected/list-item-outside-marker-outside-padding-and-border-ref.html b/Tests/LibWeb/Ref/expected/list-item-outside-marker-outside-padding-and-border-ref.htmlnew file mode 100644index 00000000000..a8d8125ff92--- /dev/null+++ b/Tests/LibWeb/Ref/expected/list-item-outside-marker-outside-padding-and-border-ref.html@@ -0,0 +1,28 @@+<!DOCTYPE html>+<style>+@font-face {+ font-family: Ahem;+ src: url("../data/fonts/Ahem.ttf");+}++body {+ margin: 0;+ font: 20px/20px Ahem;+}++ol {+ margin: 0 0 0 100px;+ padding: 0;+}++[dir="rtl"] {+ margin: 0 100px 0 0;+}+</style>+<ol>+ <li><div style="margin-left: 40px">XX</div></li>+ <li><div style="margin-left: 30px">XX</div></li>+</ol>+<ol dir="rtl">+ <li><div style="margin-right: 40px">XX</div></li>+</ol>diff --git a/Tests/LibWeb/Ref/input/list-item-outside-marker-outside-padding-and-border.html b/Tests/LibWeb/Ref/input/list-item-outside-marker-outside-padding-and-border.htmlnew file mode 100644index 00000000000..15a394704fc--- /dev/null+++ b/Tests/LibWeb/Ref/input/list-item-outside-marker-outside-padding-and-border.html@@ -0,0 +1,45 @@+<!DOCTYPE html>+<link rel="match" href="../expected/list-item-outside-marker-outside-padding-and-border-ref.html">+<style>+@font-face {+ font-family: Ahem;+ src: url("../data/fonts/Ahem.ttf");+}++body {+ margin: 0;+ font: 20px/20px Ahem;+}++/* An outside marker is placed outside the list item's border box, so the start padding and border of the list item+ move its contents but not its marker. */+ol {+ margin: 0 0 0 100px;+ padding: 0;+}++.padding {+ padding-left: 40px;+}++.border-and-padding {+ border-left: 10px solid transparent;+ padding-left: 20px;+}++[dir="rtl"] {+ margin: 0 100px 0 0;+}++[dir="rtl"] .padding {+ padding-left: 0;+ padding-right: 40px;+}+</style>+<ol>+ <li class="padding">XX</li>+ <li class="border-and-padding">XX</li>+</ol>+<ol dir="rtl">+ <li class="padding">XX</li>+</ol>