Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
259 changes: 162 additions & 97 deletions Libraries/LibWeb/Rust/src/layout/block_formatting_context.rs

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions Libraries/LibWeb/Rust/src/layout/geometry.rs
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@ pub(crate) struct RootSizingDirectives {
pub(crate) table_box_content_block_offset_in_wrapper: Option<CssPixels>,
pub(crate) adopt_automatic_content_block_size: bool,
pub(crate) float_avoidance_inline_size: Option<CssPixels>,
pub(crate) outer_float_intrusion_before_list_item_children: SpaceUsedByFloats,
}

#[derive(Clone, Copy, Debug, PartialEq, Eq)]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -905,9 +905,7 @@ impl<'context, 'pass> InlineFormattingContext<'context, 'pass> {
}
ItemType::FloatingElement => {
line_builder.commit_pending_margin_before_float();
if !self.facts(item.node).is_list_item_marker_box() {
self.create_used_values(item.node, self.input.containing_block_constraints);
}
self.create_used_values(item.node, self.input.containing_block_constraints);
self.clear_floating_boxes(item.node);
line_builder.set_unbreakable_run_inline_size_interrupted_by_float(
iterator.next_non_whitespace_sequence_inline_size(self),
Expand Down
10 changes: 2 additions & 8 deletions Libraries/LibWeb/Rust/src/layout/inline_level_iterator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -185,13 +185,7 @@ impl<'iterator, 'context, 'pass> InlineLevelIteratorGenerator<'iterator, 'contex
self.visited_fragmented_inlines.push(node);
}
let constraints = self.context().input.containing_block_constraints;
let used = if self.context().facts(node).is_list_item_marker_box() {
self.context()
.try_used_pointer(node)
.expect("list marker must have precreated used values")
} else {
self.context().create_used_values(node, constraints)
};
let used = self.context().create_used_values(node, constraints);
let style = self.context().style(node);
let basis = constraints.inline_basis();
used.margin_top.set(style.margin_top().to_px(basis));
Expand Down Expand Up @@ -552,7 +546,7 @@ impl<'iterator, 'context, 'pass> InlineLevelIteratorGenerator<'iterator, 'contex
return Some(Item::new(ItemType::BlockLevelBox, node));
}

let used = if facts.is_list_item_marker_box() || self.box_model_node_stack.last().copied() == Some(node) {
let used = if self.box_model_node_stack.last().copied() == Some(node) {
self.context()
.try_used_pointer(node)
.expect("inline box must have precreated used values")
Expand Down
23 changes: 1 addition & 22 deletions Libraries/LibWeb/Rust/src/layout/layout_state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1031,28 +1031,7 @@ impl LayoutState {
used.content_inline_size.set(content_inline_size.unwrap_or_default());
used.content_block_size.set(content_block_size.unwrap_or_default());

let used = self.used_values.allocate(slot_index, used);

let list_item_marker = facts.is_list_item_box().then(|| facts.list_item_marker());
if let Some(list_item_marker) = list_item_marker.filter(|marker| !marker.is_invalid()) {
let marker_slot_index = callbacks.slot_index(list_item_marker);
if self.used_values.get(marker_slot_index).is_none() {
// List markers inherit only bases that were already definite
// when their list item entry was created.
let marker_constraints = ContainingBlockConstraints {
percentage_basis_inline_size: used
.has_definite_inline_size()
.then_some(used.content_inline_size.get()),
percentage_basis_block_size: used
.has_definite_block_size()
.then_some(used.content_block_size.get()),
..ContainingBlockConstraints::default()
};
self.create_used_values(callbacks, list_item_marker, marker_constraints);
}
}

used
self.used_values.allocate(slot_index, used)
}

pub(crate) fn populate_from_paintable(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Viewport <#document> at [0,0] [0+0+0 800 0+0+0] [0+0+0 600 0+0+0] [BFC] children
BlockContainer <ul> at [48,16] [0+0+40 744 0+0+0] [16+0+0 0 0+0+16] children: inline
TextNode <#text> (not painted)
ListItemBox <li> at [728.265625,16] floating [0+0+0 63.734375 0+0+0] [0+0+0 24 0+0+0] [BFC] children: not-inline
ListItemMarkerBox <(anonymous)> at [728.265625,16] [0+0+0 0 0+0+0] [0+0+0 0 0+0+0] [BFC] children: not-inline
ListItemMarkerBox <(anonymous)> at [714.265625,21] [0+0+0 6 0+0+0] [0+0+0 6 0+0+0] [BFC] children: not-inline
BlockContainer <(anonymous)> at [728.265625,16] [0+0+0 63.734375 0+0+0] [0+0+0 0 0+0+0] children: inline
TextNode <#text> (not painted)
BlockContainer <form> at [728.265625,16] [0+0+0 63.734375 0+0+0] [0+0+0 24 0+0+0] children: inline
Expand Down Expand Up @@ -37,7 +37,7 @@ ViewportPaintable (Viewport<#document>) [0,0 800x600]
PaintableWithLines (BlockContainer<BODY>) [8,16 784x0]
PaintableWithLines (BlockContainer<UL>) [8,16 784x0]
PaintableWithLines (ListItemBox<LI>) [728.265625,16 63.734375x24]
MarkerPaintable (ListItemMarkerBox(anonymous)) [728.265625,16 0x0]
MarkerPaintable (ListItemMarkerBox(anonymous)) [714.265625,21 6x6]
PaintableWithLines (BlockContainer(anonymous)) [728.265625,16 63.734375x0]
PaintableWithLines (BlockContainer<FORM>) [728.265625,16 63.734375x24]
FieldSetPaintable (FieldSetBox<FIELDSET>) [728.265625,16 63.734375x24]
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
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 42 0+0+0] [BFC] children: not-inline
BlockContainer <body> at [0,0] [0+0+0 800 0+0+0] [0+0+0 42 0+0+0] children: not-inline
BlockContainer <ul> at [100,0] [0+0+100 700 0+0+0] [0+0+0 42 0+0+0] children: not-inline
BlockContainer <(anonymous)> at [100,0] [0+0+0 700 0+0+0] [0+0+0 0 0+0+0] children: inline
TextNode <#text> (not painted)
ListItemBox <li.h5> at [100,0] [0+0+0 700 0+0+0] [0+0+0 5 0+0+0] children: inline
frag 0 from TextNode start: 0, length: 43, rect: [100,0 354.390625x16] baseline: 12.796875
"specified height wins over the marker floor"
ListItemMarkerBox <(anonymous)> at [86,5] [0+0+0 6 0+0+0] [0+0+0 6 0+0+0] [BFC] children: not-inline
TextNode <#text> (not painted)
BlockContainer <(anonymous)> at [100,5] [0+0+0 700 0+0+0] [0+0+0 0 0+0+0] children: inline
TextNode <#text> (not painted)
ListItemBox <li.mh5> at [100,5] [0+0+0 700 0+0+0] [0+0+0 5 0+0+0] children: inline
frag 0 from TextNode start: 0, length: 40, rect: [100,5 342.203125x16] baseline: 12.796875
"max-height clamps below the marker floor"
ListItemMarkerBox <(anonymous)> at [86,10] [0+0+0 6 0+0+0] [0+0+0 6 0+0+0] [BFC] children: not-inline
TextNode <#text> (not painted)
BlockContainer <(anonymous)> at [100,10] [0+0+0 700 0+0+0] [0+0+0 0 0+0+0] children: inline
TextNode <#text> (not painted)
ListItemBox <li> at [100,10] [0+0+0 700 0+0+0] [0+0+0 16 0+0+0] children: not-inline
ListItemMarkerBox <(anonymous)> at [86,15] [0+0+0 6 0+0+0] [0+0+0 6 0+0+0] [BFC] children: not-inline
BlockContainer <(anonymous)> at [100,26] [0+0+0 700 0+0+0] [0+0+0 0 0+0+0] children: inline
TextNode <#text> (not painted)
ListItemBox <li> at [100,26] [0+0+0 700 0+0+0] [0+0+0 16 0+0+0] children: inline
frag 0 from TextNode start: 0, length: 21, rect: [100,26 172.828125x16] baseline: 12.796875
"automatic height item"
ListItemMarkerBox <(anonymous)> at [86,31] [0+0+0 6 0+0+0] [0+0+0 6 0+0+0] [BFC] children: not-inline
TextNode <#text> (not painted)
BlockContainer <(anonymous)> at [100,42] [0+0+0 700 0+0+0] [0+0+0 0 0+0+0] children: inline
TextNode <#text> (not painted)
BlockContainer <(anonymous)> at [0,42] [0+0+0 800 0+0+0] [0+0+0 0 0+0+0] children: inline
TextNode <#text> (not painted)

ViewportPaintable (Viewport<#document>) [0,0 800x600]
PaintableWithLines (BlockContainer<HTML>) [0,0 800x42]
PaintableWithLines (BlockContainer<BODY>) [0,0 800x42]
PaintableWithLines (BlockContainer<UL>) [0,0 800x42]
PaintableWithLines (BlockContainer(anonymous)) [100,0 700x0]
PaintableWithLines (ListItemBox<LI>.h5) [100,0 700x5]
MarkerPaintable (ListItemMarkerBox(anonymous)) [86,5 6x6]
PaintableWithLines (BlockContainer(anonymous)) [100,5 700x0]
PaintableWithLines (ListItemBox<LI>.mh5) [100,5 700x5]
MarkerPaintable (ListItemMarkerBox(anonymous)) [86,10 6x6]
PaintableWithLines (BlockContainer(anonymous)) [100,10 700x0]
PaintableWithLines (ListItemBox<LI>) [100,10 700x16]
MarkerPaintable (ListItemMarkerBox(anonymous)) [86,15 6x6]
PaintableWithLines (BlockContainer(anonymous)) [100,26 700x0]
PaintableWithLines (ListItemBox<LI>) [100,26 700x16]
MarkerPaintable (ListItemMarkerBox(anonymous)) [86,31 6x6]
PaintableWithLines (BlockContainer(anonymous)) [100,42 700x0]
PaintableWithLines (BlockContainer(anonymous)) [0,42 800x0]

SC for Viewport<#document> [0,0 800x600] (z-index: auto)
SC for BlockContainer<HTML> [0,0 800x42] (z-index: auto)
36 changes: 36 additions & 0 deletions Tests/LibWeb/Layout/expected/list-marker-in-abspos-list-item.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
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 24 0+0+0] [BFC] children: not-inline
BlockContainer <body> at [0,0] [0+0+0 800 0+0+0] [0+0+0 24 0+0+0] children: not-inline
BlockContainer <ul> at [100,0] [0+0+100 700 0+0+0] [0+0+0 24 0+0+0] children: not-inline
BlockContainer <(anonymous)> at [100,0] [0+0+0 700 0+0+0] [0+0+0 0 0+0+0] children: inline
TextNode <#text> (not painted)
ListItemBox <li> at [100,0] [0+0+0 700 0+0+0] [0+0+0 24 0+0+0] children: inline
frag 0 from TextNode start: 0, length: 7, rect: [100,4 54.421875x16] baseline: 12.796875
"in flow"
ListItemMarkerBox <(anonymous)> at [86,9] [0+0+0 6 0+0+0] [0+0+0 6 0+0+0] [BFC] children: not-inline
TextNode <#text> (not painted)
BlockContainer <(anonymous)> at [100,24] [0+0+0 700 0+0+0] [0+0+0 0 0+0+0] children: inline
TextNode <#text> (not painted)
ListItemBox <li.abs> at [300,100] positioned [0+0+0 169.15625 0+0+0] [0+0+0 24 0+0+0] [BFC] children: inline
frag 0 from TextNode start: 0, length: 21, rect: [300,104 169.15625x16] baseline: 12.796875
"absolutely positioned"
ListItemMarkerBox <(anonymous)> at [286,109] [0+0+0 6 0+0+0] [0+0+0 6 0+0+0] [BFC] children: not-inline
TextNode <#text> (not painted)
TextNode <#text> (not painted)
BlockContainer <(anonymous)> at [0,24] [0+0+0 800 0+0+0] [0+0+0 0 0+0+0] children: inline
TextNode <#text> (not painted)

ViewportPaintable (Viewport<#document>) [0,0 800x600]
PaintableWithLines (BlockContainer<HTML>) [0,0 800x24]
PaintableWithLines (BlockContainer<BODY>) [0,0 800x24]
PaintableWithLines (BlockContainer<UL>) [0,0 800x24]
PaintableWithLines (BlockContainer(anonymous)) [100,0 700x0]
PaintableWithLines (ListItemBox<LI>) [100,0 700x24]
MarkerPaintable (ListItemMarkerBox(anonymous)) [86,9 6x6]
PaintableWithLines (BlockContainer(anonymous)) [100,24 700x0]
PaintableWithLines (ListItemBox<LI>.abs) [300,100 169.15625x24]
MarkerPaintable (ListItemMarkerBox(anonymous)) [286,109 6x6]
PaintableWithLines (BlockContainer(anonymous)) [0,24 800x0]

SC for Viewport<#document> [0,0 800x600] (z-index: auto)
SC for BlockContainer<HTML> [0,0 800x24] (z-index: auto)
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
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 24 0+0+0] [BFC] children: not-inline
BlockContainer <body> at [0,0] [0+0+0 800 0+0+0] [0+0+0 24 0+0+0] children: not-inline
Box <ul> at [100,0] flex-container(row) [0+0+100 700 0+0+0] [0+0+0 24 0+0+0] [FFC] children: not-inline
BlockContainer <(anonymous)> (not painted) [BFC] children: inline
TextNode <#text> (not painted)
ListItemBox <li> at [100,0] flex-item [0+0+0 28.6875 0+0+0] [0+0+0 24 0+0+0] [BFC] children: inline
frag 0 from TextNode start: 0, length: 3, rect: [100,4 28.6875x16] baseline: 12.796875
"one"
ListItemMarkerBox <(anonymous)> at [86,9] [0+0+0 6 0+0+0] [0+0+0 6 0+0+0] [BFC] children: not-inline
TextNode <#text> (not painted)
BlockContainer <(anonymous)> (not painted) [BFC] children: inline
TextNode <#text> (not painted)
ListItemBox <li> at [168.6875,0] flex-item [0+0+0 28.4375 0+0+0] [0+0+0 24 0+0+0] [BFC] children: inline
frag 0 from TextNode start: 0, length: 3, rect: [168.6875,4 28.4375x16] baseline: 12.796875
"two"
ListItemMarkerBox <(anonymous)> at [154.6875,9] [0+0+0 6 0+0+0] [0+0+0 6 0+0+0] [BFC] children: not-inline
TextNode <#text> (not painted)
BlockContainer <(anonymous)> (not painted) [BFC] children: inline
TextNode <#text> (not painted)
BlockContainer <(anonymous)> at [0,24] [0+0+0 800 0+0+0] [0+0+0 0 0+0+0] children: inline
TextNode <#text> (not painted)

ViewportPaintable (Viewport<#document>) [0,0 800x600]
PaintableWithLines (BlockContainer<HTML>) [0,0 800x24]
PaintableWithLines (BlockContainer<BODY>) [0,0 800x24]
Paintable (Box<UL>) [0,0 800x24]
PaintableWithLines (ListItemBox<LI>) [100,0 28.6875x24]
MarkerPaintable (ListItemMarkerBox(anonymous)) [86,9 6x6]
PaintableWithLines (ListItemBox<LI>) [168.6875,0 28.4375x24]
MarkerPaintable (ListItemMarkerBox(anonymous)) [154.6875,9 6x6]
PaintableWithLines (BlockContainer(anonymous)) [0,24 800x0]

SC for Viewport<#document> [0,0 800x600] (z-index: auto)
SC for BlockContainer<HTML> [0,0 800x24] (z-index: auto)
32 changes: 32 additions & 0 deletions Tests/LibWeb/Layout/expected/list-marker-in-floating-list-item.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
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 24 0+0+0] [BFC] children: not-inline
BlockContainer <body> at [0,0] [0+0+0 800 0+0+0] [0+0+0 0 0+0+0] children: not-inline
BlockContainer <ul> at [100,0] [0+0+100 700 0+0+0] [0+0+0 0 0+0+0] children: inline
TextNode <#text> (not painted)
ListItemBox <li.left> at [100,0] floating [0+0+0 80.828125 0+0+0] [0+0+0 24 0+0+0] [BFC] children: inline
frag 0 from TextNode start: 0, length: 11, rect: [100,4 80.828125x16] baseline: 12.796875
"floats left"
ListItemMarkerBox <(anonymous)> at [86,9] [0+0+0 6 0+0+0] [0+0+0 6 0+0+0] [BFC] children: not-inline
TextNode <#text> (not painted)
TextNode <#text> (not painted)
ListItemBox <li.right> at [708.3125,0] floating [0+0+0 91.6875 0+0+0] [0+0+0 24 0+0+0] [BFC] children: inline
frag 0 from TextNode start: 0, length: 12, rect: [708.3125,4 91.6875x16] baseline: 12.796875
"floats right"
ListItemMarkerBox <(anonymous)> at [694.3125,9] [0+0+0 6 0+0+0] [0+0+0 6 0+0+0] [BFC] children: not-inline
TextNode <#text> (not painted)
TextNode <#text> (not painted)
BlockContainer <(anonymous)> at [0,0] [0+0+0 800 0+0+0] [0+0+0 0 0+0+0] children: inline
TextNode <#text> (not painted)

ViewportPaintable (Viewport<#document>) [0,0 800x600]
PaintableWithLines (BlockContainer<HTML>) [0,0 800x24]
PaintableWithLines (BlockContainer<BODY>) [0,0 800x0]
PaintableWithLines (BlockContainer<UL>) [0,0 800x0]
PaintableWithLines (ListItemBox<LI>.left) [100,0 80.828125x24]
MarkerPaintable (ListItemMarkerBox(anonymous)) [86,9 6x6]
PaintableWithLines (ListItemBox<LI>.right) [708.3125,0 91.6875x24]
MarkerPaintable (ListItemMarkerBox(anonymous)) [694.3125,9 6x6]
PaintableWithLines (BlockContainer(anonymous)) [0,0 800x0]

SC for Viewport<#document> [0,0 800x600] (z-index: auto)
SC for BlockContainer<HTML> [0,0 800x24] (z-index: auto)
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
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 64 0+0+0] [BFC] children: not-inline
BlockContainer <body> at [0,0] [0+0+0 800 0+0+0] [0+0+0 64 0+0+0] children: not-inline
BlockContainer <ul> at [100,0] [0+0+100 700 0+0+0] [0+0+0 64 0+0+0] children: not-inline
BlockContainer <(anonymous)> at [100,0] [0+0+0 700 0+0+0] [0+0+0 0 0+0+0] children: inline
TextNode <#text> (not painted)
ListItemBox <li.flow-root> at [100,0] [0+0+0 700 0+0+0] [0+0+0 24 0+0+0] [BFC] children: inline
frag 0 from TextNode start: 0, length: 19, rect: [100,4 148.484375x16] baseline: 12.796875
"flow-root list item"
ListItemMarkerBox <(anonymous)> at [86,9] [0+0+0 6 0+0+0] [0+0+0 6 0+0+0] [BFC] children: not-inline
TextNode <#text> (not painted)
BlockContainer <(anonymous)> at [100,24] [0+0+0 700 0+0+0] [0+0+0 0 0+0+0] children: inline
TextNode <#text> (not painted)
ListItemBox <li.clipped> at [100,24] [0+0+0 700 0+0+0] [0+0+0 40 0+0+0] [BFC] children: inline
frag 0 from TextNode start: 0, length: 25, rect: [100,28 197.609375x16] baseline: 12.796875
"overflow hidden list item"
ListItemMarkerBox <(anonymous)> at [86,33] [0+0+0 6 0+0+0] [0+0+0 6 0+0+0] [BFC] children: not-inline
TextNode <#text> (not painted)
BlockContainer <(anonymous)> at [100,64] [0+0+0 700 0+0+0] [0+0+0 0 0+0+0] children: inline
TextNode <#text> (not painted)
BlockContainer <(anonymous)> at [0,64] [0+0+0 800 0+0+0] [0+0+0 0 0+0+0] children: inline
TextNode <#text> (not painted)

ViewportPaintable (Viewport<#document>) [0,0 800x600]
PaintableWithLines (BlockContainer<HTML>) [0,0 800x64]
PaintableWithLines (BlockContainer<BODY>) [0,0 800x64]
PaintableWithLines (BlockContainer<UL>) [0,0 800x64]
PaintableWithLines (BlockContainer(anonymous)) [100,0 700x0]
PaintableWithLines (ListItemBox<LI>.flow-root) [100,0 700x24]
MarkerPaintable (ListItemMarkerBox(anonymous)) [86,9 6x6]
PaintableWithLines (BlockContainer(anonymous)) [100,24 700x0]
PaintableWithLines (ListItemBox<LI>.clipped) [100,24 700x40]
MarkerPaintable (ListItemMarkerBox(anonymous)) [86,33 6x6]
PaintableWithLines (BlockContainer(anonymous)) [100,64 700x0]
PaintableWithLines (BlockContainer(anonymous)) [0,64 800x0]

SC for Viewport<#document> [0,0 800x600] (z-index: auto)
SC for BlockContainer<HTML> [0,0 800x64] (z-index: auto)
Loading
Loading